mirror of https://github.com/stella-emu/stella.git
Implemented stella-extended 7- and 8-digit cheat codes. These are like
Cheetah codes prefixed with a 1- or 2-digit bank number. Try "1236ea1" in Battlezone: it should give infinite lives. "01236ea1" is the same thing with a 2-digit bank number ("01" instead of "1", same bank). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@796 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
2f55b27695
commit
98387c6c80
|
@ -0,0 +1,43 @@
|
|||
|
||||
// FIXME - don't use the debugger for this, since it may not be included
|
||||
//#include "Debugger.hxx"
|
||||
#include "BankRomCheat.hxx"
|
||||
|
||||
BankRomCheat::BankRomCheat(OSystem *os, string code) {
|
||||
myOSystem = os;
|
||||
_enabled = false;
|
||||
|
||||
if(code.length() == 7)
|
||||
code = "0" + code;
|
||||
|
||||
bank = unhex(code.substr(0, 2));
|
||||
address = 0xf000 + unhex(code.substr(2, 3));
|
||||
value = unhex(code.substr(5, 2));
|
||||
count = unhex(code.substr(7, 1)) + 1;
|
||||
}
|
||||
|
||||
BankRomCheat::~BankRomCheat() {
|
||||
}
|
||||
|
||||
bool BankRomCheat::enabled() { return _enabled; }
|
||||
|
||||
bool BankRomCheat::enable() {
|
||||
int oldBank = myOSystem->console().cartridge().bank();
|
||||
myOSystem->console().cartridge().bank(bank);
|
||||
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().bank(oldBank);
|
||||
return _enabled = true;
|
||||
}
|
||||
|
||||
bool BankRomCheat::disable() {
|
||||
int oldBank = myOSystem->console().cartridge().bank();
|
||||
myOSystem->console().cartridge().bank(bank);
|
||||
for(int i=0; i<count; i++) {
|
||||
myOSystem->console().cartridge().patch(address + i, savedRom[i]);
|
||||
}
|
||||
myOSystem->console().cartridge().bank(oldBank);
|
||||
return _enabled = false;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
#ifndef BANK_ROM_CHEAT_HXX
|
||||
#define BANK_ROM_CHEAT_HXX
|
||||
|
||||
#include "OSystem.hxx"
|
||||
#include "Cheat.hxx"
|
||||
|
||||
class BankRomCheat : public Cheat {
|
||||
public:
|
||||
BankRomCheat(OSystem *os, string code);
|
||||
~BankRomCheat();
|
||||
|
||||
virtual bool enabled();
|
||||
virtual bool enable();
|
||||
virtual bool disable();
|
||||
|
||||
|
||||
private:
|
||||
bool _enabled;
|
||||
uInt8 savedRom[16];
|
||||
uInt16 address;
|
||||
uInt8 value;
|
||||
uInt8 count;
|
||||
int bank;
|
||||
OSystem *myOSystem;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "Cheat.hxx"
|
||||
#include "CheetahCheat.hxx"
|
||||
#include "BankRomCheat.hxx"
|
||||
|
||||
uInt16 Cheat::unhex(string hex) {
|
||||
int ret = 0;
|
||||
|
@ -26,6 +27,10 @@ Cheat* Cheat::parse(OSystem *osystem, string code) {
|
|||
return 0;
|
||||
|
||||
switch(code.size()) {
|
||||
case 7:
|
||||
case 8:
|
||||
return new BankRomCheat(osystem, code);
|
||||
|
||||
case 6:
|
||||
return new CheetahCheat(osystem, code);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ MODULE := src/common
|
|||
MODULE_OBJS := \
|
||||
src/common/Cheat.o \
|
||||
src/common/CheetahCheat.o \
|
||||
src/common/BankRomCheat.o \
|
||||
src/common/mainSDL.o \
|
||||
src/common/SoundNull.o \
|
||||
src/common/SoundSDL.o \
|
||||
|
|
Loading…
Reference in New Issue