fix several longstanding bugs

This commit is contained in:
dborth 2009-03-20 08:26:10 +00:00
parent 84aaefd004
commit 31691ff94f
4 changed files with 26 additions and 26 deletions

View File

@ -232,10 +232,9 @@ NGCFreezeGameAuto (int method, bool silent)
char filepath[1024]; char filepath[1024];
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) if(!MakeFilePath(filepath, FILE_SNAPSHOT, method, Memory.ROMFilename, 0))
sprintf(filepath, "%s Auto.frz", Memory.ROMFilename); return false;
else
sprintf(filepath, "%s/%s Auto.frz", GCSettings.SaveFolder, Memory.ROMFilename);
return NGCFreezeGame(filepath, method, silent); return NGCFreezeGame(filepath, method, silent);
} }
@ -289,13 +288,13 @@ NGCUnfreezeGame (char * filepath, int method, bool silent)
bufoffset = 0; bufoffset = 0;
if(method == METHOD_AUTO) if(method == METHOD_AUTO)
method = autoSaveMethod(silent); // we use 'Save' because snapshot needs R/W method = autoSaveMethod(silent); // we use 'Save' because snapshot needs R/W
if(method == METHOD_AUTO) if(method == METHOD_AUTO)
return 0; return 0;
AllocSaveBuffer (); AllocSaveBuffer();
offset = LoadFile(filepath, method, silent); offset = LoadFile(filepath, method, silent);
@ -322,17 +321,20 @@ NGCUnfreezeGame (char * filepath, int method, bool silent)
if ( err!=Z_OK ) if ( err!=Z_OK )
{ {
offset = 0;
sprintf (msg, "Unzip error %s",zError(err)); sprintf (msg, "Unzip error %s",zError(err));
ErrorPrompt(msg); ErrorPrompt(msg);
} }
else if ( DestBuffSize != decompressedsize ) else if ( DestBuffSize != decompressedsize )
{ {
offset = 0;
ErrorPrompt("Unzipped size doesn't match expected size!"); ErrorPrompt("Unzipped size doesn't match expected size!");
} }
else else
{ {
offset = SAVEBUFFERSIZE; offset = decompressedsize;
memcpy (savebuffer, zipbuffer, SAVEBUFFERSIZE); memset(savebuffer, 0, SAVEBUFFERSIZE);
memcpy (savebuffer, zipbuffer, decompressedsize);
} }
free(zipbuffer); free(zipbuffer);
} }
@ -350,7 +352,7 @@ NGCUnfreezeGame (char * filepath, int method, bool silent)
if(!silent) if(!silent)
ErrorPrompt("Freeze file not found"); ErrorPrompt("Freeze file not found");
} }
FreeSaveBuffer (); FreeSaveBuffer();
return result; return result;
} }

View File

@ -155,10 +155,10 @@ VerifyMCFile (char *buf, int slot, char *filename, int datasize)
int CardError; int CardError;
unsigned int blocks; unsigned int blocks;
unsigned int SectorSize; unsigned int SectorSize;
int bytesleft = 0; int bytesleft = 0;
int bytesread = 0; int bytesread = 0;
memset (verifybuffer, 0, 65536); memset (verifybuffer, 0, 65536);
// Get Sector Size // Get Sector Size
CARD_GetSectorSize (slot, &SectorSize); CARD_GetSectorSize (slot, &SectorSize);
@ -216,8 +216,8 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
int CardError; int CardError;
unsigned int blocks; unsigned int blocks;
unsigned int SectorSize; unsigned int SectorSize;
int bytesleft = 0; int bytesleft = 0;
int bytesread = 0; int bytesread = 0;
// Try to mount the card // Try to mount the card
CardError = MountMC(slot, NOTSILENT); CardError = MountMC(slot, NOTSILENT);

View File

@ -179,7 +179,7 @@ preparePrefsData (int method)
createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "SNES Pad - Nunchuk + Wiimote"); createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "SNES Pad - Nunchuk + Wiimote");
createXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad", "Superscope - GameCube Controller"); createXMLController(btnmap[CTRL_SCOPE][CTRLR_GCPAD], "btnmap_scope_gcpad", "Superscope - GameCube Controller");
createXMLController(btnmap[CTRL_SCOPE][CTRLR_WIIMOTE], "btnmap_scope_wiimote", "Superscope - Wiimote"); createXMLController(btnmap[CTRL_SCOPE][CTRLR_WIIMOTE], "btnmap_scope_wiimote", "Superscope - Wiimote");
createXMLController(btnmap[CTRL_MOUSE][CTRLR_GCPAD], "btnmap_mouse_gcpad", "MMouse - GameCube Controller"); createXMLController(btnmap[CTRL_MOUSE][CTRLR_GCPAD], "btnmap_mouse_gcpad", "Mouse - GameCube Controller");
createXMLController(btnmap[CTRL_MOUSE][CTRLR_WIIMOTE], "btnmap_mouse_wiimote", "Mouse - Wiimote"); createXMLController(btnmap[CTRL_MOUSE][CTRLR_WIIMOTE], "btnmap_mouse_wiimote", "Mouse - Wiimote");
createXMLController(btnmap[CTRL_JUST][CTRLR_GCPAD], "btnmap_just_gcpad", "Justifier - GameCube Controller"); createXMLController(btnmap[CTRL_JUST][CTRLR_GCPAD], "btnmap_just_gcpad", "Justifier - GameCube Controller");
createXMLController(btnmap[CTRL_JUST][CTRLR_WIIMOTE], "btnmap_just_wiimote", "Justifier - Wiimote"); createXMLController(btnmap[CTRL_JUST][CTRLR_WIIMOTE], "btnmap_just_wiimote", "Justifier - Wiimote");
@ -188,10 +188,9 @@ preparePrefsData (int method)
mxmlDelete(xml); mxmlDelete(xml);
return datasize; return datasize+offset;
} }
/**************************************************************************** /****************************************************************************
* loadXMLSetting * loadXMLSetting
* *

View File

@ -103,8 +103,8 @@ decodesavedata (int method, int readsize)
// Check for sram comment // Check for sram comment
memcpy (sramsavecomment, savebuffer+offset, 32); memcpy (sramsavecomment, savebuffer+offset, 32);
// version 0xx found! // Snes9x GX save found!
if ( (strncmp (sramsavecomment, "Snes9x GX 0", 11) == 0) ) if ( (strncmp (sramsavecomment, "Snes9x GX", 9) == 0) )
{ {
// adjust offset // adjust offset
if(method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB) if(method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
@ -116,13 +116,13 @@ decodesavedata (int method, int readsize)
memcpy (Memory.SRAM, savebuffer + offset, size); memcpy (Memory.SRAM, savebuffer + offset, size);
} }
// check for SRAM from other version/platform of snes9x // check for SRAM from other version/platform of snes9x
else if ( readsize == size || readsize == size + SRTC_SRAM_PAD) else if (readsize == size || readsize == size + SRTC_SRAM_PAD)
{ {
// SRAM data should be at the start of the file, just import it and // SRAM data should be at the start of the file, just import it and
// ignore anything after the SRAM // ignore anything after the SRAM
memcpy (Memory.SRAM, savebuffer, size); memcpy (Memory.SRAM, savebuffer, size);
} }
else if ( readsize == size + 512 ) else if (readsize == size + 512)
{ {
// SRAM has a 512 byte header - remove it, then import the SRAM, // SRAM has a 512 byte header - remove it, then import the SRAM,
// ignoring anything after the SRAM // ignoring anything after the SRAM
@ -182,10 +182,9 @@ LoadSRAMAuto (int method, bool silent)
char filepath[1024]; char filepath[1024];
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) if(!MakeFilePath(filepath, FILE_SRAM, method, Memory.ROMFilename, 0))
sprintf(filepath, "%s Auto.srm", Memory.ROMFilename); return false;
else
sprintf(filepath, "%s/%s Auto.srm", GCSettings.SaveFolder, Memory.ROMFilename);
return LoadSRAM(filepath, method, silent); return LoadSRAM(filepath, method, silent);
} }