diff --git a/stella/src/debugger/CpuDebug.cxx b/stella/src/debugger/CpuDebug.cxx index c03a1d51f..54b445000 100644 --- a/stella/src/debugger/CpuDebug.cxx +++ b/stella/src/debugger/CpuDebug.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: CpuDebug.cxx,v 1.2 2005-07-08 14:36:17 stephena Exp $ +// $Id: CpuDebug.cxx,v 1.3 2005-07-08 17:22:40 stephena Exp $ //============================================================================ #include "Array.hxx" @@ -27,7 +27,6 @@ CpuDebug::CpuDebug(Debugger* dbg, Console* console) : DebuggerSystem(dbg, console), mySystem(&(console->system())) { - saveOldState(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index b76f826fa..fb3793389 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.56 2005-07-08 14:36:17 stephena Exp $ +// $Id: Debugger.cxx,v 1.57 2005-07-08 17:22:40 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -45,7 +45,7 @@ Debugger::Debugger(OSystem* osystem) myParser(NULL), myCpuDebug(NULL), myRamDebug(NULL), - myTIAdebug(NULL), + myTiaDebug(NULL), equateList(NULL), breakPoints(NULL), readTraps(NULL), @@ -66,7 +66,7 @@ Debugger::~Debugger() delete myCpuDebug; delete myRamDebug; - delete myTIAdebug; + delete myTiaDebug; delete equateList; delete breakPoints; @@ -134,13 +134,8 @@ void Debugger::setConsole(Console* console) delete myRamDebug; myRamDebug = new RamDebug(this, myConsole); - // Create a new TIA debugger for this console - // This code is somewhat ugly, since we derive a TIA from the MediaSource - // for no particular reason. Maybe it's better to make the TIA be the - // base class and entirely eliminate MediaSource class?? - delete myTIAdebug; - myTIAdebug = new TIADebug((TIA*)&myConsole->mediaSource()); - myTIAdebug->setDebugger(this); + delete myTiaDebug; + myTiaDebug = new TIADebug(this, myConsole); autoLoadSymbols(myOSystem->romFile()); @@ -243,10 +238,10 @@ const string Debugger::cpuState() sprintf(buf, "%d", mySystem->cycles()); result += buf; result += " Scan:"; - sprintf(buf, "%d", myTIAdebug->scanlines()); + sprintf(buf, "%d", myTiaDebug->scanlines()); result += buf; result += " Frame:"; - sprintf(buf, "%d", myTIAdebug->frameCount()); + sprintf(buf, "%d", myTiaDebug->frameCount()); result += buf; result += " 6502Ins:"; sprintf(buf, "%d", mySystem->m6502().totalInstructionCount()); @@ -472,7 +467,7 @@ const string Debugger::dumpTIA() } result += "\n"; - result += myTIAdebug->state(); + result += myTiaDebug->state(); return result; } @@ -523,8 +518,12 @@ int Debugger::step() int cyc = mySystem->cycles(); mySystem->m6502().execute(1); - myTIAdebug->updateTIA(); + + // FIXME - this doesn't work yet, pending a partial rewrite of TIA class + myTiaDebug->updateTIA(); myOSystem->frameBuffer().refreshTIA(true); + /////////////////////////////////////////////////////// + return mySystem->cycles() - cyc; } @@ -551,8 +550,12 @@ int Debugger::trace() int targetPC = myCpuDebug->pc() + 3; // return address while(myCpuDebug->pc() != targetPC) mySystem->m6502().execute(1); - myTIAdebug->updateTIA(); + + // FIXME - this doesn't work yet, pending a partial rewrite of TIA class + myTiaDebug->updateTIA(); myOSystem->frameBuffer().refreshTIA(true); + /////////////////////////////////////////////////////// + return mySystem->cycles() - cyc; } else { return step(); @@ -741,4 +744,5 @@ void Debugger::saveOldState() { myCpuDebug->saveOldState(); myRamDebug->saveOldState(); + myTiaDebug->saveOldState(); } diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 303dc5ef1..6378b1a04 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.45 2005-07-08 14:36:17 stephena Exp $ +// $Id: Debugger.hxx,v 1.46 2005-07-08 17:22:40 stephena Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -53,7 +53,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.45 2005-07-08 14:36:17 stephena Exp $ + @version $Id: Debugger.hxx,v 1.46 2005-07-08 17:22:40 stephena Exp $ */ class Debugger : public DialogContainer { @@ -104,7 +104,7 @@ class Debugger : public DialogContainer /** The debugger subsystem responsible for all TIA state */ - TIADebug& tiaDebug() { return *myTIAdebug; } + TIADebug& tiaDebug() { return *myTiaDebug; } /** Convenience methods to convert to hexidecimal values */ static char *to_hex_4(int i) @@ -236,7 +236,7 @@ class Debugger : public DialogContainer DebuggerParser* myParser; CpuDebug* myCpuDebug; RamDebug* myRamDebug; - TIADebug* myTIAdebug; + TIADebug* myTiaDebug; EquateList *equateList; PackedBitArray *breakPoints; diff --git a/stella/src/debugger/RamDebug.cxx b/stella/src/debugger/RamDebug.cxx index 0652660e1..6a34f817d 100644 --- a/stella/src/debugger/RamDebug.cxx +++ b/stella/src/debugger/RamDebug.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: RamDebug.cxx,v 1.3 2005-07-08 14:36:17 stephena Exp $ +// $Id: RamDebug.cxx,v 1.4 2005-07-08 17:22:40 stephena Exp $ //============================================================================ #include "Array.hxx" @@ -25,7 +25,6 @@ RamDebug::RamDebug(Debugger* dbg, Console* console) : DebuggerSystem(dbg, console), mySystem(&(console->system())) { - saveOldState(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/TIADebug.cxx b/stella/src/debugger/TIADebug.cxx index fe0c5de16..d842b0e1e 100644 --- a/stella/src/debugger/TIADebug.cxx +++ b/stella/src/debugger/TIADebug.cxx @@ -13,312 +13,345 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TIADebug.cxx,v 1.8 2005-07-03 08:56:48 urchlay Exp $ +// $Id: TIADebug.cxx,v 1.9 2005-07-08 17:22:40 stephena Exp $ //============================================================================ -#include "TIADebug.hxx" #include "System.hxx" #include "Debugger.hxx" -TIADebug::TIADebug(TIA *tia) { - myTIA = tia; +#include "TIADebug.hxx" - nusizStrings[0] = "size=8 copy=1"; - nusizStrings[1] = "size=8 copy=2 spac=8"; - nusizStrings[2] = "size=8 copy=2 spac=$18"; - nusizStrings[3] = "size=8 copy=3 spac=8"; - nusizStrings[4] = "size=8 copy=2 spac=$38"; - nusizStrings[5] = "size=$10 copy=1"; - nusizStrings[6] = "size=8 copy=3 spac=$18"; - nusizStrings[7] = "size=$20 copy=1"; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +TIADebug::TIADebug(Debugger* dbg, Console* console) + : DebuggerSystem(dbg, console), + mySystem(&console->system()), + myTIA((TIA*)&console->mediaSource()) +{ + nusizStrings[0] = "size=8 copy=1"; + nusizStrings[1] = "size=8 copy=2 spac=8"; + nusizStrings[2] = "size=8 copy=2 spac=$18"; + nusizStrings[3] = "size=8 copy=3 spac=8"; + nusizStrings[4] = "size=8 copy=2 spac=$38"; + nusizStrings[5] = "size=$10 copy=1"; + nusizStrings[6] = "size=8 copy=3 spac=$18"; + nusizStrings[7] = "size=$20 copy=1"; } -TIADebug::~TIADebug() { +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +DebuggerState& TIADebug::getState() +{ + myState.ram.clear(); + for(int i = 0; i < 0x010; ++i) + myState.ram.push_back(mySystem->peek(i)); + + return myState; } -void TIADebug::setDebugger(Debugger *d) { - myDebugger = d; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIADebug::saveOldState() +{ + myOldState.ram.clear(); + for(int i = 0; i < 0x010; ++i) + myOldState.ram.push_back(mySystem->peek(i)); } -int TIADebug::frameCount() { - return myTIA->myFrameCounter; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int TIADebug::frameCount() +{ + return myTIA->myFrameCounter; } -int TIADebug::scanlines() { - return myTIA->scanlines(); +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +int TIADebug::scanlines() +{ + return myTIA->scanlines(); } -bool TIADebug::vsync() { - return (myTIA->myVSYNC & 2) == 2; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TIADebug::vsync() +{ + return (myTIA->myVSYNC & 2) == 2; } -bool TIADebug::vblank() { - return (myTIA->myVBLANK & 2) == 2; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TIADebug::vblank() +{ + return (myTIA->myVBLANK & 2) == 2; } -void TIADebug::updateTIA() { +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIADebug::updateTIA() +{ // not working the way I expected: // myTIA->updateFrame(myTIA->mySystem->cycles() * 3); } -string TIADebug::colorSwatch(uInt8 c) { - string ret; +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string TIADebug::colorSwatch(uInt8 c) +{ + string ret; - ret += char((c >> 1) | 0x80); - ret += "\177 "; - ret += "\177\003 "; + ret += char((c >> 1) | 0x80); + ret += "\177 "; + ret += "\177\003 "; - return ret; + return ret; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string audFreq(uInt8 div) { - string ret; - char buf[20]; +const string audFreq(uInt8 div) +{ + string ret; + char buf[20]; - double hz = 30000.0; - if(div) hz /= div; - sprintf(buf, "%5.1f", hz); - ret += buf; - ret += "Hz"; - return ret; + double hz = 30000.0; + if(div) hz /= div; + sprintf(buf, "%5.1f", hz); + ret += buf; + ret += "Hz"; + + return ret; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string booleanWithLabel(string label, bool value) { - char buf[64]; - string ret; +const string booleanWithLabel(string label, bool value) +{ + char buf[64]; + string ret; - if(value) { - char *p = buf; - const char *q = label.c_str(); - while((*p++ = toupper(*q++))) - ; - ret += "+"; - ret += buf; - return ret; - } else { - return "-" + label; - } + if(value) + { + char *p = buf; + const char *q = label.c_str(); + while((*p++ = toupper(*q++))) + ; + ret += "+"; + ret += buf; + return ret; + } + else + return "-" + label; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string TIADebug::state() { - string ret; +string TIADebug::state() +{ + string ret; - // TODO: inverse video for changed regs. Core needs to track this. - // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR + // TODO: inverse video for changed regs. Core needs to track this. + // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR - // TIA::myCOLUxx are stored 4 copies to each int, we need only 1 - uInt8 COLUP0 = myTIA->myCOLUP0 & 0xff; - uInt8 COLUP1 = myTIA->myCOLUP1 & 0xff; - uInt8 COLUPF = myTIA->myCOLUPF & 0xff; - uInt8 COLUBK = myTIA->myCOLUBK & 0xff; + // TIA::myCOLUxx are stored 4 copies to each int, we need only 1 + uInt8 COLUP0 = myTIA->myCOLUP0 & 0xff; + uInt8 COLUP1 = myTIA->myCOLUP1 & 0xff; + uInt8 COLUPF = myTIA->myCOLUPF & 0xff; + uInt8 COLUBK = myTIA->myCOLUBK & 0xff; - // TIA::myPF holds all 3 PFx regs, we shall extract - int PF = myTIA->myPF; - uInt8 PF0 = PF & 0x0f; - uInt8 PF1 = (PF >> 4) & 0xff; - uInt8 PF2 = (PF >> 12) & 0xff; + // TIA::myPF holds all 3 PFx regs, we shall extract + int PF = myTIA->myPF; + uInt8 PF0 = PF & 0x0f; + uInt8 PF1 = (PF >> 4) & 0xff; + uInt8 PF2 = (PF >> 12) & 0xff; - // Hope Brad never changes this: - uInt16 coll = myTIA->myCollision; + // Hope Brad never changes this: + uInt16 coll = myTIA->myCollision; - // calculate sizes - uInt8 ballSize = 1 << (myTIA->myCTRLPF & 0x18); - uInt8 m0Size = 1 << (myTIA->myNUSIZ0 & 0x18); - uInt8 m1Size = 1 << (myTIA->myNUSIZ1 & 0x18); + // calculate sizes + uInt8 ballSize = 1 << (myTIA->myCTRLPF & 0x18); + uInt8 m0Size = 1 << (myTIA->myNUSIZ0 & 0x18); + uInt8 m1Size = 1 << (myTIA->myNUSIZ1 & 0x18); - // easier to use a table for these: - string p0Size = nusizStrings[myTIA->myNUSIZ0 & 0x07]; - string p1Size = nusizStrings[myTIA->myNUSIZ1 & 0x07]; + // easier to use a table for these: + string p0Size = nusizStrings[myTIA->myNUSIZ0 & 0x07]; + string p1Size = nusizStrings[myTIA->myNUSIZ1 & 0x07]; - // build up output, then return it. - ret += "scanline "; + // build up output, then return it. + ret += "scanline "; - ret += myDebugger->valueToString(myTIA->scanlines()); - ret += " "; + ret += myDebugger->valueToString(myTIA->scanlines()); + ret += " "; - ret += booleanWithLabel("vsync", vsync()); - ret += " "; + ret += booleanWithLabel("vsync", vsync()); + ret += " "; - ret += booleanWithLabel("vblank", vblank()); - ret += "\n"; + ret += booleanWithLabel("vblank", vblank()); + ret += "\n"; - ret += booleanWithLabel("inpt0", myTIA->peek(0x08) & 0x80); - ret += " "; - ret += booleanWithLabel("inpt1", myTIA->peek(0x09) & 0x80); - ret += " "; - ret += booleanWithLabel("inpt2", myTIA->peek(0x0a) & 0x80); - ret += " "; - ret += booleanWithLabel("inpt3", myTIA->peek(0x0b) & 0x80); - ret += " "; - ret += booleanWithLabel("inpt4", myTIA->peek(0x0c) & 0x80); - ret += " "; - ret += booleanWithLabel("inpt5", myTIA->peek(0x0d) & 0x80); - ret += " "; - ret += booleanWithLabel("dump_gnd_0123", myTIA->myDumpEnabled); - ret += "\n"; + ret += booleanWithLabel("inpt0", myTIA->peek(0x08) & 0x80); + ret += " "; + ret += booleanWithLabel("inpt1", myTIA->peek(0x09) & 0x80); + ret += " "; + ret += booleanWithLabel("inpt2", myTIA->peek(0x0a) & 0x80); + ret += " "; + ret += booleanWithLabel("inpt3", myTIA->peek(0x0b) & 0x80); + ret += " "; + ret += booleanWithLabel("inpt4", myTIA->peek(0x0c) & 0x80); + ret += " "; + ret += booleanWithLabel("inpt5", myTIA->peek(0x0d) & 0x80); + ret += " "; + ret += booleanWithLabel("dump_gnd_0123", myTIA->myDumpEnabled); + ret += "\n"; - ret += "COLUP0: "; - ret += myDebugger->valueToString(COLUP0); - ret += "/"; - ret += colorSwatch(COLUP0); + ret += "COLUP0: "; + ret += myDebugger->valueToString(COLUP0); + ret += "/"; + ret += colorSwatch(COLUP0); - ret += "COLUP1: "; - ret += myDebugger->valueToString(COLUP1); - ret += "/"; - ret += colorSwatch(COLUP1); + ret += "COLUP1: "; + ret += myDebugger->valueToString(COLUP1); + ret += "/"; + ret += colorSwatch(COLUP1); - ret += "COLUPF: "; - ret += myDebugger->valueToString(COLUPF); - ret += "/"; - ret += colorSwatch(COLUPF); + ret += "COLUPF: "; + ret += myDebugger->valueToString(COLUPF); + ret += "/"; + ret += colorSwatch(COLUPF); - ret += "COLUBK: "; - ret += myDebugger->valueToString(COLUBK); - ret += "/"; - ret += colorSwatch(COLUBK); + ret += "COLUBK: "; + ret += myDebugger->valueToString(COLUBK); + ret += "/"; + ret += colorSwatch(COLUBK); - ret += "\n"; + ret += "\n"; - ret += "P0: GR="; - // TODO: ret += myDebugger->invIfChanged(myTIA->myGRP0, oldGRP0); - ret += Debugger::to_bin_8(myTIA->myGRP0); - ret += "/"; - ret += myDebugger->valueToString(myTIA->myGRP0); - ret += " pos="; - ret += myDebugger->valueToString(myTIA->myPOSP0); - ret += " HM="; - ret += myDebugger->valueToString(myTIA->myHMP0); - ret += " "; - ret += p0Size; - ret += " "; - ret += booleanWithLabel("reflect", (myTIA->myREFP0)); - ret += " "; - ret += booleanWithLabel("delay", (myTIA->myVDELP0)); - ret += "\n"; + ret += "P0: GR="; + // TODO: ret += myDebugger->invIfChanged(myTIA->myGRP0, oldGRP0); + ret += Debugger::to_bin_8(myTIA->myGRP0); + ret += "/"; + ret += myDebugger->valueToString(myTIA->myGRP0); + ret += " pos="; + ret += myDebugger->valueToString(myTIA->myPOSP0); + ret += " HM="; + ret += myDebugger->valueToString(myTIA->myHMP0); + ret += " "; + ret += p0Size; + ret += " "; + ret += booleanWithLabel("reflect", (myTIA->myREFP0)); + ret += " "; + ret += booleanWithLabel("delay", (myTIA->myVDELP0)); + ret += "\n"; - ret += "P1: GR="; - // TODO: ret += myDebugger->invIfChanged(myTIA->myGRP1, oldGRP1); - ret += Debugger::to_bin_8(myTIA->myGRP1); - ret += "/"; - ret += myDebugger->valueToString(myTIA->myGRP1); - ret += " pos="; - ret += myDebugger->valueToString(myTIA->myPOSP1); - ret += " HM="; - ret += myDebugger->valueToString(myTIA->myHMP1); - ret += " "; - ret += p1Size; - ret += " "; - ret += booleanWithLabel("reflect", (myTIA->myREFP1)); - ret += " "; - ret += booleanWithLabel("delay", (myTIA->myVDELP1)); - ret += "\n"; + ret += "P1: GR="; + // TODO: ret += myDebugger->invIfChanged(myTIA->myGRP1, oldGRP1); + ret += Debugger::to_bin_8(myTIA->myGRP1); + ret += "/"; + ret += myDebugger->valueToString(myTIA->myGRP1); + ret += " pos="; + ret += myDebugger->valueToString(myTIA->myPOSP1); + ret += " HM="; + ret += myDebugger->valueToString(myTIA->myHMP1); + ret += " "; + ret += p1Size; + ret += " "; + ret += booleanWithLabel("reflect", (myTIA->myREFP1)); + ret += " "; + ret += booleanWithLabel("delay", (myTIA->myVDELP1)); + ret += "\n"; - ret += "M0: "; - ret += (myTIA->myENAM0 ? " ENABLED" : "disabled"); - ret += " pos="; - ret += myDebugger->valueToString(myTIA->myPOSM0); - ret += " HM="; - ret += myDebugger->valueToString(myTIA->myHMM0); - ret += " size="; - ret += myDebugger->valueToString(m0Size); - ret += " "; - ret += booleanWithLabel("reset", (myTIA->myRESMP0)); - ret += "\n"; + ret += "M0: "; + ret += (myTIA->myENAM0 ? " ENABLED" : "disabled"); + ret += " pos="; + ret += myDebugger->valueToString(myTIA->myPOSM0); + ret += " HM="; + ret += myDebugger->valueToString(myTIA->myHMM0); + ret += " size="; + ret += myDebugger->valueToString(m0Size); + ret += " "; + ret += booleanWithLabel("reset", (myTIA->myRESMP0)); + ret += "\n"; - ret += "M1: "; - ret += (myTIA->myENAM1 ? " ENABLED" : "disabled"); - ret += " pos="; - ret += myDebugger->valueToString(myTIA->myPOSM1); - ret += " HM="; - ret += myDebugger->valueToString(myTIA->myHMM1); - ret += " size="; - ret += myDebugger->valueToString(m1Size); - ret += " "; - ret += booleanWithLabel("reset", (myTIA->myRESMP1)); - ret += "\n"; + ret += "M1: "; + ret += (myTIA->myENAM1 ? " ENABLED" : "disabled"); + ret += " pos="; + ret += myDebugger->valueToString(myTIA->myPOSM1); + ret += " HM="; + ret += myDebugger->valueToString(myTIA->myHMM1); + ret += " size="; + ret += myDebugger->valueToString(m1Size); + ret += " "; + ret += booleanWithLabel("reset", (myTIA->myRESMP1)); + ret += "\n"; - ret += "BL: "; - ret += (myTIA->myENABL ? " ENABLED" : "disabled"); - ret += " pos="; - ret += myDebugger->valueToString(myTIA->myPOSBL); - ret += " HM="; - ret += myDebugger->valueToString(myTIA->myHMBL); - ret += " size="; - ret += myDebugger->valueToString(ballSize); - ret += " "; - ret += booleanWithLabel("delay", (myTIA->myVDELBL)); - ret += "\n"; + ret += "BL: "; + ret += (myTIA->myENABL ? " ENABLED" : "disabled"); + ret += " pos="; + ret += myDebugger->valueToString(myTIA->myPOSBL); + ret += " HM="; + ret += myDebugger->valueToString(myTIA->myHMBL); + ret += " size="; + ret += myDebugger->valueToString(ballSize); + ret += " "; + ret += booleanWithLabel("delay", (myTIA->myVDELBL)); + ret += "\n"; - ret += "PF0: "; - ret += Debugger::to_bin_8(PF0); - ret += "/"; - ret += myDebugger->valueToString(PF0); - ret += " PF1: "; - ret += Debugger::to_bin_8(PF1); - ret += "/"; - ret += myDebugger->valueToString(PF1); - ret += " PF2: "; - ret += Debugger::to_bin_8(PF2); - ret += "/"; - ret += myDebugger->valueToString(PF2); - ret += "\n "; - ret += booleanWithLabel("reflect", myTIA->myCTRLPF & 0x01); - ret += " "; - ret += booleanWithLabel("score", myTIA->myCTRLPF & 0x02); - ret += " "; - ret += booleanWithLabel("priority", myTIA->myCTRLPF & 0x04); - ret += "\n"; + ret += "PF0: "; + ret += Debugger::to_bin_8(PF0); + ret += "/"; + ret += myDebugger->valueToString(PF0); + ret += " PF1: "; + ret += Debugger::to_bin_8(PF1); + ret += "/"; + ret += myDebugger->valueToString(PF1); + ret += " PF2: "; + ret += Debugger::to_bin_8(PF2); + ret += "/"; + ret += myDebugger->valueToString(PF2); + ret += "\n "; + ret += booleanWithLabel("reflect", myTIA->myCTRLPF & 0x01); + ret += " "; + ret += booleanWithLabel("score", myTIA->myCTRLPF & 0x02); + ret += " "; + ret += booleanWithLabel("priority", myTIA->myCTRLPF & 0x04); + ret += "\n"; - ret += "Collisions: "; - ret += booleanWithLabel("m0_p1 ", bool(coll & 0x0001)); - ret += booleanWithLabel("m0_p0 ", bool(coll & 0x0002)); - ret += booleanWithLabel("m1_p0 ", bool(coll & 0x0004)); - ret += booleanWithLabel("m1_p1 ", bool(coll & 0x0008)); - ret += booleanWithLabel("p0_pf ", bool(coll & 0x0010)); - ret += booleanWithLabel("p0_bl ", bool(coll & 0x0020)); - ret += booleanWithLabel("p1_pf ", bool(coll & 0x0040)); - ret += "\n "; - ret += booleanWithLabel("p1_bl ", bool(coll & 0x0080)); - ret += booleanWithLabel("m0_pf ", bool(coll & 0x0100)); - ret += booleanWithLabel("m0_bl ", bool(coll & 0x0200)); - ret += booleanWithLabel("m1_pf ", bool(coll & 0x0400)); - ret += booleanWithLabel("m1_bl ", bool(coll & 0x0800)); - ret += booleanWithLabel("bl_pf ", bool(coll & 0x1000)); - ret += booleanWithLabel("p0_p1 ", bool(coll & 0x2000)); - ret += booleanWithLabel("m0_m1 ", bool(coll & 0x4000)); - ret += "\n"; + ret += "Collisions: "; + ret += booleanWithLabel("m0_p1 ", bool(coll & 0x0001)); + ret += booleanWithLabel("m0_p0 ", bool(coll & 0x0002)); + ret += booleanWithLabel("m1_p0 ", bool(coll & 0x0004)); + ret += booleanWithLabel("m1_p1 ", bool(coll & 0x0008)); + ret += booleanWithLabel("p0_pf ", bool(coll & 0x0010)); + ret += booleanWithLabel("p0_bl ", bool(coll & 0x0020)); + ret += booleanWithLabel("p1_pf ", bool(coll & 0x0040)); + ret += "\n "; + ret += booleanWithLabel("p1_bl ", bool(coll & 0x0080)); + ret += booleanWithLabel("m0_pf ", bool(coll & 0x0100)); + ret += booleanWithLabel("m0_bl ", bool(coll & 0x0200)); + ret += booleanWithLabel("m1_pf ", bool(coll & 0x0400)); + ret += booleanWithLabel("m1_bl ", bool(coll & 0x0800)); + ret += booleanWithLabel("bl_pf ", bool(coll & 0x1000)); + ret += booleanWithLabel("p0_p1 ", bool(coll & 0x2000)); + ret += booleanWithLabel("m0_m1 ", bool(coll & 0x4000)); + ret += "\n"; - ret += "AUDF0: "; - ret += myDebugger->valueToString(myTIA->myAUDF0); - ret += "/"; - ret += audFreq(myTIA->myAUDF0); - ret += " "; + ret += "AUDF0: "; + ret += myDebugger->valueToString(myTIA->myAUDF0); + ret += "/"; + ret += audFreq(myTIA->myAUDF0); + ret += " "; - ret += "AUDC0: "; - ret += myDebugger->valueToString(myTIA->myAUDC0); - ret += " "; + ret += "AUDC0: "; + ret += myDebugger->valueToString(myTIA->myAUDC0); + ret += " "; - ret += "AUDV0: "; - ret += myDebugger->valueToString(myTIA->myAUDV0); - ret += "\n"; + ret += "AUDV0: "; + ret += myDebugger->valueToString(myTIA->myAUDV0); + ret += "\n"; - ret += "AUDF1: "; - ret += myDebugger->valueToString(myTIA->myAUDF1); - ret += "/"; - ret += audFreq(myTIA->myAUDF1); - ret += " "; + ret += "AUDF1: "; + ret += myDebugger->valueToString(myTIA->myAUDF1); + ret += "/"; + ret += audFreq(myTIA->myAUDF1); + ret += " "; - ret += "AUDC0: "; - ret += myDebugger->valueToString(myTIA->myAUDC1); - ret += " "; + ret += "AUDC0: "; + ret += myDebugger->valueToString(myTIA->myAUDC1); + ret += " "; - ret += "AUDV0: "; - ret += myDebugger->valueToString(myTIA->myAUDV1); - //ret += "\n"; + ret += "AUDV0: "; + ret += myDebugger->valueToString(myTIA->myAUDV1); + //ret += "\n"; - // note: last "ret +=" line should not contain \n, caller will add. - return ret; + // note: last "ret +=" line should not contain \n, caller will add. + + return ret; } diff --git a/stella/src/debugger/TIADebug.hxx b/stella/src/debugger/TIADebug.hxx index 8c5e26233..e9261fc58 100644 --- a/stella/src/debugger/TIADebug.hxx +++ b/stella/src/debugger/TIADebug.hxx @@ -13,37 +13,54 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TIADebug.hxx,v 1.5 2005-07-03 01:36:39 urchlay Exp $ +// $Id: TIADebug.hxx,v 1.6 2005-07-08 17:22:40 stephena Exp $ //============================================================================ -#ifndef TIADEBUG_HXX -#define TIADEBUG_HXX +#ifndef TIA_DEBUG_HXX +#define TIA_DEBUG_HXX -#include "TIA.hxx" -#include "Debugger.hxx" +class TIA; +class Debugger; -class TIADebug { - public: - TIADebug(TIA *tia); - ~TIADebug(); +#include "Array.hxx" +#include "DebuggerSystem.hxx" - void setDebugger(Debugger *d); - - int scanlines(); - int frameCount(); - bool vsync(); - bool vblank(); - void updateTIA(); - string state(); - - private: - TIA *myTIA; - Debugger *myDebugger; - - string colorSwatch(uInt8 c); - - string nusizStrings[8]; +class TiaState : public DebuggerState +{ + public: + IntArray ram; }; +class TIADebug : public DebuggerSystem +{ + public: + TIADebug(Debugger* dbg, Console* console); + + DebuggerState& getState(); + DebuggerState& getOldState() { return myOldState; } + + void saveOldState(); + + // FIXME - add whole slew of setXXX() methods + + int scanlines(); + int frameCount(); + bool vsync(); + bool vblank(); + void updateTIA(); + string state(); + + private: + string colorSwatch(uInt8 c); + + private: + TiaState myState; + TiaState myOldState; + + System* mySystem; + TIA* myTIA; + + string nusizStrings[8]; +}; #endif diff --git a/stella/src/gui/DebuggerDialog.cxx b/stella/src/gui/DebuggerDialog.cxx index 9a1965ecb..a2fd3da42 100644 --- a/stella/src/gui/DebuggerDialog.cxx +++ b/stella/src/gui/DebuggerDialog.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: DebuggerDialog.cxx,v 1.22 2005-07-06 15:09:16 stephena Exp $ +// $Id: DebuggerDialog.cxx,v 1.23 2005-07-08 17:22:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -72,7 +72,7 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent, // 5) The TIA tab myTab->addTab("TIA"); TiaWidget* tia = new TiaWidget(myTab, 2, 2, vWidth - vBorder, _h - 25); - myTab->setParentWidget(3, tia, tia->activeWidget()); + myTab->setParentWidget(4, tia, tia->activeWidget()); // 6) The ROM tab diff --git a/stella/src/gui/TiaWidget.cxx b/stella/src/gui/TiaWidget.cxx index 729a3a4c8..495885b5c 100644 --- a/stella/src/gui/TiaWidget.cxx +++ b/stella/src/gui/TiaWidget.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: TiaWidget.cxx,v 1.5 2005-07-07 15:19:04 stephena Exp $ +// $Id: TiaWidget.cxx,v 1.6 2005-07-08 17:22:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -23,7 +23,7 @@ #include "FrameBuffer.hxx" #include "GuiUtils.hxx" #include "GuiObject.hxx" -#include "Debugger.hxx" +#include "TIADebug.hxx" #include "Widget.hxx" #include "EditTextWidget.hxx" #include "DataGridWidget.hxx" @@ -191,6 +191,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) } // FIXME - maybe issue a full reload, since changing one item can affect // others in this tab?? + loadConfig(); break; case kDGSelectionChangedCmd: @@ -231,6 +232,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaWidget::loadConfig() { +cerr << "TiaWidget::loadConfig()\n"; fillGrid(); } @@ -238,18 +240,21 @@ void TiaWidget::loadConfig() void TiaWidget::fillGrid() { // FIXME - have these widget get correct values from TIADebug - Debugger& dbg = instance()->debugger(); IntArray alist; IntArray vlist; BoolArray changed; + TIADebug& tia = instance()->debugger().tiaDebug(); + TiaState state = (TiaState&) tia.getState(); + TiaState oldstate = (TiaState&) tia.getOldState(); + // TIA RAM alist.clear(); vlist.clear(); changed.clear(); for(unsigned int i = 0; i < 16; i++) { alist.push_back(i); - vlist.push_back(i); - changed.push_back(false); + vlist.push_back(state.ram[i]); + changed.push_back(state.ram[i] != oldstate.ram[i]); } myRamGrid->setList(alist, vlist, changed); @@ -270,11 +275,14 @@ void TiaWidget::fillGrid() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaWidget::changeRam() { -cerr << "TiaWidget::changeRam()\n"; int addr = myRamGrid->getSelectedAddr(); int value = myRamGrid->getSelectedValue(); -//FIXME instance()->debugger().writeRAM(addr - kRamStart, value); + IntArray ram; + ram.push_back(addr); + ram.push_back(value); + + instance()->debugger().setRAM(ram); myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10)); myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); }