mirror of https://github.com/stella-emu/stella.git
Some rearrangement of code in Console class, so that Controller::enable
is no longer required. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2353 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
996cccde17
commit
76dc1ce716
|
@ -156,8 +156,31 @@ Debugger::~Debugger()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::initialize()
|
||||
void Debugger::initialize(Console* console)
|
||||
{
|
||||
assert(console);
|
||||
|
||||
// Keep pointers to these items for efficiency
|
||||
myConsole = console;
|
||||
mySystem = &(myConsole->system());
|
||||
|
||||
// Create debugger subsystems
|
||||
delete myCpuDebug;
|
||||
myCpuDebug = new CpuDebug(*this, *myConsole);
|
||||
|
||||
delete myCartDebug;
|
||||
myCartDebug = new CartDebug(*this, *myConsole, *myOSystem);
|
||||
|
||||
delete myRiotDebug;
|
||||
myRiotDebug = new RiotDebug(*this, *myConsole);
|
||||
|
||||
delete myTiaDebug;
|
||||
myTiaDebug = new TIADebug(*this, *myConsole);
|
||||
|
||||
// Initialize breakpoints to known state
|
||||
clearAllBreakPoints();
|
||||
clearAllTraps();
|
||||
|
||||
// Get the dialog size
|
||||
int w, h;
|
||||
myOSystem->settings().getSize("debuggerres", w, h);
|
||||
|
@ -186,33 +209,6 @@ FBInitStatus Debugger::initializeVideo()
|
|||
return myOSystem->frameBuffer().initialize(title, r.width(), r.height());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::setConsole(Console* console)
|
||||
{
|
||||
assert(console);
|
||||
|
||||
// Keep pointers to these items for efficiency
|
||||
myConsole = console;
|
||||
mySystem = &(myConsole->system());
|
||||
|
||||
// Create debugger subsystems
|
||||
delete myCpuDebug;
|
||||
myCpuDebug = new CpuDebug(*this, *myConsole);
|
||||
|
||||
delete myCartDebug;
|
||||
myCartDebug = new CartDebug(*this, *myConsole, *myOSystem);
|
||||
|
||||
delete myRiotDebug;
|
||||
myRiotDebug = new RiotDebug(*this, *myConsole);
|
||||
|
||||
delete myTiaDebug;
|
||||
myTiaDebug = new TIADebug(*this, *myConsole);
|
||||
|
||||
// Initialize breakpoints to known state
|
||||
clearAllBreakPoints();
|
||||
clearAllTraps();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::start(const string& message, int address)
|
||||
{
|
||||
|
@ -585,12 +581,6 @@ string Debugger::showWatches()
|
|||
return myParser->showWatches();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::reloadROM()
|
||||
{
|
||||
myOSystem->createConsole();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::setBank(int bank)
|
||||
{
|
||||
|
|
|
@ -93,19 +93,16 @@ class Debugger : public DialogContainer
|
|||
public:
|
||||
/**
|
||||
Updates the basedialog to be of the type defined for this derived class.
|
||||
|
||||
@param console The console to use for this debugging session.
|
||||
*/
|
||||
void initialize();
|
||||
void initialize(Console* console);
|
||||
|
||||
/**
|
||||
Initialize the video subsystem wrt this class.
|
||||
*/
|
||||
FBInitStatus initializeVideo();
|
||||
|
||||
/**
|
||||
Inform this object of a console change.
|
||||
*/
|
||||
void setConsole(Console* console);
|
||||
|
||||
/**
|
||||
Wrapper method for EventHandler::enterDebugMode() for those classes
|
||||
that don't have access to EventHandler.
|
||||
|
@ -293,8 +290,6 @@ class Debugger : public DialogContainer
|
|||
bool writeTrap(int t);
|
||||
void clearAllTraps();
|
||||
|
||||
void reloadROM();
|
||||
|
||||
// Set a bunch of RAM locations at once
|
||||
string setRAM(IntArray& args);
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ AtariVox::AtariVox(Jack jack, const Event& event, const System& system,
|
|||
myEEPROM(NULL),
|
||||
myShiftCount(0),
|
||||
myShiftRegister(0),
|
||||
myLastDataWriteCycle(0),
|
||||
myIsEnabled(false)
|
||||
myLastDataWriteCycle(0)
|
||||
{
|
||||
if(mySerialPort.openPort(portname))
|
||||
myAboutString = " (using serial port \'" + portname + "\')";
|
||||
|
@ -57,9 +56,6 @@ AtariVox::~AtariVox()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool AtariVox::read(DigitalPin pin)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return Controller::read(pin);
|
||||
|
||||
// We need to override the Controller::read() method, since the timing
|
||||
// of the actual read is important for the EEPROM (we can't just read
|
||||
// 60 times per second in the ::update() method)
|
||||
|
@ -83,9 +79,6 @@ bool AtariVox::read(DigitalPin pin)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariVox::write(DigitalPin pin, bool value)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return;
|
||||
|
||||
// Change the pin state based on value
|
||||
switch(pin)
|
||||
{
|
||||
|
|
|
@ -89,13 +89,6 @@ class AtariVox : public Controller
|
|||
*/
|
||||
void systemCyclesReset();
|
||||
|
||||
/**
|
||||
Notification to controllers that they should enable or disable
|
||||
reads and writes on their pins. Most controllers do not
|
||||
implement this.
|
||||
*/
|
||||
void enable(bool state) { myIsEnabled = state; }
|
||||
|
||||
string about() const;
|
||||
|
||||
private:
|
||||
|
@ -126,9 +119,6 @@ class AtariVox : public Controller
|
|||
// "close enough".
|
||||
uInt32 myLastDataWriteCycle;
|
||||
|
||||
// Whether we should process reads and writes
|
||||
bool myIsEnabled;
|
||||
|
||||
// Holds information concerning serial port usage
|
||||
string myAboutString;
|
||||
};
|
||||
|
|
|
@ -87,17 +87,15 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
// Construct the system and components
|
||||
mySystem = new System(13, 6);
|
||||
|
||||
// Add the controllers for this system
|
||||
const string& md5 = myProperties.get(Cartridge_MD5);
|
||||
setControllers(md5);
|
||||
|
||||
// Bumper Bash always requires all 4 directions
|
||||
// Other ROMs can use it if the setting is enabled
|
||||
bool joyallow4 = md5 == "aa1c41f86ec44c0a44eb64c332ce08af" ||
|
||||
md5 == "1bf503c724001b09be79c515ecfcbd03" ||
|
||||
myOSystem->settings().getBool("joyallow4");
|
||||
myOSystem->eventHandler().allowAllDirections(joyallow4);
|
||||
|
||||
// The real controllers for this console will be added later
|
||||
// For now, we just add dummy joystick controllers, since autodetection
|
||||
// runs the emulation for a while, and this may interfere with 'smart'
|
||||
// controllers such as the AVox and SaveKey
|
||||
// Note that the controllers must be added directly after the system
|
||||
// has been created, and before any other device is added
|
||||
// (particularly the M6532)
|
||||
myControllers[0] = new Joystick(Controller::Left, myEvent, *mySystem);
|
||||
myControllers[1] = new Joystick(Controller::Right, myEvent, *mySystem);
|
||||
|
||||
M6502* m6502 = new M6502(1);
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
|
@ -112,12 +110,6 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
mySystem->attach(myTIA);
|
||||
mySystem->attach(myCart);
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
// The debugger must be added before we run the console for the first time
|
||||
myOSystem->debugger().setConsole(this);
|
||||
myOSystem->debugger().initialize();
|
||||
#endif
|
||||
|
||||
// Auto-detect NTSC/PAL mode if it's requested
|
||||
string autodetected = "";
|
||||
myDisplayFormat = myProperties.get(Display_Format);
|
||||
|
@ -194,10 +186,24 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
myTIA->setHeight(height);
|
||||
}
|
||||
|
||||
// Add the real controllers for this system
|
||||
// This must be done before the debugger is initialized
|
||||
const string& md5 = myProperties.get(Cartridge_MD5);
|
||||
setControllers(md5);
|
||||
|
||||
// Bumper Bash always requires all 4 directions
|
||||
// Other ROMs can use it if the setting is enabled
|
||||
bool joyallow4 = md5 == "aa1c41f86ec44c0a44eb64c332ce08af" ||
|
||||
md5 == "1bf503c724001b09be79c515ecfcbd03" ||
|
||||
myOSystem->settings().getBool("joyallow4");
|
||||
myOSystem->eventHandler().allowAllDirections(joyallow4);
|
||||
|
||||
// Reset the system to its power-on state
|
||||
mySystem->reset();
|
||||
myControllers[0]->enable(true);
|
||||
myControllers[1]->enable(true);
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
myOSystem->debugger().initialize(this);
|
||||
#endif
|
||||
|
||||
// Finally, add remaining info about the console
|
||||
myConsoleInfo.CartName = myProperties.get(Cartridge_Name);
|
||||
|
@ -586,7 +592,8 @@ void Console::changeHeight(int direction)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::setControllers(const string& rommd5)
|
||||
{
|
||||
myControllers[0] = myControllers[1] = 0;
|
||||
delete myControllers[0];
|
||||
delete myControllers[1];
|
||||
|
||||
// Setup the controllers based on properties
|
||||
const string& left = myProperties.get(Controller_Left);
|
||||
|
@ -738,9 +745,6 @@ void Console::setControllers(const string& rommd5)
|
|||
{
|
||||
myControllers[rightPort] = new Joystick(Controller::Right, myEvent, *mySystem);
|
||||
}
|
||||
|
||||
myControllers[leftPort]->enable(false);
|
||||
myControllers[rightPort]->enable(false);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -188,13 +188,6 @@ class Controller : public Serializable
|
|||
*/
|
||||
virtual void systemCyclesReset() { };
|
||||
|
||||
/**
|
||||
Notification to controllers that they should enable or disable
|
||||
reads and writes on their pins. Most controllers do not
|
||||
implement this.
|
||||
*/
|
||||
virtual void enable(bool state) { };
|
||||
|
||||
/**
|
||||
Determines how this controller will treat values received from the
|
||||
X and Y axis of the mouse. Since not all controllers use the mouse,
|
||||
|
|
|
@ -462,56 +462,6 @@ bool M6502::load(Serializer& in)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ostream& operator<<(ostream& out, const M6502::AddressingMode& mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case M6502::Absolute:
|
||||
out << "$nnnn ";
|
||||
break;
|
||||
case M6502::AbsoluteX:
|
||||
out << "$nnnn,X";
|
||||
break;
|
||||
case M6502::AbsoluteY:
|
||||
out << "$nnnn,Y";
|
||||
break;
|
||||
case M6502::Implied:
|
||||
out << "implied";
|
||||
break;
|
||||
case M6502::Immediate:
|
||||
out << "#$nn ";
|
||||
break;
|
||||
case M6502::Indirect:
|
||||
out << "($nnnn)";
|
||||
break;
|
||||
case M6502::IndirectX:
|
||||
out << "($nn,X)";
|
||||
break;
|
||||
case M6502::IndirectY:
|
||||
out << "($nn),Y";
|
||||
break;
|
||||
case M6502::Invalid:
|
||||
out << "invalid";
|
||||
break;
|
||||
case M6502::Relative:
|
||||
out << "$nn ";
|
||||
break;
|
||||
case M6502::Zero:
|
||||
out << "$nn ";
|
||||
break;
|
||||
case M6502::ZeroX:
|
||||
out << "$nn,X ";
|
||||
break;
|
||||
case M6502::ZeroY:
|
||||
out << "$nn,Y ";
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void M6502::attach(Debugger& debugger)
|
||||
|
@ -577,7 +527,6 @@ void M6502::setTraps(PackedBitArray *read, PackedBitArray *write)
|
|||
myReadTraps = read;
|
||||
myWriteTraps = write;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
SaveKey::SaveKey(Jack jack, const Event& event, const System& system,
|
||||
const string& eepromfile)
|
||||
: Controller(jack, event, system, Controller::SaveKey),
|
||||
myEEPROM(NULL),
|
||||
myIsEnabled(false)
|
||||
myEEPROM(NULL)
|
||||
{
|
||||
myEEPROM = new MT24LC256(eepromfile, system);
|
||||
|
||||
|
@ -43,9 +42,6 @@ SaveKey::~SaveKey()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool SaveKey::read(DigitalPin pin)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return Controller::read(pin);
|
||||
|
||||
// We need to override the Controller::read() method, since the timing
|
||||
// of the actual read is important for the EEPROM (we can't just read
|
||||
// 60 times per second in the ::update() method)
|
||||
|
@ -64,9 +60,6 @@ bool SaveKey::read(DigitalPin pin)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SaveKey::write(DigitalPin pin, bool value)
|
||||
{
|
||||
if(!myIsEnabled)
|
||||
return;
|
||||
|
||||
// Change the pin state based on value
|
||||
switch(pin)
|
||||
{
|
||||
|
|
|
@ -85,19 +85,9 @@ class SaveKey : public Controller
|
|||
*/
|
||||
void systemCyclesReset();
|
||||
|
||||
/**
|
||||
Notification to controllers that they should enable or disable
|
||||
reads and writes on their pins. Most controllers do not
|
||||
implement this.
|
||||
*/
|
||||
void enable(bool state) { myIsEnabled = state; }
|
||||
|
||||
private:
|
||||
// The EEPROM used in the SaveKey
|
||||
MT24LC256* myEEPROM;
|
||||
|
||||
// Whether we should process reads and writes
|
||||
bool myIsEnabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue