From 54be4d813511b5d8698361823bf5d69d80e3857c Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 17 Aug 2023 12:04:06 +0930 Subject: [PATCH] Rsp: Add a rsp AccurateEmulation flag for new rsp work --- .../Settings/RspSettings.cpp | 3 +- .../Project64-rsp-core/Settings/RspSettings.h | 2 +- .../Settings/RspSettingsID.h | 2 +- Source/Project64-rsp-core/cpu/RSPCpu.cpp | 56 ++++-- .../cpu/RSPInterpreterCPU.cpp | 1 - .../cpu/RSPInterpreterOps.cpp | 85 +++++++-- Source/Project64-rsp-core/cpu/RspTypes.cpp | 17 +- Source/Project64-rsp/Main.cpp | 169 ++++++------------ Source/Project64-rsp/Project64-rsp.rc | 1 + Source/Project64-rsp/resource.h | 3 +- 10 files changed, 184 insertions(+), 155 deletions(-) diff --git a/Source/Project64-rsp-core/Settings/RspSettings.cpp b/Source/Project64-rsp-core/Settings/RspSettings.cpp index bcc18d6e1f..f936ba1168 100644 --- a/Source/Project64-rsp-core/Settings/RspSettings.cpp +++ b/Source/Project64-rsp-core/Settings/RspSettings.cpp @@ -6,7 +6,7 @@ uint16_t Set_AudioHle = 0, Set_GraphicsHle = 0; bool GraphicsHle = true, AudioHle, ConditionalMove; -bool DebuggingEnabled = false, Profiling, IndvidualBlock, ShowErrors, BreakOnStart = false, LogRDP = false, LogX86Code = false; +bool DebuggingEnabled = false, Profiling, IndvidualBlock, ShowErrors, AccurateEmulation = false, BreakOnStart = false, LogRDP = false, LogX86Code = false; void InitializeRspSetting(void) { @@ -15,6 +15,7 @@ void InitializeRspSetting(void) Set_AudioHle = FindSystemSettingId("HLE Audio"); RegisterSetting(Set_BreakOnStart, Data_DWORD_General, "Break on Start", NULL, BreakOnStart, NULL); + RegisterSetting(Set_AccurateEmulation, Data_DWORD_General, "Accurate Emulation", NULL, AccurateEmulation, NULL); RegisterSetting(Set_CPUCore, Data_DWORD_General, "CPU Method", NULL, g_CPUCore, NULL); RegisterSetting(Set_LogRDP, Data_DWORD_General, "Log RDP", NULL, LogRDP, NULL); RegisterSetting(Set_LogX86Code, Data_DWORD_General, "Log X86 Code", NULL, LogX86Code, NULL); diff --git a/Source/Project64-rsp-core/Settings/RspSettings.h b/Source/Project64-rsp-core/Settings/RspSettings.h index 08bf3e6696..638db47155 100644 --- a/Source/Project64-rsp-core/Settings/RspSettings.h +++ b/Source/Project64-rsp-core/Settings/RspSettings.h @@ -5,4 +5,4 @@ void InitializeRspSetting(void); extern uint16_t Set_AudioHle, Set_GraphicsHle; extern bool GraphicsHle, AudioHle, ConditionalMove; -extern bool DebuggingEnabled, Profiling, IndvidualBlock, ShowErrors, BreakOnStart, LogRDP, LogX86Code; \ No newline at end of file +extern bool DebuggingEnabled, Profiling, IndvidualBlock, ShowErrors, AccurateEmulation, BreakOnStart, LogRDP, LogX86Code; \ No newline at end of file diff --git a/Source/Project64-rsp-core/Settings/RspSettingsID.h b/Source/Project64-rsp-core/Settings/RspSettingsID.h index 7090879ae6..85d31676dd 100644 --- a/Source/Project64-rsp-core/Settings/RspSettingsID.h +++ b/Source/Project64-rsp-core/Settings/RspSettingsID.h @@ -3,12 +3,12 @@ enum { Set_BreakOnStart, + Set_AccurateEmulation, Set_CPUCore, Set_LogRDP, Set_LogX86Code, Set_Profiling, Set_IndvidualBlock, - Set_AccurateEmulation, Set_ShowErrors, // Compiler settings diff --git a/Source/Project64-rsp-core/cpu/RSPCpu.cpp b/Source/Project64-rsp-core/cpu/RSPCpu.cpp index b3ec541f29..3583483c8d 100644 --- a/Source/Project64-rsp-core/cpu/RSPCpu.cpp +++ b/Source/Project64-rsp-core/cpu/RSPCpu.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include UDWORD EleSpec[16], Indx[16]; @@ -51,23 +52,44 @@ void Build_RSP(void) SetCPU(g_CPUCore); g_RSPDebugger->ResetTimerList(); - EleSpec[0].DW = 0x0706050403020100; // None - EleSpec[1].DW = 0x0706050403020100; // None - EleSpec[2].DW = 0x0606040402020000; // 0q - EleSpec[3].DW = 0x0707050503030101; // 1q - EleSpec[4].DW = 0x0404040400000000; // 0h - EleSpec[5].DW = 0x0505050501010101; // 1h - EleSpec[6].DW = 0x0606060602020202; // 2h - EleSpec[7].DW = 0x0707070703030303; // 3h - EleSpec[8].DW = 0x0000000000000000; // 0 - EleSpec[9].DW = 0x0101010101010101; // 1 - EleSpec[10].DW = 0x0202020202020202; // 2 - EleSpec[11].DW = 0x0303030303030303; // 3 - EleSpec[12].DW = 0x0404040404040404; // 4 - EleSpec[13].DW = 0x0505050505050505; // 5 - EleSpec[14].DW = 0x0606060606060606; // 6 - EleSpec[15].DW = 0x0707070707070707; // 7 - + if (AccurateEmulation) + { + EleSpec[0].DW = 0x0706050403020100; // None + EleSpec[1].DW = 0x0706050403020100; // None + EleSpec[2].DW = 0x0606040402020000; // 0q + EleSpec[3].DW = 0x0707050503030101; // 1q + EleSpec[4].DW = 0x0404040400000000; // 0h + EleSpec[5].DW = 0x0505050501010101; // 1h + EleSpec[6].DW = 0x0606060602020202; // 2h + EleSpec[7].DW = 0x0707070703030303; // 3h + EleSpec[8].DW = 0x0000000000000000; // 0 + EleSpec[9].DW = 0x0101010101010101; // 1 + EleSpec[10].DW = 0x0202020202020202; // 2 + EleSpec[11].DW = 0x0303030303030303; // 3 + EleSpec[12].DW = 0x0404040404040404; // 4 + EleSpec[13].DW = 0x0505050505050505; // 5 + EleSpec[14].DW = 0x0606060606060606; // 6 + EleSpec[15].DW = 0x0707070707070707; // 7 + } + else + { + EleSpec[0].DW = 0x0001020304050607; // None + EleSpec[1].DW = 0x0001020304050607; // None + EleSpec[2].DW = 0x0000020204040606; // 0q + EleSpec[3].DW = 0x0101030305050707; // 1q + EleSpec[4].DW = 0x0000000004040404; // 0h + EleSpec[5].DW = 0x0101010105050505; // 1h + EleSpec[6].DW = 0x0202020206060606; // 2h + EleSpec[7].DW = 0x0303030307070707; // 3h + EleSpec[8].DW = 0x0000000000000000; // 0 + EleSpec[9].DW = 0x0101010101010101; // 1 + EleSpec[10].DW = 0x0202020202020202; // 2 + EleSpec[11].DW = 0x0303030303030303; // 3 + EleSpec[12].DW = 0x0404040404040404; // 4 + EleSpec[13].DW = 0x0505050505050505; // 5 + EleSpec[14].DW = 0x0606060606060606; // 6 + EleSpec[15].DW = 0x0707070707070707; // 7 + } Indx[0].DW = 0x0001020304050607; // None Indx[1].DW = 0x0001020304050607; // None Indx[2].DW = 0x0103050700020406; // 0q diff --git a/Source/Project64-rsp-core/cpu/RSPInterpreterCPU.cpp b/Source/Project64-rsp-core/cpu/RSPInterpreterCPU.cpp index 0061404d74..dfaff26e73 100644 --- a/Source/Project64-rsp-core/cpu/RSPInterpreterCPU.cpp +++ b/Source/Project64-rsp-core/cpu/RSPInterpreterCPU.cpp @@ -417,7 +417,6 @@ unsigned int RSP_branch_if(int condition) { unsigned int new_PC; - /* RSP_NextInstruction = DELAY_SLOT; */ if (condition) { new_PC = *PrgCount + 4 + ((short)RSPOpC.offset << 2); diff --git a/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp b/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp index a0fd3ad79f..c6f50d2785 100644 --- a/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp +++ b/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp @@ -1960,7 +1960,15 @@ void RSP_Vector_VMOV(void) RSP_ACCUM[i].HW[1] = RSP_Vect[RSPOpC.vt].ue(i, RSPOpC.e); } uint8_t Index = (RSPOpC.de & 0x7); - RSP_Vect[RSPOpC.vd].u16(Index) = RSP_Vect[RSPOpC.vt].ue(Index, RSPOpC.e); + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.vd].u16(Index) = RSP_Vect[RSPOpC.vt].ue(Index, RSPOpC.e); + } + else + { + uint8_t del = EleSpec[RSPOpC.e].B[Index]; + RSP_Vect[RSPOpC.vd].u16(7 - Index) = RSP_Vect[RSPOpC.vt].s16(7 - del); + } } void RSP_Vector_VRSQ(void) @@ -2108,7 +2116,14 @@ void RSP_Vector_VNOOP(void) void RSP_Opcode_LBV(void) { uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 0)) & 0xFFF; - RSP_Vect[RSPOpC.rt].s8(RSPOpC.del) = *(RSPInfo.DMEM + (Address ^ 3)); + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s8(RSPOpC.del) = *(RSPInfo.DMEM + (Address ^ 3)); + } + else + { + RSP_Vect[RSPOpC.rt].s8(15 - RSPOpC.del) = *(RSPInfo.DMEM + (Address ^ 3)); + } } void RSP_Opcode_LSV(void) @@ -2117,7 +2132,14 @@ void RSP_Opcode_LSV(void) uint8_t Length = std::min((uint8_t)2, (uint8_t)(16 - RSPOpC.del)); for (uint8_t i = RSPOpC.del, n = (uint8_t)(Length + RSPOpC.del); i < n; i++, Address++) { - RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } + else + { + RSP_Vect[RSPOpC.rt].s8(15 - i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } } } @@ -2127,7 +2149,14 @@ void RSP_Opcode_LLV(void) uint8_t Length = std::min((uint8_t)4, (uint8_t)(16 - RSPOpC.del)); for (uint8_t i = RSPOpC.del, n = (uint8_t)(Length + RSPOpC.del); i < n; i++, Address++) { - RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } + else + { + RSP_Vect[RSPOpC.rt].s8(15 - i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } } } @@ -2135,10 +2164,16 @@ void RSP_Opcode_LDV(void) { uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF; uint8_t Length = std::min((uint8_t)8, (uint8_t)(16 - RSPOpC.del)); - for (uint8_t i = RSPOpC.del, n = (uint8_t)(Length + RSPOpC.del); i < n; i++) + for (uint8_t i = RSPOpC.del, n = (uint8_t)(Length + RSPOpC.del); i < n; i++, Address++) { - RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); - Address += 1; + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } + else + { + RSP_Vect[RSPOpC.rt].s8(15 - i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } } } @@ -2148,7 +2183,14 @@ void RSP_Opcode_LQV(void) uint8_t Length = std::min((uint8_t)(((Address + 0x10) & ~0xF) - Address), (uint8_t)(16 - RSPOpC.del)); for (uint8_t i = RSPOpC.del, n = (uint8_t)(Length + RSPOpC.del); i < n; i++, Address++) { - RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + (Address ^ 3)); + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + (Address ^ 3)); + } + else + { + RSP_Vect[RSPOpC.rt].s8(15 - i) = *(RSPInfo.DMEM + (Address ^ 3)); + } } } @@ -2159,7 +2201,14 @@ void RSP_Opcode_LRV(void) Address &= 0xFF0; for (uint8_t i = Offset; i < 16; i++, Address++) { - RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s8(i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } + else + { + RSP_Vect[RSPOpC.rt].s8(15 - i) = *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)); + } } } @@ -2171,7 +2220,14 @@ void RSP_Opcode_LPV(void) for (uint8_t i = 0; i < 8; i++) { - RSP_Vect[RSPOpC.rt].s16(i) = *(RSPInfo.DMEM + ((Address + ((Offset + i) & 0xF) ^ 3) & 0xFFF)) << 8; + if (AccurateEmulation) + { + RSP_Vect[RSPOpC.rt].s16(i) = *(RSPInfo.DMEM + ((Address + ((Offset + i) & 0xF) ^ 3) & 0xFFF)) << 8; + } + else + { + RSP_Vect[RSPOpC.rt].s16(7 - i) = *(RSPInfo.DMEM + ((Address + ((Offset + i) & 0xF) ^ 3) & 0xFFF)) << 8; + } } } @@ -2283,7 +2339,14 @@ void RSP_Opcode_SQV(void) uint8_t Length = (uint8_t)(((Address + 0x10) & ~0xF) - Address); for (uint8_t i = RSPOpC.del; i < (Length + RSPOpC.del); i++) { - *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)) = RSP_Vect[RSPOpC.rt].s8(i & 0xF); + if (AccurateEmulation) + { + *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)) = RSP_Vect[RSPOpC.rt].s8(i & 0xF); + } + else + { + *(RSPInfo.DMEM + ((Address ^ 3) & 0xFFF)) = RSP_Vect[RSPOpC.rt].s8(15 - (i & 0xF)); + } Address += 1; } } diff --git a/Source/Project64-rsp-core/cpu/RspTypes.cpp b/Source/Project64-rsp-core/cpu/RspTypes.cpp index 34d5a242ac..d5df593818 100644 --- a/Source/Project64-rsp-core/cpu/RspTypes.cpp +++ b/Source/Project64-rsp-core/cpu/RspTypes.cpp @@ -1,4 +1,5 @@ #include "RspTypes.h" +#include extern UDWORD EleSpec[16]; @@ -11,41 +12,41 @@ RSPVector::RSPVector() uint16_t & RSPVector::ue(uint8_t Index, uint8_t Element) { Index = EleSpec[Element].B[Index]; - return ((uint16_t *)&m_Reg)[7 - Index]; + return ((uint16_t *)&m_Reg)[AccurateEmulation ? 7 - Index : Index]; } int16_t & RSPVector::se(uint8_t Index, uint8_t Element) { Index = EleSpec[Element].B[Index]; - return ((int16_t *)&m_Reg)[7 - Index]; + return ((int16_t *)&m_Reg)[AccurateEmulation ? 7 - Index : Index]; } int8_t & RSPVector::s8(uint8_t Index) { - return ((int8_t *)&m_Reg)[15 - Index]; + return ((int8_t *)&m_Reg)[AccurateEmulation ? 15 - Index : Index]; } uint8_t & RSPVector::u8(uint8_t Index) { - return ((uint8_t *)&m_Reg)[15 - Index]; + return ((uint8_t *)&m_Reg)[AccurateEmulation ? 15 - Index : Index]; } int16_t & RSPVector::s16(uint8_t Index) { - return ((int16_t *)&m_Reg)[7 - Index]; + return ((int16_t *)&m_Reg)[AccurateEmulation ? 7 - Index : Index]; } uint16_t & RSPVector::u16(uint8_t Index) { - return ((uint16_t *)&m_Reg)[7 - Index]; + return ((uint16_t *)&m_Reg)[AccurateEmulation ? 7 - Index : Index]; } int32_t & RSPVector::s32(uint8_t Index) { - return ((int32_t *)&m_Reg)[3 - Index]; + return ((int32_t *)&m_Reg)[AccurateEmulation ? 3 - Index : Index]; } uint64_t & RSPVector::u64(uint8_t Index) { - return m_Reg[1 - Index]; + return m_Reg[AccurateEmulation ? 1 - Index : Index]; } diff --git a/Source/Project64-rsp/Main.cpp b/Source/Project64-rsp/Main.cpp index 15811705e3..4f8da7c350 100644 --- a/Source/Project64-rsp/Main.cpp +++ b/Source/Project64-rsp/Main.cpp @@ -169,6 +169,7 @@ void FixMenuState(void) CheckMenuItem(hRSPMenu, ID_CPUMETHOD_RECOMPILER, MF_BYCOMMAND | (g_CPUCore == RecompilerCPU ? MFS_CHECKED : MF_UNCHECKED)); CheckMenuItem(hRSPMenu, ID_CPUMETHOD_INTERPT, MF_BYCOMMAND | (g_CPUCore == InterpreterCPU ? MFS_CHECKED : MF_UNCHECKED)); CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | (BreakOnStart ? MFS_CHECKED : MF_UNCHECKED)); + CheckMenuItem(hRSPMenu, ID_ACCURATEEMULATION, MF_BYCOMMAND | (AccurateEmulation ? MFS_CHECKED : MF_UNCHECKED)); CheckMenuItem(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | (LogRDP ? MFS_CHECKED : MF_UNCHECKED)); CheckMenuItem(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | (LogX86Code ? MFS_CHECKED : MF_UNCHECKED)); CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | (Profiling ? MFS_CHECKED : MF_UNCHECKED)); @@ -350,8 +351,6 @@ EXPORT void InitiateRSPDebugger(DEBUG_INFO Debug_Info) #ifdef _WIN32 void ProcessMenuItem(int ID) { - UINT uState; - switch (ID) { case ID_RSPCOMMANDS: Enter_RSP_Commands_Window(); break; @@ -361,78 +360,39 @@ void ProcessMenuItem(int ID) case ID_PROFILING_ON: case ID_PROFILING_OFF: { - uState = GetMenuState(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND); - - if (uState & MFS_CHECKED) - { - CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_UNCHECKED); - CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_CHECKED); - SetSetting(Set_Profiling, false); - if (DebuggingEnabled) - { - Profiling = false; - } - } - else + bool ProfilingOn = ID == ID_PROFILING_ON; + CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | (ProfilingOn ? MFS_CHECKED : MFS_UNCHECKED)); + CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | (ProfilingOn ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_Profiling, ProfilingOn); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_PROFILING_ON, MF_BYCOMMAND | MFS_CHECKED); - CheckMenuItem(hRSPMenu, ID_PROFILING_OFF, MF_BYCOMMAND | MFS_UNCHECKED); - SetSetting(Set_Profiling, true); - if (DebuggingEnabled) - { - Profiling = true; - } + Profiling = ProfilingOn; } + break; } - break; case ID_PROFILING_RESETSTATS: ResetTimerList(); break; case ID_PROFILING_GENERATELOG: GenerateTimerResults(); break; case ID_PROFILING_LOGINDIVIDUALBLOCKS: { - uState = GetMenuState(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND); - - if (uState & MFS_CHECKED) + bool Checked = (GetMenuState(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND) & MFS_CHECKED) != 0; + CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_IndvidualBlock, !Checked); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_UNCHECKED); - SetSetting(Set_IndvidualBlock, false); - if (DebuggingEnabled) - { - IndvidualBlock = false; - } - } - else - { - CheckMenuItem(hRSPMenu, ID_PROFILING_LOGINDIVIDUALBLOCKS, MF_BYCOMMAND | MFS_CHECKED); - SetSetting(Set_IndvidualBlock, true); - if (DebuggingEnabled) - { - IndvidualBlock = true; - } + IndvidualBlock = !Checked; } break; } case ID_SHOWCOMPILERERRORS: { - uState = GetMenuState(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND); - - if (uState & MFS_CHECKED) - { - CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_UNCHECKED); - SetSetting(Set_ShowErrors, false); - if (DebuggingEnabled) - { - ShowErrors = false; - } - } - else + bool Checked = (GetMenuState(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND) & MFS_CHECKED) != 0; + CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_ShowErrors, !Checked); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_SHOWCOMPILERERRORS, MF_BYCOMMAND | MFS_CHECKED); - SetSetting(Set_ShowErrors, true); - if (DebuggingEnabled) - { - ShowErrors = true; - } + ShowErrors = !Checked; } + break; } break; case ID_COMPILER: @@ -440,97 +400,77 @@ void ProcessMenuItem(int ID) break; case ID_BREAKONSTARTOFTASK: { - uState = GetMenuState(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND); - - if (uState & MFS_CHECKED) + bool Checked = (GetMenuState(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND) & MFS_CHECKED) != 0; + CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_BreakOnStart, !Checked); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_UNCHECKED); - SetSetting(Set_BreakOnStart, false); - if (DebuggingEnabled) - { - BreakOnStart = false; - } + BreakOnStart = !Checked; } - else + break; + } + case ID_ACCURATEEMULATION: + { + bool Checked = (GetMenuState(hRSPMenu, ID_ACCURATEEMULATION, MF_BYCOMMAND) & MFS_CHECKED) != 0; + CheckMenuItem(hRSPMenu, ID_ACCURATEEMULATION, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_AccurateEmulation, !Checked); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_BREAKONSTARTOFTASK, MF_BYCOMMAND | MFS_CHECKED); - SetSetting(Set_BreakOnStart, true); - if (DebuggingEnabled) - { - BreakOnStart = true; - } + AccurateEmulation = !Checked; } + break; } - break; case ID_LOGRDPCOMMANDS: { - uState = GetMenuState(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND); - - if (uState & MFS_CHECKED) + bool Checked = (GetMenuState(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND) & MFS_CHECKED) != 0; + CheckMenuItem(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_LogRDP, !Checked); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | MFS_UNCHECKED); - SetSetting(Set_LogRDP, false); - if (DebuggingEnabled) + LogRDP = !Checked; + if (LogRDP) { - LogRDP = false; - StopRDPLog(); + StartRDPLog(); } - } - else - { - CheckMenuItem(hRSPMenu, ID_LOGRDPCOMMANDS, MF_BYCOMMAND | MFS_CHECKED); - SetSetting(Set_LogRDP, true); - if (DebuggingEnabled) + else { - LogRDP = true; - StartRDPLog(); + StopRDPLog(); } } + break; } - break; case ID_SETTINGS_LOGX86CODE: { - uState = GetMenuState(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND); - - if (uState & MFS_CHECKED) + bool Checked = (GetMenuState(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND) & MFS_CHECKED) != 0; + CheckMenuItem(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | (Checked ? MFS_UNCHECKED : MFS_CHECKED)); + SetSetting(Set_LogX86Code, !Checked); + if (DebuggingEnabled) { - CheckMenuItem(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | MFS_UNCHECKED); - SetSetting(Set_LogX86Code, false); - if (DebuggingEnabled) + LogX86Code = !Checked; + if (LogX86Code) { - LogX86Code = false; - StopCPULog(); + StartCPULog(); } - } - else - { - CheckMenuItem(hRSPMenu, ID_SETTINGS_LOGX86CODE, MF_BYCOMMAND | MFS_CHECKED); - SetSetting(Set_LogX86Code, true); - if (DebuggingEnabled) + else { - LogX86Code = true; - StartCPULog(); + StopCPULog(); } } + break; } - break; case ID_CPUMETHOD_RECOMPILER: - { SetSetting(Set_CPUCore, RecompilerCPU); g_CPUCore = RecompilerCPU; FixMenuState(); SetCPU(RecompilerCPU); break; - } case ID_CPUMETHOD_INTERPT: - { SetSetting(Set_CPUCore, InterpreterCPU); g_CPUCore = InterpreterCPU; FixMenuState(); SetCPU(InterpreterCPU); break; } - } } #endif @@ -719,6 +659,7 @@ EXPORT void EnableDebugging(int Enabled) if (DebuggingEnabled) { BreakOnStart = GetSetting(Set_BreakOnStart) != 0; + AccurateEmulation = GetSetting(Set_AccurateEmulation) != 0; g_CPUCore = (RSPCpuType)GetSetting(Set_CPUCore); LogRDP = GetSetting(Set_LogRDP) != 0; LogX86Code = GetSetting(Set_LogX86Code) != 0; diff --git a/Source/Project64-rsp/Project64-rsp.rc b/Source/Project64-rsp/Project64-rsp.rc index ffc55ad359..ef1a0cba1f 100644 --- a/Source/Project64-rsp/Project64-rsp.rc +++ b/Source/Project64-rsp/Project64-rsp.rc @@ -192,6 +192,7 @@ BEGIN BEGIN MENUITEM "Show Compiler Errors", ID_SHOWCOMPILERERRORS MENUITEM "Break on start of task", ID_BREAKONSTARTOFTASK + MENUITEM "Accurate Emulation", ID_ACCURATEEMULATION MENUITEM "Log RDP Commands", ID_LOGRDPCOMMANDS MENUITEM "Log X86 code", ID_SETTINGS_LOGX86CODE END diff --git a/Source/Project64-rsp/resource.h b/Source/Project64-rsp/resource.h index 783663bcb9..0767b659ca 100644 --- a/Source/Project64-rsp/resource.h +++ b/Source/Project64-rsp/resource.h @@ -37,13 +37,14 @@ #define ID_CPUMETHOD_RECOMPILER 5016 #define ID_CPUMETHOD_INTERPT 5017 #define ID_SETTINGS_LOGX86CODE 5019 +#define ID_ACCURATEEMULATION 5020 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 108 -#define _APS_NEXT_COMMAND_VALUE 5020 +#define _APS_NEXT_COMMAND_VALUE 5021 #define _APS_NEXT_CONTROL_VALUE 1032 #define _APS_NEXT_SYMED_VALUE 101 #endif