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
// 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();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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.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();
}

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.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;

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: 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();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,16 +13,20 @@
// 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"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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";
@ -33,35 +37,58 @@ TIADebug::TIADebug(TIA *tia) {
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;
}
int TIADebug::scanlines() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int TIADebug::scanlines()
{
return myTIA->scanlines();
}
bool TIADebug::vsync() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TIADebug::vsync()
{
return (myTIA->myVSYNC & 2) == 2;
}
bool TIADebug::vblank() {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 TIADebug::colorSwatch(uInt8 c)
{
string ret;
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;
char buf[20];
@ -81,15 +109,18 @@ const string audFreq(uInt8 div) {
sprintf(buf, "%5.1f", hz);
ret += buf;
ret += "Hz";
return ret;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string booleanWithLabel(string label, bool value) {
const string booleanWithLabel(string label, bool value)
{
char buf[64];
string ret;
if(value) {
if(value)
{
char *p = buf;
const char *q = label.c_str();
while((*p++ = toupper(*q++)))
@ -97,13 +128,14 @@ const string booleanWithLabel(string label, bool value) {
ret += "+";
ret += buf;
return ret;
} else {
return "-" + label;
}
else
return "-" + label;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::state() {
string TIADebug::state()
{
string ret;
// TODO: inverse video for changed regs. Core needs to track this.
@ -320,5 +352,6 @@ string TIADebug::state() {
//ret += "\n";
// note: last "ret +=" line should not contain \n, caller will add.
return ret;
}

View File

@ -13,21 +13,35 @@
// 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 {
#include "Array.hxx"
#include "DebuggerSystem.hxx"
class TiaState : public DebuggerState
{
public:
TIADebug(TIA *tia);
~TIADebug();
IntArray ram;
};
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 frameCount();
@ -37,13 +51,16 @@ class TIADebug {
string state();
private:
TIA *myTIA;
Debugger *myDebugger;
string colorSwatch(uInt8 c);
private:
TiaState myState;
TiaState myOldState;
System* mySystem;
TIA* myTIA;
string nusizStrings[8];
};
#endif

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: 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

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: 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));
}