The DASH debugger tab now correctly shows the state of all banks/segments

currently in use.  Still TODO is activate the 'Commit' buttons, so that
the banks can be changed from the UI.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2966 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-07-29 22:37:17 +00:00
parent 301926ebfc
commit cced0aef33
3 changed files with 120 additions and 65 deletions

View File

@ -32,7 +32,7 @@ CartridgeDASHWidget::CartridgeDASHWidget(
ostringstream info; ostringstream info;
info << "DASH cartridge - (64K ROM + RAM)\n" info << "DASH cartridge - (64K ROM + RAM)\n"
<< " 4-64K ROM (1K banks), 32 1K RAM (512b banks)\n" << " 4-64K ROM (1K banks), 32K RAM (512b banks)\n"
<< "Each 1K ROM selected by writing to $3F\n" << "Each 1K ROM selected by writing to $3F\n"
"Each 512b RAM selected by writing to $3E\n" "Each 512b RAM selected by writing to $3E\n"
" First 512B of bank x (R)\n" " First 512B of bank x (R)\n"
@ -45,11 +45,12 @@ CartridgeDASHWidget::CartridgeDASHWidget(
info << "Bank RORG" << " = $" << Common::Base::HEX4 << start << "\n"; info << "Bank RORG" << " = $" << Common::Base::HEX4 << start << "\n";
int xpos = 10, int xpos = 10,
ypos = addBaseInformation(size, "A. Davie", info.str()) + myLineHeight; ypos = addBaseInformation(size, "A. Davie & T. Jentzsch", info.str()) +
myLineHeight;
VariantList bankno; VariantList bankno;
for(uInt32 i = 0; i < myCart.ROM_BANK_COUNT; ++i) for(uInt32 i = 0; i < myCart.ROM_BANK_COUNT; ++i)
bankno.push_back(i); bankno.push_back(i, i);
VariantList banktype; VariantList banktype;
banktype.push_back("ROM", "ROM"); banktype.push_back("ROM", "ROM");
@ -60,10 +61,7 @@ CartridgeDASHWidget::CartridgeDASHWidget(
int xpos_s = xpos, ypos_s = ypos; int xpos_s = xpos, ypos_s = ypos;
ostringstream label; ostringstream label;
uInt32 addr1 = start + (i*0x400), label << "Set segment " << i << " as: ";
addr2 = addr1 + 0x3FF;
label << "Set bank " << i << " ($" << Common::Base::HEX4 << addr1 << " - $"
<< addr2 << ") as: ";
ypos_s = ypos; ypos_s = ypos;
@ -96,12 +94,27 @@ CartridgeDASHWidget::CartridgeDASHWidget(
xpos_s = xpos + myBankCommit[i]->getWidth() + 20; xpos_s = xpos + myBankCommit[i]->getWidth() + 20;
myBankState[2*i] = new EditTextWidget(boss, _font, xpos_s, ypos_s, StaticTextWidget* t;
w - xpos_s - 10, myLineHeight, ""); int addr1 = start + (i*0x400), addr2 = addr1 + 0x1FF;
label.str("");
label << Common::Base::HEX4 << addr1 << "-" << Common::Base::HEX4 << addr2;
t = new StaticTextWidget(boss, _font, xpos_s, ypos_s+2,
_font.getStringWidth(label.str()), myFontHeight, label.str(), kTextAlignLeft);
int xoffset = xpos_s+t->getWidth() + 10;
myBankState[2*i] = new EditTextWidget(boss, _font, xoffset, ypos_s,
w - xoffset - 10, myLineHeight, "");
myBankState[2*i]->setEditable(false); myBankState[2*i]->setEditable(false);
ypos_s += myLineHeight + 4; ypos_s += myLineHeight + 4;
myBankState[2*i+1] = new EditTextWidget(boss, _font, xpos_s, ypos_s,
w - xpos_s - 10, myLineHeight, ""); label.str("");
label << Common::Base::HEX4 << (addr2 + 1) << "-" << Common::Base::HEX4 << (addr2 + 1 + 0x1FF);
t = new StaticTextWidget(boss, _font, xpos_s, ypos_s+2,
_font.getStringWidth(label.str()), myFontHeight, label.str(), kTextAlignLeft);
myBankState[2*i+1] = new EditTextWidget(boss, _font, xoffset, ypos_s,
w - xoffset - 10, myLineHeight, "");
myBankState[2*i+1]->setEditable(false); myBankState[2*i+1]->setEditable(false);
xpos = 10; xpos = 10;
@ -115,9 +128,7 @@ void CartridgeDASHWidget::saveOldState()
myOldState.internalram.clear(); myOldState.internalram.clear();
for(uInt32 i = 0; i < this->internalRamSize();i++) for(uInt32 i = 0; i < this->internalRamSize();i++)
{
myOldState.internalram.push_back(myCart.myRAM[i]); myOldState.internalram.push_back(myCart.myRAM[i]);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -131,21 +142,21 @@ void CartridgeDASHWidget::loadConfig()
void CartridgeDASHWidget::handleCommand(CommandSender* sender, void CartridgeDASHWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id) int cmd, int data, int id)
{ {
uInt8 bank = 0x00; // uInt8 bank = 0x00;
switch(cmd) switch(cmd)
{ {
case kBank0Changed: case kBank0Changed:
cerr << " 0\n"; cerr << " 0" << endl;
break; break;
case kBank1Changed: case kBank1Changed:
cerr << " 1\n"; cerr << " 1" << endl;
break; break;
case kBank2Changed: case kBank2Changed:
cerr << " 2\n"; cerr << " 2" << endl;
break; break;
case kBank3Changed: case kBank3Changed:
cerr << " 3\n"; cerr << " 3" << endl;
break; break;
} }
@ -190,13 +201,24 @@ string CartridgeDASHWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
#if 0 for(int i = 0; i < 4; ++i)
uInt16& bank = myCart.myCurrentBank; {
if(bank < 256) uInt16 segment = myCart.segmentInUse[i];
buf << "ROM bank " << dec << bank % myNumRomBanks << ", RAM inactive";
else if(segment == myCart.BANK_UNDEFINED)
buf << "ROM inactive, RAM bank " << bank % myNumRomBanks; {
#endif buf << "undefined";
}
else
{
int number = segment & myCart.BIT_BANK_MASK;
const char* type = segment & myCart.BITMASK_ROMRAM ? "RAM" : "ROM";
buf << type << " " << number;
}
if(i < 3)
buf << " / ";
}
return buf.str(); return buf.str();
} }
@ -204,53 +226,72 @@ string CartridgeDASHWidget::bankState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDASHWidget::updateUIState() void CartridgeDASHWidget::updateUIState()
{ {
for(int i = 0; i < 8; i+=2) // Set contents for actual banks number and type
for(int i = 0; i < 4; ++i)
{ {
// We need to determine whether each 1K area is all ROM, uInt16 segment = myCart.segmentInUse[i];
// or a mixture of ROM and RAM
uInt16 bank0 = myCart.bankInUse[i], bank1 = myCart.bankInUse[i+1];
uInt8 vBank0 = (bank0 >> myCart.BANK_BITS) & 3; if(segment == myCart.BANK_UNDEFINED)
uInt8 pBank0 = bank0 & myCart.BIT_BANK_MASK;
uInt8 vBank1 = (bank1 >> myCart.BANK_BITS) & 3;
uInt8 pBank1 = bank1 & myCart.BIT_BANK_MASK;
cerr << "Bank " << i << ": " << Common::Base::HEX4 << (int)bank0 << " : "
<< "v = " << Common::Base::HEX2 << (int)vBank0 << ", "
<< "p = " << Common::Base::HEX2 << (int)pBank0 << endl
<< "Bank " << (i+1) << ": " << Common::Base::HEX4 << (int)bank1 << " : "
<< "v = " << Common::Base::HEX2 << (int)vBank1 << ", "
<< "p = " << Common::Base::HEX2 << (int)pBank1 << endl;
if(bank0 == myCart.BANK_UNDEFINED) // never accessed
{ {
// If lower bank is undefined, upper bank will be too myBankNumber[i]->clearSelection();
myBankNumber[i/2]->clearSelection(); myBankType[i]->clearSelection();
myBankType[i/2]->clearSelection();
myBankState[i]->setText("Undefined");
myBankState[i+1]->setText("Undefined");
}
else if(bank0 & myCart.BITMASK_ROMRAM) // was RAM mapped here?
{
if(bank0 & myCart.BITMASK_LOWERUPPER)
{
myBankState[i]->setText("RAM write");
}
else
{
myBankNumber[i/2]->setSelected(pBank0);
myBankType[i/2]->setSelected("RAM");
myBankState[i]->setText("RAM read");
}
} }
else else
{ {
myBankType[i/2]->setSelected("ROM"); int bankno = segment & myCart.BIT_BANK_MASK;
myBankState[i]->setText("ROM x lower 1K"); const char* banktype = segment & myCart.BITMASK_ROMRAM ? "RAM" : "ROM";
myBankState[i+1]->setText("ROM x upper 1K");
myBankNumber[i]->setSelected(bankno);
myBankType[i]->setSelected(banktype);
}
}
// Set description for each 512b bank state
for(int i = 0; i < 8; ++i)
{
uInt16 bank = myCart.bankInUse[i];
if(bank == myCart.BANK_UNDEFINED) // never accessed
{
myBankState[i]->setText("Undefined");
}
else
{
ostringstream buf;
int bankno = bank & myCart.BIT_BANK_MASK;
if(bank & myCart.BITMASK_ROMRAM) // was RAM mapped here?
{
if(bank & myCart.BITMASK_LOWERUPPER) // upper is write port
{
buf << "RAM " << bankno << " @ $" << Common::Base::HEX4
<< (bankno << myCart.RAM_BANK_TO_POWER) << " (W)";
myBankState[i]->setText(buf.str());
}
else
{
buf << "RAM " << bankno << " @ $" << Common::Base::HEX4
<< (bankno << myCart.RAM_BANK_TO_POWER) << " (R)";
myBankState[i]->setText(buf.str());
}
}
else
{
if(bank & myCart.BITMASK_LOWERUPPER) // upper is high 512b
{
buf << "ROM " << bankno << " @ $" << Common::Base::HEX4
<< ((bankno << myCart.RAM_BANK_TO_POWER) + myCart.RAM_BANK_SIZE);
myBankState[i]->setText(buf.str());
}
else
{
buf << "ROM " << bankno << " @ $" << Common::Base::HEX4
<< (bankno << myCart.RAM_BANK_TO_POWER);
myBankState[i]->setText(buf.str());
}
}
} }
} }
cerr << "--------------------------------------------------\n";
#if 0 #if 0
if(myCart.myCurrentBank < 256) if(myCart.myCurrentBank < 256)

View File

@ -58,7 +58,10 @@ void CartridgeDASH::reset() {
// Initialise bank values for all ROM/RAM access // Initialise bank values for all ROM/RAM access
// This is used to reverse-lookup from address to bank location // This is used to reverse-lookup from address to bank location
for (uInt32 b = 0; b < 8; b++) for (uInt32 b = 0; b < 8; b++)
{
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible! bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
segmentInUse[b/2] = BANK_UNDEFINED;
}
initializeBankState(); initializeBankState();
// We'll map the startup banks 0 and 3 from the image into the third 1K bank upon reset // We'll map the startup banks 0 and 3 from the image into the third 1K bank upon reset
@ -89,7 +92,10 @@ void CartridgeDASH::install(System& system) {
// Initialise bank values for all ROM/RAM access // Initialise bank values for all ROM/RAM access
// This is used to reverse-lookup from address to bank location // This is used to reverse-lookup from address to bank location
for (uInt32 b = 0; b < 8; b++) for (uInt32 b = 0; b < 8; b++)
{
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible! bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
segmentInUse[b/2] = BANK_UNDEFINED;
}
initializeBankState(); initializeBankState();
// Setup the last segment (of 4, each 1K) to point to the first ROM slice // Setup the last segment (of 4, each 1K) to point to the first ROM slice
@ -167,7 +173,9 @@ bool CartridgeDASH::bankRAM(uInt8 bank) {
bankRAMSlot(bank | BITMASK_ROMRAM | 0); bankRAMSlot(bank | BITMASK_ROMRAM | 0);
bankRAMSlot(bank | BITMASK_ROMRAM | BITMASK_LOWERUPPER); bankRAMSlot(bank | BITMASK_ROMRAM | BITMASK_LOWERUPPER);
// Remember that this hotspot was accessed for RAM
uInt8 bankNumber = (bank >> BANK_BITS) & 3;
segmentInUse[bankNumber] = bank | BITMASK_ROMRAM;
cerr << "\nBANK CONTENTS: -------------------------------------\n"; cerr << "\nBANK CONTENTS: -------------------------------------\n";
for (uInt32 b = 0; b < 8; b++) for (uInt32 b = 0; b < 8; b++)
@ -245,6 +253,9 @@ bool CartridgeDASH::bankROM(uInt8 bank) {
bankROMSlot(bank | 0); bankROMSlot(bank | 0);
bankROMSlot(bank | BITMASK_LOWERUPPER); bankROMSlot(bank | BITMASK_LOWERUPPER);
// Remember that this hotspot was accessed for ROM
uInt8 bankNumber = (bank >> BANK_BITS) & 3;
segmentInUse[bankNumber] = bank;
cerr << "\nBANK CONTENTS: -------------------------------------\n"; cerr << "\nBANK CONTENTS: -------------------------------------\n";
@ -368,6 +379,7 @@ bool CartridgeDASH::save(Serializer& out) const {
try { try {
out.putString(name()); out.putString(name());
out.putShortArray(bankInUse, 8); out.putShortArray(bankInUse, 8);
out.putShortArray(segmentInUse, 4);
out.putByteArray(myRAM, RAM_TOTAL_SIZE); out.putByteArray(myRAM, RAM_TOTAL_SIZE);
} catch (...) { } catch (...) {
cerr << "ERROR: CartridgeDASH::save" << endl; cerr << "ERROR: CartridgeDASH::save" << endl;
@ -383,6 +395,7 @@ bool CartridgeDASH::load(Serializer& in) {
if (in.getString() != name()) if (in.getString() != name())
return false; return false;
in.getShortArray(bankInUse, 8); in.getShortArray(bankInUse, 8);
in.getShortArray(segmentInUse, 4);
in.getByteArray(myRAM, RAM_TOTAL_SIZE); in.getByteArray(myRAM, RAM_TOTAL_SIZE);
} catch (...) { } catch (...) {
cerr << "ERROR: CartridgeDASH::load" << endl; cerr << "ERROR: CartridgeDASH::load" << endl;

View File

@ -245,6 +245,7 @@ private:
static const uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible static const uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible
uInt16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas) uInt16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas)
uInt16 segmentInUse[4]; // set by bank methods, to know which hotspot was accessed
static const uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching static const uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
static const uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching static const uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching