diff --git a/stella/Debugger.txt b/stella/Debugger.txt index dc9a18b43..a39769c19 100644 --- a/stella/Debugger.txt +++ b/stella/Debugger.txt @@ -60,8 +60,7 @@ What the debugger can do: breakpoints, traps, etc). - Built-in functions for use with "breakif", to support common conditions (such as breaking when the user presses Game Select...) -- Save patched ROM ("saverom filename.bin"). This currently works for every - cart type except DPC (Pitfall II). +- Save patched ROM ("saverom filename.bin"). Planned features for Stella 2.0 release: - Graphical TIA tab, with register names and GUI buttons for diff --git a/stella/src/debugger/Cheat.cxx b/stella/src/debugger/Cheat.cxx new file mode 100644 index 000000000..3fa8ab404 --- /dev/null +++ b/stella/src/debugger/Cheat.cxx @@ -0,0 +1,38 @@ + +#include "Cheat.hxx" +#include "CheetahCheat.hxx" + +uInt16 Cheat::unhex(string hex) { + int ret = 0; + + for(unsigned int i=0; i= '0' && c <= '9') + ret += c - '0'; + else if(c >= 'A' && c <= 'F') + ret += c - 'A' + 10; + else + ret += c - 'a' + 10; + } + + return ret; +} + +Cheat* Cheat::parse(string code) { + for(unsigned int i=0; ienable(); + commandResult = "Cheetah code " + cheat + " enabled\n"; + } else { + commandResult = red("Invalid cheetah code " + cheat + "\n"); } - - 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; ipatchROM(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"; } } diff --git a/stella/src/debugger/module.mk b/stella/src/debugger/module.mk index f1871bd26..e09095c0d 100644 --- a/stella/src/debugger/module.mk +++ b/stella/src/debugger/module.mk @@ -1,6 +1,8 @@ MODULE := src/debugger MODULE_OBJS := \ + src/debugger/Cheat.o \ + src/debugger/CheetahCheat.o \ src/debugger/Debugger.o \ src/debugger/DebuggerParser.o \ src/debugger/EquateList.o \ diff --git a/stella/src/gui/CheatCodeDialog.cxx b/stella/src/gui/CheatCodeDialog.cxx new file mode 100644 index 000000000..372bc4125 --- /dev/null +++ b/stella/src/gui/CheatCodeDialog.cxx @@ -0,0 +1,87 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: CheatCodeDialog.cxx,v 1.1 2005-08-05 02:28:22 urchlay Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "OSystem.hxx" +#include "Props.hxx" +#include "Widget.hxx" +#include "Dialog.hxx" +#include "CheatCodeDialog.hxx" +#include "GuiUtils.hxx" + +#include "bspf.hxx" + +enum { + kEnableCheat = 'ENAC', + kLoadCmd = 'LDCH', +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent, + int x, int y, int w, int h) + : Dialog(osystem, parent, x, y, w, h) +{ + myTitle = new StaticTextWidget(this, 10, 5, w - 20, kFontHeight, "Cheat Codes", kTextAlignCenter); + addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C'); + addButton(w - (kButtonWidth + 10), h - 48, "Load", kLoadCmd, 'C'); + myEnableCheat = new CheckboxWidget(this, 10, 20, kButtonWidth+10, kLineHeight, + "Enabled", kEnableCheat); + myEnableCheat->setState(false); + myCheat = 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CheatCodeDialog::~CheatCodeDialog() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd, + int data, int id) +{ + switch(cmd) + { + case kLoadCmd: + myCheat = Cheat::parse("db000f"); + loadConfig(); + break; + + case kEnableCheat: + if(!myCheat) + myEnableCheat->setState(false); + else if(myCheat->enabled()) + myCheat->disable(); + else + myCheat->enable(); + + break; + + default: + Dialog::handleCommand(sender, cmd, data, 0); + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CheatCodeDialog::loadConfig() { + cerr << "CheatCodeDialog::loadConfig()" << endl; + + myEnableCheat->setState(myCheat && myCheat->enabled()); + myEnableCheat->setEnabled(myCheat != 0); +} diff --git a/stella/src/gui/CheatCodeDialog.hxx b/stella/src/gui/CheatCodeDialog.hxx new file mode 100644 index 000000000..3c1a7c938 --- /dev/null +++ b/stella/src/gui/CheatCodeDialog.hxx @@ -0,0 +1,56 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: CheatCodeDialog.hxx,v 1.1 2005-08-05 02:28:22 urchlay Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef CHEAT_CODE_DIALOG_HXX +#define CHEAT_CODE_DIALOG_HXX + +class DialogContainer; +class CommandSender; +class ButtonWidget; +class StaticTextWidget; + +#include "OSystem.hxx" +#include "Dialog.hxx" +#include "Widget.hxx" +#include "Cheat.hxx" +#include "Props.hxx" +#include "bspf.hxx" + +class CheatCodeDialog : public Dialog +{ + public: + CheatCodeDialog(OSystem* osystem, DialogContainer* parent, + int x, int y, int w, int h); + ~CheatCodeDialog(); + + + protected: + ButtonWidget *myExitButton; + StaticTextWidget *myTitle; + CheckboxWidget *myEnableCheat; + + private: + virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); + void loadConfig(); + Cheat *myCheat; +}; + +#endif diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index eab2dee16..c97e6b96b 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.cxx @@ -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: OptionsDialog.cxx,v 1.21 2005-07-05 15:25:44 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.22 2005-08-05 02:28:22 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -41,14 +41,15 @@ enum { kInfoCmd = 'INFO', kHelpCmd = 'HELP', kAboutCmd = 'ABOU', - kExitCmd = 'EXIM' + kExitCmd = 'EXIM', + kCheatCmd = 'CHET' }; enum { kRowHeight = 22, kBigButtonWidth = 90, kMainMenuWidth = (kBigButtonWidth + 2 * 8), - kMainMenuHeight = 7 * kRowHeight + 10, + kMainMenuHeight = 8 * kRowHeight + 10, }; #define addBigButton(label, cmd, hotkey) \ @@ -64,6 +65,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent) myAudioDialog(NULL), myEventMappingDialog(NULL), myGameInfoDialog(NULL), + myCheatCodeDialog(NULL), myHelpDialog(NULL), myAboutDialog(NULL) { @@ -79,6 +81,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent) #endif addBigButton("Event Mapping", kEMapCmd, 0); addBigButton("Game Information", kInfoCmd, 0); + addBigButton("Cheat Code", kCheatCmd, 0); addBigButton("Help", kHelpCmd, 0); addBigButton("About", kAboutCmd, 0); addBigButton("Exit Menu", kExitCmd, 0); @@ -105,6 +108,10 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent) checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); myGameInfoDialog = new GameInfoDialog(myOSystem, parent, x, y, w, h); + w = 255; h = 150; + checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); + myCheatCodeDialog = new CheatCodeDialog(myOSystem, parent, x, y, w, h); + w = 255; h = 150; checkBounds(fbWidth, fbHeight, &x, &y, &w, &h); myHelpDialog = new HelpDialog(myOSystem, parent, x, y, w, h); @@ -121,6 +128,7 @@ OptionsDialog::~OptionsDialog() delete myAudioDialog; delete myEventMappingDialog; delete myGameInfoDialog; + delete myCheatCodeDialog; delete myHelpDialog; delete myAboutDialog; } @@ -168,6 +176,10 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd, parent()->addDialog(myGameInfoDialog); break; + case kCheatCmd: + parent()->addDialog(myCheatCodeDialog); + break; + case kHelpCmd: parent()->addDialog(myHelpDialog); break; diff --git a/stella/src/gui/OptionsDialog.hxx b/stella/src/gui/OptionsDialog.hxx index 0a350677b..d7d26caf6 100644 --- a/stella/src/gui/OptionsDialog.hxx +++ b/stella/src/gui/OptionsDialog.hxx @@ -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: OptionsDialog.hxx,v 1.11 2005-07-05 15:25:44 stephena Exp $ +// $Id: OptionsDialog.hxx,v 1.12 2005-08-05 02:28:22 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -34,6 +34,7 @@ class AboutDialog; #include "OSystem.hxx" #include "Dialog.hxx" #include "GameInfoDialog.hxx" +#include "CheatCodeDialog.hxx" #include "bspf.hxx" class OptionsDialog : public Dialog @@ -52,6 +53,7 @@ class OptionsDialog : public Dialog AudioDialog* myAudioDialog; EventMappingDialog* myEventMappingDialog; GameInfoDialog* myGameInfoDialog; + CheatCodeDialog* myCheatCodeDialog; HelpDialog* myHelpDialog; AboutDialog* myAboutDialog; diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index 67b4fea37..689aa38af 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -6,6 +6,7 @@ MODULE_OBJS := \ src/gui/AudioDialog.o \ src/gui/BrowserDialog.o \ src/gui/ColorWidget.o \ + src/gui/CheatCodeDialog.o \ src/gui/DataGridWidget.o \ src/gui/DebuggerDialog.o \ src/gui/DialogContainer.o \