From 0c8b10bbc759955a259e2e5bd4f94eb1bd23af25 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 9 Nov 2023 11:53:06 +1030 Subject: [PATCH] Android: Get RSP core to compile on android --- .gitignore | 2 + Android/Script/UpdateVersionNumber.cmd | 1 + Android/app/build.gradle | 2 + Android/jni/Plugin-Rsp/CMakeLists.txt | 8 +- Android/jni/Project64-bridge/CMakeLists.txt | 3 +- Android/jni/Project64-core/CMakeLists.txt | 3 +- Android/jni/Project64-rsp-core/.gitignore | 2 + Android/jni/Project64-rsp-core/CMakeLists.txt | 40 +++- Android/settings.gradle | 2 +- Source/Project64-rsp-core/RSPDebugger.h | 18 +- Source/Project64-rsp-core/Recompiler/Mmx.cpp | 20 +- .../Recompiler/RspProfiling.cpp | 15 +- .../Recompiler/RspRecompilerCPU.cpp | 10 +- .../Recompiler/RspRecompilerOps.cpp | 40 ++-- .../Recompiler/RspRecompilerSections.cpp | 16 +- Source/Project64-rsp-core/Recompiler/Sse.cpp | 10 +- Source/Project64-rsp-core/Recompiler/X86.cpp | 176 +++++++++-------- Source/Project64-rsp-core/Recompiler/X86.h | 180 +++++++++--------- .../Settings/RspSettings.cpp | 3 +- .../Project64-rsp-core/Settings/RspSettings.h | 2 +- Source/Project64-rsp-core/cpu/RSPCpu.h | 2 + .../cpu/RSPInterpreterOps.cpp | 2 +- Source/Project64-rsp-core/cpu/RSPRegister.cpp | 4 +- Source/Project64-rsp-core/cpu/RSPRegisters.h | 4 +- Source/Project64-rsp-core/cpu/RspLog.cpp | 18 +- 25 files changed, 324 insertions(+), 259 deletions(-) diff --git a/.gitignore b/.gitignore index 781123efc..457c15dab 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,8 @@ Thumbs.db /Plugin/RSP/RSP_d 1.7.dll /Plugin/RSP/RSP-HLE_d.dll /Plugin/RSP/RSP-HLE.dll +/Plugin/RSP/Project64-RSP-Basic_d.dll +/Plugin/RSP/Project64-RSP-Basic.dll /Plugin64/AndroidAudio /Plugin64/Audio/AndroidAudio_d.dll /Plugin64/Audio/AndroidAudio.dll diff --git a/Android/Script/UpdateVersionNumber.cmd b/Android/Script/UpdateVersionNumber.cmd index 86fae3a55..c3e10e536 100644 --- a/Android/Script/UpdateVersionNumber.cmd +++ b/Android/Script/UpdateVersionNumber.cmd @@ -8,6 +8,7 @@ cd /d %origdir% "%base_dir%\Android\Script\UpdateVersion.exe" "%base_dir%\Android\config\version.gradle.in" "%base_dir%\Android\config\version.gradle" "%base_dir%\Android\Script\UpdateVersion.exe" "%base_dir%\Source\Project64-core\Version.h.in" "%base_dir%\Source\Project64-core\Version.h" +"%base_dir%\Android\Script\UpdateVersion.exe" "%base_dir%\Source\Project64-rsp-core\Version.h.in" "%base_dir%\Source\Project64-rsp-core\Version.h" "%base_dir%\Android\Script\UpdateVersion.exe" "%base_dir%\Source\Project64-audio\Version.h.in" "%base_dir%\Source\Project64-audio\Version.h" "%base_dir%\Android\Script\UpdateVersion.exe" "%base_dir%\Source\Project64-video\Version.h.in" "%base_dir%\Source\Project64-video\Version.h" "%base_dir%\Android\Script\UpdateVersion.exe" "%base_dir%\Source\RSP\Version.h.in" "%base_dir%\Source\RSP\Version.h" diff --git a/Android/app/build.gradle b/Android/app/build.gradle index 3305f9d58..d64985ebb 100644 --- a/Android/app/build.gradle +++ b/Android/app/build.gradle @@ -39,9 +39,11 @@ dependencies { implementation project(':jni:3rdParty:zlib') implementation project(':jni:Common') implementation project(':jni:Settings') + implementation project(':jni:Project64-rsp-core') implementation project(':jni:Project64-core') implementation project(':jni:Project64-bridge') implementation project(':jni:Project64-video') implementation project(':jni:Project64-audio') implementation project(':jni:Plugin-input') + implementation project(':jni:Plugin-rsp') } diff --git a/Android/jni/Plugin-Rsp/CMakeLists.txt b/Android/jni/Plugin-Rsp/CMakeLists.txt index ab26d81ad..cfb0de33b 100644 --- a/Android/jni/Plugin-Rsp/CMakeLists.txt +++ b/Android/jni/Plugin-Rsp/CMakeLists.txt @@ -2,13 +2,15 @@ cmake_minimum_required(VERSION 2.8.12) set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_STANDARD 99) -project("Project64-rsp") +project("Plugin-rsp") include_directories(..) -add_library(Project64-rsp SHARED +add_library(Plugin-rsp SHARED main.cpp) add_definitions(-DANDROID) +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../Common ${CMAKE_CURRENT_BINARY_DIR}/Common) +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../Project64-rsp-core ${CMAKE_CURRENT_BINARY_DIR}/Project64-rsp-core) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../Settings ${CMAKE_CURRENT_BINARY_DIR}/Settings) -target_link_libraries(Project64-rsp settings) +target_link_libraries(Plugin-rsp Project64-rsp-core settings Common) diff --git a/Android/jni/Project64-bridge/CMakeLists.txt b/Android/jni/Project64-bridge/CMakeLists.txt index 689157498..706e6a892 100644 --- a/Android/jni/Project64-bridge/CMakeLists.txt +++ b/Android/jni/Project64-bridge/CMakeLists.txt @@ -20,5 +20,6 @@ add_definitions(-DANDROID) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/asmjit ${CMAKE_CURRENT_BINARY_DIR}/3rdParty/asmjit) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/zlib ${CMAKE_CURRENT_BINARY_DIR}/3rdParty/zlib) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../Common ${CMAKE_CURRENT_BINARY_DIR}/Common) +ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../Project64-rsp-core ${CMAKE_CURRENT_BINARY_DIR}/Project64-rsp-core) ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../Project64-core ${CMAKE_CURRENT_BINARY_DIR}/Project64-core) -target_link_libraries(Project64-bridge asmjit zlib Project64-core Common log) +target_link_libraries(Project64-bridge asmjit zlib Project64-rsp-core Project64-core Common log) diff --git a/Android/jni/Project64-core/CMakeLists.txt b/Android/jni/Project64-core/CMakeLists.txt index f592db5c0..4a135ba6a 100644 --- a/Android/jni/Project64-core/CMakeLists.txt +++ b/Android/jni/Project64-core/CMakeLists.txt @@ -106,8 +106,7 @@ add_library(Project64-core STATIC Settings/SettingType/SettingsType-TempString.cpp Settings/DebugSettings.cpp Settings/GameSettings.cpp - Settings/N64SystemSettings.cpp - ../Project64-rsp-core/cpu/RSPRegisterHandler.cpp) + Settings/N64SystemSettings.cpp) add_definitions(-DANDROID) diff --git a/Android/jni/Project64-rsp-core/.gitignore b/Android/jni/Project64-rsp-core/.gitignore index 0805ff6de..e4185ddc0 100644 --- a/Android/jni/Project64-rsp-core/.gitignore +++ b/Android/jni/Project64-rsp-core/.gitignore @@ -1,3 +1,5 @@ +/.cxx +/build *.c *.cpp *.h diff --git a/Android/jni/Project64-rsp-core/CMakeLists.txt b/Android/jni/Project64-rsp-core/CMakeLists.txt index de5de383b..cef1afdac 100644 --- a/Android/jni/Project64-rsp-core/CMakeLists.txt +++ b/Android/jni/Project64-rsp-core/CMakeLists.txt @@ -2,11 +2,43 @@ cmake_minimum_required(VERSION 2.8.12) set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_STANDARD 99) -project("Project64.rsp.core") +project("Project64-rsp-core") -add_library(Project64.rsp.core STATIC - Hle/alist.cpp) +add_library(Project64-rsp-core STATIC + cpu/RspClamp.cpp + cpu/RSPCpu.cpp + cpu/RSPiInstruction.cpp + cpu/RSPInterpreterCPU.cpp + cpu/RSPInterpreterOps.cpp + cpu/RspLog.cpp + cpu/RspMemory.cpp + cpu/RSPRegister.cpp + cpu/RSPRegisterHandler.cpp + cpu/RSPRegisterHandlerPlugin.cpp + cpu/RspTypes.cpp + Hle/alist.cpp + Hle/alist_audio.cpp + Hle/alist_naudio.cpp + Hle/alist_nead.cpp + Hle/audio.cpp + Hle/cicx105.cpp + Hle/hle.cpp + Hle/jpeg.cpp + Hle/mem.cpp + Hle/mp3.cpp + Hle/musyx.cpp + Recompiler/Mmx.cpp + Recompiler/RspProfiling.cpp + Recompiler/RspRecompilerAnalysis.cpp + Recompiler/RspRecompilerCPU.cpp + Recompiler/RspRecompilerOps.cpp + Recompiler/RspRecompilerSections.cpp + Recompiler/Sse.cpp + Recompiler/X86.cpp + Settings/RspSettings.cpp + RSPDebugger.cpp + RSPInfo.cpp) add_definitions(-DANDROID) -target_link_libraries(Project64.rsp.core) +target_link_libraries(Project64-rsp-core) diff --git a/Android/settings.gradle b/Android/settings.gradle index ef6194156..7625f8a8e 100644 --- a/Android/settings.gradle +++ b/Android/settings.gradle @@ -1,2 +1,2 @@ rootProject.name = 'Project64' -include ':app', ':jni:3rdParty:asmjit', ':jni:3rdParty:png', ':jni:3rdParty:zlib', ':jni:Common', ':jni:Settings', ':jni:Project64-core', ':jni:Project64-bridge', ':jni:Project64-video', ':jni:Project64-audio', ':jni:Plugin-input' +include ':app', ':jni:3rdParty:asmjit', ':jni:3rdParty:png', ':jni:3rdParty:zlib', ':jni:Common', ':jni:Settings', ':jni:Project64-rsp-core', ':jni:Project64-core', ':jni:Project64-bridge', ':jni:Project64-video', ':jni:Project64-audio', ':jni:Plugin-input', ':jni:Plugin-rsp' diff --git a/Source/Project64-rsp-core/RSPDebugger.h b/Source/Project64-rsp-core/RSPDebugger.h index 265542b1e..e16dca633 100644 --- a/Source/Project64-rsp-core/RSPDebugger.h +++ b/Source/Project64-rsp-core/RSPDebugger.h @@ -1,15 +1,19 @@ #pragma once #include +#if !defined(_WIN32) && !defined(__interface) +#define __interface struct +#endif + __interface RSPDebugger { - void ResetTimerList(void) = 0; - void StartingCPU(void) = 0; - void RspCyclesStart(void) = 0; - void RspCyclesStop(void) = 0; - void BeforeExecuteOp(void) = 0; - void UnknownOpcode(void) = 0; - void RDP_LogMF0(uint32_t PC, uint32_t Reg) = 0; + virtual void ResetTimerList(void) = 0; + virtual void StartingCPU(void) = 0; + virtual void RspCyclesStart(void) = 0; + virtual void RspCyclesStop(void) = 0; + virtual void BeforeExecuteOp(void) = 0; + virtual void UnknownOpcode(void) = 0; + virtual void RDP_LogMF0(uint32_t PC, uint32_t Reg) = 0; }; extern RSPDebugger * g_RSPDebugger; diff --git a/Source/Project64-rsp-core/Recompiler/Mmx.cpp b/Source/Project64-rsp-core/Recompiler/Mmx.cpp index 67f60f21b..e22676576 100644 --- a/Source/Project64-rsp-core/Recompiler/Mmx.cpp +++ b/Source/Project64-rsp-core/Recompiler/Mmx.cpp @@ -1,4 +1,4 @@ -#include "x86.h" +#include "X86.h" #include #include #include @@ -60,7 +60,7 @@ void MmxMoveRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxMoveQwordVariableToReg(int Dest, void * Variable, char * VariableName) +void MmxMoveQwordVariableToReg(int Dest, void * Variable, const char * VariableName) { uint8_t x86Command = 0; @@ -83,7 +83,7 @@ void MmxMoveQwordVariableToReg(int Dest, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void MmxMoveQwordRegToVariable(int Dest, void * Variable, char * VariableName) +void MmxMoveQwordRegToVariable(int Dest, void * Variable, const char * VariableName) { uint8_t x86Command = 0; @@ -138,7 +138,7 @@ void MmxPorRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxPorVariableToReg(void * Variable, char * VariableName, int Dest) +void MmxPorVariableToReg(void * Variable, const char * VariableName, int Dest) { uint8_t x86Command = 0; @@ -193,7 +193,7 @@ void MmxPandRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxPandVariableToReg(void * Variable, char * VariableName, int Dest) +void MmxPandVariableToReg(void * Variable, const char * VariableName, int Dest) { uint8_t x86Command = 0; @@ -280,7 +280,7 @@ void MmxXorRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxShuffleMemoryToReg(int Dest, void * Variable, char * VariableName, uint8_t Immed) +void MmxShuffleMemoryToReg(int Dest, void * Variable, const char * VariableName, uint8_t Immed) { uint8_t x86Command = 0; @@ -368,7 +368,7 @@ void MmxPmullwRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxPmullwVariableToReg(int Dest, void * Variable, char * VariableName) +void MmxPmullwVariableToReg(int Dest, void * Variable, const char * VariableName) { uint8_t x86Command = 0; @@ -454,7 +454,7 @@ void MmxPmulhwRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxPmulhwRegToVariable(int Dest, void * Variable, char * VariableName) +void MmxPmulhwRegToVariable(int Dest, void * Variable, const char * VariableName) { uint8_t x86Command = 0; @@ -609,7 +609,7 @@ void MmxPsubswRegToReg(int Dest, int Source) PUTDST8(RecompPos, 0xC0 | x86Command); } -void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName) +void MmxPaddswVariableToReg(int Dest, void * Variable, const char * VariableName) { uint8_t x86Command = 0; @@ -632,7 +632,7 @@ void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName) +void MmxPsubswVariableToReg(int Dest, void * Variable, const char * VariableName) { uint8_t x86Command = 0; diff --git a/Source/Project64-rsp-core/Recompiler/RspProfiling.cpp b/Source/Project64-rsp-core/Recompiler/RspProfiling.cpp index 89c4b4fe9..91d5cc2f5 100644 --- a/Source/Project64-rsp-core/Recompiler/RspProfiling.cpp +++ b/Source/Project64-rsp-core/Recompiler/RspProfiling.cpp @@ -5,12 +5,13 @@ #include #include #include +#include #include #include class CRspProfiling { - typedef std::map PROFILE_ENRTIES; + typedef std::map PROFILE_ENRTIES; typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY; typedef PROFILE_ENRTIES::value_type PROFILE_VALUE; typedef struct @@ -47,7 +48,7 @@ public: m_StartTimeHi = HiValue; m_StartTimeLo = LoValue; #else - __debugbreak(); + g_Notify->BreakPoint(__FILE__, __LINE__); #endif return OldTimerAddr; } @@ -68,9 +69,9 @@ public: popad } - __int64 StopTime = ((unsigned __int64)HiValue << 32) + (unsigned __int64)LoValue; - __int64 StartTime = ((unsigned __int64)m_StartTimeHi << 32) + (unsigned __int64)m_StartTimeLo; - __int64 TimeTaken = StopTime - StartTime; + int64_t StopTime = ((uint64_t)HiValue << 32) + (uint64_t)LoValue; + int64_t StartTime = ((uint64_t)m_StartTimeHi << 32) + (uint64_t)m_StartTimeLo; + int64_t TimeTaken = StopTime - StartTime; PROFILE_ENRTY Entry = m_Entries.find(m_CurrentTimerAddr); if (Entry != m_Entries.end()) @@ -82,7 +83,7 @@ public: m_Entries.insert(PROFILE_ENRTIES::value_type(m_CurrentTimerAddr, TimeTaken)); } #else - __debugbreak(); + g_Notify->BreakPoint(__FILE__, __LINE__); #endif uint32_t OldTimerAddr = m_CurrentTimerAddr; @@ -106,7 +107,7 @@ public: LogFileName = Log.FileName(); // Get the total time - __int64 TotalTime = 0; + int64_t TotalTime = 0; for (PROFILE_ENRTY itemTime = m_Entries.begin(); itemTime != m_Entries.end(); itemTime++) { TotalTime += itemTime->second; diff --git a/Source/Project64-rsp-core/Recompiler/RspRecompilerCPU.cpp b/Source/Project64-rsp-core/Recompiler/RspRecompilerCPU.cpp index a6b4961b3..e77c7222d 100644 --- a/Source/Project64-rsp-core/Recompiler/RspRecompilerCPU.cpp +++ b/Source/Project64-rsp-core/Recompiler/RspRecompilerCPU.cpp @@ -1,7 +1,7 @@ #include "RspRecompilerCPU.h" #include "RspProfiling.h" #include "RspRecompilerOps.h" -#include "x86.h" +#include "X86.h" #include #include #include @@ -791,7 +791,7 @@ void CompilerRSPBlock(void) // Align the block to a boundary if (X86BaseAddress & 7) { - register size_t Count; + size_t Count; const size_t Padding = (8 - (X86BaseAddress & 7)) & 7; for (Count = 0; Count < Padding; Count++) @@ -864,7 +864,7 @@ void CompilerRSPBlock(void) char str[40]; sprintf(str, "%X", CompilePC); PushImm32(str, CompilePC); - Call_Direct(RDP_LogLoc, "RDP_LogLoc"); + Call_Direct((void *)RDP_LogLoc, "RDP_LogLoc"); AddConstToX86Reg(x86_ESP, 4); } @@ -1003,7 +1003,7 @@ uint32_t RunRecompilerCPU(uint32_t Cycles) popad } #else - __debugbreak(); + g_Notify->BreakPoint(__FILE__, __LINE__); #endif if (Profiling && IndvidualBlock) { @@ -1020,7 +1020,7 @@ uint32_t RunRecompilerCPU(uint32_t Cycles) #if defined(_M_IX86) && defined(_MSC_VER) _asm emms #else - __debugbreak(); + g_Notify->BreakPoint(__FILE__, __LINE__); #endif } return Cycles; diff --git a/Source/Project64-rsp-core/Recompiler/RspRecompilerOps.cpp b/Source/Project64-rsp-core/Recompiler/RspRecompilerOps.cpp index 4d149061d..e068892ca 100644 --- a/Source/Project64-rsp-core/Recompiler/RspRecompilerOps.cpp +++ b/Source/Project64-rsp-core/Recompiler/RspRecompilerOps.cpp @@ -1,7 +1,7 @@ #include "Project64-rsp-core/Recompiler/RspRecompilerCPU.h" #include "RspProfiling.h" #include "RspRecompilerCPU.h" -#include "x86.h" +#include "X86.h" #include #include #include @@ -112,17 +112,17 @@ void Branch_AddRef(uint32_t Target, uint32_t * X86Loc) } } -void Cheat_r4300iOpcode(p_func FunctAddress, char * FunctName) +void Cheat_r4300iOpcode(p_func FunctAddress, const char * FunctName) { CPU_Message(" %X %s", CompilePC, RSPInstruction(CompilePC, RSPOpC.Value).NameAndParam().c_str()); MoveConstToVariable(RSPOpC.Value, &RSPOpC.Value, "RSPOpC.Value"); - Call_Direct(FunctAddress, FunctName); + Call_Direct((void *)FunctAddress, FunctName); } -void Cheat_r4300iOpcodeNoMessage(p_func FunctAddress, char * FunctName) +void Cheat_r4300iOpcodeNoMessage(p_func FunctAddress, const char * FunctName) { MoveConstToVariable(RSPOpC.Value, &RSPOpC.Value, "RSPOpC.Value"); - Call_Direct(FunctAddress, FunctName); + Call_Direct((void *)FunctAddress, FunctName); } void x86_SetBranch8b(void * JumpByte, void * Destination) @@ -225,7 +225,7 @@ void Compile_JAL(void) sprintf(Str, "%03X", (RSPOpC.target << 2) & 0xFFC); Push(x86_EAX); PushImm32(Str, *PrgCount); - Call_Direct(StartTimer, "StartTimer"); + Call_Direct((void *)StartTimer, "StartTimer"); AddConstToX86Reg(x86_ESP, 4); Pop(x86_EAX); } @@ -1450,7 +1450,7 @@ void Compile_Special_JR(void) { Push(x86_EAX); Push(x86_EAX); - Call_Direct(StartTimer, "StartTimer"); + Call_Direct((void *)StartTimer, "StartTimer"); AddConstToX86Reg(x86_ESP, 4); Pop(x86_EAX); } @@ -1464,7 +1464,7 @@ void Compile_Special_JR(void) // Before we branch quickly update our stats /*if (CompilePC == 0x080) { Pushad(); - Call_Direct(UpdateAudioTimer, "UpdateAudioTimer"); + Call_Direct((void *)UpdateAudioTimer, "UpdateAudioTimer"); Popad(); }*/ JumpX86Reg(x86_EAX); @@ -2083,7 +2083,7 @@ void Compile_Cop0_MF(void) PushImm32(str, RSPOpC.rd); sprintf(str, "%X", CompilePC); PushImm32(str, CompilePC); - Call_Direct(RDP_LogMF0, "RDP_LogMF0"); + Call_Direct((void *)RDP_LogMF0, "RDP_LogMF0"); AddConstToX86Reg(x86_ESP, 8); } @@ -2105,7 +2105,7 @@ void Compile_Cop0_MF(void) BreakPoint(); } return; -#else +#elif defined(_M_IX86) && defined(_MSC_VER) switch (RSPOpC.rd) { case 0: @@ -2186,6 +2186,8 @@ void Compile_Cop0_MF(void) default: g_Notify->DisplayError(stdstr_f("We have not implemented RSP MF CP0 reg %s (%d)", COP0_Name(RSPOpC.rd), RSPOpC.rd).c_str()); } +#else + g_Notify->BreakPoint(__FILE__, __LINE__); #endif } @@ -2203,7 +2205,7 @@ void Compile_Cop0_MT(void) PushImm32(str, RSPOpC.rd); sprintf(str, "%X", CompilePC); PushImm32(str, CompilePC); - Call_Direct(RDP_LogMT0, "RDP_LogMT0"); + Call_Direct((void *)RDP_LogMT0, "RDP_LogMT0"); AddConstToX86Reg(x86_ESP, 12); } @@ -2227,7 +2229,7 @@ void Compile_Cop0_MT(void) BreakPoint(); } } -#else +#elif defined(_M_IX86) && defined(_MSC_VER) switch (RSPOpC.rd) { case 0: @@ -2294,7 +2296,7 @@ void Compile_Cop0_MT(void) if (LogRDP) { - Call_Direct(RDP_LogDlist, "RDP_LogDlist"); + Call_Direct((void *)RDP_LogDlist, "RDP_LogDlist"); } if (RSPInfo.ProcessRdpList != NULL) @@ -2302,14 +2304,14 @@ void Compile_Cop0_MT(void) if (Profiling) { PushImm32("Timer_RDP_Running", (uint32_t)Timer_RDP_Running); - Call_Direct(StartTimer, "StartTimer"); + Call_Direct((void *)StartTimer, "StartTimer"); AddConstToX86Reg(x86_ESP, 4); Push(x86_EAX); } - Call_Direct(RSPInfo.ProcessRdpList, "ProcessRdpList"); + Call_Direct((void *)RSPInfo.ProcessRdpList, "ProcessRdpList"); if (Profiling) { - Call_Direct(StartTimer, "StartTimer"); + Call_Direct((void *)StartTimer, "StartTimer"); AddConstToX86Reg(x86_ESP, 4); } } @@ -2324,6 +2326,8 @@ void Compile_Cop0_MT(void) Cheat_r4300iOpcode(RSP_Cop0_MT, "RSP_Cop0_MT"); break; } +#else +g_Notify->BreakPoint(__FILE__, __LINE__); #endif if (RSPOpC.rd == 2 && !ChangedPC) { @@ -4875,7 +4879,7 @@ void Compile_Vector_VGE(void) { /* bool bWriteToAccum = WriteToAccum(Low16BitAccum, CompilePC); - /* TODO: works ok, but needs careful flag analysis */ + TODO: works ok, but needs careful flag analysis */ /* #if defined (DLIST) if (bWriteToAccum == false && true == Compile_Vector_VGE_MMX()) { return; @@ -7178,6 +7182,6 @@ void Compile_UnknownOpcode(void) NextInstruction = RSPPIPELINE_FINISH_BLOCK; MoveConstToVariable(CompilePC, PrgCount, "RSP PC"); MoveConstToVariable(RSPOpC.Value, &RSPOpC.Value, "RSPOpC.Value"); - Call_Direct(rsp_UnknownOpcode, "rsp_UnknownOpcode"); + Call_Direct((void *)rsp_UnknownOpcode, "rsp_UnknownOpcode"); Ret(); } diff --git a/Source/Project64-rsp-core/Recompiler/RspRecompilerSections.cpp b/Source/Project64-rsp-core/Recompiler/RspRecompilerSections.cpp index f7ffee3be..4a634b8a8 100644 --- a/Source/Project64-rsp-core/Recompiler/RspRecompilerSections.cpp +++ b/Source/Project64-rsp-core/Recompiler/RspRecompilerSections.cpp @@ -1,5 +1,5 @@ #include "RspRecompilerCPU.h" -#include "x86.h" +#include "X86.h" #include #include #include @@ -892,7 +892,7 @@ void Compile_Section_000(void) char str[40]; sprintf(str, "%X", CompilePC); PushImm32(str, CompilePC); - Call_Direct(RDP_LogLoc, "RDP_LogLoc"); + Call_Direct((void *)RDP_LogLoc, "RDP_LogLoc"); AddConstToX86Reg(x86_ESP, 4); } @@ -906,7 +906,7 @@ void Compile_Section_000(void) char str[40]; sprintf(str, "%X", CompilePC + 0x04 + (i * 4)); PushImm32(str, CompilePC + 0x04 + (i * 4)); - Call_Direct(RDP_LogLoc, "RDP_LogLoc"); + Call_Direct((void *)RDP_LogLoc, "RDP_LogLoc"); AddConstToX86Reg(x86_ESP, 4); } } @@ -1129,7 +1129,7 @@ void Compile_Section_002(void) char str[40]; sprintf(str, "%X", CompilePC + (Count * 0x04)); PushImm32(str, CompilePC + (Count * 0x04)); - Call_Direct(RDP_LogLoc, "RDP_LogLoc"); + Call_Direct((void *)RDP_LogLoc, "RDP_LogLoc"); AddConstToX86Reg(x86_ESP, 4); } } @@ -1192,10 +1192,10 @@ static void resampler_hle() { UDWORD accum, initial; uint32_t const2 = (uint32_t)RSP_Vect[18].u16(4 ^ 7); - __int64 const3 = (__int64)((int)RSP_Vect[30].s16(0 ^ 7)) << 16; + int64_t const3 = (int64_t)((int)RSP_Vect[30].s16(0 ^ 7)) << 16; // VMUDM $v23, $v31, $v23 [7] - initial.DW = (__int64)((uint32_t)RSP_Vect[23].u16(7 ^ 7)) << 16; + initial.DW = (int64_t)((uint32_t)RSP_Vect[23].u16(7 ^ 7)) << 16; // VMADH $v23, $v31, $v22 [7] initial.W[1] += (int)RSP_Vect[22].s16(7 ^ 7); @@ -1204,7 +1204,7 @@ static void resampler_hle() accum.DW = initial.DW; // VMADM $v22, $v25, $v18 [4] - accum.DW += (__int64)((int)RSP_Vect[25].s16(i) * const2) << 16; + accum.DW += (int64_t)((int)RSP_Vect[25].s16(i) * const2) << 16; if (accum.W[1] > 0x7FFF) { RSP_Vect[22].s16(i) = 0x7FFF; @@ -1238,7 +1238,7 @@ static void resampler_hle() void Compile_Section_003(void) { CPU_Message("Compiling: %X to ..., RSP optimization $003", CompilePC); - Call_Direct(resampler_hle, "Resampler_HLE"); + Call_Direct((void *)resampler_hle, "Resampler_HLE"); CompilePC += 4 * sizeof(RSPOpcode); } diff --git a/Source/Project64-rsp-core/Recompiler/Sse.cpp b/Source/Project64-rsp-core/Recompiler/Sse.cpp index e65f43d73..e85684347 100644 --- a/Source/Project64-rsp-core/Recompiler/Sse.cpp +++ b/Source/Project64-rsp-core/Recompiler/Sse.cpp @@ -1,4 +1,4 @@ -#include "x86.h" +#include "X86.h" #include #include #include @@ -30,7 +30,7 @@ char * sse_Strings[8] = { #define sse_Name(Reg) (sse_Strings[(Reg)]) -void SseMoveAlignedVariableToReg(void * Variable, char * VariableName, int sseReg) +void SseMoveAlignedVariableToReg(void * Variable, const char * VariableName, int sseReg) { uint8_t x86Command = 0; @@ -87,7 +87,7 @@ void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg) PUTDSTPTR(RecompPos, RSPInfo.DMEM); } -void SseMoveAlignedRegToVariable(int sseReg, void * Variable, char * VariableName) +void SseMoveAlignedRegToVariable(int sseReg, void * Variable, const char * VariableName) { uint8_t x86Command = 0; @@ -144,7 +144,7 @@ void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg) PUTDSTPTR(RecompPos, RSPInfo.DMEM); } -void SseMoveUnalignedVariableToReg(void * Variable, char * VariableName, int sseReg) +void SseMoveUnalignedVariableToReg(void * Variable, const char * VariableName, int sseReg) { uint8_t x86Command = 0; @@ -201,7 +201,7 @@ void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg) PUTDSTPTR(RecompPos, RSPInfo.DMEM); } -void SseMoveUnalignedRegToVariable(int sseReg, void * Variable, char * VariableName) +void SseMoveUnalignedRegToVariable(int sseReg, void * Variable, const char * VariableName) { uint8_t x86Command = 0; diff --git a/Source/Project64-rsp-core/Recompiler/X86.cpp b/Source/Project64-rsp-core/Recompiler/X86.cpp index 5cf821b78..f1defbd07 100644 --- a/Source/Project64-rsp-core/Recompiler/X86.cpp +++ b/Source/Project64-rsp-core/Recompiler/X86.cpp @@ -1,6 +1,6 @@ #include -#include "x86.h" +#include "X86.h" #include #include #include @@ -24,15 +24,15 @@ *(void **)(dest) = (void *)(value); \ dest += sizeof(void *); -char * x86_Strings[8] = { +const char * x86_Strings[8] = { "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp"}; -char * x86_ByteStrings[8] = { +const char * x86_ByteStrings[8] = { "al", "bl", "cl", "dl", "?4", "?5", "?6", "?7"}; -char * x86_HalfStrings[8] = { +const char * x86_HalfStrings[8] = { "ax", "bx", "cx", "dx", "si", "di", "bp", "sp"}; @@ -71,7 +71,7 @@ void AdcX86RegToX86Reg(int Destination, int Source) PUTDST16(RecompPos, x86Command); } -void AdcX86regToVariable(int x86reg, void * Variable, char * VariableName) +void AdcX86regToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" adc dword ptr [%s], %s", VariableName, x86_Name(x86reg)); switch (x86reg) @@ -90,7 +90,7 @@ void AdcX86regToVariable(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void AdcX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) +void AdcX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" adc word ptr [%s], %s", VariableName, x86Half_Name(x86reg)); @@ -111,7 +111,7 @@ void AdcX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void AdcConstToVariable(void * Variable, char * VariableName, uint8_t Constant) +void AdcConstToVariable(void * Variable, const char * VariableName, uint8_t Constant) { CPU_Message(" adc dword ptr [%s], %Xh", VariableName, Constant); PUTDST16(RecompPos, 0x1583); @@ -138,7 +138,7 @@ void AdcConstToX86reg(uint8_t Constant, int x86reg) PUTDST8(RecompPos, Constant); } -void AddConstToVariable(uint32_t Const, void * Variable, char * VariableName) +void AddConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" add dword ptr [%s], 0x%X", VariableName, Const); PUTDST16(RecompPos, 0x0581); @@ -186,7 +186,7 @@ void AddConstToX86Reg(int x86Reg, size_t Const) } } -void AdcConstHalfToVariable(void * Variable, char * VariableName, uint8_t Constant) +void AdcConstHalfToVariable(void * Variable, const char * VariableName, uint8_t Constant) { CPU_Message(" adc word ptr [%s], %Xh", VariableName, Constant); @@ -199,7 +199,7 @@ void AdcConstHalfToVariable(void * Variable, char * VariableName, uint8_t Consta PUTDST8(RecompPos, Constant); } -void AddVariableToX86reg(int x86reg, void * Variable, char * VariableName) +void AddVariableToX86reg(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" add %s, dword ptr [%s]", x86_Name(x86reg), VariableName); switch (x86reg) @@ -218,7 +218,7 @@ void AddVariableToX86reg(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void AddX86regToVariable(int x86reg, void * Variable, char * VariableName) +void AddX86regToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" add dword ptr [%s], %s", VariableName, x86_Name(x86reg)); switch (x86reg) @@ -237,7 +237,7 @@ void AddX86regToVariable(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void AddX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) +void AddX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" add word ptr [%s], %s", VariableName, x86Half_Name(x86reg)); @@ -289,7 +289,7 @@ void AddX86RegToX86Reg(int Destination, int Source) PUTDST16(RecompPos, x86Command); } -void AndConstToVariable(uint32_t Const, void * Variable, char * VariableName) +void AndConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" and dword ptr [%s], 0x%X", VariableName, Const); PUTDST16(RecompPos, 0x2581); @@ -332,7 +332,7 @@ void AndConstToX86Reg(int x86Reg, uint32_t Const) } } -void AndVariableToX86Reg(void * Variable, char * VariableName, int x86Reg) +void AndVariableToX86Reg(void * Variable, const char * VariableName, int x86Reg) { CPU_Message(" and %s, dword ptr [%s]", x86_Name(x86Reg), VariableName); switch (x86Reg) @@ -349,7 +349,7 @@ void AndVariableToX86Reg(void * Variable, char * VariableName, int x86Reg) PUTDSTPTR(RecompPos, Variable); } -void AndVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) +void AndVariableToX86regHalf(void * Variable, const char * VariableName, int x86Reg) { CPU_Message(" and %s, word ptr [%s]", x86Half_Name(x86Reg), VariableName); PUTDST8(RecompPos, 0x66); @@ -367,7 +367,7 @@ void AndVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) PUTDSTPTR(RecompPos, Variable); } -void AndX86RegToVariable(void * Variable, char * VariableName, int x86Reg) +void AndX86RegToVariable(void * Variable, const char * VariableName, int x86Reg) { CPU_Message(" and dword ptr [%s], %s", VariableName, x86_Name(x86Reg)); switch (x86Reg) @@ -460,7 +460,7 @@ void X86BreakPoint(const char * FileName, int LineNumber) #else g_Notify->DisplayError("PushImm64\nUnimplemented."); #endif - Call_Direct(BreakPointNotification, "BreakPointNotification"); + Call_Direct((void *)BreakPointNotification, "BreakPointNotification"); AddConstToX86Reg(x86_ESP, 8); Popad(); CPU_Message(" int 3"); @@ -500,14 +500,14 @@ void BsrX86RegToX86Reg(int Destination, int Source) PUTDST8(RecompPos, x86Command); } -void Call_Direct(void * FunctAddress, char * FunctName) +void Call_Direct(void * FunctAddress, const char * FunctName) { CPU_Message(" call offset %s", FunctName); PUTDST8(RecompPos, 0xE8); PUTDSTPTR(RecompPos, (size_t)FunctAddress - (size_t)RecompPos - sizeof(void *)); } -void Call_Indirect(void * FunctAddress, char * FunctName) +void Call_Indirect(void * FunctAddress, const char * FunctName) { CPU_Message(" call [%s]", FunctName); PUTDST16(RecompPos, 0x15FF); @@ -802,7 +802,7 @@ void CondMoveLessEqual(int Destination, int Source) } } -void CompConstToVariable(uint32_t Const, void * Variable, char * VariableName) +void CompConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" cmp dword ptr [%s], 0x%X", VariableName, Const); PUTDST16(RecompPos, 0x3D81); @@ -810,7 +810,7 @@ void CompConstToVariable(uint32_t Const, void * Variable, char * VariableName) PUTDST32(RecompPos, Const); } -void CompConstHalfToVariable(uint16_t Const, void * Variable, char * VariableName) +void CompConstHalfToVariable(uint16_t Const, void * Variable, const char * VariableName) { CPU_Message(" cmp word ptr [%s], 0x%X", VariableName, Const); PUTDST8(RecompPos, 0x66); @@ -858,7 +858,7 @@ void CompConstToX86reg(int x86Reg, uint32_t Const) } } -void CompX86regToVariable(int x86Reg, void * Variable, char * VariableName) +void CompX86regToVariable(int x86Reg, void * Variable, const char * VariableName) { CPU_Message(" cmp %s, dword ptr [%s]", x86_Name(x86Reg), VariableName); switch (x86Reg) @@ -877,7 +877,7 @@ void CompX86regToVariable(int x86Reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void CompVariableToX86reg(int x86Reg, void * Variable, char * VariableName) +void CompVariableToX86reg(int x86Reg, void * Variable, const char * VariableName) { CPU_Message(" cmp dword ptr [%s], %s", VariableName, x86_Name(x86Reg)); switch (x86Reg) @@ -1061,105 +1061,105 @@ void IncX86reg(int x86Reg) } } -void JaeLabel32(char * Label, uint32_t Value) +void JaeLabel32(const char * Label, uint32_t Value) { CPU_Message(" jae $%s", Label); PUTDST16(RecompPos, 0x830F); PUTDST32(RecompPos, Value); } -void JaLabel8(char * Label, uint8_t Value) +void JaLabel8(const char * Label, uint8_t Value) { CPU_Message(" ja $%s", Label); PUTDST8(RecompPos, 0x77); PUTDST8(RecompPos, Value); } -void JaLabel32(char * Label, uint32_t Value) +void JaLabel32(const char * Label, uint32_t Value) { CPU_Message(" ja $%s", Label); PUTDST16(RecompPos, 0x870F); PUTDST32(RecompPos, Value); } -void JbLabel8(char * Label, uint8_t Value) +void JbLabel8(const char * Label, uint8_t Value) { CPU_Message(" jb $%s", Label); PUTDST8(RecompPos, 0x72); PUTDST8(RecompPos, Value); } -void JbLabel32(char * Label, uint32_t Value) +void JbLabel32(const char * Label, uint32_t Value) { CPU_Message(" jb $%s", Label); PUTDST16(RecompPos, 0x820F); PUTDST32(RecompPos, Value); } -void JeLabel8(char * Label, uint8_t Value) +void JeLabel8(const char * Label, uint8_t Value) { CPU_Message(" je $%s", Label); PUTDST8(RecompPos, 0x74); PUTDST8(RecompPos, Value); } -void JeLabel32(char * Label, uint32_t Value) +void JeLabel32(const char * Label, uint32_t Value) { CPU_Message(" je $%s", Label); PUTDST16(RecompPos, 0x840F); PUTDST32(RecompPos, Value); } -void JgeLabel8(char * Label, uint8_t Value) +void JgeLabel8(const char * Label, uint8_t Value) { CPU_Message(" jge $%s", Label); PUTDST8(RecompPos, 0x7D); PUTDST8(RecompPos, Value); } -void JgeLabel32(char * Label, uint32_t Value) +void JgeLabel32(const char * Label, uint32_t Value) { CPU_Message(" jge $%s", Label); PUTDST16(RecompPos, 0x8D0F); PUTDST32(RecompPos, Value); } -void JgLabel8(char * Label, uint8_t Value) +void JgLabel8(const char * Label, uint8_t Value) { CPU_Message(" jg $%s", Label); PUTDST8(RecompPos, 0x7F); PUTDST8(RecompPos, Value); } -void JgLabel32(char * Label, uint32_t Value) +void JgLabel32(const char * Label, uint32_t Value) { CPU_Message(" jg $%s", Label); PUTDST16(RecompPos, 0x8F0F); PUTDST32(RecompPos, Value); } -void JleLabel8(char * Label, uint8_t Value) +void JleLabel8(const char * Label, uint8_t Value) { CPU_Message(" jle $%s", Label); PUTDST8(RecompPos, 0x7E); PUTDST8(RecompPos, Value); } -void JleLabel32(char * Label, uint32_t Value) +void JleLabel32(const char * Label, uint32_t Value) { CPU_Message(" jle $%s", Label); PUTDST16(RecompPos, 0x8E0F); PUTDST32(RecompPos, Value); } -void JlLabel8(char * Label, uint8_t Value) +void JlLabel8(const char * Label, uint8_t Value) { CPU_Message(" jl $%s", Label); PUTDST8(RecompPos, 0x7C); PUTDST8(RecompPos, Value); } -void JlLabel32(char * Label, uint32_t Value) +void JlLabel32(const char * Label, uint32_t Value) { CPU_Message(" jl $%s", Label); PUTDST16(RecompPos, 0x8C0F); @@ -1182,49 +1182,49 @@ void JumpX86Reg(int x86reg) } } -void JmpLabel8(char * Label, uint8_t Value) +void JmpLabel8(const char * Label, uint8_t Value) { CPU_Message(" jmp $%s", Label); PUTDST8(RecompPos, 0xEB); PUTDST8(RecompPos, Value); } -void JmpLabel32(char * Label, uint32_t Value) +void JmpLabel32(const char * Label, uint32_t Value) { CPU_Message(" jmp $%s", Label); PUTDST8(RecompPos, 0xE9); PUTDST32(RecompPos, Value); } -void JneLabel8(char * Label, uint8_t Value) +void JneLabel8(const char * Label, uint8_t Value) { CPU_Message(" jne $%s", Label); PUTDST8(RecompPos, 0x75); PUTDST8(RecompPos, Value); } -void JneLabel32(char * Label, uint32_t Value) +void JneLabel32(const char * Label, uint32_t Value) { CPU_Message(" jne $%s", Label); PUTDST16(RecompPos, 0x850F); PUTDST32(RecompPos, Value); } -void JnsLabel8(char * Label, uint8_t Value) +void JnsLabel8(const char * Label, uint8_t Value) { CPU_Message(" jns $%s", Label); PUTDST8(RecompPos, 0x79); PUTDST8(RecompPos, Value); } -void JnsLabel32(char * Label, uint32_t Value) +void JnsLabel32(const char * Label, uint32_t Value) { CPU_Message(" jns $%s", Label); PUTDST16(RecompPos, 0x890F); PUTDST32(RecompPos, Value); } -void JsLabel32(char * Label, uint32_t Value) +void JsLabel32(const char * Label, uint32_t Value) { CPU_Message(" js $%s", Label); PUTDST16(RecompPos, 0x880F); @@ -1300,7 +1300,11 @@ void MoveConstByteToN64Mem(uint8_t Const, int AddrReg) } PUTDST16(RecompPos, x86Command); +#if defined(_M_IX86) && defined(_MSC_VER) PUTDST32(RecompPos, RSPInfo.DMEM); +#else + g_Notify->BreakPoint(__FILE__, __LINE__); +#endif PUTDST8(RecompPos, Const); } @@ -1325,11 +1329,15 @@ void MoveConstHalfToN64Mem(uint16_t Const, int AddrReg) } PUTDST8(RecompPos, x86Command); +#if defined(_M_IX86) && defined(_MSC_VER) PUTDST32(RecompPos, RSPInfo.DMEM); +#else + g_Notify->BreakPoint(__FILE__, __LINE__); +#endif PUTDST16(RecompPos, Const); } -void MoveConstByteToVariable(uint8_t Const, void * Variable, char * VariableName) +void MoveConstByteToVariable(uint8_t Const, void * Variable, const char * VariableName) { CPU_Message(" mov byte ptr [%s], %Xh", VariableName, Const); PUTDST16(RecompPos, 0x05C6); @@ -1337,7 +1345,7 @@ void MoveConstByteToVariable(uint8_t Const, void * Variable, char * VariableName PUTDST8(RecompPos, Const); } -void MoveConstHalfToVariable(uint16_t Const, void * Variable, char * VariableName) +void MoveConstHalfToVariable(uint16_t Const, void * Variable, const char * VariableName) { CPU_Message(" mov word ptr [%s], %Xh", VariableName, Const); PUTDST8(RecompPos, 0x66); @@ -1366,11 +1374,15 @@ void MoveConstToN64Mem(uint32_t Const, int AddrReg) } PUTDST16(RecompPos, x86Command); +#if defined(_M_IX86) && defined(_MSC_VER) PUTDST32(RecompPos, RSPInfo.DMEM); +#else + g_Notify->BreakPoint(__FILE__, __LINE__); +#endif PUTDST32(RecompPos, Const); } -void MoveConstToVariable(uint32_t Const, void * Variable, char * VariableName) +void MoveConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" mov dword ptr [%s], %Xh", VariableName, Const); PUTDST16(RecompPos, 0x05C7); @@ -1397,7 +1409,7 @@ void MoveConstToX86reg(uint32_t Const, int x86reg) PUTDST32(RecompPos, Const); } -void MoveOffsetToX86reg(size_t Const, char * VariableName, int x86reg) +void MoveOffsetToX86reg(size_t Const, const char * VariableName, int x86reg) { CPU_Message(" mov %s, offset %s", x86_Name(x86reg), VariableName); switch (x86reg) @@ -1940,7 +1952,7 @@ void MoveX86regToN64MemDisp(int x86reg, int AddrReg, uint8_t Disp) PUTDSTPTR(RecompPos, RSPInfo.DMEM + Disp); } -void MoveVariableToX86reg(void * Variable, char * VariableName, int x86reg) +void MoveVariableToX86reg(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" mov %s, dword ptr [%s]", x86_Name(x86reg), VariableName); switch (x86reg) @@ -1958,7 +1970,7 @@ void MoveVariableToX86reg(void * Variable, char * VariableName, int x86reg) PUTDSTPTR(RecompPos, Variable); } -void MoveVariableToX86regByte(void * Variable, char * VariableName, int x86reg) +void MoveVariableToX86regByte(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" mov %s, byte ptr [%s]", x86Byte_Name(x86reg), VariableName); switch (x86reg) @@ -1972,7 +1984,7 @@ void MoveVariableToX86regByte(void * Variable, char * VariableName, int x86reg) PUTDSTPTR(RecompPos, Variable); } -void MoveVariableToX86regHalf(void * Variable, char * VariableName, int x86reg) +void MoveVariableToX86regHalf(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" mov %s, word ptr [%s]", x86Half_Name(x86reg), VariableName); PUTDST8(RecompPos, 0x66); @@ -1991,7 +2003,7 @@ void MoveVariableToX86regHalf(void * Variable, char * VariableName, int x86reg) PUTDSTPTR(RecompPos, Variable); } -void MoveX86regByteToVariable(int x86reg, void * Variable, char * VariableName) +void MoveX86regByteToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" mov byte ptr [%s], %s", VariableName, x86Byte_Name(x86reg)); switch (x86reg) @@ -2006,7 +2018,7 @@ void MoveX86regByteToVariable(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void MoveX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) +void MoveX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" mov word ptr [%s], %s", VariableName, x86Half_Name(x86reg)); PUTDST8(RecompPos, 0x66); @@ -2026,7 +2038,7 @@ void MoveX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void MoveX86regToVariable(int x86reg, void * Variable, char * VariableName) +void MoveX86regToVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" mov dword ptr [%s], %s", VariableName, x86_Name(x86reg)); switch (x86reg) @@ -2144,7 +2156,7 @@ void MoveSxX86RegPtrDispToX86RegHalf(int AddrReg, uint8_t Disp, int Destination) PUTDST8(RecompPos, Disp); } -void MoveSxVariableToX86regByte(void * Variable, char * VariableName, int x86reg) +void MoveSxVariableToX86regByte(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" movsx %s, byte ptr [%s]", x86_Name(x86reg), VariableName); @@ -2165,7 +2177,7 @@ void MoveSxVariableToX86regByte(void * Variable, char * VariableName, int x86reg PUTDSTPTR(RecompPos, Variable); } -void MoveSxVariableToX86regHalf(void * Variable, char * VariableName, int x86reg) +void MoveSxVariableToX86regHalf(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" movsx %s, word ptr [%s]", x86_Name(x86reg), VariableName); @@ -2318,7 +2330,7 @@ void MoveZxX86RegPtrDispToX86RegHalf(int AddrReg, uint8_t Disp, int Destination) PUTDST8(RecompPos, Disp); } -void MoveZxVariableToX86regByte(void * Variable, char * VariableName, int x86reg) +void MoveZxVariableToX86regByte(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" movzx %s, byte ptr [%s]", x86_Name(x86reg), VariableName); @@ -2339,7 +2351,7 @@ void MoveZxVariableToX86regByte(void * Variable, char * VariableName, int x86reg PUTDSTPTR(RecompPos, Variable); } -void MoveZxVariableToX86regHalf(void * Variable, char * VariableName, int x86reg) +void MoveZxVariableToX86regHalf(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" movzx %s, word ptr [%s]", x86_Name(x86reg), VariableName); @@ -2479,7 +2491,7 @@ void NotX86reg(int x86reg) } } -void OrConstToVariable(uint32_t Const, void * Variable, char * VariableName) +void OrConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" or dword ptr [%s], 0x%X", VariableName, Const); PUTDST16(RecompPos, 0x0D81); @@ -2522,7 +2534,7 @@ void OrConstToX86Reg(uint32_t Const, int x86Reg) } } -void OrVariableToX86Reg(void * Variable, char * VariableName, int x86Reg) +void OrVariableToX86Reg(void * Variable, const char * VariableName, int x86Reg) { CPU_Message(" or %s, dword ptr [%s]", x86_Name(x86Reg), VariableName); switch (x86Reg) @@ -2539,7 +2551,7 @@ void OrVariableToX86Reg(void * Variable, char * VariableName, int x86Reg) PUTDSTPTR(RecompPos, Variable); } -void OrVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) +void OrVariableToX86regHalf(void * Variable, const char * VariableName, int x86Reg) { CPU_Message(" or %s, word ptr [%s]", x86Half_Name(x86Reg), VariableName); PUTDST8(RecompPos, 0x66); @@ -2557,7 +2569,7 @@ void OrVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) PUTDSTPTR(RecompPos, Variable); } -void OrX86RegToVariable(void * Variable, char * VariableName, int x86Reg) +void OrX86RegToVariable(void * Variable, const char * VariableName, int x86Reg) { CPU_Message(" or dword ptr [%s], %s", VariableName, x86_Name(x86Reg)); switch (x86Reg) @@ -2650,7 +2662,7 @@ void Pop(int x86reg) } } -void PushImm32(char * String, uint32_t Value) +void PushImm32(const char * String, uint32_t Value) { CPU_Message(" push %s", String); PUTDST8(RecompPos, 0x68); @@ -2678,7 +2690,7 @@ void Setl(int x86reg) } } -void SetlVariable(void * Variable, char * VariableName) +void SetlVariable(void * Variable, const char * VariableName) { CPU_Message(" setl byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x9C0F); @@ -2686,7 +2698,7 @@ void SetlVariable(void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void SetleVariable(void * Variable, char * VariableName) +void SetleVariable(void * Variable, const char * VariableName) { CPU_Message(" setle byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x9E0F); @@ -2709,7 +2721,7 @@ void Setb(int x86reg) } } -void SetbVariable(void * Variable, char * VariableName) +void SetbVariable(void * Variable, const char * VariableName) { CPU_Message(" setb byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x920F); @@ -2732,7 +2744,7 @@ void Setg(int x86reg) } } -void SetgVariable(void * Variable, char * VariableName) +void SetgVariable(void * Variable, const char * VariableName) { CPU_Message(" setg byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x9F0F); @@ -2740,7 +2752,7 @@ void SetgVariable(void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void SetgeVariable(void * Variable, char * VariableName) +void SetgeVariable(void * Variable, const char * VariableName) { CPU_Message(" setge byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x9D0F); @@ -2763,7 +2775,7 @@ void Seta(int x86reg) } } -void SetaVariable(void * Variable, char * VariableName) +void SetaVariable(void * Variable, const char * VariableName) { CPU_Message(" seta byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x970F); @@ -2801,7 +2813,7 @@ void Setz(int x86reg) } } -void SetzVariable(void * Variable, char * VariableName) +void SetzVariable(void * Variable, const char * VariableName) { CPU_Message(" setz byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x940F); @@ -2824,7 +2836,7 @@ void Setnz(int x86reg) } } -void SetnzVariable(void * Variable, char * VariableName) +void SetnzVariable(void * Variable, const char * VariableName) { CPU_Message(" setnz byte ptr [%s]", VariableName); PUTDST16(RecompPos, 0x950F); @@ -2935,7 +2947,7 @@ void ShiftLeftSignImmed(int x86reg, uint8_t Immediate) PUTDST8(RecompPos, Immediate); } -void ShiftLeftSignVariableImmed(void * Variable, char * VariableName, uint8_t Immediate) +void ShiftLeftSignVariableImmed(void * Variable, const char * VariableName, uint8_t Immediate) { CPU_Message(" shl dword ptr [%s], %Xh", VariableName, Immediate); @@ -2963,7 +2975,7 @@ void ShiftRightSignImmed(int x86reg, uint8_t Immediate) PUTDST8(RecompPos, Immediate); } -void ShiftRightSignVariableImmed(void * Variable, char * VariableName, uint8_t Immediate) +void ShiftRightSignVariableImmed(void * Variable, const char * VariableName, uint8_t Immediate) { CPU_Message(" sar dword ptr [%s], %Xh", VariableName, Immediate); @@ -3005,7 +3017,7 @@ void ShiftRightUnsignImmed(int x86reg, uint8_t Immediate) PUTDST8(RecompPos, Immediate); } -void ShiftRightUnsignVariableImmed(void * Variable, char * VariableName, uint8_t Immediate) +void ShiftRightUnsignVariableImmed(void * Variable, const char * VariableName, uint8_t Immediate) { CPU_Message(" shr dword ptr [%s], %Xh", VariableName, Immediate); @@ -3014,7 +3026,7 @@ void ShiftRightUnsignVariableImmed(void * Variable, char * VariableName, uint8_t PUTDST8(RecompPos, Immediate); } -void SubConstFromVariable(uint32_t Const, void * Variable, char * VariableName) +void SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" sub dword ptr [%s], 0x%X", VariableName, Const); PUTDST16(RecompPos, 0x2D81); @@ -3057,7 +3069,7 @@ void SubConstFromX86Reg(int x86Reg, uint32_t Const) } } -void SubVariableFromX86reg(int x86reg, void * Variable, char * VariableName) +void SubVariableFromX86reg(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" sub %s, dword ptr [%s]", x86_Name(x86reg), VariableName); switch (x86reg) @@ -3076,7 +3088,7 @@ void SubVariableFromX86reg(int x86reg, void * Variable, char * VariableName) PUTDSTPTR(RecompPos, Variable); } -void SubX86regFromVariable(int x86reg, void * Variable, char * VariableName) +void SubX86regFromVariable(int x86reg, void * Variable, const char * VariableName) { CPU_Message(" sub dword ptr [%s], %s", VariableName, x86_Name(x86reg)); switch (x86reg) @@ -3153,7 +3165,7 @@ void SbbX86RegToX86Reg(int Destination, int Source) PUTDST16(RecompPos, x86Command); } -void TestConstToVariable(uint32_t Const, void * Variable, char * VariableName) +void TestConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CPU_Message(" test dword ptr [%s], 0x%X", VariableName, Const); PUTDST16(RecompPos, 0x05F7); @@ -3244,7 +3256,7 @@ void XorConstToX86Reg(int x86Reg, uint32_t Const) } } -void XorConstToVariable(void * Variable, char * VariableName, uint32_t Const) +void XorConstToVariable(void * Variable, const char * VariableName, uint32_t Const) { CPU_Message(" xor dword ptr [%s], 0x%X", VariableName, Const); @@ -3285,7 +3297,7 @@ void XorX86RegToX86Reg(int Source, int Destination) PUTDST16(RecompPos, x86Command); } -void XorVariableToX86reg(void * Variable, char * VariableName, int x86reg) +void XorVariableToX86reg(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" xor %s, dword ptr [%s]", x86_Name(x86reg), VariableName); switch (x86reg) @@ -3303,7 +3315,7 @@ void XorVariableToX86reg(void * Variable, char * VariableName, int x86reg) PUTDSTPTR(RecompPos, Variable); } -void XorX86RegToVariable(void * Variable, char * VariableName, int x86reg) +void XorX86RegToVariable(void * Variable, const char * VariableName, int x86reg) { CPU_Message(" xor dword ptr [%s], %s", VariableName, x86_Name(x86reg)); switch (x86reg) diff --git a/Source/Project64-rsp-core/Recompiler/X86.h b/Source/Project64-rsp-core/Recompiler/X86.h index f2e585b94..ac2fcef6e 100644 --- a/Source/Project64-rsp-core/Recompiler/X86.h +++ b/Source/Project64-rsp-core/Recompiler/X86.h @@ -38,39 +38,39 @@ enum sseRegValues }; void AdcX86RegToX86Reg(int Destination, int Source); -void AdcX86regToVariable(int x86reg, void * Variable, char * VariableName); -void AdcX86regHalfToVariable(int x86reg, void * Variable, char * VariableName); +void AdcX86regToVariable(int x86reg, void * Variable, const char * VariableName); +void AdcX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName); void AdcConstToX86reg(uint8_t Constant, int x86reg); -void AdcConstToVariable(void * Variable, char * VariableName, uint8_t Constant); -void AdcConstHalfToVariable(void * Variable, char * VariableName, uint8_t Constant); -void AddConstToVariable(uint32_t Const, void * Variable, char * VariableName); +void AdcConstToVariable(void * Variable, const char * VariableName, uint8_t Constant); +void AdcConstHalfToVariable(void * Variable, const char * VariableName, uint8_t Constant); +void AddConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void AddConstToX86Reg(int x86Reg, size_t Const); -void AddVariableToX86reg(int x86reg, void * Variable, char * VariableName); -void AddX86regToVariable(int x86reg, void * Variable, char * VariableName); -void AddX86regHalfToVariable(int x86reg, void * Variable, char * VariableName); +void AddVariableToX86reg(int x86reg, void * Variable, const char * VariableName); +void AddX86regToVariable(int x86reg, void * Variable, const char * VariableName); +void AddX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName); void AddX86RegToX86Reg(int Destination, int Source); -void AndConstToVariable(uint32_t Const, void * Variable, char * VariableName); +void AndConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void AndConstToX86Reg(int x86Reg, uint32_t Const); -void AndVariableToX86Reg(void * Variable, char * VariableName, int x86Reg); -void AndVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg); -void AndX86RegToVariable(void * Variable, char * VariableName, int x86Reg); +void AndVariableToX86Reg(void * Variable, const char * VariableName, int x86Reg); +void AndVariableToX86regHalf(void * Variable, const char * VariableName, int x86Reg); +void AndX86RegToVariable(void * Variable, const char * VariableName, int x86Reg); void AndX86RegToX86Reg(int Destination, int Source); void AndX86RegHalfToX86RegHalf(int Destination, int Source); void X86BreakPoint(const char * FileName, int LineNumber); void BsrX86RegToX86Reg(int Destination, int Source); -void Call_Direct(void * FunctAddress, char * FunctName); -void Call_Indirect(void * FunctAddress, char * FunctName); +void Call_Direct(void * FunctAddress, const char * FunctName); +void Call_Indirect(void * FunctAddress, const char * FunctName); void CondMoveEqual(int Destination, int Source); void CondMoveNotEqual(int Destination, int Source); void CondMoveGreater(int Destination, int Source); void CondMoveGreaterEqual(int Destination, int Source); void CondMoveLess(int Destination, int Source); void CondMoveLessEqual(int Destination, int Source); -void CompConstToVariable(uint32_t Const, void * Variable, char * VariableName); -void CompConstHalfToVariable(uint16_t Const, void * Variable, char * VariableName); +void CompConstToVariable(uint32_t Const, void * Variable, const char * VariableName); +void CompConstHalfToVariable(uint16_t Const, void * Variable, const char * VariableName); void CompConstToX86reg(int x86Reg, uint32_t Const); -void CompX86regToVariable(int x86Reg, void * Variable, char * VariableName); -void CompVariableToX86reg(int x86Reg, void * Variable, char * VariableName); +void CompX86regToVariable(int x86Reg, void * Variable, const char * VariableName); +void CompVariableToX86reg(int x86Reg, void * Variable, const char * VariableName); void CompX86RegToX86Reg(int Destination, int Source); void Cwd(void); void Cwde(void); @@ -80,39 +80,39 @@ void idivX86reg(int x86reg); void imulX86reg(int x86reg); void ImulX86RegToX86Reg(int Destination, int Source); void IncX86reg(int x86Reg); -void JaeLabel32(char * Label, uint32_t Value); -void JaLabel8(char * Label, uint8_t Value); -void JaLabel32(char * Label, uint32_t Value); -void JbLabel8(char * Label, uint8_t Value); -void JbLabel32(char * Label, uint32_t Value); -void JeLabel8(char * Label, uint8_t Value); -void JeLabel32(char * Label, uint32_t Value); -void JgeLabel8(char * Label, uint8_t Value); -void JgeLabel32(char * Label, uint32_t Value); -void JgLabel8(char * Label, uint8_t Value); -void JgLabel32(char * Label, uint32_t Value); -void JleLabel8(char * Label, uint8_t Value); -void JleLabel32(char * Label, uint32_t Value); -void JlLabel8(char * Label, uint8_t Value); -void JlLabel32(char * Label, uint32_t Value); +void JaeLabel32(const char * Label, uint32_t Value); +void JaLabel8(const char * Label, uint8_t Value); +void JaLabel32(const char * Label, uint32_t Value); +void JbLabel8(const char * Label, uint8_t Value); +void JbLabel32(const char * Label, uint32_t Value); +void JeLabel8(const char * Label, uint8_t Value); +void JeLabel32(const char * Label, uint32_t Value); +void JgeLabel8(const char * Label, uint8_t Value); +void JgeLabel32(const char * Label, uint32_t Value); +void JgLabel8(const char * Label, uint8_t Value); +void JgLabel32(const char * Label, uint32_t Value); +void JleLabel8(const char * Label, uint8_t Value); +void JleLabel32(const char * Label, uint32_t Value); +void JlLabel8(const char * Label, uint8_t Value); +void JlLabel32(const char * Label, uint32_t Value); void JumpX86Reg(int x86reg); -void JmpLabel8(char * Label, uint8_t Value); -void JmpLabel32(char * Label, uint32_t Value); -void JneLabel8(char * Label, uint8_t Value); -void JneLabel32(char * Label, uint32_t Value); -void JnsLabel8(char * Label, uint8_t Value); -void JnsLabel32(char * Label, uint32_t Value); -void JsLabel32(char * Label, uint32_t Value); +void JmpLabel8(const char * Label, uint8_t Value); +void JmpLabel32(const char * Label, uint32_t Value); +void JneLabel8(const char * Label, uint8_t Value); +void JneLabel32(const char * Label, uint32_t Value); +void JnsLabel8(const char * Label, uint8_t Value); +void JnsLabel32(const char * Label, uint32_t Value); +void JsLabel32(const char * Label, uint32_t Value); void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, size_t offset); void MoveConstByteToN64Mem(uint8_t Const, int AddrReg); void MoveConstHalfToN64Mem(uint16_t Const, int AddrReg); -void MoveConstByteToVariable(uint8_t Const, void * Variable, char * VariableName); -void MoveConstHalfToVariable(uint16_t Const, void * Variable, char * VariableName); +void MoveConstByteToVariable(uint8_t Const, void * Variable, const char * VariableName); +void MoveConstHalfToVariable(uint16_t Const, void * Variable, const char * VariableName); void MoveConstToN64Mem(uint32_t Const, int AddrReg); void MoveConstToN64MemDisp(uint32_t Const, int AddrReg, uint8_t Disp); -void MoveConstToVariable(uint32_t Const, void * Variable, char * VariableName); +void MoveConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void MoveConstToX86reg(uint32_t Const, int x86reg); -void MoveOffsetToX86reg(size_t Const, char * VariableName, int x86reg); +void MoveOffsetToX86reg(size_t Const, const char * VariableName, int x86reg); void MoveX86regByteToX86regPointer(int Source, int AddrReg); void MoveX86regHalfToX86regPointer(int Source, int AddrReg); void MoveX86regHalfToX86regPointerDisp(int Source, int AddrReg, uint8_t Disp); @@ -126,42 +126,42 @@ void MoveN64MemToX86reg(int x86reg, int AddrReg); void MoveN64MemToX86regByte(int x86reg, int AddrReg); void MoveN64MemToX86regHalf(int x86reg, int AddrReg); void MoveX86regByteToN64Mem(int x86reg, int AddrReg); -void MoveX86regByteToVariable(int x86reg, void * Variable, char * VariableName); +void MoveX86regByteToVariable(int x86reg, void * Variable, const char * VariableName); void MoveX86regHalfToN64Mem(int x86reg, int AddrReg); -void MoveX86regHalfToVariable(int x86reg, void * Variable, char * VariableName); +void MoveX86regHalfToVariable(int x86reg, void * Variable, const char * VariableName); void MoveX86regToN64Mem(int x86reg, int AddrReg); void MoveX86regToN64MemDisp(int x86reg, int AddrReg, uint8_t Disp); -void MoveX86regToVariable(int x86reg, void * Variable, char * VariableName); +void MoveX86regToVariable(int x86reg, void * Variable, const char * VariableName); void MoveX86RegToX86Reg(int Source, int Destination); -void MoveVariableToX86reg(void * Variable, char * VariableName, int x86reg); -void MoveVariableToX86regByte(void * Variable, char * VariableName, int x86reg); -void MoveVariableToX86regHalf(void * Variable, char * VariableName, int x86reg); +void MoveVariableToX86reg(void * Variable, const char * VariableName, int x86reg); +void MoveVariableToX86regByte(void * Variable, const char * VariableName, int x86reg); +void MoveVariableToX86regHalf(void * Variable, const char * VariableName, int x86reg); void MoveSxX86RegHalfToX86Reg(int Source, int Destination); void MoveSxX86RegPtrDispToX86RegHalf(int AddrReg, uint8_t Disp, int Destination); void MoveSxN64MemToX86regByte(int x86reg, int AddrReg); void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg); -void MoveSxVariableToX86regByte(void * Variable, char * VariableName, int x86reg); -void MoveSxVariableToX86regHalf(void * Variable, char * VariableName, int x86reg); +void MoveSxVariableToX86regByte(void * Variable, const char * VariableName, int x86reg); +void MoveSxVariableToX86regHalf(void * Variable, const char * VariableName, int x86reg); void MoveZxX86RegHalfToX86Reg(int Source, int Destination); void MoveZxX86RegPtrDispToX86RegHalf(int AddrReg, uint8_t Disp, int Destination); void MoveZxN64MemToX86regByte(int x86reg, int AddrReg); void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg); -void MoveZxVariableToX86regByte(void * Variable, char * VariableName, int x86reg); -void MoveZxVariableToX86regHalf(void * Variable, char * VariableName, int x86reg); +void MoveZxVariableToX86regByte(void * Variable, const char * VariableName, int x86reg); +void MoveZxVariableToX86regHalf(void * Variable, const char * VariableName, int x86reg); void MulX86reg(int x86reg); void NegateX86reg(int x86reg); void NotX86reg(int x86reg); -void OrConstToVariable(uint32_t Const, void * Variable, char * VariableName); +void OrConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void OrConstToX86Reg(uint32_t Const, int x86Reg); -void OrVariableToX86Reg(void * Variable, char * VariableName, int x86Reg); -void OrVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg); -void OrX86RegToVariable(void * Variable, char * VariableName, int x86Reg); +void OrVariableToX86Reg(void * Variable, const char * VariableName, int x86Reg); +void OrVariableToX86regHalf(void * Variable, const char * VariableName, int x86Reg); +void OrX86RegToVariable(void * Variable, const char * VariableName, int x86Reg); void OrX86RegToX86Reg(int Destination, int Source); void Popad(void); void Pushad(void); void Push(int x86reg); void Pop(int x86reg); -void PushImm32(char * String, uint32_t Value); +void PushImm32(const char * String, uint32_t Value); void Ret(void); void Seta(int x86reg); void Setae(int x86reg); @@ -170,65 +170,65 @@ void Setb(int x86reg); void Setg(int x86reg); void Setz(int x86reg); void Setnz(int x86reg); -void SetlVariable(void * Variable, char * VariableName); -void SetleVariable(void * Variable, char * VariableName); -void SetgVariable(void * Variable, char * VariableName); -void SetgeVariable(void * Variable, char * VariableName); -void SetbVariable(void * Variable, char * VariableName); -void SetaVariable(void * Variable, char * VariableName); -void SetzVariable(void * Variable, char * VariableName); -void SetnzVariable(void * Variable, char * VariableName); +void SetlVariable(void * Variable, const char * VariableName); +void SetleVariable(void * Variable, const char * VariableName); +void SetgVariable(void * Variable, const char * VariableName); +void SetgeVariable(void * Variable, const char * VariableName); +void SetbVariable(void * Variable, const char * VariableName); +void SetaVariable(void * Variable, const char * VariableName); +void SetzVariable(void * Variable, const char * VariableName); +void SetnzVariable(void * Variable, const char * VariableName); void ShiftLeftSign(int x86reg); void ShiftLeftSignImmed(int x86reg, uint8_t Immediate); -void ShiftLeftSignVariableImmed(void * Variable, char * VariableName, uint8_t Immediate); +void ShiftLeftSignVariableImmed(void * Variable, const char * VariableName, uint8_t Immediate); void ShiftRightSignImmed(int x86reg, uint8_t Immediate); -void ShiftRightSignVariableImmed(void * Variable, char * VariableName, uint8_t Immediate); +void ShiftRightSignVariableImmed(void * Variable, const char * VariableName, uint8_t Immediate); void ShiftRightUnsign(int x86reg); void ShiftRightUnsignImmed(int x86reg, uint8_t Immediate); -void ShiftRightUnsignVariableImmed(void * Variable, char * VariableName, uint8_t Immediate); +void ShiftRightUnsignVariableImmed(void * Variable, const char * VariableName, uint8_t Immediate); void ShiftLeftDoubleImmed(int Destination, int Source, uint8_t Immediate); void ShiftRightDoubleImmed(int Destination, int Source, uint8_t Immediate); -void SubConstFromVariable(uint32_t Const, void * Variable, char * VariableName); +void SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName); void SubConstFromX86Reg(int x86Reg, uint32_t Const); -void SubVariableFromX86reg(int x86reg, void * Variable, char * VariableName); +void SubVariableFromX86reg(int x86reg, void * Variable, const char * VariableName); void SubX86RegToX86Reg(int Destination, int Source); -void SubX86regFromVariable(int x86reg, void * Variable, char * VariableName); +void SubX86regFromVariable(int x86reg, void * Variable, const char * VariableName); void SbbX86RegToX86Reg(int Destination, int Source); -void TestConstToVariable(uint32_t Const, void * Variable, char * VariableName); +void TestConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void TestConstToX86Reg(uint32_t Const, int x86reg); void TestX86RegToX86Reg(int Destination, int Source); void XorConstToX86Reg(int x86Reg, uint32_t Const); void XorX86RegToX86Reg(int Source, int Destination); -void XorVariableToX86reg(void * Variable, char * VariableName, int x86reg); -void XorX86RegToVariable(void * Variable, char * VariableName, int x86reg); -void XorConstToVariable(void * Variable, char * VariableName, uint32_t Const); +void XorVariableToX86reg(void * Variable, const char * VariableName, int x86reg); +void XorX86RegToVariable(void * Variable, const char * VariableName, int x86reg); +void XorConstToVariable(void * Variable, const char * VariableName, uint32_t Const); #define _MMX_SHUFFLE(a, b, c, d) \ ((uint8_t)(((a) << 6) | ((b) << 4) | ((c) << 2) | (d))) void MmxMoveRegToReg(int Dest, int Source); -void MmxMoveQwordRegToVariable(int Dest, void * Variable, char * VariableName); -void MmxMoveQwordVariableToReg(int Dest, void * Variable, char * VariableName); +void MmxMoveQwordRegToVariable(int Dest, void * Variable, const char * VariableName); +void MmxMoveQwordVariableToReg(int Dest, void * Variable, const char * VariableName); void MmxPandRegToReg(int Dest, int Source); void MmxPandnRegToReg(int Dest, int Source); -void MmxPandVariableToReg(void * Variable, char * VariableName, int Dest); +void MmxPandVariableToReg(void * Variable, const char * VariableName, int Dest); void MmxPorRegToReg(int Dest, int Source); -void MmxPorVariableToReg(void * Variable, char * VariableName, int Dest); +void MmxPorVariableToReg(void * Variable, const char * VariableName, int Dest); void MmxXorRegToReg(int Dest, int Source); -void MmxShuffleMemoryToReg(int Dest, void * Variable, char * VariableName, uint8_t Immed); +void MmxShuffleMemoryToReg(int Dest, void * Variable, const char * VariableName, uint8_t Immed); void MmxPcmpeqwRegToReg(int Dest, int Source); void MmxPmullwRegToReg(int Dest, int Source); -void MmxPmullwVariableToReg(int Dest, void * Variable, char * VariableName); +void MmxPmullwVariableToReg(int Dest, void * Variable, const char * VariableName); void MmxPmulhuwRegToReg(int Dest, int Source); void MmxPmulhwRegToReg(int Dest, int Source); -void MmxPmulhwRegToVariable(int Dest, void * Variable, char * VariableName); +void MmxPmulhwRegToVariable(int Dest, void * Variable, const char * VariableName); void MmxPsrlwImmed(int Dest, uint8_t Immed); void MmxPsrawImmed(int Dest, uint8_t Immed); void MmxPsllwImmed(int Dest, uint8_t Immed); void MmxPaddswRegToReg(int Dest, int Source); -void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName); +void MmxPaddswVariableToReg(int Dest, void * Variable, const char * VariableName); void MmxPaddwRegToReg(int Dest, int Source); -void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName); +void MmxPsubswVariableToReg(int Dest, void * Variable, const char * VariableName); void MmxPsubswRegToReg(int Dest, int Source); void MmxPackSignedDwords(int Dest, int Source); void MmxUnpackLowWord(int Dest, int Source); @@ -236,12 +236,12 @@ void MmxUnpackHighWord(int Dest, int Source); void MmxCompareGreaterWordRegToReg(int Dest, int Source); void MmxEmptyMultimediaState(void); -void SseMoveAlignedVariableToReg(void * Variable, char * VariableName, int sseReg); -void SseMoveAlignedRegToVariable(int sseReg, void * Variable, char * VariableName); +void SseMoveAlignedVariableToReg(void * Variable, const char * VariableName, int sseReg); +void SseMoveAlignedRegToVariable(int sseReg, void * Variable, const char * VariableName); void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg); void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg); -void SseMoveUnalignedVariableToReg(void * Variable, char * VariableName, int sseReg); -void SseMoveUnalignedRegToVariable(int sseReg, void * Variable, char * VariableName); +void SseMoveUnalignedVariableToReg(void * Variable, const char * VariableName, int sseReg); +void SseMoveUnalignedRegToVariable(int sseReg, void * Variable, const char * VariableName); void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg); void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg); void SseMoveRegToReg(int Dest, int Source); diff --git a/Source/Project64-rsp-core/Settings/RspSettings.cpp b/Source/Project64-rsp-core/Settings/RspSettings.cpp index c4b301603..e3b785bb9 100644 --- a/Source/Project64-rsp-core/Settings/RspSettings.cpp +++ b/Source/Project64-rsp-core/Settings/RspSettings.cpp @@ -4,7 +4,7 @@ #include #include -uint16_t Set_AudioHle = 0, Set_GraphicsHle = 0, Set_AllocatedRdramSize = 0; +uint16_t Set_AudioHle = 0, Set_GraphicsHle = 0, Set_AllocatedRdramSize = 0, Set_DirectoryLog = 0; bool GraphicsHle = true, AudioHle, ConditionalMove, HleAlistTask = false; bool DebuggingEnabled = false, Profiling, IndvidualBlock, ShowErrors, BreakOnStart = false, LogRDP = false, LogX86Code = false; @@ -14,6 +14,7 @@ void InitializeRspSetting(void) Set_GraphicsHle = FindSystemSettingId("HLE GFX"); Set_AudioHle = FindSystemSettingId("HLE Audio"); Set_AllocatedRdramSize = FindSystemSettingId("AllocatedRdramSize"); + Set_DirectoryLog = FindSystemSettingId("Dir:Log"); RegisterSetting(Set_BreakOnStart, Data_DWORD_General, "Break on Start", NULL, BreakOnStart, NULL); RegisterSetting(Set_CPUCore, Data_DWORD_General, "CPU Method", NULL, g_CPUCore, NULL); diff --git a/Source/Project64-rsp-core/Settings/RspSettings.h b/Source/Project64-rsp-core/Settings/RspSettings.h index 196f8d6fc..c170e0af4 100644 --- a/Source/Project64-rsp-core/Settings/RspSettings.h +++ b/Source/Project64-rsp-core/Settings/RspSettings.h @@ -3,6 +3,6 @@ void InitializeRspSetting(void); -extern uint16_t Set_AudioHle, Set_GraphicsHle, Set_AllocatedRdramSize; +extern uint16_t Set_AudioHle, Set_GraphicsHle, Set_AllocatedRdramSize, Set_DirectoryLog; extern bool GraphicsHle, AudioHle, ConditionalMove, HleAlistTask; extern bool DebuggingEnabled, Profiling, IndvidualBlock, ShowErrors, BreakOnStart, LogRDP, LogX86Code; \ No newline at end of file diff --git a/Source/Project64-rsp-core/cpu/RSPCpu.h b/Source/Project64-rsp-core/cpu/RSPCpu.h index db901c289..2acc473eb 100644 --- a/Source/Project64-rsp-core/cpu/RSPCpu.h +++ b/Source/Project64-rsp-core/cpu/RSPCpu.h @@ -1,3 +1,5 @@ +#pragma once + #include "RSPOpcode.h" #include "RSPRegisterHandlerPlugin.h" #include "RspTypes.h" diff --git a/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp b/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp index 208da0719..00cf5bd8b 100644 --- a/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp +++ b/Source/Project64-rsp-core/cpu/RSPInterpreterOps.cpp @@ -1203,7 +1203,7 @@ void RSP_Vector_VRCP(void) else { uint32_t Shift = clz32(Data); - uint32_t Index = (uint64_t(Data) << Shift & 0x7fc0'0000) >> 22; + uint32_t Index = (uint64_t(Data) << Shift & 0x7fc00000) >> 22; Result = (((0x10000 | Reciprocals[Index]) << 14) >> (31 - Shift)) ^ Mask; } RcpHigh = false; diff --git a/Source/Project64-rsp-core/cpu/RSPRegister.cpp b/Source/Project64-rsp-core/cpu/RSPRegister.cpp index ff60237b9..65a1c47e7 100644 --- a/Source/Project64-rsp-core/cpu/RSPRegister.cpp +++ b/Source/Project64-rsp-core/cpu/RSPRegister.cpp @@ -1,4 +1,4 @@ -#include "cpu/RspTypes.h" +#include "RspTypes.h" #include // RSP registers @@ -14,7 +14,7 @@ RSPFlag VCOL(RSP_Flags[0].UB[0]), VCOH(RSP_Flags[0].UB[1]); RSPFlag VCCL(RSP_Flags[1].UB[0]), VCCH(RSP_Flags[1].UB[1]); RSPFlag VCE(RSP_Flags[2].UB[0]); -char * GPR_Strings[32] = { +const char * GPR_Strings[32] = { "R0", "AT", "V0", diff --git a/Source/Project64-rsp-core/cpu/RSPRegisters.h b/Source/Project64-rsp-core/cpu/RSPRegisters.h index b8824d174..6a4df66ca 100644 --- a/Source/Project64-rsp-core/cpu/RSPRegisters.h +++ b/Source/Project64-rsp-core/cpu/RSPRegisters.h @@ -71,8 +71,8 @@ enum MI_INTR_SP = 0x01, // Bit 0: SP INTR }; -extern char * x86_Strings[8]; -extern char * GPR_Strings[32]; +extern const char * x86_Strings[8]; +extern const char * GPR_Strings[32]; #define x86_Name(Reg) (x86_Strings[(Reg)]) #define GPR_Name(Reg) (GPR_Strings[(Reg)]) diff --git a/Source/Project64-rsp-core/cpu/RspLog.cpp b/Source/Project64-rsp-core/cpu/RspLog.cpp index 6680e4c19..f891bfba1 100644 --- a/Source/Project64-rsp-core/cpu/RspLog.cpp +++ b/Source/Project64-rsp-core/cpu/RspLog.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include CLog * RDPLog = NULL; CLog * CPULog = NULL; @@ -13,11 +15,10 @@ void StartCPULog(void) { if (CPULog == NULL) { - CPath LogFile(CPath::MODULE_DIRECTORY, "RSP_x86Log.txt"); - LogFile.AppendDirectory("Logs"); - + char LogDir[260]; + CPath LogFilePath(GetSystemSettingSz(Set_DirectoryLog, LogDir, sizeof(LogDir)), "RSP_x86Log.txt"); CPULog = new CLog; - CPULog->Open(LogFile); + CPULog->Open(LogFilePath); } } @@ -51,13 +52,12 @@ void CPU_Message(const char * Message, ...) void StartRDPLog(void) { - if (RDPLog == NULL) + if (RDPLog == nullptr && Set_DirectoryLog != 0) { - CPath LogFile(CPath::MODULE_DIRECTORY, "RDP_Log.txt"); - LogFile.AppendDirectory("Logs"); - + char LogDir[260]; + CPath LogFilePath(GetSystemSettingSz(Set_DirectoryLog, LogDir, sizeof(LogDir)), "RDP_Log.txt"); RDPLog = new CLog; - RDPLog->Open(LogFile); + RDPLog->Open(LogFilePath); RDPLog->SetMaxFileSize(400 * 1024 * 1024); // RDPLog->SetFlush(true); }