Need for a program loader ?

Instead of making your own program launcher, I think there is a way to modify a game demo CD and replace games with your programs, I managed one time to change pictures and replace a game, it worked on SSF but I never burnt it.
 
Ok I think the problem is the fact that the program will not execute at an address other then the default, 0600 4000. Anytime I change that address to anything else, the program crashes at the Sega logo.
 
1. vbt : any name/iso/bin of such a game demo CD ?

2. About producing correct code

antime wrote :

A typical case is that some hardware isn't set to a known value, as whatever value is in the registers after the machine is started happens to work. When this no longer holds, the program blows up.

it is easy for me to correctly initialize the variables I define myself, but problems may arise with the SGL's variables default values. Ideas for a checklist, or init functions ?

3. About .bin and satourne (could be related to that topic)

When I load my .bin in satourne at startup, it does not run (infinite loop, i think). If I wait for the ss animation to begin, and then load the .bin, it works properly (not every time though). I wonder wether it is my prog or satourne.

By the way, don't you think satourne's developer could answer to our problem ?
 
Originally posted by vreuzon@Jan. 20 2003, 1:31 pm

it is easy for me to correctly initialize the variables I define myself, but problems may arise with the SGL's variables default values. Ideas for a checklist, or init functions ?

I don't think you'll have too much problems with programs using SGL, I'm more concerned with programs that doesn't use Sega's libraries (eg. Charles MacDonald's test software). The things that concern me most are any interrupts and slave CPU processing started by the libs, as these would still be running when executing the loaded program. Of course, if you're only planning on loading your own SGL programs there should be less to worry about.

By the way, don't you think satourne's developer could answer to our problem ?

Sure, but that would be too easy, wouldn't it? The segadev mailing list is a good place to ask (Fabien Autrel, the author of Satourne subscribes to the list too).
 
Originally posted by slinga@Jan. 19 2003, 2:32 pm

Ok I think the problem is the fact that the program will not execute at an address other then the default, 0600 4000. Anytime I change that address to anything else, the program crashes at the Sega logo.

It took me some time to find something wrong with what you have done so far. But then I thought about your overall setup, and now I got another solution that hopefully won't cause more coasters.
smile.gif


First of all, you aren't using the IP.bin example code that is supposed to be somewhere in the SGL and documents package, right? From what I read you use a normal IP.bin from some game or maybe a demo CD/homebrew game. That would explain a few things, because if you don't write your own startup code, you are likely to have missed something. You see, to correctly load and execute a program that has been compiled to work at 00200000 (low ram), you need to put 00200000 at the mentioned offset and jump to the correct address after the code in IP.bin has ended. If you don't do so, your Saturn will always jump to the same address (say 06004000) and try to execute your program there, which will fail.

To solve this problem, simply change both occurences of 06004000 in your IP.bin, and try again.
smile.gif
If changing it is too messy, I can send you some IP.bin modified to suit your program. Alternatively, you could also use the IP.bin from games such as Alien Trilogy, Die Hard Arcade and Primal Rage. Be sure to change both occurences of the start address to the address you want to have, and there you (should) go.
 
Hmmm...I changed both occurances of 0600 4000 to 0020 0000 in the ip.bin. I then changed the slstart value in makefile to SLSTART 0x00200000. Still no luck. It crashes at the sega logo, before any text is displayed, so I doubt there's anything wrong in my program code. I'm totally out of ideas. I've been reading through the docs, maybe there's something we're missing....
 
What printf was referring to is the application initial program, ie. the code that is running while the Saturn is loading the first file into memory. If you're using a custom AIP it might not jump to the address you've specified but might have 0x6004000 hard-coded into it instead.
 
That sounds possible....seeing how the code only executes when I have it at 0600 4000.

Next question: How do I create my own ip.bin? I've been using (and modifying) an already created one. I think it was from the first sms emulator.
 
You can use the package coming with the SGL files, use a very small IP.bin from a game (see my other post) or ask me to dig one up for you.
smile.gif
 
I figured out why it wasn't executing at any value other then 0600 4000, it was commented out in the MAKEFILE. Man do I feel dumb.

Another thing I learned was, don't copy anything to 0600 0000 - 0600 4000, bad things will happen.

Here's my progess:

#include "sgl.h" // Required for basic sgl functions

#include "sgl_cd.h" // Required for cd access

#include "stdlib.h" // Don't know why I need this...don't feel like burning another cd to find out

#define MAX_FILE 128 // Needed for CD functions

#define READSECT 50 // Needed for CD functions

Sint32 dirwork[SLCD_WORK_SIZE(MAX_FILE)/sizeof(Sint32)]; // Needed for CD function

//Uint8 readbuf[(READSECT*CDBUF_FORM1/sizeof(Uint8))]; // Needed for CD function

void ss_main(void)

{

void (*readbuf)(void);

Sint32 ndir;

CDHN cdhn;

CDKEY key[2];

CDBUF buf[2];

Sint32 stat;

Sint32 len[2];

Sint32 ypos=1;

readbuf = (void*)0x6004000;



slInitSystem(TV_320x224, NULL, 1); // Initializes screen

ndir=slCdInit(MAX_FILE, dirwork); // initializes cd

slPrint("SlCdInit:", slLocate(1, ypos));

slPrintFX(toFIXED(ndir), slLocate(11, ypos));

ypos++;

key[0].cn=key[0].sm=key[0].ci=CDKEY_NONE;

key[1].cn=CDKEY_TERM;

cdhn=slCdOpen("DUKE\\BONUS.BIN", key); // opens cd

slPrint("slCdOpen:", slLocate(1,ypos));

slDispHex((Uint32)cdhn, slLocate(11, ypos));

buf[0].type=CDBUF_COPY;

buf[0].trans.copy.addr=readbuf;

buf[0].trans.copy.unit=CDBUF_FORM1;

buf[0].trans.copy.size=READSECT;

buf[1].type=CDBUF_TERM;

slCdLoadFile(cdhn,buf); // loads file from cd

ypos++;

do

{

slSynch();

stat=slCdGetStatus(cdhn, len);

slPrint("stat:", slLocate(1, ypos));

slDispHex((Uint32)stat, slLocate(7, ypos));

ypos++;

if(ypos>=27) ypos=1;

if(stat==CDSTAT_COMPLETED) break;

if(len[0]==CDBUF_FORM1* READSECT)

{

slCdResetBuf(cdhn, &(key[0]));

}



} while (stat != CDSTAT_COMPLETED);

slPrint("Bin final test 4 loaded......................", slLocate(1,ypos));



readbuf();



while(1)

{

slSynch();

}

}


I verified the memory in Satourne and the bootloader is in fact being loaded to 0020 0000 (thanks to printf for the ip.bin). Bonus.bin is being loaded to 0600 4000 as it should.

When I run the iso in Satourne, all the text shows up as it should, including the last line: "Bin Final Test Whatever...".

The only thing missing now is the fact that it's not executing the next program. Not sure why....I hope I don't need some special function.
 
A look through the includes directory brought up this file, PROCESS.H

#ifndef __PROCESS_H_

#define __PROCESS_H_

#ifdef __cplusplus

extern "C" {

#endif

int execl(const char *path, const char *argv0, ...);

int execle(const char *path, const char *argv0, ... /*, char * const *envp */);

int execlp(const char *path, const char *argv0, ...);

int execlpe(const char *path, const char *argv0, ... /*, char * const *envp */);

int execv(const char *path, char * const *argv);

int execve(const char *path, char * const *argv, char * const *envp);

int execvp(const char *path, char * const *argv);

int execvpe(const char *path, char * const *argv, char * const *envp);

int spawnl(int mode, const char *path, const char *argv0, ...);

int spawnle(int mode, const char *path, const char *argv0, ... /*, char * const *envp */);

int spawnlp(int mode, const char *path, const char *argv0, ...);

int spawnlpe(int mode, const char *path, const char *argv0, ... /*, char * const *envp */);

int spawnv(int mode, const char *path, char * const *argv);

int spawnve(int mode, const char *path, char * const *argv, char * const *envp);

int spawnvp(int mode, const char *path, char * const *argv);

int spawnvpe(int mode, const char *path, char * const *argv, char * const *envp);

#define P_WAIT 1

#define P_NOWAIT 2 /* always generates error */

#define P_OVERLAY 3

#ifdef _WIN32

#define WAIT_CHILD 1

#endif

#ifdef __cplusplus

}

#endif

#endif


Of course I have no idea idea how to use these files, something about neither a null terminated array....any tips...I'm guessing with need something like spawnl....
 
I can't see what is wrong with your code. Did you try it with satourne ? Then you should see if death tank really starts its execution by looking at the pc. (The problem might come from the loaded prog itself; you could try with a simple two lines asm prog for more clarity)

About process.h. I don't think your spawn functions can help. The "path" and "argv" parameters don't have anything to do will the saturn, since they deal with command line.

(you won't need the slSynch loop at the end when it works)
 
Hmmm it appears to crash in Satourne if I take that last slSynch() out. I should probably test on a real saturn, I'll give u results by the weekend.
 
-- That means the readbuf() call was ignored... strange.

Could you do a mixed c/assembly dump and check what's called on that instruction? Using something like this...

11) Generating mixed C/assembly listings

To generate a nice assembly listing with interspersed C source, try:

gcc -O2 -m2 -g -S foo.c

as -ahld foo.s > junk.tmp

"junk.tmp" will now contain a nicely formatted mixed C/assembly listing.
 
I get an error message:

C:\SATPROG\SATURN\Sgl\MyProj\BOOTLO~1>gcc -O2 -m2 -g -s main.c -ahld main.c > ju

nk.tmp

cc1.exe: Invalid option `-ahld'

cc1.exe: Invalid option `-ahld'

 
You're passing as arguments to gcc instead of running as, and I don't remember whether or not it matters for this purpose but -s and -S almost certainly mean different things to gcc.
 
Ok I'm definitely on the verge of getting this now....what does this error mean:

main.c:74: undefined reference to `FLD_ExecGame'


I'm use FLD_ExecGame("DUKEIP.BIN", "DEATH", 1);

and I'm including fld_load.h.

Any ideas? And I'm positive this is the function I need. I read a doc on Antime's website, entitled "Saturn DEMO-DEMO File Loader", and I'm pretty sure this function is a shortcut for it.
 
Back
Top