Fixed bug in cheatcode handling; disabled cheats weren't actually being

correctly disabled.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2360 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-01-20 23:56:49 +00:00
parent 08ae1c3fe8
commit 16ad78f468
4 changed files with 25 additions and 23 deletions

View File

@ -22,7 +22,7 @@
ROM after at least one ROM had already been loaded. ROM after at least one ROM had already been loaded.
* Fixed bug in 'Fixed Debug Colors' mode; under certain circumstances, * Fixed bug in 'Fixed Debug Colors' mode; under certain circumstances,
playfield graphics could be colored as being player graphics. playfield graphics could be coloured as being player graphics.
* Several significant improvements to the debugger I/O tab: * Several significant improvements to the debugger I/O tab:
- added controller input widgets for many of the built-in - added controller input widgets for many of the built-in
@ -31,23 +31,20 @@
- added ability to modify the SWCHB/SWBCNT port B registers. - added ability to modify the SWCHB/SWBCNT port B registers.
- added ability to view TIA INPTx and VBLANK latch/dump bits. - added ability to view TIA INPTx and VBLANK latch/dump bits.
* Fixed bug in PAL color-loss setting in Video Settings; changing the
settings wouldn't take effect until the ROM was reloaded.
* Fixed bugs with cheatcode handling; loading a ROM with a cheat
disabled would sometimes trash the emulation. More work is
required in this area, including the ability to create more
advanced types of cheats.
* Updated ROM properties database for all Sega Genesis controller * Updated ROM properties database for all Sega Genesis controller
compatible ROMs. compatible ROMs.
* Fixed compile issues in Irix when using the default compiler * Fixed compile issues in Irix when using the default compiler
instead of gcc. Thanks go to Rainer M. Canavan for this code. instead of gcc. Thanks go to Rainer M. Canavan for this code.
* Fixed bug in PAL color-loss setting in Video Settings; changing the
settings wouldn't take effect until the ROM was reloaded.
* Added CompuMate bankswitching support to the emulation core;
the SpectraVision Compumate ROM now works.
(FIXME - this may not be complete)
* Added emulation for MindLink controller; Bionic Breakthrough, Mind
Maze and Telepathy ROMs now work.
(FIXME - this may not be complete)
-Have fun! -Have fun!

View File

@ -33,6 +33,10 @@ BankRomCheat::BankRomCheat(OSystem* os, const string& name, const string& code)
address = 0xf000 + unhex(myCode.substr(2, 3)); address = 0xf000 + unhex(myCode.substr(2, 3));
value = unhex(myCode.substr(5, 2)); value = unhex(myCode.substr(5, 2));
count = unhex(myCode.substr(7, 1)) + 1; count = unhex(myCode.substr(7, 1)) + 1;
// Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i)
savedRom[i] = myOSystem->console().cartridge().peek(address + i);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -52,7 +56,8 @@ bool BankRomCheat::disable()
{ {
int oldBank = myOSystem->console().cartridge().bank(); int oldBank = myOSystem->console().cartridge().bank();
myOSystem->console().cartridge().bank(bank); myOSystem->console().cartridge().bank(bank);
for(int i=0; i<count; i++)
for(int i = 0; i < count; ++i)
myOSystem->console().cartridge().patch(address + i, savedRom[i]); myOSystem->console().cartridge().patch(address + i, savedRom[i]);
myOSystem->console().cartridge().bank(oldBank); myOSystem->console().cartridge().bank(oldBank);
@ -68,11 +73,9 @@ void BankRomCheat::evaluate()
int oldBank = myOSystem->console().cartridge().bank(); int oldBank = myOSystem->console().cartridge().bank();
myOSystem->console().cartridge().bank(bank); myOSystem->console().cartridge().bank(bank);
for(int i=0; i<count; i++) for(int i = 0; i < count; ++i)
{
savedRom[i] = myOSystem->console().cartridge().peek(address + i);
myOSystem->console().cartridge().patch(address + i, value); myOSystem->console().cartridge().patch(address + i, value);
}
myOSystem->console().cartridge().bank(oldBank); myOSystem->console().cartridge().bank(oldBank);
myEnabled = true; myEnabled = true;

View File

@ -92,6 +92,7 @@ void CheatManager::remove(int idx)
// Then remove it from the cheatlist entirely // Then remove it from the cheatlist entirely
myCheatList.remove_at(idx); myCheatList.remove_at(idx);
c->disable();
delete c; delete c;
} }
@ -297,7 +298,7 @@ void CheatManager::loadCheats(const string& md5sum)
// Set up any cheatcodes that was on the command line // Set up any cheatcodes that was on the command line
// (and remove the key from the settings, so they won't get set again) // (and remove the key from the settings, so they won't get set again)
string cheats = myOSystem->settings().getString("cheat"); const string& cheats = myOSystem->settings().getString("cheat");
if(cheats != "") if(cheats != "")
myOSystem->settings().setString("cheat", ""); myOSystem->settings().setString("cheat", "");

View File

@ -29,6 +29,10 @@ CheetahCheat::CheetahCheat(OSystem* os, const string& name, const string& code)
address = 0xf000 + unhex(code.substr(0, 3)); address = 0xf000 + unhex(code.substr(0, 3));
value = unhex(code.substr(3, 2)); value = unhex(code.substr(3, 2));
count = unhex(code.substr(5, 1)) + 1; count = unhex(code.substr(5, 1)) + 1;
// Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i)
savedRom[i] = myOSystem->console().cartridge().peek(address + i);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -46,7 +50,7 @@ bool CheetahCheat::enable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheetahCheat::disable() bool CheetahCheat::disable()
{ {
for(int i=0; i<count; i++) for(int i = 0; i < count; ++i)
myOSystem->console().cartridge().patch(address + i, savedRom[i]); myOSystem->console().cartridge().patch(address + i, savedRom[i]);
return myEnabled = false; return myEnabled = false;
@ -57,11 +61,8 @@ void CheetahCheat::evaluate()
{ {
if(!myEnabled) if(!myEnabled)
{ {
for(int i=0; i<count; i++) for(int i = 0; i < count; ++i)
{
savedRom[i] = myOSystem->console().cartridge().peek(address + i);
myOSystem->console().cartridge().patch(address + i, value); myOSystem->console().cartridge().patch(address + i, value);
}
myEnabled = true; myEnabled = true;
} }