mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-27 21:14:21 +01:00
more small bugfixes
This commit is contained in:
parent
5356cf636c
commit
bb2c829be2
@ -482,10 +482,13 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||
|
||||
u32 offset = readsize;
|
||||
u32 nextread = 0;
|
||||
while(offset < size)
|
||||
{
|
||||
if(size - offset > 1024*512) nextread = 1024*512;
|
||||
else nextread = size-offset;
|
||||
ShowProgress ("Loading...", offset, size);
|
||||
readsize = fread (rbuffer + offset, 1, (1024*512), file); // read in 512K chunks
|
||||
readsize = fread (rbuffer + offset, 1, nextread, file); // read in 512K chunks
|
||||
|
||||
if(readsize <= 0 || readsize > (1024*512))
|
||||
break; // read failure
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "srtc.h"
|
||||
|
||||
#include "snes9xGX.h"
|
||||
#include "memcardop.h"
|
||||
#include "freeze.h"
|
||||
#include "fileop.h"
|
||||
#include "filebrowser.h"
|
||||
@ -152,11 +153,13 @@ NGCFreezeGame (char * filepath, int method, bool silent)
|
||||
memset(freezecomment, 0, 64);
|
||||
sprintf (freezecomment[0], "%s Snapshot", APPNAME);
|
||||
sprintf (freezecomment[1], Memory.ROMName);
|
||||
SetMCSaveComment(freezecomment);
|
||||
SetMCSaveComments(freezecomment);
|
||||
|
||||
char * zipbuffer = (char *)memalign(32, SAVEBUFFERSIZE);
|
||||
|
||||
// Zip and copy in the freeze
|
||||
uLongf DestBuffSize = (uLongf) SAVEBUFFERSIZE;
|
||||
int err= compress2((Bytef*)(savebuffer+8), (uLongf*)&DestBuffSize, (const Bytef*)savebuffer, (uLongf)bufoffset, Z_BEST_COMPRESSION);
|
||||
int err = compress2((Bytef*)(zipbuffer), (uLongf*)&DestBuffSize, (const Bytef*)savebuffer, (uLongf)bufoffset, Z_BEST_COMPRESSION);
|
||||
|
||||
if(err!=Z_OK)
|
||||
{
|
||||
@ -167,8 +170,11 @@ NGCFreezeGame (char * filepath, int method, bool silent)
|
||||
|
||||
int zippedsize = (int)DestBuffSize;
|
||||
int decompressedsize = (int)bufoffset;
|
||||
memcpy (savebuffer, &zippedsize, 4);
|
||||
memcpy (savebuffer+4, &decompressedsize, 4);
|
||||
memset(savebuffer, 0, SAVEBUFFERSIZE);
|
||||
memcpy(savebuffer, &zippedsize, 4);
|
||||
memcpy(savebuffer+4, &decompressedsize, 4);
|
||||
memcpy(savebuffer+8, zipbuffer, DestBuffSize);
|
||||
free(zipbuffer);
|
||||
|
||||
woffset = zippedsize + 8;
|
||||
}
|
||||
|
@ -15,13 +15,11 @@
|
||||
*/
|
||||
GuiImageData::GuiImageData(const u8 * img)
|
||||
{
|
||||
if(img == NULL)
|
||||
{
|
||||
data = NULL;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
else
|
||||
data = NULL;
|
||||
width = 0;
|
||||
height = 0;
|
||||
|
||||
if(img)
|
||||
{
|
||||
PNGUPROP imgProp;
|
||||
IMGCTX ctx = PNGU_SelectImageFromBuffer(img);
|
||||
|
@ -386,7 +386,7 @@ done:
|
||||
return byteswritten;
|
||||
}
|
||||
|
||||
void SetMCSaveComments(char * comments)
|
||||
void SetMCSaveComments(char comments[2][32])
|
||||
{
|
||||
memcpy(savecomments, comments, 64);
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ int ParseMCDirectory (int slot);
|
||||
int LoadMCFile (char *buf, int slot, char *filename, bool silent);
|
||||
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
|
||||
bool TestMC(int slot, bool silent);
|
||||
void SetMCSaveComments(char * comments);
|
||||
void SetMCSaveComments(char comments[2][32]);
|
||||
|
||||
#endif
|
||||
|
@ -1159,7 +1159,7 @@ static int MenuGame()
|
||||
batteryImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
batteryImg[i]->SetPosition(30, 0);
|
||||
batteryBarImg[i] = new GuiImage(&batteryBar);
|
||||
batteryBarImg[i]->SetTile(4);
|
||||
batteryBarImg[i]->SetTile(0);
|
||||
batteryBarImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
batteryBarImg[i]->SetPosition(34, 0);
|
||||
|
||||
@ -1603,10 +1603,12 @@ static int MenuGameSaves(int action)
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i < saves.length; i++)
|
||||
delete saves.previewImg[i];
|
||||
|
||||
HaltGui();
|
||||
|
||||
for(i=0; i < saves.length; i++)
|
||||
if(saves.previewImg[i])
|
||||
delete saves.previewImg[i];
|
||||
|
||||
mainWindow->Remove(&saveBrowser);
|
||||
mainWindow->Remove(&w);
|
||||
mainWindow->Remove(&titleTxt);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "srtc.h"
|
||||
|
||||
#include "snes9xGX.h"
|
||||
#include "memcardop.h"
|
||||
#include "menu.h"
|
||||
#include "fileop.h"
|
||||
#include "filebrowser.h"
|
||||
@ -50,13 +51,14 @@ LoadSRAM (char * filepath, int method, bool silent)
|
||||
if (size > 0x20000)
|
||||
size = 0x20000;
|
||||
|
||||
if (readsize == size + 512 || readsize == size + 512 + SRTC_SRAM_PAD)
|
||||
if (method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB ||
|
||||
offset == size + 512 || offset == size + 512 + SRTC_SRAM_PAD)
|
||||
{
|
||||
// SRAM has a 512 byte header - remove it, then import the SRAM,
|
||||
// ignoring anything after the SRAM
|
||||
memcpy(Memory.SRAM, savebuffer+512, size);
|
||||
}
|
||||
else if (readsize == size || readsize == size + SRTC_SRAM_PAD)
|
||||
else if (offset == size || offset == size + SRTC_SRAM_PAD)
|
||||
{
|
||||
// SRAM data should be at the start of the file, just import it and
|
||||
// ignore anything after the SRAM
|
||||
|
Loading…
Reference in New Issue
Block a user