Work in progress: bank-lock support for (most of the) cartridge types.

This will eventually be used to keep the RomWidget and prompt from
accidentally switching banks during disassembly/dump, when they hit
a hotspot.

Currently, the RomWidget is getting constructed before the Debugger has a
chance to lock the bank, so it isn't finished yet. Also, the prompt "bank"
command is temporarily broken (can read current bank, but not set it).

Thought I'd finish this tonight, but it's getting late...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@826 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-10-12 03:32:28 +00:00
parent ceec3433f4
commit dbf97c41c6
19 changed files with 166 additions and 85 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: Debugger.cxx,v 1.97 2005-10-11 19:38:10 stephena Exp $
// $Id: Debugger.cxx,v 1.98 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include "bspf.hxx"
@ -673,9 +673,11 @@ int Debugger::step()
saveOldState();
int cyc = mySystem->cycles();
mySystem->unlockDataBus();
// mySystem->unlockDataBus();
unlockState();
myOSystem->console().mediaSource().updateScanlineByStep();
mySystem->lockDataBus();
// mySystem->lockDataBus();
unlockState();
return mySystem->cycles() - cyc;
}
@ -700,9 +702,11 @@ int Debugger::trace()
int cyc = mySystem->cycles();
int targetPC = myCpuDebug->pc() + 3; // return address
mySystem->unlockDataBus();
// mySystem->unlockDataBus();
unlockState();
myOSystem->console().mediaSource().updateScanlineByTrace(targetPC);
mySystem->lockDataBus();
// mySystem->lockDataBus();
lockState();
return mySystem->cycles() - cyc;
} else {
@ -834,18 +838,22 @@ void Debugger::disassemble(IntArray& addr, StringList& addrLabel,
void Debugger::nextScanline(int lines)
{
saveOldState();
mySystem->unlockDataBus();
// mySystem->unlockDataBus();
unlockState();
myTiaOutput->advanceScanline(lines);
mySystem->lockDataBus();
// mySystem->lockDataBus();
lockState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::nextFrame(int frames)
{
saveOldState();
mySystem->unlockDataBus();
// mySystem->unlockDataBus();
unlockState();
myTiaOutput->advance(frames);
mySystem->lockDataBus();
// mySystem->lockDataBus();
lockState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -946,14 +954,16 @@ void Debugger::saveOldState()
void Debugger::setStartState()
{
// Lock the bus each time the debugger is entered, so we don't disturb anything
mySystem->lockDataBus();
// mySystem->lockDataBus();
lockState();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setQuitState()
{
// Bus must be unlocked for normal operation when leaving debugger mode
mySystem->unlockDataBus();
// mySystem->unlockDataBus();
unlockState();
// execute one instruction on quit. If we're
// sitting at a breakpoint/trap, this will get us past it.
@ -1116,3 +1126,15 @@ bool Debugger::saveROM(string filename)
delete out;
return res;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::lockState() {
mySystem->lockDataBus();
myConsole->cartridge().lockBank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::unlockState() {
mySystem->unlockDataBus();
myConsole->cartridge().unlockBank();
}

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.79 2005-10-11 17:14:34 stephena Exp $
// $Id: Debugger.hxx,v 1.80 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#ifndef DEBUGGER_HXX
@ -79,7 +79,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony
@version $Id: Debugger.hxx,v 1.79 2005-10-11 17:14:34 stephena Exp $
@version $Id: Debugger.hxx,v 1.80 2005-10-12 03:32:28 urchlay Exp $
*/
class Debugger : public DialogContainer
{
@ -278,6 +278,9 @@ class Debugger : public DialogContainer
bool setBank(int bank);
bool patchROM(int addr, int value);
void lockState();
void unlockState();
private:
/**
Save state of each debugger subsystem

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: RomWidget.cxx,v 1.8 2005-10-06 17:28:55 stephena Exp $
// $Id: RomWidget.cxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -138,6 +138,18 @@ void RomWidget::loadConfig()
// Take mirroring of PC into account
int pc = dbg.cpuDebug().pc() | 0xe000;
AddrToLine::iterator iter = myLineList.find(pc);
// if current PC not found, do an update (we're executing what
// we thought was an operand)
// This doesn't help, and seems to actually hurt.
/*
if(iter == myLineList.end()) {
incrementalUpdate(myRomList->currentPos(), myRomList->rows());
iter = myLineList.find(pc);
}
*/
if(iter != myLineList.end())
myRomList->setHighlighted(iter->second);
}

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: Cart.hxx,v 1.8 2005-07-30 16:25:48 urchlay Exp $
// $Id: Cart.hxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#ifndef CARTRIDGE_HXX
@ -32,7 +32,7 @@ class System;
game and handles any bankswitching performed by the cartridge.
@author Bradford W. Mott
@version $Id: Cart.hxx,v 1.8 2005-07-30 16:25:48 urchlay Exp $
@version $Id: Cart.hxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
*/
class Cartridge : public Device
{
@ -66,8 +66,16 @@ class Cartridge : public Device
virtual bool patch(uInt16 address, uInt8 value); // yes, this writes to ROM
bool save(ofstream& out); // need a way to save patched ROMs
virtual uInt8* getImage(int& size); // save() uses this
void lockBank() { bankLocked = true; }
void unlockBank() { bankLocked = false; }
protected:
// If bankLocked is true, ignore attempts at bankswitching. This is used
// by the debugger, when disassembling/dumping ROM.
bool bankLocked;
private:
/**
Try to auto-detect the bankswitching type of the cartridge

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: Cart3E.cxx,v 1.7 2005-10-09 17:31:47 stephena Exp $
// $Id: Cart3E.cxx,v 1.8 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -162,6 +162,8 @@ bool Cartridge3E::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3E::bank(uInt16 bank)
{
if(bankLocked) return;
if(bank < 256)
{
// Make sure the bank they're asking for is reasonable

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: Cart3F.cxx,v 1.10 2005-07-30 16:58:22 urchlay Exp $
// $Id: Cart3F.cxx,v 1.11 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -140,6 +140,8 @@ bool Cartridge3F::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3F::bank(uInt16 bank)
{
if(bankLocked) return;
// Make sure the bank they're asking for is reasonable
if((uInt32)bank * 2048 < mySize)
{

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: CartAR.cxx,v 1.11 2005-10-09 17:31:47 stephena Exp $
// $Id: CartAR.cxx,v 1.12 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -299,6 +299,8 @@ void CartridgeAR::bankConfiguration(uInt8 configuration)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::bank(uInt16 b) {
if(bankLocked) return;
bankConfiguration(b);
}

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: CartDPC.cxx,v 1.13 2005-10-09 17:31:47 stephena Exp $
// $Id: CartDPC.cxx,v 1.14 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -438,6 +438,8 @@ bool CartridgeDPC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDPC::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartE0.cxx,v 1.8 2005-07-30 16:58:22 urchlay Exp $
// $Id: CartE0.cxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -95,18 +95,20 @@ uInt8 CartridgeE0::peek(uInt16 address)
{
address = address & 0x0FFF;
// Switch banks if necessary
if((address >= 0x0FE0) && (address <= 0x0FE7))
{
segmentZero(address & 0x0007);
}
else if((address >= 0x0FE8) && (address <= 0x0FEF))
{
segmentOne(address & 0x0007);
}
else if((address >= 0x0FF0) && (address <= 0x0FF7))
{
segmentTwo(address & 0x0007);
if(!bankLocked) {
// Switch banks if necessary
if((address >= 0x0FE0) && (address <= 0x0FE7))
{
segmentZero(address & 0x0007);
}
else if((address >= 0x0FE8) && (address <= 0x0FEF))
{
segmentOne(address & 0x0007);
}
else if((address >= 0x0FF0) && (address <= 0x0FF7))
{
segmentTwo(address & 0x0007);
}
}
return myImage[(myCurrentSlice[address >> 10] << 10) + (address & 0x03FF)];
@ -117,18 +119,20 @@ void CartridgeE0::poke(uInt16 address, uInt8)
{
address = address & 0x0FFF;
// Switch banks if necessary
if((address >= 0x0FE0) && (address <= 0x0FE7))
{
segmentZero(address & 0x0007);
}
else if((address >= 0x0FE8) && (address <= 0x0FEF))
{
segmentOne(address & 0x0007);
}
else if((address >= 0x0FF0) && (address <= 0x0FF7))
{
segmentTwo(address & 0x0007);
if(!bankLocked) {
// Switch banks if necessary
if((address >= 0x0FE0) && (address <= 0x0FE7))
{
segmentZero(address & 0x0007);
}
else if((address >= 0x0FE8) && (address <= 0x0FEF))
{
segmentOne(address & 0x0007);
}
else if((address >= 0x0FF0) && (address <= 0x0FF7))
{
segmentTwo(address & 0x0007);
}
}
}

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: CartE7.cxx,v 1.11 2005-10-09 17:31:47 stephena Exp $
// $Id: CartE7.cxx,v 1.12 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -149,6 +149,8 @@ bool CartridgeE7::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeE7::bank(uInt16 slice)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentSlice[0] = slice;
uInt16 offset = slice << 11;

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: CartF4.cxx,v 1.5 2005-07-30 16:58:22 urchlay Exp $
// $Id: CartF4.cxx,v 1.6 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -113,6 +113,8 @@ bool CartridgeF4::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartF4SC.cxx,v 1.8 2005-10-09 17:31:47 stephena Exp $
// $Id: CartF4SC.cxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -143,6 +143,8 @@ bool CartridgeF4SC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4SC::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartF6.cxx,v 1.8 2005-07-30 16:58:22 urchlay Exp $
// $Id: CartF6.cxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -154,6 +154,8 @@ bool CartridgeF6::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartF6SC.cxx,v 1.8 2005-10-09 17:31:47 stephena Exp $
// $Id: CartF6SC.cxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -187,6 +187,8 @@ bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6SC::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartF8.cxx,v 1.8 2005-07-30 16:58:22 urchlay Exp $
// $Id: CartF8.cxx,v 1.9 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -135,6 +135,10 @@ bool CartridgeF8::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8::bank(uInt16 bank)
{
if(bankLocked) return;
cerr << "CartF8: switching bank..." << endl;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartF8SC.cxx,v 1.7 2005-10-09 17:31:47 stephena Exp $
// $Id: CartF8SC.cxx,v 1.8 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -106,21 +106,23 @@ uInt8 CartridgeF8SC::peek(uInt16 address)
{
address = address & 0x0FFF;
// Switch banks if necessary
switch(address)
{
case 0x0FF8:
// Set the current bank to the lower 4k bank
bank(0);
break;
case 0x0FF9:
// Set the current bank to the upper 4k bank
bank(1);
break;
default:
break;
if(!bankLocked) {
// Switch banks if necessary
switch(address)
{
case 0x0FF8:
// Set the current bank to the lower 4k bank
bank(0);
break;
case 0x0FF9:
// Set the current bank to the upper 4k bank
bank(1);
break;
default:
break;
}
}
// NOTE: This does not handle accessing RAM, however, this function
@ -134,21 +136,23 @@ void CartridgeF8SC::poke(uInt16 address, uInt8)
{
address = address & 0x0FFF;
// Switch banks if necessary
switch(address)
{
case 0x0FF8:
// Set the current bank to the lower 4k bank
bank(0);
break;
case 0x0FF9:
// Set the current bank to the upper 4k bank
bank(1);
break;
default:
break;
if(!bankLocked) {
// Switch banks if necessary
switch(address)
{
case 0x0FF8:
// Set the current bank to the lower 4k bank
bank(0);
break;
case 0x0FF9:
// Set the current bank to the upper 4k bank
bank(1);
break;
default:
break;
}
}
// NOTE: This does not handle accessing RAM, however, this function

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: CartFASC.cxx,v 1.7 2005-10-09 17:31:47 stephena Exp $
// $Id: CartFASC.cxx,v 1.8 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -177,6 +177,8 @@ bool CartridgeFASC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFASC::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;

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: CartMB.cxx,v 1.6 2005-07-30 16:58:22 urchlay Exp $
// $Id: CartMB.cxx,v 1.7 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <assert.h>
@ -108,6 +108,8 @@ bool CartridgeMB::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMB::incbank()
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank ++;
myCurrentBank &= 0x0F;

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: CartUA.cxx,v 1.5 2005-07-30 16:58:22 urchlay Exp $
// $Id: CartUA.cxx,v 1.6 2005-10-12 03:32:28 urchlay Exp $
//============================================================================
#include <cassert>
@ -149,6 +149,8 @@ bool CartridgeUA::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeUA::bank(uInt16 bank)
{
if(bankLocked) return;
// Remember what bank we're in
myCurrentBank = bank;
uInt16 offset = myCurrentBank * 4096;