Fixed bug with SaveKey and AtariVox not properly closing their

memory files before starting another instance of the same ROM.
This commit is contained in:
Stephen Anthony 2016-12-09 19:04:14 -03:30
parent b3c0993dcc
commit f7e712386b
7 changed files with 39 additions and 0 deletions

View File

@ -142,6 +142,13 @@ void AtariVox::clockDataIn(bool value)
myLastDataWriteCycle = cycle; myLastDataWriteCycle = cycle;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AtariVox::close()
{
// Force the EEPROM object to cleanup
myEEPROM.reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AtariVox::systemCyclesReset() void AtariVox::systemCyclesReset()
{ {

View File

@ -82,6 +82,13 @@ class AtariVox : public Controller
*/ */
void update() override { } void update() override { }
/**
Notification method invoked by the system indicating that the
console is about to be destroyed. It may be necessary to override
this method for controllers that need cleanup before exiting.
*/
void close() override;
/** /**
Notification method invoked by the system right before the Notification method invoked by the system right before the
system resets its cycle counter to zero. It may be necessary system resets its cycle counter to zero. It may be necessary

View File

@ -172,6 +172,9 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console::~Console() Console::~Console()
{ {
// Some smart controllers need to be informed that the console is going away
myLeftControl->close();
myRightControl->close();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -167,6 +167,13 @@ class Controller : public Serializable
*/ */
virtual void update() = 0; virtual void update() = 0;
/**
Notification method invoked by the system indicating that the
console is about to be destroyed. It may be necessary to override
this method for controllers that need cleanup before exiting.
*/
virtual void close() { };
/** /**
Notification method invoked by the system right before the Notification method invoked by the system right before the
system resets its cycle counter to zero. It may be necessary system resets its cycle counter to zero. It may be necessary

View File

@ -554,6 +554,7 @@ void OSystem::closeConsole()
// If a previous console existed, save cheats before creating a new one // If a previous console existed, save cheats before creating a new one
myCheatManager->saveCheats(myConsole->properties().get(Cartridge_MD5)); myCheatManager->saveCheats(myConsole->properties().get(Cartridge_MD5));
#endif #endif
myConsole.reset();
} }
} }

View File

@ -75,6 +75,13 @@ void SaveKey::write(DigitalPin pin, bool value)
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SaveKey::close()
{
// Force the EEPROM object to cleanup
myEEPROM.reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SaveKey::systemCyclesReset() void SaveKey::systemCyclesReset()
{ {

View File

@ -77,6 +77,13 @@ class SaveKey : public Controller
*/ */
void update() override { } void update() override { }
/**
Notification method invoked by the system indicating that the
console is about to be destroyed. It may be necessary to override
this method for controllers that need cleanup before exiting.
*/
void close() override;
/** /**
Notification method invoked by the system right before the Notification method invoked by the system right before the
system resets its cycle counter to zero. It may be necessary system resets its cycle counter to zero. It may be necessary