From d61c68c05a1f5d6fea95e7328229f1f87e310854 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 27 Mar 2020 09:03:06 +0100 Subject: [PATCH] refactored access flags used for disassembly --- src/debugger/CartDebug.cxx | 223 +++++++++++++------------- src/debugger/CartDebug.hxx | 50 ++---- src/debugger/CpuDebug.cxx | 1 - src/debugger/Debugger.cxx | 14 +- src/debugger/Debugger.hxx | 16 +- src/debugger/DebuggerParser.cxx | 14 +- src/debugger/DiStella.cxx | 241 +++++++++++++++-------------- src/debugger/DiStella.hxx | 5 +- src/debugger/gui/RomListWidget.cxx | 10 +- src/emucore/Cart.cxx | 5 +- src/emucore/Cart.hxx | 4 +- src/emucore/Cart4A50.cxx | 4 +- src/emucore/Cart4A50.hxx | 10 +- src/emucore/CartAR.cxx | 4 +- src/emucore/CartAR.hxx | 10 +- src/emucore/Device.hxx | 39 ++++- src/emucore/M6502.cxx | 22 +-- src/emucore/M6502.hxx | 6 +- src/emucore/M6532.cxx | 15 +- src/emucore/M6532.hxx | 16 +- src/emucore/System.cxx | 8 +- src/emucore/System.hxx | 15 +- src/emucore/tia/TIA.cxx | 32 ++-- src/emucore/tia/TIA.hxx | 12 +- src/gui/DeveloperDialog.cxx | 1 - 25 files changed, 385 insertions(+), 392 deletions(-) diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 0f9a75a27..7446efad4 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -32,6 +32,7 @@ #include "CartRamWidget.hxx" #include "RomWidget.hxx" #include "Base.hxx" +#include "Device.hxx" #include "exception/EmulationWarning.hxx" 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 myBankInfo[myConsole.cartridge().startBank()].addressList.push_front( myDebugger.dpeek(0xfffc)); - addLabel("Start", myDebugger.dpeek(0xfffc, DATA)); + addLabel("Start", myDebugger.dpeek(0xfffc, Device::DATA)); // Add system equates 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 uInt16 address = tag.address & 0xFFF; - // Exclude 'ROW'; they don't have a valid address - if(tag.type != CartDebug::ROW) + // Exclude 'Device::ROW'; they don't have a valid address + if(tag.type != Device::ROW) { // Create a mapping from addresses to line numbers myAddrToLineList.emplace(address, i); @@ -358,7 +359,7 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const if((tag.address & 0xfff) >= start) { if(begin == list_size) begin = end; - if(tag.type != CartDebug::ROW) + if(tag.type != Device::ROW) length = std::max(length, uInt32(tag.disasm.length())); --lines; @@ -369,7 +370,7 @@ string CartDebug::disassemble(uInt16 start, uInt16 lines) const for(uInt32 i = begin; i < end; ++i) { const CartDebug::DisassemblyTag& tag = myDisassembly.list[i]; - if(tag.type == CartDebug::NONE) + if(tag.type == Device::NONE) continue; else if(tag.address) 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) { if(end < start || start == 0 || end == 0) @@ -885,46 +886,46 @@ string CartDebug::loadConfigFile() // TODO - figure out what to do with this buf >> hex >> start; } - else if(BSPF::startsWithIgnoreCase(directive, "CODE")) + else if(BSPF::startsWithIgnoreCase(directive, "Device::CODE")) { 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; - 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; - 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; - 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; - 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; - 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; - 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 >> end; - addDirective(CartDebug::ROW, start, end, currentbank); + addDirective(Device::ROW, start, end, currentbank); } } } @@ -1053,7 +1054,7 @@ string CartDebug::saveDisassembly() if (myReserved.breakFound) addLabel("Break", myDebugger.dpeek(0xfffe)); - buf << " SEG CODE\n" + buf << " SEG Device::CODE\n" << " ORG $" << Base::HEX4 << info.offset << "\n\n"; // Format in 'distella' style @@ -1068,19 +1069,19 @@ string CartDebug::saveDisassembly() 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); if (tag.disasm.find("WSYNC") != std::string::npos) buf << "\n;---------------------------------------"; break; } - case CartDebug::ROW: + case Device::ROW: { buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 8*4-1) << "; $" << Base::HEX4 << tag.address << " (*)"; break; } - case CartDebug::GFX: + case Device::GFX: { buf << ".byte " << (settings.gfxFormat == Base::Fmt::_2 ? "%" : "$") << tag.bytes << " ; |"; @@ -1089,7 +1090,7 @@ string CartDebug::saveDisassembly() buf << ALIGN(13) << "|" << "$" << Base::HEX4 << tag.address << " (G)"; break; } - case CartDebug::PGFX: + case Device::PGFX: { buf << ".byte " << (settings.gfxFormat == Base::Fmt::_2 ? "%" : "$") << tag.bytes << " ; |"; @@ -1098,24 +1099,24 @@ string CartDebug::saveDisassembly() buf << ALIGN(13) << "|" << "$" << Base::HEX4 << tag.address << " (P)"; break; } - case CartDebug::COL: + case Device::COL: buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (Px)"; break; - case CartDebug::PCOL: + case Device::PCOL: buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (PF)"; break; - case CartDebug::BCOL: + case Device::BCOL: buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 12) << "; $" << Base::HEX4 << tag.address << " (BK)"; break; - case CartDebug::DATA: + case Device::DATA: { buf << ".byte " << ALIGN(32) << tag.disasm.substr(6, 8 * 4 - 1) << "; $" << Base::HEX4 << tag.address << " (D)"; break; } - case CartDebug::NONE: + case Device::NONE: default: { break; @@ -1133,10 +1134,10 @@ string CartDebug::saveDisassembly() << "; ROM properties name : " << myConsole.properties().get(PropType::Cart_Name) << "\n" << "; ROM properties MD5 : " << myConsole.properties().get(PropType::Cart_MD5) << "\n" << "; Bankswitch type : " << myConsole.cartridge().about() << "\n;\n" - << "; Legend: * = CODE not yet run (tentative code)\n" - << "; D = DATA directive (referenced in some way)\n" - << "; G = GFX directive, shown as '#' (stored in player, missile, ball)\n" - << "; P = PGFX directive, shown as '*' (stored in playfield)\n" + << "; Legend: * = Device::CODE not yet run (tentative code)\n" + << "; D = Device::DATA directive (referenced in some way)\n" + << "; G = Device::GFX directive, shown as '#' (stored in player, missile, ball)\n" + << "; P = Device::PGFX directive, shown as '*' (stored in playfield)\n" << "; i = indexed accessed only\n" << "; c = used by code executed in RAM\n" << "; s = used by stack\n" @@ -1166,9 +1167,9 @@ string CartDebug::saveDisassembly() bool addrUsed = false; 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) - 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) addrUsed = addrUsed || myReserved.IOReadWrite[addr]; @@ -1183,7 +1184,7 @@ string CartDebug::saveDisassembly() if(myReserved.TIARead[addr] && ourTIAMnemonicR[addr]) out << ALIGN(16) << ourTIAMnemonicR[addr] << "= $" << 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] << "= $" << Base::HEX2 << right << addr << " ; (Ri)\n"; out << "\n"; @@ -1193,7 +1194,7 @@ string CartDebug::saveDisassembly() if(myReserved.TIAWrite[addr] && ourTIAMnemonicW[addr]) out << ALIGN(16) << ourTIAMnemonicW[addr] << "= $" << 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] << "= $" << Base::HEX2 << right << addr << " ; (Wi)\n"; out << "\n"; @@ -1208,8 +1209,8 @@ string CartDebug::saveDisassembly() addrUsed = false; for(uInt16 addr = 0x80; addr <= 0xFF; ++addr) addrUsed = addrUsed || myReserved.ZPRAM[addr-0x80] - || (mySystem.getAccessFlags(addr) & (DATA | WRITE)) - || (mySystem.getAccessFlags(addr|0x100) & (DATA | WRITE)); + || (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE)) + || (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE)); if(addrUsed) { bool addLine = false; @@ -1218,9 +1219,9 @@ string CartDebug::saveDisassembly() << ";-----------------------------------------------------------\n\n"; for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) { - bool ramUsed = (mySystem.getAccessFlags(addr) & (DATA | WRITE)); - bool codeUsed = (mySystem.getAccessFlags(addr) & CODE); - bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (DATA | WRITE)); + bool ramUsed = (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE)); + bool codeUsed = (mySystem.getAccessFlags(addr) & Device::CODE); + bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE)); if (myReserved.ZPRAM[addr - 0x80] && myUserLabels.find(addr) == myUserLabels.end()) { @@ -1315,10 +1316,10 @@ string CartDebug::listConfig(int bank) buf << "[" << b << "]" << endl; for(const auto& i: info.directiveList) { - if(i.type != CartDebug::NONE) + if(i.type != Device::NONE) { buf << "(*) "; - disasmTypeAsString(buf, i.type); + AccessTypeAsString(buf, i.type); 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 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) { - DisasmType currType = disasmTypeAbsolute(mySystem.getAccessFlags(addr)); + Device::AccessType currType = accessTypeAbsolute(mySystem.getAccessFlags(addr)); // Have we changed to a new type? if(currType != prevType) { - disasmTypeAsString(buf, prevType); + AccessTypeAsString(buf, prevType); buf << " " << Base::HEX4 << prev << " " << Base::HEX4 << (addr-1) << endl; 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 if(prev != addr) { - disasmTypeAsString(buf, prevType); + AccessTypeAsString(buf, prevType); 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)) { @@ -1452,86 +1453,86 @@ void CartDebug::addressTypeAsString(ostream& buf, uInt16 addr) const label = myDisLabels[addr & 0xFFF]; 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) << " "; - disasmTypeAsString(buf, debugger); + AccessTypeAsString(buf, debugger); buf << endl << "tentative: " << Base::toString(label, Base::Fmt::_2_8) << " "; - disasmTypeAsString(buf, label); + AccessTypeAsString(buf, label); buf << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartDebug::DisasmType CartDebug::disasmTypeAbsolute(CartDebug::DisasmFlags flags) const +Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) const { - if(flags & CartDebug::CODE) - return CartDebug::CODE; - else if(flags & CartDebug::TCODE) - return CartDebug::CODE; // TODO - should this be separate?? - else if(flags & CartDebug::GFX) - return CartDebug::GFX; - else if(flags & CartDebug::PGFX) - return CartDebug::PGFX; - else if(flags & CartDebug::COL) - return CartDebug::COL; - else if(flags & CartDebug::PCOL) - return CartDebug::PCOL; - else if(flags & CartDebug::BCOL) - return CartDebug::BCOL; - else if(flags & CartDebug::DATA) - return CartDebug::DATA; - else if(flags & CartDebug::ROW) - return CartDebug::ROW; + if(flags & Device::CODE) + return Device::CODE; + else if(flags & Device::TCODE) + return Device::CODE; // TODO - should this be separate?? + else if(flags & Device::GFX) + return Device::GFX; + else if(flags & Device::PGFX) + return Device::PGFX; + else if(flags & Device::COL) + return Device::COL; + else if(flags & Device::PCOL) + return Device::PCOL; + else if(flags & Device::BCOL) + return Device::BCOL; + else if(flags & Device::DATA) + return Device::DATA; + else if(flags & Device::ROW) + return Device::ROW; 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) { - case CartDebug::CODE: buf << "CODE"; break; - case CartDebug::TCODE: buf << "TCODE"; break; - case CartDebug::GFX: buf << "GFX"; break; - case CartDebug::PGFX: buf << "PGFX"; break; - case CartDebug::COL: buf << "COL"; break; - case CartDebug::PCOL: buf << "PCOL"; break; - case CartDebug::BCOL: buf << "BCOL"; break; - case CartDebug::DATA: buf << "DATA"; break; - case CartDebug::ROW: buf << "ROW"; break; - case CartDebug::REFERENCED: - case CartDebug::VALID_ENTRY: - case CartDebug::NONE: break; + case Device::CODE: buf << "Device::CODE"; break; + case Device::TCODE: buf << "Device::TCODE"; break; + case Device::GFX: buf << "Device::GFX"; break; + case Device::PGFX: buf << "Device::PGFX"; break; + case Device::COL: buf << "Device::COL"; break; + case Device::PCOL: buf << "Device::PCOL"; break; + case Device::BCOL: buf << "Device::BCOL"; break; + case Device::DATA: buf << "Device::DATA"; break; + case Device::ROW: buf << "Device::ROW"; break; + case Device::REFERENCED: + case Device::VALID_ENTRY: + 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 & CartDebug::CODE) - buf << "CODE "; - if(flags & CartDebug::TCODE) - buf << "TCODE "; - if(flags & CartDebug::GFX) - buf << "GFX "; - if(flags & CartDebug::PGFX) - buf << "PGFX "; - if(flags & CartDebug::COL) - buf << "COL "; - if(flags & CartDebug::PCOL) - buf << "PCOL "; - if(flags & CartDebug::BCOL) - buf << "BCOL "; - if(flags & CartDebug::DATA) - buf << "DATA "; - if(flags & CartDebug::ROW) - buf << "ROW "; - if(flags & CartDebug::REFERENCED) - buf << "*REFERENCED "; - if(flags & CartDebug::VALID_ENTRY) - buf << "*VALID_ENTRY "; + if(flags & Device::CODE) + buf << "Device::CODE "; + if(flags & Device::TCODE) + buf << "Device::TCODE "; + if(flags & Device::GFX) + buf << "Device::GFX "; + if(flags & Device::PGFX) + buf << "Device::PGFX "; + if(flags & Device::COL) + buf << "Device::COL "; + if(flags & Device::PCOL) + buf << "Device::PCOL "; + if(flags & Device::BCOL) + buf << "Device::BCOL "; + if(flags & Device::DATA) + buf << "Device::DATA "; + if(flags & Device::ROW) + buf << "Device::ROW "; + if(flags & Device::REFERENCED) + buf << "*Device::REFERENCED "; + if(flags & Device::VALID_ENTRY) + buf << "*Device::VALID_ENTRY "; } else buf << "no flags set"; diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 17f67aa7a..e52389974 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -31,6 +31,7 @@ using CartMethod = int (CartDebug::*)(); #include "bspf.hxx" #include "DebuggerSystem.hxx" +#include "Device.hxx" class CartState : public DebuggerState { @@ -47,35 +48,8 @@ class CartDebug : public DebuggerSystem friend class DiStella; 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 { - DisasmType type{NONE}; + Device::AccessType type{Device::NONE}; uInt16 address{0}; string label; string disasm; @@ -175,7 +149,7 @@ class CartDebug : public DebuggerSystem @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); // 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; - // Convert given address to corresponding disassembly type and append to buf - void addressTypeAsString(ostream& buf, uInt16 addr) const; + // Convert given address to corresponding access type and append to buf + void accessTypeAsString(ostream& buf, uInt16 addr) const; private: using AddrToLabel = std::map; @@ -271,7 +245,7 @@ class CartDebug : public DebuggerSystem using AddrTypeArray = std::array; struct DirectiveTag { - DisasmType type{NONE}; + Device::AccessType type{Device::NONE}; uInt16 start{0}; uInt16 end{0}; }; @@ -309,15 +283,15 @@ class CartDebug : public DebuggerSystem // based on its disassembly void getBankDirectives(ostream& buf, BankInfo& info) const; - // Get disassembly enum type from 'flags', taking precendence into account - DisasmType disasmTypeAbsolute(CartDebug::DisasmFlags flags) const; + // Get access enum type from 'flags', taking precendence into account + Device::AccessType accessTypeAbsolute(Device::AccessFlags flags) const; - // Convert disassembly enum type to corresponding string and append to buf - void disasmTypeAsString(ostream& buf, DisasmType type) const; + // Convert access enum type to corresponding string and append to buf + 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 - void disasmTypeAsString(ostream& buf, CartDebug::DisasmFlags flags) const; + void AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const; private: const OSystem& myOSystem; diff --git a/src/debugger/CpuDebug.cxx b/src/debugger/CpuDebug.cxx index b7d26c3b5..f0bf9be12 100644 --- a/src/debugger/CpuDebug.cxx +++ b/src/debugger/CpuDebug.cxx @@ -20,7 +20,6 @@ #include "M6502.hxx" #include "System.hxx" #include "Debugger.hxx" -#include "CartDebug.hxx" #include "TIADebug.hxx" #include "CpuDebug.hxx" diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index e332d2586..cfb16a1e5 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -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)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -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); } @@ -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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -int Debugger::dpeekAsInt(int addr, CartDebug::DisasmFlags flags) +int Debugger::dpeekAsInt(int addr, Device::AccessFlags flags) { return mySystem.peek(uInt16(addr), flags) | (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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::setAccessFlags(uInt16 addr, CartDebug::DisasmFlags flags) +void Debugger::setAccessFlags(uInt16 addr, Device::AccessFlags flags) { mySystem.setAccessFlags(addr, flags); } diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 0cfbaf458..2b0ce6c1c 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -47,7 +47,7 @@ class RewindManager; #include "DialogContainer.hxx" #include "DebuggerDialog.hxx" #include "FrameBufferConstants.hxx" -#include "CartDebug.hxx" +#include "Cart.hxx" #include "bspf.hxx" /** @@ -244,18 +244,18 @@ class Debugger : public DialogContainer static Debugger& debugger() { return *myStaticDebugger; } /** Convenience methods to access peek/poke from System */ - uInt8 peek(uInt16 addr, CartDebug::DisasmFlags flags = CartDebug::NONE); - uInt16 dpeek(uInt16 addr, CartDebug::DisasmFlags flags = CartDebug::NONE); - void poke(uInt16 addr, uInt8 value, CartDebug::DisasmFlags flags = CartDebug::NONE); + uInt8 peek(uInt16 addr, Device::AccessFlags flags = Device::NONE); + uInt16 dpeek(uInt16 addr, Device::AccessFlags flags = Device::NONE); + void poke(uInt16 addr, uInt8 value, Device::AccessFlags flags = Device::NONE); /** Convenience method to access the 6502 from System */ M6502& m6502() const; /** These are now exposed so Expressions can use them. */ - int peekAsInt(int addr, CartDebug::DisasmFlags flags = CartDebug::NONE); - int dpeekAsInt(int addr, CartDebug::DisasmFlags flags = CartDebug::NONE); - CartDebug::DisasmFlags getAccessFlags(uInt16 addr) const; - void setAccessFlags(uInt16 addr, CartDebug::DisasmFlags flags); + int peekAsInt(int addr, Device::AccessFlags flags = Device::NONE); + int dpeekAsInt(int addr, Device::AccessFlags flags = Device::NONE); + Device::AccessFlags getAccessFlags(uInt16 addr) const; + void setAccessFlags(uInt16 addr, Device::AccessFlags flags); uInt32 getBaseAddress(uInt32 addr, bool read); diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index f3dfde946..176083b1f 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -924,7 +924,7 @@ void DebuggerParser::executeCode() } 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 $" << hex << args[0] << " $" << hex << args[1]; debugger.rom().invalidate(); @@ -965,7 +965,7 @@ void DebuggerParser::executeData() } 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 $" << hex << args[0] << " $" << hex << args[1]; debugger.rom().invalidate(); @@ -1282,7 +1282,7 @@ void DebuggerParser::executeGfx() } 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 $" << hex << args[0] << " $" << hex << args[1]; debugger.rom().invalidate(); @@ -1642,7 +1642,7 @@ void DebuggerParser::executePGfx() } 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 $" << hex << args[0] << " $" << hex << args[1]; debugger.rom().invalidate(); @@ -1734,7 +1734,7 @@ void DebuggerParser::executeRow() } 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 $" << hex << args[0] << " $" << hex << args[1]; debugger.rom().invalidate(); @@ -2194,7 +2194,7 @@ void DebuggerParser::executeType() for(uInt32 i = beg; i <= end; ++i) { commandResult << Base::HEX4 << i << ": "; - debugger.cartDebug().addressTypeAsString(commandResult, i); + debugger.cartDebug().accessTypeAsString(commandResult, i); commandResult << endl; } } @@ -3182,7 +3182,7 @@ std::array DebuggerParser::commands = { { { "type", - "Show disassembly type for address xx [yy]", + "Show access type for address xx [yy]", "Example: type f000, type f000 f010", true, false, diff --git a/src/debugger/DiStella.cxx b/src/debugger/DiStella.cxx index 235b2d9da..43d67749e 100644 --- a/src/debugger/DiStella.cxx +++ b/src/debugger/DiStella.cxx @@ -17,6 +17,7 @@ #include "bspf.hxx" #include "Debugger.hxx" +#include "Device.hxx" #include "DiStella.hxx" using Common::Base; @@ -73,7 +74,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list, // Add reserved line equates ostringstream reservedLabel; 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 // 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 @@ -110,7 +111,7 @@ void DiStella::disasm(uInt32 distart, int pass) int labelFound = 0; 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(""); @@ -124,58 +125,58 @@ void DiStella::disasm(uInt32 distart, int pass) if(myPC == myAppData.end) goto FIX_LAST; - if (checkBits(myPC, CartDebug::GFX | CartDebug::PGFX, - CartDebug::CODE)) + if (checkBits(myPC, Device::GFX | Device::PGFX, + Device::CODE)) { if (pass == 2) - mark(myPC + myOffset, CartDebug::VALID_ENTRY); + mark(myPC + myOffset, Device::VALID_ENTRY); if (pass == 3) outputGraphics(); ++myPC; - } else if (checkBits(myPC, CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL, - CartDebug::CODE | CartDebug::GFX | CartDebug::PGFX)) + } else if (checkBits(myPC, Device::COL | Device::PCOL | Device::BCOL, + Device::CODE | Device::GFX | Device::PGFX)) { if (pass == 2) - mark(myPC + myOffset, CartDebug::VALID_ENTRY); + mark(myPC + myOffset, Device::VALID_ENTRY); if (pass == 3) outputColors(); ++myPC; - } else if (checkBits(myPC, CartDebug::DATA, - CartDebug::CODE | CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL)) + } else if (checkBits(myPC, Device::DATA, + Device::CODE | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL)) { if (pass == 2) - mark(myPC + myOffset, CartDebug::VALID_ENTRY); + mark(myPC + myOffset, Device::VALID_ENTRY); if (pass == 3) - outputBytes(CartDebug::DATA); + outputBytes(Device::DATA); else ++myPC; - } else if (checkBits(myPC, CartDebug::ROW, - CartDebug::CODE | - CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL)) { + } else if (checkBits(myPC, Device::ROW, + Device::CODE | + Device::DATA | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL)) { FIX_LAST: if (pass == 2) - mark(myPC + myOffset, CartDebug::VALID_ENTRY); + mark(myPC + myOffset, Device::VALID_ENTRY); if (pass == 3) - outputBytes(CartDebug::ROW); + outputBytes(Device::ROW); else ++myPC; } else { // The following sections must be 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 << " ' ' "; - addEntry(CartDebug::NONE); - mark(myPC + myOffset, CartDebug::REFERENCED); // add label when switching + addEntry(Device::NONE); + mark(myPC + myOffset, Device::REFERENCED); // add label when switching } - mySegType = CartDebug::CODE; + mySegType = Device::CODE; /* version 2.1 bug fix */ if (pass == 2) - mark(myPC + myOffset, CartDebug::VALID_ENTRY); + mark(myPC + myOffset, Device::VALID_ENTRY); // get opcode opcode = Debugger::debugger().peek(myPC + myOffset); @@ -183,7 +184,7 @@ FIX_LAST: addrMode = ourLookup[opcode].addr_mode; if (pass == 3) { - if (checkBit(myPC, CartDebug::REFERENCED)) + if (checkBit(myPC, Device::REFERENCED)) myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; else myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; @@ -193,7 +194,7 @@ FIX_LAST: // detect labels inside instructions (e.g. BIT masks) labelFound = false; for (Uint8 i = 0; i < ourLookup[opcode].bytes - 1; i++) { - if (checkBit(myPC + i, CartDebug::REFERENCED)) { + if (checkBit(myPC + i, Device::REFERENCED)) { labelFound = true; break; } @@ -216,7 +217,7 @@ FIX_LAST: nextLine.str(""); 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; @@ -255,10 +256,10 @@ FIX_LAST: myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" << Base::HEX4 << myPC + myOffset << "'" << Base::HEX2 << int(opcode); - addEntry(CartDebug::DATA); + addEntry(Device::DATA); if (myPC == myAppData.end) { - if (checkBit(myPC, CartDebug::REFERENCED)) + if (checkBit(myPC, Device::REFERENCED)) myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; else myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; @@ -267,7 +268,7 @@ FIX_LAST: myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" << Base::HEX4 << myPC + myOffset << "'" << Base::HEX2 << int(opcode); - addEntry(CartDebug::DATA); + addEntry(Device::DATA); } } myPCEnd = myAppData.end + myOffset; @@ -284,7 +285,7 @@ FIX_LAST: /* Line information is already printed, but we can remove the Instruction (i.e. BMI) by simply clearing the buffer to print */ myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode); - addEntry(CartDebug::ROW); + addEntry(Device::ROW); nextLine.str(""); nextLineBytes.str(""); } @@ -312,7 +313,7 @@ FIX_LAST: case AddressingMode::ABSOLUTE: { ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - labelFound = mark(ad, CartDebug::REFERENCED); + labelFound = mark(ad, Device::REFERENCED); if (pass == 3) { if (ad < 0x100 && mySettings.fFlag) nextLine << ".w "; @@ -342,7 +343,7 @@ FIX_LAST: case AddressingMode::ZERO_PAGE: { d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - labelFound = mark(d1, CartDebug::REFERENCED); + labelFound = mark(d1, Device::REFERENCED); if (pass == 3) { nextLine << " "; LABEL_A12_LOW(int(d1)); @@ -364,13 +365,13 @@ FIX_LAST: case AddressingMode::ABSOLUTE_X: { ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - labelFound = mark(ad, CartDebug::REFERENCED); - if (pass == 2 && !checkBit(ad & myAppData.end, CartDebug::CODE)) { + labelFound = mark(ad, Device::REFERENCED); + if (pass == 2 && !checkBit(ad & myAppData.end, Device::CODE)) { // 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 // The processing is left here, however, in case future versions of // the code can somehow track access to CPU registers - mark(ad, CartDebug::ROW); + mark(ad, Device::ROW); } else if (pass == 3) { if (ad < 0x100 && mySettings.fFlag) nextLine << ".wx "; @@ -403,13 +404,13 @@ FIX_LAST: case AddressingMode::ABSOLUTE_Y: { ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - labelFound = mark(ad, CartDebug::REFERENCED); - if (pass == 2 && !checkBit(ad & myAppData.end, CartDebug::CODE)) { + labelFound = mark(ad, Device::REFERENCED); + if (pass == 2 && !checkBit(ad & myAppData.end, Device::CODE)) { // 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 // The processing is left here, however, in case future versions of // the code can somehow track access to CPU registers - mark(ad, CartDebug::ROW); + mark(ad, Device::ROW); } else if (pass == 3) { if (ad < 0x100 && mySettings.fFlag) nextLine << ".wy "; @@ -468,7 +469,7 @@ FIX_LAST: case AddressingMode::ZERO_PAGE_X: { d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - labelFound = mark(d1, CartDebug::REFERENCED); + labelFound = mark(d1, Device::REFERENCED); if (pass == 3) { nextLine << " "; LABEL_A12_LOW(d1); @@ -481,7 +482,7 @@ FIX_LAST: case AddressingMode::ZERO_PAGE_Y: { d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - labelFound = mark(d1, CartDebug::REFERENCED); + labelFound = mark(d1, Device::REFERENCED); if (pass == 3) { nextLine << " "; LABEL_A12_LOW(d1); @@ -499,7 +500,7 @@ FIX_LAST: d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; - labelFound = mark(ad, CartDebug::REFERENCED); + labelFound = mark(ad, Device::REFERENCED); if (pass == 3) { if (labelFound == 1) { nextLine << " "; @@ -515,13 +516,13 @@ FIX_LAST: case AddressingMode::ABS_INDIRECT: { ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - labelFound = mark(ad, CartDebug::REFERENCED); - if (pass == 2 && !checkBit(ad & myAppData.end, CartDebug::CODE)) { + labelFound = mark(ad, Device::REFERENCED); + if (pass == 2 && !checkBit(ad & myAppData.end, Device::CODE)) { // 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 // The processing is left here, however, in case future versions of // the code can somehow track access to CPU registers - mark(ad, CartDebug::ROW); + mark(ad, Device::ROW); } else if (pass == 3) { if (ad < 0x100 && mySettings.fFlag) nextLine << ".ind "; @@ -555,7 +556,7 @@ FIX_LAST: << ";" << std::dec << int(ourLookup[opcode].cycles) << (addrMode == AddressingMode::RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/3!" : "/3 " : " "); 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 && cycles > 0) { // output cycles for previous code block @@ -566,11 +567,11 @@ FIX_LAST: } myDisasmBuf << "'" << nextLineBytes.str(); - addEntry(CartDebug::CODE); + addEntry(Device::CODE); if (opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00) { myDisasmBuf << " ' ' "; - addEntry(CartDebug::NONE); - mySegType = CartDebug::NONE; // prevent extra lines if data follows + addEntry(Device::NONE); + mySegType = Device::NONE; // prevent extra lines if data follows } nextLine.str(""); @@ -619,17 +620,17 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses) // in the emulation core indicate that the CODE range has finished // Therefore, we stop at the first such address encountered for (uInt32 k = pcBeg; k <= myPCEnd; ++k) { - if (checkBits(k, CartDebug::CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL, - CartDebug::CODE)) { + if (checkBits(k, Device::Device::DATA | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL, + Device::CODE)) { //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: NOT USED: uInt16 flags = Debugger::debugger().getAccessFlags(k); myPCEnd = k - 1; 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()) { uInt16 addr = *it; - if (!checkBit(addr - myOffset, CartDebug::CODE)) { + if (!checkBit(addr - myOffset, Device::CODE)) { myAddressQueue.push(addr); ++it; } 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 // been referenced as CODE while (myAddressQueue.empty() && codeAccessPoint <= myAppData.end) { - if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & CartDebug::CODE) - && !(myLabels[codeAccessPoint & myAppData.end] & CartDebug::CODE)) { + if ((Debugger::debugger().getAccessFlags(codeAccessPoint + myOffset) & Device::CODE) + && !(myLabels[codeAccessPoint & myAppData.end] & Device::CODE)) { myAddressQueue.push(codeAccessPoint + myOffset); ++codeAccessPoint; break; @@ -674,17 +675,17 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses) for (int k = 0; k <= myAppData.end; k++) { // Let the emulation core know about tentative code - if (checkBit(k, CartDebug::CODE) && - !(Debugger::debugger().getAccessFlags(k + myOffset) & CartDebug::CODE) + if (checkBit(k, Device::CODE) && + !(Debugger::debugger().getAccessFlags(k + myOffset) & Device::CODE) && myOffset != 0) { - Debugger::debugger().setAccessFlags(k + myOffset, CartDebug::TCODE); + Debugger::debugger().setAccessFlags(k + myOffset, Device::TCODE); } // Must be ROW / unused bytes - if (!checkBit(k, CartDebug::CODE | CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL | - CartDebug::DATA)) - mark(k + myOffset, CartDebug::ROW); + if (!checkBit(k, Device::CODE | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL | + Device::DATA)) + mark(k + myOffset, Device::ROW); } } @@ -700,9 +701,9 @@ void DiStella::disasmFromAddress(uInt32 distart) while (myPC <= myAppData.end) { // abort when we reach non-code areas - if (checkBits(myPC, CartDebug::CartDebug::DATA | CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL, - CartDebug::CODE)) { + if (checkBits(myPC, Device::Device::DATA | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL, + Device::CODE)) { myPCEnd = (myPC - 1) + myOffset; return; } @@ -746,22 +747,22 @@ void DiStella::disasmFromAddress(uInt32 distart) switch (addrMode) { case AddressingMode::ABSOLUTE: ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, CartDebug::REFERENCED); + mark(ad, Device::REFERENCED); // handle JMP/JSR if (ourLookup[opcode].source == AccessMode::ADDR) { // 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) myAddressQueue.push((ad & myAppData.end) + myOffset); - mark(ad, CartDebug::CODE); + mark(ad, Device::CODE); } } else - mark(ad, CartDebug::DATA); + mark(ad, Device::DATA); break; case AddressingMode::ZERO_PAGE: d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - mark(d1, CartDebug::REFERENCED); + mark(d1, Device::REFERENCED); break; case AddressingMode::IMMEDIATE: @@ -770,12 +771,12 @@ void DiStella::disasmFromAddress(uInt32 distart) case AddressingMode::ABSOLUTE_X: ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, CartDebug::REFERENCED); + mark(ad, Device::REFERENCED); break; case AddressingMode::ABSOLUTE_Y: ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, CartDebug::REFERENCED); + mark(ad, Device::REFERENCED); break; case AddressingMode::INDIRECT_X: @@ -788,12 +789,12 @@ void DiStella::disasmFromAddress(uInt32 distart) case AddressingMode::ZERO_PAGE_X: d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - mark(d1, CartDebug::REFERENCED); + mark(d1, Device::REFERENCED); break; case AddressingMode::ZERO_PAGE_Y: d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; - mark(d1, CartDebug::REFERENCED); + mark(d1, Device::REFERENCED); break; case AddressingMode::RELATIVE: @@ -802,17 +803,17 @@ void DiStella::disasmFromAddress(uInt32 distart) // indexing into the labels array caused a crash d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; 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. - if (!checkBit(ad - myOffset, CartDebug::CODE, false)) { + if (!checkBit(ad - myOffset, Device::CODE, false)) { myAddressQueue.push(ad); - mark(ad, CartDebug::CODE); + mark(ad, Device::CODE); } break; case AddressingMode::ABS_INDIRECT: ad = Debugger::debugger().dpeek(myPC + myOffset); myPC += 2; - mark(ad, CartDebug::REFERENCED); + mark(ad, Device::REFERENCED); break; default: @@ -821,10 +822,10 @@ void DiStella::disasmFromAddress(uInt32 distart) // mark BRK vector if (opcode == 0x00) { - ad = Debugger::debugger().dpeek(0xfffe, CartDebug::DATA); + ad = Debugger::debugger().dpeek(0xfffe, Device::DATA); if (!myReserved.breakFound) { myAddressQueue.push(ad); - mark(ad, CartDebug::CODE); + mark(ad, Device::CODE); myReserved.breakFound = true; } } @@ -943,8 +944,8 @@ bool DiStella::checkBits(uInt16 address, uInt16 mask, uInt16 notMask, bool useDe /*bool DiStella::isType(uInt16 address) const { - return checkBits(address, CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL); + return checkBits(address, Device::GFX | Device::PGFX | + 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; @@ -993,7 +994,7 @@ void DiStella::addEntry(CartDebug::DisasmType type) if (tag.label == EmptyString) { if (myDisasmBuf.peek() != ' ') 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 tag.label = " " + Base::toString(tag.address, Base::Fmt::_16_4); tag.hllabel = false; @@ -1006,7 +1007,7 @@ void DiStella::addEntry(CartDebug::DisasmType type) // variable length labels, cycle counts, etc myDisasmBuf.seekg(11, std::ios::beg); switch (tag.type) { - case CartDebug::CODE: + case Device::CODE: getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.ccount, '\''); 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 // Since it is impossible to tell the difference, marking the address // 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) { tag.ccount += " *"; - Debugger::debugger().setAccessFlags(tag.address, CartDebug::TCODE); + Debugger::debugger().setAccessFlags(tag.address, Device::TCODE); } break; - case CartDebug::GFX: - case CartDebug::PGFX: + case Device::GFX: + case Device::PGFX: getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.bytes); break; - case CartDebug::COL: - case CartDebug::PCOL: - case CartDebug::BCOL: + case Device::COL: + case Device::PCOL: + case Device::BCOL: getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.bytes); break; - case CartDebug::DATA: + case Device::DATA: getline(myDisasmBuf, tag.disasm, '\''); getline(myDisasmBuf, tag.bytes); break; - case CartDebug::ROW: + case Device::ROW: getline(myDisasmBuf, tag.disasm); break; - case CartDebug::NONE: + case Device::NONE: default: // should never happen tag.disasm = " "; break; @@ -1061,18 +1062,18 @@ DONE_WITH_ADD: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DiStella::outputGraphics() { - bool isPGfx = checkBit(myPC, CartDebug::PGFX); + bool isPGfx = checkBit(myPC, Device::PGFX); const string& bitString = isPGfx ? "\x1f" : "\x1e"; uInt8 byte = Debugger::debugger().peek(myPC + myOffset); // 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 << " ' ' "; - 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 << "'"; else myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; @@ -1085,7 +1086,7 @@ void DiStella::outputGraphics() else 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); // 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 << " ' ' "; - addEntry(CartDebug::NONE); + addEntry(Device::NONE); } - mySegType = CartDebug::COL; + mySegType = Device::COL; // output label/address - if(checkBit(myPC, CartDebug::REFERENCED)) + if(checkBit(myPC, Device::REFERENCED)) myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; else myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; @@ -1147,29 +1148,29 @@ void DiStella::outputColors() // output address 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 myDisasmBuf << "'" << Base::HEX2 << int(byte); - addEntry(checkBit(myPC, CartDebug::COL) ? CartDebug::COL : - checkBit(myPC, CartDebug::PCOL) ? CartDebug::PCOL : CartDebug::BCOL); + addEntry(checkBit(myPC, Device::COL) ? Device::COL : + checkBit(myPC, Device::PCOL) ? Device::PCOL : Device::BCOL); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DiStella::outputBytes(CartDebug::DisasmType type) +void DiStella::outputBytes(Device::AccessType type) { bool isType = true; - bool referenced = checkBit(myPC, CartDebug::REFERENCED); + bool referenced = checkBit(myPC, Device::REFERENCED); bool lineEmpty = true; int numBytes = 0; // 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 << " ' ' "; - addEntry(CartDebug::NONE); + addEntry(Device::NONE); } - mySegType = CartDebug::DATA; + mySegType = Device::DATA; while (isType && myPC <= myAppData.end) { if (referenced) { @@ -1200,15 +1201,15 @@ void DiStella::outputBytes(CartDebug::DisasmType type) ++myPC; } isType = checkBits(myPC, type, - CartDebug::CODE | (type != CartDebug::DATA ? CartDebug::DATA : 0) | - CartDebug::GFX | CartDebug::PGFX | - CartDebug::COL | CartDebug::PCOL | CartDebug::BCOL); - referenced = checkBit(myPC, CartDebug::REFERENCED); + Device::CODE | (type != Device::DATA ? Device::DATA : 0) | + Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL); + referenced = checkBit(myPC, Device::REFERENCED); } if (!lineEmpty) addEntry(type); /*myDisasmBuf << " ' ' "; - addEntry(CartDebug::NONE);*/ + addEntry(Device::NONE);*/ } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/DiStella.hxx b/src/debugger/DiStella.hxx index 830835a02..bb1b54f5e 100644 --- a/src/debugger/DiStella.hxx +++ b/src/debugger/DiStella.hxx @@ -22,6 +22,7 @@ #include "Base.hxx" #include "CartDebug.hxx" +#include "Device.hxx" #include "bspf.hxx" /** @@ -75,7 +76,7 @@ class DiStella // Indicate that a new line of disassembly has been completed // In the original Distella code, this indicated a new line to be printed // 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 // Directives are basically the contents of a distella configuration file @@ -93,7 +94,7 @@ class DiStella //bool isType(uInt16 address) const; void outputGraphics(); void outputColors(); - void outputBytes(CartDebug::DisasmType type); + void outputBytes(Device::AccessType type); // Convenience methods to generate appropriate labels inline void labelA12High(stringstream& buf, uInt8 op, uInt16 addr, int labfound) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index fdc24fb71..b4af0daf7 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -511,10 +511,10 @@ void RomListWidget::drawWidget(bool hilite) // Bytes are only editable if they represent code, graphics, or accessible data // Otherwise, the disassembly should get all remaining space - if(dlist[pos].type & (CartDebug::CODE|CartDebug::GFX|CartDebug::PGFX| - CartDebug::COL|CartDebug::PCOL|CartDebug::BCOL|CartDebug::DATA)) + if(dlist[pos].type & (Device::CODE|Device::GFX|Device::PGFX| + Device::COL|Device::PCOL|Device::BCOL|Device::DATA)) { - if(dlist[pos].type == CartDebug::CODE) + if(dlist[pos].type == Device::CODE) { // Draw mnemonic s.drawString(_font, dlist[pos].disasm.substr(0, 7), xpos + _labelWidth, ypos, @@ -593,8 +593,8 @@ void RomListWidget::startEditMode() _editMode = true; switch(myDisasm->list[_selectedItem].type) { - case CartDebug::GFX: - case CartDebug::PGFX: + case Device::GFX: + case Device::PGFX: _base = DiStella::settings.gfxFormat; break; default: diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index cd40f886b..ec7cea379 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -20,7 +20,6 @@ #include "MD5.hxx" #ifdef DEBUGGER_SUPPORT #include "Debugger.hxx" - #include "CartDebug.hxx" #endif #include "Cart.hxx" @@ -117,8 +116,8 @@ void Cartridge::pokeRAM(uInt8& dest, uInt16 address, uInt8 value) void Cartridge::createCodeAccessBase(size_t size) { #ifdef DEBUGGER_SUPPORT - myCodeAccessBase = make_unique(size); - std::fill_n(myCodeAccessBase.get(), size, CartDebug::ROW); + myCodeAccessBase = make_unique(size); + std::fill_n(myCodeAccessBase.get(), size, Device::ROW); #else myCodeAccessBase = nullptr; #endif diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 5a34f1fc3..4b9cda533 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -30,7 +30,7 @@ class GuiObject; #ifdef DEBUGGER_SUPPORT #include "Font.hxx" #endif -#include "CartDebug.hxx" + /** 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 // whether it is used as code. - std::unique_ptr myCodeAccessBase; + std::unique_ptr myCodeAccessBase; // Contains address of illegal RAM write access or 0 uInt16 myRamWriteAccess{0}; diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index 9ac05b2b3..fd05804d4 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -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 { @@ -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 { diff --git a/src/emucore/Cart4A50.hxx b/src/emucore/Cart4A50.hxx index e1299431c..d55ec8d2f 100644 --- a/src/emucore/Cart4A50.hxx +++ b/src/emucore/Cart4A50.hxx @@ -154,18 +154,18 @@ class Cartridge4A50 : public Cartridge 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 */ - 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 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 diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index fc63d7954..42d12c0fd 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -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) + myImageOffset[(address & 0x0800) ? 1 : 0]]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeAR::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) +void CartridgeAR::setAccessFlags(uInt16 address, Device::AccessFlags flags) { myCodeAccessBase[(address & 0x07FF) + myImageOffset[(address & 0x0800) ? 1 : 0]] |= flags; diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index 888e5e6f9..877817c1b 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -160,18 +160,18 @@ class CartridgeAR : public Cartridge 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 */ - 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 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 bool bankConfiguration(uInt8 configuration); diff --git a/src/emucore/Device.hxx b/src/emucore/Device.hxx index f55312869..205de10ac 100644 --- a/src/emucore/Device.hxx +++ b/src/emucore/Device.hxx @@ -22,7 +22,6 @@ class System; #include "Console.hxx" #include "Serializable.hxx" -#include "CartDebug.hxx" #include "bspf.hxx" /** @@ -33,6 +32,34 @@ class System; */ 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: Device() = default; virtual ~Device() = default; @@ -99,19 +126,19 @@ class Device : public Serializable 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 */ - 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 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: /// Pointer to the system the device is installed in or the null pointer diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 49f8ff7e2..6f7392326 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -18,19 +18,19 @@ #ifdef DEBUGGER_SUPPORT #include "Debugger.hxx" #include "Expression.hxx" - #include "CartDebug.hxx" + #include "Device.hxx" #include "Base.hxx" - // Flags for disassembly types - #define DISASM_CODE CartDebug::CODE -// #define DISASM_GFX CartDebug::GFX -// #define DISASM_PGFX CartDebug::PGFX - #define DISASM_DATA CartDebug::DATA -// #define DISASM_ROW CartDebug::ROW - #define DISASM_WRITE CartDebug::WRITE + // Flags for access types + #define DISASM_CODE Device::CODE +// #define DISASM_GFX Device::GFX +// #define DISASM_PGFX Device::PGFX + #define DISASM_DATA Device::DATA +// #define DISASM_ROW Device::ROW + #define DISASM_WRITE Device::WRITE #define DISASM_NONE 0 #else - // Flags for disassembly types + // Flags for access types #define DISASM_CODE 0 // #define DISASM_GFX 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(); @@ -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 diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index 5c7bbbc01..6cb3ccc65 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -34,8 +34,8 @@ class DispatchResult; #endif #include "bspf.hxx" +#include "Device.hxx" #include "Serializable.hxx" -#include "CartDebug.hxx" /** 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 */ - 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 @@ -279,7 +279,7 @@ class M6502 : public Serializable @param address The address where the value should be stored @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. diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index b5276567b..645a4a332 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -21,9 +21,6 @@ #include "Settings.hxx" #include "Switches.hxx" #include "System.hxx" -#ifdef DEBUGGER_SUPPORT - #include "CartDebug.hxx" -#endif #include "M6532.hxx" @@ -460,14 +457,14 @@ uInt32 M6532::timerClocks() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void M6532::createAccessBases() { - myRAMAccessBase.fill(CartDebug::NONE); - myStackAccessBase.fill(CartDebug::NONE); - myIOAccessBase.fill(CartDebug::NONE); + myRAMAccessBase.fill(Device::NONE); + myStackAccessBase.fill(Device::NONE); + myIOAccessBase.fill(Device::NONE); myZPAccessDelay.fill(ZP_DELAY); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartDebug::DisasmFlags M6532::getAccessFlags(uInt16 address) const +Device::AccessFlags M6532::getAccessFlags(uInt16 address) const { if (address & IO_BIT) 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 - if (flags != CartDebug::NONE) { + if (flags != Device::NONE) { if (address & IO_BIT) myIOAccessBase[address & IO_MASK] |= flags; else { diff --git a/src/emucore/M6532.hxx b/src/emucore/M6532.hxx index 42fca9640..4f543b8a8 100644 --- a/src/emucore/M6532.hxx +++ b/src/emucore/M6532.hxx @@ -147,18 +147,18 @@ class M6532 : public Device 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 */ - 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 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 private: @@ -225,9 +225,9 @@ class M6532 : public Device // The arrays containing information about every byte of RIOT // indicating whether and how (RW) it is used. - std::array myRAMAccessBase; - std::array myStackAccessBase; - std::array myIOAccessBase; + std::array myRAMAccessBase; + std::array myStackAccessBase; + std::array myIOAccessBase; // The array used to skip the first ZP access tracking std::array myZPAccessDelay; #endif // DEBUGGER_SUPPORT diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index e2050ee1b..7bf3551ef 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -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); @@ -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; 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 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 const PageAccess& access = getPageAccess(addr); diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index 306f269e1..1a6dcff68 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -29,7 +29,6 @@ class NullDevice; #include "NullDev.hxx" #include "Random.hxx" #include "Serializable.hxx" -#include "CartDebug.hxx" /** 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 */ - 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. @@ -218,7 +217,7 @@ class System : public Serializable @param address The address where the value should be stored @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 @@ -233,12 +232,12 @@ class System : public Serializable 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 - 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; - void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags); + Device::AccessFlags getAccessFlags(uInt16 address) const; + void setAccessFlags(uInt16 address, Device::AccessFlags flags); public: /** @@ -278,7 +277,7 @@ class System : public Serializable conclusively determine if a section of address space is CODE, even 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 diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 10f71ec80..58eb8c8ea 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -25,10 +25,6 @@ #include "AudioQueue.hxx" #include "DispatchResult.hxx" -#ifdef DEBUGGER_SUPPORT - #include "CartDebug.hxx" -#endif - enum CollisionMask: uInt32 { player0 = 0b0111110000000000, player1 = 0b0100001111000000, @@ -575,7 +571,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::BCOL); + mySystem->setAccessFlags(dataAddr, Device::BCOL); #endif break; } @@ -590,7 +586,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::COL); + mySystem->setAccessFlags(dataAddr, Device::COL); #endif break; } @@ -605,7 +601,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::COL); + mySystem->setAccessFlags(dataAddr, Device::COL); #endif break; } @@ -634,7 +630,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::PCOL); + mySystem->setAccessFlags(dataAddr, Device::PCOL); #endif break; } @@ -645,7 +641,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::PGFX); + mySystem->setAccessFlags(dataAddr, Device::PGFX); #endif break; } @@ -656,7 +652,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::PGFX); + mySystem->setAccessFlags(dataAddr, Device::PGFX); #endif break; } @@ -667,7 +663,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::PGFX); + mySystem->setAccessFlags(dataAddr, Device::PGFX); #endif break; } @@ -735,7 +731,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::GFX); + mySystem->setAccessFlags(dataAddr, Device::GFX); #endif break; } @@ -748,7 +744,7 @@ bool TIA::poke(uInt16 address, uInt8 value) #ifdef DEBUGGER_SUPPORT uInt16 dataAddr = mySystem->m6502().lastDataAddressForPoke(); if(dataAddr) - mySystem->setAccessFlags(dataAddr, CartDebug::GFX); + mySystem->setAccessFlags(dataAddr, Device::GFX); #endif break; } @@ -1914,22 +1910,22 @@ void TIA::toggleCollBLPF() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::createAccessBase() { - myAccessBase.fill(CartDebug::NONE); + myAccessBase.fill(Device::NONE); myAccessDelay.fill(TIA_DELAY); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CartDebug::DisasmFlags TIA::getAccessFlags(uInt16 address) const +Device::AccessFlags TIA::getAccessFlags(uInt16 address) const { return myAccessBase[address & TIA_MASK]; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TIA::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) +void TIA::setAccessFlags(uInt16 address, Device::AccessFlags flags) { // ignore none flag - if (flags != CartDebug::NONE) { - if (flags == CartDebug::WRITE) { + if (flags != Device::NONE) { + if (flags == Device::WRITE) { // the first two write accesses are assumed as initialization if (myAccessDelay[address & TIA_MASK]) myAccessDelay[address & TIA_MASK]--; diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 842bc395f..30c3d04f5 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -681,18 +681,18 @@ class TIA : public Device 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 */ - 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 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 private: @@ -901,7 +901,7 @@ class TIA : public Device #ifdef DEBUGGER_SUPPORT // The arrays containing information about every byte of TIA // indicating whether and how (RW) it is used. - std::array myAccessBase; + std::array myAccessBase; // The array used to skip the first two TIA access trackings std::array myAccessDelay; diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 4d6924f11..1d3d59aa5 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -39,7 +39,6 @@ #include "M6502.hxx" #ifdef DEBUGGER_SUPPORT #include "Debugger.hxx" - #include "CartDebug.hxx" #include "DebuggerDialog.hxx" #endif #include "DeveloperDialog.hxx"