Updated FE debugger support to allow changing banks dynamically.

This commit is contained in:
Stephen Anthony 2017-08-30 17:22:56 -02:30
parent 1358be402f
commit 2930e74333
4 changed files with 64 additions and 14 deletions

View File

@ -16,6 +16,7 @@
//============================================================================
#include "CartFE.hxx"
#include "PopUpWidget.hxx"
#include "CartFEWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -27,15 +28,45 @@ CartridgeFEWidget::CartridgeFEWidget(
{
string info =
"FE cartridge, two 4K banks\n"
"Doesn't support bankswitching with hotspots, "
"but instead watches A13 of called addresses:\n"
"Bank 0 @ $F000 - $FFFF (A13 = 1)\n"
"Bank 1 @ $D000 - $DFFF (A13 = 0)\n"
"\n"
"Changing banks is not currently supported, since it "
"would immediately switch on the next address change\n";
"Monitors access to hotspot $01FE, and uses "
"upper 3 bits of databus for bank number:\n"
"Bank 0 @ $F000 - $FFFF (DATA = 111, D5 = 1)\n"
"Bank 1 @ $D000 - $DFFF (DATA = 110, D5 = 0)\n";
addBaseInformation(2 * 4096, "Activision", info);
int xpos = 10,
ypos = addBaseInformation(2 * 4096, "Activision", info) + myLineHeight;
VariantList items;
VarList::push_back(items, "0 ($01FE, D5=1)");
VarList::push_back(items, "1 ($01FE, D5=0)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2,
_font.getStringWidth("0 ($01FE, D5=1)"),
myLineHeight, items, "Set bank ",
_font.getStringWidth("Set bank "), kBankChanged);
myBank->setTarget(this);
addFocusWidget(myBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFEWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.getBank());
CartDebugWidget::loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFEWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
if(cmd == kBankChanged)
{
myCart.unlockBank();
myCart.bank(myBank->getSelected());
myCart.lockBank();
invalidate();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -19,6 +19,8 @@
#define CARTRIDGEFE_WIDGET_HXX
class CartridgeFE;
class PopUpWidget;
#include "CartDebugWidget.hxx"
class CartridgeFEWidget : public CartDebugWidget
@ -32,11 +34,14 @@ class CartridgeFEWidget : public CartDebugWidget
private:
CartridgeFE& myCart;
PopUpWidget* myBank;
enum { kBankChanged = 'bkCH' };
private:
// No implementation for non-bankswitched ROMs
void loadConfig() override { }
void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }
void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
string bankState() override;

View File

@ -90,16 +90,23 @@ void CartridgeFE::checkBankSwitch(uInt16 address, uInt8 value)
// If so, we bankswitch according to the upper 3 bits of the data bus
// NOTE: see the header file for the significance of 'value & 0x20'
if(myLastAccessWasFE)
{
myBankOffset = ((value & 0x20) ? 0 : 1) << 12;
myBankChanged = true;
}
bank((value & 0x20) ? 0 : 1);
// On the next cycle, we use the (then) current data bus value to decode
// the bank to use
myLastAccessWasFE = address == 0x01FE;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeFE::bank(uInt16 bank)
{
if(bankLocked())
return false;
myBankOffset = bank << 12;
return myBankChanged = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFE::getBank() const
{

View File

@ -104,6 +104,13 @@ class CartridgeFE : public Cartridge
*/
void install(System& system) override;
/**
Install pages for the specified bank in the system.
@param bank The bank that should be installed in the system
*/
bool bank(uInt16 bank) override;
/**
Get the current bank.
*/