Debugger: Added option to display disassembly in lower case

This commit is contained in:
Sour 2020-02-07 22:55:27 -05:00
parent bb02c4352a
commit e0cfdaad13
24 changed files with 183 additions and 142 deletions

View file

@ -3,15 +3,16 @@
#include "CpuTypes.h"
#include "Cpu.h"
#include "Console.h"
#include "EmuSettings.h"
#include "DisassemblyInfo.h"
#include "LabelManager.h"
#include "DummyCpu.h"
#include "../Utilities/HexUtilities.h"
#include "../Utilities/FastString.h"
void CpuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager)
void CpuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings)
{
FastString str;
FastString str(settings->CheckDebuggerFlag(DebuggerFlags::UseLowerCaseDisassembly));
uint8_t opCode = info.GetOpCode();
AddrMode addrMode = CpuDisUtils::OpMode[opCode];
@ -21,13 +22,13 @@ void CpuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
uint32_t opAddr = CpuDisUtils::GetOperandAddress(info, memoryAddr);
uint32_t opSize = info.GetOpSize();
FastString operand;
FastString operand(settings->CheckDebuggerFlag(DebuggerFlags::UseLowerCaseDisassembly));
if(opSize > 1) {
if(addrMode == AddrMode::Rel || addrMode == AddrMode::RelLng || opSize == 4) {
AddressInfo address { (int32_t)opAddr, SnesMemoryType::CpuMemory };
string label = labelManager ? labelManager->GetLabel(address) : "";
if(label.size()) {
operand.Write(label);
operand.Write(label, true);
} else {
operand.WriteAll('$', HexUtilities::ToHex24(opAddr));
}

View file

@ -4,6 +4,7 @@
class DisassemblyInfo;
class Console;
class LabelManager;
class EmuSettings;
struct CpuState;
enum class AddrMode : uint8_t;
@ -19,7 +20,7 @@ private:
static bool HasEffectiveAddress(AddrMode addrMode);
public:
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager);
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings);
static uint8_t GetOpSize(uint8_t opCode, uint8_t flags);
static int32_t GetEffectiveAddress(DisassemblyInfo &info, Console* console, CpuState &state);
};

View file

@ -1,12 +1,13 @@
#include "stdafx.h"
#include "Cx4DisUtils.h"
#include "DisassemblyInfo.h"
#include "EmuSettings.h"
#include "../Utilities/HexUtilities.h"
#include "../Utilities/FastString.h"
void Cx4DisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager *labelManager)
void Cx4DisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager *labelManager, EmuSettings *settings)
{
FastString str;
FastString str(settings->CheckDebuggerFlag(DebuggerFlags::UseLowerCaseDisassembly));
uint8_t op = info.GetByteCode()[1] & 0xFC;
uint8_t param1 = info.GetByteCode()[1] & 0x03;
@ -124,11 +125,11 @@ void Cx4DisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
case 0x40: str.Write("INC MAR"); break;
case 0x44: str.Write("???"); break;
case 0x48: str.Write("CMPR "); writeSrc(); str.Write(", "); writeShiftedA(); break;
case 0x4C: str.WriteAll("CMPR #$", HexUtilities::ToHex(param2)); str.Write(", "); writeShiftedA(); break;
case 0x48: str.Write("CMPR "); writeSrc(); str.Write(","); writeShiftedA(); break;
case 0x4C: str.WriteAll("CMPR #$", HexUtilities::ToHex(param2)); str.Write(","); writeShiftedA(); break;
case 0x50: str.Write("CMP "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0x54: str.WriteAll("CMP "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0x50: str.Write("CMP "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0x54: str.WriteAll("CMP "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0x58:
if(param1 == 1) {
str.Write("SXB");
@ -140,11 +141,11 @@ void Cx4DisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
break;
case 0x5C: str.Write("???"); break;
case 0x60: str.Write("LD "); writeDest(); str.Write(", "); writeSrc(); break;
case 0x60: str.Write("LD "); writeDest(); str.Write(","); writeSrc(); break;
case 0x64: str.Write("LD "); writeDest(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0x68: str.WriteAll("RDRAM RAM:", '0' + param1, ", A"); break;
case 0x6C: str.WriteAll("RDRAM RAM:", '0' + param1, ", DPR+#$", HexUtilities::ToHex(param2)); break;
case 0x68: str.WriteAll("RDRAM RAM:", '0' + param1, ",A"); break;
case 0x6C: str.WriteAll("RDRAM RAM:", '0' + param1, ",DPR+#$", HexUtilities::ToHex(param2)); break;
case 0x70: str.Write("RDROM (a)"); break;
case 0x74: str.WriteAll("RDROM (#$", HexUtilities::ToHex((param1 << 8) | param2), ")"); break;
@ -152,54 +153,54 @@ void Cx4DisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
case 0x7C:
if(param1 <= 1) {
str.WriteAll("LD P", param1 ? "H" : "L", ", #$", HexUtilities::ToHex(param2));
str.WriteAll("LD P", param1 ? "H" : "L", ",#$", HexUtilities::ToHex(param2));
} else {
str.Write("???");
}
break;
case 0x80: str.Write("ADD "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0x84: str.WriteAll("ADD "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0x88: str.Write("SUBR "); writeSrc(); str.Write(", "); writeShiftedA(); break;
case 0x8C: str.WriteAll("SUBR #$", HexUtilities::ToHex(param2)); str.Write(", "); writeShiftedA(); break;
case 0x80: str.Write("ADD "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0x84: str.WriteAll("ADD "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0x88: str.Write("SUBR "); writeSrc(); str.Write(","); writeShiftedA(); break;
case 0x8C: str.WriteAll("SUBR #$", HexUtilities::ToHex(param2)); str.Write(","); writeShiftedA(); break;
case 0x90: str.Write("SUB "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0x94: str.WriteAll("SUB "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0x90: str.Write("SUB "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0x94: str.WriteAll("SUB "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0x98: str.Write("SMUL A, "); writeSrc(); break;
case 0x9C: str.WriteAll("SMUL A, #$", HexUtilities::ToHex(param2)); break;
case 0x9C: str.WriteAll("SMUL A,#$", HexUtilities::ToHex(param2)); break;
case 0xA0: str.Write("XNOR "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0xA4: str.WriteAll("XNOR "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0xA8: str.Write("XOR "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0xAC: str.WriteAll("XOR "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0xA0: str.Write("XNOR "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0xA4: str.WriteAll("XNOR "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0xA8: str.Write("XOR "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0xAC: str.WriteAll("XOR "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0xB0: str.Write("AND "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0xB4: str.WriteAll("AND "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0xB8: str.Write("OR "); writeShiftedA(); str.Write(", "); writeSrc(); break;
case 0xBC: str.WriteAll("OR "); writeShiftedA(); str.WriteAll(", #$", HexUtilities::ToHex(param2)); break;
case 0xB0: str.Write("AND "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0xB4: str.WriteAll("AND "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0xB8: str.Write("OR "); writeShiftedA(); str.Write(","); writeSrc(); break;
case 0xBC: str.WriteAll("OR "); writeShiftedA(); str.WriteAll(",#$", HexUtilities::ToHex(param2)); break;
case 0xC0: str.Write("SHR A, "); writeSrc(); break;
case 0xC4: str.WriteAll("SHR A, #$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xC8: str.Write("ASR A, "); writeSrc(); break;
case 0xCC: str.WriteAll("ASR A, #$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xC0: str.Write("SHR A,"); writeSrc(); break;
case 0xC4: str.WriteAll("SHR A,#$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xC8: str.Write("ASR A,"); writeSrc(); break;
case 0xCC: str.WriteAll("ASR A,#$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xD0: str.Write("ROR A, "); writeSrc(); break;
case 0xD4: str.WriteAll("ROR A, #$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xD8: str.Write("SHL A, "); writeSrc(); break;
case 0xDC: str.WriteAll("SHL A, #$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xD0: str.Write("ROR A,"); writeSrc(); break;
case 0xD4: str.WriteAll("ROR A,#$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xD8: str.Write("SHL A,"); writeSrc(); break;
case 0xDC: str.WriteAll("SHL A,#$", HexUtilities::ToHex(param2 & 0x1F)); break;
case 0xE0:
if(param1 <= 1) {
str.Write("ST "); writeSrc(); str.WriteAll(", ", param1 ? "MDR" : "A");
str.Write("ST "); writeSrc(); str.WriteAll(",", param1 ? "MDR" : "A");
} else {
str.Write("???");
}
break;
case 0xE4: str.Write("???"); break;
case 0xE8: str.WriteAll("WRRAM A, RAM:", '0' + param1); break;
case 0xEC: str.WriteAll("WRRAM DPR+#$", HexUtilities::ToHex(param2), ", RAM:", '0' + param1); break;
case 0xE8: str.WriteAll("WRRAM A,RAM:", '0' + param1); break;
case 0xEC: str.WriteAll("WRRAM DPR+#$", HexUtilities::ToHex(param2), ",RAM:", '0' + param1); break;
case 0xF0: str.WriteAll("SWAP A, R", std::to_string(param2 & 0x0F)); break;
case 0xF0: str.WriteAll("SWAP A,R", std::to_string(param2 & 0x0F)); break;
case 0xF4: str.Write("???"); break;
case 0xF8: str.Write("???"); break;
case 0xFC: str.Write("STOP"); break;

View file

@ -3,9 +3,10 @@
class DisassemblyInfo;
class LabelManager;
class EmuSettings;
class Cx4DisUtils
{
public:
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager);
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings);
};

View file

@ -29,6 +29,7 @@ Disassembler::Disassembler(shared_ptr<Console> console, shared_ptr<CodeDataLogge
_labelManager = debugger->GetLabelManager();
_console = console.get();
_spc = console->GetSpc().get();
_settings = console->GetSettings().get();
_memoryDumper = _debugger->GetMemoryDumper().get();
_memoryManager = console->GetMemoryManager().get();
@ -212,10 +213,10 @@ void Disassembler::Disassemble(CpuType cpuType)
int32_t maxAddr = isSpc ? 0xFFFF : 0xFFFFFF;
results.clear();
bool disUnident = _console->GetSettings()->CheckDebuggerFlag(DebuggerFlags::DisassembleUnidentifiedData);
bool disData = _console->GetSettings()->CheckDebuggerFlag(DebuggerFlags::DisassembleVerifiedData);
bool showUnident = _console->GetSettings()->CheckDebuggerFlag(DebuggerFlags::ShowUnidentifiedData);
bool showData = _console->GetSettings()->CheckDebuggerFlag(DebuggerFlags::ShowVerifiedData);
bool disUnident = _settings->CheckDebuggerFlag(DebuggerFlags::DisassembleUnidentifiedData);
bool disData = _settings->CheckDebuggerFlag(DebuggerFlags::DisassembleVerifiedData);
bool showUnident = _settings->CheckDebuggerFlag(DebuggerFlags::ShowUnidentifiedData);
bool showData = _settings->CheckDebuggerFlag(DebuggerFlags::ShowVerifiedData);
bool inUnknownBlock = false;
bool inVerifiedBlock = false;
@ -520,7 +521,7 @@ bool Disassembler::GetLineData(CpuType type, uint32_t lineIndex, CodeLineData &d
}
string text;
disInfo.GetDisassembly(text, result.CpuAddress, _labelManager.get());
disInfo.GetDisassembly(text, result.CpuAddress, _labelManager.get(), _settings);
memcpy(data.Text, text.c_str(), std::min<int>((int)text.size(), 1000));
disInfo.GetByteCode(data.ByteCode);

View file

@ -12,6 +12,7 @@ class Debugger;
class LabelManager;
class CodeDataLogger;
class MemoryDumper;
class EmuSettings;
struct CpuState;
enum class CpuType : uint8_t;
@ -27,7 +28,8 @@ class Disassembler
private:
MemoryManager *_memoryManager;
Console *_console;
Spc *_spc;
Spc* _spc;
EmuSettings* _settings;
Debugger *_debugger;
shared_ptr<CodeDataLogger> _cdl;
shared_ptr<LabelManager> _labelManager;

View file

@ -2,6 +2,7 @@
#include <algorithm>
#include "DisassemblyInfo.h"
#include "CpuTypes.h"
#include "EmuSettings.h"
#include "MemoryDumper.h"
#include "CpuDisUtils.h"
#include "SpcDisUtils.h"
@ -45,18 +46,18 @@ void DisassemblyInfo::Reset()
_initialized = false;
}
void DisassemblyInfo::GetDisassembly(string &out, uint32_t memoryAddr, LabelManager* labelManager)
void DisassemblyInfo::GetDisassembly(string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings)
{
switch(_cpuType) {
case CpuType::Sa1:
case CpuType::Cpu:
CpuDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager);
CpuDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager, settings);
break;
case CpuType::Spc: SpcDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager); break;
case CpuType::NecDsp: NecDspDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager); break;
case CpuType::Gsu: GsuDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager); break;
case CpuType::Cx4: Cx4DisUtils::GetDisassembly(*this, out, memoryAddr, labelManager); break;
case CpuType::Spc: SpcDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager, settings); break;
case CpuType::NecDsp: NecDspDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager, settings); break;
case CpuType::Gsu: GsuDisUtils::GetDisassembly(*this, out, memoryAddr, labelManager, settings); break;
case CpuType::Cx4: Cx4DisUtils::GetDisassembly(*this, out, memoryAddr, labelManager, settings); break;
}
}

View file

@ -4,6 +4,7 @@
class Console;
class MemoryDumper;
class LabelManager;
class EmuSettings;
enum class SnesMemoryType;
enum class CpuType : uint8_t;
@ -26,7 +27,7 @@ public:
bool IsValid(uint8_t cpuFlags);
void Reset();
void GetDisassembly(string &out, uint32_t memoryAddr, LabelManager *labelManager);
void GetDisassembly(string &out, uint32_t memoryAddr, LabelManager *labelManager, EmuSettings* settings);
CpuType GetCpuType();
uint8_t GetOpCode();

View file

@ -278,10 +278,6 @@ void EmuSettings::SetDebuggerFlag(DebuggerFlags flag, bool enabled)
_debuggerFlags &= ~(int)flag;
}
}
if(flag == DebuggerFlags::UseAltSpcOpNames) {
SpcDisUtils::UseAltSpcOpNames = enabled;
}
}
bool EmuSettings::CheckDebuggerFlag(DebuggerFlags flag)

View file

@ -1,10 +1,11 @@
#include "stdafx.h"
#include "GsuDisUtils.h"
#include "DisassemblyInfo.h"
#include "EmuSettings.h"
#include "../Utilities/FastString.h"
#include "../Utilities/HexUtilities.h"
void GsuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager *labelManager)
void GsuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager *labelManager, EmuSettings *settings)
{
constexpr const char* registerNames[16] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" };
bool alt1 = (info.GetFlags() & 0x01) != 0;
@ -13,7 +14,7 @@ void GsuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
uint8_t opCode = info.GetOpCode();
FastString str;
FastString str(settings->CheckDebuggerFlag(DebuggerFlags::UseLowerCaseDisassembly));
const char* reg = registerNames[opCode & 0x0F];
uint32_t jmpTarget = memoryAddr + (int8_t)info.GetByteCode()[1];
@ -127,11 +128,11 @@ void GsuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
case 0xA0: case 0xA1: case 0xA2: case 0xA3: case 0xA4: case 0xA5: case 0xA6: case 0xA7:
case 0xA8: case 0xA9: case 0xAA: case 0xAB: case 0xAC: case 0xAD: case 0xAE: case 0xAF:
if(alt1) {
str.WriteAll("LMS R", reg, ", ($", HexUtilities::ToHex(info.GetByteCode()[1] << 1), ')');
str.WriteAll("LMS R", reg, ",($", HexUtilities::ToHex(info.GetByteCode()[1] << 1), ')');
} else if(alt2) {
str.WriteAll("SMS R", reg, ", ($", HexUtilities::ToHex(info.GetByteCode()[1] << 1), ')');
str.WriteAll("SMS R", reg, ",($", HexUtilities::ToHex(info.GetByteCode()[1] << 1), ')');
} else {
str.WriteAll("IBT R", reg, ", #$", HexUtilities::ToHex(info.GetByteCode()[1]));
str.WriteAll("IBT R", reg, ",#$", HexUtilities::ToHex(info.GetByteCode()[1]));
}
break;
@ -185,11 +186,11 @@ void GsuDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
case 0xF0: case 0xF1: case 0xF2: case 0xF3: case 0xF4: case 0xF5: case 0xF6: case 0xF7:
case 0xF8: case 0xF9: case 0xFA: case 0xFB: case 0xFC: case 0xFD: case 0xFE: case 0xFF:
if(alt1) {
str.WriteAll("LM R", reg, ", ($", HexUtilities::ToHex(info.GetByteCode()[2]), HexUtilities::ToHex(info.GetByteCode()[1]), ')');
str.WriteAll("LM R", reg, ",($", HexUtilities::ToHex(info.GetByteCode()[2]), HexUtilities::ToHex(info.GetByteCode()[1]), ')');
} else if(alt2) {
str.WriteAll("SM R", reg, ", ($", HexUtilities::ToHex(info.GetByteCode()[2]), HexUtilities::ToHex(info.GetByteCode()[1]), ')');
str.WriteAll("SM R", reg, ",($", HexUtilities::ToHex(info.GetByteCode()[2]), HexUtilities::ToHex(info.GetByteCode()[1]), ')');
} else {
str.WriteAll("IWT R", reg, ", #$", HexUtilities::ToHex(info.GetByteCode()[2]), HexUtilities::ToHex(info.GetByteCode()[1]));
str.WriteAll("IWT R", reg, ",#$", HexUtilities::ToHex(info.GetByteCode()[2]), HexUtilities::ToHex(info.GetByteCode()[1]));
}
break;
}

View file

@ -3,9 +3,10 @@
class DisassemblyInfo;
class LabelManager;
class EmuSettings;
class GsuDisUtils
{
public:
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager);
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings);
};

View file

@ -1,17 +1,18 @@
#include "stdafx.h"
#include "NecDspDisUtils.h"
#include "DisassemblyInfo.h"
#include "EmuSettings.h"
#include "../Utilities/HexUtilities.h"
#include "../Utilities/FastString.h"
void NecDspDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager *labelManager)
void NecDspDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager *labelManager, EmuSettings* settings)
{
constexpr const char* aluOperations[16] = { "NOP ", "OR ", "AND ", "XOR ", "SUB ", "ADD ", "SBC ", "ADC ", "DEC" , "INC ", "CMP ", "SHR1 ", "SHL1 ", "SHL2 ", "SHL4 ", "XCHG " };
constexpr const char* aluOperations[16] = { "NOP", "OR", "AND", "XOR", "SUB", "ADD", "SBC", "ADC", "DEC" , "INC", "CMP", "SHR1", "SHL1", "SHL2", "SHL4", "XCHG" };
constexpr const char* sourceNames[16] = { "TRB", "A", "B", "TR", "DP", "RP", "ROM", "SGN", "DR", "DRNF", "SR", "SIM", "SIL" ,"K", "L", "MEM" };
constexpr const char* destNames[16] = { "NON", "A", "B", "TR", "DP", "RP", "DR", "SR", "SOL", "SOM", "K", "KLR", "KLM", "L", "TRB", "MEM" };
constexpr const char* dataPointerOp[4] = { "DPL:NOP", "DPL:INC", "DPL:DEC", "DPL:CLR" };
FastString str;
FastString str(settings->CheckDebuggerFlag(DebuggerFlags::UseLowerCaseDisassembly));
uint32_t opCode = *(uint32_t*)info.GetByteCode();
uint8_t operationType = (opCode >> 22) & 0x03;
@ -27,10 +28,10 @@ void NecDspDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t
uint8_t pSelect = (opCode >> 20) & 0x03;
switch(pSelect) {
case 0: str.Write("RAM, "); break;
case 1: str.WriteAll(sourceNames[source], ", "); break;
case 2: str.Write("M, "); break;
case 3: str.Write("N, "); break;
case 0: str.Write("RAM,"); break;
case 1: str.WriteAll(sourceNames[source], ","); break;
case 2: str.Write("M,"); break;
case 3: str.Write("N,"); break;
}
}
@ -41,7 +42,7 @@ void NecDspDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t
if(dest) {
str.Delimiter(" | ");
str.Write("MOV ");
str.WriteAll(sourceNames[source], ", ");
str.WriteAll(sourceNames[source], ",");
str.Write(destNames[dest]);
}

View file

@ -3,9 +3,10 @@
class DisassemblyInfo;
class LabelManager;
class EmuSettings;
class NecDspDisUtils
{
public:
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager);
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings);
};

View file

@ -481,6 +481,7 @@ enum class DebuggerFlags : uint32_t
DisassembleUnidentifiedData = 0x800,
UseAltSpcOpNames = 0x1000,
UseLowerCaseDisassembly = 0x2000,
GsuDebuggerEnabled = 0x10000000,
Sa1DebuggerEnabled = 0x20000000,

View file

@ -3,48 +3,47 @@
#include "Console.h"
#include "DummySpc.h"
#include "DisassemblyInfo.h"
#include "EmuSettings.h"
#include "LabelManager.h"
#include "../Utilities/FastString.h"
#include "../Utilities/HexUtilities.h"
bool SpcDisUtils::UseAltSpcOpNames = false;
constexpr const char* _altOpTemplate[256] = {
"NOP", "TCALL 0", "SET1 d.0", "BBS d.0, q", "OR A, d", "OR A, !a", "OR A, (X)", "OR A, [d+X]", "OR A, #i", "OR t, s", "OR1 C, m.b", "ASL d", "ASL !a", "PUSH PSW", "TSET1 !a", "BRK",
"BPL r", "TCALL 1", "CLR1 d.0", "BBC d.0, q", "OR A, d+X", "OR A, !a+X", "OR A, !a+Y", "OR A, [d]+Y", "OR e, #i", "OR (X), (Y)", "DECW d", "ASL d+X", "ASL A", "DEC X", "CMP X, !a", "JMP [!a+X]",
"CLRP", "TCALL 2", "SET1 d.1", "BBS d.1, q", "AND A, d", "AND A, !a", "AND A, (X)", "AND A, [d+X]", "AND A, #i", "AND t, s", "OR1 C, /m.b", "ROL d", "ROL !a", "PUSH A", "CBNE d, q", "BRA r",
"BMI r", "TCALL 3", "CLR1 d.1", "BBC d.1, q", "AND A, d+X", "AND A, !a+X", "AND A, !a+Y", "AND A, [d]+Y", "AND e, #i", "AND (X), (Y)","INCW d", "ROL d+X", "ROL A", "INC X", "CMP X, d", "CALL !a",
"SETP", "TCALL 4", "SET1 d.2", "BBS d.2, q", "EOR A, d", "EOR A, !a", "EOR A, (X)", "EOR A, [d+X]", "EOR A, #i", "EOR t, s", "AND1 C, m.b", "LSR d", "LSR !a", "PUSH X", "TCLR1 !a", "PCALL u",
"BVC r", "TCALL 5", "CLR1 d.2", "BBC d.2, q", "EOR A, d+X", "EOR A, !a+X", "EOR A, !a+Y", "EOR A, [d]+Y", "EOR e, #i", "EOR (X), (Y)","CMPW YA, d", "LSR d+X", "LSR A", "MOV X, A", "CMP Y, !a", "JMP !a",
"CLRC", "TCALL 6", "SET1 d.3", "BBS d.3, q", "CMP A, d", "CMP A, !a", "CMP A, (X)", "CMP A, [d+X]", "CMP A, #i", "CMP t, s", "AND1 C, /m.b","ROR d", "ROR !a", "PUSH Y", "DBNZ d, q", "RET",
"BVS r", "TCALL 7", "CLR1 d.3", "BBC d.3, q", "CMP A, d+X", "CMP A, !a+X", "CMP A, !a+Y", "CMP A, [d]+Y", "CMP e, #i", "CMP (X), (Y)","ADDW YA, d", "ROR d+X", "ROR A", "MOV A, X", "CMP Y, d", "RET1",
"SETC", "TCALL 8", "SET1 d.4", "BBS d.4, q", "ADC A, d", "ADC A, !a", "ADC A, (X)", "ADC A, [d+X]", "ADC A, #i", "ADC t, s", "EOR1 C, m.b", "DEC d", "DEC !a", "MOV Y, #i","POP PSW", "MOV e, #i",
"BCC r", "TCALL 9", "CLR1 d.4", "BBC d.4, q", "ADC A, d+X", "ADC A, !a+X", "ADC A, !a+Y", "ADC A, [d]+Y", "ADC e, #i", "ADC (X), (Y)","SUBW YA, d", "DEC d+X", "DEC A", "MOV X, SP","DIV YA, X", "XCN A",
"EI", "TCALL 10", "SET1 d.5", "BBS d.5, q", "SBC A, d", "SBC A, !a", "SBC A, (X)", "SBC A, [d+X]", "SBC A, #i", "SBC t, s", "MOV1 C, m.b", "INC d", "INC !a", "CMP Y, #i","POP A", "MOV (X)+, A",
"BCS r", "TCALL 11", "CLR1 d.5", "BBC d.5, q", "SBC A, d+X", "SBC A, !a+X", "SBC A, !a+Y", "SBC A, [d]+Y", "SBC e, #i", "SBC (X), (Y)","MOVW YA, d", "INC d+X", "INC A", "MOV SP, X","DAS A", "MOV A, (X)+",
"DI", "TCALL 12", "SET1 d.6", "BBS d.6, q", "MOV d, A", "MOV !a, A", "MOV (X), A", "MOV [d+X], A", "CMP X, #i", "MOV !a, X", "MOV1 m.b, C", "MOV d, Y", "MOV !a, Y","MOV X, #i","POP X", "MUL YA",
"BNE r", "TCALL 13", "CLR1 d.6", "BBC d.6, q", "MOV d+X, A", "MOV !a+X, A", "MOV !a+Y, A", "MOV [d]+Y, A", "MOV e, X", "MOV d+Y, X", "MOVW d, YA", "MOV d+X, Y", "DEC Y", "MOV A, Y", "CBNE d+X, q", "DAA A",
"CLRV", "TCALL 14", "SET1 d.7", "BBS d.7, q", "MOV A, d", "MOV A, !a", "MOV A, (X)", "MOV A, [d+X]", "MOV A, #i", "MOV X, !a", "NOT1 m.b", "MOV Y, d", "MOV Y, !a","NOTC", "POP Y", "SLEEP",
"BEQ r", "TCALL 15", "CLR1 d.7", "BBC d.7, q", "MOV A, d+X", "MOV A, !a+X", "MOV A, !a+Y", "MOV A, [d]+Y", "MOV X, d", "MOV X, d+Y", "MOV t, s", "MOV Y, d+X", "INC Y", "MOV Y, A", "DBNZ Y, q", "STOP"
"NOP", "TCALL 0", "SET1 d.0", "BBS d.0,q", "OR A,d", "OR A,!a", "OR A,(X)", "OR A,[d+X]", "OR A,#i", "OR t,s", "OR1 C,m.b", "ASL d", "ASL !a", "PUSH PSW", "TSET1 !a", "BRK",
"BPL r", "TCALL 1", "CLR1 d.0", "BBC d.0,q", "OR A,d+X", "OR A,!a+X", "OR A,!a+Y", "OR A,[d]+Y", "OR e,#i", "OR (X),(Y)", "DECW d", "ASL d+X", "ASL A", "DEC X", "CMP X,!a", "JMP [!a+X]",
"CLRP", "TCALL 2", "SET1 d.1", "BBS d.1,q", "AND A,d", "AND A,!a", "AND A,(X)", "AND A,[d+X]", "AND A,#i", "AND t,s", "OR1 C,/m.b", "ROL d", "ROL !a", "PUSH A", "CBNE d,q", "BRA r",
"BMI r", "TCALL 3", "CLR1 d.1", "BBC d.1,q", "AND A,d+X", "AND A,!a+X", "AND A,!a+Y", "AND A,[d]+Y", "AND e,#i", "AND (X),(Y)", "INCW d", "ROL d+X", "ROL A", "INC X", "CMP X,d", "CALL !a",
"SETP", "TCALL 4", "SET1 d.2", "BBS d.2,q", "EOR A,d", "EOR A,!a", "EOR A,(X)", "EOR A,[d+X]", "EOR A,#i", "EOR t,s", "AND1 C,m.b", "LSR d", "LSR !a", "PUSH X", "TCLR1 !a", "PCALL u",
"BVC r", "TCALL 5", "CLR1 d.2", "BBC d.2,q", "EOR A,d+X", "EOR A,!a+X", "EOR A,!a+Y", "EOR A,[d]+Y", "EOR e,#i", "EOR (X),(Y)", "CMPW YA,d", "LSR d+X", "LSR A", "MOV X,A", "CMP Y,!a", "JMP !a",
"CLRC", "TCALL 6", "SET1 d.3", "BBS d.3,q", "CMP A,d", "CMP A,!a", "CMP A,(X)", "CMP A,[d+X]", "CMP A,#i", "CMP t,s", "AND1 C,/m.b", "ROR d", "ROR !a", "PUSH Y", "DBNZ d,q", "RET",
"BVS r", "TCALL 7", "CLR1 d.3", "BBC d.3,q", "CMP A,d+X", "CMP A,!a+X", "CMP A,!a+Y", "CMP A,[d]+Y", "CMP e,#i", "CMP (X),(Y)", "ADDW YA,d", "ROR d+X", "ROR A", "MOV A,X", "CMP Y,d", "RET1",
"SETC", "TCALL 8", "SET1 d.4", "BBS d.4,q", "ADC A,d", "ADC A,!a", "ADC A,(X)", "ADC A,[d+X]", "ADC A,#i", "ADC t,s", "EOR1 C,m.b", "DEC d", "DEC !a", "MOV Y,#i", "POP PSW", "MOV e,#i",
"BCC r", "TCALL 9", "CLR1 d.4", "BBC d.4,q", "ADC A,d+X", "ADC A,!a+X", "ADC A,!a+Y", "ADC A,[d]+Y", "ADC e,#i", "ADC (X),(Y)", "SUBW YA,d", "DEC d+X", "DEC A", "MOV X,SP", "DIV YA,X", "XCN A",
"EI", "TCALL 10", "SET1 d.5", "BBS d.5,q", "SBC A,d", "SBC A,!a", "SBC A,(X)", "SBC A,[d+X]", "SBC A,#i", "SBC t,s", "MOV1 C,m.b", "INC d", "INC !a", "CMP Y,#i", "POP A", "MOV (X)+,A",
"BCS r", "TCALL 11", "CLR1 d.5", "BBC d.5,q", "SBC A,d+X", "SBC A,!a+X", "SBC A,!a+Y", "SBC A,[d]+Y", "SBC e,#i", "SBC (X),(Y)", "MOVW YA,d", "INC d+X", "INC A", "MOV SP,X", "DAS A", "MOV A,(X)+",
"DI", "TCALL 12", "SET1 d.6", "BBS d.6,q", "MOV d,A", "MOV !a,A", "MOV (X),A", "MOV [d+X],A", "CMP X,#i", "MOV !a,X", "MOV1 m.b,C", "MOV d,Y", "MOV !a,Y", "MOV X,#i", "POP X", "MUL YA",
"BNE r", "TCALL 13", "CLR1 d.6", "BBC d.6,q", "MOV d+X,A", "MOV !a+X,A", "MOV !a+Y,A", "MOV [d]+Y,A", "MOV e,X", "MOV d+Y,X", "MOVW d,YA", "MOV d+X,Y", "DEC Y", "MOV A,Y", "CBNE d+X,q", "DAA A",
"CLRV", "TCALL 14", "SET1 d.7", "BBS d.7,q", "MOV A,d", "MOV A,!a", "MOV A,(X)", "MOV A,[d+X]", "MOV A,#i", "MOV X,!a", "NOT1 m.b", "MOV Y,d", "MOV Y,!a", "NOTC", "POP Y", "SLEEP",
"BEQ r", "TCALL 15", "CLR1 d.7", "BBC d.7,q", "MOV A,d+X", "MOV A,!a+X", "MOV A,!a+Y", "MOV A,[d]+Y", "MOV X,d", "MOV X,d+Y", "MOV t,s", "MOV Y,d+X", "INC Y", "MOV Y,A", "DBNZ Y,q", "STOP"
};
constexpr const char* _opTemplate[256] = {
"NOP", "JST0", "SET1 d.0", "BBS d.0, q", "ORA d", "ORA a", "ORA (X)", "ORA [d,X]", "ORA #i", "OR t, s", "ORC m.b", "ASL d", "ASL a", "PHP", "SET1 a", "BRK",
"BPL r", "JST1", "CLR1 d.0", "BBC d.0, q", "ORA d,X", "ORA a,X", "ORA a,Y", "ORA [d],Y", "OR e, #i", "OR (X), (Y)", "DEW d", "ASL d,X", "ASL A", "DEX", "CPX a", "JMP [a,X]",
"CLP", "JST2", "SET1 d.1", "BBS d.1, q", "AND d", "AND a", "AND (X)", "AND [d,X]", "AND #i", "AND t, s", "ORC /m.b", "ROL d", "ROL a", "PHA", "CBNE d, q", "BRA r",
"BMI r", "JST3", "CLR1 d.1", "BBC d.1, q", "AND d,X", "AND a,X", "AND a,Y", "AND [d],Y", "AND e, #i", "AND (X), (Y)","INW d", "ROL d,X", "ROL A", "INX", "CPX d", "JSR a",
"SEP", "JST4", "SET1 d.2", "BBS d.2, q", "EOR d", "EOR a", "EOR (X)", "EOR [d,X]", "EOR #i", "EOR t, s", "ANDC m.b", "LSR d", "LSR a", "PHX", "CLR1 a", "JSP u",
"BVC r", "JST5", "CLR1 d.2", "BBC d.2, q", "EOR d,X", "EOR a,X", "EOR a,Y", "EOR [d],Y", "EOR e, #i", "EOR (X), (Y)","CPW d", "LSR d,X", "LSR A", "TAX", "CPY a", "JMP a",
"CLC", "JST6", "SET1 d.3", "BBS d.3, q", "CMP d", "CMP a", "CMP (X)", "CMP [d,X]", "CMP #i", "CMP t, s", "ANDC /m.b", "ROR d", "ROR a", "PHY", "DBNZ d, q", "RTS",
"BVS r", "JST7", "CLR1 d.3", "BBC d.3, q", "CMP d,X", "CMP a,X", "CMP a,Y", "CMP [d],Y", "CMP e, #i", "CMP (X), (Y)","ADW d", "ROR d,X", "ROR A", "TXA", "CPY d", "RTI",
"SEC", "JST8", "SET1 d.4", "BBS d.4, q", "ADC d", "ADC a", "ADC (X)", "ADC [d,X]", "ADC #i", "ADC t, s", "EORC m.b", "DEC d", "DEC a", "LDY #i","PLP", "MOV e, #i",
"BCC r", "JST9", "CLR1 d.4", "BBC d.4, q", "ADC d,X", "ADC a,X", "ADC a,Y", "ADC [d],Y", "ADC e, #i", "ADC (X), (Y)","SBW d", "DEC d,X", "DEC A", "TSX", "DIV YA, X", "XCN A",
"CLI", "JSTA", "SET1 d.5", "BBS d.5, q", "SBC d", "SBC a", "SBC (X)", "SBC [d,X]", "SBC #i", "SBC t, s", "LDC m.b", "INC d", "INC a", "CMY #i","PLA", "STA (X)+, A",
"BCS r", "JSTB", "CLR1 d.5", "BBC d.5, q", "SBC d,X", "SBC a,X", "SBC a,Y", "SBC [d],Y", "SBC e, #i", "SBC (X), (Y)","LDW d", "INC d,X", "INC A", "TXS", "DAS A", "LDA (X)+",
"SEI", "JSTC", "SET1 d.6", "BBS d.6, q", "STA d", "STA a", "STA (X)", "STA [d,X]", "CPX #i", "STX a", "STC m.b", "STY d", "STY a", "LDX #i","PLX", "MUL YA",
"BNE r", "JSTD", "CLR1 d.6", "BBC d.6, q", "STA d,X", "STA a,X", "STA a,Y", "STA [d],Y", "STX d", "STX d,Y", "STW d", "STY d,X", "DEY", "TYA", "CBNE d,X, q", "DAA A",
"CLV", "JSTE", "SET1 d.7", "BBS d.7, q", "LDA d", "LDA a", "LDA (X)", "LDA [d,X]", "LDA #i", "LDX a", "NOT m.b", "LDY d", "LDY a", "NOTC", "PLY", "WAI",
"BEQ r", "JSTF", "CLR1 d.7", "BBC d.7, q", "LDA d,X", "LDA a,X", "LDA a,Y", "LDA [d],Y", "LDX d", "LDX d,Y", "MOV t,s", "LDY d,X", "INC Y", "TAY", "DBNZ Y, r", "STP"
"NOP", "JST0", "SET1 d.0", "BBS d.0,q", "ORA d", "ORA a", "ORA (X)", "ORA [d,X]", "ORA #i", "OR t,s", "ORC m.b", "ASL d", "ASL a", "PHP", "SET1 a", "BRK",
"BPL r", "JST1", "CLR1 d.0", "BBC d.0,q", "ORA d,X", "ORA a,X", "ORA a,Y", "ORA [d],Y", "OR e,#i", "OR (X),(Y)", "DEW d", "ASL d,X", "ASL A", "DEX", "CPX a", "JMP [a,X]",
"CLP", "JST2", "SET1 d.1", "BBS d.1,q", "AND d", "AND a", "AND (X)", "AND [d,X]", "AND #i", "AND t,s", "ORC /m.b", "ROL d", "ROL a", "PHA", "CBNE d,q", "BRA r",
"BMI r", "JST3", "CLR1 d.1", "BBC d.1,q", "AND d,X", "AND a,X", "AND a,Y", "AND [d],Y", "AND e,#i", "AND (X),(Y)", "INW d", "ROL d,X", "ROL A", "INX", "CPX d", "JSR a",
"SEP", "JST4", "SET1 d.2", "BBS d.2,q", "EOR d", "EOR a", "EOR (X)", "EOR [d,X]", "EOR #i", "EOR t,s", "ANDC m.b", "LSR d", "LSR a", "PHX", "CLR1 a", "JSP u",
"BVC r", "JST5", "CLR1 d.2", "BBC d.2,q", "EOR d,X", "EOR a,X", "EOR a,Y", "EOR [d],Y", "EOR e,#i", "EOR (X),(Y)", "CPW d", "LSR d,X", "LSR A", "TAX", "CPY a", "JMP a",
"CLC", "JST6", "SET1 d.3", "BBS d.3,q", "CMP d", "CMP a", "CMP (X)", "CMP [d,X]", "CMP #i", "CMP t,s", "ANDC /m.b", "ROR d", "ROR a", "PHY", "DBNZ d,q", "RTS",
"BVS r", "JST7", "CLR1 d.3", "BBC d.3,q", "CMP d,X", "CMP a,X", "CMP a,Y", "CMP [d],Y", "CMP e,#i", "CMP (X),(Y)", "ADW d", "ROR d,X", "ROR A", "TXA", "CPY d", "RTI",
"SEC", "JST8", "SET1 d.4", "BBS d.4,q", "ADC d", "ADC a", "ADC (X)", "ADC [d,X]", "ADC #i", "ADC t,s", "EORC m.b", "DEC d", "DEC a", "LDY #i","PLP", "MOV e,#i",
"BCC r", "JST9", "CLR1 d.4", "BBC d.4,q", "ADC d,X", "ADC a,X", "ADC a,Y", "ADC [d],Y", "ADC e,#i", "ADC (X),(Y)", "SBW d", "DEC d,X", "DEC A", "TSX", "DIV YA,X", "XCN A",
"CLI", "JSTA", "SET1 d.5", "BBS d.5,q", "SBC d", "SBC a", "SBC (X)", "SBC [d,X]", "SBC #i", "SBC t,s", "LDC m.b", "INC d", "INC a", "CMY #i","PLA", "STA (X)+,A",
"BCS r", "JSTB", "CLR1 d.5", "BBC d.5,q", "SBC d,X", "SBC a,X", "SBC a,Y", "SBC [d],Y", "SBC e,#i", "SBC (X),(Y)", "LDW d", "INC d,X", "INC A", "TXS", "DAS A", "LDA (X)+",
"SEI", "JSTC", "SET1 d.6", "BBS d.6,q", "STA d", "STA a", "STA (X)", "STA [d,X]", "CPX #i", "STX a", "STC m.b", "STY d", "STY a", "LDX #i","PLX", "MUL YA",
"BNE r", "JSTD", "CLR1 d.6", "BBC d.6,q", "STA d,X", "STA a,X", "STA a,Y", "STA [d],Y", "STX d", "STX d,Y", "STW d", "STY d,X", "DEY", "TYA", "CBNE d,X, q", "DAA A",
"CLV", "JSTE", "SET1 d.7", "BBS d.7,q", "LDA d", "LDA a", "LDA (X)", "LDA [d,X]", "LDA #i", "LDX a", "NOT m.b", "LDY d", "LDY a", "NOTC", "PLY", "WAI",
"BEQ r", "JSTF", "CLR1 d.7", "BBC d.7,q", "LDA d,X", "LDA a,X", "LDA a,Y", "LDA [d],Y", "LDX d", "LDX d,Y", "MOV t,s", "LDY d,X", "INC Y", "TAY", "DBNZ Y,r", "STP"
};
constexpr const uint8_t _opSize[256] = {
@ -85,9 +84,9 @@ constexpr bool _needAddress[256] = {
false, true, true, true, true, true, true, true, true, true, false, true, false, false, false, false
};
void SpcDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager)
void SpcDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings)
{
FastString str;
FastString str(settings->CheckDebuggerFlag(DebuggerFlags::UseLowerCaseDisassembly));
AddressInfo addrInfo { 0, SnesMemoryType::SpcMemory };
auto getOperand = [&str, &addrInfo, labelManager](uint16_t addr) {
@ -96,12 +95,12 @@ void SpcDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
if(label.empty()) {
str.WriteAll('$', HexUtilities::ToHex(addr));
} else {
str.Write(label);
str.Write(label, true);
}
};
uint8_t* byteCode = info.GetByteCode();
const char* op = SpcDisUtils::UseAltSpcOpNames ? _altOpTemplate[byteCode[0]] : _opTemplate[byteCode[0]];
const char* op = settings->CheckDebuggerFlag(DebuggerFlags::UseAltSpcOpNames) ? _altOpTemplate[byteCode[0]] : _opTemplate[byteCode[0]];
int i = 0;
while(op[i]) {
switch(op[i]) {
@ -119,7 +118,7 @@ void SpcDisUtils::GetDisassembly(DisassemblyInfo &info, string &out, uint32_t me
case 'i': str.WriteAll('$', HexUtilities::ToHex(byteCode[1])); break;
case 'm': getOperand((uint16_t)((byteCode[1] | (byteCode[2] << 8)) & 0x1FFF)); break;
case 'b': str.WriteAll('$', (char)('0' + (byteCode[2] >> 5))); break;
case 'b': str.WriteAll((char)('0' + (byteCode[2] >> 5))); break;
default: str.Write(op[i]); break;
}

View file

@ -4,14 +4,13 @@
class DisassemblyInfo;
class Console;
class LabelManager;
class EmuSettings;
struct SpcState;
class SpcDisUtils
{
public:
static bool UseAltSpcOpNames;
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager);
static void GetDisassembly(DisassemblyInfo &info, string &out, uint32_t memoryAddr, LabelManager* labelManager, EmuSettings* settings);
static int32_t GetEffectiveAddress(DisassemblyInfo &info, Console *console, SpcState &state);
static uint8_t GetOpSize(uint8_t opCode);
};

View file

@ -4,6 +4,7 @@
#include "TraceLogger.h"
#include "DisassemblyInfo.h"
#include "Console.h"
#include "EmuSettings.h"
#include "Debugger.h"
#include "MemoryManager.h"
#include "LabelManager.h"
@ -18,6 +19,7 @@ string TraceLogger::_executionTrace = "";
TraceLogger::TraceLogger(Debugger* debugger, shared_ptr<Console> console)
{
_console = console.get();
_settings = console->GetSettings().get();
_labelManager = debugger->GetLabelManager().get();
_memoryDumper = debugger->GetMemoryDumper().get();
_currentPos = 0;
@ -242,7 +244,7 @@ void TraceLogger::WriteDisassembly(DisassemblyInfo &info, RowPart &rowPart, uint
}
LabelManager* labelManager = _options.UseLabels ? _labelManager : nullptr;
info.GetDisassembly(code, pc, labelManager);
info.GetDisassembly(code, pc, labelManager, _settings);
WriteValue(output, code, rowPart);
}

View file

@ -12,6 +12,7 @@ class Console;
class Debugger;
class LabelManager;
class MemoryDumper;
class EmuSettings;
struct DebugState;
struct TraceLoggerOptions
@ -77,6 +78,7 @@ private:
string _outputBuffer;
ofstream _outputFile;
Console* _console;
EmuSettings* _settings;
LabelManager* _labelManager;
MemoryDumper* _memoryDumper;

View file

@ -15,7 +15,6 @@
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <sstream>
#include <list>
#include <atomic>

View file

@ -17,6 +17,7 @@ namespace Mesen.GUI.Config
public int? SplitterDistance = null;
public bool ShowByteCode = false;
public bool UseLowerCaseDisassembly = false;
public bool BreakOnBrk = false;
public bool BreakOnCop = false;
@ -79,6 +80,7 @@ namespace Mesen.GUI.Config
ConfigApi.SetDebuggerFlag(DebuggerFlags.DisassembleVerifiedData, VerifiedDataDisplay == CodeDisplayMode.Disassemble);
ConfigApi.SetDebuggerFlag(DebuggerFlags.UseAltSpcOpNames, UseAltSpcOpNames);
ConfigApi.SetDebuggerFlag(DebuggerFlags.UseLowerCaseDisassembly, UseLowerCaseDisassembly);
}
}

View file

@ -90,6 +90,7 @@
this.mnuShowData = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
this.mnuShowByteCode = new System.Windows.Forms.ToolStripMenuItem();
this.mnuUseLowerCaseDisassembly = new System.Windows.Forms.ToolStripMenuItem();
this.mnuUseAltSpcOpNames = new System.Windows.Forms.ToolStripMenuItem();
this.mnuBreakOptions = new System.Windows.Forms.ToolStripMenuItem();
this.mnuBreakOnPowerCycleReset = new System.Windows.Forms.ToolStripMenuItem();
@ -521,6 +522,7 @@
this.mnuVerifiedData,
this.toolStripMenuItem6,
this.mnuShowByteCode,
this.mnuUseLowerCaseDisassembly,
this.mnuUseAltSpcOpNames});
this.mnuDisassemblyOptions.Name = "mnuDisassemblyOptions";
this.mnuDisassemblyOptions.Size = new System.Drawing.Size(209, 22);
@ -534,7 +536,7 @@
this.mnuShowUnident});
this.mnuUnidentifiedData.Image = global::Mesen.GUI.Properties.Resources.UnidentifiedData;
this.mnuUnidentifiedData.Name = "mnuUnidentifiedData";
this.mnuUnidentifiedData.Size = new System.Drawing.Size(217, 22);
this.mnuUnidentifiedData.Size = new System.Drawing.Size(227, 22);
this.mnuUnidentifiedData.Text = "Unidentified Code/Data";
this.mnuUnidentifiedData.DropDownOpening += new System.EventHandler(this.mnuUnidentifiedData_DropDownOpening);
//
@ -564,7 +566,7 @@
this.mnuShowData});
this.mnuVerifiedData.Image = global::Mesen.GUI.Properties.Resources.VerifiedData;
this.mnuVerifiedData.Name = "mnuVerifiedData";
this.mnuVerifiedData.Size = new System.Drawing.Size(217, 22);
this.mnuVerifiedData.Size = new System.Drawing.Size(227, 22);
this.mnuVerifiedData.Text = "Verified Data";
this.mnuVerifiedData.DropDownOpening += new System.EventHandler(this.mnuVerifiedData_DropDownOpening);
//
@ -589,20 +591,27 @@
// toolStripMenuItem6
//
this.toolStripMenuItem6.Name = "toolStripMenuItem6";
this.toolStripMenuItem6.Size = new System.Drawing.Size(214, 6);
this.toolStripMenuItem6.Size = new System.Drawing.Size(224, 6);
//
// mnuShowByteCode
//
this.mnuShowByteCode.CheckOnClick = true;
this.mnuShowByteCode.Name = "mnuShowByteCode";
this.mnuShowByteCode.Size = new System.Drawing.Size(217, 22);
this.mnuShowByteCode.Size = new System.Drawing.Size(227, 22);
this.mnuShowByteCode.Text = "Show byte code";
//
// mnuUseLowerCaseDisassembly
//
this.mnuUseLowerCaseDisassembly.CheckOnClick = true;
this.mnuUseLowerCaseDisassembly.Name = "mnuUseLowerCaseDisassembly";
this.mnuUseLowerCaseDisassembly.Size = new System.Drawing.Size(227, 22);
this.mnuUseLowerCaseDisassembly.Text = "Show in lower case";
//
// mnuUseAltSpcOpNames
//
this.mnuUseAltSpcOpNames.CheckOnClick = true;
this.mnuUseAltSpcOpNames.Name = "mnuUseAltSpcOpNames";
this.mnuUseAltSpcOpNames.Size = new System.Drawing.Size(217, 22);
this.mnuUseAltSpcOpNames.Size = new System.Drawing.Size(227, 22);
this.mnuUseAltSpcOpNames.Text = "Use alternative mnemonics";
//
// mnuBreakOptions
@ -1067,5 +1076,6 @@
private System.Windows.Forms.ToolStripMenuItem mnuExit;
private Controls.ctrlGsuStatus ctrlGsuStatus;
private System.Windows.Forms.ToolStripMenuItem mnuUseAltSpcOpNames;
private System.Windows.Forms.ToolStripMenuItem mnuUseLowerCaseDisassembly;
}
}

View file

@ -5,14 +5,9 @@ using Mesen.GUI.Debugger.Labels;
using Mesen.GUI.Debugger.Workspace;
using Mesen.GUI.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesen.GUI.Debugger
@ -291,19 +286,24 @@ namespace Mesen.GUI.Debugger
);
}
private void UpdateFlags(object sender, EventArgs e)
{
_entityBinder.UpdateObject();
ConfigManager.Config.Debug.Debugger.ApplyConfig();
RefreshDisassembly();
}
private void LoadConfig()
{
DebuggerInfo cfg = ConfigManager.Config.Debug.Debugger;
_entityBinder.Entity = cfg;
_entityBinder.AddBinding(nameof(cfg.ShowByteCode), mnuShowByteCode);
_entityBinder.AddBinding(nameof(cfg.UseLowerCaseDisassembly), mnuUseLowerCaseDisassembly);
_entityBinder.AddBinding(nameof(cfg.UseAltSpcOpNames), mnuUseAltSpcOpNames);
mnuShowByteCode.CheckedChanged += (s, e) => { ctrlDisassemblyView.CodeViewer.ShowContentNotes = mnuShowByteCode.Checked; };
mnuUseAltSpcOpNames.CheckedChanged += (s, e) => {
_entityBinder.UpdateObject();
cfg.ApplyConfig();
RefreshDisassembly();
};
mnuUseLowerCaseDisassembly.CheckedChanged += this.UpdateFlags;
mnuUseAltSpcOpNames.CheckedChanged += this.UpdateFlags;
_entityBinder.UpdateUI();

View file

@ -60,6 +60,7 @@ namespace Mesen.GUI
DisassembleUnidentifiedData = 0x800,
UseAltSpcOpNames = 0x1000,
UseLowerCaseDisassembly = 0x2000,
GsuDebuggerEnabled = 0x10000000,
Sa1DebuggerEnabled = 0x20000000,

View file

@ -6,22 +6,33 @@ class FastString
private:
char _buffer[1000];
uint16_t _pos = 0;
bool _lowerCase = false;
void WriteAll() {}
public:
FastString() {}
FastString(bool lowerCase = false) { _lowerCase = lowerCase; }
FastString(const char* str, int size) { Write(str, size); }
FastString(string &str) { Write(str); }
void Write(char c)
{
_buffer[_pos++] = c;
if(_lowerCase) {
_buffer[_pos++] = ::tolower(c);
} else {
_buffer[_pos++] = c;
}
}
void Write(const char* str, int size)
{
memcpy(_buffer + _pos, str, size);
if(_lowerCase) {
for(size_t i = 0; i < size; i++) {
_buffer[_pos + i] = ::tolower(str[i]);
}
} else {
memcpy(_buffer + _pos, str, size);
}
_pos += size;
}
@ -37,9 +48,15 @@ public:
Write(str, (uint16_t)strlen(str));
}
void Write(string &str)
void Write(string &str, bool preserveCase = false)
{
memcpy(_buffer + _pos, str.c_str(), str.size());
if(_lowerCase && !preserveCase) {
for(size_t i = 0; i < str.size(); i++) {
_buffer[_pos + i] = ::tolower(str[i]);
}
} else {
memcpy(_buffer + _pos, str.c_str(), str.size());
}
_pos += (uint16_t)str.size();
}