use defined type for disassembly flags

This commit is contained in:
thrust26 2020-03-26 23:26:18 +01:00
parent 474ba22e5e
commit 3fa6ede03c
19 changed files with 57 additions and 51 deletions

View File

@ -84,7 +84,6 @@ using ByteArray = std::vector<uInt8>;
using ShortArray = std::vector<uInt16>;
using StringList = std::vector<std::string>;
using ByteBuffer = std::unique_ptr<uInt8[]>; // NOLINT
using WordBuffer = std::unique_ptr<uInt16[]>; // NOLINT
// We use KB a lot; let's make a literal for it
constexpr uInt32 operator "" _KB(unsigned long long size)

View File

@ -1461,7 +1461,7 @@ void CartDebug::addressTypeAsString(ostream& buf, uInt16 addr) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::DisasmType CartDebug::disasmTypeAbsolute(uInt16 flags) const
CartDebug::DisasmType CartDebug::disasmTypeAbsolute(CartDebug::DisasmFlags flags) const
{
if(flags & CartDebug::CODE)
return CartDebug::CODE;
@ -1506,7 +1506,7 @@ void CartDebug::disasmTypeAsString(ostream& buf, DisasmType type) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::disasmTypeAsString(ostream& buf, uInt16 flags) const
void CartDebug::disasmTypeAsString(ostream& buf, CartDebug::DisasmFlags flags) const
{
if(flags)
{

View File

@ -72,6 +72,8 @@ class CartDebug : public DebuggerSystem
// special type for poke()
WRITE = TCODE // 0x200, address written to
};
using DisasmFlags = uInt16;
struct DisassemblyTag {
DisasmType type{NONE};
uInt16 address{0};
@ -308,14 +310,14 @@ class CartDebug : public DebuggerSystem
void getBankDirectives(ostream& buf, BankInfo& info) const;
// Get disassembly enum type from 'flags', taking precendence into account
DisasmType disasmTypeAbsolute(uInt16 flags) const;
DisasmType disasmTypeAbsolute(CartDebug::DisasmFlags flags) const;
// Convert disassembly enum type to corresponding string and append to buf
void disasmTypeAsString(ostream& buf, DisasmType type) const;
// Convert all disassembly types in 'flags' to corresponding string and
// append to buf
void disasmTypeAsString(ostream& buf, uInt16 flags) const;
void disasmTypeAsString(ostream& buf, CartDebug::DisasmFlags flags) const;
private:
const OSystem& myOSystem;

View File

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

View File

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

View File

@ -30,6 +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
@ -322,7 +323,7 @@ class Cartridge : public Device
// The array containing information about every byte of ROM indicating
// whether it is used as code.
WordBuffer myCodeAccessBase;
std::unique_ptr<CartDebug::DisasmFlags[]> myCodeAccessBase;
// Contains address of illegal RAM write access or 0
uInt16 myRamWriteAccess{0};

View File

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

View File

@ -158,14 +158,14 @@ class Cartridge4A50 : public Cartridge
@param address The address to query
*/
uInt16 getAccessFlags(uInt16 address) const override;
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override;
/**
Change the given address to use the given disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt16 flags) override;
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override;
/**
Check all possible hotspots

View File

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

View File

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

View File

@ -22,6 +22,7 @@ class System;
#include "Console.hxx"
#include "Serializable.hxx"
#include "CartDebug.hxx"
#include "bspf.hxx"
/**
@ -102,7 +103,7 @@ class Device : public Serializable
@param address The address to modify
*/
virtual uInt16 getAccessFlags(uInt16 address) const { return 0; }
virtual CartDebug::DisasmFlags getAccessFlags(uInt16 address) const { return CartDebug::NONE; }
/**
Change the given address type to use the given disassembly flags
@ -110,7 +111,7 @@ class Device : public Serializable
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
virtual void setAccessFlags(uInt16 address, uInt16 flags) { }
virtual void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) { }
protected:
/// Pointer to the system the device is installed in or the null pointer

View File

@ -104,7 +104,7 @@ void M6502::reset()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline uInt8 M6502::peek(uInt16 address, uInt16 flags)
inline uInt8 M6502::peek(uInt16 address, CartDebug::DisasmFlags flags)
{
handleHalt();
@ -144,7 +144,7 @@ inline uInt8 M6502::peek(uInt16 address, uInt16 flags)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void M6502::poke(uInt16 address, uInt8 value, uInt16 flags)
inline void M6502::poke(uInt16 address, uInt8 value, CartDebug::DisasmFlags flags)
{
////////////////////////////////////////////////
// TODO - move this logic directly into CartAR

View File

@ -35,6 +35,7 @@ class DispatchResult;
#include "bspf.hxx"
#include "Serializable.hxx"
#include "CartDebug.hxx"
/**
The 6502 is an 8-bit microprocessor that has a 64K addressing space.
@ -269,7 +270,7 @@ class M6502 : public Serializable
@return The byte at the specified address
*/
uInt8 peek(uInt16 address, uInt16 flags);
uInt8 peek(uInt16 address, CartDebug::DisasmFlags flags);
/**
Change the byte at the specified address to the given value and
@ -278,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, uInt16 flags = 0);
void poke(uInt16 address, uInt8 value, CartDebug::DisasmFlags flags = CartDebug::NONE);
/**
Get the 8-bit value of the Processor Status register.

View File

@ -467,7 +467,7 @@ void M6532::createAccessBases()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 M6532::getAccessFlags(uInt16 address) const
CartDebug::DisasmFlags M6532::getAccessFlags(uInt16 address) const
{
if (address & IO_BIT)
return myIOAccessBase[address & IO_MASK];
@ -478,7 +478,7 @@ uInt16 M6532::getAccessFlags(uInt16 address) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::setAccessFlags(uInt16 address, uInt16 flags)
void M6532::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags)
{
// ignore none flag
if (flags != CartDebug::NONE) {

View File

@ -151,14 +151,14 @@ class M6532 : public Device
@param address The address to query
*/
uInt16 getAccessFlags(uInt16 address) const override;
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override;
/**
Change the given address to use the given disassembly flags.
@param address The address to modify
@param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt16 flags) override;
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override;
#endif // DEBUGGER_SUPPORT
private:

View File

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

View File

@ -29,6 +29,7 @@ class NullDevice;
#include "NullDev.hxx"
#include "Random.hxx"
#include "Serializable.hxx"
#include "CartDebug.hxx"
/**
This class represents a system consisting of a 6502 microprocessor
@ -202,7 +203,7 @@ class System : public Serializable
@return The byte at the specified address
*/
uInt8 peek(uInt16 address, uInt16 flags = 0);
uInt8 peek(uInt16 address, CartDebug::DisasmFlags flags = CartDebug::NONE);
/**
Change the byte at the specified address to the given value.
@ -217,7 +218,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, uInt16 flags = 0);
void poke(uInt16 address, uInt8 value, CartDebug::DisasmFlags flags = CartDebug::NONE);
/**
Lock/unlock the data bus. When the bus is locked, peek() and
@ -236,8 +237,8 @@ class System : public Serializable
address. Note that while any flag can be used, the disassembly
only really acts on CODE/GFX/PGFX/DATA/ROW.
*/
uInt16 getAccessFlags(uInt16 address) const;
void setAccessFlags(uInt16 address, uInt16 flags);
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const;
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags);
public:
/**
@ -277,7 +278,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.
*/
uInt16* codeAccessBase{nullptr};
CartDebug::DisasmFlags* codeAccessBase{nullptr};
/**
Pointer to the device associated with this page or to the system's

View File

@ -1919,13 +1919,13 @@ void TIA::createAccessBase()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 TIA::getAccessFlags(uInt16 address) const
CartDebug::DisasmFlags TIA::getAccessFlags(uInt16 address) const
{
return myAccessBase[address & TIA_MASK];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::setAccessFlags(uInt16 address, uInt16 flags)
void TIA::setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags)
{
// ignore none flag
if (flags != CartDebug::NONE) {

View File

@ -685,14 +685,14 @@ class TIA : public Device
*
* @param address The address to query
*/
uInt16 getAccessFlags(uInt16 address) const override;
CartDebug::DisasmFlags getAccessFlags(uInt16 address) const override;
/**
* Change the given address to use the given disassembly flags.
*
* @param address The address to modify
* @param flags A bitfield of DisasmType directives for the given address
*/
void setAccessFlags(uInt16 address, uInt16 flags) override;
void setAccessFlags(uInt16 address, CartDebug::DisasmFlags flags) override;
#endif // DEBUGGER_SUPPORT
private: