MetaFox
April 5th, 2005, 23:25
EDIT (4/6/05): Upgraded tutorial to use KOS 1.3.x instead of 1.2.0. Uploaded a new makefile to coincide with these changes.
EDIT (4/5/05): Mental2k suggested adding comments as to what's being done in the steps. This is a good idea, so I'm updating the tutorial series with comments. Comments will be shown in red.
These tutorials should help you get started with Dreamcast development, even if you haven't coded before in your life. I'm trying to make these as newbie friendly as possible, so if you have any trouble with these, post here and let me know, so I can update them as appropriate. Here's part 2, compiling an SDL game:
1) Run a command prompt (cmd.exe, command.com depending on your version of Windows)
2) Type cd\cygwin
3) Type cygwin.bat
4) Once inside cygwin,
a) Type cd /usr/local/dc/kos1.3/kos The KOS directory
b) Type source environ.sh This loads the dcdevelopment environment variables.
5) Find a simple SDL port (for our usage right now - it should be pure SDL with no other libraries - no SDL_mixer, etc.).
a) For our purposes, grab http://www.consolevision.com/members/metafox/dreamcast/pong.zip (from gameprog.it)
b) extract it's contents to c:\cygwin\usr\local\dc\kos1.3\kos
6) now:
a) download http://www.consolevision.com/members/metafox/dreamcast/makefile.zip
b) Extract to c:\cygwin\usr\local\dc\kos1.3\kos\pong (overwrite the previous makefile) This is a makefile template. It's easy to update it for your own purposes for other ports.
7) edit makefile to change all instances of .o extensions to match every .c in the directory:
- so if you have main.c control.c game.c menu.c
- you'd have main.o control.o game.o menu.o in your makefile (don't change the .c files themselves, the .o files are just for the object files in the makefile) The .o extension stands for object files. The compiler processes the C code and outputs an object file with an .o extension
8) look for the main function - could be main() or main(argc, argv) - or something else in the parenthesis.
a)After the main function, there should be a bracket {
b)After the bracket, add fs_chdir("/cd"); This sets up the main directory as /cd/ rather than / so that the Dreamcast will recognize it.
9) Open up all the files and look for SDL_SetVideoMode
a) make sure the width is either 640 or 320 and the height is 480 or 240, and that SDL_FULLSCREEN is initialized.
- ex: SDL_SetVideoMode(640, 480, 8, SDL_FULLSCREEN) This sets up the screen size to a Dreamcast compatible screen size. 320x240 and 640x480 are the only ones that should be used on SDL for KOS. KOS supports more resolutions, but SDL KOS only supports 3 of those - the 800x600 resolution that SDL KOS supports is only available on VGA monitor setups.
10) Now, in cygwin:
a) type cd /usr/local/dc/kos1.3/kos/pong
b) type make This command processes your makefile, and sets the compiler in motion to process the c files to object files, then finally to link the object files together into a Dreamcast-compatible elf file.
Congratulations! You should now have an elf file which is now a workable SDL port. :)
You can do this for just about every SDL game that you find. Some are more difficult, but most just require these steps. This doesn't have controller support, or any other Dreamcast specific stuff. We'll look at some of that in tutorial #3.
EDIT (4/5/05): Mental2k suggested adding comments as to what's being done in the steps. This is a good idea, so I'm updating the tutorial series with comments. Comments will be shown in red.
These tutorials should help you get started with Dreamcast development, even if you haven't coded before in your life. I'm trying to make these as newbie friendly as possible, so if you have any trouble with these, post here and let me know, so I can update them as appropriate. Here's part 2, compiling an SDL game:
1) Run a command prompt (cmd.exe, command.com depending on your version of Windows)
2) Type cd\cygwin
3) Type cygwin.bat
4) Once inside cygwin,
a) Type cd /usr/local/dc/kos1.3/kos The KOS directory
b) Type source environ.sh This loads the dcdevelopment environment variables.
5) Find a simple SDL port (for our usage right now - it should be pure SDL with no other libraries - no SDL_mixer, etc.).
a) For our purposes, grab http://www.consolevision.com/members/metafox/dreamcast/pong.zip (from gameprog.it)
b) extract it's contents to c:\cygwin\usr\local\dc\kos1.3\kos
6) now:
a) download http://www.consolevision.com/members/metafox/dreamcast/makefile.zip
b) Extract to c:\cygwin\usr\local\dc\kos1.3\kos\pong (overwrite the previous makefile) This is a makefile template. It's easy to update it for your own purposes for other ports.
7) edit makefile to change all instances of .o extensions to match every .c in the directory:
- so if you have main.c control.c game.c menu.c
- you'd have main.o control.o game.o menu.o in your makefile (don't change the .c files themselves, the .o files are just for the object files in the makefile) The .o extension stands for object files. The compiler processes the C code and outputs an object file with an .o extension
8) look for the main function - could be main() or main(argc, argv) - or something else in the parenthesis.
a)After the main function, there should be a bracket {
b)After the bracket, add fs_chdir("/cd"); This sets up the main directory as /cd/ rather than / so that the Dreamcast will recognize it.
9) Open up all the files and look for SDL_SetVideoMode
a) make sure the width is either 640 or 320 and the height is 480 or 240, and that SDL_FULLSCREEN is initialized.
- ex: SDL_SetVideoMode(640, 480, 8, SDL_FULLSCREEN) This sets up the screen size to a Dreamcast compatible screen size. 320x240 and 640x480 are the only ones that should be used on SDL for KOS. KOS supports more resolutions, but SDL KOS only supports 3 of those - the 800x600 resolution that SDL KOS supports is only available on VGA monitor setups.
10) Now, in cygwin:
a) type cd /usr/local/dc/kos1.3/kos/pong
b) type make This command processes your makefile, and sets the compiler in motion to process the c files to object files, then finally to link the object files together into a Dreamcast-compatible elf file.
Congratulations! You should now have an elf file which is now a workable SDL port. :)
You can do this for just about every SDL game that you find. Some are more difficult, but most just require these steps. This doesn't have controller support, or any other Dreamcast specific stuff. We'll look at some of that in tutorial #3.