Saturn Save Game Copier

ramirez60

New Member
I've been working on this project for the last couple of days. I'm trying to write a program that copies a file from the cd to the saturn's internal memory. Basically a way for people without a netlink or a PAR to get saves. My source code compiles (with 2 warnings) and boots on a real saturn. The code also executes fully, it prints out my "Done" statement at the end. Unfortunately it doesn't seem to be copying the file properly. Anyway here's my source code, I've already wasted enough blank cds

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

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

#include "sega_bup.h" // Required for backup memory functions

#include "stdlib.h"

#define BUP_START 0x6090000 // In the sgl doc's they say to put 0x06????? but that doesn't compile...

#define MAX_FILE 128 // Needed for CD functions

#define READSECT 50 // Needed for CD functions

Uint32 workmemory[2048]; // Needed for BackUpFunctions

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

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

void ss_main(void)

{

Sint32 ndir;

CDHN cdhn;

CDKEY key[2];

CDBUF buf[2];

Sint32 stat;

Sint32 len[2];

Sint32 ypos=1;

BupConfig conf[3]; // stores backup configuration

BupStat sttb; // stores backup status

BupDir writetb; // writeb holds file data



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("FPS_6MEN.DAT", 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++;



while(1)

{

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;



}





slPrint("Save loaded...", slLocate(1,3));

BUP_Init(BUP_START, workmemory, conf); // Initializes back up cart

slPrint("Back up initialized...", slLocate(1,4));









strcpy((char *)writetb.filename, "FPS_6MEN_01"); // Specifies filename for the save

strcpy((char *)writetb.comment, "Test2"); // Specifies comment for the save

writetb.language = BUP_ENGLISH; // not sure what this does?? language probably

writetb.datasize = 320; // Specifies file size, this is not working.

slPrint("Formatting internal ram....", slLocate(1, 5));

BUP_Format(0); // Clears interal memory, 0 = internal memory, 1 = backup cart

BUP_Write(0, &writetb, cdhn, 0); // This should copy the file to internal memory but doesn't...

slPrint("Done.", slLocate(1,4)); // Prints done to the screen



while(1)

{

slSynch();

}

}

After I run this cd, my internal memory is wiped clean, and there's a file called FPS_6MEN_01 which is 6 blocks big. The real save should be 320ish. When I load Fire Pro, and select internal memory, I get a message which I'm assuming says, "Corrupt Save" or something to that effect. I can't read Japanese. Anyway to make a long story short this isn't working and I'm giving up. Anybody up for finishing this project? Later
 

ExCyber

Staff member
You're putting 320 in writetb.datasize; I think this needs to be the size of the file in bytes rather than blocks...
 

ramirez60

New Member
Nevermind it works!!!!!!

Thank you, and everyone else on these boards for their help!!!!!

Woo-Hoo!!!

Finally translated Fire Pro goodness...::drools::

If anyone's interested in my source code or my iso please message me. I'm pretty sure that you can use it for any game, if you modify the source and when you compile the cd.
 
Top