mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-26 04:24:16 +01:00
determine correct size for snapshot files
This commit is contained in:
parent
0b4ca7509f
commit
146e2f111f
@ -247,17 +247,6 @@ int MemCPUWriteBatteryFile(char * membuffer)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* SetFileBytesWritten
|
|
||||||
* Sets the # of bytes written into a file
|
|
||||||
* Used by GBA.cpp and GB.cpp
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void SetFileBytesWritten(int bytes)
|
|
||||||
{
|
|
||||||
//datasize = bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* LoadBatteryOrState
|
* LoadBatteryOrState
|
||||||
* Load Battery/State file into memory
|
* Load Battery/State file into memory
|
||||||
@ -416,10 +405,41 @@ bool SaveBatteryOrState(int method, int action, bool silent)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool written = emulator.emuWriteMemState((char *)savebuffer+offset, SAVEBUFFERSIZE-offset);
|
bool written = emulator.emuWriteMemState((char *)savebuffer+offset, SAVEBUFFERSIZE-offset);
|
||||||
// we really should set datasize to the exact memory size written
|
// we need to set datasize to the exact memory size written
|
||||||
// but instead we'll set it at 192K - although much of it will go unused
|
// but emuWriteMemState doesn't return that for us
|
||||||
|
// so instead we'll find the end of the save the old fashioned way
|
||||||
if(written)
|
if(written)
|
||||||
datasize = (1024*192);
|
{
|
||||||
|
datasize = (1024*192); // we'll start at 192K - no save should be larger
|
||||||
|
char check = savebuffer[datasize];
|
||||||
|
while(check == 0)
|
||||||
|
{
|
||||||
|
datasize -= 16384;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
}
|
||||||
|
datasize += 16384;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
while(check == 0)
|
||||||
|
{
|
||||||
|
datasize -= 1024;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
}
|
||||||
|
datasize += 1024;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
while(check == 0)
|
||||||
|
{
|
||||||
|
datasize -= 64;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
}
|
||||||
|
datasize += 64;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
while(check == 0)
|
||||||
|
{
|
||||||
|
datasize -= 1;
|
||||||
|
check = savebuffer[datasize];
|
||||||
|
}
|
||||||
|
datasize += 2; // include last byte AND a null byte
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write savebuffer into file
|
// write savebuffer into file
|
||||||
|
@ -652,8 +652,6 @@ bool CPUWriteState(const char *file)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void SetFileBytesWritten(int bytes); // Tantric - Wii/GameCube addition - store # bytes written
|
|
||||||
|
|
||||||
bool CPUWriteMemState(char *memory, int available)
|
bool CPUWriteMemState(char *memory, int available)
|
||||||
{
|
{
|
||||||
gzFile gzFile = utilMemGzOpen(memory, available, "w");
|
gzFile gzFile = utilMemGzOpen(memory, available, "w");
|
||||||
@ -669,8 +667,6 @@ bool CPUWriteMemState(char *memory, int available)
|
|||||||
if(pos >= (available))
|
if(pos >= (available))
|
||||||
res = false;
|
res = false;
|
||||||
|
|
||||||
SetFileBytesWritten((int)pos); // Tantric - Wii/GameCube addition - store # bytes written
|
|
||||||
|
|
||||||
utilGzClose(gzFile);
|
utilGzClose(gzFile);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user