Simplify save state handling
- size and version parameters are unused in the libretro implementation, so remove them
This commit is contained in:
parent
3158b73d69
commit
1c95df1212
|
@ -20,9 +20,9 @@ struct EmulatedSystem {
|
|||
bool (*emuWriteBattery)(const char *);
|
||||
#ifdef __LIBRETRO__
|
||||
// load state
|
||||
bool (*emuReadState)(const uint8_t *, unsigned);
|
||||
bool (*emuReadState)(const uint8_t *);
|
||||
// load state
|
||||
unsigned (*emuWriteState)(uint8_t *, unsigned);
|
||||
unsigned (*emuWriteState)(uint8_t *);
|
||||
#else
|
||||
// load state
|
||||
bool (*emuReadState)(const char *);
|
||||
|
|
|
@ -5492,7 +5492,7 @@ bool gbLoadRomData(const char* data, unsigned size)
|
|||
#ifdef __LIBRETRO__
|
||||
#include <stddef.h>
|
||||
|
||||
unsigned int gbWriteSaveState(uint8_t* data, unsigned)
|
||||
unsigned int gbWriteSaveState(uint8_t* data)
|
||||
{
|
||||
uint8_t* orig = data;
|
||||
|
||||
|
@ -5560,7 +5560,7 @@ unsigned int gbWriteSaveState(uint8_t* data, unsigned)
|
|||
return (ptrdiff_t)data - (ptrdiff_t)orig;
|
||||
}
|
||||
|
||||
bool gbReadSaveState(const uint8_t* data, unsigned)
|
||||
bool gbReadSaveState(const uint8_t* data)
|
||||
{
|
||||
int version = utilReadIntMem(data);
|
||||
|
||||
|
@ -5625,7 +5625,7 @@ bool gbReadSaveState(const uint8_t* data, unsigned)
|
|||
utilReadMem(&IFF, data, 2);
|
||||
|
||||
if (gbSgbMode) {
|
||||
gbSgbReadGame(data, version);
|
||||
gbSgbReadGame(data);
|
||||
} else {
|
||||
gbSgbMask = 0; // loading a game at the wrong time causes no display
|
||||
}
|
||||
|
@ -5767,7 +5767,7 @@ bool gbReadSaveState(const uint8_t* data, unsigned)
|
|||
gbMemoryMap[0x0d] = &gbWram[value * 0x1000];
|
||||
}
|
||||
|
||||
gbSoundReadGame(data, version);
|
||||
gbSoundReadGame(data);
|
||||
|
||||
if (gbCgbMode && gbSgbMode) {
|
||||
gbSgbMode = 0;
|
||||
|
|
|
@ -896,7 +896,7 @@ void gbSgbSaveGame(uint8_t*& data)
|
|||
utilWriteMem(data, gbSgbATFList, 45 * 20 * 18);
|
||||
}
|
||||
|
||||
void gbSgbReadGame(const uint8_t*& data, int version)
|
||||
void gbSgbReadGame(const uint8_t*& data)
|
||||
{
|
||||
utilReadDataMem(data, gbSgbSaveStructV3);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ void gbSgbDoBitTransfer(uint8_t);
|
|||
void gbSgbRenderBorder();
|
||||
#ifdef __LIBRETRO__
|
||||
void gbSgbSaveGame(uint8_t*&);
|
||||
void gbSgbReadGame(const uint8_t*&, int);
|
||||
void gbSgbReadGame(const uint8_t*&);
|
||||
#else
|
||||
void gbSgbSaveGame(gzFile);
|
||||
void gbSgbReadGame(gzFile, int version);
|
||||
|
|
|
@ -449,7 +449,7 @@ void gbSoundSaveGame(gzFile out)
|
|||
}
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
void gbSoundReadGame(const uint8_t*& in, int version)
|
||||
void gbSoundReadGame(const uint8_t*& in)
|
||||
#else
|
||||
void gbSoundReadGame(int version, gzFile in)
|
||||
#endif
|
||||
|
|
|
@ -70,7 +70,7 @@ extern int soundTicks; // Number of 16.8 MHz clocks until gbSoundTick() will be
|
|||
// Saves/loads emulator state
|
||||
#ifdef __LIBRETRO__
|
||||
void gbSoundSaveGame(uint8_t*&);
|
||||
void gbSoundReadGame(const uint8_t*&, int);
|
||||
void gbSoundReadGame(const uint8_t*&);
|
||||
#else
|
||||
void gbSoundSaveGame(gzFile out);
|
||||
void gbSoundReadGame(int version, gzFile in);
|
||||
|
|
|
@ -51,16 +51,11 @@ void eepromSaveGame(uint8_t*& data)
|
|||
utilWriteMem(data, eepromData, SIZE_EEPROM_8K);
|
||||
}
|
||||
|
||||
void eepromReadGame(const uint8_t*& data, int version)
|
||||
void eepromReadGame(const uint8_t*& data)
|
||||
{
|
||||
utilReadDataMem(data, eepromSaveData);
|
||||
if (version >= SAVE_GAME_VERSION_3) {
|
||||
eepromSize = utilReadIntMem(data);
|
||||
utilReadMem(eepromData, data, SIZE_EEPROM_8K);
|
||||
} else {
|
||||
// prior to 0.7.1, only 4K EEPROM was supported
|
||||
eepromSize = SIZE_EEPROM_512;
|
||||
}
|
||||
eepromSize = utilReadIntMem(data);
|
||||
utilReadMem(eepromData, data, SIZE_EEPROM_8K);
|
||||
}
|
||||
|
||||
#else // !__LIBRETRO__
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#ifdef __LIBRETRO__
|
||||
extern void eepromSaveGame(uint8_t*& data);
|
||||
extern void eepromReadGame(const uint8_t*& data, int version);
|
||||
extern void eepromReadGame(const uint8_t*& data);
|
||||
#else // !__LIBRETRO__
|
||||
extern void eepromSaveGame(gzFile _gzFile);
|
||||
extern void eepromReadGame(gzFile _gzFile, int version);
|
||||
|
|
|
@ -228,7 +228,7 @@ void flashSaveGame(uint8_t*& data)
|
|||
utilWriteDataMem(data, flashSaveData3);
|
||||
}
|
||||
|
||||
void flashReadGame(const uint8_t*& data, int)
|
||||
void flashReadGame(const uint8_t*& data)
|
||||
{
|
||||
utilReadDataMem(data, flashSaveData3);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#ifdef __LIBRETRO__
|
||||
extern void flashSaveGame(uint8_t*& data);
|
||||
extern void flashReadGame(const uint8_t*& data, int);
|
||||
extern void flashReadGame(const uint8_t*& data);
|
||||
#else
|
||||
extern void flashSaveGame(gzFile _gzFile);
|
||||
extern void flashReadGame(gzFile _gzFile, int version);
|
||||
|
|
|
@ -578,7 +578,7 @@ void CPUUpdateRenderBuffers(bool force)
|
|||
#ifdef __LIBRETRO__
|
||||
#include <stddef.h>
|
||||
|
||||
unsigned int CPUWriteState(uint8_t* data, unsigned size)
|
||||
unsigned int CPUWriteState(uint8_t* data)
|
||||
{
|
||||
uint8_t* orig = data;
|
||||
|
||||
|
@ -608,12 +608,7 @@ unsigned int CPUWriteState(uint8_t* data, unsigned size)
|
|||
return (ptrdiff_t)data - (ptrdiff_t)orig;
|
||||
}
|
||||
|
||||
bool CPUWriteMemState(char* memory, int available, long& reserved)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPUReadState(const uint8_t* data, unsigned size)
|
||||
bool CPUReadState(const uint8_t* data)
|
||||
{
|
||||
// Don't really care about version.
|
||||
int version = utilReadIntMem(data);
|
||||
|
@ -650,9 +645,9 @@ bool CPUReadState(const uint8_t* data, unsigned size)
|
|||
utilReadMem(pix, data, SIZE_PIX);
|
||||
utilReadMem(ioMem, data, SIZE_IOMEM);
|
||||
|
||||
eepromReadGame(data, version);
|
||||
flashReadGame(data, version);
|
||||
soundReadGame(data, version);
|
||||
eepromReadGame(data);
|
||||
flashReadGame(data);
|
||||
soundReadGame(data);
|
||||
rtcReadGame(data);
|
||||
|
||||
//// Copypasta stuff ...
|
||||
|
@ -4260,14 +4255,15 @@ struct EmulatedSystem GBASystem = {
|
|||
CPUReadState,
|
||||
// emuWriteState
|
||||
CPUWriteState,
|
||||
// emuReadMemState
|
||||
#ifdef __LIBRETRO__
|
||||
NULL,
|
||||
NULL, // emuReadMemState
|
||||
NULL, // emuWriteMemState
|
||||
#else
|
||||
// emuReadMemState
|
||||
CPUReadMemState,
|
||||
#endif
|
||||
// emuWriteMemState
|
||||
CPUWriteMemState,
|
||||
#endif
|
||||
#ifdef __LIBRETRO__
|
||||
NULL, // emuWritePNG
|
||||
NULL, // emuWriteBMP
|
||||
|
|
|
@ -136,7 +136,7 @@ extern void CPUUpdateRenderBuffers(bool);
|
|||
extern bool CPUReadMemState(char*, int);
|
||||
extern bool CPUWriteMemState(char*, int);
|
||||
#ifdef __LIBRETRO__
|
||||
extern bool CPUReadState(const uint8_t*, unsigned);
|
||||
extern bool CPUReadState(const uint8_t*);
|
||||
extern unsigned int CPUWriteState(uint8_t* data, unsigned int size);
|
||||
#else
|
||||
extern bool CPUReadState(const char*);
|
||||
|
|
|
@ -799,7 +799,7 @@ static void soundReadGameOld(gzFile in, int version)
|
|||
#include <stdio.h>
|
||||
|
||||
#ifdef __LIBRETRO__
|
||||
void soundReadGame(const uint8_t*& in, int version)
|
||||
void soundReadGame(const uint8_t*& in)
|
||||
#else
|
||||
void soundReadGame(gzFile in, int version)
|
||||
#endif
|
||||
|
|
|
@ -78,7 +78,7 @@ extern int soundTicks;
|
|||
// Saves/loads emulator state
|
||||
#ifdef __LIBRETRO__
|
||||
void soundSaveGame(uint8_t*&);
|
||||
void soundReadGame(const uint8_t*& in, int version);
|
||||
void soundReadGame(const uint8_t*& in);
|
||||
#else
|
||||
void soundSaveGame(gzFile);
|
||||
void soundReadGame(gzFile, int version);
|
||||
|
|
|
@ -1438,14 +1438,14 @@ size_t retro_serialize_size(void)
|
|||
bool retro_serialize(void* data, size_t size)
|
||||
{
|
||||
if (size == serialize_size)
|
||||
return core->emuWriteState((uint8_t*)data, size);
|
||||
return core->emuWriteState((uint8_t*)data);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool retro_unserialize(const void* data, size_t size)
|
||||
{
|
||||
if (size == serialize_size)
|
||||
return core->emuReadState((uint8_t*)data, size);
|
||||
return core->emuReadState((uint8_t*)data);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1678,7 +1678,7 @@ bool retro_load_game(const struct retro_game_info *game)
|
|||
update_input_descriptors(); // Initialize input descriptors and info
|
||||
update_variables(false);
|
||||
uint8_t* state_buf = (uint8_t*)malloc(2000000);
|
||||
serialize_size = core->emuWriteState(state_buf, 2000000);
|
||||
serialize_size = core->emuWriteState(state_buf);
|
||||
free(state_buf);
|
||||
|
||||
emulating = 1;
|
||||
|
|
Loading…
Reference in New Issue