Partially untangle the saveTypes. Fixes Pokemon Ruby from freezing on reset.
This commit is contained in:
parent
6771c25a63
commit
40f4c50f7e
|
@ -143,7 +143,24 @@ SoundSDL::~SoundSDL()
|
|||
if (!_initialized)
|
||||
return;
|
||||
|
||||
reset();
|
||||
SDL_mutexP(_mutex);
|
||||
int iSave = emulating;
|
||||
emulating = 0;
|
||||
SDL_SemPost(_semBufferFull);
|
||||
SDL_SemPost(_semBufferEmpty);
|
||||
SDL_mutexV(_mutex);
|
||||
|
||||
SDL_DestroySemaphore(_semBufferFull);
|
||||
SDL_DestroySemaphore(_semBufferEmpty);
|
||||
_semBufferFull = NULL;
|
||||
_semBufferEmpty = NULL;
|
||||
|
||||
SDL_DestroyMutex(_mutex);
|
||||
_mutex = NULL;
|
||||
|
||||
SDL_CloseAudio();
|
||||
|
||||
emulating = iSave;
|
||||
|
||||
_initialized = false;
|
||||
}
|
||||
|
@ -166,22 +183,4 @@ void SoundSDL::resume()
|
|||
|
||||
void SoundSDL::reset()
|
||||
{
|
||||
SDL_mutexP(_mutex);
|
||||
int iSave = emulating;
|
||||
emulating = 0;
|
||||
SDL_SemPost(_semBufferFull);
|
||||
SDL_SemPost(_semBufferEmpty);
|
||||
SDL_mutexV(_mutex);
|
||||
|
||||
SDL_DestroySemaphore(_semBufferFull);
|
||||
SDL_DestroySemaphore(_semBufferEmpty);
|
||||
_semBufferFull = NULL;
|
||||
_semBufferEmpty = NULL;
|
||||
|
||||
SDL_DestroyMutex(_mutex);
|
||||
_mutex = NULL;
|
||||
|
||||
SDL_CloseAudio();
|
||||
|
||||
emulating = iSave;
|
||||
}
|
||||
|
|
|
@ -163,10 +163,10 @@ void flashSaveDecide(u32 address, u8 byte)
|
|||
{
|
||||
// log("Deciding save type %08x\n", address);
|
||||
if(address == 0x0e005555) {
|
||||
saveType = 2;
|
||||
saveType = 3;
|
||||
cpuSaveGameFunc = flashWrite;
|
||||
} else {
|
||||
saveType = 1;
|
||||
saveType = 2;
|
||||
cpuSaveGameFunc = sramWrite;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ void flashSaveDecide(u32 address, u8 byte)
|
|||
|
||||
void flashDelayedWrite(u32 address, u8 byte)
|
||||
{
|
||||
saveType = 2;
|
||||
saveType = 3;
|
||||
cpuSaveGameFunc = flashWrite;
|
||||
flashWrite(address, byte);
|
||||
}
|
||||
|
|
|
@ -3662,7 +3662,6 @@ void CPUReset()
|
|||
dma2Dest = 0;
|
||||
dma3Source = 0;
|
||||
dma3Dest = 0;
|
||||
cpuSaveGameFunc = flashSaveDecide;
|
||||
renderLine = mode0RenderLine;
|
||||
fxOn = false;
|
||||
windowOn = false;
|
||||
|
@ -3691,9 +3690,6 @@ void CPUReset()
|
|||
|
||||
SetMapMasks();
|
||||
|
||||
eepromReset();
|
||||
flashReset();
|
||||
|
||||
soundReset();
|
||||
|
||||
CPUUpdateWindow0();
|
||||
|
@ -3716,14 +3712,16 @@ void CPUReset()
|
|||
cpuFlashEnabled = true;
|
||||
cpuEEPROMEnabled = true;
|
||||
cpuEEPROMSensorEnabled = false;
|
||||
saveType = gbaSaveType = 0;
|
||||
gbaSaveType = 0;
|
||||
cpuSaveGameFunc = flashSaveDecide;
|
||||
break;
|
||||
case 1: // EEPROM
|
||||
eepromReset();
|
||||
cpuSramEnabled = false;
|
||||
cpuFlashEnabled = false;
|
||||
cpuEEPROMEnabled = true;
|
||||
cpuEEPROMSensorEnabled = false;
|
||||
saveType = gbaSaveType = 3;
|
||||
gbaSaveType = 3;
|
||||
// EEPROM usage is automatically detected
|
||||
break;
|
||||
case 2: // SRAM
|
||||
|
@ -3732,15 +3730,16 @@ void CPUReset()
|
|||
cpuEEPROMEnabled = false;
|
||||
cpuEEPROMSensorEnabled = false;
|
||||
cpuSaveGameFunc = sramDelayedWrite; // to insure we detect the write
|
||||
saveType = gbaSaveType = 1;
|
||||
gbaSaveType = 1;
|
||||
break;
|
||||
case 3: // FLASH
|
||||
flashReset();
|
||||
cpuSramEnabled = false;
|
||||
cpuFlashEnabled = true;
|
||||
cpuEEPROMEnabled = false;
|
||||
cpuEEPROMSensorEnabled = false;
|
||||
cpuSaveGameFunc = flashDelayedWrite; // to insure we detect the write
|
||||
saveType = gbaSaveType = 2;
|
||||
gbaSaveType = 2;
|
||||
break;
|
||||
case 4: // EEPROM+Sensor
|
||||
cpuSramEnabled = false;
|
||||
|
@ -3748,7 +3747,7 @@ void CPUReset()
|
|||
cpuEEPROMEnabled = true;
|
||||
cpuEEPROMSensorEnabled = true;
|
||||
// EEPROM usage is automatically detected
|
||||
saveType = gbaSaveType = 3;
|
||||
gbaSaveType = 3;
|
||||
break;
|
||||
case 5: // NONE
|
||||
cpuSramEnabled = false;
|
||||
|
@ -3756,7 +3755,7 @@ void CPUReset()
|
|||
cpuEEPROMEnabled = false;
|
||||
cpuEEPROMSensorEnabled = false;
|
||||
// no save at all
|
||||
saveType = gbaSaveType = 5;
|
||||
gbaSaveType = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ u8 sramRead(u32 address)
|
|||
}
|
||||
void sramDelayedWrite(u32 address, u8 byte)
|
||||
{
|
||||
saveType = 1;
|
||||
saveType = 2;
|
||||
cpuSaveGameFunc = sramWrite;
|
||||
sramWrite(address, byte);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue