mirror of https://github.com/stella-emu/stella.git
Added initial trap support. It doesn't quite work yet: when I hit a
trap, the PC keeps getting reset to the start of the frame. FYI, traps are like breakpoints, only they trigger on any access of the trap location (e.g. loading data from it, rather than executing it as a breakpoint). Fixed two nasty bugs: 1. Debugger::disassemble() was printing hex bytes from the wrong address. This is because I used readRAM(), which wants a parameter of 0-127, and reads only from RAM. I *should* have been using peek(), which takes a 16-bit address. In fact, readRAM() is only for the GUI. 2. D6502::disassemble() was printing wrong operands in zero,x and zero,y addressing modes, due to me passing a wrong number of places (and thus creating a wrong format string). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@537 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
8f49bb5d88
commit
bb47a4b341
|
@ -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: makefile,v 1.102 2005-06-20 18:32:10 stephena Exp $
|
||||
## $Id: makefile,v 1.103 2005-06-21 04:30:49 urchlay Exp $
|
||||
##============================================================================
|
||||
|
||||
##============================================================================
|
||||
|
@ -165,7 +165,7 @@ GUI_OBJS = Font.o Menu.o Launcher.o \
|
|||
ProgressDialog.o \
|
||||
DebuggerDialog.o PromptWidget.o CheatWidget.o RamWidget.o CpuWidget.o
|
||||
|
||||
DBG_OBJS = Debugger.o DebuggerParser.o EquateList.o PackedBitArray.o
|
||||
DBG_OBJS = Debugger.o DebuggerParser.o EquateList.o PackedBitArray.o TIADebug.o
|
||||
|
||||
CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
|
||||
CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \
|
||||
|
@ -383,7 +383,7 @@ NullDev.o: $(CORE)/m6502/src/NullDev.cxx $(CORE)/m6502/src/NullDev.hxx
|
|||
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/NullDev.cxx
|
||||
|
||||
System.o: $(CORE)/m6502/src/System.cxx $(CORE)/m6502/src/System.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/m6502/src/System.cxx
|
||||
|
||||
Font.o: $(GUI)/Font.cxx $(GUI)/Font.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/Font.cxx
|
||||
|
@ -492,3 +492,6 @@ EquateList.o: $(DBG)/EquateList.cxx $(DBG)/EquateList.hxx $(DBG)/Equate.hxx
|
|||
|
||||
PackedBitArray.o: $(DBG)/PackedBitArray.cxx $(DBG)/PackedBitArray.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/PackedBitArray.cxx
|
||||
|
||||
TIADebug.o: $(DBG)/TIADebug.cxx $(DBG)/TIADebug.hxx
|
||||
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/TIADebug.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.22 2005-06-21 00:13:49 urchlay Exp $
|
||||
// $Id: Debugger.cxx,v 1.23 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "Debugger.hxx"
|
||||
#include "EquateList.hxx"
|
||||
#include "TIADebug.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Debugger::Debugger(OSystem* osystem)
|
||||
|
@ -45,6 +46,8 @@ Debugger::Debugger(OSystem* osystem)
|
|||
myParser = new DebuggerParser(this);
|
||||
equateList = new EquateList();
|
||||
breakPoints = new PackedBitArray(0x10000);
|
||||
readTraps = new PackedBitArray(0x10000);
|
||||
writeTraps = new PackedBitArray(0x10000);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -54,6 +57,8 @@ Debugger::~Debugger()
|
|||
delete myDebugger;
|
||||
delete equateList;
|
||||
delete breakPoints;
|
||||
delete readTraps;
|
||||
delete writeTraps;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -102,6 +107,7 @@ void Debugger::setConsole(Console* console)
|
|||
// Keep pointers to these items for efficiency
|
||||
myConsole = console;
|
||||
mySystem = &(myConsole->system());
|
||||
myTIAdebug = myConsole->tiaDebugger();
|
||||
|
||||
// Create a new 6502 debugger for this console
|
||||
delete myDebugger;
|
||||
|
@ -302,6 +308,14 @@ const string Debugger::dumpRAM(uInt16 start)
|
|||
return result;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string booleanWithLabel(string label, bool value) {
|
||||
if(value)
|
||||
return label + ":On";
|
||||
else
|
||||
return label + ":Off";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string Debugger::dumpTIA()
|
||||
{
|
||||
|
@ -317,12 +331,20 @@ const string Debugger::dumpTIA()
|
|||
|
||||
if(j == 0x07) result += "- ";
|
||||
}
|
||||
result += "\nscanline ";
|
||||
|
||||
//result += valueToString( myConsole->mediaSource().scanlines() );
|
||||
result += valueToString( myTIAdebug->scanlines() );
|
||||
result += "\n";
|
||||
|
||||
result += booleanWithLabel("VSYNC", myTIAdebug->vsync());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Start the debugger if we aren't already in it.
|
||||
// Returns false if we were already in the debugger.
|
||||
bool Debugger::start()
|
||||
{
|
||||
if(myOSystem->eventHandler().state() != EventHandler::S_DEBUGGER) {
|
||||
|
@ -451,6 +473,34 @@ bool Debugger::breakPoint(int bp) {
|
|||
return breakPoints->isSet(bp) != 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::toggleReadTrap(int t) {
|
||||
mySystem->setTraps(readTraps, writeTraps, this);
|
||||
readTraps->toggle(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::toggleWriteTrap(int t) {
|
||||
mySystem->setTraps(readTraps, writeTraps, this);
|
||||
writeTraps->toggle(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::toggleTrap(int t) {
|
||||
toggleReadTrap(t);
|
||||
toggleWriteTrap(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::readTrap(int t) {
|
||||
return readTraps->isSet(t) != 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::writeTrap(int t) {
|
||||
return writeTraps->isSet(t) != 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int Debugger::getPC() {
|
||||
return myDebugger->pc();
|
||||
|
@ -495,7 +545,7 @@ string Debugger::disassemble(int start, int lines) {
|
|||
int count = myDebugger->disassemble(start, buf, equateList);
|
||||
|
||||
for(int i=0; i<count; i++) {
|
||||
sprintf(bbuf, "%02x ", readRAM(start++));
|
||||
sprintf(bbuf, "%02x ", peek(start++));
|
||||
result += bbuf;
|
||||
}
|
||||
|
||||
|
@ -523,6 +573,15 @@ void Debugger::clearAllBreakPoints() {
|
|||
mySystem->m6502().setBreakPoints(NULL);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::clearAllTraps() {
|
||||
delete readTraps;
|
||||
delete writeTraps;
|
||||
readTraps = new PackedBitArray(0x10000);
|
||||
writeTraps = new PackedBitArray(0x10000);
|
||||
mySystem->setTraps(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int Debugger::peek(int addr) {
|
||||
return mySystem->peek(addr);
|
||||
|
|
|
@ -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.20 2005-06-21 00:13:49 urchlay Exp $
|
||||
// $Id: Debugger.hxx,v 1.21 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_HXX
|
||||
|
@ -31,6 +31,7 @@ class D6502;
|
|||
#include "EquateList.hxx"
|
||||
#include "PackedBitArray.hxx"
|
||||
#include "PromptWidget.hxx"
|
||||
#include "TIADebug.hxx"
|
||||
#include "bspf.hxx"
|
||||
|
||||
enum {
|
||||
|
@ -50,7 +51,7 @@ enum {
|
|||
for all debugging operations in Stella (parser, 6502 debugger, etc).
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Debugger.hxx,v 1.20 2005-06-21 00:13:49 urchlay Exp $
|
||||
@version $Id: Debugger.hxx,v 1.21 2005-06-21 04:30:49 urchlay Exp $
|
||||
*/
|
||||
class Debugger : public DialogContainer
|
||||
{
|
||||
|
@ -130,7 +131,16 @@ class Debugger : public DialogContainer
|
|||
const string valueToString(int value);
|
||||
|
||||
void toggleBreakPoint(int bp);
|
||||
|
||||
bool breakPoint(int bp);
|
||||
void toggleReadTrap(int t);
|
||||
void toggleWriteTrap(int t);
|
||||
void toggleTrap(int t);
|
||||
bool readTrap(int t);
|
||||
bool writeTrap(int t);
|
||||
void clearAllTraps();
|
||||
|
||||
|
||||
string disassemble(int start, int lines);
|
||||
bool setHeight(int height);
|
||||
|
||||
|
@ -200,7 +210,10 @@ class Debugger : public DialogContainer
|
|||
D6502* myDebugger;
|
||||
EquateList *equateList;
|
||||
PackedBitArray *breakPoints;
|
||||
PackedBitArray *readTraps;
|
||||
PackedBitArray *writeTraps;
|
||||
PromptWidget *myPrompt;
|
||||
TIADebug *myTIAdebug;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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.22 2005-06-21 01:05:49 stephena Exp $
|
||||
// $Id: DebuggerParser.cxx,v 1.23 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -358,6 +358,18 @@ string DebuggerParser::delWatch(int which) {
|
|||
return "removed watch";
|
||||
}
|
||||
|
||||
string DebuggerParser::trapStatus(int addr) {
|
||||
string result;
|
||||
result += debugger->valueToString(addr);
|
||||
result += ": ";
|
||||
if(debugger->readTrap(addr))
|
||||
result += "read ";
|
||||
if(debugger->writeTrap(addr))
|
||||
result += "write ";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string DebuggerParser::run(const string& command) {
|
||||
string result;
|
||||
|
||||
|
@ -455,6 +467,28 @@ string DebuggerParser::run(const string& command) {
|
|||
result = debugger->dumpTIA();
|
||||
} else if(subStringMatch(verb, "reset")) {
|
||||
debugger->reset();
|
||||
} else if(subStringMatch(verb, "trap")) {
|
||||
if(argCount != 1)
|
||||
return "one argument required";
|
||||
|
||||
debugger->toggleReadTrap(args[0]);
|
||||
debugger->toggleWriteTrap(args[0]);
|
||||
return trapStatus(args[0]);
|
||||
} else if(subStringMatch(verb, "trapwrite")) {
|
||||
if(argCount != 1)
|
||||
return "one argument required";
|
||||
|
||||
debugger->toggleWriteTrap(args[0]);
|
||||
return trapStatus(args[0]);
|
||||
} else if(subStringMatch(verb, "trapread")) {
|
||||
if(argCount != 1)
|
||||
return "one argument required";
|
||||
|
||||
debugger->toggleReadTrap(args[0]);
|
||||
return trapStatus(args[0]);
|
||||
} else if(subStringMatch(verb, "cleartraps")) {
|
||||
debugger->clearAllTraps();
|
||||
return "cleared all traps";
|
||||
} else if(subStringMatch(verb, "break")) {
|
||||
int bp = -1;
|
||||
|
||||
|
|
|
@ -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.hxx,v 1.13 2005-06-21 00:13:49 urchlay Exp $
|
||||
// $Id: DebuggerParser.hxx,v 1.14 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef DEBUGGER_PARSER_HXX
|
||||
|
@ -59,6 +59,7 @@ class DebuggerParser
|
|||
string listBreaks();
|
||||
string eval();
|
||||
string dump();
|
||||
string trapStatus(int addr);
|
||||
|
||||
Debugger* debugger;
|
||||
|
||||
|
|
|
@ -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: EquateList.cxx,v 1.9 2005-06-21 01:05:49 stephena Exp $
|
||||
// $Id: EquateList.cxx,v 1.10 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <string>
|
||||
|
@ -139,6 +139,7 @@ char *EquateList::getFormatted(int addr, int places) {
|
|||
return res;
|
||||
|
||||
sprintf(fmt, "$%%0%dx", places);
|
||||
//cerr << addr << ", " << fmt << ", " << places << endl;
|
||||
sprintf(buf, fmt, addr);
|
||||
return buf;
|
||||
}
|
||||
|
@ -179,11 +180,16 @@ string EquateList::loadFile(string file) {
|
|||
|
||||
// cerr << "total lines " << lines << endl;
|
||||
|
||||
// allocate enough storage for all the lines
|
||||
// FIXME: decide whether to keep the hard-coded symbols or throw them out
|
||||
// (currently allocating space for them, but throwing them away anyway)
|
||||
Equate *newEquates = new Equate[lines + currentSize + 1];
|
||||
lines = 0;
|
||||
// allocate enough storage for all the lines plus the
|
||||
// hard-coded symbols
|
||||
int hardSize = sizeof(hardCodedEquates)/sizeof(struct Equate) - 1;
|
||||
Equate *newEquates = new Equate[lines + hardSize + 1];
|
||||
lines = hardSize;
|
||||
|
||||
// Make sure the hard-coded equates show up first
|
||||
for(int i=0; i<hardSize; i++) {
|
||||
newEquates[i] = hardCodedEquates[i];
|
||||
}
|
||||
|
||||
// start over, now that we've allocated enough entries.
|
||||
in.clear();
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
#include "TIADebug.hxx"
|
||||
|
||||
TIADebug::TIADebug(TIA *tia) {
|
||||
myTIA = tia;
|
||||
}
|
||||
|
||||
TIADebug::~TIADebug() {
|
||||
}
|
||||
|
||||
int TIADebug::scanlines() {
|
||||
return myTIA->scanlines();
|
||||
}
|
||||
|
||||
bool TIADebug::vsync() {
|
||||
return (myTIA->myVSYNC & 2) == 2;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#ifndef TIADEBUG_HXX
|
||||
#define TIADEBUG_HXX
|
||||
|
||||
#include "TIA.hxx"
|
||||
|
||||
class TIADebug {
|
||||
public:
|
||||
TIADebug(TIA *tia);
|
||||
~TIADebug();
|
||||
|
||||
int scanlines();
|
||||
bool vsync();
|
||||
|
||||
private:
|
||||
TIA *myTIA;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -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: Console.cxx,v 1.57 2005-06-16 12:28:53 stephena Exp $
|
||||
// $Id: Console.cxx,v 1.58 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include "OSystem.hxx"
|
||||
#include "Menu.hxx"
|
||||
#include "Debugger.hxx"
|
||||
#include "TIADebug.hxx"
|
||||
|
||||
#ifdef SNAPSHOT_SUPPORT
|
||||
#include "Snapshot.hxx"
|
||||
|
@ -147,7 +148,7 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
|
|||
m6502->attach(myOSystem->debugger());
|
||||
|
||||
M6532* m6532 = new M6532(*this);
|
||||
TIA* tia = new TIA(*this, myOSystem->settings());
|
||||
TIA *tia = new TIA(*this, myOSystem->settings());
|
||||
tia->setSound(myOSystem->sound());
|
||||
Cartridge* cartridge = Cartridge::create(image, size, myProperties);
|
||||
|
||||
|
@ -158,6 +159,7 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
|
|||
|
||||
// Remember what my media source is
|
||||
myMediaSource = tia;
|
||||
myTIAdebugger = new TIADebug(tia);
|
||||
|
||||
// Reset, the system to its power-on state
|
||||
mySystem->reset();
|
||||
|
@ -210,6 +212,7 @@ Console::~Console()
|
|||
delete mySwitches;
|
||||
delete myControllers[0];
|
||||
delete myControllers[1];
|
||||
delete myTIAdebugger;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: Console.hxx,v 1.32 2005-06-09 15:08:22 stephena Exp $
|
||||
// $Id: Console.hxx,v 1.33 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CONSOLE_HXX
|
||||
|
@ -30,12 +30,13 @@ class System;
|
|||
#include "Control.hxx"
|
||||
#include "Props.hxx"
|
||||
#include "TIA.hxx"
|
||||
#include "TIADebug.hxx"
|
||||
|
||||
/**
|
||||
This class represents the entire game console.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: Console.hxx,v 1.32 2005-06-09 15:08:22 stephena Exp $
|
||||
@version $Id: Console.hxx,v 1.33 2005-06-21 04:30:49 urchlay Exp $
|
||||
*/
|
||||
class Console
|
||||
{
|
||||
|
@ -151,6 +152,8 @@ class Console
|
|||
*/
|
||||
void setPalette();
|
||||
|
||||
TIADebug *tiaDebugger() { return myTIAdebugger; }
|
||||
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
public:
|
||||
/**
|
||||
|
@ -222,6 +225,9 @@ class Console
|
|||
|
||||
// Pointer to the 6502 based system being emulated
|
||||
System* mySystem;
|
||||
|
||||
// Pointer to TIADebug
|
||||
TIADebug *myTIAdebugger;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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: TIA.hxx,v 1.21 2005-06-16 00:55:58 stephena Exp $
|
||||
// $Id: TIA.hxx,v 1.22 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef TIA_HXX
|
||||
|
@ -42,11 +42,13 @@ class Settings;
|
|||
be displayed on screen.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: TIA.hxx,v 1.21 2005-06-16 00:55:58 stephena Exp $
|
||||
@version $Id: TIA.hxx,v 1.22 2005-06-21 04:30:49 urchlay Exp $
|
||||
*/
|
||||
class TIA : public Device , public MediaSource
|
||||
{
|
||||
public:
|
||||
friend class TIADebug;
|
||||
|
||||
/**
|
||||
Create a new TIA for the specified console
|
||||
|
||||
|
|
|
@ -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: D6502.cxx,v 1.8 2005-06-16 01:11:28 stephena Exp $
|
||||
// $Id: D6502.cxx,v 1.9 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -117,13 +117,13 @@ uInt16 D6502::disassemble(uInt16 address, char* buffer, EquateList *equateList)
|
|||
|
||||
case M6502::ZeroX:
|
||||
sprintf(buffer, "%s %s,x ; %d", M6502::ourInstructionMnemonicTable[opcode],
|
||||
equateList->getFormatted(dpeek(mySystem, address + 1), 2),
|
||||
equateList->getFormatted(mySystem->peek(address + 1), 2),
|
||||
M6502::ourInstructionProcessorCycleTable[opcode]);
|
||||
return 2;
|
||||
|
||||
case M6502::ZeroY:
|
||||
sprintf(buffer, "%s %s,y ; %d", M6502::ourInstructionMnemonicTable[opcode],
|
||||
equateList->getFormatted(dpeek(mySystem, address + 1), 2),
|
||||
equateList->getFormatted(mySystem->peek(address + 1), 2),
|
||||
M6502::ourInstructionProcessorCycleTable[opcode]);
|
||||
return 2;
|
||||
|
||||
|
|
|
@ -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: System.cxx,v 1.8 2005-06-16 00:55:58 stephena Exp $
|
||||
// $Id: System.cxx,v 1.9 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -24,6 +24,7 @@
|
|||
#include "System.hxx"
|
||||
#include "Serializer.hxx"
|
||||
#include "Deserializer.hxx"
|
||||
#include "Debugger.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
System::System(uInt16 n, uInt16 m)
|
||||
|
@ -55,6 +56,9 @@ System::System(uInt16 n, uInt16 m)
|
|||
// Set up (de)serializer in case we are asked to save/load state
|
||||
serializer = new Serializer();
|
||||
deserializer = new Deserializer();
|
||||
|
||||
// Start out with traps disabled (the normal case)
|
||||
setTraps(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -309,3 +313,68 @@ System& System::operator = (const System&)
|
|||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void System::setTraps(PackedBitArray *read, PackedBitArray *write, Debugger *debugger) {
|
||||
readTraps = read;
|
||||
writeTraps = write;
|
||||
myDebugger = debugger;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 System::peek(uInt16 addr)
|
||||
{
|
||||
PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift];
|
||||
|
||||
uInt8 result;
|
||||
|
||||
// See if this page uses direct accessing or not
|
||||
if(access.directPeekBase != 0)
|
||||
{
|
||||
result = *(access.directPeekBase + (addr & myPageMask));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = access.device->peek(addr);
|
||||
}
|
||||
|
||||
myDataBusState = result;
|
||||
|
||||
// Check for read traps, but only if there's a Debugger
|
||||
if(myDebugger != NULL && readTraps != NULL) {
|
||||
cerr << "peek(" << addr << ")" << endl;
|
||||
if(readTraps->isSet(addr)) {
|
||||
cerr << "read trap at " << addr << endl;
|
||||
myDebugger->start();
|
||||
cerr << "tried to start debugger" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void System::poke(uInt16 addr, uInt8 value)
|
||||
{
|
||||
PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift];
|
||||
|
||||
// See if this page uses direct accessing or not
|
||||
if(access.directPokeBase != 0)
|
||||
{
|
||||
*(access.directPokeBase + (addr & myPageMask)) = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
access.device->poke(addr, value);
|
||||
}
|
||||
|
||||
myDataBusState = value;
|
||||
|
||||
// Check for write traps, but only if there's a Debugger
|
||||
if(myDebugger != NULL && writeTraps != NULL) {
|
||||
if(writeTraps->isSet(addr)) {
|
||||
myDebugger->start();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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: System.hxx,v 1.5 2005-06-16 00:55:58 stephena Exp $
|
||||
// $Id: System.hxx,v 1.6 2005-06-21 04:30:49 urchlay Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SYSTEM_HXX
|
||||
|
@ -28,6 +28,10 @@ class Deserializer;
|
|||
#include "bspf.hxx"
|
||||
#include "Device.hxx"
|
||||
#include "NullDev.hxx"
|
||||
#include "PackedBitArray.hxx"
|
||||
//#include "Debugger.hxx"
|
||||
|
||||
class Debugger;
|
||||
|
||||
/**
|
||||
This class represents a system consisting of a 6502 microprocessor
|
||||
|
@ -46,7 +50,7 @@ class Deserializer;
|
|||
dynamic code for that page of memory.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: System.hxx,v 1.5 2005-06-16 00:55:58 stephena Exp $
|
||||
@version $Id: System.hxx,v 1.6 2005-06-21 04:30:49 urchlay Exp $
|
||||
*/
|
||||
class System
|
||||
{
|
||||
|
@ -129,6 +133,9 @@ class System
|
|||
*/
|
||||
int loadState(const string& fileName, const string& md5sum);
|
||||
|
||||
// set trap bit arrays. Pass NULL, NULL to disable traps.
|
||||
void System::setTraps(PackedBitArray *read, PackedBitArray *write, Debugger *debugger);
|
||||
|
||||
public:
|
||||
/**
|
||||
Answer the 6502 microprocessor attached to the system. If a
|
||||
|
@ -326,6 +333,13 @@ class System
|
|||
// The deserializer for the system. Used to load state.
|
||||
Deserializer* deserializer;
|
||||
|
||||
// Trap arrays
|
||||
PackedBitArray *readTraps;
|
||||
PackedBitArray *writeTraps;
|
||||
|
||||
// Debugger (set via setTraps())
|
||||
Debugger *myDebugger;
|
||||
|
||||
private:
|
||||
// Copy constructor isn't supported by this class so make it private
|
||||
System(const System&);
|
||||
|
@ -340,43 +354,4 @@ inline uInt8 System::getDataBusState() const
|
|||
return myDataBusState;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
inline uInt8 System::peek(uInt16 addr)
|
||||
{
|
||||
PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift];
|
||||
|
||||
uInt8 result;
|
||||
|
||||
// See if this page uses direct accessing or not
|
||||
if(access.directPeekBase != 0)
|
||||
{
|
||||
result = *(access.directPeekBase + (addr & myPageMask));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = access.device->peek(addr);
|
||||
}
|
||||
|
||||
myDataBusState = result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
inline void System::poke(uInt16 addr, uInt8 value)
|
||||
{
|
||||
PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift];
|
||||
|
||||
// See if this page uses direct accessing or not
|
||||
if(access.directPokeBase != 0)
|
||||
{
|
||||
*(access.directPokeBase + (addr & myPageMask)) = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
access.device->poke(addr, value);
|
||||
}
|
||||
|
||||
myDataBusState = value;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue