Dreamcas KOS help

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Dreamcas KOS help

Post by lalacomun »

Hi, a few days ago i started with dreamcast development, im working a bit with SDL, but when i try to load an image EX: SDL_Surface *img = SDL_LoadBMP("image.bmp"); it doesnt load it, i read about KOS Romdisk but i dont know how to use it with the makefile, so is there any other way for loading files???
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Dreamcas KOS help

Post by Falco Girgis »

lalacomun wrote:Hi, a few days ago i started with dreamcast development, im working a bit with SDL, but when i try to load an image EX: SDL_Surface *img = SDL_LoadBMP("image.bmp"); it doesnt load it, i read about KOS Romdisk but i dont know how to use it with the makefile, so is there any other way for loading files???
...If you aren't mounting a ramdisk/romdisk, where exactly is your image located at?

Building a romdisk in KOS is a very easy extra step in your makefile. Just look at any image/texture examples in KOS.

If you're using a coder's cable or broadband adapter, you can also stream your file directly from the host machine via the "/pc/" virtual directory:

Code: Select all

//Loads directly from your PC.
SDL_Surface *img = SDL_LoadBMP("/pc/image.bmp");
The actual location "pc" points to on the host depends on whether you're running a real Linux distro or Cygwin. You can always create a new file/print the current directory from the Dreamcast to see where the hell you are.

Keep in mind that /pc/ is extremely slow with a coder's cable, and EXREMELY fast with a BBA. I'm assuming the USB coder's cable is somewhere in between.
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Dreamcas KOS help

Post by lalacomun »

Falco Girgis wrote:
lalacomun wrote:Hi, a few days ago i started with dreamcast development, im working a bit with SDL, but when i try to load an image EX: SDL_Surface *img = SDL_LoadBMP("image.bmp"); it doesnt load it, i read about KOS Romdisk but i dont know how to use it with the makefile, so is there any other way for loading files???
...If you aren't mounting a ramdisk/romdisk, where exactly is your image located at?

Building a romdisk in KOS is a very easy extra step in your makefile. Just look at any image/texture examples in KOS.

If you're using a coder's cable or broadband adapter, you can also stream your file directly from the host machine via the "/pc/" virtual directory:

Code: Select all

//Loads directly from your PC.
SDL_Surface *img = SDL_LoadBMP("/pc/image.bmp");
The actual location "pc" points to on the host depends on whether you're running a real Linux distro or Cygwin. You can always create a new file/print the current directory from the Dreamcast to see where the hell you are.

Keep in mind that /pc/ is extremely slow with a coder's cable, and EXREMELY fast with a BBA. I'm assuming the USB coder's cable is somewhere in between.
Thanks for the response, right now im using an emulator, so i cant use /pc/image.bmp i made a new makefile, that creates a romdisk.img and a romdisk.o, but it seems that the program isnt loading the file correctly :|
now for loading the image i use the folowing code:

Code: Select all

SDL_Surface*img = SDL_LoadBMP("/rd/image.bmp");
and the image is located on a folder called romdisk
this is the makefile:

Code: Select all

TARGET = video_test

OPTFLAGS=-O3 -fomit-frame-pointer

KOS_CFLAGS+= -I$(KOS_BASE)/../kos-ports/include/SDL-1.2.9 $(OPTFLAGS) 

all: $(TARGET).bin

include $(KOS_BASE)/Makefile.rules

.SRCS	=	video_test.c \

OBJS = $(.SRCS:.c=.o)

clean:
	rm -f $(OBJS) $(TARGET).elf $(TARGET).bin 
	-rm -f romdisk.*
	
rm-elf:
	-rm -f romdisk.*

$(TARGET).elf: $(OBJS) romdisk.o
	$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET).elf $(KOS_START) \
		$(OBJS) romdisk.o -lSDL_129 -lm $(OBJEXTRA) $(KOS_LIBS)

$(TARGET).bin: $(TARGET).elf
	$(KOS_OBJCOPY) -R .stack -O binary $(TARGET).elf $(TARGET).bin

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).bin
	$(KOS_LOADER) $(TARGET).bin

dist:
	rm -f $(OBJS) romdisk.o romdisk.img
	$(KOS_STRIP) $(TARGET)
Any suggestions???
Image
User avatar
Dormoxx
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 19
Joined: Sun Feb 05, 2012 9:01 am
Current Project: Learning SFML and KallistiOS
Favorite Gaming Platforms: PC, Dreamcast, SNES
Programming Language of Choice: C++
Location: Gigazilla HQ, Kentucky
Contact:

Re: Dreamcas KOS help

Post by Dormoxx »

Do you have something like this:

Code: Select all

extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
right outside your main()?
CPU: AMD FX-6300 4GHz
Motherboard: MSI 970A-G46
GPU: Sapphire Fury X
Memory: 8GB Corsair Vengeance
OS: Windows 10
Noteables: Sega Dreamcast with Keyboard
----------------------------
YouTube: Channel
Steam: [D]ormoxx
tumblr
User avatar
lalacomun
VS Setup Wizard
VS Setup Wizard
Posts: 114
Joined: Wed Dec 28, 2011 10:18 pm
Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
Programming Language of Choice: C++
Location: Argentina
Contact:

Re: Dreamcas KOS help

Post by lalacomun »

Dormoxx wrote:Do you have something like this:

Code: Select all

extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
right outside your main()?
Dude, i feel like an idiot, i had that, but inside my main function, now is working great!! :mrgreen:
Thanks for all your responses!!
Image
User avatar
Dormoxx
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 19
Joined: Sun Feb 05, 2012 9:01 am
Current Project: Learning SFML and KallistiOS
Favorite Gaming Platforms: PC, Dreamcast, SNES
Programming Language of Choice: C++
Location: Gigazilla HQ, Kentucky
Contact:

Re: Dreamcas KOS help

Post by Dormoxx »

lalacomun wrote:
Dormoxx wrote:Do you have something like this:

Code: Select all

extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
right outside your main()?
Dude, i feel like an idiot, i had that, but inside my main function, now is working great!! :mrgreen:
Thanks for all your responses!!
Hey, no problem. The only way I knew it was supposed to be outside of main() is because when I first started with KOS, I modified the PNG example and it was there, so I kept it there. :lol:
CPU: AMD FX-6300 4GHz
Motherboard: MSI 970A-G46
GPU: Sapphire Fury X
Memory: 8GB Corsair Vengeance
OS: Windows 10
Noteables: Sega Dreamcast with Keyboard
----------------------------
YouTube: Channel
Steam: [D]ormoxx
tumblr
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Dreamcas KOS help

Post by Falco Girgis »

Dormoxx wrote:
lalacomun wrote:
Dormoxx wrote:Do you have something like this:

Code: Select all

extern uint8 romdisk[];
KOS_INIT_ROMDISK(romdisk);
right outside your main()?
Dude, i feel like an idiot, i had that, but inside my main function, now is working great!! :mrgreen:
Thanks for all your responses!!
Hey, no problem. The only way I knew it was supposed to be outside of main() is because when I first started with KOS, I modified the PNG example and it was there, so I kept it there. :lol:
Oh, snap. I was totally just reading your thread on DCemulation.org!
Post Reply