diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 1e4cbf494..0f9af3bc0 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.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: Debugger.cxx,v 1.33 2005-06-24 13:51:55 urchlay Exp $ +// $Id: Debugger.cxx,v 1.34 2005-06-24 16:36:41 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -467,6 +467,51 @@ void Debugger::toggleN() { myDebugger->ps( myDebugger->ps() ^ 0x80 ); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // NV-BDIZC +void Debugger::setC(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 0, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x01 ); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::setZ(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 1, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x02 ); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::setI(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 2, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x04 ); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::setD(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 3, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x08 ); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::setB(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 4, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x10 ); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::setV(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 6, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x40 ); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::setN(bool value) { + myDebugger->ps( set_bit(myDebugger->ps(), 7, value) ); + // myDebugger->ps( myDebugger->ps() ^ 0x80 ); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EquateList *Debugger::equates() { return equateList; diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 6ee9a02b7..56f4348fb 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.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: Debugger.hxx,v 1.30 2005-06-24 13:51:57 urchlay Exp $ +// $Id: Debugger.hxx,v 1.31 2005-06-24 16:36:41 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -51,7 +51,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.30 2005-06-24 13:51:57 urchlay Exp $ + @version $Id: Debugger.hxx,v 1.31 2005-06-24 16:36:41 urchlay Exp $ */ class Debugger : public DialogContainer { @@ -125,6 +125,14 @@ class Debugger : public DialogContainer return to_bin(dec, 16, buf); } + static unsigned char set_bit(unsigned char input, int bit, bool value) { + if(value) + return input | (1 << bit); + else + return input & (~(1 << bit)); + } + + int stringToValue(const string& stringval) { return myParser->decipher_arg(stringval); } const string valueToString(int value, BaseFormat outputBase = kBASE_DEFAULT); @@ -198,6 +206,13 @@ class Debugger : public DialogContainer void toggleI(); void toggleZ(); void toggleC(); + void setN(bool value); + void setV(bool value); + void setB(bool value); + void setD(bool value); + void setI(bool value); + void setZ(bool value); + void setC(bool value); void reset(); void autoLoadSymbols(string file); void nextFrame(int frames); diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 63877eeb9..def7a059a 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.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: DebuggerParser.cxx,v 1.33 2005-06-24 12:10:31 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.34 2005-06-24 16:36:41 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -448,15 +448,40 @@ string DebuggerParser::run(const string& command) { else return "one argument required"; } else if(subStringMatch(verb, "c")) { - debugger->toggleC(); + if(argCount == 0) + debugger->toggleC(); + else if(argCount == 1) + debugger->setC(args[0]); + else + return "0 or 1 arguments required"; } else if(subStringMatch(verb, "z")) { - debugger->toggleZ(); + if(argCount == 0) + debugger->toggleZ(); + else if(argCount == 1) + debugger->setZ(args[0]); + else + return "0 or 1 arguments required"; } else if(subStringMatch(verb, "n")) { - debugger->toggleN(); + if(argCount == 0) + debugger->toggleN(); + else if(argCount == 1) + debugger->setN(args[0]); + else + return "0 or 1 arguments required"; } else if(subStringMatch(verb, "v")) { - debugger->toggleV(); + if(argCount == 0) + debugger->toggleV(); + else if(argCount == 1) + debugger->setV(args[0]); + else + return "0 or 1 arguments required"; } else if(subStringMatch(verb, "d")) { - debugger->toggleD(); + if(argCount == 0) + debugger->toggleD(); + else if(argCount == 1) + debugger->setD(args[0]); + else + return "0 or 1 arguments required"; } else if(subStringMatch(verb, "pc")) { if(argCount == 1) debugger->setPC(args[0]); @@ -652,11 +677,13 @@ string DebuggerParser::run(const string& command) { "break - Set/clear breakpoint at current PC\n" "break xx - Set/clear breakpoint at address xx\n" "c - Toggle Carry Flag\n" + "c xx - Set Carry Flag to value xx (0 or 1)\n" "*cartinfo - Show cartridge information\n" "clearbreaks - Clear all breakpoints\n" "cleartraps - Clear all traps\n" "clearwatches - Clear all watches\n" "d - Toggle Decimal Flag\n" + "d xx - Set Decimal Flag to value xx (0 or 1)\n" "define ll xx - Define label ll with value xx\n" "delwatch xx - Delete watch xx\n" "disasm - Disassemble (from current PC)\n" @@ -670,6 +697,7 @@ string DebuggerParser::run(const string& command) { "listsym - List all currently defined symbols\n" "loadsym f - Load DASM symbols from file f\n" "n - Toggle Negative Flag\n" + "n xx - Set Negative Flag to value xx (0 or 1)\n" "pc xx - Set Program Counter to xx\n" "print xx - Evaluate and print expression xx in hex/decimal/binary\n" //"poke xx yy - Write data yy to address xx (may be ROM, TIA, etc)\n" @@ -689,10 +717,12 @@ string DebuggerParser::run(const string& command) { "trapwrite xx - Trap any write access to location xx\n" "undef ll - Undefine label ll (if defined)\n" "v - Toggle Overflow Flag\n" + "v xx - Set Overflow Flag to value xx (0 or 1)\n" "watch xx - Print contents of location xx before every prompt\n" "x xx - Set X register to xx\n" "y xx - Set Y register to xx\n" "z - Toggle Zero Flag\n" + "z xx - Set Zero Flag to value xx (0 or 1)\n" ; } else { return "unimplemented command (try \"help\")";