Support for Bob Colbert's Cheetah cheat codes, either in the debugger

or on the command line. See http://members.cox.net/rcolbert/ for details.

Cheetah codes are cool, but all they can do is modify ROM. We'll also be
adding some sort of extended Stella cheat code support to allow modifying
RAM, either once or once per frame, like the Game Genie does on an NES.
Most likely the actual codes will resemble Bob's codes, but with extra
digits. Unfortunately there won't be an easy way for the real Cheetah
to support these extended codes :(


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@704 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-07-30 22:08:25 +00:00
parent 3738fc1ca0
commit 43653c53af
3 changed files with 69 additions and 3 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.cxx,v 1.78 2005-07-30 16:25:45 urchlay Exp $
// $Id: Debugger.cxx,v 1.79 2005-07-30 22:08:24 urchlay Exp $
//============================================================================
#include "bspf.hxx"
@ -154,6 +154,13 @@ void Debugger::initialize()
string initBreak = myOSystem->settings().getString("break");
if(initBreak != "") run("break " + initBreak);
myOSystem->settings().setString("break", "", false);
// set up any cheeetah code that was on the command line
// (and remove the key from the settings, so they won't get set again)
string cheetah = myOSystem->settings().getString("cheetah");
if(cheetah != "") run("cheetah " + cheetah);
myOSystem->settings().setString("cheetah", "", false);
autoExec();
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.cxx,v 1.73 2005-07-30 16:25:48 urchlay Exp $
// $Id: DebuggerParser.cxx,v 1.74 2005-07-30 22:08:24 urchlay Exp $
//============================================================================
#include "bspf.hxx"
@ -77,6 +77,15 @@ Command DebuggerParser::commands[] = {
&DebuggerParser::executeC
},
{
"cheetah",
"Use Cheetah cheat code (see http://members.cox.net/rcolbert/)",
false,
// lame: accept 0-4 args instead of inventing a kARG_MULTI_LABEL type
{ kARG_LABEL, kARG_LABEL, kARG_LABEL, kARG_LABEL, kARG_END_ARGS },
&DebuggerParser::executeCheetah
},
{
"clearbreaks",
"Clear all breakpoints",
@ -1285,6 +1294,55 @@ void DebuggerParser::executeC() {
debugger->cpuDebug().setC(args[0]);
}
// "cheetah"
// (see http://members.cox.net/rcolbert/chtdox.htm)
void DebuggerParser::executeCheetah() {
if(argCount == 0) {
commandResult = red("Missing cheat code");
return;
}
for(int arg = 0; arg < argCount; arg++) {
string& cheat = argStrings[arg];
if(cheat.size() != 6) {
commandResult += red(cheat + ": Invalid Cheetah code (must be 6 hex digits)");
return;
}
for(int i=0; i<6; i++) {
if(conv_hex_digit(cheat[i]) < 0) {
commandResult += red(cheat + ": Invalid hex digit in Cheetah code");
return;
}
}
int addr = 0;
for(int i=0; i<3; i++) {
addr = addr * 16 + conv_hex_digit(cheat[i]);
}
addr += 0xf000;
int value = 0;
for(int i=3; i<5; i++) {
value = value * 16 + conv_hex_digit(cheat[i]);
}
int count = conv_hex_digit(cheat[5]) + 1;
for(int i=0; i<count; i++)
debugger->patchROM(addr + i, value);
commandResult += cheat;
commandResult += ": ";
commandResult += debugger->valueToString(count);
commandResult += " address";
if(count != 1) commandResult += "es";
commandResult += " modified.";
if(arg != argCount - 1) commandResult += "\n";
}
}
// "clearbreaks"
void DebuggerParser::executeClearbreaks() {
debugger->clearAllBreakPoints();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.hxx,v 1.39 2005-07-30 16:25:48 urchlay Exp $
// $Id: DebuggerParser.hxx,v 1.40 2005-07-30 22:08:25 urchlay Exp $
//============================================================================
#ifndef DEBUGGER_PARSER_HXX
@ -100,6 +100,7 @@ class DebuggerParser
void executeBreak();
void executeBreakif();
void executeC();
void executeCheetah();
void executeClearbreaks();
void executeCleartraps();
void executeClearwatches();