Merge pull request #111 from negativeExponent/fix_warnings

Fix warnings and more cleanups
This commit is contained in:
LibretroAdmin 2022-10-07 10:57:48 +02:00 committed by GitHub
commit 655cfb929d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 123 additions and 116 deletions

View File

@ -20,9 +20,9 @@ struct EmulatedSystem {
bool (*emuWriteBattery)(const char *); bool (*emuWriteBattery)(const char *);
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
// load state // load state
bool (*emuReadState)(const uint8_t *, unsigned); bool (*emuReadState)(const uint8_t *);
// load state // load state
unsigned (*emuWriteState)(uint8_t *, unsigned); unsigned (*emuWriteState)(uint8_t *);
#else #else
// load state // load state
bool (*emuReadState)(const char *); bool (*emuReadState)(const char *);

View File

@ -312,6 +312,7 @@ void utilPutWord(uint8_t *p, uint16_t value)
*p = (value >> 8) & 255; *p = (value >> 8) & 255;
} }
#ifndef __LIBRETRO__
bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix) bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix)
{ {
uint8_t writeBuffer[512 * 3]; uint8_t writeBuffer[512 * 3];
@ -430,6 +431,7 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix)
return true; return true;
} }
#endif /* !__LIBRETRO__ */
extern bool cpuIsMultiBoot; extern bool cpuIsMultiBoot;

View File

@ -26,8 +26,10 @@ std::string get_xdg_user_config_home();
std::string get_xdg_user_data_home(); std::string get_xdg_user_data_home();
void utilReadScreenPixels(uint8_t *dest, int w, int h); void utilReadScreenPixels(uint8_t *dest, int w, int h);
#ifndef __LIBRETRO__
bool utilWritePNGFile(const char *, int, int, uint8_t *); bool utilWritePNGFile(const char *, int, int, uint8_t *);
bool utilWriteBMPFile(const char *, int, int, uint8_t *); bool utilWriteBMPFile(const char *, int, int, uint8_t *);
#endif
void utilApplyIPS(const char *ips, uint8_t **rom, int *size); void utilApplyIPS(const char *ips, uint8_t **rom, int *size);
bool utilIsGBAImage(const char *); bool utilIsGBAImage(const char *);
bool utilIsGBImage(const char *); bool utilIsGBImage(const char *);

View File

@ -4064,7 +4064,6 @@ bool gbReadSaveState(const char* name)
return res; return res;
} }
#endif // !__LIBRETRO__
bool gbWritePNGFile(const char* fileName) bool gbWritePNGFile(const char* fileName)
{ {
@ -4079,6 +4078,7 @@ bool gbWriteBMPFile(const char* fileName)
return utilWriteBMPFile(fileName, 256, 224, pix); return utilWriteBMPFile(fileName, 256, 224, pix);
return utilWriteBMPFile(fileName, 160, 144, pix); return utilWriteBMPFile(fileName, 160, 144, pix);
} }
#endif // !__LIBRETRO__
void gbCleanUp() void gbCleanUp()
{ {
@ -5492,7 +5492,7 @@ bool gbLoadRomData(const char* data, unsigned size)
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
#include <stddef.h> #include <stddef.h>
unsigned int gbWriteSaveState(uint8_t* data, unsigned) unsigned int gbWriteSaveState(uint8_t* data)
{ {
uint8_t* orig = data; uint8_t* orig = data;
@ -5560,7 +5560,7 @@ unsigned int gbWriteSaveState(uint8_t* data, unsigned)
return (ptrdiff_t)data - (ptrdiff_t)orig; return (ptrdiff_t)data - (ptrdiff_t)orig;
} }
bool gbReadSaveState(const uint8_t* data, unsigned) bool gbReadSaveState(const uint8_t* data)
{ {
int version = utilReadIntMem(data); int version = utilReadIntMem(data);
@ -5625,7 +5625,7 @@ bool gbReadSaveState(const uint8_t* data, unsigned)
utilReadMem(&IFF, data, 2); utilReadMem(&IFF, data, 2);
if (gbSgbMode) { if (gbSgbMode) {
gbSgbReadGame(data, version); gbSgbReadGame(data);
} else { } else {
gbSgbMask = 0; // loading a game at the wrong time causes no display 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]; gbMemoryMap[0x0d] = &gbWram[value * 0x1000];
} }
gbSoundReadGame(data, version); gbSoundReadGame(data);
if (gbCgbMode && gbSgbMode) { if (gbCgbMode && gbSgbMode) {
gbSgbMode = 0; gbSgbMode = 0;
@ -5800,27 +5800,7 @@ bool gbReadSaveState(const uint8_t* data, unsigned)
return true; return true;
} }
#endif /* __LIBRETRO__ */
bool gbWriteMemSaveState(char*, int, long&)
{
return false;
}
bool gbReadMemSaveState(char*, int)
{
return false;
}
bool gbReadBatteryFile(const char*)
{
return false;
}
bool gbWriteBatteryFile(const char*)
{
return false;
}
#endif
struct EmulatedSystem GBSystem = { struct EmulatedSystem GBSystem = {
// emuMain // emuMain
@ -5829,6 +5809,16 @@ struct EmulatedSystem GBSystem = {
gbReset, gbReset,
// emuCleanUp // emuCleanUp
gbCleanUp, gbCleanUp,
#ifdef __LIBRETRO__
NULL, // emuReadBattery
NULL, // emuWriteBattery
gbReadSaveState, // emuReadState
gbWriteSaveState, // emuWriteState
NULL, // emuReadMemState
NULL, // emuWriteMemState
NULL, // emuWritePNG
NULL, // emuWriteBMP
#else
// emuReadBattery // emuReadBattery
gbReadBatteryFile, gbReadBatteryFile,
// emuWriteBattery // emuWriteBattery
@ -5845,6 +5835,7 @@ struct EmulatedSystem GBSystem = {
gbWritePNGFile, gbWritePNGFile,
// emuWriteBMP // emuWriteBMP
gbWriteBMPFile, gbWriteBMPFile,
#endif /* ! __LIBRETRO__ */
// emuUpdateCPSR // emuUpdateCPSR
NULL, NULL,
// emuHasDebugger // emuHasDebugger

View File

@ -99,7 +99,7 @@ void gbCheatsReadGameSkip(gzFile gzFile, int version)
} }
} }
} }
#endif #endif /* __LIBRETRO__ */
void gbCheatsSaveCheatList(const char* file) void gbCheatsSaveCheatList(const char* file)
{ {

View File

@ -896,7 +896,7 @@ void gbSgbSaveGame(uint8_t*& data)
utilWriteMem(data, gbSgbATFList, 45 * 20 * 18); utilWriteMem(data, gbSgbATFList, 45 * 20 * 18);
} }
void gbSgbReadGame(const uint8_t*& data, int version) void gbSgbReadGame(const uint8_t*& data)
{ {
utilReadDataMem(data, gbSgbSaveStructV3); utilReadDataMem(data, gbSgbSaveStructV3);

View File

@ -10,7 +10,7 @@ void gbSgbDoBitTransfer(uint8_t);
void gbSgbRenderBorder(); void gbSgbRenderBorder();
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void gbSgbSaveGame(uint8_t*&); void gbSgbSaveGame(uint8_t*&);
void gbSgbReadGame(const uint8_t*&, int); void gbSgbReadGame(const uint8_t*&);
#else #else
void gbSgbSaveGame(gzFile); void gbSgbSaveGame(gzFile);
void gbSgbReadGame(gzFile, int version); void gbSgbReadGame(gzFile, int version);

View File

@ -393,7 +393,7 @@ static void gbSoundReadGameOld(int version, gzFile gzFile)
memcpy(&s.regs[0x20], &gbMemory[0xFF30], 0x10); // wave memcpy(&s.regs[0x20], &gbMemory[0xFF30], 0x10); // wave
} }
#endif #endif // ! __LIBRETRO__
// New state format // New state format
static variable_desc gb_state[] = { static variable_desc gb_state[] = {
@ -429,11 +429,8 @@ static variable_desc gb_state[] = {
{ NULL, 0 } { NULL, 0 }
}; };
#ifdef __LIBRETRO__ #ifndef __LIBRETRO__
void gbSoundSaveGame(uint8_t*& out)
#else
void gbSoundSaveGame(gzFile out) void gbSoundSaveGame(gzFile out)
#endif
{ {
gb_apu->save_state(&state.apu); gb_apu->save_state(&state.apu);
@ -441,31 +438,43 @@ void gbSoundSaveGame(gzFile out)
memset(dummy_state, 0, sizeof dummy_state); memset(dummy_state, 0, sizeof dummy_state);
state.version = 1; state.version = 1;
#ifdef __LIBRETRO__
utilWriteDataMem(out, gb_state);
#else
utilWriteData(out, gb_state); utilWriteData(out, gb_state);
#endif
} }
#ifdef __LIBRETRO__
void gbSoundReadGame(const uint8_t*& in, int version)
#else
void gbSoundReadGame(int version, gzFile in) void gbSoundReadGame(int version, gzFile in)
#endif
{ {
// Prepare APU and default state // Prepare APU and default state
reset_apu(); reset_apu();
gb_apu->save_state(&state.apu); gb_apu->save_state(&state.apu);
#ifdef __LIBRETRO__
utilReadDataMem(in, gb_state);
#else
if (version > 11) if (version > 11)
utilReadData(in, gb_state); utilReadData(in, gb_state);
else else
gbSoundReadGameOld(version, in); gbSoundReadGameOld(version, in);
#endif
gb_apu->load_state(state.apu); gb_apu->load_state(state.apu);
} }
#endif // ! __LIBRETRO__
#ifdef __LIBRETRO__
void gbSoundSaveGame(uint8_t*& out)
{
gb_apu->save_state(&state.apu);
// Be sure areas for expansion get written as zero
memset(dummy_state, 0, sizeof dummy_state);
state.version = 1;
utilWriteDataMem(out, gb_state);
}
void gbSoundReadGame(const uint8_t*& in)
{
// Prepare APU and default state
reset_apu();
gb_apu->save_state(&state.apu);
utilReadDataMem(in, gb_state);
gb_apu->load_state(state.apu);
}
#endif // __LIBRETRO__

View File

@ -70,7 +70,7 @@ extern int soundTicks; // Number of 16.8 MHz clocks until gbSoundTick() will be
// Saves/loads emulator state // Saves/loads emulator state
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void gbSoundSaveGame(uint8_t*&); void gbSoundSaveGame(uint8_t*&);
void gbSoundReadGame(const uint8_t*&, int); void gbSoundReadGame(const uint8_t*&);
#else #else
void gbSoundSaveGame(gzFile out); void gbSoundSaveGame(gzFile out);
void gbSoundReadGame(int version, gzFile in); void gbSoundReadGame(int version, gzFile in);

View File

@ -2825,9 +2825,9 @@ static uint8_t cheatsGetType(uint32_t address)
} }
#endif #endif
#ifdef BKPT_SUPPORT
void cheatsWriteMemory(uint32_t address, uint32_t value) void cheatsWriteMemory(uint32_t address, uint32_t value)
{ {
#ifdef BKPT_SUPPORT
if (cheatsNumber == 0) { if (cheatsNumber == 0) {
int type = cheatsGetType(address); int type = cheatsGetType(address);
uint32_t oldValue = debuggerReadMemory(address); uint32_t oldValue = debuggerReadMemory(address);
@ -2837,12 +2837,10 @@ void cheatsWriteMemory(uint32_t address, uint32_t value)
} }
debuggerWriteMemory(address, value); debuggerWriteMemory(address, value);
} }
#endif
} }
void cheatsWriteHalfWord(uint32_t address, uint16_t value) void cheatsWriteHalfWord(uint32_t address, uint16_t value)
{ {
#ifdef BKPT_SUPPORT
if (cheatsNumber == 0) { if (cheatsNumber == 0) {
int type = cheatsGetType(address); int type = cheatsGetType(address);
uint16_t oldValue = debuggerReadHalfWord(address); uint16_t oldValue = debuggerReadHalfWord(address);
@ -2852,12 +2850,10 @@ void cheatsWriteHalfWord(uint32_t address, uint16_t value)
} }
debuggerWriteHalfWord(address, value); debuggerWriteHalfWord(address, value);
} }
#endif
} }
void cheatsWriteByte(uint32_t address, uint8_t value) void cheatsWriteByte(uint32_t address, uint8_t value)
{ {
#ifdef BKPT_SUPPORT
if (cheatsNumber == 0) { if (cheatsNumber == 0) {
int type = cheatsGetType(address); int type = cheatsGetType(address);
uint8_t oldValue = debuggerReadByte(address); uint8_t oldValue = debuggerReadByte(address);
@ -2867,5 +2863,5 @@ void cheatsWriteByte(uint32_t address, uint8_t value)
} }
debuggerWriteByte(address, value); debuggerWriteByte(address, value);
} }
#endif
} }
#endif

View File

@ -33,9 +33,11 @@ void cheatsReadGameSkip(gzFile file, int version);
void cheatsSaveCheatList(const char* file); void cheatsSaveCheatList(const char* file);
bool cheatsLoadCheatList(const char* file); bool cheatsLoadCheatList(const char* file);
#endif #endif
#ifdef BKPT_SUPPORT
void cheatsWriteMemory(uint32_t address, uint32_t value); void cheatsWriteMemory(uint32_t address, uint32_t value);
void cheatsWriteHalfWord(uint32_t address, uint16_t value); void cheatsWriteHalfWord(uint32_t address, uint16_t value);
void cheatsWriteByte(uint32_t address, uint8_t value); void cheatsWriteByte(uint32_t address, uint8_t value);
#endif
int cheatsCheckKeys(uint32_t keys, uint32_t extended); int cheatsCheckKeys(uint32_t keys, uint32_t extended);
extern int cheatsNumber; extern int cheatsNumber;

View File

@ -51,16 +51,11 @@ void eepromSaveGame(uint8_t*& data)
utilWriteMem(data, eepromData, SIZE_EEPROM_8K); utilWriteMem(data, eepromData, SIZE_EEPROM_8K);
} }
void eepromReadGame(const uint8_t*& data, int version) void eepromReadGame(const uint8_t*& data)
{ {
utilReadDataMem(data, eepromSaveData); utilReadDataMem(data, eepromSaveData);
if (version >= SAVE_GAME_VERSION_3) { eepromSize = utilReadIntMem(data);
eepromSize = utilReadIntMem(data); utilReadMem(eepromData, data, SIZE_EEPROM_8K);
utilReadMem(eepromData, data, SIZE_EEPROM_8K);
} else {
// prior to 0.7.1, only 4K EEPROM was supported
eepromSize = SIZE_EEPROM_512;
}
} }
#else // !__LIBRETRO__ #else // !__LIBRETRO__

View File

@ -5,7 +5,7 @@
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
extern void eepromSaveGame(uint8_t*& data); extern void eepromSaveGame(uint8_t*& data);
extern void eepromReadGame(const uint8_t*& data, int version); extern void eepromReadGame(const uint8_t*& data);
#else // !__LIBRETRO__ #else // !__LIBRETRO__
extern void eepromSaveGame(gzFile _gzFile); extern void eepromSaveGame(gzFile _gzFile);
extern void eepromReadGame(gzFile _gzFile, int version); extern void eepromReadGame(gzFile _gzFile, int version);

View File

@ -228,7 +228,7 @@ void flashSaveGame(uint8_t*& data)
utilWriteDataMem(data, flashSaveData3); utilWriteDataMem(data, flashSaveData3);
} }
void flashReadGame(const uint8_t*& data, int) void flashReadGame(const uint8_t*& data)
{ {
utilReadDataMem(data, flashSaveData3); utilReadDataMem(data, flashSaveData3);
} }

View File

@ -7,7 +7,7 @@
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
extern void flashSaveGame(uint8_t*& data); extern void flashSaveGame(uint8_t*& data);
extern void flashReadGame(const uint8_t*& data, int); extern void flashReadGame(const uint8_t*& data);
#else #else
extern void flashSaveGame(gzFile _gzFile); extern void flashSaveGame(gzFile _gzFile);
extern void flashReadGame(gzFile _gzFile, int version); extern void flashReadGame(gzFile _gzFile, int version);

View File

@ -578,7 +578,7 @@ void CPUUpdateRenderBuffers(bool force)
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
#include <stddef.h> #include <stddef.h>
unsigned int CPUWriteState(uint8_t* data, unsigned size) unsigned int CPUWriteState(uint8_t* data)
{ {
uint8_t* orig = data; uint8_t* orig = data;
@ -608,12 +608,7 @@ unsigned int CPUWriteState(uint8_t* data, unsigned size)
return (ptrdiff_t)data - (ptrdiff_t)orig; return (ptrdiff_t)data - (ptrdiff_t)orig;
} }
bool CPUWriteMemState(char* memory, int available, long& reserved) bool CPUReadState(const uint8_t* data)
{
return false;
}
bool CPUReadState(const uint8_t* data, unsigned size)
{ {
// Don't really care about version. // Don't really care about version.
int version = utilReadIntMem(data); int version = utilReadIntMem(data);
@ -650,9 +645,9 @@ bool CPUReadState(const uint8_t* data, unsigned size)
utilReadMem(pix, data, SIZE_PIX); utilReadMem(pix, data, SIZE_PIX);
utilReadMem(ioMem, data, SIZE_IOMEM); utilReadMem(ioMem, data, SIZE_IOMEM);
eepromReadGame(data, version); eepromReadGame(data);
flashReadGame(data, version); flashReadGame(data);
soundReadGame(data, version); soundReadGame(data);
rtcReadGame(data); rtcReadGame(data);
//// Copypasta stuff ... //// Copypasta stuff ...
@ -1259,6 +1254,7 @@ bool CPUReadBatteryFile(const char* fileName)
return true; return true;
} }
#ifndef __LIBRETRO__
bool CPUWritePNGFile(const char* fileName) bool CPUWritePNGFile(const char* fileName)
{ {
return utilWritePNGFile(fileName, 240, 160, pix); return utilWritePNGFile(fileName, 240, 160, pix);
@ -1268,6 +1264,7 @@ bool CPUWriteBMPFile(const char* fileName)
{ {
return utilWriteBMPFile(fileName, 240, 160, pix); return utilWriteBMPFile(fileName, 240, 160, pix);
} }
#endif /* !__LIBRETRO__ */
bool CPUIsZipFile(const char* file) bool CPUIsZipFile(const char* file)
{ {
@ -4251,6 +4248,16 @@ struct EmulatedSystem GBASystem = {
CPUReset, CPUReset,
// emuCleanUp // emuCleanUp
CPUCleanUp, CPUCleanUp,
#ifdef __LIBRETRO__
NULL, // emuReadBattery
NULL, // emuReadState
CPUReadState, // emuReadState
CPUWriteState, // emuWriteState
NULL, // emuReadMemState
NULL, // emuWriteMemState
NULL, // emuWritePNG
NULL, // emuWriteBMP
#else
// emuReadBattery // emuReadBattery
CPUReadBatteryFile, CPUReadBatteryFile,
// emuWriteBattery // emuWriteBattery
@ -4259,18 +4266,15 @@ struct EmulatedSystem GBASystem = {
CPUReadState, CPUReadState,
// emuWriteState // emuWriteState
CPUWriteState, CPUWriteState,
// emuReadMemState // emuReadMemState
#ifdef __LIBRETRO__
NULL,
#else
CPUReadMemState, CPUReadMemState,
#endif
// emuWriteMemState // emuWriteMemState
CPUWriteMemState, CPUWriteMemState,
// emuWritePNG // emuWritePNG
CPUWritePNGFile, CPUWritePNGFile,
// emuWriteBMP // emuWriteBMP
CPUWriteBMPFile, CPUWriteBMPFile,
#endif
// emuUpdateCPSR // emuUpdateCPSR
CPUUpdateCPSR, CPUUpdateCPSR,
// emuHasDebugger // emuHasDebugger

View File

@ -136,7 +136,7 @@ extern void CPUUpdateRenderBuffers(bool);
extern bool CPUReadMemState(char*, int); extern bool CPUReadMemState(char*, int);
extern bool CPUWriteMemState(char*, int); extern bool CPUWriteMemState(char*, int);
#ifdef __LIBRETRO__ #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); extern unsigned int CPUWriteState(uint8_t* data, unsigned int size);
#else #else
extern bool CPUReadState(const char*); extern bool CPUReadState(const char*);

View File

@ -337,13 +337,16 @@ static void end_frame(blip_time_t time)
stereo_buffer->end_frame(time); stereo_buffer->end_frame(time);
} }
#ifdef __LIBRETRO__
void flush_samples(Multi_Buffer* buffer) void flush_samples(Multi_Buffer* buffer)
{ {
#ifdef __LIBRETRO__
int numSamples = buffer->read_samples((blip_sample_t*)soundFinalWave, buffer->samples_avail()); int numSamples = buffer->read_samples((blip_sample_t*)soundFinalWave, buffer->samples_avail());
soundDriver->write(soundFinalWave, numSamples); soundDriver->write(soundFinalWave, numSamples);
systemOnWriteDataToSoundBuffer(soundFinalWave, numSamples); systemOnWriteDataToSoundBuffer(soundFinalWave, numSamples);
}
#else #else
void flush_samples(Multi_Buffer* buffer)
{
// We want to write the data frame by frame to support legacy audio drivers // We want to write the data frame by frame to support legacy audio drivers
// that don't use the length parameter of the write method. // that don't use the length parameter of the write method.
// TODO: Update the Win32 audio drivers (DS, OAL, XA2), and flush all the // TODO: Update the Win32 audio drivers (DS, OAL, XA2), and flush all the
@ -365,8 +368,8 @@ void flush_samples(Multi_Buffer* buffer)
soundDriver->write(soundFinalWave, soundBufferLen); soundDriver->write(soundFinalWave, soundBufferLen);
systemOnWriteDataToSoundBuffer(soundFinalWave, soundBufferLen); systemOnWriteDataToSoundBuffer(soundFinalWave, soundBufferLen);
} }
#endif
} }
#endif // ! __LIBRETRO__
static void apply_filtering() static void apply_filtering()
{ {
@ -726,25 +729,17 @@ static variable_desc gba_state[] = {
{ NULL, 0 } { NULL, 0 }
}; };
#ifdef __LIBRETRO__ #ifndef __LIBRETRO__
void soundSaveGame(uint8_t*& out)
#else
void soundSaveGame(gzFile out) void soundSaveGame(gzFile out)
#endif
{ {
gb_apu->save_state(&state.apu); gb_apu->save_state(&state.apu);
// Be sure areas for expansion get written as zero // Be sure areas for expansion get written as zero
memset(dummy_state, 0, sizeof dummy_state); memset(dummy_state, 0, sizeof dummy_state);
#ifdef __LIBRETRO__
utilWriteDataMem(out, gba_state);
#else
utilWriteData(out, gba_state); utilWriteData(out, gba_state);
#endif
} }
#ifndef __LIBRETRO__
// Reads and discards count bytes from in // Reads and discards count bytes from in
static void skip_read(gzFile in, int count) static void skip_read(gzFile in, int count)
{ {
@ -794,31 +789,49 @@ static void soundReadGameOld(gzFile in, int version)
(void)utilReadInt(in); // ignore quality (void)utilReadInt(in); // ignore quality
} }
#endif
#include <stdio.h> #include <stdio.h>
#ifdef __LIBRETRO__
void soundReadGame(const uint8_t*& in, int version)
#else
void soundReadGame(gzFile in, int version) void soundReadGame(gzFile in, int version)
#endif
{ {
// Prepare APU and default state // Prepare APU and default state
reset_apu(); reset_apu();
gb_apu->save_state(&state.apu); gb_apu->save_state(&state.apu);
#ifdef __LIBRETRO__
utilReadDataMem(in, gba_state);
#else
if (version > SAVE_GAME_VERSION_9) if (version > SAVE_GAME_VERSION_9)
utilReadData(in, gba_state); utilReadData(in, gba_state);
else else
soundReadGameOld(in, version); soundReadGameOld(in, version);
#endif
gb_apu->load_state(state.apu); gb_apu->load_state(state.apu);
write_SGCNT0_H(READ16LE(&ioMem[SGCNT0_H]) & 0x770F); write_SGCNT0_H(READ16LE(&ioMem[SGCNT0_H]) & 0x770F);
apply_muting(); apply_muting();
} }
#endif // !__LIBRETRO__
#ifdef __LIBRETRO__
void soundSaveGame(uint8_t*& out)
{
gb_apu->save_state(&state.apu);
// Be sure areas for expansion get written as zero
memset(dummy_state, 0, sizeof dummy_state);
utilWriteDataMem(out, gba_state);
}
void soundReadGame(const uint8_t*& in)
{
// Prepare APU and default state
reset_apu();
gb_apu->save_state(&state.apu);
utilReadDataMem(in, gba_state);
gb_apu->load_state(state.apu);
write_SGCNT0_H(READ16LE(&ioMem[SGCNT0_H]) & 0x770F);
apply_muting();
}
#endif // __LIBRETRO__

View File

@ -78,7 +78,7 @@ extern int soundTicks;
// Saves/loads emulator state // Saves/loads emulator state
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void soundSaveGame(uint8_t*&); void soundSaveGame(uint8_t*&);
void soundReadGame(const uint8_t*& in, int version); void soundReadGame(const uint8_t*& in);
#else #else
void soundSaveGame(gzFile); void soundSaveGame(gzFile);
void soundReadGame(gzFile, int version); void soundReadGame(gzFile, int version);

View File

@ -1,6 +1,7 @@
LIBRETRO_COMMON := $(CORE_DIR)/libretro/libretro-common LIBRETRO_COMMON := $(CORE_DIR)/libretro/libretro-common
INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_COMMON)/include INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_COMMON)/include
VBA_DEFINES := -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_DEBUGGER VBA_DEFINES := -D__LIBRETRO__ -DFINAL_VERSION -DC_CORE -DNO_DEBUGGER
VBA_DEFINES += -DNO_PNG
ifeq ($(TILED_RENDERING), 1) ifeq ($(TILED_RENDERING), 1)
VBA_DEFINES += -DTILED_RENDERING VBA_DEFINES += -DTILED_RENDERING

View File

@ -43,11 +43,6 @@ bool cpuIsMultiBoot = false;
const char* loadDotCodeFile; const char* loadDotCodeFile;
const char* saveDotCodeFile; const char* saveDotCodeFile;
bool utilWritePNGFile(const char* fileName, int w, int h, uint8_t* pix)
{
return false;
}
void utilPutDword(uint8_t* p, uint32_t value) void utilPutDword(uint8_t* p, uint32_t value)
{ {
*p++ = value & 255; *p++ = value & 255;
@ -62,11 +57,6 @@ void utilPutWord(uint8_t* p, uint16_t value)
*p = (value >> 8) & 255; *p = (value >> 8) & 255;
} }
bool utilWriteBMPFile(const char* fileName, int w, int h, uint8_t* pix)
{
return false;
}
extern bool cpuIsMultiBoot; extern bool cpuIsMultiBoot;
bool utilIsGBAImage(const char* file) bool utilIsGBAImage(const char* file)

View File

@ -48,6 +48,7 @@ static retro_input_poll_t poll_cb;
static retro_input_state_t input_cb; static retro_input_state_t input_cb;
static retro_environment_t environ_cb; static retro_environment_t environ_cb;
static retro_set_rumble_state_t rumble_cb; static retro_set_rumble_state_t rumble_cb;
static retro_audio_sample_t audio_cb;
retro_audio_sample_batch_t audio_batch_cb; retro_audio_sample_batch_t audio_batch_cb;
static char retro_system_directory[2048]; static char retro_system_directory[2048];
@ -375,6 +376,7 @@ void retro_set_video_refresh(retro_video_refresh_t cb)
void retro_set_audio_sample(retro_audio_sample_t cb) void retro_set_audio_sample(retro_audio_sample_t cb)
{ {
audio_cb = cb;
} }
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
@ -1436,14 +1438,14 @@ size_t retro_serialize_size(void)
bool retro_serialize(void* data, size_t size) bool retro_serialize(void* data, size_t size)
{ {
if (size == serialize_size) if (size == serialize_size)
return core->emuWriteState((uint8_t*)data, size); return core->emuWriteState((uint8_t*)data);
return false; return false;
} }
bool retro_unserialize(const void* data, size_t size) bool retro_unserialize(const void* data, size_t size)
{ {
if (size == serialize_size) if (size == serialize_size)
return core->emuReadState((uint8_t*)data, size); return core->emuReadState((uint8_t*)data);
return false; return false;
} }
@ -1676,7 +1678,7 @@ bool retro_load_game(const struct retro_game_info *game)
update_input_descriptors(); // Initialize input descriptors and info update_input_descriptors(); // Initialize input descriptors and info
update_variables(false); update_variables(false);
uint8_t* state_buf = (uint8_t*)malloc(2000000); uint8_t* state_buf = (uint8_t*)malloc(2000000);
serialize_size = core->emuWriteState(state_buf, 2000000); serialize_size = core->emuWriteState(state_buf);
free(state_buf); free(state_buf);
emulating = 1; emulating = 1;