From 7a756515413adbddd5d0f04a14bb9d0b1ce518a1 Mon Sep 17 00:00:00 2001 From: Vladimir Kononovich Date: Mon, 12 Oct 2020 16:49:10 +0300 Subject: [PATCH] Fixes to registers change core. --- Core/Cpu.cpp | 4 ++ Core/DebugTypes.h | 3 +- InteropDLL/DebugApiWrapper.cpp | 10 ++-- UI/Interop/DebugApi.cs | 9 +++ UI/Interop/DebugState.cs | 106 +++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 6 deletions(-) diff --git a/Core/Cpu.cpp b/Core/Cpu.cpp index 1d2d09c..b461e9b 100644 --- a/Core/Cpu.cpp +++ b/Core/Cpu.cpp @@ -157,5 +157,9 @@ void Cpu::SetReg(CpuRegister reg, uint16_t value) { _state.PS = value & 0xFF; } break; + case CpuRegister::CpuRegNmiFlag: + { + _state.NmiFlag = value != 0; + } break; } } diff --git a/Core/DebugTypes.h b/Core/DebugTypes.h index 5b1607f..d678326 100644 --- a/Core/DebugTypes.h +++ b/Core/DebugTypes.h @@ -295,7 +295,8 @@ enum class CpuRegister : uint8_t CpuRegPC, CpuRegK, CpuRegDBR, - CpuRegPS + CpuRegPS, + CpuRegNmiFlag }; enum class Cx4Register : uint8_t diff --git a/InteropDLL/DebugApiWrapper.cpp b/InteropDLL/DebugApiWrapper.cpp index ba2d442..62fbf0f 100644 --- a/InteropDLL/DebugApiWrapper.cpp +++ b/InteropDLL/DebugApiWrapper.cpp @@ -69,12 +69,12 @@ extern "C" DllExport void __stdcall GetState(DebugState& state) { GetDebugger()->GetState(state, false); } DllExport void __stdcall SetCpuRegister(CpuRegister reg, uint16_t value) { GetDebugger()->SetCpuRegister(reg, value); } - DllExport void __stdcall SetSpcRegister(SpcRegister reg, uint32_t value) { GetDebugger()->SetSpcRegister(reg, value); } - DllExport void __stdcall SetNecDspRegister(NecDspRegister reg, uint32_t value) { GetDebugger()->SetNecDspRegister(reg, value); } - DllExport void __stdcall SetSa1Register(CpuRegister reg, uint32_t value) { GetDebugger()->SetSa1Register(reg, value); } - DllExport void __stdcall SetGsuRegister(GsuRegister reg, uint32_t value) { GetDebugger()->SetGsuRegister(reg, value); } + DllExport void __stdcall SetSpcRegister(SpcRegister reg, uint16_t value) { GetDebugger()->SetSpcRegister(reg, value); } + DllExport void __stdcall SetNecDspRegister(NecDspRegister reg, uint16_t value) { GetDebugger()->SetNecDspRegister(reg, value); } + DllExport void __stdcall SetSa1Register(CpuRegister reg, uint16_t value) { GetDebugger()->SetSa1Register(reg, value); } + DllExport void __stdcall SetGsuRegister(GsuRegister reg, uint16_t value) { GetDebugger()->SetGsuRegister(reg, value); } DllExport void __stdcall SetCx4Register(Cx4Register reg, uint32_t value) { GetDebugger()->SetCx4Register(reg, value); } - DllExport void __stdcall SetGameboyRegister(GbRegister reg, uint32_t value) { GetDebugger()->SetGameboyRegister(reg, value); } + DllExport void __stdcall SetGameboyRegister(GbRegister reg, uint16_t value) { GetDebugger()->SetGameboyRegister(reg, value); } DllExport const char* __stdcall GetDebuggerLog() { diff --git a/UI/Interop/DebugApi.cs b/UI/Interop/DebugApi.cs index 1773d26..a5eb3a6 100644 --- a/UI/Interop/DebugApi.cs +++ b/UI/Interop/DebugApi.cs @@ -58,6 +58,15 @@ namespace Mesen.GUI return state; } + [DllImport(DllPath)] public static extern void SetCpuRegister(CpuRegister reg, UInt16 value); + [DllImport(DllPath)] public static extern void SetSpcRegister(SpcRegister reg, UInt16 value); + [DllImport(DllPath)] public static extern void SetNecDspRegister(NecDspRegister reg, UInt16 value); + [DllImport(DllPath)] public static extern void SetSa1Register(CpuRegister reg, UInt16 value); + [DllImport(DllPath)] public static extern void SetGsuRegister(GsuRegister reg, UInt16 value); + [DllImport(DllPath)] public static extern void SetCx4Register(Cx4Register reg, UInt32 value); + [DllImport(DllPath)] public static extern void SetGameboyRegister(GbRegister reg, UInt16 value); + + [DllImport(DllPath)] public static extern void SetScriptTimeout(UInt32 timeout); [DllImport(DllPath)] public static extern Int32 LoadScript([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))]string content, Int32 scriptId = -1); [DllImport(DllPath)] public static extern void RemoveScript(Int32 scriptId); diff --git a/UI/Interop/DebugState.cs b/UI/Interop/DebugState.cs index f983cea..9351a7d 100644 --- a/UI/Interop/DebugState.cs +++ b/UI/Interop/DebugState.cs @@ -925,4 +925,110 @@ namespace Mesen.GUI public InternalRegisterState InternalRegs; public AluState Alu; } + + public enum CpuRegister : byte + { + CpuRegA, + CpuRegX, + CpuRegY, + CpuRegSP, + CpuRegD, + CpuRegPC, + CpuRegK, + CpuRegDBR, + CpuRegPS, + CpuRegNmiFlag, + } + + public enum Cx4Register : byte + { + Cx4Reg0, + Cx4Reg1, + Cx4Reg2, + Cx4Reg3, + Cx4Reg4, + Cx4Reg5, + Cx4Reg6, + Cx4Reg7, + Cx4Reg8, + Cx4Reg9, + Cx4Reg10, + Cx4Reg11, + Cx4Reg12, + Cx4Reg13, + Cx4Reg14, + Cx4Reg15, + Cx4RegPB, + Cx4RegPC, + Cx4RegA, + Cx4RegP, + Cx4RegSP, + } + + public enum GbRegister : byte + { + GbRegPC, + GbRegSP, + GbRegA, + GbRegFlags, + GbRegB, + GbRegC, + GbRegD, + GbRegE, + GbRegH, + GbRegL, + } + + public enum GsuRegister : byte + { + GsuReg0, + GsuReg1, + GsuReg2, + GsuReg3, + GsuReg4, + GsuReg5, + GsuReg6, + GsuReg7, + GsuReg8, + GsuReg9, + GsuRegA, + GsuRegB, + GsuRegC, + GsuRegD, + GsuRegE, + GsuRegF, + GsuRegSFR, + } + + public enum NecDspRegister : byte + { + NecDspRegA, + NecDspRegFlagsA, + NecDspRegB, + NecDspRegFlagsB, + NecDspRegTR, + NecDspRegTRB, + NecDspRegPC, + NecDspRegRP, + NecDspRegDP, + NecDspRegDR, + NecDspRegSR, + NecDspRegK, + NecDspRegL, + NecDspRegM, + NecDspRegN, + NecDspRegSerialOut, + NecDspRegSerialIn, + NecDspRegSP, + } + + public enum SpcRegister : byte + { + SpcRegPC, + SpcRegA, + SpcRegX, + SpcRegY, + SpcRegSP, + SpcRegPS, + } }