more small bugfixes

This commit is contained in:
dborth 2009-03-21 02:01:40 +00:00
parent 5356cf636c
commit bb2c829be2
7 changed files with 31 additions and 20 deletions

View File

@ -482,10 +482,13 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
u32 offset = readsize; u32 offset = readsize;
u32 nextread = 0;
while(offset < size) while(offset < size)
{ {
if(size - offset > 1024*512) nextread = 1024*512;
else nextread = size-offset;
ShowProgress ("Loading...", offset, size); 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)) if(readsize <= 0 || readsize > (1024*512))
break; // read failure break; // read failure

View File

@ -31,6 +31,7 @@
#include "srtc.h" #include "srtc.h"
#include "snes9xGX.h" #include "snes9xGX.h"
#include "memcardop.h"
#include "freeze.h" #include "freeze.h"
#include "fileop.h" #include "fileop.h"
#include "filebrowser.h" #include "filebrowser.h"
@ -152,11 +153,13 @@ NGCFreezeGame (char * filepath, int method, bool silent)
memset(freezecomment, 0, 64); memset(freezecomment, 0, 64);
sprintf (freezecomment[0], "%s Snapshot", APPNAME); sprintf (freezecomment[0], "%s Snapshot", APPNAME);
sprintf (freezecomment[1], Memory.ROMName); sprintf (freezecomment[1], Memory.ROMName);
SetMCSaveComment(freezecomment); SetMCSaveComments(freezecomment);
char * zipbuffer = (char *)memalign(32, SAVEBUFFERSIZE);
// 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+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) if(err!=Z_OK)
{ {
@ -167,8 +170,11 @@ NGCFreezeGame (char * filepath, int method, bool silent)
int zippedsize = (int)DestBuffSize; int zippedsize = (int)DestBuffSize;
int decompressedsize = (int)bufoffset; int decompressedsize = (int)bufoffset;
memset(savebuffer, 0, SAVEBUFFERSIZE);
memcpy(savebuffer, &zippedsize, 4); memcpy(savebuffer, &zippedsize, 4);
memcpy(savebuffer+4, &decompressedsize, 4); memcpy(savebuffer+4, &decompressedsize, 4);
memcpy(savebuffer+8, zipbuffer, DestBuffSize);
free(zipbuffer);
woffset = zippedsize + 8; woffset = zippedsize + 8;
} }

View File

@ -14,14 +14,12 @@
* Constructor for the GuiImageData class. * Constructor for the GuiImageData class.
*/ */
GuiImageData::GuiImageData(const u8 * img) GuiImageData::GuiImageData(const u8 * img)
{
if(img == NULL)
{ {
data = NULL; data = NULL;
width = 0; width = 0;
height = 0; height = 0;
}
else if(img)
{ {
PNGUPROP imgProp; PNGUPROP imgProp;
IMGCTX ctx = PNGU_SelectImageFromBuffer(img); IMGCTX ctx = PNGU_SelectImageFromBuffer(img);

View File

@ -386,7 +386,7 @@ done:
return byteswritten; return byteswritten;
} }
void SetMCSaveComments(char * comments) void SetMCSaveComments(char comments[2][32])
{ {
memcpy(savecomments, comments, 64); memcpy(savecomments, comments, 64);
} }

View File

@ -17,6 +17,6 @@ int ParseMCDirectory (int slot);
int LoadMCFile (char *buf, int slot, char *filename, bool silent); int LoadMCFile (char *buf, int slot, char *filename, bool silent);
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent); int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
bool TestMC(int slot, bool silent); bool TestMC(int slot, bool silent);
void SetMCSaveComments(char * comments); void SetMCSaveComments(char comments[2][32]);
#endif #endif

View File

@ -1159,7 +1159,7 @@ static int MenuGame()
batteryImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); batteryImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
batteryImg[i]->SetPosition(30, 0); batteryImg[i]->SetPosition(30, 0);
batteryBarImg[i] = new GuiImage(&batteryBar); batteryBarImg[i] = new GuiImage(&batteryBar);
batteryBarImg[i]->SetTile(4); batteryBarImg[i]->SetTile(0);
batteryBarImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); batteryBarImg[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
batteryBarImg[i]->SetPosition(34, 0); batteryBarImg[i]->SetPosition(34, 0);
@ -1603,10 +1603,12 @@ static int MenuGameSaves(int action)
} }
} }
HaltGui();
for(i=0; i < saves.length; i++) for(i=0; i < saves.length; i++)
if(saves.previewImg[i])
delete saves.previewImg[i]; delete saves.previewImg[i];
HaltGui();
mainWindow->Remove(&saveBrowser); mainWindow->Remove(&saveBrowser);
mainWindow->Remove(&w); mainWindow->Remove(&w);
mainWindow->Remove(&titleTxt); mainWindow->Remove(&titleTxt);

View File

@ -20,6 +20,7 @@
#include "srtc.h" #include "srtc.h"
#include "snes9xGX.h" #include "snes9xGX.h"
#include "memcardop.h"
#include "menu.h" #include "menu.h"
#include "fileop.h" #include "fileop.h"
#include "filebrowser.h" #include "filebrowser.h"
@ -50,13 +51,14 @@ LoadSRAM (char * filepath, int method, bool silent)
if (size > 0x20000) if (size > 0x20000)
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, // SRAM has a 512 byte header - remove it, then import the SRAM,
// ignoring anything after the SRAM // ignoring anything after the SRAM
memcpy(Memory.SRAM, savebuffer+512, size); 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 // SRAM data should be at the start of the file, just import it and
// ignore anything after the SRAM // ignore anything after the SRAM