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.
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 ?
By the way, don't you think satourne's developer could answer to our problem ?
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.
#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();
}
}
#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
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'
main.c:74: undefined reference to `FLD_ExecGame'