mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
SMB updates, menu tweaks
This commit is contained in:
parent
6b785b0b68
commit
30dc47b29d
@ -235,6 +235,8 @@ LoadBufferFromFAT (char *filepath, bool silent)
|
|||||||
int boffset = 0;
|
int boffset = 0;
|
||||||
int read = 0;
|
int read = 0;
|
||||||
|
|
||||||
|
ClearSaveBuffer ();
|
||||||
|
|
||||||
handle = fopen (filepath, "rb");
|
handle = fopen (filepath, "rb");
|
||||||
|
|
||||||
if (handle <= 0)
|
if (handle <= 0)
|
||||||
@ -248,8 +250,6 @@ LoadBufferFromFAT (char *filepath, bool silent)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (savebuffer, 0, 0x22000);
|
|
||||||
|
|
||||||
/*** This is really nice, just load the file and decode it ***/
|
/*** This is really nice, just load the file and decode it ***/
|
||||||
while ((read = fread (savebuffer + boffset, 1, 1024, handle)) > 0)
|
while ((read = fread (savebuffer + boffset, 1, 1024, handle)) > 0)
|
||||||
{
|
{
|
||||||
@ -285,5 +285,6 @@ SaveBufferToFAT (char *filepath, int datasize, bool silent)
|
|||||||
fclose (handle);
|
fclose (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClearSaveBuffer ();
|
||||||
return datasize;
|
return datasize;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,8 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
S9xPrepareSoundForSnapshotSave (FALSE);
|
S9xPrepareSoundForSnapshotSave (FALSE);
|
||||||
|
|
||||||
NGCFreezeMemBuffer (); // copy freeze mem into membuffer
|
NGCFreezeMemBuffer (); // copy freeze mem into membuffer
|
||||||
|
|
||||||
|
ClearSaveBuffer ();
|
||||||
memcpy (savebuffer, membuffer, bufoffset);
|
memcpy (savebuffer, membuffer, bufoffset);
|
||||||
|
|
||||||
S9xPrepareSoundForSnapshotSave (TRUE);
|
S9xPrepareSoundForSnapshotSave (TRUE);
|
||||||
@ -164,17 +166,17 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
ClearSaveBuffer ();
|
ClearSaveBuffer ();
|
||||||
|
|
||||||
/*** Copy in save icon ***/
|
/*** Copy in save icon ***/
|
||||||
int offset = sizeof (saveicon);
|
int woffset = sizeof (saveicon);
|
||||||
memcpy (savebuffer, saveicon, offset);
|
memcpy (savebuffer, saveicon, woffset);
|
||||||
|
|
||||||
/*** And the freezecomment ***/
|
/*** And the freezecomment ***/
|
||||||
sprintf (freezecomment[1], "%s", Memory.ROMFilename);
|
sprintf (freezecomment[1], "%s", Memory.ROMFilename);
|
||||||
memcpy (savebuffer + offset, freezecomment, 64);
|
memcpy (savebuffer + woffset, freezecomment, 64);
|
||||||
offset += 64;
|
woffset += 64;
|
||||||
|
|
||||||
/*** Zip and copy in the freeze ***/
|
/*** Zip and copy in the freeze ***/
|
||||||
uLongf DestBuffSize = (uLongf) SAVEBUFFERSIZE;
|
uLongf DestBuffSize = (uLongf) SAVEBUFFERSIZE;
|
||||||
int err= compress2((Bytef*)(savebuffer+offset+8), (uLongf*)&DestBuffSize, (const Bytef*)membuffer, (uLongf)bufoffset, Z_BEST_COMPRESSION);
|
int err= compress2((Bytef*)(savebuffer+woffset+8), (uLongf*)&DestBuffSize, (const Bytef*)membuffer, (uLongf)bufoffset, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
if(err!=Z_OK)
|
if(err!=Z_OK)
|
||||||
{
|
{
|
||||||
@ -184,27 +186,19 @@ NGCFreezeGame (int method, bool8 silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int zippedsize = (int)DestBuffSize;
|
int zippedsize = (int)DestBuffSize;
|
||||||
memcpy (savebuffer + offset, &zippedsize, 4);
|
memcpy (savebuffer + woffset, &zippedsize, 4);
|
||||||
offset += 4;
|
woffset += 4;
|
||||||
|
|
||||||
int decompressedsize = (int)bufoffset;
|
int decompressedsize = (int)bufoffset;
|
||||||
memcpy (savebuffer + offset, &decompressedsize, 4);
|
memcpy (savebuffer + woffset, &decompressedsize, 4);
|
||||||
offset += 4;
|
woffset += 4;
|
||||||
|
|
||||||
offset += zippedsize;
|
woffset += zippedsize;
|
||||||
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA)
|
if(method == METHOD_MC_SLOTA)
|
||||||
ret = SaveBufferToMC ( savebuffer, CARD_SLOTA, filename, offset, SILENT );
|
offset = SaveBufferToMC ( savebuffer, CARD_SLOTA, filename, woffset, SILENT );
|
||||||
else
|
else
|
||||||
ret = SaveBufferToMC ( savebuffer, CARD_SLOTB, filename, offset, SILENT );
|
offset = SaveBufferToMC ( savebuffer, CARD_SLOTB, filename, woffset, SILENT );
|
||||||
|
|
||||||
if ( ret && !silent )
|
|
||||||
{
|
|
||||||
sprintf (filename, "Written %d bytes", ret);
|
|
||||||
WaitPrompt (filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset > 0) // save successful!
|
if(offset > 0) // save successful!
|
||||||
@ -289,12 +283,14 @@ NGCUnfreezeGame (int method, bool8 silent)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if(method == METHOD_MC_SLOTA)
|
if(method == METHOD_MC_SLOTA)
|
||||||
LoadBufferFromMC ( savebuffer, CARD_SLOTA, filename, silent );
|
ret = LoadBufferFromMC ( savebuffer, CARD_SLOTA, filename, silent );
|
||||||
else
|
else
|
||||||
LoadBufferFromMC ( savebuffer, CARD_SLOTB, filename, silent );
|
ret = LoadBufferFromMC ( savebuffer, CARD_SLOTB, filename, silent );
|
||||||
|
|
||||||
if ( ret )
|
if (ret)
|
||||||
{
|
{
|
||||||
|
char zipbuffer[MEMBUFFER];
|
||||||
|
|
||||||
// skip the saveicon and comment
|
// skip the saveicon and comment
|
||||||
offset = (sizeof(saveicon) + 64);
|
offset = (sizeof(saveicon) + 64);
|
||||||
uLongf zipsize = 0;
|
uLongf zipsize = 0;
|
||||||
@ -309,7 +305,7 @@ NGCUnfreezeGame (int method, bool8 silent)
|
|||||||
memset(membuffer, 0, MEMBUFFER);
|
memset(membuffer, 0, MEMBUFFER);
|
||||||
|
|
||||||
uLongf DestBuffSize = MEMBUFFER;
|
uLongf DestBuffSize = MEMBUFFER;
|
||||||
int err= uncompress((Bytef*)membuffer, (uLongf*)&DestBuffSize, (const Bytef*)(savebuffer + offset), zipsize);
|
int err= uncompress((Bytef*)zipbuffer, (uLongf*)&DestBuffSize, (const Bytef*)(savebuffer + offset), zipsize);
|
||||||
|
|
||||||
if ( err!=Z_OK )
|
if ( err!=Z_OK )
|
||||||
{
|
{
|
||||||
@ -317,18 +313,23 @@ NGCUnfreezeGame (int method, bool8 silent)
|
|||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if ( DestBuffSize != decompressedsize )
|
||||||
if ( DestBuffSize != decompressedsize )
|
|
||||||
{
|
{
|
||||||
WaitPrompt((char*) "Unzipped size doesn't match expected size!");
|
WaitPrompt((char*) "Unzipped size doesn't match expected size!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
offset = MEMBUFFER;
|
||||||
|
memcpy (savebuffer, zipbuffer, MEMBUFFER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset > 0)
|
if(offset > 0)
|
||||||
{
|
{
|
||||||
memcpy (membuffer, savebuffer, offset);
|
memcpy (membuffer, savebuffer, offset);
|
||||||
|
ClearSaveBuffer ();
|
||||||
|
|
||||||
if (S9xUnfreezeGame ("AGAME") == SUCCESS)
|
if (S9xUnfreezeGame ("AGAME") == SUCCESS)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -188,11 +188,11 @@ PreferencesMenu ()
|
|||||||
|
|
||||||
if (GCSettings.AutoLoad == 0) sprintf (prefmenu[4],"Auto Load OFF");
|
if (GCSettings.AutoLoad == 0) sprintf (prefmenu[4],"Auto Load OFF");
|
||||||
else if (GCSettings.AutoLoad == 1) sprintf (prefmenu[4],"Auto Load SRAM");
|
else if (GCSettings.AutoLoad == 1) sprintf (prefmenu[4],"Auto Load SRAM");
|
||||||
else if (GCSettings.AutoLoad == 2) sprintf (prefmenu[4],"Auto Load FREEZE");
|
else if (GCSettings.AutoLoad == 2) sprintf (prefmenu[4],"Auto Load SNAPSHOT");
|
||||||
|
|
||||||
if (GCSettings.AutoSave == 0) sprintf (prefmenu[5],"Auto Save OFF");
|
if (GCSettings.AutoSave == 0) sprintf (prefmenu[5],"Auto Save OFF");
|
||||||
else if (GCSettings.AutoSave == 1) sprintf (prefmenu[5],"Auto Save SRAM");
|
else if (GCSettings.AutoSave == 1) sprintf (prefmenu[5],"Auto Save SRAM");
|
||||||
else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save FREEZE");
|
else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save SNAPSHOT");
|
||||||
else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH");
|
else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH");
|
||||||
|
|
||||||
sprintf (prefmenu[6], "Verify MC Saves %s",
|
sprintf (prefmenu[6], "Verify MC Saves %s",
|
||||||
@ -332,20 +332,21 @@ void CheatMenu()
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Game Options Menu
|
* Game Options Menu
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static int gamemenuCount = 9;
|
|
||||||
static char gamemenu[][50] = {
|
|
||||||
"Return to Game",
|
|
||||||
"Reset Game",
|
|
||||||
"ROM Information",
|
|
||||||
"Cheats",
|
|
||||||
"Load SRAM", "Save SRAM",
|
|
||||||
"Load Freeze", "Save Freeze",
|
|
||||||
"Back to Main Menu"
|
|
||||||
};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
GameMenu ()
|
GameMenu ()
|
||||||
{
|
{
|
||||||
|
int gamemenuCount = 9;
|
||||||
|
char gamemenu[][50] = {
|
||||||
|
"Return to Game",
|
||||||
|
"Reset Game",
|
||||||
|
"ROM Information",
|
||||||
|
"Cheats",
|
||||||
|
"Load SRAM", "Save SRAM",
|
||||||
|
"Load Game Snapshot", "Save Game Snapshot",
|
||||||
|
"Back to Main Menu"
|
||||||
|
};
|
||||||
|
|
||||||
int ret, retval = 0;
|
int ret, retval = 0;
|
||||||
int quit = 0;
|
int quit = 0;
|
||||||
int oldmenu = menu;
|
int oldmenu = menu;
|
||||||
@ -353,7 +354,28 @@ GameMenu ()
|
|||||||
|
|
||||||
while (quit == 0)
|
while (quit == 0)
|
||||||
{
|
{
|
||||||
ret = RunMenu (gamemenu, gamemenuCount, (char*)"Game Options");
|
// disable SRAM/SNAPSHOT saving/loading if AUTO is on
|
||||||
|
|
||||||
|
if (GCSettings.AutoLoad == 1) // Auto Load SRAM
|
||||||
|
gamemenu[4][0] = '\0';
|
||||||
|
else if (GCSettings.AutoLoad == 2) // Auto Load SNAPSHOT
|
||||||
|
gamemenu[6][0] = '\0';
|
||||||
|
|
||||||
|
if (GCSettings.AutoSave == 1) // Auto Save SRAM
|
||||||
|
gamemenu[5][0] = '\0';
|
||||||
|
else if (GCSettings.AutoSave == 2) // Auto Save SNAPSHOT
|
||||||
|
gamemenu[7][0] = '\0';
|
||||||
|
else if (GCSettings.AutoSave == 3) // Auto Save BOTH
|
||||||
|
{
|
||||||
|
gamemenu[5][0] = '\0';
|
||||||
|
gamemenu[7][0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide cheats menu if cheats file not present
|
||||||
|
if(Cheat.num_cheats == 0)
|
||||||
|
gamemenu[3][0] = '\0';
|
||||||
|
|
||||||
|
ret = RunMenu (gamemenu, gamemenuCount, (char*)"Game Menu");
|
||||||
|
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
|
@ -226,14 +226,17 @@ LoadSMBFile (char *filename, int length)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
boffset = LoadBufferFromSMB(SMBPath(filepath), NOTSILENT);
|
boffset = LoadBufferFromSMB((char *)rbuffer, SMBPath(filepath), NOTSILENT);
|
||||||
|
|
||||||
if(boffset > 0)
|
if(boffset > 0)
|
||||||
{
|
{
|
||||||
if(IsZipFile ((char *)savebuffer))
|
if(IsZipFile ((char *)rbuffer))
|
||||||
return UnZipBuffer(rbuffer, savebuffer);
|
{
|
||||||
else
|
//return UnZipBuffer(rbuffer, 0, 2, NULL);
|
||||||
memcpy (rbuffer, savebuffer, boffset);
|
// UNZIP currently crashes - FIX ME
|
||||||
|
WaitPrompt((char*) "Zipped files are currently not supported!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return boffset;
|
return boffset;
|
||||||
}
|
}
|
||||||
@ -270,10 +273,7 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
|||||||
boffset += wrote;
|
boffset += wrote;
|
||||||
dsize -= wrote;
|
dsize -= wrote;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMB_CloseFile (smbfile);
|
SMB_CloseFile (smbfile);
|
||||||
|
|
||||||
return boffset;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -282,7 +282,8 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
|||||||
WaitPrompt (msg);
|
WaitPrompt (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ClearSaveBuffer ();
|
||||||
|
return boffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -290,13 +291,20 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int
|
int
|
||||||
LoadBufferFromSMB (char *filepath, bool8 silent)
|
LoadBufferFromSMB (char *filepath, bool8 silent)
|
||||||
|
{
|
||||||
|
ClearSaveBuffer ();
|
||||||
|
return LoadBufferFromSMB((char *)savebuffer, filepath, silent);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
LoadBufferFromSMB (char * sbuffer, char *filepath, bool8 silent)
|
||||||
{
|
{
|
||||||
if(!ConnectShare (NOTSILENT))
|
if(!ConnectShare (NOTSILENT))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
SMBFILE smbfile;
|
SMBFILE smbfile;
|
||||||
int ret;
|
int ret;
|
||||||
int offset = 0;
|
int boffset = 0;
|
||||||
|
|
||||||
smbfile =
|
smbfile =
|
||||||
SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
|
||||||
@ -312,14 +320,10 @@ LoadBufferFromSMB (char *filepath, bool8 silent)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (savebuffer, 0, 0x22000);
|
while ((ret = SMB_ReadFile (sbuffer + boffset, 1024, boffset, smbfile)) > 0)
|
||||||
|
boffset += ret;
|
||||||
while ((ret =
|
|
||||||
SMB_ReadFile ((char *) savebuffer + offset, 1024, offset,
|
|
||||||
smbfile)) > 0)
|
|
||||||
offset += ret;
|
|
||||||
|
|
||||||
SMB_CloseFile (smbfile);
|
SMB_CloseFile (smbfile);
|
||||||
|
|
||||||
return offset;
|
return boffset;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ int UpdateSMBdirname();
|
|||||||
int ParseSMBdirectory ();
|
int ParseSMBdirectory ();
|
||||||
int LoadSMBFile (char *filename, int length);
|
int LoadSMBFile (char *filename, int length);
|
||||||
int LoadBufferFromSMB (char *filepath, bool8 silent);
|
int LoadBufferFromSMB (char *filepath, bool8 silent);
|
||||||
|
int LoadBufferFromSMB (char * sbuffer, char *filepath, bool8 silent);
|
||||||
int SaveBufferToSMB (char *filepath, int datasize, bool8 silent);
|
int SaveBufferToSMB (char *filepath, int datasize, bool8 silent);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -595,14 +595,6 @@ NGCReportButtons ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainmenu (3); // go to game menu
|
mainmenu (3); // go to game menu
|
||||||
FrameTimer = 0;
|
|
||||||
ConfigRequested = 0;
|
|
||||||
|
|
||||||
setFrameTimerMethod(); // set frametimer method every time a ROM is loaded
|
|
||||||
|
|
||||||
S9xReportControllers(); // FIX
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -803,7 +795,10 @@ emulate ()
|
|||||||
AudioStart ();
|
AudioStart ();
|
||||||
S9xInitSync();
|
S9xInitSync();
|
||||||
|
|
||||||
setFrameTimerMethod(); // also called in NGCReportButtons()
|
FrameTimer = 0;
|
||||||
|
ConfigRequested = 0;
|
||||||
|
setFrameTimerMethod(); // set frametimer method every time a ROM is loaded
|
||||||
|
S9xReportControllers(); // FIX
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -73,13 +73,6 @@ IsZipFile (char *buffer)
|
|||||||
*
|
*
|
||||||
* It should be noted that there is a limit of 5MB total size for any ROM
|
* It should be noted that there is a limit of 5MB total size for any ROM
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
unsigned char * uzipbuffer;
|
|
||||||
|
|
||||||
int UnZipBuffer(unsigned char *outbuffer, unsigned char *inbuffer)
|
|
||||||
{
|
|
||||||
uzipbuffer = inbuffer;
|
|
||||||
return UnZipBuffer(outbuffer, 0, 2, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
UnZipBuffer (unsigned char *outbuffer, u64 inoffset, short where, FILE* filehandle)
|
UnZipBuffer (unsigned char *outbuffer, u64 inoffset, short where, FILE* filehandle)
|
||||||
@ -108,7 +101,7 @@ UnZipBuffer (unsigned char *outbuffer, u64 inoffset, short where, FILE* filehand
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // From buffer
|
case 2: // From buffer
|
||||||
memcpy(readbuffer, uzipbuffer, 2048);
|
memcpy(readbuffer, outbuffer, 2048);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +179,7 @@ UnZipBuffer (unsigned char *outbuffer, u64 inoffset, short where, FILE* filehand
|
|||||||
|
|
||||||
case 2: // From buffer
|
case 2: // From buffer
|
||||||
inoffset += 2048;
|
inoffset += 2048;
|
||||||
memcpy(readbuffer, uzipbuffer+inoffset, 2048);
|
memcpy(readbuffer, outbuffer+inoffset, 2048);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user