Results 1 to 3 of 3

Thread: Getting started with KOS

                  
   
  1. #1
    DCEmu Newbie
    Join Date
    May 2005
    Posts
    3
    Rep Power
    0

    Default Getting started with KOS

    Hello everybody! I've started developing for the dreamcast a little while ago. So far I have just been making stupid patterns by writing directly to the frame buffer with KOS.

    I am looking at doing something a bit more powerfull now. I want to access resources in my base directory over my serial cable connection, with the eventual hope of using them in my game.

    fs_open seems to be the right function for this, but it always returns NULL for some reason.

    Is there something I have to do with DC-Tool in order to get the directory setup? Or is my path just goofy? If anybody has some ideas, that would be great, cause I am stumped.

    Here is the source code for my little demo project.
    Code:
    #include <kos.h>
    #include <stdio.h>
    
    
    #define _RGB(r, g, b) ((r << 12)|(g << 5)|(b << 0)) 
    
    void drawPix(int x, int y, int color);
    
    int main(int argc, char **argv) {
    	int x, y;
    	int color;	
    	file_t fptr;
    	
    	fptr = fs_open("/pc/dummy.txt", O_RDONLY);	
    	
    	color = _RGB(255,255,255);
    	
        if(fptr != 0)
        {
            fs_close(fptr);
            color = _RGB(0,0,255);
        }
    	
    	/* Bother us with output only if something died */
    	dbglog_set_level(DBG_DEAD);
    	
    	/* Set the video mode */
    	vid_set_mode(DM_640x480, PM_RGB565);
    	
    	for (y=0; y<480; y++)
    		for (x=0; x<640; x++) {
    			drawPix(x,y, color);
    		}
    		
    
    	/* Pause to see the results */
    	usleep(5*1000*1000);
    
    	return 0;
    }
    
    void drawPix(int x, int y, int color)
    {
        vram_s[y*640+x] = color;
        return;
    }
    And yes, I know that the default is to read from the root directory. I put the file 'dummy/txt' in the root directory and in the base directory, so I am thinking that the problem lies with dc-tool somewhere.

  2. #2
    DCEmu Coder
    Join Date
    Apr 2004
    Location
    Portugal
    Age
    46
    Posts
    93
    Rep Power
    0

    Default

    Hi

    Since you only want to read the dummy.txt file you can read it via Romdisk, here are the changes:
    Code:
    #include <kos.h>
    #include <stdio.h>
    
    extern uint8 romdisk[];
    KOS_INIT_FLAGS(INIT_DEFAULT|INIT_MALLOCSTATS);
    KOS_INIT_ROMDISK(romdisk);
    
    #define _RGB(r, g, b) ((r << 12)|(g << 5)|(b << 0)) 
    
    void drawPix(int x, int y, int color);
    
    int main(int argc, char **argv) {
    	int x, y;
    	int color;	
    	file_t fptr;
    	
    	fptr = fs_open("/rd/dummy.txt", O_RDONLY);	
    ..........
    still you need to change the makefile to your needs on the Romdisk 'use', so check the 'Hello world' KOS example.

    or see it here:
    Code:
    #
    # Basic KallistiOS skeleton / test program
    # (c)2001 Dan Potter
    #   
    
    # Put the filename of the output binary here
    TARGET = hello.elf
    
    # List all of your C files here, but change the extension to ".o"
    OBJS = hello.o
    
    all: rm-elf $(TARGET)
    
    include $(KOS_BASE)/Makefile.rules
    
    clean:
    	-rm -f $(TARGET) $(OBJS) romdisk.*
    
    rm-elf:
    	-rm -f $(TARGET) romdisk.*
    
    # If you don't need a ROMDISK, then remove "romdisk.o" from the next few
    # lines. Also change the -l arguments to include everything you need,
    # such as -lmp3, etc.. these will need to go _before_ $(KOS_LIBS)
    $(TARGET): $(OBJS) romdisk.o
    	$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
    		$(OBJS) romdisk.o $(OBJEXTRA) $(KOS_LIBS)
    
    # You can safely remove the next two targets if you don't use a ROMDISK
    romdisk.img:
    	$(KOS_GENROMFS) -f romdisk.img -d romdisk -v
    
    romdisk.o: romdisk.img
    	$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
    
    run: $(TARGET)
    	$(KOS_LOADER) $(TARGET)
    
    dist:
    	rm -f $(OBJS) romdisk.o romdisk.img
    	$(KOS_STRIP) $(TARGET)
    -Mekanaizer-
    &&
    Don't dream, play DreamCast!!!

  3. #3
    DCEmu Newbie
    Join Date
    May 2005
    Posts
    3
    Rep Power
    0

    Default

    I'm not interested in the romdisk, that isn't teaching me what I want to know.

    I found a cheap trick that will work for me, and this is probably what I am going to do.

    Instead of messing with paths and such, I use mkisofs on my content directory to turn it into an ISO, then i just load that over with DC-Tool.

    now, if only I could get mkisofs to run from my makefile, i would be set.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •