refactored access flags used for disassembly

This commit is contained in:
thrust26 2020-03-27 09:03:06 +01:00
parent 5fd53520e7
commit fca12051ba
25 changed files with 385 additions and 392 deletions

View File

@ -32,6 +32,7 @@
#include "CartRamWidget.hxx" #include "CartRamWidget.hxx"
#include "RomWidget.hxx" #include "RomWidget.hxx"
#include "Base.hxx" #include "Base.hxx"
#include "Device.hxx"
#include "exception/EmulationWarning.hxx" #include "exception/EmulationWarning.hxx"
using Common::Base; using Common::Base;
@ -85,7 +86,7 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
// We know the address for the startup bank right now // We know the address for the startup bank right now
myBankInfo[myConsole.cartridge().startBank()].addressList.push_front( myBankInfo[myConsole.cartridge().startBank()].addressList.push_front(
myDebugger.dpeek(0xfffc)); myDebugger.dpeek(0xfffc));
addLabel("Start", myDebugger.dpeek(0xfffc, DATA)); addLabel("Start", myDebugger.dpeek(0xfffc, Device::DATA));
// Add system equates // Add system equates
for(uInt16 addr = 0x00; addr <= 0x0F; ++addr) for(uInt16 addr = 0x00; addr <= 0x0F; ++addr)
@ -316,8 +317,8 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, uInt16 search)
const DisassemblyTag& tag = myDisassembly.list[i]; const DisassemblyTag& tag = myDisassembly.list[i];
const uInt16 address = tag.address & 0xFFF; const uInt16 address = tag.address & 0xFFF;
// Exclude 'ROW'; they don't have a valid address // Exclude 'Device::ROW'; they don't have a valid address
if(tag.type != CartDebug::ROW) if(tag.type != Device::ROW)
{ {
// Create a mapping from addresses to line numbers // Create a mapping from addresses to line numbers
myAddrToLineList.emplace(address, i); myAddrToLineList.emplace(address, i);
@ -358,7 +359,7 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
if((tag.address & 0xfff) >= start) if((tag.address & 0xfff) >= start)
{ {
if(begin == list_size) begin = end; if(begin == list_size) begin = end;
if(tag.type != CartDebug::ROW) if(tag.type != Device::ROW)
length = std::max(length, uInt32(tag.disasm.length())); length = std::max(length, uInt32(tag.disasm.length()));
--lines; --lines;
@ -369,7 +370,7 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
for(uInt32 i = begin; i < end; ++i) for(uInt32 i = begin; i < end; ++i)
{ {
const CartDebug::DisassemblyTag& tag = myDisassembly.list[i]; const CartDebug::DisassemblyTag& tag = myDisassembly.list[i];
if(tag.type == CartDebug::NONE) if(tag.type == Device::NONE)
continue; continue;
else if(tag.address) else if(tag.address)
buffer << std::uppercase << std::hex << std::setw(4) buffer << std::uppercase << std::hex << std::setw(4)
@ -386,7 +387,7 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDebug::addDirective(CartDebug::DisasmType type, bool CartDebug::addDirective(Device::AccessType type,
uInt16 start, uInt16 end, int bank) uInt16 start, uInt16 end, int bank)
{ {
if(end < start || start == 0 || end == 0) if(end < start || start == 0 || end == 0)
@ -885,46 +886,46 @@ string CartDebug::loadConfigFile()
// TODO - figure out what to do with this // TODO - figure out what to do with this
buf >> hex >> start; buf >> hex >> start;
} }
else if(BSPF::startsWithIgnoreCase(directive, "CODE")) else if(BSPF::startsWithIgnoreCase(directive, "Device::CODE"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::CODE, start, end, currentbank); addDirective(Device::CODE, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "GFX")) else if(BSPF::startsWithIgnoreCase(directive, "Device::GFX"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::GFX, start, end, currentbank); addDirective(Device::GFX, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "PGFX")) else if(BSPF::startsWithIgnoreCase(directive, "Device::PGFX"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::PGFX, start, end, currentbank); addDirective(Device::PGFX, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "COL")) else if(BSPF::startsWithIgnoreCase(directive, "Device::COL"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::COL, start, end, currentbank); addDirective(Device::COL, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "PCOL")) else if(BSPF::startsWithIgnoreCase(directive, "Device::PCOL"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::PCOL, start, end, currentbank); addDirective(Device::PCOL, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "BCOL")) else if(BSPF::startsWithIgnoreCase(directive, "Device::BCOL"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::BCOL, start, end, currentbank); addDirective(Device::BCOL, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "DATA")) else if(BSPF::startsWithIgnoreCase(directive, "Device::DATA"))
{ {
buf >> hex >> start >> hex >> end; buf >> hex >> start >> hex >> end;
addDirective(CartDebug::DATA, start, end, currentbank); addDirective(Device::DATA, start, end, currentbank);
} }
else if(BSPF::startsWithIgnoreCase(directive, "ROW")) else if(BSPF::startsWithIgnoreCase(directive, "Device::ROW"))
{ {
buf >> hex >> start; buf >> hex >> start;
buf >> hex >> end; buf >> hex >> end;
addDirective(CartDebug::ROW, start, end, currentbank); addDirective(Device::ROW, start, end, currentbank);
} }
} }
} }
@ -1053,7 +1054,7 @@ string CartDebug::saveDisassembly()
if (myReserved.breakFound) if (myReserved.breakFound)
addLabel("Break", myDebugger.dpeek(0xfffe)); addLabel("Break", myDebugger.dpeek(0xfffe));
buf << " SEG CODE\n" buf << " SEG Device::CODE\n"
<< " ORG $" << Base::HEX4 << info.offset << "\n\n"; << " ORG $" << Base::HEX4 << info.offset << "\n\n";
// Format in 'distella' style // Format in 'distella' style
@ -1068,19 +1069,19 @@ string CartDebug::saveDisassembly()
switch(tag.type) switch(tag.type)
{ {
case CartDebug::CODE: case Device::CODE:
{ {
buf << ALIGN(32) << tag.disasm << tag.ccount.substr(0, 5) << tag.ctotal << tag.ccount.substr(5, 2); buf << ALIGN(32) << tag.disasm << tag.ccount.substr(0, 5) << tag.ctotal << tag.ccount.substr(5, 2);
if (tag.disasm.find("WSYNC") != std::string::npos) if (tag.disasm.find("WSYNC") != std::string::npos)
buf << "\n;---------------------------------------"; buf << "\n;---------------------------------------";
break; break;
} }
case CartDebug::ROW: case Device::ROW:
{ {
buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 8*4-1) << "; $" << Base::HEX4 << tag.address << " (*)"; buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 8*4-1) << "; $" << Base::HEX4 << tag.address << " (*)";
break; break;
} }
case CartDebug::GFX: case Device::GFX:
{ {
buf << ".byte " << (settings.gfxFormat == Base::Fmt::_2 ? "%" : "$") buf << ".byte " << (settings.gfxFormat == Base::Fmt::_2 ? "%" : "$")
<< tag.bytes << " ; |"; << tag.bytes << " ; |";
@ -1089,7 +1090,7 @@ string CartDebug::saveDisassembly()
buf << ALIGN(13) << "|" << "$" << Base::HEX4 << tag.address << " (G)"; buf << ALIGN(13) << "|" << "$" << Base::HEX4 << tag.address << " (G)";
break; break;
} }
case CartDebug::PGFX: case Device::PGFX:
{ {
buf << ".byte " << (settings.gfxFormat == Base::Fmt::_2 ? "%" : "$") buf << ".byte " << (settings.gfxFormat == Base::Fmt::_2 ? "%" : "$")
<< tag.bytes << " ; |"; << tag.bytes << " ; |";
@ -1098,24 +1099,24 @@ string CartDebug::saveDisassembly()
buf << ALIGN(13) << "|" << "$" << Base::HEX4 << tag.address << " (P)"; buf << ALIGN(13) << "|" << "$" << Base::HEX4 << tag.address << " (P)";
break; break;
} }
case CartDebug::COL: case Device::COL:
buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (Px)"; buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (Px)";
break; break;
case CartDebug::PCOL: case Device::PCOL:
buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (PF)"; buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (PF)";
break; break;
case CartDebug::BCOL: case Device::BCOL:
buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (BK)"; buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (BK)";
break; break;
case CartDebug::DATA: case Device::DATA:
{ {
buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 8 * 4 - 1) << "; $" << Base::HEX4 << tag.address << " (D)"; buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 8 * 4 - 1) << "; $" << Base::HEX4 << tag.address << " (D)";
break; break;
} }
case CartDebug::NONE: case Device::NONE:
default: default:
{ {
break; break;
@ -1133,10 +1134,10 @@ string CartDebug::saveDisassembly()
<< "; ROM properties name : " << myConsole.properties().get(PropType::Cart_Name) << "\n" << "; ROM properties name : " << myConsole.properties().get(PropType::Cart_Name) << "\n"
<< "; ROM properties MD5 : " << myConsole.properties().get(PropType::Cart_MD5) << "\n" << "; ROM properties MD5 : " << myConsole.properties().get(PropType::Cart_MD5) << "\n"
<< "; Bankswitch type : " << myConsole.cartridge().about() << "\n;\n" << "; Bankswitch type : " << myConsole.cartridge().about() << "\n;\n"
<< "; Legend: * = CODE not yet run (tentative code)\n" << "; Legend: * = Device::CODE not yet run (tentative code)\n"
<< "; D = DATA directive (referenced in some way)\n" << "; D = Device::DATA directive (referenced in some way)\n"
<< "; G = GFX directive, shown as '#' (stored in player, missile, ball)\n" << "; G = Device::GFX directive, shown as '#' (stored in player, missile, ball)\n"
<< "; P = PGFX directive, shown as '*' (stored in playfield)\n" << "; P = Device::PGFX directive, shown as '*' (stored in playfield)\n"
<< "; i = indexed accessed only\n" << "; i = indexed accessed only\n"
<< "; c = used by code executed in RAM\n" << "; c = used by code executed in RAM\n"
<< "; s = used by stack\n" << "; s = used by stack\n"
@ -1166,9 +1167,9 @@ string CartDebug::saveDisassembly()
bool addrUsed = false; bool addrUsed = false;
for(uInt16 addr = 0x00; addr <= 0x0F; ++addr) for(uInt16 addr = 0x00; addr <= 0x0F; ++addr)
addrUsed = addrUsed || myReserved.TIARead[addr] || (mySystem.getAccessFlags(addr) & WRITE); addrUsed = addrUsed || myReserved.TIARead[addr] || (mySystem.getAccessFlags(addr) & Device::WRITE);
for(uInt16 addr = 0x00; addr <= 0x3F; ++addr) for(uInt16 addr = 0x00; addr <= 0x3F; ++addr)
addrUsed = addrUsed || myReserved.TIAWrite[addr] || (mySystem.getAccessFlags(addr) & DATA); addrUsed = addrUsed || myReserved.TIAWrite[addr] || (mySystem.getAccessFlags(addr) & Device::DATA);
for(uInt16 addr = 0x00; addr <= 0x17; ++addr) for(uInt16 addr = 0x00; addr <= 0x17; ++addr)
addrUsed = addrUsed || myReserved.IOReadWrite[addr]; addrUsed = addrUsed || myReserved.IOReadWrite[addr];
@ -1183,7 +1184,7 @@ string CartDebug::saveDisassembly()
if(myReserved.TIARead[addr] && ourTIAMnemonicR[addr]) if(myReserved.TIARead[addr] && ourTIAMnemonicR[addr])
out << ALIGN(16) << ourTIAMnemonicR[addr] << "= $" out << ALIGN(16) << ourTIAMnemonicR[addr] << "= $"
<< Base::HEX2 << right << addr << " ; (R)\n"; << Base::HEX2 << right << addr << " ; (R)\n";
else if (mySystem.getAccessFlags(addr) & DATA) else if (mySystem.getAccessFlags(addr) & Device::DATA)
out << ";" << ALIGN(16-1) << ourTIAMnemonicR[addr] << "= $" out << ";" << ALIGN(16-1) << ourTIAMnemonicR[addr] << "= $"
<< Base::HEX2 << right << addr << " ; (Ri)\n"; << Base::HEX2 << right << addr << " ; (Ri)\n";
out << "\n"; out << "\n";
@ -1193,7 +1194,7 @@ string CartDebug::saveDisassembly()
if(myReserved.TIAWrite[addr] && ourTIAMnemonicW[addr]) if(myReserved.TIAWrite[addr] && ourTIAMnemonicW[addr])
out << ALIGN(16) << ourTIAMnemonicW[addr] << "= $" out << ALIGN(16) << ourTIAMnemonicW[addr] << "= $"
<< Base::HEX2 << right << addr << " ; (W)\n"; << Base::HEX2 << right << addr << " ; (W)\n";
else if (mySystem.getAccessFlags(addr) & WRITE) else if (mySystem.getAccessFlags(addr) & Device::WRITE)
out << ";" << ALIGN(16-1) << ourTIAMnemonicW[addr] << "= $" out << ";" << ALIGN(16-1) << ourTIAMnemonicW[addr] << "= $"
<< Base::HEX2 << right << addr << " ; (Wi)\n"; << Base::HEX2 << right << addr << " ; (Wi)\n";
out << "\n"; out << "\n";
@ -1208,8 +1209,8 @@ string CartDebug::saveDisassembly()
addrUsed = false; addrUsed = false;
for(uInt16 addr = 0x80; addr <= 0xFF; ++addr) for(uInt16 addr = 0x80; addr <= 0xFF; ++addr)
addrUsed = addrUsed || myReserved.ZPRAM[addr-0x80] addrUsed = addrUsed || myReserved.ZPRAM[addr-0x80]
|| (mySystem.getAccessFlags(addr) & (DATA | WRITE)) || (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE))
|| (mySystem.getAccessFlags(addr|0x100) & (DATA | WRITE)); || (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE));
if(addrUsed) if(addrUsed)
{ {
bool addLine = false; bool addLine = false;
@ -1218,9 +1219,9 @@ string CartDebug::saveDisassembly()
<< ";-----------------------------------------------------------\n\n"; << ";-----------------------------------------------------------\n\n";
for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) { for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) {
bool ramUsed = (mySystem.getAccessFlags(addr) & (DATA | WRITE)); bool ramUsed = (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE));
bool codeUsed = (mySystem.getAccessFlags(addr) & CODE); bool codeUsed = (mySystem.getAccessFlags(addr) & Device::CODE);
bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (DATA | WRITE)); bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE));
if (myReserved.ZPRAM[addr - 0x80] && if (myReserved.ZPRAM[addr - 0x80] &&
myUserLabels.find(addr) == myUserLabels.end()) { myUserLabels.find(addr) == myUserLabels.end()) {
@ -1315,10 +1316,10 @@ string CartDebug::listConfig(int bank)
buf << "[" << b << "]" << endl; buf << "[" << b << "]" << endl;
for(const auto& i: info.directiveList) for(const auto& i: info.directiveList)
{ {
if(i.type != CartDebug::NONE) if(i.type != Device::NONE)
{ {
buf << "(*) "; buf << "(*) ";
disasmTypeAsString(buf, i.type); AccessTypeAsString(buf, i.type);
buf << " " << Base::HEX4 << i.start << " " << Base::HEX4 << i.end << endl; buf << " " << Base::HEX4 << i.start << " " << Base::HEX4 << i.end << endl;
} }
} }
@ -1414,15 +1415,15 @@ void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const
// Now consider each byte // Now consider each byte
uInt32 prev = info.offset, addr = prev + 1; uInt32 prev = info.offset, addr = prev + 1;
DisasmType prevType = disasmTypeAbsolute(mySystem.getAccessFlags(prev)); Device::AccessType prevType = accessTypeAbsolute(mySystem.getAccessFlags(prev));
for( ; addr < info.offset + info.size; ++addr) for( ; addr < info.offset + info.size; ++addr)
{ {
DisasmType currType = disasmTypeAbsolute(mySystem.getAccessFlags(addr)); Device::AccessType currType = accessTypeAbsolute(mySystem.getAccessFlags(addr));
// Have we changed to a new type? // Have we changed to a new type?
if(currType != prevType) if(currType != prevType)
{ {
disasmTypeAsString(buf, prevType); AccessTypeAsString(buf, prevType);
buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl; buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl;
prev = addr; prev = addr;
@ -1433,13 +1434,13 @@ void CartDebug::getBankDirectives(ostream& buf, BankInfo& info) const
// Grab the last directive, making sure it accounts for all remaining space // Grab the last directive, making sure it accounts for all remaining space
if(prev != addr) if(prev != addr)
{ {
disasmTypeAsString(buf, prevType); AccessTypeAsString(buf, prevType);
buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl; buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::addressTypeAsString(ostream& buf, uInt16 addr) const void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const
{ {
if(!(addr & 0x1000)) if(!(addr & 0x1000))
{ {
@ -1452,86 +1453,86 @@ void CartDebug::addressTypeAsString(ostream& buf, uInt16 addr) const
label = myDisLabels[addr & 0xFFF]; label = myDisLabels[addr & 0xFFF];
buf << endl << "directive: " << Base::toString(directive, Base::Fmt::_2_8) << " "; buf << endl << "directive: " << Base::toString(directive, Base::Fmt::_2_8) << " ";
disasmTypeAsString(buf, directive); AccessTypeAsString(buf, directive);
buf << endl << "emulation: " << Base::toString(debugger, Base::Fmt::_2_8) << " "; buf << endl << "emulation: " << Base::toString(debugger, Base::Fmt::_2_8) << " ";
disasmTypeAsString(buf, debugger); AccessTypeAsString(buf, debugger);
buf << endl << "tentative: " << Base::toString(label, Base::Fmt::_2_8) << " "; buf << endl << "tentative: " << Base::toString(label, Base::Fmt::_2_8) << " ";
disasmTypeAsString(buf, label); AccessTypeAsString(buf, label);
buf << endl; buf << endl;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmType CartDebug::disasmTypeAbsolute(CartDebug::DisasmFlags flags) const Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) const
{ {
if(flags & CartDebug::CODE) if(flags & Device::CODE)
return CartDebug::CODE; return Device::CODE;
else if(flags & CartDebug::TCODE) else if(flags & Device::TCODE)
return CartDebug::CODE; // TODO - should this be separate?? return Device::CODE; // TODO - should this be separate??
else if(flags & CartDebug::GFX) else if(flags & Device::GFX)
return CartDebug::GFX; return Device::GFX;
else if(flags & CartDebug::PGFX) else if(flags & Device::PGFX)
return CartDebug::PGFX; return Device::PGFX;
else if(flags & CartDebug::COL) else if(flags & Device::COL)
return CartDebug::COL; return Device::COL;
else if(flags & CartDebug::PCOL) else if(flags & Device::PCOL)
return CartDebug::PCOL; return Device::PCOL;
else if(flags & CartDebug::BCOL) else if(flags & Device::BCOL)
return CartDebug::BCOL; return Device::BCOL;
else if(flags & CartDebug::DATA) else if(flags & Device::DATA)
return CartDebug::DATA; return Device::DATA;
else if(flags & CartDebug::ROW) else if(flags & Device::ROW)
return CartDebug::ROW; return Device::ROW;
else else
return CartDebug::NONE; return Device::NONE;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::disasmTypeAsString(ostream& buf, DisasmType type) const void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const
{ {
switch(type) switch(type)
{ {
case CartDebug::CODE: buf << "CODE"; break; case Device::CODE: buf << "Device::CODE"; break;
case CartDebug::TCODE: buf << "TCODE"; break; case Device::TCODE: buf << "Device::TCODE"; break;
case CartDebug::GFX: buf << "GFX"; break; case Device::GFX: buf << "Device::GFX"; break;
case CartDebug::PGFX: buf << "PGFX"; break; case Device::PGFX: buf << "Device::PGFX"; break;
case CartDebug::COL: buf << "COL"; break; case Device::COL: buf << "Device::COL"; break;
case CartDebug::PCOL: buf << "PCOL"; break; case Device::PCOL: buf << "Device::PCOL"; break;
case CartDebug::BCOL: buf << "BCOL"; break; case Device::BCOL: buf << "Device::BCOL"; break;
case CartDebug::DATA: buf << "DATA"; break; case Device::DATA: buf << "Device::DATA"; break;
case CartDebug::ROW: buf << "ROW"; break; case Device::ROW: buf << "Device::ROW"; break;
case CartDebug::REFERENCED: case Device::REFERENCED:
case CartDebug::VALID_ENTRY: case Device::VALID_ENTRY:
case CartDebug::NONE: break; case Device::NONE: break;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::disasmTypeAsString(ostream& buf, CartDebug::DisasmFlags flags) const void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const
{ {
if(flags) if(flags)
{ {
if(flags & CartDebug::CODE) if(flags & Device::CODE)
buf << "CODE "; buf << "Device::CODE ";
if(flags & CartDebug::TCODE) if(flags & Device::TCODE)
buf << "TCODE "; buf << "Device::TCODE ";
if(flags & CartDebug::GFX) if(flags & Device::GFX)
buf << "GFX "; buf << "Device::GFX ";
if(flags & CartDebug::PGFX) if(flags & Device::PGFX)
buf << "PGFX "; buf << "Device::PGFX ";
if(flags & CartDebug::COL) if(flags & Device::COL)
buf << "COL "; buf << "Device::COL ";
if(flags & CartDebug::PCOL) if(flags & Device::PCOL)
buf << "PCOL "; buf << "Device::PCOL ";
if(flags & CartDebug::BCOL) if(flags & Device::BCOL)
buf << "BCOL "; buf << "Device::BCOL ";
if(flags & CartDebug::DATA) if(flags & Device::DATA)
buf << "DATA "; buf << "Device::DATA ";
if(flags & CartDebug::ROW) if(flags & Device::ROW)
buf << "ROW "; buf << "Device::ROW ";
if(flags & CartDebug::REFERENCED) if(flags & Device::REFERENCED)
buf << "*REFERENCED "; buf << "*Device::REFERENCED ";
if(flags & CartDebug::VALID_ENTRY) if(flags & Device::VALID_ENTRY)
buf << "*VALID_ENTRY "; buf << "*Device::VALID_ENTRY ";
} }
else else
buf << "no flags set"; buf << "no flags set";

View File

@ -31,6 +31,7 @@ using CartMethod = int (CartDebug::*)();
#include "bspf.hxx" #include "bspf.hxx"
#include "DebuggerSystem.hxx" #include "DebuggerSystem.hxx"
#include "Device.hxx"
class CartState : public DebuggerState class CartState : public DebuggerState
{ {
@ -47,35 +48,8 @@ class CartDebug : public DebuggerSystem
friend class DiStella; friend class DiStella;
public: public:
enum DisasmType {
NONE = 0,
REFERENCED = 1 << 0, /* 0x01, code somewhere in the program references it,
i.e. LDA $F372 referenced $F372 */
VALID_ENTRY = 1 << 1, /* 0x02, addresses that can have a label placed in front of it.
A good counterexample would be "FF00: LDA $FE00"; $FF01
would be in the middle of a multi-byte instruction, and
therefore cannot be labelled. */
// The following correspond to specific types that can be set within the
// debugger, or specified in a Distella cfg file, and are listed in order
// of decreasing hierarchy
//
CODE = 1 << 10, // 0x400, disassemble-able code segments
TCODE = 1 << 9, // 0x200, (tentative) disassemble-able code segments
GFX = 1 << 8, // 0x100, addresses loaded into GRPx registers
PGFX = 1 << 7, // 0x080, addresses loaded into PFx registers
COL = 1 << 6, // 0x040, addresses loaded into COLUPx registers
PCOL = 1 << 5, // 0x010, addresses loaded into COLUPF register
BCOL = 1 << 4, // 0x010, addresses loaded into COLUBK register
DATA = 1 << 3, // 0x008, addresses loaded into registers other than GRPx / PFx
ROW = 1 << 2, // 0x004, all other addresses
// special type for poke()
WRITE = TCODE // 0x200, address written to
};
using DisasmFlags = uInt16;
struct DisassemblyTag { struct DisassemblyTag {
DisasmType type{NONE}; Device::AccessType type{Device::NONE};
uInt16 address{0}; uInt16 address{0};
string label; string label;
string disasm; string disasm;
@ -175,7 +149,7 @@ class CartDebug : public DebuggerSystem
@return True if directive was added, else false if it was removed @return True if directive was added, else false if it was removed
*/ */
bool addDirective(CartDebug::DisasmType type, uInt16 start, uInt16 end, bool addDirective(Device::AccessType type, uInt16 start, uInt16 end,
int bank = -1); int bank = -1);
// The following are convenience methods that query the cartridge object // The following are convenience methods that query the cartridge object
@ -260,8 +234,8 @@ class CartDebug : public DebuggerSystem
*/ */
void getCompletions(const char* in, StringList& list) const; void getCompletions(const char* in, StringList& list) const;
// Convert given address to corresponding disassembly type and append to buf // Convert given address to corresponding access type and append to buf
void addressTypeAsString(ostream& buf, uInt16 addr) const; void accessTypeAsString(ostream& buf, uInt16 addr) const;
private: private:
using AddrToLabel = std::map<uInt16, string>; using AddrToLabel = std::map<uInt16, string>;
@ -271,7 +245,7 @@ class CartDebug : public DebuggerSystem
using AddrTypeArray = std::array<uInt16, 0x1000>; using AddrTypeArray = std::array<uInt16, 0x1000>;
struct DirectiveTag { struct DirectiveTag {
DisasmType type{NONE}; Device::AccessType type{Device::NONE};
uInt16 start{0}; uInt16 start{0};
uInt16 end{0}; uInt16 end{0};
}; };
@ -309,15 +283,15 @@ class CartDebug : public DebuggerSystem
// based on its disassembly // based on its disassembly
void getBankDirectives(ostream& buf, BankInfo& info) const; void getBankDirectives(ostream& buf, BankInfo& info) const;
// Get disassembly enum type from 'flags', taking precendence into account // Get access enum type from 'flags', taking precendence into account
DisasmType disasmTypeAbsolute(CartDebug::DisasmFlags flags) const; Device::AccessType accessTypeAbsolute(Device::AccessFlags flags) const;
// Convert disassembly enum type to corresponding string and append to buf // Convert access enum type to corresponding string and append to buf
void disasmTypeAsString(ostream& buf, DisasmType type) const; void AccessTypeAsString(ostream& buf, Device::AccessType type) const;
// Convert all disassembly types in 'flags' to corresponding string and // Convert all access types in 'flags' to corresponding string and
// append to buf // append to buf
void disasmTypeAsString(ostream& buf, CartDebug::DisasmFlags flags) const; void AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const;
private: private:
const OSystem& myOSystem; const OSystem& myOSystem;

View File

@ -20,7 +20,6 @@
#include "M6502.hxx" #include "M6502.hxx"
#include "System.hxx" #include "System.hxx"
#include "Debugger.hxx" #include "Debugger.hxx"
#include "CartDebug.hxx"
#include "TIADebug.hxx" #include "TIADebug.hxx"
#include "CpuDebug.hxx" #include "CpuDebug.hxx"

View File

@ -440,19 +440,19 @@ bool Debugger::writeTrap(uInt16 t)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Debugger::peek(uInt16 addr, CartDebug::DisasmFlags flags) uInt8 Debugger::peek(uInt16 addr, Device::AccessFlags flags)
{ {
return mySystem.peek(addr, flags); return mySystem.peek(addr, flags);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Debugger::dpeek(uInt16 addr, CartDebug::DisasmFlags flags) uInt16 Debugger::dpeek(uInt16 addr, Device::AccessFlags flags)
{ {
return uInt16(mySystem.peek(addr, flags) | (mySystem.peek(addr+1, flags) << 8)); return uInt16(mySystem.peek(addr, flags) | (mySystem.peek(addr+1, flags) << 8));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::poke(uInt16 addr, uInt8 value, CartDebug::DisasmFlags flags) void Debugger::poke(uInt16 addr, uInt8 value, Device::AccessFlags flags)
{ {
mySystem.poke(addr, value, flags); mySystem.poke(addr, value, flags);
} }
@ -464,26 +464,26 @@ M6502& Debugger::m6502() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::peekAsInt(int addr, CartDebug::DisasmFlags flags) int Debugger::peekAsInt(int addr, Device::AccessFlags flags)
{ {
return mySystem.peek(uInt16(addr), flags); return mySystem.peek(uInt16(addr), flags);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::dpeekAsInt(int addr, CartDebug::DisasmFlags flags) int Debugger::dpeekAsInt(int addr, Device::AccessFlags flags)
{ {
return mySystem.peek(uInt16(addr), flags) | return mySystem.peek(uInt16(addr), flags) |
(mySystem.peek(uInt16(addr+1), flags) << 8); (mySystem.peek(uInt16(addr+1), flags) << 8);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmFlags Debugger::getAccessFlags(uInt16 addr) const Device::AccessFlags Debugger::getAccessFlags(uInt16 addr) const
{ {
return mySystem.getAccessFlags(addr); return mySystem.getAccessFlags(addr);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setAccessFlags(uInt16 addr, CartDebug::DisasmFlags flags) void Debugger::setAccessFlags(uInt16 addr, Device::AccessFlags flags)
{ {
mySystem.setAccessFlags(addr, flags); mySystem.setAccessFlags(addr, flags);
} }

View File

@ -47,7 +47,7 @@ class RewindManager;
#include "DialogContainer.hxx" #include "DialogContainer.hxx"
#include "DebuggerDialog.hxx" #include "DebuggerDialog.hxx"
#include "FrameBufferConstants.hxx" #include "FrameBufferConstants.hxx"
#include "CartDebug.hxx" #include "Cart.hxx"
#include "bspf.hxx" #include "bspf.hxx"
/** /**
@ -244,18 +244,18 @@ class Debugger : public DialogContainer
static Debugger& debugger() { return *myStaticDebugger; } static Debugger& debugger() { return *myStaticDebugger; }
/** Convenience methods to access peek/poke from System */ /** Convenience methods to access peek/poke from System */
uInt8 peek(uInt16 addr, CartDebug::DisasmFlags flags = CartDebug::NONE); uInt8 peek(uInt16 addr, Device::AccessFlags flags = Device::NONE);
uInt16 dpeek(uInt16 addr, CartDebug::DisasmFlags flags = CartDebug::NONE); uInt16 dpeek(uInt16 addr, Device::AccessFlags flags = Device::NONE);
void poke(uInt16 addr, uInt8 value, CartDebug::DisasmFlags flags = CartDebug::NONE); void poke(uInt16 addr, uInt8 value, Device::AccessFlags flags = Device::NONE);
/** Convenience method to access the 6502 from System */ /** Convenience method to access the 6502 from System */
M6502& m6502() const; M6502& m6502() const;
/** These are now exposed so Expressions can use them. */ /** These are now exposed so Expressions can use them. */
int peekAsInt(int addr, CartDebug::DisasmFlags flags = CartDebug::NONE); int peekAsInt(int addr, Device::AccessFlags flags = Device::NONE);
int dpeekAsInt(int addr, CartDebug::DisasmFlags flags = CartDebug::NONE); int dpeekAsInt(int addr, Device::AccessFlags flags = Device::NONE);
CartDebug::DisasmFlags getAccessFlags(uInt16 addr) const; Device::AccessFlags getAccessFlags(uInt16 addr) const;
void setAccessFlags(uInt16 addr, CartDebug::DisasmFlags flags); void setAccessFlags(uInt16 addr, Device::AccessFlags flags);
uInt32 getBaseAddress(uInt32 addr, bool read); uInt32 getBaseAddress(uInt32 addr, bool read);

View File

@ -924,7 +924,7 @@ void DebuggerParser::executeCode()
} }
bool result = debugger.cartDebug().addDirective( bool result = debugger.cartDebug().addDirective(
CartDebug::CODE, args[0], args[1]); Device::CODE, args[0], args[1]);
commandResult << (result ? "added" : "removed") << " CODE directive on range $" commandResult << (result ? "added" : "removed") << " CODE directive on range $"
<< hex << args[0] << " $" << hex << args[1]; << hex << args[0] << " $" << hex << args[1];
debugger.rom().invalidate(); debugger.rom().invalidate();
@ -965,7 +965,7 @@ void DebuggerParser::executeData()
} }
bool result = debugger.cartDebug().addDirective( bool result = debugger.cartDebug().addDirective(
CartDebug::DATA, args[0], args[1]); Device::DATA, args[0], args[1]);
commandResult << (result ? "added" : "removed") << " DATA directive on range $" commandResult << (result ? "added" : "removed") << " DATA directive on range $"
<< hex << args[0] << " $" << hex << args[1]; << hex << args[0] << " $" << hex << args[1];
debugger.rom().invalidate(); debugger.rom().invalidate();
@ -1282,7 +1282,7 @@ void DebuggerParser::executeGfx()
} }
bool result = debugger.cartDebug().addDirective( bool result = debugger.cartDebug().addDirective(
CartDebug::GFX, args[0], args[1]); Device::GFX, args[0], args[1]);
commandResult << (result ? "added" : "removed") << " GFX directive on range $" commandResult << (result ? "added" : "removed") << " GFX directive on range $"
<< hex << args[0] << " $" << hex << args[1]; << hex << args[0] << " $" << hex << args[1];
debugger.rom().invalidate(); debugger.rom().invalidate();
@ -1642,7 +1642,7 @@ void DebuggerParser::executePGfx()
} }
bool result = debugger.cartDebug().addDirective( bool result = debugger.cartDebug().addDirective(
CartDebug::PGFX, args[0], args[1]); Device::PGFX, args[0], args[1]);
commandResult << (result ? "added" : "removed") << " PGFX directive on range $" commandResult << (result ? "added" : "removed") << " PGFX directive on range $"
<< hex << args[0] << " $" << hex << args[1]; << hex << args[0] << " $" << hex << args[1];
debugger.rom().invalidate(); debugger.rom().invalidate();
@ -1734,7 +1734,7 @@ void DebuggerParser::executeRow()
} }
bool result = debugger.cartDebug().addDirective( bool result = debugger.cartDebug().addDirective(
CartDebug::ROW, args[0], args[1]); Device::ROW, args[0], args[1]);
commandResult << (result ? "added" : "removed") << " ROW directive on range $" commandResult << (result ? "added" : "removed") << " ROW directive on range $"
<< hex << args[0] << " $" << hex << args[1]; << hex << args[0] << " $" << hex << args[1];
debugger.rom().invalidate(); debugger.rom().invalidate();
@ -2194,7 +2194,7 @@ void DebuggerParser::executeType()
for(uInt32 i = beg; i <= end; ++i) for(uInt32 i = beg; i <= end; ++i)
{ {
commandResult << Base::HEX4 << i << ": "; commandResult << Base::HEX4 << i << ": ";
debugger.cartDebug().addressTypeAsString(commandResult, i); debugger.cartDebug().accessTypeAsString(commandResult, i);
commandResult << endl; commandResult << endl;
} }
} }
@ -3182,7 +3182,7 @@ std::array<DebuggerParser::Command, 95> DebuggerParser::commands = { {
{ {
"type", "type",
"Show disassembly type for address xx [yy]", "Show access type for address xx [yy]",
"Example: type f000, type f000 f010", "Example: type f000, type f000 f010",
true, true,
false, false,

View File

@ -17,6 +17,7 @@
#include "bspf.hxx" #include "bspf.hxx"
#include "Debugger.hxx" #include "Debugger.hxx"
#include "Device.hxx"
#include "DiStella.hxx" #include "DiStella.hxx"
using Common::Base; using Common::Base;
@ -73,7 +74,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
// Add reserved line equates // Add reserved line equates
ostringstream reservedLabel; ostringstream reservedLabel;
for (int k = 0; k <= myAppData.end; k++) { for (int k = 0; k <= myAppData.end; k++) {
if ((myLabels[k] & (CartDebug::REFERENCED | CartDebug::VALID_ENTRY)) == CartDebug::REFERENCED) { if ((myLabels[k] & (Device::REFERENCED | Device::VALID_ENTRY)) == Device::REFERENCED) {
// If we have a piece of code referenced somewhere else, but cannot // If we have a piece of code referenced somewhere else, but cannot
// locate the label in code (i.e because the address is inside of a // locate the label in code (i.e because the address is inside of a
// multi-byte instruction, then we make note of that address for reference // multi-byte instruction, then we make note of that address for reference
@ -110,7 +111,7 @@ void DiStella::disasm(uInt32 distart, int pass)
int labelFound = 0; int labelFound = 0;
stringstream nextLine, nextLineBytes; stringstream nextLine, nextLineBytes;
mySegType = CartDebug::NONE; // create extra lines between code and data mySegType = Device::NONE; // create extra lines between code and data
myDisasmBuf.str(""); myDisasmBuf.str("");
@ -124,58 +125,58 @@ void DiStella::disasm(uInt32 distart, int pass)
if(myPC == myAppData.end) if(myPC == myAppData.end)
goto FIX_LAST; goto FIX_LAST;
if (checkBits(myPC, CartDebug::GFX | CartDebug::PGFX, if (checkBits(myPC, Device::GFX | Device::PGFX,
CartDebug::CODE)) Device::CODE))
{ {
if (pass == 2) if (pass == 2)
mark(myPC + myOffset, CartDebug::VALID_ENTRY); mark(myPC + myOffset, Device::VALID_ENTRY);
if (pass == 3) if (pass == 3)
outputGraphics(); outputGraphics();
++myPC; ++myPC;
} else if (checkBits(myPC, CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL, } else if (checkBits(myPC, Device::COL | Device::PCOL | Device::BCOL,
CartDebug::CODE | CartDebug::GFX | CartDebug::PGFX)) Device::CODE | Device::GFX | Device::PGFX))
{ {
if (pass == 2) if (pass == 2)
mark(myPC + myOffset, CartDebug::VALID_ENTRY); mark(myPC + myOffset, Device::VALID_ENTRY);
if (pass == 3) if (pass == 3)
outputColors(); outputColors();
++myPC; ++myPC;
} else if (checkBits(myPC, CartDebug::DATA, } else if (checkBits(myPC, Device::DATA,
CartDebug::CODE | CartDebug::GFX | CartDebug::PGFX | Device::CODE | Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL)) Device::COL | Device::PCOL | Device::BCOL))
{ {
if (pass == 2) if (pass == 2)
mark(myPC + myOffset, CartDebug::VALID_ENTRY); mark(myPC + myOffset, Device::VALID_ENTRY);
if (pass == 3) if (pass == 3)
outputBytes(CartDebug::DATA); outputBytes(Device::DATA);
else else
++myPC; ++myPC;
} else if (checkBits(myPC, CartDebug::ROW, } else if (checkBits(myPC, Device::ROW,
CartDebug::CODE | Device::CODE |
CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX | Device::DATA | Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL)) { Device::COL | Device::PCOL | Device::BCOL)) {
FIX_LAST: FIX_LAST:
if (pass == 2) if (pass == 2)
mark(myPC + myOffset, CartDebug::VALID_ENTRY); mark(myPC + myOffset, Device::VALID_ENTRY);
if (pass == 3) if (pass == 3)
outputBytes(CartDebug::ROW); outputBytes(Device::ROW);
else else
++myPC; ++myPC;
} else { } else {
// The following sections must be CODE // The following sections must be CODE
// add extra spacing line when switching from non-code to code // add extra spacing line when switching from non-code to code
if (pass == 3 && mySegType != CartDebug::CODE && mySegType != CartDebug::NONE) { if (pass == 3 && mySegType != Device::CODE && mySegType != Device::NONE) {
myDisasmBuf << " ' ' "; myDisasmBuf << " ' ' ";
addEntry(CartDebug::NONE); addEntry(Device::NONE);
mark(myPC + myOffset, CartDebug::REFERENCED); // add label when switching mark(myPC + myOffset, Device::REFERENCED); // add label when switching
} }
mySegType = CartDebug::CODE; mySegType = Device::CODE;
/* version 2.1 bug fix */ /* version 2.1 bug fix */
if (pass == 2) if (pass == 2)
mark(myPC + myOffset, CartDebug::VALID_ENTRY); mark(myPC + myOffset, Device::VALID_ENTRY);
// get opcode // get opcode
opcode = Debugger::debugger().peek(myPC + myOffset); opcode = Debugger::debugger().peek(myPC + myOffset);
@ -183,7 +184,7 @@ FIX_LAST:
addrMode = ourLookup[opcode].addr_mode; addrMode = ourLookup[opcode].addr_mode;
if (pass == 3) { if (pass == 3) {
if (checkBit(myPC, CartDebug::REFERENCED)) if (checkBit(myPC, Device::REFERENCED))
myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'";
else else
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '";
@ -193,7 +194,7 @@ FIX_LAST:
// detect labels inside instructions (e.g. BIT masks) // detect labels inside instructions (e.g. BIT masks)
labelFound = false; labelFound = false;
for (Uint8 i = 0; i < ourLookup[opcode].bytes - 1; i++) { for (Uint8 i = 0; i < ourLookup[opcode].bytes - 1; i++) {
if (checkBit(myPC + i, CartDebug::REFERENCED)) { if (checkBit(myPC + i, Device::REFERENCED)) {
labelFound = true; labelFound = true;
break; break;
} }
@ -216,7 +217,7 @@ FIX_LAST:
nextLine.str(""); nextLine.str("");
cycles = 0; cycles = 0;
addEntry(CartDebug::CODE); // add the new found CODE entry addEntry(Device::CODE); // add the new found CODE entry
} }
// continue with the label's opcode // continue with the label's opcode
continue; continue;
@ -255,10 +256,10 @@ FIX_LAST:
myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $"
<< Base::HEX4 << myPC + myOffset << "'" << Base::HEX4 << myPC + myOffset << "'"
<< Base::HEX2 << int(opcode); << Base::HEX2 << int(opcode);
addEntry(CartDebug::DATA); addEntry(Device::DATA);
if (myPC == myAppData.end) { if (myPC == myAppData.end) {
if (checkBit(myPC, CartDebug::REFERENCED)) if (checkBit(myPC, Device::REFERENCED))
myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'";
else else
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '";
@ -267,7 +268,7 @@ FIX_LAST:
myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $"
<< Base::HEX4 << myPC + myOffset << "'" << Base::HEX4 << myPC + myOffset << "'"
<< Base::HEX2 << int(opcode); << Base::HEX2 << int(opcode);
addEntry(CartDebug::DATA); addEntry(Device::DATA);
} }
} }
myPCEnd = myAppData.end + myOffset; myPCEnd = myAppData.end + myOffset;
@ -284,7 +285,7 @@ FIX_LAST:
/* Line information is already printed, but we can remove the /* Line information is already printed, but we can remove the
Instruction (i.e. BMI) by simply clearing the buffer to print */ Instruction (i.e. BMI) by simply clearing the buffer to print */
myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode); myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode);
addEntry(CartDebug::ROW); addEntry(Device::ROW);
nextLine.str(""); nextLine.str("");
nextLineBytes.str(""); nextLineBytes.str("");
} }
@ -312,7 +313,7 @@ FIX_LAST:
case AddressingMode::ABSOLUTE: case AddressingMode::ABSOLUTE:
{ {
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
labelFound = mark(ad, CartDebug::REFERENCED); labelFound = mark(ad, Device::REFERENCED);
if (pass == 3) { if (pass == 3) {
if (ad < 0x100 && mySettings.fFlag) if (ad < 0x100 && mySettings.fFlag)
nextLine << ".w "; nextLine << ".w ";
@ -342,7 +343,7 @@ FIX_LAST:
case AddressingMode::ZERO_PAGE: case AddressingMode::ZERO_PAGE:
{ {
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
labelFound = mark(d1, CartDebug::REFERENCED); labelFound = mark(d1, Device::REFERENCED);
if (pass == 3) { if (pass == 3) {
nextLine << " "; nextLine << " ";
LABEL_A12_LOW(int(d1)); LABEL_A12_LOW(int(d1));
@ -364,13 +365,13 @@ FIX_LAST:
case AddressingMode::ABSOLUTE_X: case AddressingMode::ABSOLUTE_X:
{ {
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
labelFound = mark(ad, CartDebug::REFERENCED); labelFound = mark(ad, Device::REFERENCED);
if (pass == 2 && !checkBit(ad & myAppData.end, CartDebug::CODE)) { if (pass == 2 && !checkBit(ad & myAppData.end, Device::CODE)) {
// Since we can't know what address is being accessed unless we also // Since we can't know what address is being accessed unless we also
// know the current X value, this is marked as ROW instead of DATA // know the current X value, this is marked as ROW instead of DATA
// The processing is left here, however, in case future versions of // The processing is left here, however, in case future versions of
// the code can somehow track access to CPU registers // the code can somehow track access to CPU registers
mark(ad, CartDebug::ROW); mark(ad, Device::ROW);
} else if (pass == 3) { } else if (pass == 3) {
if (ad < 0x100 && mySettings.fFlag) if (ad < 0x100 && mySettings.fFlag)
nextLine << ".wx "; nextLine << ".wx ";
@ -403,13 +404,13 @@ FIX_LAST:
case AddressingMode::ABSOLUTE_Y: case AddressingMode::ABSOLUTE_Y:
{ {
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
labelFound = mark(ad, CartDebug::REFERENCED); labelFound = mark(ad, Device::REFERENCED);
if (pass == 2 && !checkBit(ad & myAppData.end, CartDebug::CODE)) { if (pass == 2 && !checkBit(ad & myAppData.end, Device::CODE)) {
// Since we can't know what address is being accessed unless we also // Since we can't know what address is being accessed unless we also
// know the current Y value, this is marked as ROW instead of DATA // know the current Y value, this is marked as ROW instead of DATA
// The processing is left here, however, in case future versions of // The processing is left here, however, in case future versions of
// the code can somehow track access to CPU registers // the code can somehow track access to CPU registers
mark(ad, CartDebug::ROW); mark(ad, Device::ROW);
} else if (pass == 3) { } else if (pass == 3) {
if (ad < 0x100 && mySettings.fFlag) if (ad < 0x100 && mySettings.fFlag)
nextLine << ".wy "; nextLine << ".wy ";
@ -468,7 +469,7 @@ FIX_LAST:
case AddressingMode::ZERO_PAGE_X: case AddressingMode::ZERO_PAGE_X:
{ {
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
labelFound = mark(d1, CartDebug::REFERENCED); labelFound = mark(d1, Device::REFERENCED);
if (pass == 3) { if (pass == 3) {
nextLine << " "; nextLine << " ";
LABEL_A12_LOW(d1); LABEL_A12_LOW(d1);
@ -481,7 +482,7 @@ FIX_LAST:
case AddressingMode::ZERO_PAGE_Y: case AddressingMode::ZERO_PAGE_Y:
{ {
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
labelFound = mark(d1, CartDebug::REFERENCED); labelFound = mark(d1, Device::REFERENCED);
if (pass == 3) { if (pass == 3) {
nextLine << " "; nextLine << " ";
LABEL_A12_LOW(d1); LABEL_A12_LOW(d1);
@ -499,7 +500,7 @@ FIX_LAST:
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; ad = ((myPC + Int8(d1)) & 0xfff) + myOffset;
labelFound = mark(ad, CartDebug::REFERENCED); labelFound = mark(ad, Device::REFERENCED);
if (pass == 3) { if (pass == 3) {
if (labelFound == 1) { if (labelFound == 1) {
nextLine << " "; nextLine << " ";
@ -515,13 +516,13 @@ FIX_LAST:
case AddressingMode::ABS_INDIRECT: case AddressingMode::ABS_INDIRECT:
{ {
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
labelFound = mark(ad, CartDebug::REFERENCED); labelFound = mark(ad, Device::REFERENCED);
if (pass == 2 && !checkBit(ad & myAppData.end, CartDebug::CODE)) { if (pass == 2 && !checkBit(ad & myAppData.end, Device::CODE)) {
// Since we can't know what address is being accessed unless we also // Since we can't know what address is being accessed unless we also
// know the current X value, this is marked as ROW instead of DATA // know the current X value, this is marked as ROW instead of DATA
// The processing is left here, however, in case future versions of // The processing is left here, however, in case future versions of
// the code can somehow track access to CPU registers // the code can somehow track access to CPU registers
mark(ad, CartDebug::ROW); mark(ad, Device::ROW);
} else if (pass == 3) { } else if (pass == 3) {
if (ad < 0x100 && mySettings.fFlag) if (ad < 0x100 && mySettings.fFlag)
nextLine << ".ind "; nextLine << ".ind ";
@ -555,7 +556,7 @@ FIX_LAST:
<< ";" << std::dec << int(ourLookup[opcode].cycles) << ";" << std::dec << int(ourLookup[opcode].cycles)
<< (addrMode == AddressingMode::RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/3!" : "/3 " : " "); << (addrMode == AddressingMode::RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/3!" : "/3 " : " ");
if ((opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00 // code block end if ((opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00 // code block end
|| checkBit(myPC, CartDebug::REFERENCED) // referenced address || checkBit(myPC, Device::REFERENCED) // referenced address
|| (ourLookup[opcode].rw_mode == RWMode::WRITE && d1 == WSYNC)) // strobe WSYNC || (ourLookup[opcode].rw_mode == RWMode::WRITE && d1 == WSYNC)) // strobe WSYNC
&& cycles > 0) { && cycles > 0) {
// output cycles for previous code block // output cycles for previous code block
@ -566,11 +567,11 @@ FIX_LAST:
} }
myDisasmBuf << "'" << nextLineBytes.str(); myDisasmBuf << "'" << nextLineBytes.str();
addEntry(CartDebug::CODE); addEntry(Device::CODE);
if (opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00) { if (opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00) {
myDisasmBuf << " ' ' "; myDisasmBuf << " ' ' ";
addEntry(CartDebug::NONE); addEntry(Device::NONE);
mySegType = CartDebug::NONE; // prevent extra lines if data follows mySegType = Device::NONE; // prevent extra lines if data follows
} }
nextLine.str(""); nextLine.str("");
@ -619,17 +620,17 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
// in the emulation core indicate that the CODE range has finished // in the emulation core indicate that the CODE range has finished
// Therefore, we stop at the first such address encountered // Therefore, we stop at the first such address encountered
for (uInt32 k = pcBeg; k <= myPCEnd; ++k) { for (uInt32 k = pcBeg; k <= myPCEnd; ++k) {
if (checkBits(k, CartDebug::CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX | if (checkBits(k, Device::Device::DATA | Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL, Device::COL | Device::PCOL | Device::BCOL,
CartDebug::CODE)) { Device::CODE)) {
//if (Debugger::debugger().getAccessFlags(k) & //if (Debugger::debugger().getAccessFlags(k) &
// (CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX)) { // (Device::DATA | Device::GFX | Device::PGFX)) {
// TODO: this should never happen, remove when we are sure // TODO: this should never happen, remove when we are sure
// TODO: NOT USED: uInt16 flags = Debugger::debugger().getAccessFlags(k); // TODO: NOT USED: uInt16 flags = Debugger::debugger().getAccessFlags(k);
myPCEnd = k - 1; myPCEnd = k - 1;
break; break;
} }
mark(k, CartDebug::CODE); mark(k, Device::CODE);
} }
} }
@ -651,7 +652,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
while (myAddressQueue.empty() && it != debuggerAddresses.end()) { while (myAddressQueue.empty() && it != debuggerAddresses.end()) {
uInt16 addr = *it; uInt16 addr = *it;
if (!checkBit(addr - myOffset, CartDebug::CODE)) { if (!checkBit(addr - myOffset, Device::CODE)) {
myAddressQueue.push(addr); myAddressQueue.push(addr);
++it; ++it;
} else // remove this address, it is redundant } else // remove this address, it is redundant
@ -661,8 +662,8 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
// Stella itself can provide hints on whether an address has ever // Stella itself can provide hints on whether an address has ever
// been referenced as CODE // been referenced as CODE
while (myAddressQueue.empty() && codeAccessPoint <= myAppData.end) { while (myAddressQueue.empty() && codeAccessPoint <= myAppData.end) {
if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & CartDebug::CODE) if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & Device::CODE)
&& !(myLabels[codeAccessPoint & myAppData.end] & CartDebug::CODE)) { && !(myLabels[codeAccessPoint & myAppData.end] & Device::CODE)) {
myAddressQueue.push(codeAccessPoint + myOffset); myAddressQueue.push(codeAccessPoint + myOffset);
++codeAccessPoint; ++codeAccessPoint;
break; break;
@ -674,17 +675,17 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
for (int k = 0; k <= myAppData.end; k++) { for (int k = 0; k <= myAppData.end; k++) {
// Let the emulation core know about tentative code // Let the emulation core know about tentative code
if (checkBit(k, CartDebug::CODE) && if (checkBit(k, Device::CODE) &&
!(Debugger::debugger().getAccessFlags(k + myOffset) & CartDebug::CODE) !(Debugger::debugger().getAccessFlags(k + myOffset) & Device::CODE)
&& myOffset != 0) { && myOffset != 0) {
Debugger::debugger().setAccessFlags(k + myOffset, CartDebug::TCODE); Debugger::debugger().setAccessFlags(k + myOffset, Device::TCODE);
} }
// Must be ROW / unused bytes // Must be ROW / unused bytes
if (!checkBit(k, CartDebug::CODE | CartDebug::GFX | CartDebug::PGFX | if (!checkBit(k, Device::CODE | Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL | Device::COL | Device::PCOL | Device::BCOL |
CartDebug::DATA)) Device::DATA))
mark(k + myOffset, CartDebug::ROW); mark(k + myOffset, Device::ROW);
} }
} }
@ -700,9 +701,9 @@ void DiStella::disasmFromAddress(uInt32 distart)
while (myPC <= myAppData.end) { while (myPC <= myAppData.end) {
// abort when we reach non-code areas // abort when we reach non-code areas
if (checkBits(myPC, CartDebug::CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX | if (checkBits(myPC, Device::Device::DATA | Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL, Device::COL | Device::PCOL | Device::BCOL,
CartDebug::CODE)) { Device::CODE)) {
myPCEnd = (myPC - 1) + myOffset; myPCEnd = (myPC - 1) + myOffset;
return; return;
} }
@ -746,22 +747,22 @@ void DiStella::disasmFromAddress(uInt32 distart)
switch (addrMode) { switch (addrMode) {
case AddressingMode::ABSOLUTE: case AddressingMode::ABSOLUTE:
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
mark(ad, CartDebug::REFERENCED); mark(ad, Device::REFERENCED);
// handle JMP/JSR // handle JMP/JSR
if (ourLookup[opcode].source == AccessMode::ADDR) { if (ourLookup[opcode].source == AccessMode::ADDR) {
// do NOT use flags set by debugger, else known CODE will not analyzed statically. // do NOT use flags set by debugger, else known CODE will not analyzed statically.
if (!checkBit(ad & myAppData.end, CartDebug::CODE, false)) { if (!checkBit(ad & myAppData.end, Device::CODE, false)) {
if (ad > 0xfff) if (ad > 0xfff)
myAddressQueue.push((ad & myAppData.end) + myOffset); myAddressQueue.push((ad & myAppData.end) + myOffset);
mark(ad, CartDebug::CODE); mark(ad, Device::CODE);
} }
} else } else
mark(ad, CartDebug::DATA); mark(ad, Device::DATA);
break; break;
case AddressingMode::ZERO_PAGE: case AddressingMode::ZERO_PAGE:
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
mark(d1, CartDebug::REFERENCED); mark(d1, Device::REFERENCED);
break; break;
case AddressingMode::IMMEDIATE: case AddressingMode::IMMEDIATE:
@ -770,12 +771,12 @@ void DiStella::disasmFromAddress(uInt32 distart)
case AddressingMode::ABSOLUTE_X: case AddressingMode::ABSOLUTE_X:
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
mark(ad, CartDebug::REFERENCED); mark(ad, Device::REFERENCED);
break; break;
case AddressingMode::ABSOLUTE_Y: case AddressingMode::ABSOLUTE_Y:
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
mark(ad, CartDebug::REFERENCED); mark(ad, Device::REFERENCED);
break; break;
case AddressingMode::INDIRECT_X: case AddressingMode::INDIRECT_X:
@ -788,12 +789,12 @@ void DiStella::disasmFromAddress(uInt32 distart)
case AddressingMode::ZERO_PAGE_X: case AddressingMode::ZERO_PAGE_X:
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
mark(d1, CartDebug::REFERENCED); mark(d1, Device::REFERENCED);
break; break;
case AddressingMode::ZERO_PAGE_Y: case AddressingMode::ZERO_PAGE_Y:
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
mark(d1, CartDebug::REFERENCED); mark(d1, Device::REFERENCED);
break; break;
case AddressingMode::RELATIVE: case AddressingMode::RELATIVE:
@ -802,17 +803,17 @@ void DiStella::disasmFromAddress(uInt32 distart)
// indexing into the labels array caused a crash // indexing into the labels array caused a crash
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; ad = ((myPC + Int8(d1)) & 0xfff) + myOffset;
mark(ad, CartDebug::REFERENCED); mark(ad, Device::REFERENCED);
// do NOT use flags set by debugger, else known CODE will not analyzed statically. // do NOT use flags set by debugger, else known CODE will not analyzed statically.
if (!checkBit(ad - myOffset, CartDebug::CODE, false)) { if (!checkBit(ad - myOffset, Device::CODE, false)) {
myAddressQueue.push(ad); myAddressQueue.push(ad);
mark(ad, CartDebug::CODE); mark(ad, Device::CODE);
} }
break; break;
case AddressingMode::ABS_INDIRECT: case AddressingMode::ABS_INDIRECT:
ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2;
mark(ad, CartDebug::REFERENCED); mark(ad, Device::REFERENCED);
break; break;
default: default:
@ -821,10 +822,10 @@ void DiStella::disasmFromAddress(uInt32 distart)
// mark BRK vector // mark BRK vector
if (opcode == 0x00) { if (opcode == 0x00) {
ad = Debugger::debugger().dpeek(0xfffe, CartDebug::DATA); ad = Debugger::debugger().dpeek(0xfffe, Device::DATA);
if (!myReserved.breakFound) { if (!myReserved.breakFound) {
myAddressQueue.push(ad); myAddressQueue.push(ad);
mark(ad, CartDebug::CODE); mark(ad, Device::CODE);
myReserved.breakFound = true; myReserved.breakFound = true;
} }
} }
@ -943,8 +944,8 @@ bool DiStella::checkBits(uInt16 address, uInt16 mask, uInt16 notMask, bool useDe
/*bool DiStella::isType(uInt16 address) const /*bool DiStella::isType(uInt16 address) const
{ {
return checkBits(address, CartDebug::GFX | CartDebug::PGFX | return checkBits(address, Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL); Device::COL | Device::PCOL | Device::BCOL);
}*/ }*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -967,7 +968,7 @@ bool DiStella::check_range(uInt16 beg, uInt16 end) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DiStella::addEntry(CartDebug::DisasmType type) void DiStella::addEntry(Device::AccessType type)
{ {
CartDebug::DisassemblyTag tag; CartDebug::DisassemblyTag tag;
@ -993,7 +994,7 @@ void DiStella::addEntry(CartDebug::DisasmType type)
if (tag.label == EmptyString) { if (tag.label == EmptyString) {
if (myDisasmBuf.peek() != ' ') if (myDisasmBuf.peek() != ' ')
getline(myDisasmBuf, tag.label, '\''); getline(myDisasmBuf, tag.label, '\'');
else if (mySettings.showAddresses && tag.type == CartDebug::CODE) { else if (mySettings.showAddresses && tag.type == Device::CODE) {
// Have addresses indented, to differentiate from actual labels // Have addresses indented, to differentiate from actual labels
tag.label = " " + Base::toString(tag.address, Base::Fmt::_16_4); tag.label = " " + Base::toString(tag.address, Base::Fmt::_16_4);
tag.hllabel = false; tag.hllabel = false;
@ -1006,7 +1007,7 @@ void DiStella::addEntry(CartDebug::DisasmType type)
// variable length labels, cycle counts, etc // variable length labels, cycle counts, etc
myDisasmBuf.seekg(11, std::ios::beg); myDisasmBuf.seekg(11, std::ios::beg);
switch (tag.type) { switch (tag.type) {
case CartDebug::CODE: case Device::CODE:
getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.disasm, '\'');
getline(myDisasmBuf, tag.ccount, '\''); getline(myDisasmBuf, tag.ccount, '\'');
getline(myDisasmBuf, tag.ctotal, '\''); getline(myDisasmBuf, tag.ctotal, '\'');
@ -1017,36 +1018,36 @@ void DiStella::addEntry(CartDebug::DisasmType type)
// but it could also indicate that code will *never* be accessed // but it could also indicate that code will *never* be accessed
// Since it is impossible to tell the difference, marking the address // Since it is impossible to tell the difference, marking the address
// in the disassembly at least tells the user about it // in the disassembly at least tells the user about it
if (!(Debugger::debugger().getAccessFlags(tag.address) & CartDebug::CODE) if (!(Debugger::debugger().getAccessFlags(tag.address) & Device::CODE)
&& myOffset != 0) { && myOffset != 0) {
tag.ccount += " *"; tag.ccount += " *";
Debugger::debugger().setAccessFlags(tag.address, CartDebug::TCODE); Debugger::debugger().setAccessFlags(tag.address, Device::TCODE);
} }
break; break;
case CartDebug::GFX: case Device::GFX:
case CartDebug::PGFX: case Device::PGFX:
getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.disasm, '\'');
getline(myDisasmBuf, tag.bytes); getline(myDisasmBuf, tag.bytes);
break; break;
case CartDebug::COL: case Device::COL:
case CartDebug::PCOL: case Device::PCOL:
case CartDebug::BCOL: case Device::BCOL:
getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.disasm, '\'');
getline(myDisasmBuf, tag.bytes); getline(myDisasmBuf, tag.bytes);
break; break;
case CartDebug::DATA: case Device::DATA:
getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.disasm, '\'');
getline(myDisasmBuf, tag.bytes); getline(myDisasmBuf, tag.bytes);
break; break;
case CartDebug::ROW: case Device::ROW:
getline(myDisasmBuf, tag.disasm); getline(myDisasmBuf, tag.disasm);
break; break;
case CartDebug::NONE: case Device::NONE:
default: // should never happen default: // should never happen
tag.disasm = " "; tag.disasm = " ";
break; break;
@ -1061,18 +1062,18 @@ DONE_WITH_ADD:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DiStella::outputGraphics() void DiStella::outputGraphics()
{ {
bool isPGfx = checkBit(myPC, CartDebug::PGFX); bool isPGfx = checkBit(myPC, Device::PGFX);
const string& bitString = isPGfx ? "\x1f" : "\x1e"; const string& bitString = isPGfx ? "\x1f" : "\x1e";
uInt8 byte = Debugger::debugger().peek(myPC + myOffset); uInt8 byte = Debugger::debugger().peek(myPC + myOffset);
// add extra spacing line when switching from non-graphics to graphics // add extra spacing line when switching from non-graphics to graphics
if (mySegType != CartDebug::GFX && mySegType != CartDebug::NONE) { if (mySegType != Device::GFX && mySegType != Device::NONE) {
myDisasmBuf << " ' ' "; myDisasmBuf << " ' ' ";
addEntry(CartDebug::NONE); addEntry(Device::NONE);
} }
mySegType = CartDebug::GFX; mySegType = Device::GFX;
if (checkBit(myPC, CartDebug::REFERENCED)) if (checkBit(myPC, Device::REFERENCED))
myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'";
else else
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '";
@ -1085,7 +1086,7 @@ void DiStella::outputGraphics()
else else
myDisasmBuf << Base::HEX2 << int(byte); myDisasmBuf << Base::HEX2 << int(byte);
addEntry(isPGfx ? CartDebug::PGFX : CartDebug::GFX); addEntry(isPGfx ? Device::PGFX : Device::GFX);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1111,15 +1112,15 @@ void DiStella::outputColors()
uInt8 byte = Debugger::debugger().peek(myPC + myOffset); uInt8 byte = Debugger::debugger().peek(myPC + myOffset);
// add extra spacing line when switching from non-colors to colors // add extra spacing line when switching from non-colors to colors
if(mySegType != CartDebug::COL && mySegType != CartDebug::NONE) if(mySegType != Device::COL && mySegType != Device::NONE)
{ {
myDisasmBuf << " ' ' "; myDisasmBuf << " ' ' ";
addEntry(CartDebug::NONE); addEntry(Device::NONE);
} }
mySegType = CartDebug::COL; mySegType = Device::COL;
// output label/address // output label/address
if(checkBit(myPC, CartDebug::REFERENCED)) if(checkBit(myPC, Device::REFERENCED))
myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'";
else else
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '";
@ -1147,29 +1148,29 @@ void DiStella::outputColors()
// output address // output address
myDisasmBuf << "; $" << Base::HEX4 << myPC + myOffset << " " myDisasmBuf << "; $" << Base::HEX4 << myPC + myOffset << " "
<< (checkBit(myPC, CartDebug::COL) ? "(Px)" : checkBit(myPC, CartDebug::PCOL) ? "(PF)" : "(BK)"); << (checkBit(myPC, Device::COL) ? "(Px)" : checkBit(myPC, Device::PCOL) ? "(PF)" : "(BK)");
// output color value // output color value
myDisasmBuf << "'" << Base::HEX2 << int(byte); myDisasmBuf << "'" << Base::HEX2 << int(byte);
addEntry(checkBit(myPC, CartDebug::COL) ? CartDebug::COL : addEntry(checkBit(myPC, Device::COL) ? Device::COL :
checkBit(myPC, CartDebug::PCOL) ? CartDebug::PCOL : CartDebug::BCOL); checkBit(myPC, Device::PCOL) ? Device::PCOL : Device::BCOL);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DiStella::outputBytes(CartDebug::DisasmType type) void DiStella::outputBytes(Device::AccessType type)
{ {
bool isType = true; bool isType = true;
bool referenced = checkBit(myPC, CartDebug::REFERENCED); bool referenced = checkBit(myPC, Device::REFERENCED);
bool lineEmpty = true; bool lineEmpty = true;
int numBytes = 0; int numBytes = 0;
// add extra spacing line when switching from non-data to data // add extra spacing line when switching from non-data to data
if (mySegType != CartDebug::DATA && mySegType != CartDebug::NONE) { if (mySegType != Device::DATA && mySegType != Device::NONE) {
myDisasmBuf << " ' ' "; myDisasmBuf << " ' ' ";
addEntry(CartDebug::NONE); addEntry(Device::NONE);
} }
mySegType = CartDebug::DATA; mySegType = Device::DATA;
while (isType && myPC <= myAppData.end) { while (isType && myPC <= myAppData.end) {
if (referenced) { if (referenced) {
@ -1200,15 +1201,15 @@ void DiStella::outputBytes(CartDebug::DisasmType type)
++myPC; ++myPC;
} }
isType = checkBits(myPC, type, isType = checkBits(myPC, type,
CartDebug::CODE | (type != CartDebug::DATA ? CartDebug::DATA : 0) | Device::CODE | (type != Device::DATA ? Device::DATA : 0) |
CartDebug::GFX | CartDebug::PGFX | Device::GFX | Device::PGFX |
CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL); Device::COL | Device::PCOL | Device::BCOL);
referenced = checkBit(myPC, CartDebug::REFERENCED); referenced = checkBit(myPC, Device::REFERENCED);
} }
if (!lineEmpty) if (!lineEmpty)
addEntry(type); addEntry(type);
/*myDisasmBuf << " ' ' "; /*myDisasmBuf << " ' ' ";
addEntry(CartDebug::NONE);*/ addEntry(Device::NONE);*/
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -22,6 +22,7 @@
#include "Base.hxx" #include "Base.hxx"
#include "CartDebug.hxx" #include "CartDebug.hxx"
#include "Device.hxx"
#include "bspf.hxx" #include "bspf.hxx"
/** /**
@ -75,7 +76,7 @@ class DiStella
// Indicate that a new line of disassembly has been completed // Indicate that a new line of disassembly has been completed
// In the original Distella code, this indicated a new line to be printed // In the original Distella code, this indicated a new line to be printed
// Here, we add a new entry to the DisassemblyList // Here, we add a new entry to the DisassemblyList
void addEntry(CartDebug::DisasmType type); void addEntry(Device::AccessType type);
// Process directives given in the list // Process directives given in the list
// Directives are basically the contents of a distella configuration file // Directives are basically the contents of a distella configuration file
@ -93,7 +94,7 @@ class DiStella
//bool isType(uInt16 address) const; //bool isType(uInt16 address) const;
void outputGraphics(); void outputGraphics();
void outputColors(); void outputColors();
void outputBytes(CartDebug::DisasmType type); void outputBytes(Device::AccessType type);
// Convenience methods to generate appropriate labels // Convenience methods to generate appropriate labels
inline void labelA12High(stringstream& buf, uInt8 op, uInt16 addr, int labfound) inline void labelA12High(stringstream& buf, uInt8 op, uInt16 addr, int labfound)

View File

@ -511,10 +511,10 @@ void RomListWidget::drawWidget(bool hilite)
// Bytes are only editable if they represent code, graphics, or accessible data // Bytes are only editable if they represent code, graphics, or accessible data
// Otherwise, the disassembly should get all remaining space // Otherwise, the disassembly should get all remaining space
if(dlist[pos].type & (CartDebug::CODE|CartDebug::GFX|CartDebug::PGFX| if(dlist[pos].type & (Device::CODE|Device::GFX|Device::PGFX|
CartDebug::COL|CartDebug::PCOL|CartDebug::BCOL|CartDebug::DATA)) Device::COL|Device::PCOL|Device::BCOL|Device::DATA))
{ {
if(dlist[pos].type == CartDebug::CODE) if(dlist[pos].type == Device::CODE)
{ {
// Draw mnemonic // Draw mnemonic
s.drawString(_font, dlist[pos].disasm.substr(0, 7), xpos + _labelWidth, ypos, s.drawString(_font, dlist[pos].disasm.substr(0, 7), xpos + _labelWidth, ypos,
@ -593,8 +593,8 @@ void RomListWidget::startEditMode()
_editMode = true; _editMode = true;
switch(myDisasm->list[_selectedItem].type) switch(myDisasm->list[_selectedItem].type)
{ {
case CartDebug::GFX: case Device::GFX:
case CartDebug::PGFX: case Device::PGFX:
_base = DiStella::settings.gfxFormat; _base = DiStella::settings.gfxFormat;
break; break;
default: default:

View File

@ -20,7 +20,6 @@
#include "MD5.hxx" #include "MD5.hxx"
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx" #include "Debugger.hxx"
#include "CartDebug.hxx"
#endif #endif
#include "Cart.hxx" #include "Cart.hxx"
@ -117,8 +116,8 @@ void Cartridge::pokeRAM(uInt8& dest, uInt16 address, uInt8 value)
void Cartridge::createCodeAccessBase(size_t size) void Cartridge::createCodeAccessBase(size_t size)
{ {
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
myCodeAccessBase = make_unique<uInt16[]>(size); myCodeAccessBase = make_unique<Device::AccessFlags[]>(size);
std::fill_n(myCodeAccessBase.get(), size, CartDebug::ROW); std::fill_n(myCodeAccessBase.get(), size, Device::ROW);
#else #else
myCodeAccessBase = nullptr; myCodeAccessBase = nullptr;
#endif #endif

View File

@ -30,7 +30,7 @@ class GuiObject;
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "Font.hxx" #include "Font.hxx"
#endif #endif
#include "CartDebug.hxx"
/** /**
A cartridge is a device which contains the machine code for a A cartridge is a device which contains the machine code for a
@ -323,7 +323,7 @@ class Cartridge : public Device
// The array containing information about every byte of ROM indicating // The array containing information about every byte of ROM indicating
// whether it is used as code. // whether it is used as code.
std::unique_ptr<CartDebug::DisasmFlags[]> myCodeAccessBase; std::unique_ptr<Device::AccessFlags[]> myCodeAccessBase;
// Contains address of illegal RAM write access or 0 // Contains address of illegal RAM write access or 0
uInt16 myRamWriteAccess{0}; uInt16 myRamWriteAccess{0};

View File

@ -182,7 +182,7 @@ bool Cartridge4A50::poke(uInt16 address, uInt8 value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmFlags Cartridge4A50::getAccessFlags(uInt16 address) const Device::AccessFlags Cartridge4A50::getAccessFlags(uInt16 address) const
{ {
if((address & 0x1800) == 0x1000) // 2K region from 0x1000 - 0x17ff if((address & 0x1800) == 0x1000) // 2K region from 0x1000 - 0x17ff
{ {
@ -214,7 +214,7 @@ CartDebug::DisasmFlags Cartridge4A50::getAccessFlags(uInt16 address) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) void Cartridge4A50::setAccessFlags(uInt16 address, Device::AccessFlags flags)
{ {
if((address & 0x1800) == 0x1000) // 2K region from 0x1000 - 0x17ff if((address & 0x1800) == 0x1000) // 2K region from 0x1000 - 0x17ff
{ {

View File

@ -154,18 +154,18 @@ class Cartridge4A50 : public Cartridge
private: private:
/** /**
Query the given address type for the associated disassembly flags. Query the given address type for the associated access flags.
@param address The address to query @param address The address to query
*/ */
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override; Device::AccessFlags getAccessFlags(uInt16 address) const override;
/** /**
Change the given address to use the given disassembly flags. Change the given address to use the given access flags.
@param address The address to modify @param address The address to modify
@param flags A bitfield of DisasmType directives for the given address @param flags A bitfield of AccessType directives for the given address
*/ */
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override; void setAccessFlags(uInt16 address, Device::AccessFlags flags) override;
/** /**
Check all possible hotspots Check all possible hotspots

View File

@ -191,14 +191,14 @@ bool CartridgeAR::poke(uInt16 addr, uInt8)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmFlags CartridgeAR::getAccessFlags(uInt16 address) const Device::AccessFlags CartridgeAR::getAccessFlags(uInt16 address) const
{ {
return myCodeAccessBase[(address & 0x07FF) + return myCodeAccessBase[(address & 0x07FF) +
myImageOffset[(address & 0x0800) ? 1 : 0]]; myImageOffset[(address & 0x0800) ? 1 : 0]];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeAR::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) void CartridgeAR::setAccessFlags(uInt16 address, Device::AccessFlags flags)
{ {
myCodeAccessBase[(address & 0x07FF) + myCodeAccessBase[(address & 0x07FF) +
myImageOffset[(address & 0x0800) ? 1 : 0]] |= flags; myImageOffset[(address & 0x0800) ? 1 : 0]] |= flags;

View File

@ -160,18 +160,18 @@ class CartridgeAR : public Cartridge
private: private:
/** /**
Query the given address type for the associated disassembly flags. Query the given address type for the associated access flags.
@param address The address to query @param address The address to query
*/ */
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override; Device::AccessFlags getAccessFlags(uInt16 address) const override;
/** /**
Change the given address to use the given disassembly flags. Change the given address to use the given access flags.
@param address The address to modify @param address The address to modify
@param flags A bitfield of DisasmType directives for the given address @param flags A bitfield of AccessType directives for the given address
*/ */
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override; void setAccessFlags(uInt16 address, Device::AccessFlags flags) override;
// Handle a change to the bank configuration // Handle a change to the bank configuration
bool bankConfiguration(uInt8 configuration); bool bankConfiguration(uInt8 configuration);

View File

@ -22,7 +22,6 @@ class System;
#include "Console.hxx" #include "Console.hxx"
#include "Serializable.hxx" #include "Serializable.hxx"
#include "CartDebug.hxx"
#include "bspf.hxx" #include "bspf.hxx"
/** /**
@ -33,6 +32,34 @@ class System;
*/ */
class Device : public Serializable class Device : public Serializable
{ {
public:
enum AccessType {
NONE = 0,
REFERENCED = 1 << 0, /* 0x01, code somewhere in the program references it,
i.e. LDA $F372 referenced $F372 */
VALID_ENTRY = 1 << 1, /* 0x02, addresses that can have a label placed in front of it.
A good counterexample would be "FF00: LDA $FE00"; $FF01
would be in the middle of a multi-byte instruction, and
therefore cannot be labelled. */
// The following correspond to specific types that can be set within the
// debugger, or specified in a Distella cfg file, and are listed in order
// of decreasing hierarchy
//
CODE = 1 << 10, // 0x400, disassemble-able code segments
TCODE = 1 << 9, // 0x200, (tentative) disassemble-able code segments
GFX = 1 << 8, // 0x100, addresses loaded into GRPx registers
PGFX = 1 << 7, // 0x080, addresses loaded into PFx registers
COL = 1 << 6, // 0x040, addresses loaded into COLUPx registers
PCOL = 1 << 5, // 0x010, addresses loaded into COLUPF register
BCOL = 1 << 4, // 0x010, addresses loaded into COLUBK register
DATA = 1 << 3, // 0x008, addresses loaded into registers other than GRPx / PFx
ROW = 1 << 2, // 0x004, all other addresses
// special type for poke()
WRITE = TCODE // 0x200, address written to
};
using AccessFlags = uInt16;
public: public:
Device() = default; Device() = default;
virtual ~Device() = default; virtual ~Device() = default;
@ -99,19 +126,19 @@ class Device : public Serializable
virtual bool poke(uInt16 address, uInt8 value) { return false; } virtual bool poke(uInt16 address, uInt8 value) { return false; }
/** /**
Query the given address for its disassembly flags Query the given address for its access flags
@param address The address to modify @param address The address to modify
*/ */
virtual CartDebug::DisasmFlags getAccessFlags(uInt16 address) const { return CartDebug::NONE; } virtual AccessFlags getAccessFlags(uInt16 address) const { return AccessType::NONE; }
/** /**
Change the given address type to use the given disassembly flags Change the given address type to use the given access flags
@param address The address to modify @param address The address to modify
@param flags A bitfield of DisasmType directives for the given address @param flags A bitfield of AccessType directives for the given address
*/ */
virtual void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) { } virtual void setAccessFlags(uInt16 address, AccessFlags flags) { }
protected: protected:
/// Pointer to the system the device is installed in or the null pointer /// Pointer to the system the device is installed in or the null pointer

View File

@ -18,19 +18,19 @@
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx" #include "Debugger.hxx"
#include "Expression.hxx" #include "Expression.hxx"
#include "CartDebug.hxx" #include "Device.hxx"
#include "Base.hxx" #include "Base.hxx"
// Flags for disassembly types // Flags for access types
#define DISASM_CODE CartDebug::CODE #define DISASM_CODE Device::CODE
// #define DISASM_GFX CartDebug::GFX // #define DISASM_GFX Device::GFX
// #define DISASM_PGFX CartDebug::PGFX // #define DISASM_PGFX Device::PGFX
#define DISASM_DATA CartDebug::DATA #define DISASM_DATA Device::DATA
// #define DISASM_ROW CartDebug::ROW // #define DISASM_ROW Device::ROW
#define DISASM_WRITE CartDebug::WRITE #define DISASM_WRITE Device::WRITE
#define DISASM_NONE 0 #define DISASM_NONE 0
#else #else
// Flags for disassembly types // Flags for access types
#define DISASM_CODE 0 #define DISASM_CODE 0
// #define DISASM_GFX 0 // #define DISASM_GFX 0
// #define DISASM_PGFX 0 // #define DISASM_PGFX 0
@ -104,7 +104,7 @@ void M6502::reset()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline uInt8 M6502::peek(uInt16 address, CartDebug::DisasmFlags flags) inline uInt8 M6502::peek(uInt16 address, Device::AccessFlags flags)
{ {
handleHalt(); handleHalt();
@ -144,7 +144,7 @@ inline uInt8 M6502::peek(uInt16 address, CartDebug::DisasmFlags flags)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void M6502::poke(uInt16 address, uInt8 value, CartDebug::DisasmFlags flags) inline void M6502::poke(uInt16 address, uInt8 value, Device::AccessFlags flags)
{ {
//////////////////////////////////////////////// ////////////////////////////////////////////////
// TODO - move this logic directly into CartAR // TODO - move this logic directly into CartAR

View File

@ -34,8 +34,8 @@ class DispatchResult;
#endif #endif
#include "bspf.hxx" #include "bspf.hxx"
#include "Device.hxx"
#include "Serializable.hxx" #include "Serializable.hxx"
#include "CartDebug.hxx"
/** /**
The 6502 is an 8-bit microprocessor that has a 64K addressing space. The 6502 is an 8-bit microprocessor that has a 64K addressing space.
@ -270,7 +270,7 @@ class M6502 : public Serializable
@return The byte at the specified address @return The byte at the specified address
*/ */
uInt8 peek(uInt16 address, CartDebug::DisasmFlags flags); uInt8 peek(uInt16 address, Device::AccessFlags flags);
/** /**
Change the byte at the specified address to the given value and Change the byte at the specified address to the given value and
@ -279,7 +279,7 @@ class M6502 : public Serializable
@param address The address where the value should be stored @param address The address where the value should be stored
@param value The value to be stored at the address @param value The value to be stored at the address
*/ */
void poke(uInt16 address, uInt8 value, CartDebug::DisasmFlags flags = CartDebug::NONE); void poke(uInt16 address, uInt8 value, Device::AccessFlags flags = Device::NONE);
/** /**
Get the 8-bit value of the Processor Status register. Get the 8-bit value of the Processor Status register.

View File

@ -21,9 +21,6 @@
#include "Settings.hxx" #include "Settings.hxx"
#include "Switches.hxx" #include "Switches.hxx"
#include "System.hxx" #include "System.hxx"
#ifdef DEBUGGER_SUPPORT
#include "CartDebug.hxx"
#endif
#include "M6532.hxx" #include "M6532.hxx"
@ -460,14 +457,14 @@ uInt32 M6532::timerClocks() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::createAccessBases() void M6532::createAccessBases()
{ {
myRAMAccessBase.fill(CartDebug::NONE); myRAMAccessBase.fill(Device::NONE);
myStackAccessBase.fill(CartDebug::NONE); myStackAccessBase.fill(Device::NONE);
myIOAccessBase.fill(CartDebug::NONE); myIOAccessBase.fill(Device::NONE);
myZPAccessDelay.fill(ZP_DELAY); myZPAccessDelay.fill(ZP_DELAY);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmFlags M6532::getAccessFlags(uInt16 address) const Device::AccessFlags M6532::getAccessFlags(uInt16 address) const
{ {
if (address & IO_BIT) if (address & IO_BIT)
return myIOAccessBase[address & IO_MASK]; return myIOAccessBase[address & IO_MASK];
@ -478,10 +475,10 @@ CartDebug::DisasmFlags M6532::getAccessFlags(uInt16 address) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) void M6532::setAccessFlags(uInt16 address, Device::AccessFlags flags)
{ {
// ignore none flag // ignore none flag
if (flags != CartDebug::NONE) { if (flags != Device::NONE) {
if (address & IO_BIT) if (address & IO_BIT)
myIOAccessBase[address & IO_MASK] |= flags; myIOAccessBase[address & IO_MASK] |= flags;
else { else {

View File

@ -147,18 +147,18 @@ class M6532 : public Device
void createAccessBases(); void createAccessBases();
/** /**
Query the given address type for the associated disassembly flags. Query the given address type for the associated access flags.
@param address The address to query @param address The address to query
*/ */
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override; Device::AccessFlags getAccessFlags(uInt16 address) const override;
/** /**
Change the given address to use the given disassembly flags. Change the given address to use the given access flags.
@param address The address to modify @param address The address to modify
@param flags A bitfield of DisasmType directives for the given address @param flags A bitfield of AccessType directives for the given address
*/ */
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override; void setAccessFlags(uInt16 address, Device::AccessFlags flags) override;
#endif // DEBUGGER_SUPPORT #endif // DEBUGGER_SUPPORT
private: private:
@ -225,9 +225,9 @@ class M6532 : public Device
// The arrays containing information about every byte of RIOT // The arrays containing information about every byte of RIOT
// indicating whether and how (RW) it is used. // indicating whether and how (RW) it is used.
std::array<uInt16, RAM_SIZE> myRAMAccessBase; std::array<Device::AccessFlags, RAM_SIZE> myRAMAccessBase;
std::array<uInt16, STACK_SIZE> myStackAccessBase; std::array<Device::AccessFlags, STACK_SIZE> myStackAccessBase;
std::array<uInt16, IO_SIZE> myIOAccessBase; std::array<Device::AccessFlags, IO_SIZE> myIOAccessBase;
// The array used to skip the first ZP access tracking // The array used to skip the first ZP access tracking
std::array<uInt8, RAM_SIZE> myZPAccessDelay; std::array<uInt8, RAM_SIZE> myZPAccessDelay;
#endif // DEBUGGER_SUPPORT #endif // DEBUGGER_SUPPORT

View File

@ -99,7 +99,7 @@ void System::clearDirtyPages()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 System::peek(uInt16 addr, CartDebug::DisasmFlags flags) uInt8 System::peek(uInt16 addr, Device::AccessFlags flags)
{ {
const PageAccess& access = getPageAccess(addr); const PageAccess& access = getPageAccess(addr);
@ -127,7 +127,7 @@ uInt8 System::peek(uInt16 addr, CartDebug::DisasmFlags flags)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::poke(uInt16 addr, uInt8 value, CartDebug::DisasmFlags flags) void System::poke(uInt16 addr, uInt8 value, Device::AccessFlags flags)
{ {
uInt16 page = (addr & ADDRESS_MASK) >> PAGE_SHIFT; uInt16 page = (addr & ADDRESS_MASK) >> PAGE_SHIFT;
const PageAccess& access = myPageAccessTable[page]; const PageAccess& access = myPageAccessTable[page];
@ -160,7 +160,7 @@ void System::poke(uInt16 addr, uInt8 value, CartDebug::DisasmFlags flags)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmFlags System::getAccessFlags(uInt16 addr) const Device::AccessFlags System::getAccessFlags(uInt16 addr) const
{ {
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
const PageAccess& access = getPageAccess(addr); const PageAccess& access = getPageAccess(addr);
@ -175,7 +175,7 @@ CartDebug::DisasmFlags System::getAccessFlags(uInt16 addr) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::setAccessFlags(uInt16 addr, CartDebug::DisasmFlags flags) void System::setAccessFlags(uInt16 addr, Device::AccessFlags flags)
{ {
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
const PageAccess& access = getPageAccess(addr); const PageAccess& access = getPageAccess(addr);

View File

@ -29,7 +29,6 @@ class NullDevice;
#include "NullDev.hxx" #include "NullDev.hxx"
#include "Random.hxx" #include "Random.hxx"
#include "Serializable.hxx" #include "Serializable.hxx"
#include "CartDebug.hxx"
/** /**
This class represents a system consisting of a 6502 microprocessor This class represents a system consisting of a 6502 microprocessor
@ -203,7 +202,7 @@ class System : public Serializable
@return The byte at the specified address @return The byte at the specified address
*/ */
uInt8 peek(uInt16 address, CartDebug::DisasmFlags flags = CartDebug::NONE); uInt8 peek(uInt16 address, Device::AccessFlags flags = Device::NONE);
/** /**
Change the byte at the specified address to the given value. Change the byte at the specified address to the given value.
@ -218,7 +217,7 @@ class System : public Serializable
@param address The address where the value should be stored @param address The address where the value should be stored
@param value The value to be stored at the address @param value The value to be stored at the address
*/ */
void poke(uInt16 address, uInt8 value, CartDebug::DisasmFlags flags = CartDebug::NONE); void poke(uInt16 address, uInt8 value, Device::AccessFlags flags = Device::NONE);
/** /**
Lock/unlock the data bus. When the bus is locked, peek() and Lock/unlock the data bus. When the bus is locked, peek() and
@ -233,12 +232,12 @@ class System : public Serializable
void unlockDataBus() { myDataBusLocked = false; } void unlockDataBus() { myDataBusLocked = false; }
/** /**
Access and modify the disassembly type flags for the given Access and modify the access type flags for the given
address. Note that while any flag can be used, the disassembly address. Note that while any flag can be used, the disassembly
only really acts on CODE/GFX/PGFX/DATA/ROW. only really acts on CODE/GFX/PGFX/COL/PCOL/BCOL/DATA/ROW.
*/ */
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const; Device::AccessFlags getAccessFlags(uInt16 address) const;
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags); void setAccessFlags(uInt16 address, Device::AccessFlags flags);
public: public:
/** /**
@ -278,7 +277,7 @@ class System : public Serializable
conclusively determine if a section of address space is CODE, even conclusively determine if a section of address space is CODE, even
if the disassembler failed to mark it as such. if the disassembler failed to mark it as such.
*/ */
CartDebug::DisasmFlags* codeAccessBase{nullptr}; Device::AccessFlags* codeAccessBase{nullptr};
/** /**
Pointer to the device associated with this page or to the system's Pointer to the device associated with this page or to the system's

View File

@ -25,10 +25,6 @@
#include "AudioQueue.hxx" #include "AudioQueue.hxx"
#include "DispatchResult.hxx" #include "DispatchResult.hxx"
#ifdef DEBUGGER_SUPPORT
#include "CartDebug.hxx"
#endif
enum CollisionMask: uInt32 { enum CollisionMask: uInt32 {
player0 = 0b0111110000000000, player0 = 0b0111110000000000,
player1 = 0b0100001111000000, player1 = 0b0100001111000000,
@ -575,7 +571,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::BCOL); mySystem->setAccessFlags(dataAddr, Device::BCOL);
#endif #endif
break; break;
} }
@ -590,7 +586,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::COL); mySystem->setAccessFlags(dataAddr, Device::COL);
#endif #endif
break; break;
} }
@ -605,7 +601,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::COL); mySystem->setAccessFlags(dataAddr, Device::COL);
#endif #endif
break; break;
} }
@ -634,7 +630,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::PCOL); mySystem->setAccessFlags(dataAddr, Device::PCOL);
#endif #endif
break; break;
} }
@ -645,7 +641,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::PGFX); mySystem->setAccessFlags(dataAddr, Device::PGFX);
#endif #endif
break; break;
} }
@ -656,7 +652,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::PGFX); mySystem->setAccessFlags(dataAddr, Device::PGFX);
#endif #endif
break; break;
} }
@ -667,7 +663,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::PGFX); mySystem->setAccessFlags(dataAddr, Device::PGFX);
#endif #endif
break; break;
} }
@ -735,7 +731,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::GFX); mySystem->setAccessFlags(dataAddr, Device::GFX);
#endif #endif
break; break;
} }
@ -748,7 +744,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke();
if(dataAddr) if(dataAddr)
mySystem->setAccessFlags(dataAddr, CartDebug::GFX); mySystem->setAccessFlags(dataAddr, Device::GFX);
#endif #endif
break; break;
} }
@ -1914,22 +1910,22 @@ void TIA::toggleCollBLPF()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::createAccessBase() void TIA::createAccessBase()
{ {
myAccessBase.fill(CartDebug::NONE); myAccessBase.fill(Device::NONE);
myAccessDelay.fill(TIA_DELAY); myAccessDelay.fill(TIA_DELAY);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmFlags TIA::getAccessFlags(uInt16 address) const Device::AccessFlags TIA::getAccessFlags(uInt16 address) const
{ {
return myAccessBase[address & TIA_MASK]; return myAccessBase[address & TIA_MASK];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) void TIA::setAccessFlags(uInt16 address, Device::AccessFlags flags)
{ {
// ignore none flag // ignore none flag
if (flags != CartDebug::NONE) { if (flags != Device::NONE) {
if (flags == CartDebug::WRITE) { if (flags == Device::WRITE) {
// the first two write accesses are assumed as initialization // the first two write accesses are assumed as initialization
if (myAccessDelay[address & TIA_MASK]) if (myAccessDelay[address & TIA_MASK])
myAccessDelay[address & TIA_MASK]--; myAccessDelay[address & TIA_MASK]--;

View File

@ -681,18 +681,18 @@ class TIA : public Device
void createAccessBase(); void createAccessBase();
/** /**
* Query the given address type for the associated disassembly flags. * Query the given address type for the associated access flags.
* *
* @param address The address to query * @param address The address to query
*/ */
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override; Device::AccessFlags getAccessFlags(uInt16 address) const override;
/** /**
* Change the given address to use the given disassembly flags. * Change the given address to use the given access flags.
* *
* @param address The address to modify * @param address The address to modify
* @param flags A bitfield of DisasmType directives for the given address * @param flags A bitfield of AccessType directives for the given address
*/ */
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override; void setAccessFlags(uInt16 address, Device::AccessFlags flags) override;
#endif // DEBUGGER_SUPPORT #endif // DEBUGGER_SUPPORT
private: private:
@ -901,7 +901,7 @@ class TIA : public Device
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
// The arrays containing information about every byte of TIA // The arrays containing information about every byte of TIA
// indicating whether and how (RW) it is used. // indicating whether and how (RW) it is used.
std::array<uInt16, TIA_SIZE> myAccessBase; std::array<Device::AccessFlags, TIA_SIZE> myAccessBase;
// The array used to skip the first two TIA access trackings // The array used to skip the first two TIA access trackings
std::array<uInt8, TIA_SIZE> myAccessDelay; std::array<uInt8, TIA_SIZE> myAccessDelay;

View File

@ -39,7 +39,6 @@
#include "M6502.hxx" #include "M6502.hxx"
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx" #include "Debugger.hxx"
#include "CartDebug.hxx"
#include "DebuggerDialog.hxx" #include "DebuggerDialog.hxx"
#endif #endif
#include "DeveloperDialog.hxx" #include "DeveloperDialog.hxx"