could someone post some working hello world code?

Hi.

I'm new to Saturn dev, and admittedly am getting swamped with all the various documentation for the SH2, SBL, and SGL.

I also haven't set up my toolchain yet, but lack the motivation to do so because I don't really know where to begin once that part of it is done.

Could someone please post C and/or assembler code that will do something simple, such as display "Hello World," so I can see what the basic skeleton for a Saturn app looks like, as well as maybe see some of the common library functions put to use?

I'm going to be using Yabause for my initial testing. Thanks!
 
Welcome Mirakus.

The easiest way to start Saturn Dev is to use the two sega libraries SGL and SBL. http://www.rockin-b.de/saturn/saturngametutorial/SaturnGameTutorial.htm is the best way to learn how to use the SGL.

If you wish to avoid the libraries http://vberthelot.free.fr/SX/satdev/Programs.html download some of Charles M. stuff. He is no longer part of the Saturn Dev community as are a lot of these people. So if you have any questions please ask here on the forums and do not contact the authors availible.

I have included some example code.. please note this hacked together from Rockin'Bs tutorial and may not compile.

Code:
#include <SGL.H>

#include <sddrvs.dat>

void init_VDP2()

{

    slBack1ColSet((void *)BACK_CRAM, CD_Black);

    slPriorityNbg0(7);

    slPriorityNbg1(6);

    slScrPosNbg1(toFIXED(0.0), toFIXED(0.0));

    slZoomModeNbg1(ZOOM_1);

    slZoomNbg1(toFIXED(1.0), toFIXED(1.0));            

    slScrAutoDisp(NBG0ON | NBG1ON);

}

void init_GFX()

{

    

    slInitSystem(TV_320x240, tex_SpriteTable, 1);

    slInitGouraud(gourRealMax, GOUR_REAL_MAX, GRaddr, vwork);

    slIntFunction(my_vblank);

    slTVOff();

    init_VDP2();

    slTVOn();

}

void ss_main()

{

slInitSystem(TV_320x240, tex_SpriteTable, 1);

// init sprite GPU, upload textures

init_GFX();

while(1) {

slPrint("Hello World",toFIXED(0,0));

slSynch();

}

// return to demo demo loader

// or activate multiplayer

SYS_Exit(0);

}
 
I've got some (non-SGL) code examples here. I use KPIT's toolchain for building, but using a home-built SH2 version of GCC will work just as well.
 
Thanks a lot! I know some of this info was already out there, but I didn't really know where to begin. Tonight I'm going to try to get my toolchain set up, and see if I can get some of this stuff building and running. I'm sure I'll have more questions as I go, but thanks!

Mir
 
I am pretty lost now...

I tried to compile your sample code but had several problems.

A got the following warning message:



Then it seems that he does not find library sgl.h ( SGL.H: No such file or directory. )

I looked at rockin-b's saturndemo and tried to copy some files (OBJECTS, coff.mak, makefile)

I do not understand how he tells the compiler in the saturndemo where to look for the libraries. My makefile.win does not show anything like c:\SaturnOrbit in it like in the demo.

Maybe I am just too much of a noob and my inexperience in C is a big drawback. But I would really want to know how to compile this simple example...

But it seems that the saturn dev community is pretty dead now
sad.gif
. I hope there is still some help for a tenacious beginner like me
smile.gif


edit:

Since the tutorial writes that configuring a new project is difficult I took the advice and used the existing demo and changed it a bit.

I changed "demo_loop();" to

Code:
while(1)

    {slPrint("My first Program for Saturn [img]http://segaxtreme.net/forum/images/smilies2/smile.gif[/img]",slLocate(2,5));}

and got the following result:



It is nothing big but a beginning and now I am ready to go
smile.gif


I will start by trying to understand the demo and see how far I get. Maybe this is of help for other beginners
smile.gif
Feel free to contact me

edit 2:

I tried your short code snipped Amon. It worked so far but your line

Code:
slPrint("Hello World",toFIXED(0,0));

caused an error. I got an error, because toFixed does not expect 2 parameters...

However, this line works:

Code:
slPrint("My first Program for Saturn [img]http://segaxtreme.net/forum/images/smilies2/smile.gif[/img]",slLocate(2,5));

 
Well, it's taken me a while since I first started, but I finally got my toolchain built.

I built some code successfully, but I'm not sure how to get into into the proper format to run on an emulator or system.

What else is involved once the code is built? The samples I'm using have some .S files in there as well as some linker scripts, but I'm not sure what they are or how to use them. Thanks.
 
.S files have assembly language code and data. Linker scripts tell the object loader (ld) what addresses to use for different sections; for example, it will set the code and data and bss sections to high ram. That allows a binary file to be created with everything having proper pointers.
 
Slightly off-topic but ld is just a linker. The object loader (ld.so on many systems) is not part of binutils.
 
Okay. Bear with me here. All of this is pretty new to me (targeting a machine other than PC), so I'm still kind of confused.

Really all I'm trying to do at this moment is to create a small program similar to what antorino did in the post above, just so that I can verify that I have everything working and I'm ready to take the next step.

Let's say I write the example above, what would I do after linking my built object code with the SGL static lib (assuming that's all I would have to do)? How should binary files be named? I'm clueless as to how the linker script is supposed to work, or how to make use of the instructions in the .S file. Do I need to assemble the S file link that in with everything else? Additionally, I just don't understand what the Saturn/emulator is going to look for when I load an iso.

I have the part of making the iso covered - I just don't know how to make sure all of my other files are built/set up correctly. I've done a fair scouring through the forums, but haven't found a lot of this specific setup information. I've seen a lot of good examples out there on writing code for Saturn, but still not really much on setting up that code once it's compiled and preparing it to run.
 
Back
Top