HomeForumsWhat's newResources 
 
 
Programming Saturngame, need help...
Daniel Eriksson - Dec 21, 2002
   Daniel Eriksson Dec 21, 2002 
Just a question, if I use the PCX to Sat program to convert an image, how do I open it in my program? Anyone who can help me with the SGL code for this? Or is it loads of code? Maybe there is some example? It would help me a lot in the development of my game if anyone could help me. I have managed to create a simple text adventure this far, and it with some nice pictures it would look something like Myst... Ok that was a little optimistic, but atleast that is what I´m aming for

   vbt Dec 21, 2002 
try to use these functions, I know I didn't take the time to create a sample :

#define MAX_FILE 128

void load_color_proms(char *name);

void selectPic(unsigned char pic[],unsigned short palette[]);

int LoadFile(char *name, Uint8 *location, Uint32 size);

unsigned char Scene3[307200];

unsigned short Scene3Pal[513];

extern unsigned short file_id, dir_id;

void InitCD()

{

Sint32 dirwork[SLCD_WORK_SIZE(MAX_FILE)];

Sint32 ndir;

ndir = slCdInit(MAX_FILE, dirwork);

}

void ChooseFile(unsigned short prefix)

{

char filename[50];

char filenamePal[50];

char toto[100];

sprintf(filename,&q
uot;%04d.BIN",p
refix);

sprintf(filenamePal
,"%04dPAL.BIN&q
uot;,prefix);

sprintf(toto,"Current file : %s ", filename);

slPrint(toto,slLoca
te(19,6));

if (LoadFile(filename, &Scene3[0x000], 192)==0) //taille /16000

{

load_color_proms(fi
lenamePal);

// slPrint("End Loading picture...", slLocate(2,2));

selectPic(Scene3,Sc
ene3Pal);

}

else

{

file_id--;

}

}

void ChangeDir(unsigned short prefix)

{

Sint32 stat;

char dirname[50];

char toto[100];

if (prefix > 0)

sprintf(dirname,&qu
ot;%04d",prefix
);

else

sprintf(dirname,&qu
ot;..");

//

file_id=0;

stat= slCdChgDir(dirname);

if (stat < 2) dir_id--;

//sprintf(toto,"CD %s nb files : %d ", dirname,stat-2);

slSynch();

// slPrint(toto,slL
ocate(19,5));

}

int LoadFile(char *name, Uint8 *location, Uint32 size)

{

// Sint32 dirwork[SLCD_WORK_SIZE(MAX_FILE)];

// Sint32 ndir;

CDHN cdhn;

CDKEY key[2];

CDBUF buf[2];

Sint32 stat;

Sint32 len[2];

Sint32 CDerr;

char toto[100];

// ndir = slCdInit(MAX_FILE, dirwork);

// stat= slCdChgDir("0001");



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

key[1].cn = CDKEY_TERM;

cdhn = slCdOpen(name, key);

if (cdhn!=NULL)

{



buf[0].type = CDBUF_COPY;

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

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

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

buf[1].type = CDBUF_TERM;

slCdLoadFile(cdhn, buf);

while (1)

{

slSynch();

stat = slCdGetStatus(cdhn, len);

// if (stat == CDSTAT_DOING) slPrint("Read in progress ", slLocate(2,2));

// if (stat == CDSTAT_WAIT) slPrint("CD waiting ", slLocate(2,2));

// if (stat == CDSTAT_PAUSE) slPrint("CD pause ", slLocate(2,2));

// sprintf(toto,"toto %06d",stat);

// slPrint(toto,slL
ocate(10,3));

// sprintf(toto,"CDERR_NEXIST %06d len[0] %d len[1] %d len[2] %d ",CDERR_NEXIST,len[0], len[1], len[2]);

//

// slPrint(toto,slL
ocate(10,5));

// sprintf(toto,"CDSTAT_DOING %06d",CDSTAT_DOING);



// slPrint(toto,slL
ocate(10,6));

if (stat == CDSTAT_COMPLETED || stat == CDSTAT_WAIT || len[2]==0) break;

// if (stat == CDSTAT_COMPLETED) break;

}

return 0;

}

else

{

slSynch();

sprintf(toto,"file not found : %s ",name);

slPrint(toto,slLoca
te(15,5));

return -1;

}

}

void load_color_proms(char *name)

{

int i;

unsigned char buffer[513];

if (LoadFile(name, &buffer[0x000], 1)==0)

{

for(i=1;i<513;i+
=2)

{

Scene3Pal[(i-1)/2] = (buffer>> 0) + (buffer[i-1] << 8);

}

}

}

   Daniel Eriksson Dec 21, 2002 
Thanks! I´ll try them!

   vbt Jan 5, 2003 
Did you manage to do something with these lines of code ?

   Daniel Eriksson Jan 6, 2003 
Yeah, ive tried to use it in the game i am making, but i couldn´t get it to compile right. I don´t think its your code though, its my code for the game that won´t work. I have to check through it. Ill post it here if I get it to work.