Converted TIADebug to be a DebuggerSystem object. There's some strange

stuff going on in the TIA class ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@625 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-07-08 17:22:41 +00:00
parent 6aa2830d71
commit 0bcf843c89
8 changed files with 358 additions and 298 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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" #include "Array.hxx"
@ -27,7 +27,6 @@ CpuDebug::CpuDebug(Debugger* dbg, Console* console)
: DebuggerSystem(dbg, console), : DebuggerSystem(dbg, console),
mySystem(&(console->system())) mySystem(&(console->system()))
{ {
saveOldState();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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" #include "bspf.hxx"
@ -45,7 +45,7 @@ Debugger::Debugger(OSystem* osystem)
myParser(NULL), myParser(NULL),
myCpuDebug(NULL), myCpuDebug(NULL),
myRamDebug(NULL), myRamDebug(NULL),
myTIAdebug(NULL), myTiaDebug(NULL),
equateList(NULL), equateList(NULL),
breakPoints(NULL), breakPoints(NULL),
readTraps(NULL), readTraps(NULL),
@ -66,7 +66,7 @@ Debugger::~Debugger()
delete myCpuDebug; delete myCpuDebug;
delete myRamDebug; delete myRamDebug;
delete myTIAdebug; delete myTiaDebug;
delete equateList; delete equateList;
delete breakPoints; delete breakPoints;
@ -134,13 +134,8 @@ void Debugger::setConsole(Console* console)
delete myRamDebug; delete myRamDebug;
myRamDebug = new RamDebug(this, myConsole); myRamDebug = new RamDebug(this, myConsole);
// Create a new TIA debugger for this console delete myTiaDebug;
// This code is somewhat ugly, since we derive a TIA from the MediaSource myTiaDebug = new TIADebug(this, myConsole);
// 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);
autoLoadSymbols(myOSystem->romFile()); autoLoadSymbols(myOSystem->romFile());
@ -243,10 +238,10 @@ const string Debugger::cpuState()
sprintf(buf, "%d", mySystem->cycles()); sprintf(buf, "%d", mySystem->cycles());
result += buf; result += buf;
result += " Scan:"; result += " Scan:";
sprintf(buf, "%d", myTIAdebug->scanlines()); sprintf(buf, "%d", myTiaDebug->scanlines());
result += buf; result += buf;
result += " Frame:"; result += " Frame:";
sprintf(buf, "%d", myTIAdebug->frameCount()); sprintf(buf, "%d", myTiaDebug->frameCount());
result += buf; result += buf;
result += " 6502Ins:"; result += " 6502Ins:";
sprintf(buf, "%d", mySystem->m6502().totalInstructionCount()); sprintf(buf, "%d", mySystem->m6502().totalInstructionCount());
@ -472,7 +467,7 @@ const string Debugger::dumpTIA()
} }
result += "\n"; result += "\n";
result += myTIAdebug->state(); result += myTiaDebug->state();
return result; return result;
} }
@ -523,8 +518,12 @@ int Debugger::step()
int cyc = mySystem->cycles(); int cyc = mySystem->cycles();
mySystem->m6502().execute(1); 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); myOSystem->frameBuffer().refreshTIA(true);
///////////////////////////////////////////////////////
return mySystem->cycles() - cyc; return mySystem->cycles() - cyc;
} }
@ -551,8 +550,12 @@ int Debugger::trace()
int targetPC = myCpuDebug->pc() + 3; // return address int targetPC = myCpuDebug->pc() + 3; // return address
while(myCpuDebug->pc() != targetPC) while(myCpuDebug->pc() != targetPC)
mySystem->m6502().execute(1); 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); myOSystem->frameBuffer().refreshTIA(true);
///////////////////////////////////////////////////////
return mySystem->cycles() - cyc; return mySystem->cycles() - cyc;
} else { } else {
return step(); return step();
@ -741,4 +744,5 @@ void Debugger::saveOldState()
{ {
myCpuDebug->saveOldState(); myCpuDebug->saveOldState();
myRamDebug->saveOldState(); myRamDebug->saveOldState();
myTiaDebug->saveOldState();
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 #ifndef DEBUGGER_HXX
@ -53,7 +53,7 @@ enum {
for all debugging operations in Stella (parser, 6502 debugger, etc). for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony @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 class Debugger : public DialogContainer
{ {
@ -104,7 +104,7 @@ class Debugger : public DialogContainer
/** /**
The debugger subsystem responsible for all TIA state The debugger subsystem responsible for all TIA state
*/ */
TIADebug& tiaDebug() { return *myTIAdebug; } TIADebug& tiaDebug() { return *myTiaDebug; }
/** Convenience methods to convert to hexidecimal values */ /** Convenience methods to convert to hexidecimal values */
static char *to_hex_4(int i) static char *to_hex_4(int i)
@ -236,7 +236,7 @@ class Debugger : public DialogContainer
DebuggerParser* myParser; DebuggerParser* myParser;
CpuDebug* myCpuDebug; CpuDebug* myCpuDebug;
RamDebug* myRamDebug; RamDebug* myRamDebug;
TIADebug* myTIAdebug; TIADebug* myTiaDebug;
EquateList *equateList; EquateList *equateList;
PackedBitArray *breakPoints; PackedBitArray *breakPoints;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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" #include "Array.hxx"
@ -25,7 +25,6 @@ RamDebug::RamDebug(Debugger* dbg, Console* console)
: DebuggerSystem(dbg, console), : DebuggerSystem(dbg, console),
mySystem(&(console->system())) mySystem(&(console->system()))
{ {
saveOldState();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,16 +13,20 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 "System.hxx"
#include "Debugger.hxx" #include "Debugger.hxx"
TIADebug::TIADebug(TIA *tia) { #include "TIADebug.hxx"
myTIA = tia;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIADebug::TIADebug(Debugger* dbg, Console* console)
: DebuggerSystem(dbg, console),
mySystem(&console->system()),
myTIA((TIA*)&console->mediaSource())
{
nusizStrings[0] = "size=8 copy=1"; nusizStrings[0] = "size=8 copy=1";
nusizStrings[1] = "size=8 copy=2 spac=8"; nusizStrings[1] = "size=8 copy=2 spac=8";
nusizStrings[2] = "size=8 copy=2 spac=$18"; nusizStrings[2] = "size=8 copy=2 spac=$18";
@ -33,35 +37,58 @@ TIADebug::TIADebug(TIA *tia) {
nusizStrings[7] = "size=$20 copy=1"; 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() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int TIADebug::frameCount()
{
return myTIA->myFrameCounter; return myTIA->myFrameCounter;
} }
int TIADebug::scanlines() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int TIADebug::scanlines()
{
return myTIA->scanlines(); return myTIA->scanlines();
} }
bool TIADebug::vsync() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIADebug::vsync()
{
return (myTIA->myVSYNC & 2) == 2; return (myTIA->myVSYNC & 2) == 2;
} }
bool TIADebug::vblank() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIADebug::vblank()
{
return (myTIA->myVBLANK & 2) == 2; return (myTIA->myVBLANK & 2) == 2;
} }
void TIADebug::updateTIA() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIADebug::updateTIA()
{
// not working the way I expected: // not working the way I expected:
// myTIA->updateFrame(myTIA->mySystem->cycles() * 3); // myTIA->updateFrame(myTIA->mySystem->cycles() * 3);
} }
string TIADebug::colorSwatch(uInt8 c) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::colorSwatch(uInt8 c)
{
string ret; string ret;
ret += char((c >> 1) | 0x80); ret += char((c >> 1) | 0x80);
@ -72,7 +99,8 @@ string TIADebug::colorSwatch(uInt8 c) {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string audFreq(uInt8 div) { const string audFreq(uInt8 div)
{
string ret; string ret;
char buf[20]; char buf[20];
@ -81,15 +109,18 @@ const string audFreq(uInt8 div) {
sprintf(buf, "%5.1f", hz); sprintf(buf, "%5.1f", hz);
ret += buf; ret += buf;
ret += "Hz"; ret += "Hz";
return ret; return ret;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string booleanWithLabel(string label, bool value) { const string booleanWithLabel(string label, bool value)
{
char buf[64]; char buf[64];
string ret; string ret;
if(value) { if(value)
{
char *p = buf; char *p = buf;
const char *q = label.c_str(); const char *q = label.c_str();
while((*p++ = toupper(*q++))) while((*p++ = toupper(*q++)))
@ -97,13 +128,14 @@ const string booleanWithLabel(string label, bool value) {
ret += "+"; ret += "+";
ret += buf; ret += buf;
return ret; return ret;
} else {
return "-" + label;
} }
else
return "-" + label;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::state() { string TIADebug::state()
{
string ret; string ret;
// TODO: inverse video for changed regs. Core needs to track this. // TODO: inverse video for changed regs. Core needs to track this.
@ -320,5 +352,6 @@ string TIADebug::state() {
//ret += "\n"; //ret += "\n";
// note: last "ret +=" line should not contain \n, caller will add. // note: last "ret +=" line should not contain \n, caller will add.
return ret; return ret;
} }

View File

@ -13,21 +13,35 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 #ifndef TIA_DEBUG_HXX
#define TIADEBUG_HXX #define TIA_DEBUG_HXX
#include "TIA.hxx" class TIA;
#include "Debugger.hxx" class Debugger;
class TIADebug { #include "Array.hxx"
#include "DebuggerSystem.hxx"
class TiaState : public DebuggerState
{
public: public:
TIADebug(TIA *tia); IntArray ram;
~TIADebug(); };
void setDebugger(Debugger *d); 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 scanlines();
int frameCount(); int frameCount();
@ -37,13 +51,16 @@ class TIADebug {
string state(); string state();
private: private:
TIA *myTIA;
Debugger *myDebugger;
string colorSwatch(uInt8 c); string colorSwatch(uInt8 c);
private:
TiaState myState;
TiaState myOldState;
System* mySystem;
TIA* myTIA;
string nusizStrings[8]; string nusizStrings[8];
}; };
#endif #endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -72,7 +72,7 @@ DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent,
// 5) The TIA tab // 5) The TIA tab
myTab->addTab("TIA"); myTab->addTab("TIA");
TiaWidget* tia = new TiaWidget(myTab, 2, 2, vWidth - vBorder, _h - 25); 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 // 6) The ROM tab

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -23,7 +23,7 @@
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
#include "GuiUtils.hxx" #include "GuiUtils.hxx"
#include "GuiObject.hxx" #include "GuiObject.hxx"
#include "Debugger.hxx" #include "TIADebug.hxx"
#include "Widget.hxx" #include "Widget.hxx"
#include "EditTextWidget.hxx" #include "EditTextWidget.hxx"
#include "DataGridWidget.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 // FIXME - maybe issue a full reload, since changing one item can affect
// others in this tab?? // others in this tab??
loadConfig();
break; break;
case kDGSelectionChangedCmd: case kDGSelectionChangedCmd:
@ -231,6 +232,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::loadConfig() void TiaWidget::loadConfig()
{ {
cerr << "TiaWidget::loadConfig()\n";
fillGrid(); fillGrid();
} }
@ -238,18 +240,21 @@ void TiaWidget::loadConfig()
void TiaWidget::fillGrid() void TiaWidget::fillGrid()
{ {
// FIXME - have these widget get correct values from TIADebug // FIXME - have these widget get correct values from TIADebug
Debugger& dbg = instance()->debugger();
IntArray alist; IntArray alist;
IntArray vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
TIADebug& tia = instance()->debugger().tiaDebug();
TiaState state = (TiaState&) tia.getState();
TiaState oldstate = (TiaState&) tia.getOldState();
// TIA RAM // TIA RAM
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(unsigned int i = 0; i < 16; i++) for(unsigned int i = 0; i < 16; i++)
{ {
alist.push_back(i); alist.push_back(i);
vlist.push_back(i); vlist.push_back(state.ram[i]);
changed.push_back(false); changed.push_back(state.ram[i] != oldstate.ram[i]);
} }
myRamGrid->setList(alist, vlist, changed); myRamGrid->setList(alist, vlist, changed);
@ -270,11 +275,14 @@ void TiaWidget::fillGrid()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaWidget::changeRam() void TiaWidget::changeRam()
{ {
cerr << "TiaWidget::changeRam()\n";
int addr = myRamGrid->getSelectedAddr(); int addr = myRamGrid->getSelectedAddr();
int value = myRamGrid->getSelectedValue(); 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)); myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2)); myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2));
} }