From 761a1ee52a8a5817055f933645cd177a4ac15f65 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 10 Oct 2022 10:52:17 +1030 Subject: [PATCH] Code clean up --- Source/Common/md5.cpp | 5 +- Source/Project64-core/3rdParty/7zip.cpp | 45 +- Source/Project64-core/3rdParty/7zip.h | 50 +- Source/Project64-core/AppInit.h | 2 +- Source/Project64-core/Logging.h | 2 +- .../Project64-core/MemoryExceptionFilter.cpp | 125 +-- Source/Project64-core/Multilanguage.h | 14 +- .../Project64-core/Multilanguage/Language.h | 17 +- .../N64System/EmulationThread.cpp | 7 +- .../N64System/Enhancement/Enhancement.cpp | 3 +- .../N64System/Enhancement/Enhancement.h | 75 +- .../N64System/Enhancement/EnhancementFile.cpp | 82 +- .../N64System/Enhancement/EnhancementFile.h | 21 +- .../N64System/Enhancement/EnhancementList.h | 8 +- .../N64System/Enhancement/Enhancements.h | 38 +- .../N64System/FramePerSecond.cpp | 6 +- .../Project64-core/N64System/FramePerSecond.h | 13 +- .../N64System/Interpreter/InterpreterCPU.h | 6 +- .../N64System/Interpreter/InterpreterOps.cpp | 72 +- .../N64System/Interpreter/InterpreterOps.h | 36 +- .../Interpreter/InterpreterOps32.cpp | 37 +- .../N64System/Interpreter/InterpreterOps32.h | 108 +-- .../MemoryHandler/AudioInterfaceHandler.cpp | 10 +- .../MemoryHandler/AudioInterfaceHandler.h | 20 +- .../CartridgeDomain1Address1Handler.cpp | 1 + .../CartridgeDomain1Address3Handler.cpp | 1 + .../CartridgeDomain2Address1Handler.cpp | 3 +- .../CartridgeDomain2Address1Handler.h | 4 +- .../CartridgeDomain2Address2Handler.cpp | 3 +- .../CartridgeDomain2Address2Handler.h | 16 +- .../DisplayControlRegHandler.cpp | 14 +- .../MemoryHandler/DisplayControlRegHandler.h | 52 +- .../MemoryHandler/ISViewerHandler.cpp | 10 +- .../N64System/MemoryHandler/ISViewerHandler.h | 7 +- .../MemoryHandler/MIPSInterfaceHandler.cpp | 3 +- .../MemoryHandler/MIPSInterfaceHandler.h | 6 +- .../PeripheralInterfaceHandler.cpp | 23 +- .../PeripheralInterfaceHandler.h | 22 +- .../N64System/MemoryHandler/PifRamHandler.cpp | 6 +- .../N64System/MemoryHandler/PifRamHandler.h | 2 +- .../MemoryHandler/RDRAMInterfaceHandler.cpp | 5 +- .../MemoryHandler/RDRAMInterfaceHandler.h | 2 +- .../MemoryHandler/RDRAMRegistersHandler.cpp | 1 + .../MemoryHandler/RDRAMRegistersHandler.h | 6 +- .../MemoryHandler/RomMemoryHandler.cpp | 5 +- .../MemoryHandler/RomMemoryHandler.h | 16 +- .../MemoryHandler/SPRegistersHandler.cpp | 135 ++- .../MemoryHandler/SPRegistersHandler.h | 22 +- .../MemoryHandler/SerialInterfaceHandler.cpp | 1 + .../MemoryHandler/SerialInterfaceHandler.h | 8 +- .../MemoryHandler/VideoInterfaceHandler.cpp | 7 +- .../MemoryHandler/VideoInterfaceHandler.h | 16 +- Source/Project64-core/N64System/Mips/Disk.cpp | 30 +- Source/Project64-core/N64System/Mips/Disk.h | 16 +- .../Project64-core/N64System/Mips/GBCart.cpp | 139 +-- Source/Project64-core/N64System/Mips/GBCart.h | 34 +- .../N64System/Mips/MemoryVirtualMem.cpp | 89 +- .../N64System/Mips/MemoryVirtualMem.h | 72 +- .../Project64-core/N64System/Mips/Mempak.cpp | 10 +- Source/Project64-core/N64System/Mips/Mempak.h | 4 +- .../Project64-core/N64System/Mips/PifRam.cpp | 105 +- Source/Project64-core/N64System/Mips/PifRam.h | 9 +- .../N64System/Mips/R4300iInstruction.cpp | 24 +- .../N64System/Mips/R4300iInstruction.h | 8 +- .../N64System/Mips/R4300iOpcode.h | 184 ++-- .../N64System/Mips/Register.cpp | 67 +- .../Project64-core/N64System/Mips/Register.h | 303 +++--- .../N64System/Mips/Rumblepak.cpp | 34 +- .../N64System/Mips/SystemEvents.cpp | 3 +- .../N64System/Mips/SystemEvents.h | 12 +- .../N64System/Mips/SystemTiming.cpp | 23 +- .../N64System/Mips/SystemTiming.h | 26 +- Source/Project64-core/N64System/Mips/TLB.cpp | 13 +- Source/Project64-core/N64System/Mips/TLB.h | 24 +- .../N64System/Mips/Transferpak.cpp | 56 +- .../N64System/Mips/Transferpak.h | 22 +- Source/Project64-core/N64System/N64Disk.cpp | 86 +- Source/Project64-core/N64System/N64Disk.h | 181 ++-- Source/Project64-core/N64System/N64Rom.cpp | 113 ++- Source/Project64-core/N64System/N64Rom.h | 42 +- Source/Project64-core/N64System/N64System.cpp | 288 +++--- Source/Project64-core/N64System/N64System.h | 63 +- Source/Project64-core/N64System/N64Types.h | 70 +- Source/Project64-core/N64System/Profiling.cpp | 20 +- Source/Project64-core/N64System/Profiling.h | 6 +- .../Aarch64/Aarch64RecompilerOps.cpp | 2 +- .../Recompiler/Aarch64/Aarch64RecompilerOps.h | 21 +- .../Recompiler/Aarch64/Aarch64RegInfo.cpp | 4 +- .../Recompiler/Aarch64/Aarch64RegInfo.h | 8 +- .../N64System/Recompiler/Aarch64/Aarch64ops.h | 4 +- .../N64System/Recompiler/Arm/ArmOps.cpp | 233 +++-- .../N64System/Recompiler/Arm/ArmOps.h | 8 +- .../Recompiler/Arm/ArmRecompilerOps.cpp | 801 +++++++++++---- .../Recompiler/Arm/ArmRecompilerOps.h | 172 +++- .../N64System/Recompiler/Arm/ArmRegInfo.cpp | 429 ++++++-- .../N64System/Recompiler/Arm/ArmRegInfo.h | 74 +- .../N64System/Recompiler/CodeBlock.cpp | 167 +++- .../N64System/Recompiler/CodeBlock.h | 94 +- .../N64System/Recompiler/CodeSection.cpp | 255 +++-- .../N64System/Recompiler/CodeSection.h | 8 +- .../N64System/Recompiler/ExitInfo.cpp | 3 +- .../N64System/Recompiler/ExitInfo.h | 2 +- .../N64System/Recompiler/FunctionInfo.cpp | 2 +- .../N64System/Recompiler/FunctionInfo.h | 58 +- .../N64System/Recompiler/FunctionMap.cpp | 3 +- .../N64System/Recompiler/FunctionMap.h | 14 +- .../N64System/Recompiler/JumpInfo.cpp | 23 +- .../N64System/Recompiler/LoopAnalysis.cpp | 341 +++++-- .../N64System/Recompiler/LoopAnalysis.h | 12 +- .../N64System/Recompiler/Recompiler.cpp | 29 +- .../N64System/Recompiler/Recompiler.h | 22 +- .../N64System/Recompiler/RecompilerMemory.cpp | 13 +- .../N64System/Recompiler/RecompilerMemory.h | 26 +- .../N64System/Recompiler/RegBase.cpp | 38 +- .../N64System/Recompiler/RegBase.h | 159 ++- .../N64System/Recompiler/SectionInfo.h | 4 +- .../Recompiler/x64-86/x64RecompilerOps.cpp | 2 +- .../Recompiler/x64-86/x64RecompilerOps.h | 21 +- .../Recompiler/x64-86/x64RegInfo.cpp | 4 +- .../N64System/Recompiler/x64-86/x64RegInfo.h | 8 +- .../N64System/Recompiler/x64-86/x64ops.h | 4 +- .../Recompiler/x86/x86RecompilerOps.cpp | 918 ++++++++++-------- .../Recompiler/x86/x86RecompilerOps.h | 229 ++++- .../N64System/Recompiler/x86/x86RegInfo.cpp | 319 ++++-- .../N64System/Recompiler/x86/x86RegInfo.h | 80 +- .../N64System/Recompiler/x86/x86ops.cpp | 173 ++-- .../N64System/Recompiler/x86/x86ops.h | 22 +- .../N64System/SaveType/Eeprom.cpp | 9 +- .../N64System/SaveType/Eeprom.h | 8 +- .../N64System/SaveType/FlashRam.cpp | 9 +- .../N64System/SaveType/FlashRam.h | 4 +- .../N64System/SaveType/Sram.cpp | 7 +- .../Project64-core/N64System/SaveType/Sram.h | 4 +- .../Project64-core/N64System/SpeedLimiter.cpp | 49 +- .../Project64-core/N64System/SpeedLimiter.h | 18 +- .../N64System/SystemGlobals.cpp | 13 +- .../Project64-core/N64System/SystemGlobals.h | 6 +- Source/Project64-core/Plugin.h | 6 +- Source/Project64-core/Plugins/AudioPlugin.cpp | 59 +- Source/Project64-core/Plugins/AudioPlugin.h | 29 +- .../Plugins/ControllerPlugin.cpp | 59 +- .../Project64-core/Plugins/ControllerPlugin.h | 67 +- Source/Project64-core/Plugins/GFXPlugin.cpp | 102 +- Source/Project64-core/Plugins/GFXPlugin.h | 112 ++- Source/Project64-core/Plugins/Plugin.cpp | 139 ++- Source/Project64-core/Plugins/Plugin.h | 114 ++- Source/Project64-core/Plugins/PluginBase.cpp | 108 ++- Source/Project64-core/Plugins/PluginBase.h | 28 +- Source/Project64-core/Plugins/RSPPlugin.cpp | 91 +- Source/Project64-core/Plugins/RSPPlugin.h | 76 +- Source/Project64-core/RomList/RomList.cpp | 20 +- Source/Project64-core/RomList/RomList.h | 22 +- Source/Project64-core/Settings.h | 6 +- .../Project64-core/Settings/DebugSettings.cpp | 1 + .../Project64-core/Settings/DebugSettings.h | 105 +- .../Project64-core/Settings/GameSettings.cpp | 27 +- Source/Project64-core/Settings/GameSettings.h | 141 ++- .../Settings/LoggingSettings.cpp | 171 ++-- .../Project64-core/Settings/LoggingSettings.h | 127 ++- .../Settings/N64SystemSettings.cpp | 1 + .../Settings/N64SystemSettings.h | 30 +- .../Settings/RecompilerSettings.cpp | 1 + .../Settings/RecompilerSettings.h | 5 +- .../SettingType/SettingsType-Application.cpp | 11 +- .../SettingType/SettingsType-Application.h | 19 +- .../SettingsType-ApplicationIndex.cpp | 1 + .../SettingsType-ApplicationIndex.h | 9 +- .../SettingsType-ApplicationPath.cpp | 3 +- .../SettingsType-ApplicationPath.h | 14 +- .../Settings/SettingType/SettingsType-Base.h | 8 +- .../SettingType/SettingsType-GameSetting.cpp | 1 + .../SettingType/SettingsType-GameSetting.h | 40 +- .../SettingsType-GameSettingIndex.cpp | 53 +- .../SettingsType-GameSettingIndex.h | 40 +- .../SettingType/SettingsType-RDBCpuType.cpp | 75 +- .../SettingType/SettingsType-RDBOnOff.cpp | 68 +- .../SettingType/SettingsType-RDBOnOff.h | 27 +- .../SettingType/SettingsType-RDBRamSize.cpp | 41 +- .../SettingType/SettingsType-RDBRamSize.h | 31 +- .../SettingType/SettingsType-RDBSaveChip.cpp | 88 +- .../SettingType/SettingsType-RDBSaveChip.h | 31 +- .../SettingType/SettingsType-RDBYesNo.cpp | 10 +- .../SettingType/SettingsType-RDBYesNo.h | 27 +- .../SettingType/SettingsType-RelativePath.cpp | 3 +- .../SettingType/SettingsType-RelativePath.h | 49 +- .../SettingType/SettingsType-RomDatabase.cpp | 53 +- .../SettingType/SettingsType-RomDatabase.h | 28 +- .../SettingsType-RomDatabaseIndex.cpp | 57 +- .../SettingsType-RomDatabaseIndex.h | 39 +- .../SettingsType-RomDatabaseSetting.cpp | 1 + .../SettingsType-RomDatabaseSetting.h | 22 +- .../SettingType/SettingsType-RomSetting.h | 25 +- .../SettingsType-SelectedDirectory.cpp | 1 + .../SettingsType-SelectedDirectory.h | 19 +- .../SettingType/SettingsType-TempBool.cpp | 19 +- .../SettingType/SettingsType-TempBool.h | 24 +- .../SettingType/SettingsType-TempNumber.cpp | 27 +- .../SettingType/SettingsType-TempNumber.h | 41 +- .../SettingType/SettingsType-TempString.cpp | 25 +- .../SettingType/SettingsType-TempString.h | 41 +- Source/Project64-core/Settings/SettingsID.h | 55 +- Source/Project64-core/stdafx.h | 4 +- .../Debugger/Debugger-RegisterTabData.h | 39 +- .../Debugger/Debugger-RegisterTabs.h | 3 +- .../Debugger/ScriptAPI/ScriptAPI_cpu.cpp | 14 +- .../Debugger/ScriptAPI/ScriptAPI_fs.cpp | 10 +- .../UserInterface/WTLControls/TooltipDialog.h | 18 +- 207 files changed, 7244 insertions(+), 3928 deletions(-) diff --git a/Source/Common/md5.cpp b/Source/Common/md5.cpp index f7509a045..f9f5ce402 100644 --- a/Source/Common/md5.cpp +++ b/Source/Common/md5.cpp @@ -131,12 +131,13 @@ void MD5::finalize() { unsigned char bits[8]; unsigned int index, padLen; - static uint1 PADDING[64] = - { + // clang-format off + static uint1 PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + // clang-format on if (finalized) { diff --git a/Source/Project64-core/3rdParty/7zip.cpp b/Source/Project64-core/3rdParty/7zip.cpp index 85b8fe7c9..88425b57d 100644 --- a/Source/Project64-core/3rdParty/7zip.cpp +++ b/Source/Project64-core/3rdParty/7zip.cpp @@ -1,22 +1,22 @@ -typedef const char * LPCSTR; +typedef const char * LPCSTR; -#include -#include -#include -#include #include "7zip.h" #include +#include +#include +#include +#include C7zip::C7zip(const char * FileName) : -m_FileSize(0), -m_CurrentFile(-1), -m_blockIndex(0xFFFFFFFF), -m_outBuffer(0), -m_outBufferSize(0), -m_NotfyCallback(NotfyCallbackDefault), -m_NotfyCallbackInfo(nullptr), -m_db(nullptr), -m_Opened(false) + m_FileSize(0), + m_CurrentFile(-1), + m_blockIndex(0xFFFFFFFF), + m_outBuffer(0), + m_outBufferSize(0), + m_NotfyCallback(NotfyCallbackDefault), + m_NotfyCallbackInfo(nullptr), + m_db(nullptr), + m_Opened(false) { memset(&m_FileName, 0, sizeof(m_FileName)); memset(&m_archiveLookStream, 0, sizeof(m_archiveLookStream)); @@ -78,7 +78,6 @@ void C7zip::SetNotificationCallback(LP7ZNOTIFICATION NotfyFnc, void * CBInfo) m_NotfyCallbackInfo = CBInfo; } - bool C7zip::GetFile(int index, Byte * Data, size_t DataLen) { m_CurrentFile = -1; @@ -101,9 +100,9 @@ bool C7zip::GetFile(int index, Byte * Data, size_t DataLen) m_NotfyCallback(Msg, m_NotfyCallbackInfo); SRes res = SzArEx_Extract(m_db, &m_archiveLookStream.s, index, - &m_blockIndex, &m_outBuffer, &m_outBufferSize, - &offset, &outSizeProcessed, - &m_allocImp, &m_allocTempImp); + &m_blockIndex, &m_outBuffer, &m_outBufferSize, + &offset, &outSizeProcessed, + &m_allocImp, &m_allocTempImp); if (res != SZ_OK) { m_CurrentFile = -1; @@ -126,7 +125,7 @@ void * C7zip::AllocAllocImp(void * /*p*/, size_t size) //return new BYTE[size]; } -void C7zip::AllocFreeImp(void * /*p*/, void *address) +void C7zip::AllocFreeImp(void * /*p*/, void * address) { if (address != nullptr) { @@ -134,9 +133,9 @@ void C7zip::AllocFreeImp(void * /*p*/, void *address) } } -SRes C7zip::SzFileReadImp(void *object, void *buffer, size_t *processedSize) +SRes C7zip::SzFileReadImp(void * object, void * buffer, size_t * processedSize) { - CFileInStream *p = (CFileInStream *)object; + CFileInStream * p = (CFileInStream *)object; DWORD dwRead; if (!ReadFile(p->file.handle, buffer, (DWORD)*processedSize, &dwRead, nullptr)) { @@ -147,9 +146,9 @@ SRes C7zip::SzFileReadImp(void *object, void *buffer, size_t *processedSize) return SZ_OK; } -SRes C7zip::SzFileSeekImp(void *p, Int64 *pos, ESzSeek origin) +SRes C7zip::SzFileSeekImp(void * p, Int64 * pos, ESzSeek origin) { - CFileInStream *s = (CFileInStream *)p; + CFileInStream * s = (CFileInStream *)p; DWORD dwMoveMethod; switch (origin) diff --git a/Source/Project64-core/3rdParty/7zip.h b/Source/Project64-core/3rdParty/7zip.h index c0b772ae9..ad710e858 100644 --- a/Source/Project64-core/3rdParty/7zip.h +++ b/Source/Project64-core/3rdParty/7zip.h @@ -2,11 +2,12 @@ #include #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -#include "7zip/7zCrc.h" #include "7zip/7z.h" +#include "7zip/7zCrc.h" #include "7zip/7zFile.h" #include "7zip/Types.h" @@ -17,18 +18,29 @@ extern "C" { class C7zip { public: - C7zip(const char * FileName); ~C7zip(); typedef void (*LP7ZNOTIFICATION)(const char * Status, void * CBInfo); - inline int NumFiles(void) const { return m_db ? m_db->db.NumFiles : 0; } - inline CSzFileItem * FileItem(int index) const { return m_db ? &m_db->db.Files[index] : nullptr; } - inline int FileSize(void) const { return m_FileSize; } - inline bool OpenSuccess(void) const { return m_Opened; } + inline int NumFiles(void) const + { + return m_db ? m_db->db.NumFiles : 0; + } + inline CSzFileItem * FileItem(int index) const + { + return m_db ? &m_db->db.Files[index] : nullptr; + } + inline int FileSize(void) const + { + return m_FileSize; + } + inline bool OpenSuccess(void) const + { + return m_Opened; + } - bool GetFile(int index, Byte * Data, size_t DataLen); + bool GetFile(int index, Byte * Data, size_t DataLen); const char * FileName(char * FileName, size_t SizeOfFileName) const; std::wstring FileNameIndex(int index); @@ -36,8 +48,8 @@ public: private: C7zip(void); - C7zip(const C7zip&); - C7zip& operator=(const C7zip&); + C7zip(const C7zip &); + C7zip & operator=(const C7zip &); CSzArEx * m_db; CFileInStream m_archiveStream; @@ -50,19 +62,21 @@ private: bool m_Opened; // Used for extraction - UInt32 m_blockIndex; // It can have any value before first call (if outBuffer = 0) - Byte * m_outBuffer; // It must be 0 before first call for each new archive - size_t m_outBufferSize; // It can have any value before first call (if outBuffer = 0) + UInt32 m_blockIndex; // It can have any value before first call (if outBuffer = 0) + Byte * m_outBuffer; // It must be 0 before first call for each new archive + size_t m_outBufferSize; // It can have any value before first call (if outBuffer = 0) - static void * AllocAllocImp(void *p, size_t size); - static void AllocFreeImp(void *p, void *address); // Address can be 0 + static void * AllocAllocImp(void * p, size_t size); + static void AllocFreeImp(void * p, void * address); // Address can be 0 - static SRes SzFileReadImp(void *object, void *buffer, size_t *processedSize); - static SRes SzFileSeekImp(void *p, Int64 *pos, ESzSeek origin); + static SRes SzFileReadImp(void * object, void * buffer, size_t * processedSize); + static SRes SzFileSeekImp(void * p, Int64 * pos, ESzSeek origin); //static void __stdcall StatusUpdate(_7Z_STATUS status, int Value1, int Value2, C7zip * _this); - static void NotfyCallbackDefault(const char * /*Status*/, void * /*CBInfo*/) { } + static void NotfyCallbackDefault(const char * /*Status*/, void * /*CBInfo*/) + { + } LP7ZNOTIFICATION m_NotfyCallback; void * m_NotfyCallbackInfo; diff --git a/Source/Project64-core/AppInit.h b/Source/Project64-core/AppInit.h index 37a68151b..0bed9a6f5 100644 --- a/Source/Project64-core/AppInit.h +++ b/Source/Project64-core/AppInit.h @@ -2,5 +2,5 @@ #include -bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char **argv); +bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char ** argv); void AppCleanup(void); diff --git a/Source/Project64-core/Logging.h b/Source/Project64-core/Logging.h index b3a34a510..15e8081f0 100644 --- a/Source/Project64-core/Logging.h +++ b/Source/Project64-core/Logging.h @@ -1,6 +1,6 @@ #pragma once -#include #include +#include class CLogging : public CLogSettings diff --git a/Source/Project64-core/MemoryExceptionFilter.cpp b/Source/Project64-core/MemoryExceptionFilter.cpp index 8864f2cc0..cda8c8332 100644 --- a/Source/Project64-core/MemoryExceptionFilter.cpp +++ b/Source/Project64-core/MemoryExceptionFilter.cpp @@ -168,37 +168,37 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex switch (*(TypePos + 1)) { case 0xB6: - { - uint8_t Value = 0; - g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value); - *(uint32_t *)Reg = Value; - } + { + uint8_t Value = 0; + g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value); + *(uint32_t *)Reg = Value; *context.Eip = (uint32_t)ReadPos; return true; + } case 0xB7: - { - uint16_t Value = 0; - g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value); - *(uint32_t *)Reg = Value; - } + { + uint16_t Value = 0; + g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value); + *(uint32_t *)Reg = Value; *context.Eip = (uint32_t)ReadPos; return true; + } case 0xBE: - { - uint8_t Value = 0; - g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value); - *(int32_t *)Reg = (int8_t)Value; - } + { + uint8_t Value = 0; + g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value); + *(int32_t *)Reg = (int8_t)Value; *context.Eip = (uint32_t)ReadPos; return true; + } case 0xBF: - { - uint16_t Value = 0; - g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value); - *(int32_t *)Reg = (int16_t)Value; - } + { + uint16_t Value = 0; + g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value); + *(int32_t *)Reg = (int16_t)Value; *context.Eip = (uint32_t)ReadPos; return true; + } default: if (HaveDebugger()) { @@ -211,13 +211,13 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex switch (*(TypePos + 1)) { case 0x8B: - { - uint16_t Value = 0; - g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value); - *(uint32_t *)Reg = Value; - } + { + uint16_t Value = 0; + g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, Value); + *(uint32_t *)Reg = Value; *context.Eip = (uint32_t)ReadPos; return true; + } case 0x89: g_MMU->SH_NonMemory((MemAddress | 0x80000000) ^ 2, *(uint16_t *)Reg); *context.Eip = (uint32_t)ReadPos; @@ -247,13 +247,13 @@ bool CMipsMemoryVM::FilterX86Exception(uint32_t MemAddress, X86_CONTEXT & contex *context.Eip = (uint32_t)ReadPos; return true; case 0x8A: - { - uint8_t Value = 0; - g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value); - *(uint32_t *)Reg = Value; - } + { + uint8_t Value = 0; + g_MMU->LB_NonMemory((MemAddress | 0x80000000) ^ 3, Value); + *(uint32_t *)Reg = Value; *context.Eip = (uint32_t)ReadPos; return true; + } case 0x8B: g_MMU->LW_NonMemory(MemAddress | 0x80000000, *((uint32_t *)Reg)); *context.Eip = (uint32_t)ReadPos; @@ -379,12 +379,23 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context return false; } - uint32_t * ArmRegisters[16] = - { - (uint32_t*)&context.arm_r0, (uint32_t*)&context.arm_r1, (uint32_t*)&context.arm_r2, (uint32_t*)&context.arm_r3, - (uint32_t*)&context.arm_r4, (uint32_t*)&context.arm_r5, (uint32_t*)&context.arm_r6, (uint32_t*)&context.arm_r7, - (uint32_t*)&context.arm_r8, (uint32_t*)&context.arm_r9, (uint32_t*)&context.arm_r10,(uint32_t*)&context.arm_fp, - (uint32_t*)&context.arm_ip, (uint32_t*)&context.arm_sp, (uint32_t*)&context.arm_lr, (uint32_t*)&context.arm_pc, + uint32_t * ArmRegisters[16] = { + (uint32_t *)&context.arm_r0, + (uint32_t *)&context.arm_r1, + (uint32_t *)&context.arm_r2, + (uint32_t *)&context.arm_r3, + (uint32_t *)&context.arm_r4, + (uint32_t *)&context.arm_r5, + (uint32_t *)&context.arm_r6, + (uint32_t *)&context.arm_r7, + (uint32_t *)&context.arm_r8, + (uint32_t *)&context.arm_r9, + (uint32_t *)&context.arm_r10, + (uint32_t *)&context.arm_fp, + (uint32_t *)&context.arm_ip, + (uint32_t *)&context.arm_sp, + (uint32_t *)&context.arm_lr, + (uint32_t *)&context.arm_pc, }; ArmThumbOpcode * OpCode = (ArmThumbOpcode *)context.arm_pc; @@ -569,9 +580,9 @@ bool CMipsMemoryVM::SetupSegvHandler(void) return sigaction(SIGSEGV, &sig_act, nullptr) == 0; } -void CMipsMemoryVM::segv_handler(int signal, siginfo_t *siginfo, void *sigcontext) +void CMipsMemoryVM::segv_handler(int signal, siginfo_t * siginfo, void * sigcontext) { - ucontext_t *ucontext = (ucontext_t*)sigcontext; + ucontext_t * ucontext = (ucontext_t *)sigcontext; WriteTrace(TraceExceptionHandler, TraceNotice, "Segmentation fault!"); WriteTrace(TraceExceptionHandler, TraceNotice, "info.si_signo = %d", signal); @@ -597,15 +608,15 @@ void CMipsMemoryVM::segv_handler(int signal, siginfo_t *siginfo, void *sigcontex } X86_CONTEXT context; - context.Edi = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_EDI]; - context.Esi = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_ESI]; - context.Ebx = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_EBX]; - context.Edx = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_EDX]; - context.Ecx = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_ECX]; - context.Eax = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_EAX]; - context.Eip = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_EIP]; - context.Esp = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_ESP]; - context.Ebp = (uint32_t*)&ucontext->uc_mcontext.gregs[REG_EBP]; + context.Edi = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_EDI]; + context.Esi = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_ESI]; + context.Ebx = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_EBX]; + context.Edx = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_EDX]; + context.Ecx = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_ECX]; + context.Eax = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_EAX]; + context.Eip = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_EIP]; + context.Esp = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_ESP]; + context.Ebp = (uint32_t *)&ucontext->uc_mcontext.gregs[REG_EBP]; if (FilterX86Exception(MemAddress, context)) { @@ -641,15 +652,15 @@ int32_t CMipsMemoryVM::MemoryFilter(uint32_t dwExptCode, void * lpExceptionPoint uint32_t MemAddress = (char *)lpEP->ExceptionRecord->ExceptionInformation[1] - (char *)g_MMU->Rdram(); X86_CONTEXT context; - context.Edi = (uint32_t*)&lpEP->ContextRecord->Edi; - context.Esi = (uint32_t*)&lpEP->ContextRecord->Esi; - context.Ebx = (uint32_t*)&lpEP->ContextRecord->Ebx; - context.Edx = (uint32_t*)&lpEP->ContextRecord->Edx; - context.Ecx = (uint32_t*)&lpEP->ContextRecord->Ecx; - context.Eax = (uint32_t*)&lpEP->ContextRecord->Eax; - context.Eip = (uint32_t*)&lpEP->ContextRecord->Eip; - context.Esp = (uint32_t*)&lpEP->ContextRecord->Esp; - context.Ebp = (uint32_t*)&lpEP->ContextRecord->Ebp; + context.Edi = (uint32_t *)&lpEP->ContextRecord->Edi; + context.Esi = (uint32_t *)&lpEP->ContextRecord->Esi; + context.Ebx = (uint32_t *)&lpEP->ContextRecord->Ebx; + context.Edx = (uint32_t *)&lpEP->ContextRecord->Edx; + context.Ecx = (uint32_t *)&lpEP->ContextRecord->Ecx; + context.Eax = (uint32_t *)&lpEP->ContextRecord->Eax; + context.Eip = (uint32_t *)&lpEP->ContextRecord->Eip; + context.Esp = (uint32_t *)&lpEP->ContextRecord->Esp; + context.Ebp = (uint32_t *)&lpEP->ContextRecord->Ebp; if (FilterX86Exception(MemAddress, context)) { @@ -658,7 +669,7 @@ int32_t CMipsMemoryVM::MemoryFilter(uint32_t dwExptCode, void * lpExceptionPoint } return EXCEPTION_EXECUTE_HANDLER; #else - dwExptCode = dwExptCode; //unreferenced formal parameter + dwExptCode = dwExptCode; //unreferenced formal parameter lpExceptionPointer = lpExceptionPointer; // unreferenced formal parameter return EXCEPTION_EXECUTE_HANDLER; #endif diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index af86298d7..0283d6ab2 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -117,7 +117,7 @@ enum LanguageStringID POPUP_CHEATS = 213, POPUP_GFX_PLUGIN = 214, POPUP_PLAYDISK = 215, - POPUP_ENHANCEMENTS = 216, + POPUP_ENHANCEMENTS = 216, // Selecting save slot SAVE_SLOT_DEFAULT = 220, @@ -391,7 +391,7 @@ enum LanguageStringID STR_FR_DLS = 701, STR_FR_PERCENT = 702, STR_FR_DLS_VIS = 703, - STR_FR_NONE = 704, + STR_FR_NONE = 704, // Increase speed STR_INSREASE_SPEED = 710, @@ -402,7 +402,7 @@ enum LanguageStringID BOTTOM_RESET_ALL = 721, BOTTOM_APPLY = 722, BOTTOM_CLOSE = 723, - + // Disk save type DISKSAVE_SHADOW = 730, DISKSAVE_RAM = 731, @@ -593,10 +593,10 @@ enum LanguageStringID ANDROID_ABOUT_LICENCE = 3017, ANDROID_ABOUT_REVISION = 3018, ANDROID_ABOUT_TEXT = 3019, - ANDROID_ABOUT_PJ64_AUTHORS = 3020, - ANDROID_DISCORD = 3021, - ANDROID_SUPPORT_PJ64 = 3022, - ANDROID_REVIEW_PJ64 = 3023, + ANDROID_ABOUT_PJ64_AUTHORS = 3020, + ANDROID_DISCORD = 3021, + ANDROID_SUPPORT_PJ64 = 3022, + ANDROID_REVIEW_PJ64 = 3023, // In-game menu ANDROID_MENU_SETTINGS = 3100, diff --git a/Source/Project64-core/Multilanguage/Language.h b/Source/Project64-core/Multilanguage/Language.h index a4c06b111..572259229 100644 --- a/Source/Project64-core/Multilanguage/Language.h +++ b/Source/Project64-core/Multilanguage/Language.h @@ -1,12 +1,12 @@ #pragma once -#pragma warning(disable:4786) -#include -#include +#pragma warning(disable : 4786) #include +#include #include +#include -typedef std::map > LANG_STRINGS; +typedef std::map> LANG_STRINGS; typedef LANG_STRINGS::value_type LANG_STR; struct LanguageFile @@ -28,11 +28,14 @@ public: void SetLanguage(const char * LanguageName); bool LoadCurrentStrings(void); bool IsCurrentLang(LanguageFile & File); - bool IsLanguageLoaded(void) const { return m_LanguageLoaded; } + bool IsLanguageLoaded(void) const + { + return m_LanguageLoaded; + } private: - CLanguage(const CLanguage&); - CLanguage& operator=(const CLanguage&); + CLanguage(const CLanguage &); + CLanguage & operator=(const CLanguage &); static void StaticResetStrings(CLanguage * _this) { diff --git a/Source/Project64-core/N64System/EmulationThread.cpp b/Source/Project64-core/N64System/EmulationThread.cpp index 8348e3045..7030f8ae6 100644 --- a/Source/Project64-core/N64System/EmulationThread.cpp +++ b/Source/Project64-core/N64System/EmulationThread.cpp @@ -1,12 +1,13 @@ #include "stdafx.h" + +#include #include #include -#include -void CN64System::StartEmulationThead() +void CN64System::StartEmulationThead() { WriteTrace(TraceN64System, TraceDebug, "Start"); - + CThread * thread = new CThread((CThread::CTHREAD_START_ROUTINE)StartEmulationThread); thread->Start(thread); WriteTrace(TraceN64System, TraceDebug, "Done"); diff --git a/Source/Project64-core/N64System/Enhancement/Enhancement.cpp b/Source/Project64-core/N64System/Enhancement/Enhancement.cpp index 5fc3129bb..bac8b50d1 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancement.cpp +++ b/Source/Project64-core/N64System/Enhancement/Enhancement.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include #include #include @@ -196,7 +197,7 @@ CEnhancement::CEnhancement(const char * Ident, const char * Entry) : // Gameshark code while (CurrentLine < Lines.size()) { - char TempFormat[128] = { 0 }; + char TempFormat[128] = {0}; const char * Line = Lines[CurrentLine].c_str(); size_t LineLen = strlen(Line); if (LineLen >= (sizeof(TempFormat) / sizeof(TempFormat[0]))) diff --git a/Source/Project64-core/N64System/Enhancement/Enhancement.h b/Source/Project64-core/N64System/Enhancement/Enhancement.h index 19a6d7de3..ffd10b8ee 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancement.h +++ b/Source/Project64-core/N64System/Enhancement/Enhancement.h @@ -36,21 +36,66 @@ public: void SetOnByDefault(bool OnByDefault); void SetOverClock(bool OverClock, uint32_t OverClockModifier); - inline const std::string & GetName(void) const { return m_Name; } - inline const std::string & GetNameAndExtension(void) const { return m_NameAndExtension; } - inline const std::string & GetAuthor(void) const { return m_Author; } - inline const std::string & GetNote(void) const { return m_Note; } - inline const CodeEntries & GetEntries(void) const { return m_Entries; } - inline const CodeOptions & GetOptions(void) const { return m_Options; } - inline const PluginList & GetPluginList(void) const { return m_PluginList; } - inline uint32_t CodeOptionSize(void) const { return m_CodeOptionSize; } - inline bool Valid(void) const { return m_Valid; } - inline bool Active(void) const { return m_Active; } - inline bool GetOnByDefault(void) const { return m_OnByDefault; } - inline bool OverClock(void) const { return m_OverClock; } - inline uint32_t OverClockModifier(void) const { return m_OverClockModifier; } - bool OptionSelected() const { return (m_SelectedOption & 0xFFFF0000) == 0; } - uint16_t SelectedOption() const { return (uint16_t)(m_SelectedOption & 0xFFFF); } + inline const std::string & GetName(void) const + { + return m_Name; + } + inline const std::string & GetNameAndExtension(void) const + { + return m_NameAndExtension; + } + inline const std::string & GetAuthor(void) const + { + return m_Author; + } + inline const std::string & GetNote(void) const + { + return m_Note; + } + inline const CodeEntries & GetEntries(void) const + { + return m_Entries; + } + inline const CodeOptions & GetOptions(void) const + { + return m_Options; + } + inline const PluginList & GetPluginList(void) const + { + return m_PluginList; + } + inline uint32_t CodeOptionSize(void) const + { + return m_CodeOptionSize; + } + inline bool Valid(void) const + { + return m_Valid; + } + inline bool Active(void) const + { + return m_Active; + } + inline bool GetOnByDefault(void) const + { + return m_OnByDefault; + } + inline bool OverClock(void) const + { + return m_OverClock; + } + inline uint32_t OverClockModifier(void) const + { + return m_OverClockModifier; + } + bool OptionSelected() const + { + return (m_SelectedOption & 0xFFFF0000) == 0; + } + uint16_t SelectedOption() const + { + return (uint16_t)(m_SelectedOption & 0xFFFF); + } private: CEnhancement(); diff --git a/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp b/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp index 9b332a8ad..194ef1f40 100644 --- a/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp +++ b/Source/Project64-core/N64System/Enhancement/EnhancementFile.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include -#pragma warning(disable:4996) +#pragma warning(disable : 4996) CEnhancmentFile::CEnhancmentFile(const char * FileName, const char * Ident) : m_Ident(Ident), @@ -106,7 +106,7 @@ bool CEnhancmentFile::RemoveEnhancements(const char * Section) return true; } -bool CEnhancmentFile::GetName(const char * Section, std::string &Name) +bool CEnhancmentFile::GetName(const char * Section, std::string & Name) { CGuard Guard(m_CS); if (!m_File.IsOpen()) @@ -192,8 +192,14 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect do { result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos); - if (result <= 1) { continue; } - if (strlen(CleanLine(Input)) <= 1) { continue; } + if (result <= 1) + { + continue; + } + if (strlen(CleanLine(Input)) <= 1) + { + continue; + } // We only care about sections char * CurrentSection = Input; @@ -203,9 +209,15 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect CurrentSection += 3; } - if (CurrentSection[0] != '[') { continue; } + if (CurrentSection[0] != '[') + { + continue; + } int lineEndPos = (int)strlen(CurrentSection) - 1; - if (CurrentSection[lineEndPos] != ']') { continue; } + if (CurrentSection[lineEndPos] != ']') + { + continue; + } // Take off the ']' from the end of the string CurrentSection[lineEndPos] = 0; CurrentSection += 1; @@ -236,9 +248,18 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect do { result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos); - if (result <= 1) { continue; } - if (strlen(CleanLine(Input)) <= 1) { continue; } - if (Input[0] == '[') { break; } + if (result <= 1) + { + continue; + } + if (strlen(CleanLine(Input)) <= 1) + { + continue; + } + if (Input[0] == '[') + { + break; + } char * Pos = strchr(Input, '='); if (Input[0] == '$') { @@ -246,7 +267,7 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect do { result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos); - if (result <= 1 || strlen(CleanLine(Input)) <= 1) + if (result <= 1 || strlen(CleanLine(Input)) <= 1) { break; } @@ -264,7 +285,7 @@ bool CEnhancmentFile::MoveToSection(const char * Section, bool ChangeCurrentSect } } else if (Pos != nullptr) - { + { char * Value = &Pos[1]; char * Pos1 = Pos - 1; @@ -323,7 +344,7 @@ void CEnhancmentFile::SaveCurrentSection(void) } PluginList += List[i].c_str(); } - Section += stdstr_f("Plugin List=%s%s", PluginList.c_str() , m_LineFeed); + Section += stdstr_f("Plugin List=%s%s", PluginList.c_str(), m_LineFeed); } if (Enhancement.GetOnByDefault()) { @@ -352,7 +373,7 @@ void CEnhancmentFile::SaveCurrentSection(void) if (Enhancement.CodeOptionSize() == 4) { Section += stdstr_f("%04X %s%s", Options[i].Value, Options[i].Name.c_str(), m_LineFeed); - } + } else if (Enhancement.CodeOptionSize() == 2) { Section += stdstr_f("%02X %s%s", Options[i].Value, Options[i].Name.c_str(), m_LineFeed); @@ -379,7 +400,7 @@ void CEnhancmentFile::SaveCurrentSection(void) m_File.Write(SectionName.get(), (int)strlen(SectionName.get())); m_CurrentSectionFilePos = m_File.GetPosition(); m_SectionsPos.insert(FILELOC::value_type(m_CurrentSection, m_CurrentSectionFilePos)); - } + } else { int NeededBufferLen = (int)Section.length(); @@ -397,7 +418,10 @@ void CEnhancmentFile::SaveCurrentSection(void) do { result = GetStringFromFile(Input, Data, MaxDataSize, DataSize, ReadPos); - if (result <= 1) { continue; } + if (result <= 1) + { + continue; + } if (strlen(CleanLine(Input)) <= 1 || Input[0] != '[') { EndPos = ((m_File.GetPosition() - DataSize) + ReadPos); @@ -423,9 +447,12 @@ void CEnhancmentFile::SaveCurrentSection(void) m_File.Write(Section.data(), (uint32_t)Section.length()); } -int CEnhancmentFile::GetStringFromFile(char * & String, std::unique_ptr & Data, int & MaxDataSize, int & DataSize, int & ReadPos) +int CEnhancmentFile::GetStringFromFile(char *& String, std::unique_ptr & Data, int & MaxDataSize, int & DataSize, int & ReadPos) { - enum { BufferIncrease = 0x2000 }; + enum + { + BufferIncrease = 0x2000 + }; if (MaxDataSize == 0) { ReadPos = 0; @@ -531,9 +558,9 @@ const char * CEnhancmentFile::CleanLine(char * Line) // Strip any spaces or line feeds from the end of the line for (int32_t i = (int32_t)strlen(&Line[0]) - 1; i >= 0; i--) { - if (Line[i] != ' ' && Line[i] != '\r') - { - break; + if (Line[i] != ' ' && Line[i] != '\r') + { + break; } Line[i] = 0; } @@ -542,7 +569,10 @@ const char * CEnhancmentFile::CleanLine(char * Line) void CEnhancmentFile::fInsertSpaces(int Pos, int NoOfSpaces) { - enum { fIS_MvSize = 0x2000 }; + enum + { + fIS_MvSize = 0x2000 + }; unsigned char Data[fIS_MvSize + 1]; int SizeToRead, result; @@ -558,7 +588,10 @@ void CEnhancmentFile::fInsertSpaces(int Pos, int NoOfSpaces) do { SizeToRead = end - Pos; - if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; } + if (SizeToRead > fIS_MvSize) + { + SizeToRead = fIS_MvSize; + } if (SizeToRead > 0) { m_File.Seek(SizeToRead * -1, CFileBase::current); @@ -582,7 +615,10 @@ void CEnhancmentFile::fInsertSpaces(int Pos, int NoOfSpaces) do { SizeToRead = end - ReadPos; - if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; } + if (SizeToRead > fIS_MvSize) + { + SizeToRead = fIS_MvSize; + } m_File.Seek(ReadPos, CFileBase::begin); m_File.Read(Data, SizeToRead); m_File.Seek(WritePos, CFileBase::begin); diff --git a/Source/Project64-core/N64System/Enhancement/EnhancementFile.h b/Source/Project64-core/N64System/Enhancement/EnhancementFile.h index 80eb5d98b..e66156964 100644 --- a/Source/Project64-core/N64System/Enhancement/EnhancementFile.h +++ b/Source/Project64-core/N64System/Enhancement/EnhancementFile.h @@ -1,19 +1,19 @@ #pragma once +#include +#include #include #include -#include -#include +#include +#include #include #include -#include #include -#include class CEnhancmentFile { struct insensitive_compare { - bool operator() (const std::string & a, const std::string & b) const + bool operator()(const std::string & a, const std::string & b) const { return _stricmp(a.c_str(), b.c_str()) < 0; } @@ -38,17 +38,20 @@ public: void GetSections(SectionList & sections); - const char * FileName(void) const { return m_FileName.c_str(); } + const char * FileName(void) const + { + return m_FileName.c_str(); + } private: CEnhancmentFile(); - CEnhancmentFile(const CEnhancmentFile&); - CEnhancmentFile& operator=(const CEnhancmentFile&); + CEnhancmentFile(const CEnhancmentFile &); + CEnhancmentFile & operator=(const CEnhancmentFile &); bool AddEnhancement(const CEnhancement & Details); void OpenFile(void); bool MoveToSection(const char * Section, bool ChangeCurrentSection); - int GetStringFromFile(char * & String, std::unique_ptr & Data, int & MaxDataSize, int & DataSize, int & ReadPos); + int GetStringFromFile(char *& String, std::unique_ptr & Data, int & MaxDataSize, int & DataSize, int & ReadPos); const char * CleanLine(char * Line); void fInsertSpaces(int32_t Pos, int32_t NoOfSpaces); void ClearSectionPosList(long FilePos); diff --git a/Source/Project64-core/N64System/Enhancement/EnhancementList.h b/Source/Project64-core/N64System/Enhancement/EnhancementList.h index 7a9da44c4..8409d7698 100644 --- a/Source/Project64-core/N64System/Enhancement/EnhancementList.h +++ b/Source/Project64-core/N64System/Enhancement/EnhancementList.h @@ -1,12 +1,12 @@ #pragma once -#include -#include -#include #include +#include +#include +#include struct EnhancementItemList_compare { - bool operator() (const std::string & a, const std::string & b) const + bool operator()(const std::string & a, const std::string & b) const { return _stricmp(a.c_str(), b.c_str()) < 0; } diff --git a/Source/Project64-core/N64System/Enhancement/Enhancements.h b/Source/Project64-core/N64System/Enhancement/Enhancements.h index fed322f0f..f1e61f59f 100644 --- a/Source/Project64-core/N64System/Enhancement/Enhancements.h +++ b/Source/Project64-core/N64System/Enhancement/Enhancements.h @@ -1,8 +1,8 @@ #pragma once +#include +#include #include #include -#include -#include #include #include @@ -19,7 +19,7 @@ class CEnhancements public: CEnhancements(); ~CEnhancements(); - + void ApplyActive(CMipsMemoryVM & MMU, CPlugins * Plugins, bool UpdateChanges); void ApplyGSButton(CMipsMemoryVM & MMU, bool UpdateChanges); void UpdateCheats(const CEnhancementList & Cheats); @@ -36,17 +36,29 @@ private: class GAMESHARK_CODE { public: - GAMESHARK_CODE(const GAMESHARK_CODE&); + GAMESHARK_CODE(const GAMESHARK_CODE &); GAMESHARK_CODE(uint32_t Command, uint16_t Value, bool HasDisableValue, uint16_t DisableValue); - - uint32_t Command(void) const { return m_Command; } - uint16_t Value(void) const { return m_Value; } - bool HasDisableValue(void) const { return m_HasDisableValue; } - uint16_t DisableValue(void) const { return m_DisableValue; } + + uint32_t Command(void) const + { + return m_Command; + } + uint16_t Value(void) const + { + return m_Value; + } + bool HasDisableValue(void) const + { + return m_HasDisableValue; + } + uint16_t DisableValue(void) const + { + return m_DisableValue; + } private: GAMESHARK_CODE(); - GAMESHARK_CODE& operator=(const GAMESHARK_CODE&); + GAMESHARK_CODE & operator=(const GAMESHARK_CODE &); uint32_t m_Command; uint16_t m_Value; @@ -86,7 +98,11 @@ private: static uint32_t ConvertXP64Address(uint32_t Address); static uint16_t ConvertXP64Value(uint16_t Value); - static uint32_t stScanFileThread(void * lpThreadParameter) { ((CEnhancements *)lpThreadParameter)->ScanFileThread(); return 0; } + static uint32_t stScanFileThread(void * lpThreadParameter) + { + ((CEnhancements *)lpThreadParameter)->ScanFileThread(); + return 0; + } CriticalSection m_CS; SectionFiles m_CheatFiles, m_EnhancementFiles; diff --git a/Source/Project64-core/N64System/FramePerSecond.cpp b/Source/Project64-core/N64System/FramePerSecond.cpp index 9a8a416e9..b3bff32a7 100644 --- a/Source/Project64-core/N64System/FramePerSecond.cpp +++ b/Source/Project64-core/N64System/FramePerSecond.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "FramePerSecond.h" #include @@ -86,7 +87,10 @@ void CFramePerSecond::UpdateDisplay(void) } if (m_iFrameRateType == FR_DLs || m_iFrameRateType == FR_VIs_DLs) { - if (DisplayString.length() > 0) { DisplayString += " "; } + if (DisplayString.length() > 0) + { + DisplayString += " "; + } DisplayString += stdstr_f(m_DlistFrameRate >= 0 ? "DL/s: %.1f" : "DL/s: -.--", m_DlistFrameRate); } g_Notify->DisplayMessage2(DisplayString.c_str()); diff --git a/Source/Project64-core/N64System/FramePerSecond.h b/Source/Project64-core/N64System/FramePerSecond.h index 2c3d26df1..2643068ff 100644 --- a/Source/Project64-core/N64System/FramePerSecond.h +++ b/Source/Project64-core/N64System/FramePerSecond.h @@ -1,6 +1,6 @@ #pragma once -#include #include "../Settings/N64SystemSettings.h" +#include class CFramePerSecond : public CN64SystemSettings { @@ -15,16 +15,19 @@ public: void DisplayViCounter(int32_t FrameRateWhole, uint32_t FrameRateFraction); private: - CFramePerSecond(const CFramePerSecond&); - CFramePerSecond& operator=(const CFramePerSecond&); + CFramePerSecond(const CFramePerSecond &); + CFramePerSecond & operator=(const CFramePerSecond &); static void FrameRateTypeChanged(CFramePerSecond * _this); static void ScreenHertzChanged(CFramePerSecond * _this); void UpdateDisplay(void); - int32_t m_iFrameRateType, m_ScreenHertz; + int32_t m_iFrameRateType, m_ScreenHertz; - enum { NoOfFrames = 7 }; + enum + { + NoOfFrames = 7 + }; HighResTimeStamp m_LastViFrame; uint64_t m_ViFrames[NoOfFrames]; diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterCPU.h b/Source/Project64-core/N64System/Interpreter/InterpreterCPU.h index b6a9496eb..5e3d0add1 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterCPU.h +++ b/Source/Project64-core/N64System/Interpreter/InterpreterCPU.h @@ -10,11 +10,11 @@ public: static void ExecuteCPU(); static void ExecuteOps(int32_t Cycles); static void InPermLoop(); - + private: CInterpreterCPU(); - CInterpreterCPU(const CInterpreterCPU&); - CInterpreterCPU& operator=(const CInterpreterCPU&); + CInterpreterCPU(const CInterpreterCPU &); + CInterpreterCPU & operator=(const CInterpreterCPU &); static R4300iOp::Func * m_R4300i_Opcode; }; diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp index b93583613..0c86f2702 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp @@ -2133,7 +2133,7 @@ void R4300iOp::COP1_BCTL() __inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) // warning C4244: disable conversion from 'float' to 'int32_t', possible loss of data +#pragma warning(disable : 4244) // warning C4244: disable conversion from 'float' to 'int32_t', possible loss of data if (RoundType == FE_TONEAREST) { @@ -2155,9 +2155,18 @@ __inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int R *Dest = roundf(*Source); } } - else if (RoundType == FE_TOWARDZERO) { *Dest = truncf(*Source); } - else if (RoundType == FE_UPWARD) { *Dest = ceilf(*Source); } - else if (RoundType == FE_DOWNWARD) { *Dest = floorf(*Source); } + else if (RoundType == FE_TOWARDZERO) + { + *Dest = truncf(*Source); + } + else if (RoundType == FE_UPWARD) + { + *Dest = ceilf(*Source); + } + else if (RoundType == FE_DOWNWARD) + { + *Dest = floorf(*Source); + } #pragma warning(pop) } @@ -2165,7 +2174,7 @@ __inline void Float_RoundToInteger32(int32_t * Dest, const float * Source, int R __inline void Float_RoundToInteger64(int64_t * Dest, const float * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) // warning C4244: disable conversion from 'float' to 'int64_t', possible loss of data +#pragma warning(disable : 4244) // warning C4244: disable conversion from 'float' to 'int64_t', possible loss of data if (RoundType == FE_TONEAREST) { @@ -2187,9 +2196,18 @@ __inline void Float_RoundToInteger64(int64_t * Dest, const float * Source, int R *Dest = roundf(*Source); } } - else if (RoundType == FE_TOWARDZERO) { *Dest = truncf(*Source); } - else if (RoundType == FE_UPWARD) { *Dest = ceilf(*Source); } - else if (RoundType == FE_DOWNWARD) { *Dest = floorf(*Source); } + else if (RoundType == FE_TOWARDZERO) + { + *Dest = truncf(*Source); + } + else if (RoundType == FE_UPWARD) + { + *Dest = ceilf(*Source); + } + else if (RoundType == FE_DOWNWARD) + { + *Dest = floorf(*Source); + } #pragma warning(pop) } @@ -2353,7 +2371,7 @@ void R4300iOp::COP1_S_CMP() } condition = ((m_Opcode.funct & 4) && less) | ((m_Opcode.funct & 2) && equal) | - ((m_Opcode.funct & 1) && unorded); + ((m_Opcode.funct & 1) && unorded); if (condition) { @@ -2370,7 +2388,7 @@ void R4300iOp::COP1_S_CMP() __inline void Double_RoundToInteger32(int32_t * Dest, const double * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) // warning C4244: disable conversion from 'double' to 'uint32_t', possible loss of data +#pragma warning(disable : 4244) // warning C4244: disable conversion from 'double' to 'uint32_t', possible loss of data if (RoundType == FE_TONEAREST) { @@ -2392,9 +2410,18 @@ __inline void Double_RoundToInteger32(int32_t * Dest, const double * Source, int *Dest = round(*Source); } } - else if (RoundType == FE_TOWARDZERO) { *Dest = trunc(*Source); } - else if (RoundType == FE_UPWARD) { *Dest = ceil(*Source); } - else if (RoundType == FE_DOWNWARD) { *Dest = floor(*Source); } + else if (RoundType == FE_TOWARDZERO) + { + *Dest = trunc(*Source); + } + else if (RoundType == FE_UPWARD) + { + *Dest = ceil(*Source); + } + else if (RoundType == FE_DOWNWARD) + { + *Dest = floor(*Source); + } else { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -2406,7 +2433,7 @@ __inline void Double_RoundToInteger32(int32_t * Dest, const double * Source, int __inline void Double_RoundToInteger64(int64_t * Dest, const double * Source, int RoundType) { #pragma warning(push) -#pragma warning(disable:4244) // warning C4244: disable conversion from 'double' to 'uint64_t', possible loss of data +#pragma warning(disable : 4244) // warning C4244: disable conversion from 'double' to 'uint64_t', possible loss of data if (RoundType == FE_TONEAREST) { @@ -2428,9 +2455,18 @@ __inline void Double_RoundToInteger64(int64_t * Dest, const double * Source, int *Dest = round(*Source); } } - else if (RoundType == FE_TOWARDZERO) { *Dest = trunc(*Source); } - else if (RoundType == FE_UPWARD) { *Dest = ceil(*Source); } - else if (RoundType == FE_DOWNWARD) { *Dest = floor(*Source); } + else if (RoundType == FE_TOWARDZERO) + { + *Dest = trunc(*Source); + } + else if (RoundType == FE_UPWARD) + { + *Dest = ceil(*Source); + } + else if (RoundType == FE_DOWNWARD) + { + *Dest = floor(*Source); + } else { g_Notify->BreakPoint(__FILE__, __LINE__); @@ -2598,7 +2634,7 @@ void R4300iOp::COP1_D_CMP() } condition = ((m_Opcode.funct & 4) && less) | ((m_Opcode.funct & 2) && equal) | - ((m_Opcode.funct & 1) && unorded); + ((m_Opcode.funct & 1) && unorded); if (condition) { diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.h b/Source/Project64-core/N64System/Interpreter/InterpreterOps.h index 5acc17fab..5bcf43d69 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.h +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.h @@ -1,8 +1,8 @@ #pragma once -#include -#include #include +#include +#include class R4300iOp : public CLogging, @@ -10,7 +10,7 @@ class R4300iOp : protected CSystemRegisters { public: - typedef void(*Func)(); + typedef void (*Func)(); // Opcode functions static void J(); @@ -101,12 +101,12 @@ public: static void SPECIAL_DADDU(); static void SPECIAL_DSUB(); static void SPECIAL_DSUBU(); - static void SPECIAL_TGE(); - static void SPECIAL_TGEU(); - static void SPECIAL_TLT(); - static void SPECIAL_TLTU(); + static void SPECIAL_TGE(); + static void SPECIAL_TGEU(); + static void SPECIAL_TLT(); + static void SPECIAL_TLTU(); static void SPECIAL_TEQ(); - static void SPECIAL_TNE(); + static void SPECIAL_TNE(); static void SPECIAL_DSLL(); static void SPECIAL_DSRL(); static void SPECIAL_DSRA(); @@ -167,11 +167,11 @@ public: static void COP1_S_NEG(); static void COP1_S_ROUND_L(); static void COP1_S_TRUNC_L(); - static void COP1_S_CEIL_L(); - static void COP1_S_FLOOR_L(); + static void COP1_S_CEIL_L(); + static void COP1_S_FLOOR_L(); static void COP1_S_ROUND_W(); static void COP1_S_TRUNC_W(); - static void COP1_S_CEIL_W(); + static void COP1_S_CEIL_W(); static void COP1_S_FLOOR_W(); static void COP1_S_CVT_D(); static void COP1_S_CVT_W(); @@ -188,13 +188,13 @@ public: static void COP1_D_MOV(); static void COP1_D_NEG(); static void COP1_D_ROUND_L(); - static void COP1_D_TRUNC_L(); - static void COP1_D_CEIL_L(); - static void COP1_D_FLOOR_L(); + static void COP1_D_TRUNC_L(); + static void COP1_D_CEIL_L(); + static void COP1_D_FLOOR_L(); static void COP1_D_ROUND_W(); static void COP1_D_TRUNC_W(); - static void COP1_D_CEIL_W(); - static void COP1_D_FLOOR_W(); + static void COP1_D_CEIL_W(); + static void COP1_D_FLOOR_W(); static void COP1_D_CVT_S(); static void COP1_D_CVT_W(); static void COP1_D_CVT_L(); @@ -212,12 +212,12 @@ public: static void ReservedInstruction(); static void UnknownOpcode(); - static Func* BuildInterpreter(); + static Func * BuildInterpreter(); static bool m_TestTimer; static R4300iOpcode m_Opcode; - static bool MemoryBreakpoint(); + static bool MemoryBreakpoint(); protected: static void SPECIAL(); diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp index 9813bc00a..d9402b5ae 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.cpp @@ -1,20 +1,22 @@ #include "stdafx.h" -#include "InterpreterOps32.h" -#include -#include -#include -#include -#include -#include -#include -#include -#define TEST_COP1_USABLE_EXCEPTION \ - if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\ - g_Reg->DoCopUnusableException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP,1);\ - g_System->m_PipelineStage = PIPELINE_STAGE_JUMP;\ - g_System->m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return;\ +#include "InterpreterOps32.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define TEST_COP1_USABLE_EXCEPTION \ + if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) \ + { \ + g_Reg->DoCopUnusableException(g_System->m_PipelineStage == PIPELINE_STAGE_JUMP, 1); \ + g_System->m_PipelineStage = PIPELINE_STAGE_JUMP; \ + g_System->m_JumpToLocation = (*_PROGRAM_COUNTER); \ + return; \ } R4300iOp32::Func * R4300iOp32::BuildInterpreter() @@ -1261,7 +1263,10 @@ void R4300iOp32::COP1_CF() TEST_COP1_USABLE_EXCEPTION if (m_Opcode.fs != 31 && m_Opcode.fs != 0) { - if (CDebugSettings::HaveDebugger()) { g_Notify->DisplayError("CFC1: what register are you writing to?"); } + if (CDebugSettings::HaveDebugger()) + { + g_Notify->DisplayError("CFC1: what register are you writing to?"); + } return; } _GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs]; diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h index 615842669..9794b9f5b 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps32.h @@ -7,67 +7,67 @@ class R4300iOp32 : { public: // Opcode functions - static void JAL(); - static void BEQ(); - static void BNE(); - static void BLEZ(); - static void BGTZ(); - static void ADDI(); - static void ADDIU(); - static void SLTI(); - static void SLTIU(); - static void ANDI(); - static void ORI(); - static void XORI(); - static void LUI(); - static void BEQL(); - static void BNEL(); - static void BLEZL(); - static void BGTZL(); - static void LB(); - static void LH(); - static void LWL(); - static void LW(); - static void LBU(); - static void LHU(); - static void LWR(); - static void LWU(); - static void LL(); + static void JAL(); + static void BEQ(); + static void BNE(); + static void BLEZ(); + static void BGTZ(); + static void ADDI(); + static void ADDIU(); + static void SLTI(); + static void SLTIU(); + static void ANDI(); + static void ORI(); + static void XORI(); + static void LUI(); + static void BEQL(); + static void BNEL(); + static void BLEZL(); + static void BGTZL(); + static void LB(); + static void LH(); + static void LWL(); + static void LW(); + static void LBU(); + static void LHU(); + static void LWR(); + static void LWU(); + static void LL(); // R4300i opcodes: Special - static void SPECIAL_SLL(); - static void SPECIAL_SRL(); - static void SPECIAL_SRA(); - static void SPECIAL_SLLV(); - static void SPECIAL_SRLV(); - static void SPECIAL_SRAV(); - static void SPECIAL_JALR(); - static void SPECIAL_ADD(); - static void SPECIAL_ADDU(); - static void SPECIAL_SUB(); - static void SPECIAL_SUBU(); - static void SPECIAL_AND(); - static void SPECIAL_OR(); - static void SPECIAL_NOR(); - static void SPECIAL_SLT(); - static void SPECIAL_SLTU(); - static void SPECIAL_TEQ(); + static void SPECIAL_SLL(); + static void SPECIAL_SRL(); + static void SPECIAL_SRA(); + static void SPECIAL_SLLV(); + static void SPECIAL_SRLV(); + static void SPECIAL_SRAV(); + static void SPECIAL_JALR(); + static void SPECIAL_ADD(); + static void SPECIAL_ADDU(); + static void SPECIAL_SUB(); + static void SPECIAL_SUBU(); + static void SPECIAL_AND(); + static void SPECIAL_OR(); + static void SPECIAL_NOR(); + static void SPECIAL_SLT(); + static void SPECIAL_SLTU(); + static void SPECIAL_TEQ(); // R4300i opcodes: RegImm - static void REGIMM_BLTZ(); - static void REGIMM_BGEZ(); - static void REGIMM_BLTZL(); - static void REGIMM_BGEZL(); - static void REGIMM_BLTZAL(); - static void REGIMM_BGEZAL(); + static void REGIMM_BLTZ(); + static void REGIMM_BGEZ(); + static void REGIMM_BLTZL(); + static void REGIMM_BGEZL(); + static void REGIMM_BLTZAL(); + static void REGIMM_BGEZAL(); // COP0 functions - static void COP0_MF(); + static void COP0_MF(); // COP1 functions - static void COP1_MF(); - static void COP1_CF(); - static void COP1_DMT(); + static void COP1_MF(); + static void COP1_CF(); + static void COP1_DMT(); - static Func* BuildInterpreter(); + static Func * BuildInterpreter(); }; diff --git a/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.cpp index 7344c8a4f..9d90458d6 100644 --- a/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "AudioInterfaceHandler.h" -#include #include +#include #include AudioInterfaceReg::AudioInterfaceReg(uint32_t * _AudioInterface) : @@ -199,9 +200,9 @@ void AudioInterfaceHandler::SetFrequency(uint32_t Dacrate, uint32_t System) switch (System) { - case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break; + case SYSTEM_PAL: Frequency = 49656530 / (Dacrate + 1); break; case SYSTEM_MPAL: Frequency = 48628316 / (Dacrate + 1); break; - default: Frequency = 48681812 / (Dacrate + 1); break; + default: Frequency = 48681812 / (Dacrate + 1); break; } //nBlockAlign = 16 / 8 * 2; @@ -239,7 +240,7 @@ uint32_t AudioInterfaceHandler::GetLength(void) uint32_t TimeLeft = g_SystemTimer->GetTimer(CSystemTimer::AiTimerInterrupt), Res = 0; if (TimeLeft > 0) { - Res = (TimeLeft / m_CountsPerByte)&~7; + Res = (TimeLeft / m_CountsPerByte) & ~7; } WriteTrace(TraceAudio, TraceDebug, "Done (res = %d, TimeLeft = %d)", Res, TimeLeft); return Res; @@ -301,4 +302,3 @@ void AudioInterfaceHandler::LenChanged() } WriteTrace(TraceAudio, TraceDebug, "Done"); } - diff --git a/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.h index df94f9e7e..0185b5ea6 100644 --- a/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/AudioInterfaceHandler.h @@ -1,14 +1,14 @@ #pragma once #include "MemoryHandler.h" +#include #include #include -#include #include enum { - AI_STATUS_FIFO_FULL = 0x80000000, // Bit 31: Full - AI_STATUS_DMA_BUSY = 0x40000000, // Bit 30: Busy + AI_STATUS_FIFO_FULL = 0x80000000, // Bit 31: Full + AI_STATUS_DMA_BUSY = 0x40000000, // Bit 30: Busy }; class AudioInterfaceReg @@ -26,8 +26,8 @@ public: private: AudioInterfaceReg(); - AudioInterfaceReg(const AudioInterfaceReg&); - AudioInterfaceReg& operator=(const AudioInterfaceReg&); + AudioInterfaceReg(const AudioInterfaceReg &); + AudioInterfaceReg & operator=(const AudioInterfaceReg &); }; class CRegisters; @@ -60,8 +60,14 @@ private: AudioInterfaceHandler(const AudioInterfaceHandler &); AudioInterfaceHandler & operator=(const AudioInterfaceHandler &); - static void stSystemReset(AudioInterfaceHandler * _this) { _this->SystemReset(); } - static void stLoadedGameState(AudioInterfaceHandler * _this) { _this->LoadedGameState(); } + static void stSystemReset(AudioInterfaceHandler * _this) + { + _this->SystemReset(); + } + static void stLoadedGameState(AudioInterfaceHandler * _this) + { + _this->LoadedGameState(); + } void LoadedGameState(void); void SystemReset(void); diff --git a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address1Handler.cpp b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address1Handler.cpp index fe290d29f..56c7ab85d 100644 --- a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address1Handler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address1Handler.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "CartridgeDomain1Address1Handler.h" #include #include diff --git a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address3Handler.cpp b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address3Handler.cpp index 94074cfca..d80a5faad 100644 --- a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address3Handler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain1Address3Handler.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "CartridgeDomain1Address3Handler.h" CartridgeDomain1Address3Handler::CartridgeDomain1Address3Handler() diff --git a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.cpp b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.cpp index d4cc71042..5b8220152 100644 --- a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "CartridgeDomain2Address1Handler.h" -#include #include +#include DiskInterfaceReg::DiskInterfaceReg(uint32_t * DiskInterface) : ASIC_DATA(DiskInterface[0]), diff --git a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.h b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.h index e7ea6d701..0f7030cc3 100644 --- a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.h +++ b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address1Handler.h @@ -63,8 +63,8 @@ public: private: DiskInterfaceReg(); - DiskInterfaceReg(const DiskInterfaceReg&); - DiskInterfaceReg& operator=(const DiskInterfaceReg&); + DiskInterfaceReg(const DiskInterfaceReg &); + DiskInterfaceReg & operator=(const DiskInterfaceReg &); }; class CRegisters; diff --git a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.cpp b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.cpp index 36f5509b8..aaff55d4f 100644 --- a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "CartridgeDomain2Address2Handler.h" #include @@ -91,7 +92,7 @@ bool CartridgeDomain2Address2Handler::DMARead() } if (m_System.m_SaveUsing == SaveChip_Sram) { - m_Sram.DmaToSram(m_MMU.Rdram() + m_Reg.PI_DRAM_ADDR_REG,m_Reg.PI_CART_ADDR_REG - 0x08000000, PI_RD_LEN_REG); + m_Sram.DmaToSram(m_MMU.Rdram() + m_Reg.PI_DRAM_ADDR_REG, m_Reg.PI_CART_ADDR_REG - 0x08000000, PI_RD_LEN_REG); m_Reg.PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; m_Reg.PI_STATUS_REG |= PI_STATUS_INTERRUPT; m_Reg.MI_INTR_REG |= MI_INTR_PI; diff --git a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.h b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.h index 6bc059aa1..e7829de10 100644 --- a/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.h +++ b/Source/Project64-core/N64System/MemoryHandler/CartridgeDomain2Address2Handler.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include #include "MemoryHandler.h" +#include +#include +#include class CN64System; class CMipsMemoryVM; @@ -21,8 +21,14 @@ public: bool DMARead(); void DMAWrite(); - CSram & Sram(void) { return m_Sram; } - CFlashRam & FlashRam (void) { return m_FlashRam; } + CSram & Sram(void) + { + return m_Sram; + } + CFlashRam & FlashRam(void) + { + return m_FlashRam; + } private: CartridgeDomain2Address2Handler(void); diff --git a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp index a1034b96f..7621fc043 100644 --- a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.cpp @@ -1,11 +1,12 @@ #include "stdafx.h" -#include -#include -#include -#include -#include -#include + #include "SPRegistersHandler.h" +#include +#include +#include +#include +#include +#include DisplayControlRegHandler::DisplayControlRegHandler(CN64System & N64System, CPlugins * Plugins, CRegisters & Reg) : DisplayControlReg(Reg.m_Display_ControlReg), @@ -143,4 +144,3 @@ bool DisplayControlRegHandler::Write32(uint32_t Address, uint32_t Value, uint32_ } return true; } - diff --git a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h index 25a155c35..3327adbaa 100644 --- a/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/DisplayControlRegHandler.h @@ -1,34 +1,34 @@ #pragma once -#include -#include -#include "SPRegistersHandler.h" #include "MemoryHandler.h" +#include "SPRegistersHandler.h" +#include +#include #include enum { - DPC_CLR_XBUS_DMEM_DMA = 0x0001, // Bit 0: Clear xbus_dmem_dma - DPC_SET_XBUS_DMEM_DMA = 0x0002, // Bit 1: Set xbus_dmem_dma - DPC_CLR_FREEZE = 0x0004, // Bit 2: Clear freeze - DPC_SET_FREEZE = 0x0008, // Bit 3: Set freeze - DPC_CLR_FLUSH = 0x0010, // Bit 4: Clear flush - DPC_SET_FLUSH = 0x0020, // Bit 5: Set flush - DPC_CLR_TMEM_CTR = 0x0040, // Bit 6: Clear TMEM CTR - DPC_CLR_PIPE_CTR = 0x0080, // Bit 7: Clear pipe CTR - DPC_CLR_CMD_CTR = 0x0100, // Bit 8: Clear CMD CTR - DPC_CLR_CLOCK_CTR = 0x0200, // Bit 9: Clear clock CTR + DPC_CLR_XBUS_DMEM_DMA = 0x0001, // Bit 0: Clear xbus_dmem_dma + DPC_SET_XBUS_DMEM_DMA = 0x0002, // Bit 1: Set xbus_dmem_dma + DPC_CLR_FREEZE = 0x0004, // Bit 2: Clear freeze + DPC_SET_FREEZE = 0x0008, // Bit 3: Set freeze + DPC_CLR_FLUSH = 0x0010, // Bit 4: Clear flush + DPC_SET_FLUSH = 0x0020, // Bit 5: Set flush + DPC_CLR_TMEM_CTR = 0x0040, // Bit 6: Clear TMEM CTR + DPC_CLR_PIPE_CTR = 0x0080, // Bit 7: Clear pipe CTR + DPC_CLR_CMD_CTR = 0x0100, // Bit 8: Clear CMD CTR + DPC_CLR_CLOCK_CTR = 0x0200, // Bit 9: Clear clock CTR - DPC_STATUS_XBUS_DMEM_DMA = 0x001, // Bit 0: xbus_dmem_dma - DPC_STATUS_FREEZE = 0x002, // Bit 1: Freeze - DPC_STATUS_FLUSH = 0x004, // Bit 2: Flush - DPC_STATUS_START_GCLK = 0x008, // Bit 3: Start GCLK - DPC_STATUS_TMEM_BUSY = 0x010, // Bit 4: TMEM busy - DPC_STATUS_PIPE_BUSY = 0x020, // Bit 5: Pipe busy - DPC_STATUS_CMD_BUSY = 0x040, // Bit 6: CMD busy - DPC_STATUS_CBUF_READY = 0x080, // Bit 7: CBUF ready - DPC_STATUS_DMA_BUSY = 0x100, // Bit 8: DMA busy - DPC_STATUS_END_VALID = 0x200, // Bit 9: End valid - DPC_STATUS_START_VALID = 0x400, // Bit 10: Start valid + DPC_STATUS_XBUS_DMEM_DMA = 0x001, // Bit 0: xbus_dmem_dma + DPC_STATUS_FREEZE = 0x002, // Bit 1: Freeze + DPC_STATUS_FLUSH = 0x004, // Bit 2: Flush + DPC_STATUS_START_GCLK = 0x008, // Bit 3: Start GCLK + DPC_STATUS_TMEM_BUSY = 0x010, // Bit 4: TMEM busy + DPC_STATUS_PIPE_BUSY = 0x020, // Bit 5: Pipe busy + DPC_STATUS_CMD_BUSY = 0x040, // Bit 6: CMD busy + DPC_STATUS_CBUF_READY = 0x080, // Bit 7: CBUF ready + DPC_STATUS_DMA_BUSY = 0x100, // Bit 8: DMA busy + DPC_STATUS_END_VALID = 0x200, // Bit 9: End valid + DPC_STATUS_START_VALID = 0x400, // Bit 10: Start valid }; class DisplayControlReg @@ -48,8 +48,8 @@ public: private: DisplayControlReg(); - DisplayControlReg(const DisplayControlReg&); - DisplayControlReg& operator=(const DisplayControlReg&); + DisplayControlReg(const DisplayControlReg &); + DisplayControlReg & operator=(const DisplayControlReg &); }; class CN64System; diff --git a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp index 37d165baf..7748eac67 100644 --- a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" + #include "ISViewerHandler.h" -#include -#include #include +#include +#include ISViewerHandler::ISViewerHandler(CN64System & System) : m_hLogFile(nullptr), @@ -70,10 +71,7 @@ uint32_t ISViewerHandler::Swap32by8(uint32_t Value) #elif defined(__GNUC__) __builtin_bswap32(Value) #else - (Value & 0x000000FFul) << 24 - | (Value & 0x0000FF00ul) << 8 - | (Value & 0x00FF0000ul) >> 8 - | (Value & 0xFF000000ul) >> 24 + (Value & 0x000000FFul) << 24 | (Value & 0x0000FF00ul) << 8 | (Value & 0x00FF0000ul) >> 8 | (Value & 0xFF000000ul) >> 24 #endif ; return (Swapped & 0xFFFFFFFFul); diff --git a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h index 62a8c3749..6336abcef 100644 --- a/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/ISViewerHandler.h @@ -2,8 +2,8 @@ #include "MemoryHandler.h" #include #include -#include #include +#include class CN64System; @@ -21,7 +21,10 @@ private: ISViewerHandler(const ISViewerHandler &); ISViewerHandler & operator=(const ISViewerHandler &); - static void stSystemReset(ISViewerHandler * _this) { _this->SystemReset(); } + static void stSystemReset(ISViewerHandler * _this) + { + _this->SystemReset(); + } static uint32_t Swap32by8(uint32_t Value); void SystemReset(void); diff --git a/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.cpp index 6c4586695..668f3873b 100644 --- a/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "MIPSInterfaceHandler.h" -#include #include +#include MIPSInterfaceReg::MIPSInterfaceReg(uint32_t * MipsInterface) : MI_INIT_MODE_REG(MipsInterface[0]), diff --git a/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.h index 56986ca23..de0945d43 100644 --- a/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/MIPSInterfaceHandler.h @@ -1,7 +1,7 @@ #pragma once #include "MemoryHandler.h" -#include #include +#include #include class MIPSInterfaceReg @@ -19,8 +19,8 @@ public: private: MIPSInterfaceReg(); - MIPSInterfaceReg(const MIPSInterfaceReg&); - MIPSInterfaceReg& operator=(const MIPSInterfaceReg&); + MIPSInterfaceReg(const MIPSInterfaceReg &); + MIPSInterfaceReg & operator=(const MIPSInterfaceReg &); }; class CRegisters; diff --git a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp index ad05c9fbb..6568b8f0a 100644 --- a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.cpp @@ -1,14 +1,15 @@ #include "stdafx.h" -#include -#include -#include -#include -#include -#include -#include -#include + #include "PeripheralInterfaceHandler.h" #include +#include +#include +#include +#include +#include +#include +#include +#include PeripheralInterfaceReg::PeripheralInterfaceReg(uint32_t * PeripheralInterface) : PI_DRAM_ADDR_REG(PeripheralInterface[0]), @@ -216,7 +217,7 @@ void PeripheralInterfaceHandler::PI_DMA_READ() } // PI_STATUS_REG |= PI_STATUS_DMA_BUSY; - uint32_t PI_RD_LEN = ((PI_RD_LEN_REG) & 0x00FFFFFFul) + 1; + uint32_t PI_RD_LEN = ((PI_RD_LEN_REG)&0x00FFFFFFul) + 1; if ((PI_RD_LEN & 1) != 0) { PI_RD_LEN += 1; @@ -351,7 +352,7 @@ void PeripheralInterfaceHandler::PI_DMA_WRITE() uint32_t WritePos = PI_DRAM_ADDR_REG & 0x7FFFFE; uint32_t ReadPos = PI_CART_ADDR_REG; - + if (ReadPos >= 0x05000580 && ReadPos <= 0x050005BF) { // 64DD MSEQ (don't care) @@ -412,7 +413,7 @@ void PeripheralInterfaceHandler::PI_DMA_WRITE() TransferLen += (BlockLen + 7) & ~7; FirstBlock = false; } - + if (ReadPos >= 0x05000000 && ReadPos <= 0x050004FF) { // 64DD buffers read and 64DD user sector diff --git a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h index 0469bdcad..f7024db67 100644 --- a/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/PeripheralInterfaceHandler.h @@ -1,8 +1,9 @@ #pragma once -#include -#include -#include #include "MemoryHandler.h" +#include +#include +#include +#include #include class PeripheralInterfaceReg @@ -29,10 +30,11 @@ public: private: PeripheralInterfaceReg(); - PeripheralInterfaceReg(const PeripheralInterfaceReg&); - PeripheralInterfaceReg& operator=(const PeripheralInterfaceReg&); + PeripheralInterfaceReg(const PeripheralInterfaceReg &); + PeripheralInterfaceReg & operator=(const PeripheralInterfaceReg &); }; +class CN64System; class CRegisters; class CMipsMemoryVM; class CartridgeDomain2Address2Handler; @@ -68,8 +70,14 @@ private: PeripheralInterfaceHandler(const PeripheralInterfaceHandler &); PeripheralInterfaceHandler & operator=(const PeripheralInterfaceHandler &); - static void stSystemReset(PeripheralInterfaceHandler * _this) { _this->SystemReset(); } - static void stLoadedGameState(PeripheralInterfaceHandler * _this) { _this->LoadedGameState(); } + static void stSystemReset(PeripheralInterfaceHandler * _this) + { + _this->SystemReset(); + } + static void stLoadedGameState(PeripheralInterfaceHandler * _this) + { + _this->LoadedGameState(); + } void PI_DMA_READ(); void PI_DMA_WRITE(); diff --git a/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.cpp index 4ced3278c..a39a769a0 100644 --- a/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "PifRamHandler.h" #include #include @@ -79,10 +80,7 @@ uint32_t PifRamHandler::swap32by8(uint32_t word) #elif defined(__GNUC__) __builtin_bswap32(word) #else - (word & 0x000000FFul) << 24 - | (word & 0x0000FF00ul) << 8 - | (word & 0x00FF0000ul) >> 8 - | (word & 0xFF000000ul) >> 24 + (word & 0x000000FFul) << 24 | (word & 0x0000FF00ul) << 8 | (word & 0x00FF0000ul) >> 8 | (word & 0xFF000000ul) >> 24 #endif ; return (swapped & 0xFFFFFFFFul); diff --git a/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.h b/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.h index bafb805a0..b5dd530fb 100644 --- a/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/PifRamHandler.h @@ -1,7 +1,7 @@ #pragma once #include "MemoryHandler.h" -#include #include +#include #include class CMipsMemoryVM; diff --git a/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.cpp index 601f15323..90d06b88d 100644 --- a/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" -#include -#include + #include "RDRAMInterfaceHandler.h" +#include +#include RDRAMInterfaceReg::RDRAMInterfaceReg(uint32_t * RdramInterface) : RI_MODE_REG(RdramInterface[0]), diff --git a/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.h index 8b6de7d4c..62fd58923 100644 --- a/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/RDRAMInterfaceHandler.h @@ -1,7 +1,7 @@ #pragma once #include "MemoryHandler.h" -#include #include +#include #include class RDRAMInterfaceReg diff --git a/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.cpp index 7e00b18fd..563addc96 100644 --- a/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "RDRAMRegistersHandler.h" #include #include diff --git a/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.h b/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.h index faeb7858c..bb4a7fad6 100644 --- a/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/RDRAMRegistersHandler.h @@ -1,7 +1,7 @@ #pragma once #include "MemoryHandler.h" -#include #include +#include #include class RDRAMRegistersReg @@ -24,8 +24,8 @@ public: private: RDRAMRegistersReg(); - RDRAMRegistersReg(const RDRAMRegistersReg&); - RDRAMRegistersReg& operator=(const RDRAMRegistersReg&); + RDRAMRegistersReg(const RDRAMRegistersReg &); + RDRAMRegistersReg & operator=(const RDRAMRegistersReg &); }; class CRegisters; diff --git a/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.cpp index f9ec4b5ca..cdb93da4a 100644 --- a/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" + #include "RomMemoryHandler.h" -#include #include #include +#include #include RomMemoryHandler::RomMemoryHandler(CN64System & System, CRegisters & Reg, CN64Rom & Rom) : @@ -41,7 +42,7 @@ bool RomMemoryHandler::Read32(uint32_t Address, uint32_t & Value) case 0x1000000C: LogMessage("%08X: read from ROM release offset (%08X)", m_PC, Value); break; case 0x10000010: LogMessage("%08X: read from ROM CRC1 (%08X)", m_PC, Value); break; case 0x10000014: LogMessage("%08X: read from ROM CRC2 (%08X)", m_PC, Value); break; - default: LogMessage("%08X: read from ROM header 0x%X (%08X)", m_PC, ReadAddr & 0xFF, Value); break; + default: LogMessage("%08X: read from ROM header 0x%X (%08X)", m_PC, ReadAddr & 0xFF, Value); break; } } } diff --git a/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.h b/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.h index 5eb3b1737..48374ddd2 100644 --- a/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/RomMemoryHandler.h @@ -1,7 +1,7 @@ #pragma once #include "MemoryHandler.h" -#include #include +#include #include class CRegisters; @@ -23,14 +23,20 @@ public: private: RomMemoryHandler(); - RomMemoryHandler(const RomMemoryHandler&); - RomMemoryHandler& operator=(const RomMemoryHandler&); + RomMemoryHandler(const RomMemoryHandler &); + RomMemoryHandler & operator=(const RomMemoryHandler &); void SystemReset(void); void LoadedGameState(void); - static void stSystemReset(RomMemoryHandler * _this) { _this->SystemReset(); } - static void stLoadedGameState(RomMemoryHandler * _this) { _this->LoadedGameState(); } + static void stSystemReset(RomMemoryHandler * _this) + { + _this->SystemReset(); + } + static void stLoadedGameState(RomMemoryHandler * _this) + { + _this->LoadedGameState(); + } uint32_t & m_PC; CRegisters & m_Reg; diff --git a/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.cpp index b89782ce2..b546fb867 100644 --- a/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" + #include "SPRegistersHandler.h" -#include #include #include +#include #include SPRegistersReg::SPRegistersReg(uint32_t * SignalProcessorInterface) : @@ -32,7 +33,7 @@ SPRegistersHandler::SPRegistersHandler(CN64System & System, CMipsMemoryVM & MMU, m_PC(Reg.m_PROGRAM_COUNTER) { System.RegisterCallBack(CN64SystemCB_Reset, this, (CN64System::CallBackFunction)stSystemReset); - System.RegisterCallBack(CN64SystemCB_LoadedGameState, this, (CN64System::CallBackFunction)stLoadedGameState); + System.RegisterCallBack(CN64SystemCB_LoadedGameState, this, (CN64System::CallBackFunction)stLoadedGameState); } bool SPRegistersHandler::Read32(uint32_t Address, uint32_t & Value) @@ -109,7 +110,7 @@ bool SPRegistersHandler::Write32(uint32_t Address, uint32_t Value, uint32_t Mask switch (Address & 0x1FFFFFFF) { case 0x04040000: SP_MEM_ADDR_REG = (SP_MEM_ADDR_REG & ~Mask) | (MaskedValue); break; - case 0x04040004: SP_DRAM_ADDR_REG = (SP_DRAM_ADDR_REG & ~Mask) | (MaskedValue); break; + case 0x04040004: SP_DRAM_ADDR_REG = (SP_DRAM_ADDR_REG & ~Mask) | (MaskedValue); break; case 0x04040008: SP_RD_LEN_REG = MaskedValue; SP_DMA_READ(); @@ -119,36 +120,111 @@ bool SPRegistersHandler::Write32(uint32_t Address, uint32_t Value, uint32_t Mask SP_DMA_WRITE(); break; case 0x04040010: - if ((MaskedValue & SP_CLR_HALT) != 0) { SP_STATUS_REG &= ~SP_STATUS_HALT; } - if ((MaskedValue & SP_SET_HALT) != 0) { SP_STATUS_REG |= SP_STATUS_HALT; } - if ((MaskedValue & SP_CLR_BROKE) != 0) { SP_STATUS_REG &= ~SP_STATUS_BROKE; } + if ((MaskedValue & SP_CLR_HALT) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_HALT; + } + if ((MaskedValue & SP_SET_HALT) != 0) + { + SP_STATUS_REG |= SP_STATUS_HALT; + } + if ((MaskedValue & SP_CLR_BROKE) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_BROKE; + } if ((MaskedValue & SP_CLR_INTR) != 0) { MI_INTR_REG &= ~MI_INTR_SP; m_RspIntrReg &= ~MI_INTR_SP; m_Reg.CheckInterrupts(); } - if ((MaskedValue & SP_SET_INTR) != 0) { if (BreakOnUnhandledMemory()) { g_Notify->BreakPoint(__FILE__, __LINE__); } } - if ((MaskedValue & SP_CLR_SSTEP) != 0) { SP_STATUS_REG &= ~SP_STATUS_SSTEP; } - if ((MaskedValue & SP_SET_SSTEP) != 0) { SP_STATUS_REG |= SP_STATUS_SSTEP; } - if ((MaskedValue & SP_CLR_INTR_BREAK) != 0) { SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; } - if ((MaskedValue & SP_SET_INTR_BREAK) != 0) { SP_STATUS_REG |= SP_STATUS_INTR_BREAK; } - if ((MaskedValue & SP_CLR_SIG0) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG0; } - if ((MaskedValue & SP_SET_SIG0) != 0) { SP_STATUS_REG |= SP_STATUS_SIG0; } - if ((MaskedValue & SP_CLR_SIG1) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG1; } - if ((MaskedValue & SP_SET_SIG1) != 0) { SP_STATUS_REG |= SP_STATUS_SIG1; } - if ((MaskedValue & SP_CLR_SIG2) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG2; } - if ((MaskedValue & SP_SET_SIG2) != 0) { SP_STATUS_REG |= SP_STATUS_SIG2; } - if ((MaskedValue & SP_CLR_SIG3) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG3; } - if ((MaskedValue & SP_SET_SIG3) != 0) { SP_STATUS_REG |= SP_STATUS_SIG3; } - if ((MaskedValue & SP_CLR_SIG4) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG4; } - if ((MaskedValue & SP_SET_SIG4) != 0) { SP_STATUS_REG |= SP_STATUS_SIG4; } - if ((MaskedValue & SP_CLR_SIG5) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG5; } - if ((MaskedValue & SP_SET_SIG5) != 0) { SP_STATUS_REG |= SP_STATUS_SIG5; } - if ((MaskedValue & SP_CLR_SIG6) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG6; } - if ((MaskedValue & SP_SET_SIG6) != 0) { SP_STATUS_REG |= SP_STATUS_SIG6; } - if ((MaskedValue & SP_CLR_SIG7) != 0) { SP_STATUS_REG &= ~SP_STATUS_SIG7; } - if ((MaskedValue & SP_SET_SIG7) != 0) { SP_STATUS_REG |= SP_STATUS_SIG7; } + if ((MaskedValue & SP_SET_INTR) != 0) + { + if (BreakOnUnhandledMemory()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + } + if ((MaskedValue & SP_CLR_SSTEP) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SSTEP; + } + if ((MaskedValue & SP_SET_SSTEP) != 0) + { + SP_STATUS_REG |= SP_STATUS_SSTEP; + } + if ((MaskedValue & SP_CLR_INTR_BREAK) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; + } + if ((MaskedValue & SP_SET_INTR_BREAK) != 0) + { + SP_STATUS_REG |= SP_STATUS_INTR_BREAK; + } + if ((MaskedValue & SP_CLR_SIG0) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG0; + } + if ((MaskedValue & SP_SET_SIG0) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG0; + } + if ((MaskedValue & SP_CLR_SIG1) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG1; + } + if ((MaskedValue & SP_SET_SIG1) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG1; + } + if ((MaskedValue & SP_CLR_SIG2) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG2; + } + if ((MaskedValue & SP_SET_SIG2) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG2; + } + if ((MaskedValue & SP_CLR_SIG3) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG3; + } + if ((MaskedValue & SP_SET_SIG3) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG3; + } + if ((MaskedValue & SP_CLR_SIG4) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG4; + } + if ((MaskedValue & SP_SET_SIG4) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG4; + } + if ((MaskedValue & SP_CLR_SIG5) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG5; + } + if ((MaskedValue & SP_SET_SIG5) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG5; + } + if ((MaskedValue & SP_CLR_SIG6) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG6; + } + if ((MaskedValue & SP_SET_SIG6) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG6; + } + if ((MaskedValue & SP_CLR_SIG7) != 0) + { + SP_STATUS_REG &= ~SP_STATUS_SIG7; + } + if ((MaskedValue & SP_SET_SIG7) != 0) + { + SP_STATUS_REG |= SP_STATUS_SIG7; + } if ((MaskedValue & SP_SET_SIG0) != 0 && RspAudioSignal()) { MI_INTR_REG |= MI_INTR_SP; @@ -218,7 +294,10 @@ void SPRegistersHandler::SP_DMA_READ() if ((CopyLength + ReadPos) > m_MMU.RdramSize()) { int32_t CopyAmount = m_MMU.RdramSize() - ReadPos; - if (CopyAmount < 0) { CopyAmount = 0; } + if (CopyAmount < 0) + { + CopyAmount = 0; + } NullLen = CopyLength - CopyAmount; if (CopyAmount > 0) diff --git a/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.h b/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.h index 7f4ac86eb..57b36290a 100644 --- a/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/SPRegistersHandler.h @@ -1,9 +1,9 @@ #pragma once -#include "MemoryHandler.h" #include "MIPSInterfaceHandler.h" -#include -#include +#include "MemoryHandler.h" #include +#include +#include #include class SPRegistersReg @@ -25,8 +25,8 @@ public: private: SPRegistersReg(); - SPRegistersReg(const SPRegistersReg&); - SPRegistersReg& operator=(const SPRegistersReg&); + SPRegistersReg(const SPRegistersReg &); + SPRegistersReg & operator=(const SPRegistersReg &); }; class CRegisters; @@ -39,7 +39,7 @@ class SPRegistersHandler : private CGameSettings, private MIPSInterfaceReg, private CDebugSettings, - private CLogging + private CLogging { public: SPRegistersHandler(CN64System & N64System, CMipsMemoryVM & MMU, CRegisters & Reg); @@ -51,8 +51,14 @@ private: SPRegistersHandler(const SPRegistersHandler &); SPRegistersHandler & operator=(const SPRegistersHandler &); - static void stSystemReset(SPRegistersHandler * _this) { _this->SystemReset(); } - static void stLoadedGameState(SPRegistersHandler * _this) { _this->LoadedGameState(); } + static void stSystemReset(SPRegistersHandler * _this) + { + _this->SystemReset(); + } + static void stLoadedGameState(SPRegistersHandler * _this) + { + _this->LoadedGameState(); + } void SP_DMA_READ(); void SP_DMA_WRITE(); diff --git a/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.cpp index 71894b566..879c9ef9b 100644 --- a/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SerialInterfaceHandler.h" #include #include diff --git a/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.h index bddd45763..1e033ee4b 100644 --- a/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/SerialInterfaceHandler.h @@ -1,8 +1,8 @@ #pragma once -#include "MemoryHandler.h" #include "MIPSInterfaceHandler.h" -#include +#include "MemoryHandler.h" #include +#include #include enum @@ -26,8 +26,8 @@ public: private: SerialInterfaceReg(); - SerialInterfaceReg(const SerialInterfaceReg&); - SerialInterfaceReg& operator=(const SerialInterfaceReg&); + SerialInterfaceReg(const SerialInterfaceReg &); + SerialInterfaceReg & operator=(const SerialInterfaceReg &); }; class CMipsMemoryVM; diff --git a/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.cpp b/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.cpp index dfd5db588..5f6254e8a 100644 --- a/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.cpp +++ b/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.cpp @@ -1,11 +1,12 @@ #include "stdafx.h" + #include "VideoInterfaceHandler.h" -#include #include -#include #include -#include +#include +#include #include +#include VideoInterfaceReg::VideoInterfaceReg(uint32_t * VideoInterface) : VI_STATUS_REG(VideoInterface[0]), diff --git a/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.h b/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.h index 3823e5a2b..3d2fc83f8 100644 --- a/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.h +++ b/Source/Project64-core/N64System/MemoryHandler/VideoInterfaceHandler.h @@ -1,8 +1,8 @@ #pragma once #include "MemoryHandler.h" +#include #include #include -#include #include class VideoInterfaceReg @@ -37,8 +37,8 @@ public: private: VideoInterfaceReg(); - VideoInterfaceReg(const VideoInterfaceReg&); - VideoInterfaceReg& operator=(const VideoInterfaceReg&); + VideoInterfaceReg(const VideoInterfaceReg &); + VideoInterfaceReg & operator=(const VideoInterfaceReg &); }; class CMipsMemoryVM; @@ -67,8 +67,14 @@ private: VideoInterfaceHandler(const VideoInterfaceHandler &); VideoInterfaceHandler & operator=(const VideoInterfaceHandler &); - static void stSystemReset(VideoInterfaceHandler * _this) { _this->SystemReset(); } - static void stLoadedGameState(VideoInterfaceHandler * _this) { _this->LoadedGameState(); } + static void stSystemReset(VideoInterfaceHandler * _this) + { + _this->SystemReset(); + } + static void stLoadedGameState(VideoInterfaceHandler * _this) + { + _this->LoadedGameState(); + } void UpdateHalfLine(); void LoadedGameState(void); diff --git a/Source/Project64-core/N64System/Mips/Disk.cpp b/Source/Project64-core/N64System/Mips/Disk.cpp index a3cd0f4ce..10040ddb7 100644 --- a/Source/Project64-core/N64System/Mips/Disk.cpp +++ b/Source/Project64-core/N64System/Mips/Disk.cpp @@ -1,11 +1,12 @@ // Based on MAME's N64DD driver code by Happy_ #include "stdafx.h" + #include "Disk.h" -#include -#include -#include #include #include +#include +#include +#include #ifdef _WIN32 #include @@ -41,7 +42,7 @@ void DiskCommand() time_t ltime; ltime = time(<ime); - struct tm result = { 0 }; + struct tm result = {0}; localtime_r(<ime, &result); // BCD format needed for 64DD RTC @@ -72,7 +73,8 @@ void DiskCommand() break; case 0x00080000: // Unset disk changed bit - g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_CHNG; break; + g_Reg->ASIC_STATUS &= ~DD_STATUS_DISK_CHNG; + break; case 0x00090000: // Unset reset and disk changed bit bit g_Reg->ASIC_STATUS &= ~DD_STATUS_RST_STATE; @@ -84,16 +86,20 @@ void DiskCommand() break; case 0x00120000: // RTC get year and month - g_Reg->ASIC_DATA = (year << 24) | (month << 16); break; + g_Reg->ASIC_DATA = (year << 24) | (month << 16); + break; case 0x00130000: // RTC get day and hour - g_Reg->ASIC_DATA = (day << 24) | (hour << 16); break; + g_Reg->ASIC_DATA = (day << 24) | (hour << 16); + break; case 0x00140000: // RTC get minute and second - g_Reg->ASIC_DATA = (minute << 24) | (second << 16); break; + g_Reg->ASIC_DATA = (minute << 24) | (second << 16); + break; case 0x001B0000: // Disk inquiry - g_Reg->ASIC_DATA = 0x00000000; break; + g_Reg->ASIC_DATA = 0x00000000; + break; } if (isSeek) @@ -188,7 +194,7 @@ void DiskReset(void) void DiskBMControl(void) { g_Reg->ASIC_CUR_SECTOR = g_Reg->ASIC_BM_CTL & 0x00FF0000; - + if ((g_Reg->ASIC_CUR_SECTOR >> 16) == 0x00) { dd_start_block = 0; @@ -199,7 +205,7 @@ void DiskBMControl(void) dd_start_block = 1; dd_current = 0; } - + if (g_Reg->ASIC_BM_CTL & DD_BM_CTL_BLK_TRANS) g_Reg->ASIC_BM_STATUS |= DD_BM_STATUS_BLOCK; @@ -355,7 +361,7 @@ bool DiskBMReadWrite(bool /*write*/) uint16_t block = (uint16_t)dd_start_block; uint16_t sector = (uint16_t)dd_current; uint16_t sectorsize = (((g_Reg->ASIC_HOST_SECBYTE & 0x00FF0000) >> 16) + 1); - + uint32_t addr = g_Disk->GetDiskAddressBlock(head, track, block, sector, sectorsize); if (addr == 0xFFFFFFFF) diff --git a/Source/Project64-core/N64System/Mips/Disk.h b/Source/Project64-core/N64System/Mips/Disk.h index d9ce3482b..eff84d7e6 100644 --- a/Source/Project64-core/N64System/Mips/Disk.h +++ b/Source/Project64-core/N64System/Mips/Disk.h @@ -15,13 +15,13 @@ extern bool dd_reset_hold; extern uint32_t dd_track_offset, dd_zone; extern uint32_t dd_start_block, dd_current; -const uint32_t ddZoneSecSize[16] = { 232, 216, 208, 192, 176, 160, 144, 128, - 216, 208, 192, 176, 160, 144, 128, 112 }; -const uint32_t ddZoneTrackSize[16] = { 158, 158, 149, 149, 149, 149, 149, 114, - 158, 158, 149, 149, 149, 149, 149, 114 }; +const uint32_t ddZoneSecSize[16] = {232, 216, 208, 192, 176, 160, 144, 128, + 216, 208, 192, 176, 160, 144, 128, 112}; +const uint32_t ddZoneTrackSize[16] = {158, 158, 149, 149, 149, 149, 149, 114, + 158, 158, 149, 149, 149, 149, 149, 114}; const uint32_t ddStartOffset[16] = - { 0x0, 0x5F15E0, 0xB79D00, 0x10801A0, 0x1523720, 0x1963D80, 0x1D414C0, 0x20BBCE0, - 0x23196E0, 0x28A1E00, 0x2DF5DC0, 0x3299340, 0x36D99A0, 0x3AB70E0, 0x3E31900, 0x4149200 }; + {0x0, 0x5F15E0, 0xB79D00, 0x10801A0, 0x1523720, 0x1963D80, 0x1D414C0, 0x20BBCE0, + 0x23196E0, 0x28A1E00, 0x2DF5DC0, 0x3299340, 0x36D99A0, 0x3AB70E0, 0x3E31900, 0x4149200}; -#define SECTORS_PER_BLOCK 85 -#define BLOCKS_PER_TRACK 2 +#define SECTORS_PER_BLOCK 85 +#define BLOCKS_PER_TRACK 2 diff --git a/Source/Project64-core/N64System/Mips/GBCart.cpp b/Source/Project64-core/N64System/Mips/GBCart.cpp index 5a929c159..784cbd064 100644 --- a/Source/Project64-core/N64System/Mips/GBCart.cpp +++ b/Source/Project64-core/N64System/Mips/GBCart.cpp @@ -5,12 +5,12 @@ // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html #include "stdafx.h" + #include "GBCart.h" - -#include #include +#include -static void read_gb_cart_normal(struct gb_cart* gb_cart, uint16_t address, uint8_t* data) +static void read_gb_cart_normal(struct gb_cart * gb_cart, uint16_t address, uint8_t * data) { uint16_t offset; @@ -45,7 +45,7 @@ static void read_gb_cart_normal(struct gb_cart* gb_cart, uint16_t address, uint8 } } -static void write_gb_cart_normal(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +static void write_gb_cart_normal(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { uint16_t offset; if ((address >= 0xA000) && (address <= 0xBFFF)) @@ -68,7 +68,7 @@ static void write_gb_cart_normal(struct gb_cart* gb_cart, uint16_t address, cons } } -static void read_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, uint8_t* data) +static void read_gb_cart_mbc1(struct gb_cart * gb_cart, uint16_t address, uint8_t * data) { size_t offset; @@ -97,7 +97,7 @@ static void read_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, uint8_t } } -static void write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +static void write_gb_cart_mbc1(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { size_t offset; @@ -108,7 +108,7 @@ static void write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const } else if ((address >= 0x2000) && (address <= 0x3FFF)) // ROM bank select { - gb_cart->rom_bank &= 0x60; // Keep MSB + gb_cart->rom_bank &= 0x60; // Keep MSB gb_cart->rom_bank |= data[0] & 0x1F; // Emulate quirk: 0x00 -> 0x01, 0x20 -> 0x21, 0x40->0x41, 0x60 -> 0x61 @@ -139,14 +139,14 @@ static void write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const gb_cart->ram_bank_mode = data[0] & 0x01; if (gb_cart->ram_bank_mode) { - gb_cart->ram_bank = gb_cart->rom_bank >> 5; // Set the RAM bank to the "magic bits" - gb_cart->rom_bank &= 0x1F; // Zero out bits 5 and 6 to keep consistency + gb_cart->ram_bank = gb_cart->rom_bank >> 5; // Set the RAM bank to the "magic bits" + gb_cart->rom_bank &= 0x1F; // Zero out bits 5 and 6 to keep consistency } else { gb_cart->rom_bank &= 0x1F; gb_cart->rom_bank |= (gb_cart->ram_bank << 5); - gb_cart->ram_bank = 0x00; // We can only reach RAM page 0 + gb_cart->ram_bank = 0x00; // We can only reach RAM page 0 } } } @@ -163,7 +163,7 @@ static void write_gb_cart_mbc1(struct gb_cart* gb_cart, uint16_t address, const } } -static void read_gb_cart_mbc2(struct gb_cart* gb_cart, uint16_t address, uint8_t* data) +static void read_gb_cart_mbc2(struct gb_cart * gb_cart, uint16_t address, uint8_t * data) { size_t offset; @@ -192,7 +192,7 @@ static void read_gb_cart_mbc2(struct gb_cart* gb_cart, uint16_t address, uint8_t } } -static void write_gb_cart_mbc2(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +static void write_gb_cart_mbc2(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { size_t offset; @@ -228,36 +228,42 @@ static void write_gb_cart_mbc2(struct gb_cart* gb_cart, uint16_t address, const } } -void memoryUpdateMBC3Clock(struct gb_cart* gb_cart) +void memoryUpdateMBC3Clock(struct gb_cart * gb_cart) { time_t now = time(nullptr); time_t diff = now - gb_cart->rtc_last_time; - if (diff > 0) { + if (diff > 0) + { // Update the clock according to the last update time gb_cart->rtc_data[0] += (int)(diff % 60); - if (gb_cart->rtc_data[0] > 59) { + if (gb_cart->rtc_data[0] > 59) + { gb_cart->rtc_data[0] -= 60; gb_cart->rtc_data[1]++; } diff /= 60; gb_cart->rtc_data[1] += (int)(diff % 60); - if (gb_cart->rtc_data[1] > 59) { + if (gb_cart->rtc_data[1] > 59) + { gb_cart->rtc_data[1] -= 60; gb_cart->rtc_data[2]++; } diff /= 60; gb_cart->rtc_data[2] += (int)(diff % 24); - if (gb_cart->rtc_data[2] > 23) { + if (gb_cart->rtc_data[2] > 23) + { gb_cart->rtc_data[2] -= 24; gb_cart->rtc_data[3]++; } diff /= 24; gb_cart->rtc_data[3] += (int)(diff & 0xFFFFFFFF); - if (gb_cart->rtc_data[3] > 255) { - if (gb_cart->rtc_data[3] > 511) { + if (gb_cart->rtc_data[3] > 255) + { + if (gb_cart->rtc_data[3] > 511) + { gb_cart->rtc_data[3] %= 512; gb_cart->rtc_data[3] |= 0x80; } @@ -267,7 +273,7 @@ void memoryUpdateMBC3Clock(struct gb_cart* gb_cart) gb_cart->rtc_last_time = now; } -static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t* data) +static void read_gb_cart_mbc3(struct gb_cart * gb_cart, uint16_t address, uint8_t * data) { size_t offset; @@ -317,7 +323,7 @@ static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t } } -static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +static void write_gb_cart_mbc3(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { uint8_t bank; size_t offset; @@ -422,11 +428,11 @@ static void read_gb_cart_mbc5(struct gb_cart * gb_cart, uint16_t address, uint8_ } } -static void write_gb_cart_mbc5(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +static void write_gb_cart_mbc5(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { size_t offset; - if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on + if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on { // Enable / Disable RAM -- NOT WORKING -- gb_cart->ram_enabled = (data[0] & 0x0F) == 0x0A; @@ -511,11 +517,11 @@ static void read_gb_cart_pocket_cam(struct gb_cart * gb_cart, uint16_t address, } } -static void write_gb_cart_pocket_cam(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +static void write_gb_cart_pocket_cam(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { size_t offset; - if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on + if ((address >= 0x0000) && (address <= 0x1FFF)) // We shouldn't be able to read/write to RAM unless this is toggled on { // Enable / Disable RAM gb_cart->ram_enabled = (data[0] & 0x0F) == 0x0A; @@ -603,46 +609,45 @@ enum gbcart_extra_devices struct parsed_cart_type { - void(*read_gb_cart)(struct gb_cart*, uint16_t, uint8_t*); - void(*write_gb_cart)(struct gb_cart*, uint16_t, const uint8_t*); + void (*read_gb_cart)(struct gb_cart *, uint16_t, uint8_t *); + void (*write_gb_cart)(struct gb_cart *, uint16_t, const uint8_t *); unsigned int extra_devices; }; -static const struct parsed_cart_type* parse_cart_type(uint8_t cart_type) +static const struct parsed_cart_type * parse_cart_type(uint8_t cart_type) { -#define MBC(x) read_gb_cart_ ## x, write_gb_cart_ ## x +#define MBC(x) read_gb_cart_##x, write_gb_cart_##x static const struct parsed_cart_type GB_CART_TYPES[] = - { - { MBC(normal), GED_NONE }, - { MBC(mbc1), GED_NONE }, - { MBC(mbc1), GED_RAM }, - { MBC(mbc1), GED_RAM | GED_BATTERY }, - { MBC(mbc2), GED_NONE }, - { MBC(mbc2), GED_BATTERY }, - { MBC(normal), GED_RAM }, - { MBC(normal), GED_RAM | GED_BATTERY }, - { MBC(mmm01), GED_NONE }, - { MBC(mmm01), GED_RAM }, - { MBC(mmm01), GED_RAM | GED_BATTERY }, - { MBC(mbc3), GED_BATTERY | GED_RTC }, - { MBC(mbc3), GED_RAM | GED_BATTERY | GED_RTC }, - { MBC(mbc3), GED_NONE }, - { MBC(mbc3), GED_RAM }, - { MBC(mbc3), GED_RAM | GED_BATTERY }, - { MBC(mbc4), GED_NONE }, - { MBC(mbc4), GED_RAM }, - { MBC(mbc4), GED_RAM | GED_BATTERY }, - { MBC(mbc5), GED_NONE }, - { MBC(mbc5), GED_RAM }, - { MBC(mbc5), GED_RAM | GED_BATTERY }, - { MBC(mbc5), GED_RUMBLE }, - { MBC(mbc5), GED_RAM | GED_RUMBLE }, - { MBC(mbc5), GED_RAM | GED_BATTERY | GED_RUMBLE }, - { MBC(pocket_cam), GED_NONE }, - { MBC(bandai_tama5), GED_NONE }, - { MBC(huc3), GED_NONE }, - { MBC(huc1), GED_RAM | GED_BATTERY } - }; + { + {MBC(normal), GED_NONE}, + {MBC(mbc1), GED_NONE}, + {MBC(mbc1), GED_RAM}, + {MBC(mbc1), GED_RAM | GED_BATTERY}, + {MBC(mbc2), GED_NONE}, + {MBC(mbc2), GED_BATTERY}, + {MBC(normal), GED_RAM}, + {MBC(normal), GED_RAM | GED_BATTERY}, + {MBC(mmm01), GED_NONE}, + {MBC(mmm01), GED_RAM}, + {MBC(mmm01), GED_RAM | GED_BATTERY}, + {MBC(mbc3), GED_BATTERY | GED_RTC}, + {MBC(mbc3), GED_RAM | GED_BATTERY | GED_RTC}, + {MBC(mbc3), GED_NONE}, + {MBC(mbc3), GED_RAM}, + {MBC(mbc3), GED_RAM | GED_BATTERY}, + {MBC(mbc4), GED_NONE}, + {MBC(mbc4), GED_RAM}, + {MBC(mbc4), GED_RAM | GED_BATTERY}, + {MBC(mbc5), GED_NONE}, + {MBC(mbc5), GED_RAM}, + {MBC(mbc5), GED_RAM | GED_BATTERY}, + {MBC(mbc5), GED_RUMBLE}, + {MBC(mbc5), GED_RAM | GED_RUMBLE}, + {MBC(mbc5), GED_RAM | GED_BATTERY | GED_RUMBLE}, + {MBC(pocket_cam), GED_NONE}, + {MBC(bandai_tama5), GED_NONE}, + {MBC(huc3), GED_NONE}, + {MBC(huc1), GED_RAM | GED_BATTERY}}; #undef MBC switch (cart_type) @@ -676,13 +681,13 @@ static const struct parsed_cart_type* parse_cart_type(uint8_t cart_type) case 0xFD: return &GB_CART_TYPES[26]; case 0xFE: return &GB_CART_TYPES[27]; case 0xFF: return &GB_CART_TYPES[28]; - default: return nullptr; + default: return nullptr; } } -bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) +bool GBCart::init_gb_cart(struct gb_cart * gb_cart, const char * gb_file) { - const struct parsed_cart_type* type; + const struct parsed_cart_type * type; std::unique_ptr rom; size_t rom_size = 0; std::unique_ptr ram; @@ -777,7 +782,7 @@ bool GBCart::init_gb_cart(struct gb_cart* gb_cart, const char* gb_file) return true; } -void GBCart::save_gb_cart(struct gb_cart* gb_cart) +void GBCart::save_gb_cart(struct gb_cart * gb_cart) { CFile ramFile; ramFile.Open(g_Settings->LoadStringVal(Game_Transferpak_Sav).c_str(), CFileBase::modeWrite | CFileBase::modeCreate); @@ -801,7 +806,7 @@ void GBCart::save_gb_cart(struct gb_cart* gb_cart) ramFile.Close(); } -void GBCart::release_gb_cart(struct gb_cart* gb_cart) +void GBCart::release_gb_cart(struct gb_cart * gb_cart) { if (gb_cart->rom != nullptr) delete gb_cart->rom; @@ -812,12 +817,12 @@ void GBCart::release_gb_cart(struct gb_cart* gb_cart) memset(gb_cart, 0, sizeof(*gb_cart)); } -void GBCart::read_gb_cart(struct gb_cart* gb_cart, uint16_t address, uint8_t* data) +void GBCart::read_gb_cart(struct gb_cart * gb_cart, uint16_t address, uint8_t * data) { gb_cart->read_gb_cart(gb_cart, address, data); } -void GBCart::write_gb_cart(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data) +void GBCart::write_gb_cart(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data) { gb_cart->write_gb_cart(gb_cart, address, data); } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/GBCart.h b/Source/Project64-core/N64System/Mips/GBCart.h index da1cc006d..71bab6fec 100644 --- a/Source/Project64-core/N64System/Mips/GBCart.h +++ b/Source/Project64-core/N64System/Mips/GBCart.h @@ -5,36 +5,36 @@ struct gb_cart { - uint8_t* rom; - uint8_t* ram; + uint8_t * rom; + uint8_t * ram; - size_t rom_size; - size_t ram_size; + size_t rom_size; + size_t ram_size; - unsigned int rom_bank; - unsigned int ram_bank; + unsigned int rom_bank; + unsigned int ram_bank; - bool has_rtc; - bool ram_bank_mode; - bool ram_enabled; + bool has_rtc; + bool ram_bank_mode; + bool ram_enabled; uint32_t rtc_latch; int rtc_data[5]; int rtc_latch_data[5]; - time_t rtc_last_time; + time_t rtc_last_time; - void(*read_gb_cart)(struct gb_cart* gb_cart, uint16_t address, uint8_t* data); - void(*write_gb_cart)(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data); + void (*read_gb_cart)(struct gb_cart * gb_cart, uint16_t address, uint8_t * data); + void (*write_gb_cart)(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data); }; class GBCart { public: - static bool init_gb_cart(struct gb_cart* gb_cart, const char* gb_file); - static void release_gb_cart(struct gb_cart* gb_cart); - static void save_gb_cart(struct gb_cart* gb_cart); + static bool init_gb_cart(struct gb_cart * gb_cart, const char * gb_file); + static void release_gb_cart(struct gb_cart * gb_cart); + static void save_gb_cart(struct gb_cart * gb_cart); - static void read_gb_cart(struct gb_cart* gb_cart, uint16_t address, uint8_t* data); - static void write_gb_cart(struct gb_cart* gb_cart, uint16_t address, const uint8_t* data); + static void read_gb_cart(struct gb_cart * gb_cart, uint16_t address, uint8_t * data); + static void write_gb_cart(struct gb_cart * gb_cart, uint16_t address, const uint8_t * data); }; diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp index 0710e349e..59837fc0b 100755 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp @@ -1,20 +1,20 @@ #include "stdafx.h" -#include -#include -#include -#include -#include +#include #include #include -#include +#include +#include +#include +#include +#include #include uint8_t * CMipsMemoryVM::m_Reserve1 = nullptr; uint8_t * CMipsMemoryVM::m_Reserve2 = nullptr; uint32_t CMipsMemoryVM::RegModValue; -#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list +#pragma warning(disable : 4355) // Disable 'this' : used in base member initializer list CMipsMemoryVM::CMipsMemoryVM(CN64System & System, bool SavesReadOnly) : CPifRam(SavesReadOnly), @@ -92,7 +92,7 @@ void CMipsMemoryVM::Reset(bool /*EraseMemory*/) if (g_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0) { uint32_t Start = g_Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000; - uint32_t Len = g_Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; + uint32_t Len = g_Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; uint32_t PAddr = g_Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30; uint32_t End = Start + Len; for (uint32_t Address = Start; Address < End; Address += 0x1000) @@ -185,14 +185,14 @@ bool CMipsMemoryVM::Initialize(bool SyncSystem) m_IMEM = (uint8_t *)(m_RDRAM + 0x04001000); CPifRam::Reset(); - m_MemoryReadMap = new size_t [0x100000]; + m_MemoryReadMap = new size_t[0x100000]; if (m_MemoryReadMap == nullptr) { WriteTrace(TraceN64System, TraceError, "Failed to allocate m_MemoryReadMap (Size: 0x%X)", 0x100000 * sizeof(size_t)); FreeMemory(); return false; } - m_MemoryWriteMap = new size_t [0x100000]; + m_MemoryWriteMap = new size_t[0x100000]; if (m_MemoryWriteMap == nullptr) { WriteTrace(TraceN64System, TraceError, "Failed to allocate m_MemoryWriteMap (Size: 0x%X)", 0x100000 * sizeof(size_t)); @@ -278,16 +278,16 @@ uint8_t * CMipsMemoryVM::MemoryPtr(uint32_t VAddr, uint32_t Size, bool Read) uint32_t PAddr = m_TLB_ReadMap[VAddr >> 12] + VAddr; if ((PAddr + Size) < m_AllocatedRdramSize) { - return (uint8_t*)(m_RDRAM + PAddr); + return (uint8_t *)(m_RDRAM + PAddr); } if (PAddr >= 0x04000000 && (PAddr + Size) < 0x04001000) { - return (uint8_t*)(m_DMEM + (PAddr - 0x04000000)); + return (uint8_t *)(m_DMEM + (PAddr - 0x04000000)); } if (PAddr >= 0x04001000 && (PAddr + Size) < 0x04002000) { - return (uint8_t*)(m_IMEM + (PAddr - 0x04001000)); + return (uint8_t *)(m_IMEM + (PAddr - 0x04001000)); } if (Read && PAddr >= 0x10000000 && (PAddr + Size) < (0x10000000 + m_Rom.GetRomSize())) { @@ -296,7 +296,6 @@ uint8_t * CMipsMemoryVM::MemoryPtr(uint32_t VAddr, uint32_t Size, bool Read) g_Notify->BreakPoint(__FILE__, __LINE__); return nullptr; - } bool CMipsMemoryVM::MemoryValue8(uint32_t VAddr, uint8_t & Value) @@ -317,7 +316,7 @@ bool CMipsMemoryVM::MemoryValue16(uint32_t VAddr, uint16_t & Value) { return false; } - Value = *(uint16_t*)(ptr); + Value = *(uint16_t *)(ptr); return true; } @@ -328,7 +327,7 @@ bool CMipsMemoryVM::MemoryValue32(uint32_t VAddr, uint32_t & Value) { return false; } - Value = *(uint32_t*)(ptr); + Value = *(uint32_t *)(ptr); return true; } @@ -339,8 +338,8 @@ bool CMipsMemoryVM::MemoryValue64(uint32_t VAddr, uint64_t & Value) { return false; } - *((uint32_t*)(&Value) + 1) = *(uint32_t*)(ptr); - *((uint32_t*)(&Value) + 0) = *(uint32_t*)(ptr + 4); + *((uint32_t *)(&Value) + 1) = *(uint32_t *)(ptr); + *((uint32_t *)(&Value) + 0) = *(uint32_t *)(ptr + 4); return true; } @@ -362,7 +361,7 @@ bool CMipsMemoryVM::UpdateMemoryValue16(uint32_t VAddr, uint16_t Value) { return false; } - *(uint16_t*)(ptr) = Value; + *(uint16_t *)(ptr) = Value; return true; } @@ -373,11 +372,11 @@ bool CMipsMemoryVM::UpdateMemoryValue32(uint32_t VAddr, uint32_t Value) { return false; } - *(uint32_t*)(ptr) = Value; + *(uint32_t *)(ptr) = Value; return true; } -bool CMipsMemoryVM::LB_Memory(uint64_t VAddr, uint8_t& Value) +bool CMipsMemoryVM::LB_Memory(uint64_t VAddr, uint8_t & Value) { if (!b32BitCore() && (uint64_t)((int32_t)VAddr) != VAddr) { @@ -390,10 +389,10 @@ bool CMipsMemoryVM::LB_Memory(uint64_t VAddr, uint8_t& Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryReadMap[VAddr32 >> 12]; - if (MemoryPtr != (uint8_t*)-1) + uint8_t * MemoryPtr = (uint8_t *)m_MemoryReadMap[VAddr32 >> 12]; + if (MemoryPtr != (uint8_t *)-1) { - Value = *(uint8_t*)(MemoryPtr + (VAddr32 ^ 3)); + Value = *(uint8_t *)(MemoryPtr + (VAddr32 ^ 3)); return true; } uint32_t BaseAddress = m_TLB_ReadMap[VAddr32 >> 12]; @@ -423,10 +422,10 @@ bool CMipsMemoryVM::LH_Memory(uint64_t VAddr, uint16_t & Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryReadMap[VAddr32 >> 12]; - if (MemoryPtr != (uint8_t*)-1) + uint8_t * MemoryPtr = (uint8_t *)m_MemoryReadMap[VAddr32 >> 12]; + if (MemoryPtr != (uint8_t *)-1) { - Value = *(uint16_t*)(MemoryPtr + (VAddr32 ^ 2)); + Value = *(uint16_t *)(MemoryPtr + (VAddr32 ^ 2)); return true; } uint32_t BaseAddress = m_TLB_ReadMap[VAddr32 >> 12]; @@ -455,10 +454,10 @@ bool CMipsMemoryVM::LW_Memory(uint64_t VAddr, uint32_t & Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryReadMap[VAddr32 >> 12]; + uint8_t * MemoryPtr = (uint8_t *)m_MemoryReadMap[VAddr32 >> 12]; if (MemoryPtr != (uint8_t *)-1) { - Value = *(uint32_t*)(MemoryPtr + VAddr32); + Value = *(uint32_t *)(MemoryPtr + VAddr32); return true; } uint32_t BaseAddress = m_TLB_ReadMap[VAddr32 >> 12]; @@ -470,7 +469,7 @@ bool CMipsMemoryVM::LW_Memory(uint64_t VAddr, uint32_t & Value) return LW_NonMemory(VAddr32, Value); } -bool CMipsMemoryVM::LD_Memory(uint64_t VAddr, uint64_t& Value) +bool CMipsMemoryVM::LD_Memory(uint64_t VAddr, uint64_t & Value) { if (!b32BitCore() && (uint64_t)((int32_t)VAddr) != VAddr) { @@ -488,11 +487,11 @@ bool CMipsMemoryVM::LD_Memory(uint64_t VAddr, uint64_t& Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryReadMap[VAddr32 >> 12]; + uint8_t * MemoryPtr = (uint8_t *)m_MemoryReadMap[VAddr32 >> 12]; if (MemoryPtr != (uint8_t *)-1) { - *((uint32_t*)(&Value) + 1) = *(uint32_t*)(MemoryPtr + VAddr32); - *((uint32_t*)(&Value) + 0) = *(uint32_t*)(MemoryPtr + VAddr32 + 4); + *((uint32_t *)(&Value) + 1) = *(uint32_t *)(MemoryPtr + VAddr32); + *((uint32_t *)(&Value) + 0) = *(uint32_t *)(MemoryPtr + VAddr32 + 4); return true; } uint32_t BaseAddress = m_TLB_ReadMap[VAddr32 >> 12]; @@ -516,10 +515,10 @@ bool CMipsMemoryVM::SB_Memory(uint64_t VAddr, uint32_t Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryWriteMap[VAddr32 >> 12]; + uint8_t * MemoryPtr = (uint8_t *)m_MemoryWriteMap[VAddr32 >> 12]; if (MemoryPtr != (uint8_t *)-1) { - *(uint8_t*)(MemoryPtr + (VAddr32 ^ 3)) = (uint8_t)Value; + *(uint8_t *)(MemoryPtr + (VAddr32 ^ 3)) = (uint8_t)Value; return true; } if (m_TLB_WriteMap[VAddr32 >> 12] == -1) @@ -548,10 +547,10 @@ bool CMipsMemoryVM::SH_Memory(uint64_t VAddr, uint32_t Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryWriteMap[VAddr32 >> 12]; + uint8_t * MemoryPtr = (uint8_t *)m_MemoryWriteMap[VAddr32 >> 12]; if (MemoryPtr != (uint8_t *)-1) { - *(uint16_t*)(MemoryPtr + (VAddr32 ^ 2)) = (uint16_t)Value; + *(uint16_t *)(MemoryPtr + (VAddr32 ^ 2)) = (uint16_t)Value; return true; } uint32_t BaseAddress = m_TLB_ReadMap[VAddr32 >> 12]; @@ -581,10 +580,10 @@ bool CMipsMemoryVM::SW_Memory(uint64_t VAddr, uint32_t Value) { return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryWriteMap[VAddr32 >> 12]; + uint8_t * MemoryPtr = (uint8_t *)m_MemoryWriteMap[VAddr32 >> 12]; if (MemoryPtr != (uint8_t *)-1) { - *(uint32_t*)(MemoryPtr + VAddr32) = Value; + *(uint32_t *)(MemoryPtr + VAddr32) = Value; return true; } uint32_t BaseAddress = m_TLB_ReadMap[VAddr32 >> 12]; @@ -615,11 +614,11 @@ bool CMipsMemoryVM::SD_Memory(uint64_t VAddr, uint64_t Value) return false; } - uint8_t * MemoryPtr = (uint8_t*)m_MemoryWriteMap[VAddr32 >> 12]; + uint8_t * MemoryPtr = (uint8_t *)m_MemoryWriteMap[VAddr32 >> 12]; if (MemoryPtr != (uint8_t *)-1) { - *(uint32_t*)(MemoryPtr + VAddr32 + 0) = *((uint32_t*)(&Value) + 1); - *(uint32_t*)(MemoryPtr + VAddr32 + 4) = *((uint32_t*)(&Value)); + *(uint32_t *)(MemoryPtr + VAddr32 + 0) = *((uint32_t *)(&Value) + 1); + *(uint32_t *)(MemoryPtr + VAddr32 + 4) = *((uint32_t *)(&Value)); return true; } if (m_TLB_WriteMap[VAddr32 >> 12] == -1) @@ -635,7 +634,7 @@ bool CMipsMemoryVM::ValidVaddr(uint32_t VAddr) const return m_TLB_ReadMap[VAddr >> 12] != -1; } -bool CMipsMemoryVM::VAddrToPAddr(uint32_t VAddr, uint32_t &PAddr) const +bool CMipsMemoryVM::VAddrToPAddr(uint32_t VAddr, uint32_t & PAddr) const { if (m_TLB_ReadMap[VAddr >> 12] == -1) { @@ -792,7 +791,7 @@ bool CMipsMemoryVM::SB_NonMemory(uint32_t VAddr, uint32_t Value) { g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0xFFC, CRecompiler::Remove_ProtectedMem); ::ProtectMemory(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, MEM_READWRITE); - *(uint8_t *)(m_RDRAM + (PAddr ^ 3)) = (uint8_t)Value; + *(uint8_t *)(m_RDRAM + (PAddr ^ 3)) = (uint8_t)Value; } break; default: @@ -919,7 +918,7 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t VAddr, uint32_t Value) case 0x06000000: m_CartridgeDomain1Address1Handler.Write32(PAddr, Value, 0xFFFFFFFF); break; case 0x08000000: case 0x0fe00000: - m_CartridgeDomain2Address2Handler.Write32(PAddr, Value, 0xFFFFFFFF); + m_CartridgeDomain2Address2Handler.Write32(PAddr, Value, 0xFFFFFFFF); break; case 0x13F00000: m_ISViewerHandler.Write32(PAddr, Value, 0xFFFFFFFF); break; case 0x1FC00000: m_PifRamHandler.Write32(PAddr, Value, 0xFFFFFFFF); break; diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h index e428bf9f4..61de1226e 100644 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h @@ -1,9 +1,5 @@ #pragma once -#include -#include #include -#include -#include #include #include #include @@ -17,9 +13,13 @@ #include #include #include -#include #include +#include #include +#include +#include +#include +#include #include #ifdef __arm__ @@ -63,14 +63,35 @@ public: bool Initialize(bool SyncSystem); void Reset(bool EraseMemory); - uint8_t * Rdram() const { return m_RDRAM; } - uint32_t RdramSize() const { return m_AllocatedRdramSize; } - uint8_t * Dmem() const { return m_DMEM; } - uint8_t * Imem() const { return m_IMEM; } - uint8_t * PifRam() { return &m_PifRam[0]; } + uint8_t * Rdram() const + { + return m_RDRAM; + } + uint32_t RdramSize() const + { + return m_AllocatedRdramSize; + } + uint8_t * Dmem() const + { + return m_DMEM; + } + uint8_t * Imem() const + { + return m_IMEM; + } + uint8_t * PifRam() + { + return &m_PifRam[0]; + } - CSram & GetSram() { return m_CartridgeDomain2Address2Handler.Sram(); } - CFlashRam & GetFlashRam() { return m_CartridgeDomain2Address2Handler.FlashRam(); } + CSram & GetSram() + { + return m_CartridgeDomain2Address2Handler.Sram(); + } + CFlashRam & GetFlashRam() + { + return m_CartridgeDomain2Address2Handler.FlashRam(); + } uint8_t * MemoryPtr(uint32_t VAddr, uint32_t Size, bool Read); @@ -93,11 +114,11 @@ public: bool SW_Memory(uint64_t VAddr, uint32_t Value); bool SD_Memory(uint64_t VAddr, uint64_t Value); - int32_t MemoryFilter(uint32_t dwExptCode, void * lpExceptionPointer); + int32_t MemoryFilter(uint32_t dwExptCode, void * lpExceptionPointer); #ifndef _WIN32 static bool SetupSegvHandler(void); - static void segv_handler(int signal, siginfo_t *siginfo, void *sigcontext); + static void segv_handler(int signal, siginfo_t * siginfo, void * sigcontext); #endif void ClearMemoryWriteMap(uint32_t VAddr, uint32_t Length); @@ -116,14 +137,23 @@ public: // Labels const char * LabelName(uint32_t Address) const; - AudioInterfaceHandler & AudioInterface(void) { return m_AudioInterfaceHandler; } - VideoInterfaceHandler & VideoInterface(void) { return m_VideoInterfaceHandler; } - RomMemoryHandler & RomMemory(void) { return m_RomMemoryHandler; }; + AudioInterfaceHandler & AudioInterface(void) + { + return m_AudioInterfaceHandler; + } + VideoInterfaceHandler & VideoInterface(void) + { + return m_VideoInterfaceHandler; + } + RomMemoryHandler & RomMemory(void) + { + return m_RomMemoryHandler; + }; private: CMipsMemoryVM(); - CMipsMemoryVM(const CMipsMemoryVM&); - CMipsMemoryVM& operator=(const CMipsMemoryVM&); + CMipsMemoryVM(const CMipsMemoryVM &); + CMipsMemoryVM & operator=(const CMipsMemoryVM &); #if defined(__i386__) || defined(_M_IX86) friend class CX86RecompilerOps; @@ -169,7 +199,7 @@ private: #endif void FreeMemory(); - static uint8_t * m_Reserve1, *m_Reserve2; + static uint8_t *m_Reserve1, *m_Reserve2; CN64System & m_System; CRegisters & m_Reg; AudioInterfaceHandler m_AudioInterfaceHandler; @@ -188,7 +218,7 @@ private: SerialInterfaceHandler m_SerialInterfaceHandler; SPRegistersHandler m_SPRegistersHandler; VideoInterfaceHandler m_VideoInterfaceHandler; - uint8_t * m_RDRAM, *m_DMEM, *m_IMEM; + uint8_t *m_RDRAM, *m_DMEM, *m_IMEM; uint32_t m_AllocatedRdramSize; CN64Rom & m_Rom; diff --git a/Source/Project64-core/N64System/Mips/Mempak.cpp b/Source/Project64-core/N64System/Mips/Mempak.cpp index a3a016671..7e5ad47cd 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.cpp +++ b/Source/Project64-core/N64System/Mips/Mempak.cpp @@ -1,8 +1,8 @@ #include "stdafx.h" -#include "Mempak.h" -#include +#include "Mempak.h" #include +#include CMempak::CMempak() { @@ -10,7 +10,7 @@ CMempak::CMempak() { m_Formatted[i] = 0; m_SaveExists[i] = true; - } + } memset(m_Mempaks, 0, sizeof(m_Mempaks)); } @@ -67,6 +67,7 @@ void CMempak::LoadMempak(int32_t Control, bool Create) void CMempak::Format(int32_t Control) { + // clang-format off static const uint8_t Initialize[] = { 0x81, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -107,8 +108,9 @@ void CMempak::Format(int32_t Control) 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, - 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03 + 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, }; + // clang-format on memcpy(&m_Mempaks[Control][0], &Initialize[0], sizeof(Initialize)); diff --git a/Source/Project64-core/N64System/Mips/Mempak.h b/Source/Project64-core/N64System/Mips/Mempak.h index dd733290d..1dfaad467 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.h +++ b/Source/Project64-core/N64System/Mips/Mempak.h @@ -11,8 +11,8 @@ public: static uint8_t CalculateCrc(uint8_t * DataToCrc); private: - CMempak(const CMempak&); - CMempak& operator=(const CMempak&); + CMempak(const CMempak &); + CMempak & operator=(const CMempak &); void LoadMempak(int32_t Control, bool Create); void Format(int32_t Control); diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp index 8e6cdf950..065cdcccb 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.cpp +++ b/Source/Project64-core/N64System/Mips/PifRam.cpp @@ -1,17 +1,17 @@ #include "stdafx.h" #include +#include +#include +#include +#include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include CPifRam::CPifRam(bool SavesReadOnly) : @@ -32,14 +32,16 @@ void CPifRam::Reset() void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int32_t length) { + // clang-format off static char lut0[0x10] = { 0x4, 0x7, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1, - 0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9 + 0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9, }; static char lut1[0x10] = { 0x4, 0x1, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1, - 0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9 + 0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9, }; + // clang-format on char key, *lut; int32_t i, sgn, mag, mod; @@ -85,8 +87,11 @@ void CPifRam::PifRamRead() break; case 0xFD: CurPos = 0x40; break; case 0xFE: CurPos = 0x40; break; - case 0xFF: break; - case 0xB4: case 0x56: case 0xB8: break; + case 0xFF: + case 0xB4: + case 0x56: + case 0xB8: + break; default: if ((m_PifRam[CurPos] & 0xC0) == 0) { @@ -195,8 +200,11 @@ void CPifRam::PifRamWrite() break; case 0xFD: CurPos = 0x40; break; case 0xFE: CurPos = 0x40; break; - case 0xFF: break; - case 0xB4: case 0x56: case 0xB8: break; // ??? + case 0xFF: + case 0xB4: + case 0x56: + case 0xB8: + break; default: if ((m_PifRam[CurPos] & 0xC0) == 0) { @@ -305,8 +313,8 @@ void CPifRam::SI_DMA_READ() AsciiData[0] = '\0'; } sprintf(Addon, "%02X %02X %02X %02X", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); strcat(HexData, Addon); if (((count + 1) % 4) != 0) { @@ -315,8 +323,8 @@ void CPifRam::SI_DMA_READ() } sprintf(Addon, "%c%c%c%c", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); strcat(AsciiData, Addon); if (((count + 1) % 4) == 0) @@ -327,9 +335,9 @@ void CPifRam::SI_DMA_READ() LogMessage(""); } - if(g_System->bRandomizeSIPIInterrupts()) + if (g_System->bRandomizeSIPIInterrupts()) { - if(g_System->bDelaySI()) + if (g_System->bDelaySI()) { g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900 + (g_Random->next() % 0x40), false); } @@ -340,7 +348,7 @@ void CPifRam::SI_DMA_READ() } else { - if(g_System->bDelaySI()) + if (g_System->bDelaySI()) { g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900, false); } @@ -378,7 +386,8 @@ void CPifRam::SI_DMA_WRITE() { if (RdramPos < 0) { - m_PifRam[count] = 0; continue; + m_PifRam[count] = 0; + continue; } m_PifRam[count] = RDRAM[RdramPos ^ 3]; } @@ -406,8 +415,8 @@ void CPifRam::SI_DMA_WRITE() AsciiData[0] = '\0'; } sprintf(Addon, "%02X %02X %02X %02X", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); strcat(HexData, Addon); if (((count + 1) % 4) != 0) { @@ -416,8 +425,8 @@ void CPifRam::SI_DMA_WRITE() } sprintf(Addon, "%c%c%c%c", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); strcat(AsciiData, Addon); if (((count + 1) % 4) == 0) @@ -474,7 +483,8 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) case PLUGIN_RUMBLE_PAK: case PLUGIN_MEMPAK: case PLUGIN_RAW: - Command[5] = 1; break; + Command[5] = 1; + break; default: Command[5] = 0; break; } } @@ -519,14 +529,19 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) if (Controllers[Control].Present != PRESENT_NONE) { uint32_t address = (Command[3] << 8) | (Command[4] & 0xE0); - uint8_t* data = &Command[5]; + uint8_t * data = &Command[5]; switch (Controllers[Control].Plugin) { case PLUGIN_RUMBLE_PAK: Rumblepak::ReadFrom(address, data); break; case PLUGIN_MEMPAK: g_Mempak->ReadFrom(Control, address, data); break; case PLUGIN_TRANSFER_PAK: Transferpak::ReadFrom((uint16_t)address, data); break; - case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; + case PLUGIN_RAW: + if (g_Plugins->Control()->ControllerCommand) + { + g_Plugins->Control()->ControllerCommand(Control, Command); + } + break; default: memset(&Command[5], 0, 0x20); } @@ -560,14 +575,19 @@ void CPifRam::ProcessControllerCommand(int32_t Control, uint8_t * Command) if (Controllers[Control].Present != PRESENT_NONE) { uint32_t address = (Command[3] << 8) | (Command[4] & 0xE0); - uint8_t* data = &Command[5]; + uint8_t * data = &Command[5]; switch (Controllers[Control].Plugin) { case PLUGIN_MEMPAK: g_Mempak->WriteTo(Control, address, data); break; case PLUGIN_RUMBLE_PAK: Rumblepak::WriteTo(Control, address, data); break; case PLUGIN_TRANSFER_PAK: Transferpak::WriteTo((uint16_t)address, data); break; - case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; + case PLUGIN_RAW: + if (g_Plugins->Control()->ControllerCommand) + { + g_Plugins->Control()->ControllerCommand(Control, Command); + } + break; } if (Controllers[Control].Plugin != PLUGIN_RAW) @@ -603,7 +623,10 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command) { if (bShowPifRamErrors()) { - if (Command[0] != 1 || Command[1] != 4) { g_Notify->DisplayError("What am I meant to do with this controller command?"); } + if (Command[0] != 1 || Command[1] != 4) + { + g_Notify->DisplayError("What am I meant to do with this controller command?"); + } } const uint32_t buttons = g_BaseSystem->GetButtons(Control); @@ -615,7 +638,12 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command) { switch (Controllers[Control].Plugin) { - case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break; + case PLUGIN_RAW: + if (g_Plugins->Control()->ReadController) + { + g_Plugins->Control()->ReadController(Control, Command); + } + break; } } break; @@ -624,7 +652,12 @@ void CPifRam::ReadControllerCommand(int32_t Control, uint8_t * Command) { switch (Controllers[Control].Plugin) { - case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break; + case PLUGIN_RAW: + if (g_Plugins->Control()->ReadController) + { + g_Plugins->Control()->ReadController(Control, Command); + } + break; } } break; @@ -647,8 +680,8 @@ void CPifRam::LogControllerPakData(const char * Description) AsciiData[0] = '\0'; } sprintf(Addon, "%02X %02X %02X %02X", - PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1], - PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3]); + PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1], + PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3]); strcat(HexData, Addon); if (((count + 1) % 4) != 0) { diff --git a/Source/Project64-core/N64System/Mips/PifRam.h b/Source/Project64-core/N64System/Mips/PifRam.h index e30a5365d..1e715c4ea 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.h +++ b/Source/Project64-core/N64System/Mips/PifRam.h @@ -25,10 +25,13 @@ protected: private: CPifRam(); - CPifRam(const CPifRam&); - CPifRam& operator=(const CPifRam&); + CPifRam(const CPifRam &); + CPifRam & operator=(const CPifRam &); - enum { CHALLENGE_LENGTH = 0x20 }; + enum + { + CHALLENGE_LENGTH = 0x20 + }; void ProcessControllerCommand(int32_t Control, uint8_t * Command); void ReadControllerCommand(int32_t Control, uint8_t * Command); void LogControllerPakData(const char * Description); diff --git a/Source/Project64-core/N64System/Mips/R4300iInstruction.cpp b/Source/Project64-core/N64System/Mips/R4300iInstruction.cpp index e2b3af27a..7e8b9f43c 100644 --- a/Source/Project64-core/N64System/Mips/R4300iInstruction.cpp +++ b/Source/Project64-core/N64System/Mips/R4300iInstruction.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" -#include + #include "R4300iInstruction.h" +#include R4300iInstruction::R4300iInstruction(uint32_t Address, uint32_t Instruction) : m_Address(Address) @@ -326,10 +327,22 @@ bool R4300iInstruction::DelaySlotEffectsCompare(uint32_t DelayInstruction) const const char * R4300iInstruction::FPR_Type(uint32_t COP1OpCode) { - if (COP1OpCode == R4300i_COP1_S) { return "S"; }; - if (COP1OpCode == R4300i_COP1_D) { return "D"; }; - if (COP1OpCode == R4300i_COP1_W) { return "W"; }; - if (COP1OpCode == R4300i_COP1_L) { return "L"; }; + if (COP1OpCode == R4300i_COP1_S) + { + return "S"; + }; + if (COP1OpCode == R4300i_COP1_D) + { + return "D"; + }; + if (COP1OpCode == R4300i_COP1_W) + { + return "W"; + }; + if (COP1OpCode == R4300i_COP1_L) + { + return "L"; + }; return "?"; } @@ -1152,4 +1165,3 @@ void R4300iInstruction::DecodeCop1Name(void) sprintf(m_Param, "0x%08X", m_Instruction.Value); } } - diff --git a/Source/Project64-core/N64System/Mips/R4300iInstruction.h b/Source/Project64-core/N64System/Mips/R4300iInstruction.h index a47a3e1b5..4ab3cd10f 100644 --- a/Source/Project64-core/N64System/Mips/R4300iInstruction.h +++ b/Source/Project64-core/N64System/Mips/R4300iInstruction.h @@ -16,16 +16,16 @@ public: private: R4300iInstruction(void); - R4300iInstruction(const R4300iInstruction&); - R4300iInstruction& operator=(const R4300iInstruction&); + R4300iInstruction(const R4300iInstruction &); + R4300iInstruction & operator=(const R4300iInstruction &); static const char * FPR_Type(uint32_t COP1OpCode); - + void DecodeName(void); void DecodeSpecialName(void); void DecodeRegImmName(void); void DecodeCop1Name(void); - + uint32_t m_Address; R4300iOpcode m_Instruction; char m_Name[40]; diff --git a/Source/Project64-core/N64System/Mips/R4300iOpcode.h b/Source/Project64-core/N64System/Mips/R4300iOpcode.h index 0706ce99a..37ba358b3 100644 --- a/Source/Project64-core/N64System/Mips/R4300iOpcode.h +++ b/Source/Project64-core/N64System/Mips/R4300iOpcode.h @@ -50,120 +50,120 @@ union R4300iOpcode unsigned : 6; }; - struct - { - unsigned : 6; - unsigned code : 20; - unsigned : 6; - }; + struct + { + unsigned : 6; + unsigned code : 20; + unsigned : 6; + }; }; #pragma warning(pop) enum R4300iOpCodes { - R4300i_SPECIAL = 0, - R4300i_REGIMM = 1, - R4300i_J = 2, + R4300i_SPECIAL = 0, + R4300i_REGIMM = 1, + R4300i_J = 2, R4300i_JAL = 3, - R4300i_BEQ = 4, - R4300i_BNE = 5, - R4300i_BLEZ = 6, + R4300i_BEQ = 4, + R4300i_BNE = 5, + R4300i_BLEZ = 6, R4300i_BGTZ = 7, - R4300i_ADDI = 8, - R4300i_ADDIU = 9, - R4300i_SLTI = 10, + R4300i_ADDI = 8, + R4300i_ADDIU = 9, + R4300i_SLTI = 10, R4300i_SLTIU = 11, - R4300i_ANDI = 12, - R4300i_ORI = 13, - R4300i_XORI = 14, + R4300i_ANDI = 12, + R4300i_ORI = 13, + R4300i_XORI = 14, R4300i_LUI = 15, - R4300i_CP0 = 16, - R4300i_CP1 = 17, - R4300i_BEQL = 20, + R4300i_CP0 = 16, + R4300i_CP1 = 17, + R4300i_BEQL = 20, R4300i_BNEL = 21, - R4300i_BLEZL = 22, - R4300i_BGTZL = 23, - R4300i_DADDI = 24, + R4300i_BLEZL = 22, + R4300i_BGTZL = 23, + R4300i_DADDI = 24, R4300i_DADDIU = 25, - R4300i_LDL = 26, - R4300i_LDR = 27, + R4300i_LDL = 26, + R4300i_LDR = 27, R4300i_RESERVED31 = 31, R4300i_LB = 32, R4300i_LH = 33, - R4300i_LWL = 34, - R4300i_LW = 35, - R4300i_LBU = 36, + R4300i_LWL = 34, + R4300i_LW = 35, + R4300i_LBU = 36, R4300i_LHU = 37, - R4300i_LWR = 38, - R4300i_LWU = 39, - R4300i_SB = 40, + R4300i_LWR = 38, + R4300i_LWU = 39, + R4300i_SB = 40, R4300i_SH = 41, - R4300i_SWL = 42, - R4300i_SW = 43, - R4300i_SDL = 44, + R4300i_SWL = 42, + R4300i_SW = 43, + R4300i_SDL = 44, R4300i_SDR = 45, - R4300i_SWR = 46, - R4300i_CACHE = 47, - R4300i_LL = 48, + R4300i_SWR = 46, + R4300i_CACHE = 47, + R4300i_LL = 48, R4300i_LWC1 = 49, - R4300i_LDC1 = 53, + R4300i_LDC1 = 53, R4300i_LD = 55, - R4300i_SC = 56, + R4300i_SC = 56, R4300i_SWC1 = 57, - R4300i_SDC1 = 61, - R4300i_SDC2 = 62, + R4300i_SDC1 = 61, + R4300i_SDC2 = 62, R4300i_SD = 63 }; enum R4300iSpecialOpCodes { - R4300i_SPECIAL_SLL = 0, - R4300i_SPECIAL_SRL = 2, + R4300i_SPECIAL_SLL = 0, + R4300i_SPECIAL_SRL = 2, R4300i_SPECIAL_SRA = 3, - R4300i_SPECIAL_SLLV = 4, - R4300i_SPECIAL_SRLV = 6, + R4300i_SPECIAL_SLLV = 4, + R4300i_SPECIAL_SRLV = 6, R4300i_SPECIAL_SRAV = 7, - R4300i_SPECIAL_JR = 8, - R4300i_SPECIAL_JALR = 9, + R4300i_SPECIAL_JR = 8, + R4300i_SPECIAL_JALR = 9, R4300i_SPECIAL_SYSCALL = 12, R4300i_SPECIAL_BREAK = 13, - R4300i_SPECIAL_SYNC = 15, + R4300i_SPECIAL_SYNC = 15, R4300i_SPECIAL_MFHI = 16, - R4300i_SPECIAL_MTHI = 17, + R4300i_SPECIAL_MTHI = 17, R4300i_SPECIAL_MFLO = 18, R4300i_SPECIAL_MTLO = 19, - R4300i_SPECIAL_DSLLV = 20, + R4300i_SPECIAL_DSLLV = 20, R4300i_SPECIAL_DSRLV = 22, R4300i_SPECIAL_DSRAV = 23, - R4300i_SPECIAL_MULT = 24, - R4300i_SPECIAL_MULTU = 25, + R4300i_SPECIAL_MULT = 24, + R4300i_SPECIAL_MULTU = 25, R4300i_SPECIAL_DIV = 26, R4300i_SPECIAL_DIVU = 27, - R4300i_SPECIAL_DMULT = 28, + R4300i_SPECIAL_DMULT = 28, R4300i_SPECIAL_DMULTU = 29, R4300i_SPECIAL_DDIV = 30, R4300i_SPECIAL_DDIVU = 31, R4300i_SPECIAL_ADD = 32, R4300i_SPECIAL_ADDU = 33, - R4300i_SPECIAL_SUB = 34, + R4300i_SPECIAL_SUB = 34, R4300i_SPECIAL_SUBU = 35, R4300i_SPECIAL_AND = 36, - R4300i_SPECIAL_OR = 37, + R4300i_SPECIAL_OR = 37, R4300i_SPECIAL_XOR = 38, - R4300i_SPECIAL_NOR = 39, + R4300i_SPECIAL_NOR = 39, R4300i_SPECIAL_SLT = 42, R4300i_SPECIAL_SLTU = 43, R4300i_SPECIAL_DADD = 44, - R4300i_SPECIAL_DADDU = 45, + R4300i_SPECIAL_DADDU = 45, R4300i_SPECIAL_DSUB = 46, R4300i_SPECIAL_DSUBU = 47, - R4300i_SPECIAL_TGE = 48, + R4300i_SPECIAL_TGE = 48, R4300i_SPECIAL_TGEU = 49, R4300i_SPECIAL_TLT = 50, - R4300i_SPECIAL_TLTU = 51, + R4300i_SPECIAL_TLTU = 51, R4300i_SPECIAL_TEQ = 52, R4300i_SPECIAL_TNE = 54, - R4300i_SPECIAL_DSLL = 56, + R4300i_SPECIAL_DSLL = 56, R4300i_SPECIAL_DSRL = 58, R4300i_SPECIAL_DSRA = 59, R4300i_SPECIAL_DSLL32 = 60, @@ -174,18 +174,18 @@ enum R4300iSpecialOpCodes enum R4300iRegImmOpCodes { R4300i_REGIMM_BLTZ = 0, - R4300i_REGIMM_BGEZ = 1, + R4300i_REGIMM_BGEZ = 1, R4300i_REGIMM_BLTZL = 2, - R4300i_REGIMM_BGEZL = 3, - R4300i_REGIMM_TGEI = 8, + R4300i_REGIMM_BGEZL = 3, + R4300i_REGIMM_TGEI = 8, R4300i_REGIMM_TGEIU = 9, - R4300i_REGIMM_TLTI = 10, - R4300i_REGIMM_TLTIU = 11, + R4300i_REGIMM_TLTI = 10, + R4300i_REGIMM_TLTIU = 11, R4300i_REGIMM_TEQI = 12, - R4300i_REGIMM_TNEI = 14, - R4300i_REGIMM_BLTZAL = 16, + R4300i_REGIMM_TNEI = 14, + R4300i_REGIMM_BLTZAL = 16, R4300i_REGIMM_BGEZAL = 17, - R4300i_REGIMM_BLTZALL = 18, + R4300i_REGIMM_BLTZALL = 18, R4300i_REGIMM_BGEZALL = 19, }; @@ -199,70 +199,70 @@ enum R4300iCOP0OpCodes enum R4300iCOP0C0OpCodes { - R4300i_COP0_CO_TLBR = 1, - R4300i_COP0_CO_TLBWI = 2, + R4300i_COP0_CO_TLBR = 1, + R4300i_COP0_CO_TLBWI = 2, R4300i_COP0_CO_TLBWR = 6, - R4300i_COP0_CO_TLBP = 8, + R4300i_COP0_CO_TLBP = 8, R4300i_COP0_CO_ERET = 24, }; enum R4300iCOP1OpCodes { - R4300i_COP1_MF = 0, - R4300i_COP1_DMF = 1, - R4300i_COP1_CF = 2, + R4300i_COP1_MF = 0, + R4300i_COP1_DMF = 1, + R4300i_COP1_CF = 2, R4300i_COP1_MT = 4, R4300i_COP1_DMT = 5, - R4300i_COP1_CT = 6, + R4300i_COP1_CT = 6, R4300i_COP1_BC = 8, R4300i_COP1_S = 16, - R4300i_COP1_D = 17, - R4300i_COP1_W = 20, + R4300i_COP1_D = 17, + R4300i_COP1_W = 20, R4300i_COP1_L = 21, }; enum R4300iCOP1BcOpCodes { R4300i_COP1_BC_BCF = 0, - R4300i_COP1_BC_BCT = 1, + R4300i_COP1_BC_BCT = 1, R4300i_COP1_BC_BCFL = 2, R4300i_COP1_BC_BCTL = 3, }; enum R4300iCOP1FuntOpCodes { - R4300i_COP1_FUNCT_ADD = 0, + R4300i_COP1_FUNCT_ADD = 0, R4300i_COP1_FUNCT_SUB = 1, R4300i_COP1_FUNCT_MUL = 2, R4300i_COP1_FUNCT_DIV = 3, - R4300i_COP1_FUNCT_SQRT = 4, + R4300i_COP1_FUNCT_SQRT = 4, R4300i_COP1_FUNCT_ABS = 5, R4300i_COP1_FUNCT_MOV = 6, R4300i_COP1_FUNCT_NEG = 7, R4300i_COP1_FUNCT_ROUND_L = 8, - R4300i_COP1_FUNCT_TRUNC_L = 9, - R4300i_COP1_FUNCT_CEIL_L = 10, + R4300i_COP1_FUNCT_TRUNC_L = 9, + R4300i_COP1_FUNCT_CEIL_L = 10, R4300i_COP1_FUNCT_FLOOR_L = 11, - R4300i_COP1_FUNCT_ROUND_W = 12, + R4300i_COP1_FUNCT_ROUND_W = 12, R4300i_COP1_FUNCT_TRUNC_W = 13, R4300i_COP1_FUNCT_CEIL_W = 14, R4300i_COP1_FUNCT_FLOOR_W = 15, - R4300i_COP1_FUNCT_CVT_S = 32, + R4300i_COP1_FUNCT_CVT_S = 32, R4300i_COP1_FUNCT_CVT_D = 33, R4300i_COP1_FUNCT_CVT_W = 36, R4300i_COP1_FUNCT_CVT_L = 37, R4300i_COP1_FUNCT_C_F = 48, - R4300i_COP1_FUNCT_C_UN = 49, - R4300i_COP1_FUNCT_C_EQ = 50, + R4300i_COP1_FUNCT_C_UN = 49, + R4300i_COP1_FUNCT_C_EQ = 50, R4300i_COP1_FUNCT_C_UEQ = 51, - R4300i_COP1_FUNCT_C_OLT = 52, - R4300i_COP1_FUNCT_C_ULT = 53, + R4300i_COP1_FUNCT_C_OLT = 52, + R4300i_COP1_FUNCT_C_ULT = 53, R4300i_COP1_FUNCT_C_OLE = 54, - R4300i_COP1_FUNCT_C_ULE = 55, - R4300i_COP1_FUNCT_C_SF = 56, + R4300i_COP1_FUNCT_C_ULE = 55, + R4300i_COP1_FUNCT_C_SF = 56, R4300i_COP1_FUNCT_C_NGLE = 57, R4300i_COP1_FUNCT_C_SEQ = 58, - R4300i_COP1_FUNCT_C_NGL = 59, + R4300i_COP1_FUNCT_C_NGL = 59, R4300i_COP1_FUNCT_C_LT = 60, R4300i_COP1_FUNCT_C_NGE = 61, R4300i_COP1_FUNCT_C_LE = 62, diff --git a/Source/Project64-core/N64System/Mips/Register.cpp b/Source/Project64-core/N64System/Mips/Register.cpp index 715116e44..067a51cbb 100644 --- a/Source/Project64-core/N64System/Mips/Register.cpp +++ b/Source/Project64-core/N64System/Mips/Register.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" + +#include #include #include #include -#include const char * CRegName::GPR[32] = { "R0", @@ -36,11 +37,10 @@ const char * CRegName::GPR[32] = { "GP", "SP", "FP", - "RA" + "RA", }; -const char *CRegName::GPR_Hi[32] = -{ +const char * CRegName::GPR_Hi[32] = { "r0.HI", "at.HI", "v0.HI", @@ -72,11 +72,10 @@ const char *CRegName::GPR_Hi[32] = "gp.HI", "sp.HI", "fp.HI", - "ra.HI" + "ra.HI", }; -const char *CRegName::GPR_Lo[32] = -{ +const char * CRegName::GPR_Lo[32] = { "r0.LO", "at.LO", "v0.LO", @@ -108,11 +107,10 @@ const char *CRegName::GPR_Lo[32] = "gp.LO", "sp.LO", "fp.LO", - "ra.LO" + "ra.LO", }; -const char * CRegName::Cop0[32] = -{ +const char * CRegName::Cop0[32] = { "Index", "Random", "EntryLo0", @@ -144,11 +142,10 @@ const char * CRegName::Cop0[32] = "TagLo", "TagHi", "ErrEPC", - "Reg31" + "Reg31", }; -const char * CRegName::FPR[32] = -{ +const char * CRegName::FPR[32] = { "F0", "F1", "F2", @@ -180,11 +177,10 @@ const char * CRegName::FPR[32] = "F28", "F29", "F30", - "F31" + "F31", }; -const char * CRegName::FPR_Ctrl[32] = -{ +const char * CRegName::FPR_Ctrl[32] = { "Revision", "Unknown", "Unknown", @@ -216,20 +212,20 @@ const char * CRegName::FPR_Ctrl[32] = "Unknown", "Unknown", "Unknown", - "FCSR" + "FCSR", }; -uint32_t * CSystemRegisters::_PROGRAM_COUNTER = nullptr; -MIPS_DWORD * CSystemRegisters::_GPR = nullptr; -MIPS_DWORD * CSystemRegisters::_FPR = nullptr; -uint64_t * CSystemRegisters::_CP0 = nullptr; -MIPS_DWORD * CSystemRegisters::_RegHI = nullptr; -MIPS_DWORD * CSystemRegisters::_RegLO = nullptr; -float ** CSystemRegisters::_FPR_S; -double ** CSystemRegisters::_FPR_D; -uint32_t * CSystemRegisters::_FPCR = nullptr; -uint32_t * CSystemRegisters::_LLBit = nullptr; -int32_t * CSystemRegisters::_RoundingModel = nullptr; +uint32_t * CSystemRegisters::_PROGRAM_COUNTER = nullptr; +MIPS_DWORD * CSystemRegisters::_GPR = nullptr; +MIPS_DWORD * CSystemRegisters::_FPR = nullptr; +uint64_t * CSystemRegisters::_CP0 = nullptr; +MIPS_DWORD * CSystemRegisters::_RegHI = nullptr; +MIPS_DWORD * CSystemRegisters::_RegLO = nullptr; +float ** CSystemRegisters::_FPR_S; +double ** CSystemRegisters::_FPR_D; +uint32_t * CSystemRegisters::_FPCR = nullptr; +uint32_t * CSystemRegisters::_LLBit = nullptr; +int32_t * CSystemRegisters::_RoundingModel = nullptr; CP0registers::CP0registers(uint64_t * _CP0) : INDEX_REGISTER(_CP0[0]), @@ -353,7 +349,7 @@ void CRegisters::Cop0_MT(uint32_t Reg, uint64_t Value) if (LogCP0changes() && Reg <= 0x1F) { LogMessage("%08X: Writing 0x%I64U to %s register (originally: 0x%I64U)", (*_PROGRAM_COUNTER), Value, CRegName::Cop0[Reg], m_CP0[Reg]); - if (Reg == 11) // Compare + if (Reg == 11) // Compare { LogMessage("%08X: Cause register changed from %08X to %08X", (*_PROGRAM_COUNTER), CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); } @@ -361,12 +357,12 @@ void CRegisters::Cop0_MT(uint32_t Reg, uint64_t Value) switch (Reg) { - case 0: // Index - case 2: // EntryLo0 - case 3: // EntryLo1 - case 5: // PageMask - case 7: // Reg7 - case 8: // BadVaddr + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 5: // PageMask + case 7: // Reg7 + case 8: // BadVaddr case 10: // Entry Hi case 14: // EPC case 15: // PRId @@ -579,7 +575,6 @@ void CRegisters::DoTrapException(bool DelaySlot) EPC_REGISTER = (int64_t)((int32_t)m_PROGRAM_COUNTER); } m_PROGRAM_COUNTER = 0x80000180; - } void CRegisters::DoCopUnusableException(bool DelaySlot, int32_t Coprocessor) diff --git a/Source/Project64-core/N64System/Mips/Register.h b/Source/Project64-core/N64System/Mips/Register.h index 0f31070ab..2ac46f76b 100644 --- a/Source/Project64-core/N64System/Mips/Register.h +++ b/Source/Project64-core/N64System/Mips/Register.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include #include @@ -9,12 +9,12 @@ #include #include #include -#include #include +#include #include +#include #include #include -#include #pragma warning(push) #pragma warning(disable : 4201) // Non-standard extension used: nameless struct/union @@ -51,7 +51,7 @@ union COP0XContext class CP0registers { protected: - CP0registers (uint64_t * _CP0); + CP0registers(uint64_t * _CP0); public: uint64_t & INDEX_REGISTER; @@ -78,19 +78,29 @@ public: private: CP0registers(); - CP0registers(const CP0registers&); - CP0registers& operator=(const CP0registers&); + CP0registers(const CP0registers &); + CP0registers & operator=(const CP0registers &); }; // CPO register flags enum { // Status register - STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004, - STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400, - STATUS_IP3 = 0x00000800, STATUS_IP4 = 0x00001000, STATUS_IP5 = 0x00002000, - STATUS_IP6 = 0x00004000, STATUS_IP7 = 0x00008000, STATUS_BEV = 0x00400000, - STATUS_FR = 0x04000000, STATUS_CU0 = 0x10000000, STATUS_CU1 = 0x20000000, + STATUS_IE = 0x00000001, + STATUS_EXL = 0x00000002, + STATUS_ERL = 0x00000004, + STATUS_IP0 = 0x00000100, + STATUS_IP1 = 0x00000200, + STATUS_IP2 = 0x00000400, + STATUS_IP3 = 0x00000800, + STATUS_IP4 = 0x00001000, + STATUS_IP5 = 0x00002000, + STATUS_IP6 = 0x00004000, + STATUS_IP7 = 0x00008000, + STATUS_BEV = 0x00400000, + STATUS_FR = 0x04000000, + STATUS_CU0 = 0x10000000, + STATUS_CU1 = 0x20000000, // Cause flags CAUSE_EXC_CODE = 0xFF, @@ -105,171 +115,170 @@ enum CAUSE_BD = 0x80000000, // Cause exception ID's - EXC_INT = 0, // Interrupt - EXC_MOD = 4, // TLB mod + EXC_INT = 0, // Interrupt + EXC_MOD = 4, // TLB mod EXC_RMISS = 8, // Read TLB miss - EXC_WMISS = 12, // Write TLB miss + EXC_WMISS = 12, // Write TLB miss EXC_RADE = 16, // Read address error EXC_WADE = 20, // Write address error - EXC_IBE = 24, // Instruction bus error - EXC_DBE = 28, // Data bus error - EXC_SYSCALL = 32, // Syscall - EXC_BREAK = 36, // Breakpoint - EXC_II = 40, // Illegal instruction - EXC_CPU = 44, // Co-processor unusable - EXC_OV = 48, // Overflow - EXC_TRAP = 52, // Trap exception - EXC_VCEI = 56, // Virtual coherency on instruction fetch - EXC_FPE = 60, // Floating point exception + EXC_IBE = 24, // Instruction bus error + EXC_DBE = 28, // Data bus error + EXC_SYSCALL = 32, // Syscall + EXC_BREAK = 36, // Breakpoint + EXC_II = 40, // Illegal instruction + EXC_CPU = 44, // Co-processor unusable + EXC_OV = 48, // Overflow + EXC_TRAP = 52, // Trap exception + EXC_VCEI = 56, // Virtual coherency on instruction fetch + EXC_FPE = 60, // Floating point exception EXC_WATCH = 92, // Watchpoint reference - EXC_VCED = 124, // Virtual coherency on data read + EXC_VCED = 124, // Virtual coherency on data read }; // Float point control status register flags enum { - FPCSR_FS = 0x01000000, // Flush denormalization to zero - FPCSR_C = 0x00800000, // Condition bit - FPCSR_CE = 0x00020000, // Cause: unimplemented operation - FPCSR_CV = 0x00010000, // Cause: invalid operation - FPCSR_CZ = 0x00008000, // Cause: division by zero - FPCSR_CO = 0x00004000, // Cause: overflow - FPCSR_CU = 0x00002000, // Cause: underflow - FPCSR_CI = 0x00001000, // Cause: inexact operation - FPCSR_EV = 0x00000800, // Enable: invalid operation - FPCSR_EZ = 0x00000400, // Enable: division by zero - FPCSR_EO = 0x00000200, // Enable: overflow - FPCSR_EU = 0x00000100, // Enable: underflow - FPCSR_EI = 0x00000080, // Enable: inexact operation - FPCSR_FV = 0x00000040, // Flag: invalid operation - FPCSR_FZ = 0x00000020, // Flag: division by zero - FPCSR_FO = 0x00000010, // Flag: overflow - FPCSR_FU = 0x00000008, // Flag: underflow - FPCSR_FI = 0x00000004, // Flag: inexact operation + FPCSR_FS = 0x01000000, // Flush denormalization to zero + FPCSR_C = 0x00800000, // Condition bit + FPCSR_CE = 0x00020000, // Cause: unimplemented operation + FPCSR_CV = 0x00010000, // Cause: invalid operation + FPCSR_CZ = 0x00008000, // Cause: division by zero + FPCSR_CO = 0x00004000, // Cause: overflow + FPCSR_CU = 0x00002000, // Cause: underflow + FPCSR_CI = 0x00001000, // Cause: inexact operation + FPCSR_EV = 0x00000800, // Enable: invalid operation + FPCSR_EZ = 0x00000400, // Enable: division by zero + FPCSR_EO = 0x00000200, // Enable: overflow + FPCSR_EU = 0x00000100, // Enable: underflow + FPCSR_EI = 0x00000080, // Enable: inexact operation + FPCSR_FV = 0x00000040, // Flag: invalid operation + FPCSR_FZ = 0x00000020, // Flag: division by zero + FPCSR_FO = 0x00000010, // Flag: overflow + FPCSR_FU = 0x00000008, // Flag: underflow + FPCSR_FI = 0x00000004, // Flag: inexact operation FPCSR_RM_MASK = 0x00000003, // Rounding mode mask - FPCSR_RM_RN = 0x00000000, // Round to nearest - FPCSR_RM_RZ = 0x00000001, // Round to zero - FPCSR_RM_RP = 0x00000002, // Round to positive infinity - FPCSR_RM_RM = 0x00000003, // Round to negative infinity + FPCSR_RM_RN = 0x00000000, // Round to nearest + FPCSR_RM_RZ = 0x00000001, // Round to zero + FPCSR_RM_RP = 0x00000002, // Round to positive infinity + FPCSR_RM_RM = 0x00000003, // Round to negative infinity }; - // MIPS interface flags enum { - MI_MODE_INIT = 0x0080, // Bit 7: Initialization mode - MI_MODE_EBUS = 0x0100, // Bit 8: EBUS test mode - MI_MODE_RDRAM = 0x0200, // Bit 9: RDRAM register mode + MI_MODE_INIT = 0x0080, // Bit 7: Initialization mode + MI_MODE_EBUS = 0x0100, // Bit 8: EBUS test mode + MI_MODE_RDRAM = 0x0200, // Bit 9: RDRAM register mode - MI_CLR_INIT = 0x0080, // Bit 7: Clear initialization mode - MI_SET_INIT = 0x0100, // Bit 8: Set initialization mode - MI_CLR_EBUS = 0x0200, // Bit 9: Clear EBUS test - MI_SET_EBUS = 0x0400, // Bit 10: Set EBUS test mode - MI_CLR_DP_INTR = 0x0800, // Bit 11: Clear DP interrupt - MI_CLR_RDRAM = 0x1000, // Bit 12: Clear RDRAM register - MI_SET_RDRAM = 0x2000, // Bit 13: Set RDRAM register mode + MI_CLR_INIT = 0x0080, // Bit 7: Clear initialization mode + MI_SET_INIT = 0x0100, // Bit 8: Set initialization mode + MI_CLR_EBUS = 0x0200, // Bit 9: Clear EBUS test + MI_SET_EBUS = 0x0400, // Bit 10: Set EBUS test mode + MI_CLR_DP_INTR = 0x0800, // Bit 11: Clear DP interrupt + MI_CLR_RDRAM = 0x1000, // Bit 12: Clear RDRAM register + MI_SET_RDRAM = 0x2000, // Bit 13: Set RDRAM register mode // Flags for writing to MI_INTR_MASK_REG - MI_INTR_MASK_CLR_SP = 0x0001, // Bit 0: Clear SP mask - MI_INTR_MASK_SET_SP = 0x0002, // Bit 1: Set SP mask - MI_INTR_MASK_CLR_SI = 0x0004, // Bit 2: Clear SI mask - MI_INTR_MASK_SET_SI = 0x0008, // Bit 3: Set SI mask - MI_INTR_MASK_CLR_AI = 0x0010, // Bit 4: Clear AI mask - MI_INTR_MASK_SET_AI = 0x0020, // Bit 5: Set AI mask - MI_INTR_MASK_CLR_VI = 0x0040, // Bit 6: Clear VI mask - MI_INTR_MASK_SET_VI = 0x0080, // Bit 7: Set VI mask - MI_INTR_MASK_CLR_PI = 0x0100, // Bit 8: Clear PI mask - MI_INTR_MASK_SET_PI = 0x0200, // Bit 9: Set PI mask - MI_INTR_MASK_CLR_DP = 0x0400, // Bit 10: Clear DP mask - MI_INTR_MASK_SET_DP = 0x0800, // Bit 11: Set DP mask + MI_INTR_MASK_CLR_SP = 0x0001, // Bit 0: Clear SP mask + MI_INTR_MASK_SET_SP = 0x0002, // Bit 1: Set SP mask + MI_INTR_MASK_CLR_SI = 0x0004, // Bit 2: Clear SI mask + MI_INTR_MASK_SET_SI = 0x0008, // Bit 3: Set SI mask + MI_INTR_MASK_CLR_AI = 0x0010, // Bit 4: Clear AI mask + MI_INTR_MASK_SET_AI = 0x0020, // Bit 5: Set AI mask + MI_INTR_MASK_CLR_VI = 0x0040, // Bit 6: Clear VI mask + MI_INTR_MASK_SET_VI = 0x0080, // Bit 7: Set VI mask + MI_INTR_MASK_CLR_PI = 0x0100, // Bit 8: Clear PI mask + MI_INTR_MASK_SET_PI = 0x0200, // Bit 9: Set PI mask + MI_INTR_MASK_CLR_DP = 0x0400, // Bit 10: Clear DP mask + MI_INTR_MASK_SET_DP = 0x0800, // Bit 11: Set DP mask // Flags for reading from MI_INTR_MASK_REG - MI_INTR_MASK_SP = 0x01, // Bit 0: SP INTR mask - MI_INTR_MASK_SI = 0x02, // Bit 1: SI INTR mask - MI_INTR_MASK_AI = 0x04, // Bit 2: AI INTR mask - MI_INTR_MASK_VI = 0x08, // Bit 3: VI INTR mask - MI_INTR_MASK_PI = 0x10, // Bit 4: PI INTR mask - MI_INTR_MASK_DP = 0x20, // Bit 5: DP INTR mask + MI_INTR_MASK_SP = 0x01, // Bit 0: SP INTR mask + MI_INTR_MASK_SI = 0x02, // Bit 1: SI INTR mask + MI_INTR_MASK_AI = 0x04, // Bit 2: AI INTR mask + MI_INTR_MASK_VI = 0x08, // Bit 3: VI INTR mask + MI_INTR_MASK_PI = 0x10, // Bit 4: PI INTR mask + MI_INTR_MASK_DP = 0x20, // Bit 5: DP INTR mask - MI_INTR_SP = 0x01, // Bit 0: SP INTR - MI_INTR_SI = 0x02, // Bit 1: SI INTR - MI_INTR_AI = 0x04, // Bit 2: AI INTR - MI_INTR_VI = 0x08, // Bit 3: VI INTR - MI_INTR_PI = 0x10, // Bit 4: PI INTR - MI_INTR_DP = 0x20, // Bit 5: DP INTR + MI_INTR_SP = 0x01, // Bit 0: SP INTR + MI_INTR_SI = 0x02, // Bit 1: SI INTR + MI_INTR_AI = 0x04, // Bit 2: AI INTR + MI_INTR_VI = 0x08, // Bit 3: VI INTR + MI_INTR_PI = 0x10, // Bit 4: PI INTR + MI_INTR_DP = 0x20, // Bit 5: DP INTR }; // Signal processor interface flags enum { - SP_CLR_HALT = 0x00001, // Bit 0: Clear halt - SP_SET_HALT = 0x00002, // Bit 1: Set halt - SP_CLR_BROKE = 0x00004, // Bit 2: Clear broke - SP_CLR_INTR = 0x00008, // Bit 3: Clear INTR - SP_SET_INTR = 0x00010, // Bit 4: Set INTR - SP_CLR_SSTEP = 0x00020, // Bit 5: Clear SSTEP - SP_SET_SSTEP = 0x00040, // Bit 6: Set SSTEP - SP_CLR_INTR_BREAK = 0x00080, // Bit 7: Clear INTR on break - SP_SET_INTR_BREAK = 0x00100, // Bit 8: Set INTR on break - SP_CLR_SIG0 = 0x00200, // Bit 9: Clear signal 0 - SP_SET_SIG0 = 0x00400, // Bit 10: Set signal 0 - SP_CLR_SIG1 = 0x00800, // Bit 11: Clear signal 1 - SP_SET_SIG1 = 0x01000, // Bit 12: Set signal 1 - SP_CLR_SIG2 = 0x02000, // Bit 13: Clear signal 2 - SP_SET_SIG2 = 0x04000, // Bit 14: Set signal 2 - SP_CLR_SIG3 = 0x08000, // Bit 15: Clear signal 3 - SP_SET_SIG3 = 0x10000, // Bit 16: Set signal 3 - SP_CLR_SIG4 = 0x20000, // Bit 17: Clear signal 4 - SP_SET_SIG4 = 0x40000, // Bit 18: Set signal 4 - SP_CLR_SIG5 = 0x80000, // Bit 19: Clear signal 5 - SP_SET_SIG5 = 0x100000, // Bit 20: Set signal 5 - SP_CLR_SIG6 = 0x200000, // Bit 21: Clear signal 6 - SP_SET_SIG6 = 0x400000, // Bit 22: Set signal 6 - SP_CLR_SIG7 = 0x800000, // Bit 23: Clear signal 7 - SP_SET_SIG7 = 0x1000000, // Bit 24: Set signal 7 + SP_CLR_HALT = 0x00001, // Bit 0: Clear halt + SP_SET_HALT = 0x00002, // Bit 1: Set halt + SP_CLR_BROKE = 0x00004, // Bit 2: Clear broke + SP_CLR_INTR = 0x00008, // Bit 3: Clear INTR + SP_SET_INTR = 0x00010, // Bit 4: Set INTR + SP_CLR_SSTEP = 0x00020, // Bit 5: Clear SSTEP + SP_SET_SSTEP = 0x00040, // Bit 6: Set SSTEP + SP_CLR_INTR_BREAK = 0x00080, // Bit 7: Clear INTR on break + SP_SET_INTR_BREAK = 0x00100, // Bit 8: Set INTR on break + SP_CLR_SIG0 = 0x00200, // Bit 9: Clear signal 0 + SP_SET_SIG0 = 0x00400, // Bit 10: Set signal 0 + SP_CLR_SIG1 = 0x00800, // Bit 11: Clear signal 1 + SP_SET_SIG1 = 0x01000, // Bit 12: Set signal 1 + SP_CLR_SIG2 = 0x02000, // Bit 13: Clear signal 2 + SP_SET_SIG2 = 0x04000, // Bit 14: Set signal 2 + SP_CLR_SIG3 = 0x08000, // Bit 15: Clear signal 3 + SP_SET_SIG3 = 0x10000, // Bit 16: Set signal 3 + SP_CLR_SIG4 = 0x20000, // Bit 17: Clear signal 4 + SP_SET_SIG4 = 0x40000, // Bit 18: Set signal 4 + SP_CLR_SIG5 = 0x80000, // Bit 19: Clear signal 5 + SP_SET_SIG5 = 0x100000, // Bit 20: Set signal 5 + SP_CLR_SIG6 = 0x200000, // Bit 21: Clear signal 6 + SP_SET_SIG6 = 0x400000, // Bit 22: Set signal 6 + SP_CLR_SIG7 = 0x800000, // Bit 23: Clear signal 7 + SP_SET_SIG7 = 0x1000000, // Bit 24: Set signal 7 - SP_STATUS_HALT = 0x001, // Bit 0: Halt - SP_STATUS_BROKE = 0x002, // Bit 1: Broke - SP_STATUS_DMA_BUSY = 0x004, // Bit 2: DMA busy - SP_STATUS_DMA_FULL = 0x008, // Bit 3: DMA full - SP_STATUS_IO_FULL = 0x010, // Bit 4: IO full - SP_STATUS_SSTEP = 0x020, // Bit 5: Single step - SP_STATUS_INTR_BREAK = 0x040, // Bit 6: Interrupt on break - SP_STATUS_SIG0 = 0x080, // Bit 7: Signal 0 set - SP_STATUS_SIG1 = 0x100, // Bit 8: Signal 1 set - SP_STATUS_SIG2 = 0x200, // Bit 9: Signal 2 set - SP_STATUS_SIG3 = 0x400, // Bit 10: Signal 3 set - SP_STATUS_SIG4 = 0x800, // Bit 11: Signal 4 set - SP_STATUS_SIG5 = 0x1000, // Bit 12: Signal 5 set - SP_STATUS_SIG6 = 0x2000, // Bit 13: Signal 6 set - SP_STATUS_SIG7 = 0x4000, // Bit 14: Signal 7 set + SP_STATUS_HALT = 0x001, // Bit 0: Halt + SP_STATUS_BROKE = 0x002, // Bit 1: Broke + SP_STATUS_DMA_BUSY = 0x004, // Bit 2: DMA busy + SP_STATUS_DMA_FULL = 0x008, // Bit 3: DMA full + SP_STATUS_IO_FULL = 0x010, // Bit 4: IO full + SP_STATUS_SSTEP = 0x020, // Bit 5: Single step + SP_STATUS_INTR_BREAK = 0x040, // Bit 6: Interrupt on break + SP_STATUS_SIG0 = 0x080, // Bit 7: Signal 0 set + SP_STATUS_SIG1 = 0x100, // Bit 8: Signal 1 set + SP_STATUS_SIG2 = 0x200, // Bit 9: Signal 2 set + SP_STATUS_SIG3 = 0x400, // Bit 10: Signal 3 set + SP_STATUS_SIG4 = 0x800, // Bit 11: Signal 4 set + SP_STATUS_SIG5 = 0x1000, // Bit 12: Signal 5 set + SP_STATUS_SIG6 = 0x2000, // Bit 13: Signal 6 set + SP_STATUS_SIG7 = 0x4000, // Bit 14: Signal 7 set }; class CRegName { public: - static const char *GPR[32]; - static const char *GPR_Hi[32]; - static const char *GPR_Lo[32]; - static const char *Cop0[32]; - static const char *FPR[32]; - static const char *FPR_Ctrl[32]; + static const char * GPR[32]; + static const char * GPR_Hi[32]; + static const char * GPR_Lo[32]; + static const char * Cop0[32]; + static const char * FPR[32]; + static const char * FPR_Ctrl[32]; }; class CSystemRegisters { protected: - static uint32_t * _PROGRAM_COUNTER; - static MIPS_DWORD * _GPR; - static MIPS_DWORD * _FPR; - static uint64_t * _CP0; - static MIPS_DWORD * _RegHI; - static MIPS_DWORD * _RegLO; - static float ** _FPR_S; - static double ** _FPR_D; - static uint32_t * _FPCR; - static uint32_t * _LLBit; - static int32_t * _RoundingModel; + static uint32_t * _PROGRAM_COUNTER; + static MIPS_DWORD * _GPR; + static MIPS_DWORD * _FPR; + static uint64_t * _CP0; + static MIPS_DWORD * _RegHI; + static MIPS_DWORD * _RegLO; + static float ** _FPR_S; + static double ** _FPR_D; + static uint32_t * _FPCR; + static uint32_t * _LLBit; + static int32_t * _RoundingModel; }; class CN64System; @@ -296,16 +305,16 @@ public: CRegisters(CN64System * System, CSystemEvents * SystemEvents); void CheckInterrupts(); - void DoAddressError( bool DelaySlot, uint64_t BadVaddr, bool FromRead ); - void DoBreakException( bool DelaySlot ); - void DoTrapException( bool DelaySlot ); - void DoCopUnusableException( bool DelaySlot, int32_t Coprocessor ); - bool DoIntrException( bool DelaySlot ); + void DoAddressError(bool DelaySlot, uint64_t BadVaddr, bool FromRead); + void DoBreakException(bool DelaySlot); + void DoTrapException(bool DelaySlot); + void DoCopUnusableException(bool DelaySlot, int32_t Coprocessor); + bool DoIntrException(bool DelaySlot); void DoIllegalInstructionException(bool DelaySlot); void DoOverflowException(bool DelaySlot); void DoTLBReadMiss(bool DelaySlot, uint64_t BadVaddr); void DoTLBWriteMiss(bool DelaySlot, uint64_t BadVaddr); - void DoSysCallException ( bool DelaySlot); + void DoSysCallException(bool DelaySlot); void FixFpuLocations(); void Reset(); void SetAsCurrentSystem(); @@ -345,8 +354,8 @@ public: private: CRegisters(); - CRegisters(const CRegisters&); - CRegisters& operator=(const CRegisters&); + CRegisters(const CRegisters &); + CRegisters & operator=(const CRegisters &); bool m_FirstInterupt; CN64System * m_System; diff --git a/Source/Project64-core/N64System/Mips/Rumblepak.cpp b/Source/Project64-core/N64System/Mips/Rumblepak.cpp index 40d2f7ef9..fdd4eb5e3 100644 --- a/Source/Project64-core/N64System/Mips/Rumblepak.cpp +++ b/Source/Project64-core/N64System/Mips/Rumblepak.cpp @@ -1,29 +1,29 @@ #include "stdafx.h" -#include "Rumblepak.h" +#include "Rumblepak.h" #include -#include #include +#include void Rumblepak::ReadFrom(uint32_t address, uint8_t * data) { - if ((address >= 0x8000) && (address < 0x9000)) - { - memset(data, 0x80, 0x20); - } - else - { - memset(data, 0x00, 0x20); - } + if ((address >= 0x8000) && (address < 0x9000)) + { + memset(data, 0x80, 0x20); + } + else + { + memset(data, 0x00, 0x20); + } } void Rumblepak::WriteTo(int32_t Control, uint32_t address, uint8_t * data) { - if ((address) == 0xC000) - { - if (g_Plugins->Control()->RumbleCommand != nullptr) - { - g_Plugins->Control()->RumbleCommand(Control, *(int *)data); - } - } + if ((address) == 0xC000) + { + if (g_Plugins->Control()->RumbleCommand != nullptr) + { + g_Plugins->Control()->RumbleCommand(Control, *(int *)data); + } + } } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/SystemEvents.cpp b/Source/Project64-core/N64System/Mips/SystemEvents.cpp index 17ba830f5..51ea4e0f0 100644 --- a/Source/Project64-core/N64System/Mips/SystemEvents.cpp +++ b/Source/Project64-core/N64System/Mips/SystemEvents.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include -#include #include +#include const char * SystemEventName(SystemEvent event) { diff --git a/Source/Project64-core/N64System/Mips/SystemEvents.h b/Source/Project64-core/N64System/Mips/SystemEvents.h index 499b12d91..9cde291aa 100644 --- a/Source/Project64-core/N64System/Mips/SystemEvents.h +++ b/Source/Project64-core/N64System/Mips/SystemEvents.h @@ -72,14 +72,14 @@ public: private: CSystemEvents(); - CSystemEvents(const CSystemEvents&); - CSystemEvents& operator=(const CSystemEvents&); + CSystemEvents(const CSystemEvents &); + CSystemEvents & operator=(const CSystemEvents &); void ChangePluginFunc(); - CN64System * m_System; - CPlugins * m_Plugins; - EventList m_Events; - int32_t m_bDoSomething; + CN64System * m_System; + CPlugins * m_Plugins; + EventList m_Events; + int32_t m_bDoSomething; CriticalSection m_CS; }; diff --git a/Source/Project64-core/N64System/Mips/SystemTiming.cpp b/Source/Project64-core/N64System/Mips/SystemTiming.cpp index f616615e1..5165ac18b 100644 --- a/Source/Project64-core/N64System/Mips/SystemTiming.cpp +++ b/Source/Project64-core/N64System/Mips/SystemTiming.cpp @@ -1,12 +1,11 @@ #include "stdafx.h" -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include CSystemTimer::CSystemTimer(CN64System & System) : m_System(System), @@ -56,12 +55,12 @@ void CSystemTimer::SetTimer(TimerType Type, uint32_t Cycles, bool bRelative) } else { - m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; // Replace the new cycles + m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; // Replace the new cycles } } else { - m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; // Replace the new cycles + m_TimerDetatils[Type].CyclesToTimer = (int64_t)Cycles - (int64_t)m_NextTimer; // Replace the new cycles } FixTimers(); } @@ -400,7 +399,7 @@ void CSystemTimer::LoadData(CFile & file) file.Read((void *)&m_Current, sizeof(m_Current)); } -void CSystemTimer::RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer) +void CSystemTimer::RecordDifference(CLog & LogFile, const CSystemTimer & rSystemTimer) { if (m_LastUpdate != rSystemTimer.m_LastUpdate) { @@ -432,7 +431,7 @@ void CSystemTimer::RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTi } } -bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const +bool CSystemTimer::operator==(const CSystemTimer & rSystemTimer) const { if (m_LastUpdate != rSystemTimer.m_LastUpdate) { @@ -465,7 +464,7 @@ bool CSystemTimer::operator == (const CSystemTimer& rSystemTimer) const return true; } -bool CSystemTimer::operator != (const CSystemTimer& rSystemTimer) const +bool CSystemTimer::operator!=(const CSystemTimer & rSystemTimer) const { return !(*this == rSystemTimer); } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/SystemTiming.h b/Source/Project64-core/N64System/Mips/SystemTiming.h index 1f48c79d3..14c0fc1c5 100644 --- a/Source/Project64-core/N64System/Mips/SystemTiming.h +++ b/Source/Project64-core/N64System/Mips/SystemTiming.h @@ -1,11 +1,12 @@ #pragma once #include -#include -#include #include +#include +#include class AudioInterfaceHandler; +class RomMemoryHandler; class CSystemTimer { @@ -32,7 +33,7 @@ public: struct TIMER_DETAILS { - union + union { int64_t reserved; bool Active; @@ -42,7 +43,7 @@ public: CSystemTimer(CN64System & System); void SetTimer(TimerType Type, uint32_t Cycles, bool bRelative); - uint32_t GetTimer(TimerType Type); + uint32_t GetTimer(TimerType Type); void StopTimer(TimerType Type); void UpdateTimers(); void TimerDone(); @@ -55,21 +56,24 @@ public: void LoadData(zipFile & file); void LoadData(CFile & file); - void RecordDifference(CLog &LogFile, const CSystemTimer& rSystemTimer); + void RecordDifference(CLog & LogFile, const CSystemTimer & rSystemTimer); - TimerType CurrentType() const { return m_Current; } + TimerType CurrentType() const + { + return m_Current; + } - bool operator == (const CSystemTimer& rSystemTimer) const; - bool operator != (const CSystemTimer& rSystemTimer) const; + bool operator==(const CSystemTimer & rSystemTimer) const; + bool operator!=(const CSystemTimer & rSystemTimer) const; private: CSystemTimer(void); - CSystemTimer(const CSystemTimer&); - CSystemTimer& operator=(const CSystemTimer&); + CSystemTimer(const CSystemTimer &); + CSystemTimer & operator=(const CSystemTimer &); void SetCompareTimer(); void FixTimers(); - + CN64System & m_System; TIMER_DETAILS m_TimerDetatils[MaxTimer]; int32_t m_LastUpdate; diff --git a/Source/Project64-core/N64System/Mips/TLB.cpp b/Source/Project64-core/N64System/Mips/TLB.cpp index b4d6f1ed6..0899fd450 100644 --- a/Source/Project64-core/N64System/Mips/TLB.cpp +++ b/Source/Project64-core/N64System/Mips/TLB.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" + #include "TLB.h" -#include #include +#include CTLB::CTLB(CTLB_CB * CallBack) : -m_CB(CallBack) + m_CB(CallBack) { WriteTrace(TraceTLB, TraceDebug, "Start"); memset(m_tlb, 0, sizeof(m_tlb)); @@ -85,7 +86,7 @@ void CTLB::Probe() if (TlbValueMasked == EntryHiMasked) { - if ((TlbEntryHiValue & 0x100) != 0 || // Global + if ((TlbEntryHiValue & 0x100) != 0 || // Global ((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) // SameAsid { g_Reg->INDEX_REGISTER = Counter; @@ -262,7 +263,7 @@ bool CTLB::PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index) return false; } -void CTLB::RecordDifference(CLog &LogFile, const CTLB& rTLB) +void CTLB::RecordDifference(CLog & LogFile, const CTLB & rTLB) { for (int i = 0, n = sizeof(m_tlb) / sizeof(m_tlb[0]); i < n; i++) { @@ -294,7 +295,7 @@ void CTLB::RecordDifference(CLog &LogFile, const CTLB& rTLB) } } -bool CTLB::operator == (const CTLB& rTLB) const +bool CTLB::operator==(const CTLB & rTLB) const { const size_t n = sizeof(m_tlb) / sizeof(m_tlb[0]); for (size_t i = 0; i < n; i++) @@ -318,7 +319,7 @@ bool CTLB::operator == (const CTLB& rTLB) const return true; } -bool CTLB::operator != (const CTLB& rTLB) const +bool CTLB::operator!=(const CTLB & rTLB) const { return !(*this == rTLB); } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/TLB.h b/Source/Project64-core/N64System/Mips/TLB.h index 8ca36f6bf..ae36bbeaa 100644 --- a/Source/Project64-core/N64System/Mips/TLB.h +++ b/Source/Project64-core/N64System/Mips/TLB.h @@ -103,10 +103,10 @@ public: bool PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index); - void RecordDifference(CLog &LogFile, const CTLB& rTLB); + void RecordDifference(CLog & LogFile, const CTLB & rTLB); - bool operator == (const CTLB& rTLB) const; - bool operator != (const CTLB& rTLB) const; + bool operator==(const CTLB & rTLB) const; + bool operator!=(const CTLB & rTLB) const; private: struct FASTTLB @@ -116,12 +116,12 @@ private: uint32_t PHYSSTART; uint32_t PHYSEND; uint32_t Length; - bool VALID; - bool DIRTY; - bool GLOBAL; - bool ValidEntry; - bool Random; - bool Probed; + bool VALID; + bool DIRTY; + bool GLOBAL; + bool ValidEntry; + bool Random; + bool Probed; }; friend class CDebugTlb; // Enable debug window to read class @@ -129,14 +129,14 @@ private: CTLB_CB * const m_CB; TLB_ENTRY m_tlb[32]; - FASTTLB m_FastTlb[64]; + FASTTLB m_FastTlb[64]; void SetupTLB_Entry(int32_t index, bool Random); private: CTLB(); - CTLB(const CTLB&); - CTLB& operator=(const CTLB&); + CTLB(const CTLB &); + CTLB & operator=(const CTLB &); }; #pragma warning(pop) diff --git a/Source/Project64-core/N64System/Mips/Transferpak.cpp b/Source/Project64-core/N64System/Mips/Transferpak.cpp index 531f34248..6b67eca39 100644 --- a/Source/Project64-core/N64System/Mips/Transferpak.cpp +++ b/Source/Project64-core/N64System/Mips/Transferpak.cpp @@ -5,6 +5,7 @@ // GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html #include "stdafx.h" + #include "GBCart.h" #include "Transferpak.h" @@ -36,42 +37,41 @@ void Transferpak::Release() void Transferpak::ReadFrom(uint16_t address, uint8_t * data) { - if ((address >= 0x8000) && (address <= 0x8FFF)) - { + if ((address >= 0x8000) && (address <= 0x8FFF)) + { // Ensure we actually have a ROM loaded in first if (tpak.gb_cart.rom == nullptr) { Init(); } - // Get whether the Game Boy cart is enabled or disabled - uint8_t value = (tpak.enabled) ? 0x84 : 0x00; + // Get whether the Game Boy cart is enabled or disabled + uint8_t value = (tpak.enabled) ? 0x84 : 0x00; + + memset(data, value, 0x20); + } + else if ((address >= 0xB000) && (address <= 0xBFFF)) + { + // Get the Game Boy cart access mode + if (tpak.enabled) + { + memset(data, tpak.access_mode, 0x20); + if (tpak.access_mode != CART_NOT_INSERTED) + { + data[0] |= tpak.access_mode_changed; + } - memset(data, value, 0x20); - } - else if ((address >= 0xB000) && (address <= 0xBFFF)) - { - // Get the Game Boy cart access mode - if (tpak.enabled) - { - memset(data, tpak.access_mode, 0x20); - if (tpak.access_mode != CART_NOT_INSERTED) - { - data[0] |= tpak.access_mode_changed; - } - tpak.access_mode_changed = 0; - } - } - else if (address >= 0xC000) - { - // Read the Game Boy cart - if (tpak.enabled) - { + } + } + else if (address >= 0xC000) + { + // Read the Game Boy cart + if (tpak.enabled) + { GBCart::read_gb_cart(&tpak.gb_cart, gb_cart_address(tpak.bank, address), data); - } - } - + } + } } void Transferpak::WriteTo(uint16_t address, uint8_t * data) @@ -99,7 +99,7 @@ void Transferpak::WriteTo(uint16_t address, uint8_t * data) break; } } - else if ((address >= 0xA000) && (address <= 0xAFFF)) + else if ((address >= 0xA000) && (address <= 0xAFFF)) { // Set the bank for the Game Boy cart if (tpak.enabled) diff --git a/Source/Project64-core/N64System/Mips/Transferpak.h b/Source/Project64-core/N64System/Mips/Transferpak.h index e60fddbfe..84ed6922f 100644 --- a/Source/Project64-core/N64System/Mips/Transferpak.h +++ b/Source/Project64-core/N64System/Mips/Transferpak.h @@ -1,27 +1,27 @@ #pragma once #include "GBCart.h" + enum cart_access_mode { - CART_NOT_INSERTED = 0x40, - CART_ACCESS_MODE_0 = 0x80, - CART_ACCESS_MODE_1 = 0x89 + CART_NOT_INSERTED = 0x40, + CART_ACCESS_MODE_0 = 0x80, + CART_ACCESS_MODE_1 = 0x89 }; struct transferpak { - unsigned int enabled; - unsigned int bank; - unsigned int access_mode; - unsigned int access_mode_changed; - struct gb_cart gb_cart; + unsigned int enabled; + unsigned int bank; + unsigned int access_mode; + unsigned int access_mode_changed; + struct gb_cart gb_cart; }; class Transferpak { public: - static void Release(); static void Init(); - static void ReadFrom(uint16_t address, uint8_t * command); - static void WriteTo(uint16_t address, uint8_t * command); + static void ReadFrom(uint16_t address, uint8_t * command); + static void WriteTo(uint16_t address, uint8_t * command); }; diff --git a/Source/Project64-core/N64System/N64Disk.cpp b/Source/Project64-core/N64System/N64Disk.cpp index e6558e4bf..53faea0dd 100644 --- a/Source/Project64-core/N64System/N64Disk.cpp +++ b/Source/Project64-core/N64System/N64Disk.cpp @@ -1,9 +1,10 @@ #include "stdafx.h" + #include "N64Disk.h" #include "SystemGlobals.h" -#include -#include #include +#include +#include #include #include @@ -193,9 +194,18 @@ bool CN64Disk::IsValidDiskImage(uint8_t Test[0x20]) if (ipl_load_addr < 0x80000000 && ipl_load_addr >= 0x80800000) return false; // Country code - if (*((uint32_t *)&Test[0]) == 0x16D348E8) { return true; } - else if (*((uint32_t *)&Test[0]) == 0x56EE6322) { return true; } - else if (*((uint32_t *)&Test[0]) == 0x00000000) { return true; } + if (*((uint32_t *)&Test[0]) == 0x16D348E8) + { + return true; + } + else if (*((uint32_t *)&Test[0]) == 0x56EE6322) + { + return true; + } + else if (*((uint32_t *)&Test[0]) == 0x00000000) + { + return true; + } return false; } @@ -284,7 +294,7 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) uint8_t Test[0x100]; bool isValidDisk = false; - const uint8_t blocks[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; + const uint8_t blocks[8] = {0, 1, 2, 3, 8, 9, 10, 11}; for (int i = 0; i < 8; i++) { m_DiskFile.Seek(0x4D08 * blocks[i], CFileBase::SeekPosition::begin); @@ -339,7 +349,10 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) for (count = 0; count < (int)DiskFileSize; count += ReadFromRomSection) { uint32_t dwToRead = DiskFileSize - count; - if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; } + if (dwToRead > ReadFromRomSection) + { + dwToRead = ReadFromRomSection; + } if (m_DiskFile.Read(&m_DiskImage[count], dwToRead) != dwToRead) { @@ -416,7 +429,10 @@ bool CN64Disk::AllocateAndLoadDiskImage(const char * FileLoc) for (count = 0; count < (int)DiskFileSize; count += ReadFromRomSection) { uint32_t dwToRead = DiskFileSize - count; - if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; } + if (dwToRead > ReadFromRomSection) + { + dwToRead = ReadFromRomSection; + } if (m_DiskFile.Read(&m_DiskImage[count], dwToRead) != dwToRead) { @@ -575,7 +591,7 @@ uint32_t CN64Disk::CalculateCrc() uint32_t crc = 0; for (int i = 0; i < 0x4D08; i += 4) { - crc += *(uint32_t*)(&GetDiskAddressRom()[i]); + crc += *(uint32_t *)(&GetDiskAddressRom()[i]); } return crc; } @@ -672,9 +688,9 @@ uint32_t CN64Disk::GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t b else { // D64 - uint16_t ROM_LBA_END = *(uint16_t*)(&GetDiskAddressSys()[0xE2]); - uint16_t RAM_LBA_START = *(uint16_t*)(&GetDiskAddressSys()[0xE0]); - uint16_t RAM_LBA_END = *(uint16_t*)(&GetDiskAddressSys()[0xE6]); + uint16_t ROM_LBA_END = *(uint16_t *)(&GetDiskAddressSys()[0xE2]); + uint16_t RAM_LBA_START = *(uint16_t *)(&GetDiskAddressSys()[0xE0]); + uint16_t RAM_LBA_END = *(uint16_t *)(&GetDiskAddressSys()[0xE6]); uint16_t LBA = PhysToLBA(head, track, block); if (LBA < DISKID_LBA) { @@ -720,7 +736,7 @@ void CN64Disk::DetectSystemArea() m_DiskRomAddress = SYSTEM_LBAS * 0x4D08; // Handle system data - const uint16_t sysblocks[4] = { 9, 8, 1, 0 }; + const uint16_t sysblocks[4] = {9, 8, 1, 0}; // Check if disk is development disk bool isDevDisk = false; @@ -790,12 +806,14 @@ bool CN64Disk::IsSysSectorGood(uint32_t block, uint32_t sectorsize) return false; // Always 0xFFFFFFFF - if (*(uint32_t*)&m_DiskImage[(block * 0x4D08) + 0x18] != 0xFFFFFFFF) + if (*(uint32_t *)&m_DiskImage[(block * 0x4D08) + 0x18] != 0xFFFFFFFF) return false; - uint8_t alt = 0xC; // Retail + uint8_t alt = 0xC; // Retail if ((block & 2) != 0) - alt = 0xA; // Development + { + alt = 0xA; // Development + } // Alternate tracks offsets (always the same) for (int i = 0; i < 16; i++) @@ -810,15 +828,15 @@ bool CN64Disk::IsSysSectorGood(uint32_t block, uint32_t sectorsize) Country CN64Disk::GetDiskCountryCode() { - switch (*(uint32_t*)&GetDiskAddressSys()[0]) + switch (*(uint32_t *)&GetDiskAddressSys()[0]) { - case DISK_COUNTRY_JPN: - return Country_Japan; - case DISK_COUNTRY_USA: - return Country_NorthAmerica; - case DISK_COUNTRY_DEV: - default: - return Country_Unknown; + case DISK_COUNTRY_JPN: + return Country_Japan; + case DISK_COUNTRY_USA: + return Country_NorthAmerica; + case DISK_COUNTRY_DEV: + default: + return Country_Unknown; } } @@ -834,13 +852,13 @@ void CN64Disk::InitSysDataD64() // Expand RAM area for file format consistency if (m_DiskType < 6) { - *(uint16_t*)&GetDiskAddressSys()[0xE2 ^ 2] = RAM_START_LBA[m_DiskType] - SYSTEM_LBAS; - *(uint16_t*)&GetDiskAddressSys()[0xE4 ^ 2] = MAX_LBA - SYSTEM_LBAS; + *(uint16_t *)&GetDiskAddressSys()[0xE2 ^ 2] = RAM_START_LBA[m_DiskType] - SYSTEM_LBAS; + *(uint16_t *)&GetDiskAddressSys()[0xE4 ^ 2] = MAX_LBA - SYSTEM_LBAS; } else { - *(uint16_t*)&GetDiskAddressSys()[0xE2 ^ 2] = 0xFFFF; - *(uint16_t*)&GetDiskAddressSys()[0xE4 ^ 2] = 0xFFFF; + *(uint16_t *)&GetDiskAddressSys()[0xE2 ^ 2] = 0xFFFF; + *(uint16_t *)&GetDiskAddressSys()[0xE4 ^ 2] = 0xFFFF; } } @@ -850,8 +868,8 @@ void CN64Disk::DeinitSysDataD64() if (m_DiskFormat != DiskFormatD64) return; - GetDiskAddressSys()[4^3] = 0x00; - GetDiskAddressSys()[5^3] &= 0x0F; + GetDiskAddressSys()[4 ^ 3] = 0x00; + GetDiskAddressSys()[5 ^ 3] &= 0x0F; } void CN64Disk::GenerateLBAToPhysTable() @@ -875,14 +893,16 @@ void CN64Disk::DetectRamAddress() } else //if (m_DiskFormat == DiskFormatD64) { - m_DiskRamAddress = m_DiskRomAddress + LBAToByte(SYSTEM_LBAS, *(uint16_t*)(&GetDiskAddressSys()[0xE0 ^ 2]) + 1); + m_DiskRamAddress = m_DiskRomAddress + LBAToByte(SYSTEM_LBAS, *(uint16_t *)(&GetDiskAddressSys()[0xE0 ^ 2]) + 1); } } uint32_t CN64Disk::LBAToVZone(uint32_t lba) { - for (uint32_t vzone = 0; vzone < 16; vzone++) { - if (lba < VZONE_LBA_TBL[m_DiskType][vzone]) { + for (uint32_t vzone = 0; vzone < 16; vzone++) + { + if (lba < VZONE_LBA_TBL[m_DiskType][vzone]) + { return vzone; } } diff --git a/Source/Project64-core/N64System/N64Disk.h b/Source/Project64-core/N64System/N64Disk.h index 441f4194a..cb7a6cc07 100644 --- a/Source/Project64-core/N64System/N64Disk.h +++ b/Source/Project64-core/N64System/N64Disk.h @@ -9,55 +9,104 @@ public: CN64Disk(); ~CN64Disk(); - bool LoadDiskImage(const char * FileLoc); - bool SaveDiskImage(); - void SwapDiskImage(const char * FileLoc); + bool LoadDiskImage(const char * FileLoc); + bool SaveDiskImage(); + void SwapDiskImage(const char * FileLoc); static bool IsValidDiskImage(uint8_t Test[0x20]); - void SaveDiskSettingID(bool temp); - void ClearDiskSettingID(); - uint8_t * GetDiskAddress() { return m_DiskImage; } - uint8_t * GetDiskAddressBuffer() { return m_DiskImage + m_DiskBufAddress; } - uint8_t * GetDiskAddressSys() { return m_DiskImage + m_DiskSysAddress; } - uint8_t * GetDiskAddressID() { return m_DiskImage + m_DiskIDAddress; } - uint8_t * GetDiskAddressRom() { return m_DiskImage + m_DiskRomAddress; } - uint8_t * GetDiskAddressRam() { return m_DiskImage + m_DiskRamAddress; } - uint32_t GetDiskSize() const { return m_DiskFileSize; } - uint8_t * GetDiskHeader() { return m_DiskHeader; } - void SetDiskAddressBuffer(uint32_t address) { m_DiskBufAddress = address; } - uint32_t GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block, uint16_t sector, uint16_t sectorsize); - uint32_t CalculateCrc(); - stdstr GetRomName() const { return m_RomName; } - stdstr GetFileName() const { return m_FileName; } - stdstr GetDiskIdent() const { return m_DiskIdent; } - Country GetCountry() const { return m_Country; } - void UnallocateDiskImage(); + void SaveDiskSettingID(bool temp); + void ClearDiskSettingID(); + uint8_t * GetDiskAddress() + { + return m_DiskImage; + } + uint8_t * GetDiskAddressBuffer() + { + return m_DiskImage + m_DiskBufAddress; + } + uint8_t * GetDiskAddressSys() + { + return m_DiskImage + m_DiskSysAddress; + } + uint8_t * GetDiskAddressID() + { + return m_DiskImage + m_DiskIDAddress; + } + uint8_t * GetDiskAddressRom() + { + return m_DiskImage + m_DiskRomAddress; + } + uint8_t * GetDiskAddressRam() + { + return m_DiskImage + m_DiskRamAddress; + } + uint32_t GetDiskSize() const + { + return m_DiskFileSize; + } + uint8_t * GetDiskHeader() + { + return m_DiskHeader; + } + void SetDiskAddressBuffer(uint32_t address) + { + m_DiskBufAddress = address; + } + uint32_t GetDiskAddressBlock(uint16_t head, uint16_t track, uint16_t block, uint16_t sector, uint16_t sectorsize); + uint32_t CalculateCrc(); + stdstr GetRomName() const + { + return m_RomName; + } + stdstr GetFileName() const + { + return m_FileName; + } + stdstr GetDiskIdent() const + { + return m_DiskIdent; + } + Country GetCountry() const + { + return m_Country; + } + void UnallocateDiskImage(); - LanguageStringID GetError() const { return m_ErrorMsg; } + LanguageStringID GetError() const + { + return m_ErrorMsg; + } private: - bool AllocateDiskImage(uint32_t DiskFileSize); - bool AllocateDiskHeader(); - bool AllocateAndLoadDiskImage(const char * FileLoc); - bool LoadDiskRAMImage(); - void ByteSwapDisk(); - void ForceByteSwapDisk(); - void SetError(LanguageStringID ErrorMsg); + bool AllocateDiskImage(uint32_t DiskFileSize); + bool AllocateDiskHeader(); + bool AllocateAndLoadDiskImage(const char * FileLoc); + bool LoadDiskRAMImage(); + void ByteSwapDisk(); + void ForceByteSwapDisk(); + void SetError(LanguageStringID ErrorMsg); - void DetectSystemArea(); - bool IsSysSectorGood(uint32_t block, uint32_t sectorsize); + void DetectSystemArea(); + bool IsSysSectorGood(uint32_t block, uint32_t sectorsize); Country GetDiskCountryCode(); - void InitSysDataD64(); - void DeinitSysDataD64(); - void GenerateLBAToPhysTable(); - void DetectRamAddress(); + void InitSysDataD64(); + void DeinitSysDataD64(); + void GenerateLBAToPhysTable(); + void DetectRamAddress(); uint32_t LBAToVZone(uint32_t lba); uint32_t LBAToByte(uint32_t lba, uint32_t nlbas); uint16_t LBAToPhys(uint32_t lba); uint16_t PhysToLBA(uint16_t head, uint16_t track, uint16_t block); // Constant values - enum { ReadFromRomSection = 0x400000, MameFormatSize = 0x0435B0C0, SDKFormatSize = 0x03DEC800, - DiskFormatMAME = 0x0, DiskFormatSDK = 0x1, DiskFormatD64 = 0x2 }; + enum + { + ReadFromRomSection = 0x400000, + MameFormatSize = 0x0435B0C0, + SDKFormatSize = 0x03DEC800, + DiskFormatMAME = 0x0, + DiskFormatSDK = 0x1, + DiskFormatD64 = 0x2 + }; // Class variables CFile m_DiskFile; @@ -78,24 +127,24 @@ private: uint8_t m_DiskType; bool m_isShadowDisk; - // Disk defines - #define MAX_LBA 0x10DB - #define SIZE_LBA MAX_LBA+1 - #define SYSTEM_LBAS 24 - #define DISKID_LBA 14 +// Disk defines +#define MAX_LBA 0x10DB +#define SIZE_LBA MAX_LBA + 1 +#define SYSTEM_LBAS 24 +#define DISKID_LBA 14 - #define DISK_COUNTRY_JPN 0xE848D316 - #define DISK_COUNTRY_USA 0x2263EE56 - #define DISK_COUNTRY_DEV 0x00000000 +#define DISK_COUNTRY_JPN 0xE848D316 +#define DISK_COUNTRY_USA 0x2263EE56 +#define DISK_COUNTRY_DEV 0x00000000 - #define SECTORS_PER_BLOCK 85 - #define BLOCKS_PER_TRACK 2 +#define SECTORS_PER_BLOCK 85 +#define BLOCKS_PER_TRACK 2 - const uint32_t SECTORSIZE[16] = { 232, 216, 208, 192, 176, 160, 144, 128, - 216, 208, 192, 176, 160, 144, 128, 112 }; - const uint32_t SECTORSIZE_P[9] = { 232, 216, 208, 192, 176, 160, 144, 128, 112 }; - const uint32_t ZoneTracks[16] = { 158, 158, 149, 149, 149, 149, 149, 114, - 158, 158, 149, 149, 149, 149, 149, 114 }; + const uint32_t SECTORSIZE[16] = {232, 216, 208, 192, 176, 160, 144, 128, + 216, 208, 192, 176, 160, 144, 128, 112}; + const uint32_t SECTORSIZE_P[9] = {232, 216, 208, 192, 176, 160, 144, 128, 112}; + const uint32_t ZoneTracks[16] = {158, 158, 149, 149, 149, 149, 149, 114, + 158, 158, 149, 149, 149, 149, 149, 114}; const uint16_t VZONE_LBA_TBL[7][16] = { {0x0124, 0x0248, 0x035A, 0x047E, 0x05A2, 0x06B4, 0x07C6, 0x08D8, 0x09EA, 0x0AB6, 0x0B82, 0x0C94, 0x0DA6, 0x0EB8, 0x0FCA, 0x10DC}, @@ -104,7 +153,7 @@ private: {0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AEA, 0x0C0E, 0x0D20, 0x0DEC, 0x0EB8, 0x0FCA, 0x10DC}, {0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x08B4, 0x09C6, 0x0AD8, 0x0BEA, 0x0D0E, 0x0E32, 0x0EFE, 0x0FCA, 0x10DC}, {0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x0980, 0x0A92, 0x0BA4, 0x0CB6, 0x0DC8, 0x0EEC, 0x1010, 0x10DC}, - {0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94, 0x0FB8, 0x10DC} + {0x0124, 0x0248, 0x035A, 0x046C, 0x057E, 0x0690, 0x07A2, 0x086E, 0x093A, 0x0A4C, 0x0B5E, 0x0C70, 0x0D82, 0x0E94, 0x0FB8, 0x10DC}, }; const uint8_t VZONE_PZONE_TBL[7][16] = { @@ -114,31 +163,31 @@ private: {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0xC, 0xB, 0xA, 0x9, 0x8, 0x6, 0x7, 0xF, 0xE, 0xD}, {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0x7, 0xF, 0xE}, {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8, 0xF}, - {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8} + {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8}, }; const uint16_t SCYL_ZONE_TBL[2][8] = { {0x000, 0x09E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425}, - {0x091, 0x12F, 0x1C4, 0x259, 0x2EE, 0x383, 0x418, 0x48A} + {0x091, 0x12F, 0x1C4, 0x259, 0x2EE, 0x383, 0x418, 0x48A}, }; - const uint16_t OUTERCYL_TBL[8] = { 0x000, 0x09E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425 }; + const uint16_t OUTERCYL_TBL[8] = {0x000, 0x09E, 0x13C, 0x1D1, 0x266, 0x2FB, 0x390, 0x425}; - const uint16_t RAM_START_LBA[7] = { 0x5A2, 0x7C6, 0x9EA, 0xC0E, 0xE32, 0x1010, 0x10DC }; + const uint16_t RAM_START_LBA[7] = {0x5A2, 0x7C6, 0x9EA, 0xC0E, 0xE32, 0x1010, 0x10DC}; - const uint32_t RAM_SIZES[7] = { 0x24A9DC0, 0x1C226C0, 0x1450F00, 0xD35680, 0x6CFD40, 0x1DA240, 0x0 }; + const uint32_t RAM_SIZES[7] = {0x24A9DC0, 0x1C226C0, 0x1450F00, 0xD35680, 0x6CFD40, 0x1DA240, 0x0}; - #define BLOCKSIZE(_zone) SECTORSIZE[_zone] * SECTORS_PER_BLOCK - #define TRACKSIZE(_zone) BLOCKSIZE(_zone) * BLOCKS_PER_TRACK - #define ZONESIZE(_zone) TRACKSIZE(_zone) * ZoneTracks[_zone] - #define VZONESIZE(_zone) TRACKSIZE(_zone) * (ZoneTracks[_zone] - 0xC) - - #define VZoneToPZone(x, y) VZONE_PZONE_TBL[y][x] +#define BLOCKSIZE(_zone) SECTORSIZE[_zone] * SECTORS_PER_BLOCK +#define TRACKSIZE(_zone) BLOCKSIZE(_zone) * BLOCKS_PER_TRACK +#define ZONESIZE(_zone) TRACKSIZE(_zone) * ZoneTracks[_zone] +#define VZONESIZE(_zone) TRACKSIZE(_zone) * (ZoneTracks[_zone] - 0xC) + +#define VZoneToPZone(x, y) VZONE_PZONE_TBL[y][x] // Used for MAME format const uint32_t MAMEStartOffset[16] = - { 0x0, 0x5F15E0, 0xB79D00, 0x10801A0, 0x1523720, 0x1963D80, 0x1D414C0, 0x20BBCE0, - 0x23196E0, 0x28A1E00, 0x2DF5DC0, 0x3299340, 0x36D99A0, 0x3AB70E0, 0x3E31900, 0x4149200 }; + {0x0, 0x5F15E0, 0xB79D00, 0x10801A0, 0x1523720, 0x1963D80, 0x1D414C0, 0x20BBCE0, + 0x23196E0, 0x28A1E00, 0x2DF5DC0, 0x3299340, 0x36D99A0, 0x3AB70E0, 0x3E31900, 0x4149200}; // Used for SDK and D64 format uint16_t LBAToPhysTable[SIZE_LBA]; diff --git a/Source/Project64-core/N64System/N64Rom.cpp b/Source/Project64-core/N64System/N64Rom.cpp index 65ad4c4f9..1a2becae8 100644 --- a/Source/Project64-core/N64System/N64Rom.cpp +++ b/Source/Project64-core/N64System/N64Rom.cpp @@ -1,11 +1,12 @@ #include "stdafx.h" + #include "N64Rom.h" #include "SystemGlobals.h" -#include -#include -#include -#include #include +#include +#include +#include +#include #include #ifdef _WIN32 @@ -95,7 +96,10 @@ bool CN64Rom::AllocateAndLoadN64Image(const char * FileLoc, bool LoadBootCodeOnl for (count = 0; count < (int)RomFileSize; count += ReadFromRomSection) { uint32_t dwToRead = RomFileSize - count; - if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; } + if (dwToRead > ReadFromRomSection) + { + dwToRead = ReadFromRomSection; + } if (m_RomFile.Read(&m_ROMImage[count], dwToRead) != dwToRead) { @@ -181,7 +185,10 @@ bool CN64Rom::AllocateAndLoadZipImage(const char * FileLoc, bool LoadBootCodeOnl for (count = 4; count < (int)RomFileSize; count += ReadFromRomSection) { uint32_t dwToRead = RomFileSize - count; - if (dwToRead > ReadFromRomSection) { dwToRead = ReadFromRomSection; } + if (dwToRead > ReadFromRomSection) + { + dwToRead = ReadFromRomSection; + } dwRead = unzReadCurrentFile(file, &m_ROMImage[count], dwToRead); if (dwRead == 0) @@ -267,10 +274,13 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC) for (count = 0x40; count < 0x1000; count += 4) { - if (count == 0xC00) crcAleck64 = crc; //From 0x40 to 0xC00 (Aleck64) + if (count == 0xC00) crcAleck64 = crc; //From 0x40 to 0xC00 (Aleck64) crc += *(uint32_t *)(RomData + count); } - if (CRC != nullptr) { *CRC = crc; } + if (CRC != nullptr) + { + *CRC = crc; + } switch (crc) { @@ -289,7 +299,10 @@ CICChip CN64Rom::GetCicChipID(uint8_t * RomData, uint64_t * CRC) //Aleck64 CIC if (crcAleck64 == 0x000000A5F80BF620) { - if (CRC != nullptr) { *CRC = crcAleck64; } + if (CRC != nullptr) + { + *CRC = crcAleck64; + } return CIC_NUS_5101; } return CIC_UNKNOWN; @@ -343,9 +356,18 @@ void CN64Rom::CalculateRomCrc() case CIC_NUS_6103: v0 = 0xA3886759; break; case CIC_NUS_6105: v0 = 0xDF26F436; break; case CIC_NUS_6106: v0 = 0x1FEA617A; break; - case CIC_NUS_DDUS: length = 0x000A0000; v0 = 0x861AE3A7; break; - case CIC_NUS_8303: length = 0x000A0000; v0 = 0x8331D4CA; break; - case CIC_NUS_8401: length = 0x000A0000; v0 = 0x0D8303E2; break; + case CIC_NUS_DDUS: + length = 0x000A0000; + v0 = 0x861AE3A7; + break; + case CIC_NUS_8303: + length = 0x000A0000; + v0 = 0x8331D4CA; + break; + case CIC_NUS_8401: + length = 0x000A0000; + v0 = 0x0D8303E2; + break; case CIC_NUS_5101: v0 = 0x95104FDD; break; default: return; @@ -353,7 +375,7 @@ void CN64Rom::CalculateRomCrc() ProtectMemory(m_ROMImage, m_RomFileSize, MEM_READWRITE); - if (m_CicChip == CIC_NUS_5101 && (*(uint32_t*)(m_ROMImage + 0x8) == 0x80100400)) + if (m_CicChip == CIC_NUS_5101 && (*(uint32_t *)(m_ROMImage + 0x8) == 0x80100400)) length = 0x003FE000; v1 = 0; @@ -374,7 +396,8 @@ void CN64Rom::CalculateRomCrc() v1 = a3 + v0; a1 = v1; - if (v1 < a3) { + if (v1 < a3) + { if (m_CicChip == CIC_NUS_DDUS || m_CicChip == CIC_NUS_8303) { t2 = t2 ^ t3; @@ -408,7 +431,8 @@ void CN64Rom::CalculateRomCrc() { t4 = (v0 ^ (*(uint32_t *)(m_ROMImage + (0xFF & t0) + 0x750))) + t4; } - else t4 = (v0 ^ s0) + t4; + else + t4 = (v0 ^ s0) + t4; } if (m_CicChip == CIC_NUS_6103) { @@ -444,10 +468,22 @@ CICChip CN64Rom::CicChipID() bool CN64Rom::IsValidRomImage(uint8_t Test[4]) { - if (*((uint32_t *)&Test[0]) == 0x40123780) { return true; } - if (*((uint32_t *)&Test[0]) == 0x12408037) { return true; } - if (*((uint32_t *)&Test[0]) == 0x80371240) { return true; } - if (*((uint32_t *)&Test[0]) == 0x40072780) { return true; } // 64DD IPL + if (*((uint32_t *)&Test[0]) == 0x40123780) + { + return true; + } + if (*((uint32_t *)&Test[0]) == 0x12408037) + { + return true; + } + if (*((uint32_t *)&Test[0]) == 0x80371240) + { + return true; + } + if (*((uint32_t *)&Test[0]) == 0x40072780) + { + return true; + } // 64DD IPL return false; } @@ -501,7 +537,8 @@ void CN64Rom::CleanRomName(char * RomName, bool byteswap) { switch (RomName[count]) { - case '/': case '\\': RomName[count] = '-'; break; + case '/': + case '\\': RomName[count] = '-'; break; case ':': RomName[count] = ';'; break; } } @@ -528,16 +565,16 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) stdstr FullPath = FileLoc; // This should be a 7-zip file - char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); + char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); if (SubFile != nullptr) { *SubFile = '\0'; SubFile += 1; } - //else load first found file until dialog is implemented + //else load first found file until dialog is implemented //{ - // Pop up a dialog and select file - // Allocate memory for sub name and copy selected file name to variable + // Pop up a dialog and select file + // Allocate memory for sub name and copy selected file name to variable //} C7zip ZipFile(FullPath.c_str()); @@ -563,7 +600,10 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) // Get the size of the ROM and try to allocate the memory needed uint32_t RomFileSize = (uint32_t)f->Size; // If loading boot code then just load the first 0x1000 bytes - if (LoadBootCodeOnly) { RomFileSize = 0x1000; } + if (LoadBootCodeOnly) + { + RomFileSize = 0x1000; + } if (!AllocateRomImage(RomFileSize)) { @@ -582,11 +622,11 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) if (!IsValidRomImage(m_ROMImage)) { - if (i < ZipFile.NumFiles() - 1) - { + if (i < ZipFile.NumFiles() - 1) + { UnallocateRomImage(); continue; - } + } SetError(MSG_FAIL_IMAGE); WriteTrace(TraceN64System, TraceDebug, "Done (res: false)"); return false; @@ -674,7 +714,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) if (GameIdentifiers.find(m_RomIdent.c_str()) == GameIdentifiers.end()) { - char InternalName[22] = { 0 }; + char InternalName[22] = {0}; memcpy(InternalName, (void *)(m_ROMImage + 0x20), 20); CN64Rom::CleanRomName(InternalName); @@ -697,7 +737,7 @@ bool CN64Rom::LoadN64Image(const char * FileLoc, bool LoadBootCodeOnly) } else if (!IsLoadedRomDDIPL()) { - g_Settings->SaveString(Game_GameName, m_RomName.c_str()); // Use base games save file if loaded in combo + g_Settings->SaveString(Game_GameName, m_RomName.c_str()); // Use base games save file if loaded in combo } } @@ -724,7 +764,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) stdstr FullPath = FileLoc; // This should be a 7-zip file - char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); + char * SubFile = strstr(const_cast(FullPath.c_str()), "?"); if (SubFile != nullptr) { *SubFile = '\0'; @@ -732,8 +772,8 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) } //else load first found file until dialog is implemented //{ - // Pop up a dialog and select file - // Allocate memory for sub name and copy selected file name to variable + // Pop up a dialog and select file + // Allocate memory for sub name and copy selected file name to variable //} C7zip ZipFile(FullPath.c_str()); @@ -759,7 +799,10 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) // Get the size of the ROM and try to allocate the memory needed uint32_t RomFileSize = (uint32_t)f->Size; // If loading boot code then just load the first 0x1000 bytes - if (LoadBootCodeOnly) { RomFileSize = 0x1000; } + if (LoadBootCodeOnly) + { + RomFileSize = 0x1000; + } if (!AllocateRomImage(RomFileSize)) { @@ -827,7 +870,7 @@ bool CN64Rom::LoadN64ImageIPL(const char * FileLoc, bool LoadBootCodeOnly) if (strlen(RomName) == 0) { strcpy(RomName, CPath(FileLoc).GetName().c_str()); - CN64Rom::CleanRomName(RomName,false); + CN64Rom::CleanRomName(RomName, false); } WriteTrace(TraceN64System, TraceDebug, "RomName %s", RomName); diff --git a/Source/Project64-core/N64System/N64Rom.h b/Source/Project64-core/N64System/N64Rom.h index 4d5e4dbef..922cceced 100644 --- a/Source/Project64-core/N64System/N64Rom.h +++ b/Source/Project64-core/N64System/N64Rom.h @@ -1,8 +1,8 @@ #pragma once +#include #include #include -#include class CN64Rom : protected CDebugSettings @@ -18,17 +18,38 @@ public: void SaveRomSettingID(bool temp); void ClearRomSettingID(); CICChip CicChipID(); - uint8_t * GetRomAddress() const { return m_ROMImage; } - uint32_t GetRomSize() const { return m_RomFileSize; } - const std::string & GetRomMD5() const { return m_MD5; } - const std::string & GetRomName() const { return m_RomName; } - const std::string & GetFileName() const { return m_FileName; } - Country GetCountry() const { return m_Country; } + uint8_t * GetRomAddress() const + { + return m_ROMImage; + } + uint32_t GetRomSize() const + { + return m_RomFileSize; + } + const std::string & GetRomMD5() const + { + return m_MD5; + } + const std::string & GetRomName() const + { + return m_RomName; + } + const std::string & GetFileName() const + { + return m_FileName; + } + Country GetCountry() const + { + return m_Country; + } bool IsPal(); void UnallocateRomImage(); // Get a message ID for the reason that you failed to load the ROM - LanguageStringID GetError() const { return m_ErrorMsg; } + LanguageStringID GetError() const + { + return m_ErrorMsg; + } static CICChip GetCicChipID(uint8_t * RomData, uint64_t * CRC = nullptr); static void CleanRomName(char * RomName, bool byteswap = true); @@ -44,7 +65,10 @@ private: static void NotificationCB(const char * Status, CN64Rom * _this); // Constant values - enum { ReadFromRomSection = 0x400000 }; + enum + { + ReadFromRomSection = 0x400000 + }; // Class variables CFile m_RomFile; diff --git a/Source/Project64-core/N64System/N64System.cpp b/Source/Project64-core/N64System/N64System.cpp index 834999b94..c3ba6536a 100644 --- a/Source/Project64-core/N64System/N64System.cpp +++ b/Source/Project64-core/N64System/N64System.cpp @@ -1,26 +1,27 @@ #include "stdafx.h" + #include "N64System.h" +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #if defined(ANDROID) #include #endif -#pragma warning(disable:4355) // Disable 'this' : used in base member initializer list +#pragma warning(disable : 4355) // Disable 'this' : used in base member initializer list CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesReadOnly, bool SyncSystem) : CSystemEvents(this, Plugins), @@ -650,27 +651,27 @@ bool CN64System::SelectAndLoadFileImageIPL(Country country, bool combo) LanguageStringID IPLROMError; switch (country) { - case Country_Japan: - IPLROMPathSetting = File_DiskIPLPath; - IPLROMError = MSG_IPL_REQUIRED; - break; - case Country_NorthAmerica: - IPLROMPathSetting = File_DiskIPLUSAPath; - IPLROMError = MSG_USA_IPL_REQUIRED; - break; - case Country_Unknown: - default: - IPLROMPathSetting = File_DiskIPLTOOLPath; - IPLROMError = MSG_TOOL_IPL_REQUIRED; - if (combo && !CPath(g_Settings->LoadStringVal(File_DiskIPLTOOLPath).c_str()).Exists()) - { - // Development IPL is not needed for combo ROM + disk loading - if (CPath(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()).Exists()) - IPLROMPathSetting = File_DiskIPLPath; - else if (CPath(g_Settings->LoadStringVal(File_DiskIPLUSAPath).c_str()).Exists()) - IPLROMPathSetting = File_DiskIPLUSAPath; - } - break; + case Country_Japan: + IPLROMPathSetting = File_DiskIPLPath; + IPLROMError = MSG_IPL_REQUIRED; + break; + case Country_NorthAmerica: + IPLROMPathSetting = File_DiskIPLUSAPath; + IPLROMError = MSG_USA_IPL_REQUIRED; + break; + case Country_Unknown: + default: + IPLROMPathSetting = File_DiskIPLTOOLPath; + IPLROMError = MSG_TOOL_IPL_REQUIRED; + if (combo && !CPath(g_Settings->LoadStringVal(File_DiskIPLTOOLPath).c_str()).Exists()) + { + // Development IPL is not needed for combo ROM + disk loading + if (CPath(g_Settings->LoadStringVal(File_DiskIPLPath).c_str()).Exists()) + IPLROMPathSetting = File_DiskIPLPath; + else if (CPath(g_Settings->LoadStringVal(File_DiskIPLUSAPath).c_str()).Exists()) + IPLROMPathSetting = File_DiskIPLUSAPath; + } + break; } if (!CPath(g_Settings->LoadStringVal(IPLROMPathSetting).c_str()).Exists()) @@ -822,7 +823,8 @@ void CN64System::EndEmulation(void) void CN64System::Pause() { - if (m_Plugins && m_Plugins->Control()->EmulationPaused) { + if (m_Plugins && m_Plugins->Control()->EmulationPaused) + { m_Plugins->Control()->EmulationPaused(); } if (m_EndEmulation) @@ -838,7 +840,7 @@ void CN64System::Pause() } m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT); m_hPauseEvent.Reset(); - g_Settings->SaveBool(GameRunning_CPU_Paused, (uint32_t)false); + g_Settings->SaveBool(GameRunning_CPU_Paused, (uint32_t) false); if (pause_type == PauseType_FromMenu) { g_Notify->DisplayMessage(2, MSG_CPU_RESUMED); @@ -1145,15 +1147,15 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) case CIC_NUS_6101: m_Reg.m_GPR[22].DW = 0x000000000000003F; break; - case CIC_NUS_8303: // 64DD IPL CIC - case CIC_NUS_8401: // 64DD IPL tool CIC - case CIC_NUS_5167: // 64DD conversion CIC + case CIC_NUS_8303: // 64DD IPL CIC + case CIC_NUS_8401: // 64DD IPL tool CIC + case CIC_NUS_5167: // 64DD conversion CIC m_Reg.m_GPR[22].DW = 0x00000000000000DD; break; - case CIC_NUS_DDUS: // 64DD US IPL CIC + case CIC_NUS_DDUS: // 64DD US IPL CIC m_Reg.m_GPR[22].DW = 0x00000000000000DE; break; - case CIC_NUS_5101: // Aleck64 CIC + case CIC_NUS_5101: // Aleck64 CIC m_Reg.m_GPR[22].DW = 0x00000000000000AC; break; case CIC_UNKNOWN: @@ -1266,8 +1268,8 @@ void CN64System::ExecuteCPU() switch (cpuType) { case CPU_Recompiler: ExecuteRecompiler(); break; - case CPU_SyncCores: ExecuteSyncCPU(); break; - default: ExecuteInterpret(); break; + case CPU_SyncCores: ExecuteSyncCPU(); break; + default: ExecuteInterpret(); break; } WriteTrace(TraceN64System, TraceDebug, "CPU finished executing"); CpuStopped(); @@ -1307,7 +1309,7 @@ void CN64System::CpuStopped() WriteTrace(TraceN64System, TraceDebug, "Start"); if (!m_InReset) { - g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t)false); + g_Settings->SaveBool(GameRunning_CPU_Running, (uint32_t) false); g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); } if (m_SyncCPU) @@ -1323,10 +1325,16 @@ void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, uint32_t const Cycl // Update the number of cycles to skip m_CyclesToSkip -= Cycles; - if (m_CyclesToSkip < 0) { m_CyclesToSkip = 0; } + if (m_CyclesToSkip < 0) + { + m_CyclesToSkip = 0; + } // Run the other CPU For the same amount of cycles - if (CyclesToExecute < 0) { return; } + if (CyclesToExecute < 0) + { + return; + } SecondCPU->SetActiveSystem(true); CInterpreterCPU::ExecuteOps(Cycles); @@ -1343,11 +1351,23 @@ void CN64System::SyncCPUPC(CN64System * const SecondCPU) ErrorFound = true; } - if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } - if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } - if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } + if (m_TLB != SecondCPU->m_TLB) + { + ErrorFound = true; + } + if (m_SystemTimer != SecondCPU->m_SystemTimer) + { + ErrorFound = true; + } + if (m_NextTimer != SecondCPU->m_NextTimer) + { + ErrorFound = true; + } - if (ErrorFound) { DumpSyncErrors(SecondCPU); } + if (ErrorFound) + { + DumpSyncErrors(SecondCPU); + } for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) { @@ -1364,7 +1384,8 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) g_SystemTimer->UpdateTimers(); #ifdef TEST_SP_TRACKING - if (m_CurrentSP != GPR[29].UW[0]) { + if (m_CurrentSP != GPR[29].UW[0]) + { ErrorFound = true; } #endif @@ -1409,15 +1430,30 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) } } - if (m_Random.get_state() != SecondCPU->m_Random.get_state()) + if (m_Random.get_state() != SecondCPU->m_Random.get_state()) { - ErrorFound = true; + ErrorFound = true; + } + if (m_TLB != SecondCPU->m_TLB) + { + ErrorFound = true; + } + if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) + { + ErrorFound = true; + } + if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) + { + ErrorFound = true; + } + if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) + { + ErrorFound = true; + } + if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) + { + ErrorFound = true; } - if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } - if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; } - if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; } - if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { ErrorFound = true; } - if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { ErrorFound = true; } /*if (m_SyncCount > 4788000) { if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0) @@ -1446,7 +1482,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) if (bFastSP() && m_Recomp) { #if defined(__aarch64__) || defined(__amd64__) || defined(_M_X64) - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); #else if (m_Recomp->MemoryStackPos() != (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) { @@ -1455,9 +1491,18 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) #endif } - if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } - if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } - if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; } + if (m_SystemTimer != SecondCPU->m_SystemTimer) + { + ErrorFound = true; + } + if (m_NextTimer != SecondCPU->m_NextTimer) + { + ErrorFound = true; + } + if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) + { + ErrorFound = true; + } for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) { @@ -1483,7 +1528,10 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) } } - if (ErrorFound) { DumpSyncErrors(SecondCPU); } + if (ErrorFound) + { + DumpSyncErrors(SecondCPU); + } for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) { @@ -1530,8 +1578,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) if (m_Reg.m_GPR[count].UW[0] != SecondCPU->m_Reg.m_GPR[count].UW[0]) { Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], - m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); } } } @@ -1542,8 +1590,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) { Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], - m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); } } } @@ -1552,8 +1600,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) { Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], - m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], - SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); + m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], + SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); } } for (count = 0; count < 32; count++) @@ -1561,7 +1609,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) if (m_Reg.m_FPCR[count] != SecondCPU->m_Reg.m_FPCR[count]) { Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count], - m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); + m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); } } for (count = 0; count < 32; count++) @@ -1569,7 +1617,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) { Error.LogF("CP0[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::Cop0[count], - (uint32_t)(m_Reg.m_CP0[count] >> 32), (uint32_t)m_Reg.m_CP0[count], (uint32_t)(SecondCPU->m_Reg.m_CP0[count] >> 32), (uint32_t)(SecondCPU->m_Reg.m_CP0[count])); + (uint32_t)(m_Reg.m_CP0[count] >> 32), (uint32_t)m_Reg.m_CP0[count], (uint32_t)(SecondCPU->m_Reg.m_CP0[count] >> 32), (uint32_t)(SecondCPU->m_Reg.m_CP0[count])); } } if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) @@ -1616,7 +1664,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) if (bFastSP() && m_Recomp) { #if defined(__aarch64__) || defined(__amd64__) || defined(_M_X64) - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); #else if (m_Recomp->MemoryStackPos() != (uint32_t)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) { @@ -1625,7 +1673,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) #endif } - uint32_t * Rdram = (uint32_t *)m_MMU_VM.Rdram(), *Rdram2 = (uint32_t *)SecondCPU->m_MMU_VM.Rdram(); + uint32_t *Rdram = (uint32_t *)m_MMU_VM.Rdram(), *Rdram2 = (uint32_t *)SecondCPU->m_MMU_VM.Rdram(); for (int z = 0, n = (RdramSize() >> 2); z < n; z++) { if (Rdram[z] != Rdram2[z]) @@ -1634,7 +1682,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) } } - uint32_t * Imem = (uint32_t *)m_MMU_VM.Imem(), *Imem2 = (uint32_t *)SecondCPU->m_MMU_VM.Imem(); + uint32_t *Imem = (uint32_t *)m_MMU_VM.Imem(), *Imem2 = (uint32_t *)SecondCPU->m_MMU_VM.Imem(); for (int z = 0; z < (0x1000 >> 2); z++) { if (Imem[z] != Imem2[z]) @@ -1642,7 +1690,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) Error.LogF("IMEM[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); } } - uint32_t * Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)SecondCPU->m_MMU_VM.Dmem(); + uint32_t *Dmem = (uint32_t *)m_MMU_VM.Dmem(), *Dmem2 = (uint32_t *)SecondCPU->m_MMU_VM.Dmem(); for (int z = 0; z < (0x1000 >> 2); z++) { if (Dmem[z] != Dmem2[z]) @@ -1665,27 +1713,27 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) for (count = 0; count < 32; count++) { Error.LogF("GPR[%s], 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], - m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); } Error.Log("\r\n"); for (count = 0; count < 32; count++) { Error.LogF("FPR[%s],%*s0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], - count < 10 ? 9 : 8, " ", m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], - SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); + count < 10 ? 9 : 8, " ", m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], + SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); } Error.Log("\r\n"); for (count = 0; count < 32; count++) { Error.LogF("FPR_S[%s],%*s%f, %f\r\n", CRegName::FPR[count], - count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(SecondCPU->m_Reg.m_FPR_S[count])); + count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(SecondCPU->m_Reg.m_FPR_S[count])); } Error.Log("\r\n"); for (count = 0; count < 32; count++) { Error.LogF("FPR_D[%s],%*s%f, %f\r\n", CRegName::FPR[count], - count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count])); + count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count])); } Error.Log("\r\n"); Error.LogF("Rounding model, 0x%08X, 0x%08X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); @@ -1693,30 +1741,33 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) for (count = 0; count < 32; count++) { Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n", CRegName::Cop0[count], - 12 - strlen(CRegName::Cop0[count]), "", - m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); + 12 - strlen(CRegName::Cop0[count]), "", + m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); } Error.Log("\r\n"); for (count = 0; count < 32; count++) { Error.LogF("FPR_Ctrl[%s],%*s0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count], - 12 - strlen(CRegName::FPR_Ctrl[count]), "", - m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); + 12 - strlen(CRegName::FPR_Ctrl[count]), "", + m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); } Error.Log("\r\n"); Error.LogF("HI 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], - SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); + SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], - SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); + SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n", CRegName::Cop0[count], - 12 - strlen(CRegName::Cop0[count]), "", - m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); + 12 - strlen(CRegName::Cop0[count]), "", + m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); bool bHasTlb = false; for (count = 0; count < 32; count++) { - if (!m_TLB.TlbEntry(count).EntryDefined) { continue; } + if (!m_TLB.TlbEntry(count).EntryDefined) + { + continue; + } if (!bHasTlb) { Error.Log("\r\n"); @@ -1724,9 +1775,8 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) bHasTlb = true; } Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count, - m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value, - SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value - ); + m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value, + SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value); } Error.Log("\r\n"); Error.Log("Code at PC:\r\n"); @@ -1845,7 +1895,7 @@ bool CN64System::SaveState() zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13); zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8); zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4); - zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + zipWriteInFileInZip(file, (void * const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40); zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize); zipWriteInFileInZip(file, m_MMU_VM.Dmem(), 0x1000); @@ -2073,7 +2123,7 @@ bool CN64System::LoadState(const char * FileName) { // Base ROM information (64DD IPL / compatible game ROM) and disk info check if ((memcmp(LoadHeader, &g_Rom->GetRomAddress()[0x10], 0x20) != 0 || - memcmp(&LoadHeader[0x20], g_Disk->GetDiskAddressID(), 0x20) != 0) && + memcmp(&LoadHeader[0x20], g_Disk->GetDiskAddressID(), 0x20) != 0) && !g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SAVE_STATE_HEADER).c_str())) { return false; @@ -2110,7 +2160,7 @@ bool CN64System::LoadState(const char * FileName) unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13); unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8); unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(uint32_t) * 4); - unzReadCurrentFile(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + unzReadCurrentFile(file, (void * const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40); unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize); unzReadCurrentFile(file, m_MMU_VM.Dmem(), 0x1000); @@ -2169,7 +2219,7 @@ bool CN64System::LoadState(const char * FileName) { // Base ROM information (64DD IPL / compatible game ROM) and disk info check if ((memcmp(LoadHeader, &g_Rom->GetRomAddress()[0x10], 0x20) != 0 || - memcmp(&LoadHeader[0x20], g_Disk->GetDiskAddressID(), 0x20) != 0) && + memcmp(&LoadHeader[0x20], g_Disk->GetDiskAddressID(), 0x20) != 0) && !g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SAVE_STATE_HEADER).c_str())) { return false; @@ -2205,7 +2255,7 @@ bool CN64System::LoadState(const char * FileName) hSaveFile.Read(m_Reg.m_Peripheral_Interface, sizeof(uint32_t) * 13); hSaveFile.Read(m_Reg.m_RDRAM_Interface, sizeof(uint32_t) * 8); hSaveFile.Read(m_Reg.m_SerialInterface, sizeof(uint32_t) * 4); - hSaveFile.Read((void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + hSaveFile.Read((void * const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); hSaveFile.Read(m_MMU_VM.PifRam(), 0x40); hSaveFile.Read(m_MMU_VM.Rdram(), SaveRDRAMSize); hSaveFile.Read(m_MMU_VM.Dmem(), 0x1000); @@ -2283,7 +2333,10 @@ bool CN64System::LoadState(const char * FileName) #ifdef TEST_SP_TRACKING m_CurrentSP = GPR[29].UW[0]; #endif - if (bFastSP() && m_Recomp) { m_Recomp->ResetMemoryStackPos(); } + if (bFastSP() && m_Recomp) + { + m_Recomp->ResetMemoryStackPos(); + } if (g_Settings->LoadDword(Game_CpuType) == CPU_SyncCores) { @@ -2307,7 +2360,7 @@ bool CN64System::LoadState(const char * FileName) } uint32_t CN64System::GetButtons(int32_t Control) const -{ +{ CControl_Plugin::fnGetKeys GetKeys = m_Plugins->Control()->GetKeys; if (!UpdateControllerOnRefresh() && GetKeys != nullptr) { @@ -2316,7 +2369,7 @@ uint32_t CN64System::GetButtons(int32_t Control) const GetKeys(Control, &Keys); return Keys.Value; } - return m_Buttons[Control]; + return m_Buttons[Control]; } void CN64System::DisplayRSPListCount() @@ -2447,10 +2500,13 @@ void CN64System::RunRSP() void CN64System::RefreshScreen() { - PROFILE_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/; + PROFILE_TIMERS CPU_UsageAddr = Timer_None /*, ProfilingAddr = Timer_None*/; uint32_t VI_INTR_TIME = 500000; - if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); } + if (bShowCPUPer()) + { + CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); + } // Calculate how many cycles to next refresh if (m_Reg.VI_V_SYNC_REG == 0) @@ -2482,16 +2538,19 @@ void CN64System::RefreshScreen() } } - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateScreen); } + if (bShowCPUPer()) + { + m_CPU_Usage.StartTimer(Timer_UpdateScreen); + } __except_try() { WriteTrace(TraceVideoPlugin, TraceDebug, "UpdateScreen starting"); m_Plugins->Gfx()->UpdateScreen(); - if (g_Debugger != nullptr && HaveDebugger()) - { - g_Debugger->FrameDrawn(); - } + if (g_Debugger != nullptr && HaveDebugger()) + { + g_Debugger->FrameDrawn(); + } WriteTrace(TraceVideoPlugin, TraceDebug, "UpdateScreen done"); } __except_catch() @@ -2502,18 +2561,27 @@ void CN64System::RefreshScreen() if ((bBasicMode() || bLimitFPS()) && (!bSyncToAudio() || !FullSpeed())) { - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_Idel); } + if (bShowCPUPer()) + { + m_CPU_Usage.StartTimer(Timer_Idel); + } uint32_t FrameRate; if (m_Limiter.Timer_Process(&FrameRate) && bDisplayFrameRate()) { m_FPS.DisplayViCounter(FrameRate, 0); m_bCleanFrameBox = true; } - if (bShowCPUPer()) { m_CPU_Usage.StopTimer(); } + if (bShowCPUPer()) + { + m_CPU_Usage.StopTimer(); + } } else if (bDisplayFrameRate()) { - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateFPS); } + if (bShowCPUPer()) + { + m_CPU_Usage.StartTimer(Timer_UpdateFPS); + } m_FPS.UpdateViCounter(); m_bCleanFrameBox = true; } diff --git a/Source/Project64-core/N64System/N64System.h b/Source/Project64-core/N64System/N64System.h index a29a5c53f..d81efd845 100644 --- a/Source/Project64-core/N64System/N64System.h +++ b/Source/Project64-core/N64System/N64System.h @@ -3,22 +3,22 @@ #include #include #include -#include -#include -#include +#include #include +#include #include #include -#include -#include +#include +#include #include -#include +#include +#include -#include "Mips/TLB.h" #include "FramePerSecond.h" +#include "Mips/TLB.h" #include "SpeedLimiter.h" -typedef std::list EVENT_LIST; +typedef std::list EVENT_LIST; typedef std::map FUNC_CALLS; @@ -44,12 +44,12 @@ class CN64System : protected CDebugSettings { public: - typedef void(*CallBackFunction)(void *); + typedef void (*CallBackFunction)(void *); CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesReadOnly, bool SyncSystem); virtual ~CN64System(void); - bool m_EndEmulation; + bool m_EndEmulation; SAVE_CHIP_TYPE m_SaveUsing; // Methods @@ -70,10 +70,22 @@ public: void ExternalEvent(SystemEvent action); // Covers GUI interactions and timers etc. void StartEmulation(bool NewThread); void EndEmulation(); - void AlterSpeed(const CSpeedLimiter::ESpeedChange SpeedChange) { m_Limiter.AlterSpeed(SpeedChange); } - void SetSpeed(int Speed) { m_Limiter.SetSpeed(Speed); } - int GetSpeed(void) const { return m_Limiter.GetSpeed(); } - int GetBaseSpeed(void) const { return m_Limiter.GetBaseSpeed(); } + void AlterSpeed(const CSpeedLimiter::ESpeedChange SpeedChange) + { + m_Limiter.AlterSpeed(SpeedChange); + } + void SetSpeed(int Speed) + { + m_Limiter.SetSpeed(Speed); + } + int GetSpeed(void) const + { + return m_Limiter.GetSpeed(); + } + int GetBaseSpeed(void) const + { + return m_Limiter.GetBaseSpeed(); + } void Reset(bool bInitReg, bool ClearMenory); void GameReset(); void PluginReset(); @@ -97,9 +109,18 @@ public: void SyncSystem(); void SyncSystemPC(); - CPlugins * GetPlugins() { return m_Plugins; } - PIPELINE_STAGE PipelineStage() const { return m_PipelineStage; } - uint32_t JumpToLocation() const { return m_JumpToLocation; } + CPlugins * GetPlugins() + { + return m_Plugins; + } + PIPELINE_STAGE PipelineStage() const + { + return m_PipelineStage; + } + uint32_t JumpToLocation() const + { + return m_JumpToLocation; + } private: struct SETTING_CHANGED_CB @@ -156,7 +177,7 @@ private: void TLB_Changed(); SETTING_CALLBACK m_Callback; - CPlugins * const m_Plugins; // The plugin container + CPlugins * const m_Plugins; // The plugin container CPlugins * m_SyncPlugins; CN64System * m_SyncCPU; CMipsMemoryVM m_MMU_VM; @@ -199,7 +220,7 @@ private: FUNC_CALLS m_FunctionCalls; // List of save state file IDs - const uint32_t SaveID_0 = 0x23D8A6C8; // Main save state info (*.pj) - const uint32_t SaveID_1 = 0x56D2CD23; // Extra data v1 (system timing) info (*.dat) - const uint32_t SaveID_2 = 0x750A6BEB; // Extra data v2 (timing + disk registers) (*.dat) + const uint32_t SaveID_0 = 0x23D8A6C8; // Main save state info (*.pj) + const uint32_t SaveID_1 = 0x56D2CD23; // Extra data v1 (system timing) info (*.dat) + const uint32_t SaveID_2 = 0x750A6BEB; // Extra data v2 (timing + disk registers) (*.dat) }; diff --git a/Source/Project64-core/N64System/N64Types.h b/Source/Project64-core/N64System/N64Types.h index ef3f6a4d9..5700c7a77 100644 --- a/Source/Project64-core/N64System/N64Types.h +++ b/Source/Project64-core/N64System/N64Types.h @@ -31,44 +31,70 @@ enum PauseType enum CPU_TYPE { - CPU_Default = -1, CPU_Interpreter = 1, CPU_Recompiler = 2, CPU_SyncCores = 3 + CPU_Default = -1, + CPU_Interpreter = 1, + CPU_Recompiler = 2, + CPU_SyncCores = 3 }; enum FRAMERATE_TYPE { - FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, FR_VIs_DLs = 3, + FR_VIs = 0, + FR_DLs = 1, + FR_PERCENT = 2, + FR_VIs_DLs = 3, }; enum SAVE_CHIP_TYPE { - SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam + SaveChip_Auto = -1, + SaveChip_Eeprom_4K, + SaveChip_Eeprom_16K, + SaveChip_Sram, + SaveChip_FlashRam }; enum SAVE_DISK_TYPE { - SaveDisk_ShadowFile = 0, SaveDisk_RAMFile = 1, + SaveDisk_ShadowFile = 0, + SaveDisk_RAMFile = 1, }; enum DISK_SEEK_TYPE { - DiskSeek_Turbo = 0, DiskSeek_Slow = 1, + DiskSeek_Turbo = 0, + DiskSeek_Slow = 1, }; enum FUNC_LOOKUP_METHOD { - FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3, + FuncFind_Default = -1, + FuncFind_PhysicalLookup = 1, + FuncFind_VirtualLookup = 2, + FuncFind_ChangeMemory = 3, }; enum SYSTEM_TYPE { - SYSTEM_NTSC = 0, SYSTEM_PAL = 1, SYSTEM_MPAL = 2 + SYSTEM_NTSC = 0, + SYSTEM_PAL = 1, + SYSTEM_MPAL = 2 }; enum CICChip { - CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3, - CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7, - CIC_NUS_8303 = 8, CIC_NUS_DDUS = 9, CIC_NUS_8401 = 10, CIC_NUS_5101 = 11, + CIC_UNKNOWN = -1, + CIC_NUS_6101 = 1, + CIC_NUS_6102 = 2, + CIC_NUS_6103 = 3, + CIC_NUS_6104 = 4, + CIC_NUS_6105 = 5, + CIC_NUS_6106 = 6, + CIC_NUS_5167 = 7, + CIC_NUS_8303 = 8, + CIC_NUS_DDUS = 9, + CIC_NUS_8401 = 10, + CIC_NUS_5101 = 11, CIC_MINI_IPL3 = 12, }; @@ -129,27 +155,27 @@ enum PIPELINE_STAGE union MIPS_WORD { - int32_t W; + int32_t W; uint32_t UW; - int16_t HW[2]; + int16_t HW[2]; uint16_t UHW[2]; - int8_t B[4]; - uint8_t UB[4]; + int8_t B[4]; + uint8_t UB[4]; - float F; + float F; }; union MIPS_DWORD { - int64_t DW; + int64_t DW; uint64_t UDW; - int32_t W[2]; + int32_t W[2]; uint32_t UW[2]; - int16_t HW[4]; + int16_t HW[4]; uint16_t UHW[4]; - int8_t B[8]; - uint8_t UB[8]; + int8_t B[8]; + uint8_t UB[8]; - double D; - float F[2]; + double D; + float F[2]; }; diff --git a/Source/Project64-core/N64System/Profiling.cpp b/Source/Project64-core/N64System/Profiling.cpp index 8a3f8370d..26bc023c7 100644 --- a/Source/Project64-core/N64System/Profiling.cpp +++ b/Source/Project64-core/N64System/Profiling.cpp @@ -1,14 +1,18 @@ #include "stdafx.h" + #include -#include #include +#include -enum { MAX_FRAMES = 13 }; +enum +{ + MAX_FRAMES = 13 +}; CProfiling::CProfiling() : -m_CurrentDisplayCount(MAX_FRAMES), -m_CurrentTimerType(Timer_None) + m_CurrentDisplayCount(MAX_FRAMES), + m_CurrentTimerType(Timer_None) { memset(m_Timers, 0, sizeof(m_Timers)); } @@ -42,7 +46,10 @@ PROFILE_TIMERS CProfiling::StartTimer(PROFILE_TIMERS TimerType) PROFILE_TIMERS CProfiling::StopTimer() { - if (m_CurrentTimerType == Timer_None) { return m_CurrentTimerType; } + if (m_CurrentTimerType == Timer_None) + { + return m_CurrentTimerType; + } HighResTimeStamp EndTime; EndTime.SetToNow(); uint64_t TimeTaken = EndTime.GetMicroSeconds() - m_StartTime.GetMicroSeconds(); @@ -71,7 +78,8 @@ void CProfiling::ShowCPU_Usage() m_CurrentDisplayCount = MAX_FRAMES; g_Notify->DisplayMessage(0, stdstr_f("r4300i: %d.%02d%% GFX: %d.%02d%% Alist: %d.%02d%% Idle: %d.%02d%%", - R4300 / 100, R4300 % 100, RSP_Dlist / 100, RSP_Dlist % 100, RSP_Alist / 100, RSP_Alist % 100, Idel / 100, Idel % 100).c_str()); + R4300 / 100, R4300 % 100, RSP_Dlist / 100, RSP_Dlist % 100, RSP_Alist / 100, RSP_Alist % 100, Idel / 100, Idel % 100) + .c_str()); ResetTimers(); if (PreviousType != Timer_None) diff --git a/Source/Project64-core/N64System/Profiling.h b/Source/Project64-core/N64System/Profiling.h index 6f8e0e693..3f1b51c43 100644 --- a/Source/Project64-core/N64System/Profiling.h +++ b/Source/Project64-core/N64System/Profiling.h @@ -1,6 +1,6 @@ #pragma once -#include #include +#include class CProfiling { @@ -20,8 +20,8 @@ public: void ResetTimers(void); private: - CProfiling(const CProfiling&); - CProfiling& operator=(const CProfiling&); + CProfiling(const CProfiling &); + CProfiling & operator=(const CProfiling &); uint32_t m_CurrentDisplayCount; PROFILE_TIMERS m_CurrentTimerType; diff --git a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.cpp index 9b1a8801f..595b63048 100644 --- a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.cpp @@ -249,7 +249,7 @@ void CAarch64RecompilerOps::SC() g_Notify->BreakPoint(__FILE__, __LINE__); } -void CAarch64RecompilerOps::SWC1() +void CAarch64RecompilerOps::SWC1() { g_Notify->BreakPoint(__FILE__, __LINE__); } diff --git a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.h index 40f015bc6..4ee36d8e3 100644 --- a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RecompilerOps.h @@ -1,11 +1,11 @@ #pragma once #if defined(__aarch64__) -#include -#include -#include -#include #include +#include +#include +#include +#include class CMipsMemoryVM; class CCodeBlock; @@ -13,7 +13,7 @@ class CCodeSection; class CAarch64Ops; struct CJumpInfo; -class CAarch64RecompilerOps +class CAarch64RecompilerOps { public: CAarch64RecompilerOps(CMipsMemoryVM & MMU, CCodeBlock & CodeBlock); @@ -213,18 +213,21 @@ public: const R4300iOpcode & GetOpcode(void) const; void PreCompileOpcode(void); void PostCompileOpcode(void); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason); void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false, bool UpdateTimer = true); void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet); void CompileExecuteBP(void); void CompileExecuteDelaySlotBP(void); - CAarch64Ops & Assembler() { return m_Assembler; } + CAarch64Ops & Assembler() + { + return m_Assembler; + } private: - CAarch64RecompilerOps(const CAarch64RecompilerOps&); - CAarch64RecompilerOps& operator=(const CAarch64RecompilerOps&); + CAarch64RecompilerOps(const CAarch64RecompilerOps &); + CAarch64RecompilerOps & operator=(const CAarch64RecompilerOps &); CAarch64RegInfo m_RegWorkingSet; CAarch64Ops m_Assembler; diff --git a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.cpp index f895724a1..f34129b1a 100644 --- a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.cpp @@ -7,7 +7,7 @@ CAarch64RegInfo::CAarch64RegInfo(CCodeBlock & /*CodeBlock*/, CAarch64Ops & /*Ass { } -CAarch64RegInfo::CAarch64RegInfo(const CAarch64RegInfo&) +CAarch64RegInfo::CAarch64RegInfo(const CAarch64RegInfo &) { g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -16,7 +16,7 @@ CAarch64RegInfo::~CAarch64RegInfo() { } -CAarch64RegInfo& CAarch64RegInfo::operator=(const CAarch64RegInfo & right) +CAarch64RegInfo & CAarch64RegInfo::operator=(const CAarch64RegInfo & right) { CRegBase::operator=(right); g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.h b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.h index 5c3a68fb0..f6a29a288 100644 --- a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64RegInfo.h @@ -10,13 +10,13 @@ class CAarch64RegInfo : { public: CAarch64RegInfo(CCodeBlock & CodeBlock, CAarch64Ops & Assembler); - CAarch64RegInfo(const CAarch64RegInfo&); + CAarch64RegInfo(const CAarch64RegInfo &); ~CAarch64RegInfo(); - CAarch64RegInfo& operator=(const CAarch64RegInfo&); + CAarch64RegInfo & operator=(const CAarch64RegInfo &); - bool operator==(const CAarch64RegInfo& right) const; - bool operator!=(const CAarch64RegInfo& right) const; + bool operator==(const CAarch64RegInfo & right) const; + bool operator!=(const CAarch64RegInfo & right) const; }; #endif diff --git a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64ops.h b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64ops.h index a145feedd..18557bb4e 100644 --- a/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64ops.h +++ b/Source/Project64-core/N64System/Recompiler/Aarch64/Aarch64ops.h @@ -10,8 +10,8 @@ public: private: CAarch64Ops(void); - CAarch64Ops(const CAarch64Ops&); - CAarch64Ops& operator=(const CAarch64Ops&); + CAarch64Ops(const CAarch64Ops &); + CAarch64Ops & operator=(const CAarch64Ops &); CCodeBlock & m_CodeBlock; }; diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp index 21befdeea..dcff4eef2 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.cpp @@ -1,12 +1,12 @@ #include "stdafx.h" #if defined(__arm__) || defined(_M_ARM) -#include #include -#include #include +#include #include #include +#include CArmOps::CArmOps(CCodeBlock & CodeBlock, CArmRegInfo & RegWorkingSet) : m_CodeBlock(CodeBlock), @@ -42,7 +42,7 @@ void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source if (DestReg <= 7 && SourceReg1 <= 7 && SourceReg2 <= 7) { CodeLog(" add\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg.rt = DestReg; op.Reg.rn = SourceReg1; op.Reg.rm = SourceReg2; @@ -52,7 +52,7 @@ void CArmOps::AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source else { CodeLog(" add.w\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = SourceReg1; op.imm5.s = 0; op.imm5.opcode = 0x758; @@ -82,7 +82,7 @@ void CArmOps::AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) { CodeLog(" and\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); uint16_t CompressedConst = ThumbCompressConst(Const); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = SourceReg; op.imm8_3_1.s = 0; op.imm8_3_1.opcode = 0; @@ -104,7 +104,7 @@ void CArmOps::AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) } } -void CArmOps::AndConstToVariable(void *Variable, const char * VariableName, uint32_t Const) +void CArmOps::AndConstToVariable(void * Variable, const char * VariableName, uint32_t Const) { PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); @@ -135,7 +135,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) else if ((Const & 0xFFFFFFF8) == 0 && DestReg <= 7 && SourceReg <= 7) { CodeLog(" adds\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm3.rd = DestReg; op.Imm3.rn = SourceReg; op.Imm3.imm3 = Const; @@ -145,7 +145,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) else if ((Const & 0xFFFFFF00) == 0 && DestReg <= 7 && DestReg == SourceReg) { CodeLog(" adds\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm8.imm8 = Const; op.Imm8.rdn = DestReg; op.Imm8.opcode = 0x6; @@ -154,7 +154,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) else if ((Const & 0xFFFFFF80) == 0xFFFFFF80 && DestReg <= 7 && DestReg == SourceReg) { CodeLog(" sub\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (~Const) + 1); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm8.imm8 = ((~Const) + 1) & 0xFF; op.Imm8.rdn = DestReg; op.Imm8.opcode = 0x7; @@ -164,7 +164,7 @@ void CArmOps::AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const) { CodeLog(" add.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), Const); uint16_t CompressedConst = ThumbCompressConst(Const); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = SourceReg; op.imm8_3_1.s = 0; op.imm8_3_1.opcode = 0x8; @@ -198,7 +198,7 @@ void CArmOps::AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source if (DestReg <= 0x7 && SourceReg2 <= 0x7 && SourceReg1 == DestReg) { CodeLog(" ands\t%s, %s", ArmRegName(DestReg), ArmRegName(SourceReg2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg2.rn = DestReg; op.Reg2.rm = SourceReg2; op.Reg2.opcode = 0x100; @@ -207,7 +207,7 @@ void CArmOps::AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source else { CodeLog(" and.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = SourceReg1; op.imm5.s = 0; op.imm5.opcode = 0x750; @@ -245,7 +245,7 @@ void CArmOps::BranchLabel8(ArmCompareType CompareType, const char * Label) PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); CodeLog(" b%s\t%s", ArmCompareSuffix(CompareType), Label); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; if (CompareType == ArmBranch_Always) { op.BranchImm.imm = 0; @@ -265,7 +265,7 @@ void CArmOps::BranchLabel20(ArmCompareType CompareType, const char * Label) PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); CodeLog(" b%s\t%s", ArmCompareSuffix(CompareType), Label); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.Branch20.imm6 = 0; op.Branch20.cond = CompareType == ArmBranch_Always ? 0 : CompareType; op.Branch20.S = 0; @@ -285,7 +285,7 @@ void CArmOps::CallFunction(void * Function, const char * FunctionName) ArmReg reg = Arm_R4; MoveConstToArmReg(reg, (uint32_t)Function, FunctionName); int32_t Offset = (int32_t)Function - (int32_t)*g_RecompPos; - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Branch.reserved = 0; op.Branch.rm = reg; op.Branch.opcode = 0x8F; @@ -323,7 +323,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment if ((value & 0xFF00) == 0 && Reg <= 7) { CodeLog(" mov%s\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "s", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm8.imm8 = value; op.Imm8.rdn = Reg; op.Imm8.opcode = 0x4; @@ -333,7 +333,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment { CodeLog(" mov%s.w\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); uint16_t CompressedValue = ThumbCompressConst(value); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = 0xF; op.imm8_3_1.s = 0; op.imm8_3_1.opcode = 0x2; @@ -350,7 +350,7 @@ void CArmOps::MoveConstToArmReg(ArmReg Reg, uint16_t value, const char * comment { CodeLog(" movw%s\t%s, #0x%X\t; %s", m_InItBlock ? ArmCurrentItCondition() : "", ArmRegName(Reg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm16.opcode = ArmMOV_IMM16; op.imm16.i = ((value >> 11) & 0x1); op.imm16.opcode2 = ArmMOVW_IMM16; @@ -374,7 +374,7 @@ void CArmOps::MoveConstToArmRegTop(ArmReg DestReg, uint16_t Const, const char * CodeLog(" movt\t%s, %s", ArmRegName(DestReg), comment != nullptr ? stdstr_f("#0x%X\t; %s", (uint32_t)Const, comment).c_str() : stdstr_f("#%d\t; 0x%X", (uint32_t)Const, (uint32_t)Const).c_str()); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm16.opcode = ArmMOV_IMM16; op.imm16.i = ((Const >> 11) & 0x1); op.imm16.opcode2 = ArmMOVT_IMM16; @@ -397,7 +397,7 @@ void CArmOps::CompareArmRegToConst(ArmReg Reg, uint32_t value) if (Reg <= 0x7 && (value & 0xFFFFFF00) == 0) { CodeLog(" cmp\t%s, #%d\t; 0x%X", ArmRegName(Reg), value, value); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm8.imm8 = value; op.Imm8.rdn = Reg; op.Imm8.opcode = 0x5; @@ -407,7 +407,7 @@ void CArmOps::CompareArmRegToConst(ArmReg Reg, uint32_t value) { CodeLog(" cmp\t%s, #%d\t; 0x%X", ArmRegName(Reg), value, value); uint16_t CompressedValue = ThumbCompressConst(value); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = Reg; op.imm8_3_1.s = 1; op.imm8_3_1.opcode = 0xD; @@ -436,7 +436,7 @@ void CArmOps::CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2) if (Reg1 <= 0x7 && Reg2 <= 0x7) { CodeLog(" cmp\t%s, %s", ArmRegName(Reg1), ArmRegName(Reg2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg2.rn = Reg1; op.Reg2.rm = Reg2; op.Reg2.opcode = 0x10A; @@ -445,7 +445,7 @@ void CArmOps::CompareArmRegToArmReg(ArmReg Reg1, ArmReg Reg2) else { CodeLog(" cmp.w\t%s, %s", ArmRegName(Reg1), ArmRegName(Reg2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = Reg1; op.imm5.s = 1; op.imm5.opcode = 0x75D; @@ -480,7 +480,7 @@ void CArmOps::IfBlock(ArmItMask mask, ArmCompareType CompareType) g_Notify->BreakPoint(__FILE__, __LINE__); } - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.It.mask = computed_mask; op.It.firstcond = CompareType; op.It.opcode = 0xBF; @@ -500,7 +500,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, u return; } CodeLog(" ldrb.w\t%s, [%s, #%d]", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)offset); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm12.rt = DestReg; op.imm12.rn = RegPointer; op.imm12.imm = offset; @@ -510,7 +510,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, u else { CodeLog(" ldrb\t%s, [%s%s%s]", ArmRegName(DestReg), ArmRegName(RegPointer), offset == 0 ? "" : ",", offset == 0 ? "" : stdstr_f("#%d", offset).c_str()); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm5.rt = DestReg; op.Imm5.rn = RegPointer; op.Imm5.imm5 = offset; @@ -526,7 +526,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, A if ((DestReg > 0x7 || RegPointer > 0x7 || RegPointer2 > 0x7) && (shift & ~3) == 0) { CodeLog(" ldrb\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.uint16.rn = RegPointer; op.uint16.opcode = 0xF81; op.uint16.rm = RegPointer2; @@ -538,7 +538,7 @@ void CArmOps::LoadArmRegPointerByteToArmReg(ArmReg DestReg, ArmReg RegPointer, A else if (shift == 0 && DestReg <= 0x7 && RegPointer <= 0x7 && RegPointer2 <= 0x7) { CodeLog(" ldrb\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg.rm = RegPointer2; op.Reg.rt = DestReg; op.Reg.rn = RegPointer; @@ -564,7 +564,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8 return; } CodeLog(" ldr.w\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm12.rt = DestReg; op.imm12.rn = RegPointer; op.imm12.imm = Offset; @@ -574,7 +574,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, uint8 else { CodeLog(" ldr\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm5.rt = DestReg; op.Imm5.rn = RegPointer; op.Imm5.imm5 = Offset >> 2; @@ -596,7 +596,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmRe if (shift == 0 && DestReg <= 0x7 && RegPointer <= 0x7 && RegPointer2 <= 0x7) { CodeLog(" ldr\t%s, [%s,%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg.rm = RegPointer2; op.Reg.rt = DestReg; op.Reg.rn = RegPointer; @@ -606,7 +606,7 @@ void CArmOps::LoadArmRegPointerToArmReg(ArmReg DestReg, ArmReg RegPointer, ArmRe else { CodeLog(" ldr.w\t%s, [%s, %s, lsl #%d]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2), shift); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm2.rm = RegPointer2; op.imm2.imm = shift; op.imm2.Opcode2 = 0; @@ -629,7 +629,7 @@ void CArmOps::LoadArmRegPointerToFloatReg(ArmReg RegPointer, ArmFpuSingle Reg, u { CodeLog(" vldr\t%s, [%s]", ArmFpuSingleName(Reg), ArmRegName(RegPointer)); } - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.RnVdImm8.Rn = RegPointer; op.RnVdImm8.op3 = 1; op.RnVdImm8.D = Reg & 1; @@ -654,7 +654,7 @@ void CArmOps::LoadFloatingPointControlReg(ArmReg DestReg) PreOpCheck(DestReg, false, __FILE__, __LINE__); CodeLog(" vmrs\t%s, fpscr", ArmRegName(DestReg)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.fpscr.opcode2 = 0xA10; op.fpscr.rt = DestReg; op.fpscr.opcode = 0xEEF1; @@ -669,7 +669,7 @@ void CArmOps::MoveConstToArmReg(ArmReg DestReg, uint32_t value, const char * com CodeLog(" mov.w\t%s, #0x%X\t; %s", ArmRegName(DestReg), (uint32_t)value, comment != nullptr ? comment : stdstr_f("0x%X", (uint32_t)value).c_str()); uint16_t CompressedValue = ThumbCompressConst(value); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = 0xF; op.imm8_3_1.s = 0; op.imm8_3_1.opcode = 0x2; @@ -740,7 +740,7 @@ void CArmOps::OrArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceR return; } CodeLog(" orr.w\t%s, %s, %s%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2), shift ? stdstr_f(", lsl #%d", shift).c_str() : ""); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = SourceReg1; op.imm5.s = 0; op.imm5.opcode = 0x752; @@ -768,7 +768,7 @@ void CArmOps::OrConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t value) { uint16_t CompressedValue = ThumbCompressConst(value); CodeLog(" orr\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), value); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = SourceReg; op.imm8_3_1.s = 0; op.imm8_3_1.opcode = 0x2; @@ -816,7 +816,7 @@ void CArmOps::MulF32(ArmFpuSingle DestReg, ArmFpuSingle SourceReg1, ArmFpuSingle PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); CodeLog(" vmul.f32\t%s, %s, %s", ArmFpuSingleName(DestReg), ArmFpuSingleName(SourceReg1), ArmFpuSingleName(SourceReg2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.VnVmVd.vn = SourceReg1 >> 1; op.VnVmVd.op1 = 0x2; op.VnVmVd.d = DestReg & 1; @@ -857,8 +857,14 @@ void CArmOps::PushArmReg(uint16_t Registers) { return; } - if ((Registers & ArmPushPop_SP) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if ((Registers & ArmPushPop_PC) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if ((Registers & ArmPushPop_SP) != 0) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + if ((Registers & ArmPushPop_PC) != 0) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } if ((Registers & ArmPushPop_LR) == 0) { m_PushRegisters = Registers; @@ -879,7 +885,7 @@ void CArmOps::PushArmReg(uint16_t Registers) { CodeLog("%X: push\t{%s}", (int32_t)*g_RecompPos, pushed.c_str()); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.PushPop.register_list = Registers; op.PushPop.opcode = 0xE92D; AddCode32(op.Hex); @@ -890,7 +896,7 @@ void CArmOps::PushArmReg(uint16_t Registers) bool lr = (Registers & ArmPushPop_LR) != 0; Registers &= Registers & ~ArmPushPop_LR; - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Push.register_list = (uint8_t)Registers; op.Push.m = lr ? 1 : 0; op.Push.opcode = ArmPUSH; @@ -918,8 +924,14 @@ void CArmOps::PopArmReg(uint16_t Registers) CodeLog("%s: Setting m_PushRegisters: %X Registers: %X", __FUNCTION__, m_PushRegisters, Registers); g_Notify->BreakPoint(__FILE__, __LINE__); } - if ((Registers & ArmPushPop_SP) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if ((Registers & ArmPushPop_LR) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if ((Registers & ArmPushPop_SP) != 0) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + if ((Registers & ArmPushPop_LR) != 0) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); m_PopRegisters = Registers; @@ -949,7 +961,7 @@ void CArmOps::FlushPopArmReg(void) { CodeLog("%X pop\t{%s}", (int32_t)*g_RecompPos, pushed.c_str()); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.PushPop.register_list = m_PopRegisters; op.PushPop.opcode = 0xE8BD; AddCode32(op.Hex); @@ -960,7 +972,7 @@ void CArmOps::FlushPopArmReg(void) bool pc = (m_PopRegisters & ArmPushPop_PC) != 0; m_PopRegisters &= ~ArmPushPop_PC; - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Pop.register_list = (uint8_t)m_PopRegisters; op.Pop.p = pc ? 1 : 0; op.Pop.opcode = ArmPOP; @@ -973,11 +985,10 @@ void CArmOps::FlushPopArmReg(void) uint32_t CArmOps::PushPopRegisterSize(uint16_t Registers) { static uint32_t RegisterList[] = - { - ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4, - ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9, - ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC - }; + { + ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4, + ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9, + ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC}; uint32_t size = 0; for (uint32_t i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) { @@ -991,18 +1002,40 @@ uint32_t CArmOps::PushPopRegisterSize(uint16_t Registers) std::string CArmOps::PushPopRegisterList(uint16_t Registers) { - static uint32_t PushPopRegisterList[] = - { - ArmPushPop_R0, ArmPushPop_R1, ArmPushPop_R2, ArmPushPop_R3, ArmPushPop_R4, - ArmPushPop_R5, ArmPushPop_R6, ArmPushPop_R7, ArmPushPop_R8, ArmPushPop_R9, - ArmPushPop_R10, ArmPushPop_R11, ArmPushPop_R12, ArmPushPop_LR, ArmPushPop_PC + static uint32_t PushPopRegisterList[] = { + ArmPushPop_R0, + ArmPushPop_R1, + ArmPushPop_R2, + ArmPushPop_R3, + ArmPushPop_R4, + ArmPushPop_R5, + ArmPushPop_R6, + ArmPushPop_R7, + ArmPushPop_R8, + ArmPushPop_R9, + ArmPushPop_R10, + ArmPushPop_R11, + ArmPushPop_R12, + ArmPushPop_LR, + ArmPushPop_PC, }; - static ArmReg RegisterList[] = - { - Arm_R0, Arm_R1, Arm_R2, Arm_R3, Arm_R4, - Arm_R5, Arm_R6, Arm_R7, Arm_R8, Arm_R9, - Arm_R10, Arm_R11, Arm_R12, ArmRegLR, ArmRegPC, + static ArmReg RegisterList[] = { + Arm_R0, + Arm_R1, + Arm_R2, + Arm_R3, + Arm_R4, + Arm_R5, + Arm_R6, + Arm_R7, + Arm_R8, + Arm_R9, + Arm_R10, + Arm_R11, + Arm_R12, + ArmRegLR, + ArmRegPC, }; std::string RegisterResult; @@ -1027,7 +1060,7 @@ void CArmOps::ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shi else if (DestReg > 0x7 || SourceReg > 0x7) { CodeLog(" asrs.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = 0xF; op.imm5.s = 0; op.imm5.opcode = 0x752; @@ -1044,7 +1077,7 @@ void CArmOps::ShiftRightSignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shi { CodeLog(" asrs\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm5.rt = DestReg; op.Imm5.rn = SourceReg; op.Imm5.imm5 = shift; @@ -1064,7 +1097,7 @@ void CArmOps::ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t s if (DestReg > 0x7 || SourceReg > 0x7) { CodeLog(" lsrs.w\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = 0xF; op.imm5.s = 0; op.imm5.opcode = 0x752; @@ -1081,7 +1114,7 @@ void CArmOps::ShiftRightUnsignImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t s { CodeLog(" lsrs\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm5.rt = DestReg; op.Imm5.rn = SourceReg; op.Imm5.imm5 = shift; @@ -1101,7 +1134,7 @@ void CArmOps::ShiftLeftImmed(ArmReg DestReg, ArmReg SourceReg, uint32_t shift) } CodeLog(" lsls\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(SourceReg), (uint32_t)shift); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm5.rt = DestReg; op.Imm5.rn = SourceReg; op.Imm5.imm5 = shift; @@ -1114,7 +1147,7 @@ void CArmOps::SignExtendByte(ArmReg Reg) if (Reg > 0x7) { CodeLog(" sxtb.w\t%s, %s", ArmRegName(Reg), ArmRegName(Reg)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.rotate.opcode = 0xFA4F; op.rotate.rm = Reg; op.rotate.rotate = 0; @@ -1126,7 +1159,7 @@ void CArmOps::SignExtendByte(ArmReg Reg) else { CodeLog(" sxtb\t%s, %s", ArmRegName(Reg), ArmRegName(Reg)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg2.rn = Reg; op.Reg2.rm = Reg; op.Reg2.opcode = 0x2C9; @@ -1140,10 +1173,14 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint if (DestReg > 0x7 || RegPointer > 0x7 || (Offset & (~0x7C)) != 0) { - if ((Offset & (~0xFFF)) != 0) { g_Notify->BreakPoint(__FILE__, __LINE__); return; } + if ((Offset & (~0xFFF)) != 0) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + return; + } CodeLog(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm12.rt = DestReg; op.imm12.rn = RegPointer; op.imm12.imm = Offset; @@ -1153,7 +1190,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, uint else { CodeLog(" str\t%s, [%s, #%d]%s%s", ArmRegName(DestReg), ArmRegName(RegPointer), (uint32_t)Offset, comment != nullptr ? "\t; " : "", comment != nullptr ? comment : ""); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm5.rt = DestReg; op.Imm5.rn = RegPointer; op.Imm5.imm5 = Offset >> 2; @@ -1170,7 +1207,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmR if (DestReg > 0x7 || RegPointer > 0x7 || RegPointer2 > 0x7 || shift != 0) { CodeLog(" str.w\t%s, [%s, %s%s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2), shift != 0 ? stdstr_f(", lsl #%d", shift).c_str() : ""); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm2.rm = RegPointer2; op.imm2.imm = shift; op.imm2.Opcode2 = 0; @@ -1182,7 +1219,7 @@ void CArmOps::StoreArmRegToArmRegPointer(ArmReg DestReg, ArmReg RegPointer, ArmR else { CodeLog(" str\t%s, [%s, %s]", ArmRegName(DestReg), ArmRegName(RegPointer), ArmRegName(RegPointer2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg.rt = DestReg; op.Reg.rn = RegPointer; op.Reg.rm = RegPointer2; @@ -1196,7 +1233,7 @@ void CArmOps::StoreFloatingPointControlReg(ArmReg SourceReg) PreOpCheck(Arm_Unknown, false, __FILE__, __LINE__); CodeLog(" vmsr\tfpscr, %s", ArmRegName(SourceReg)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.fpscr.opcode2 = 0xA10; op.fpscr.rt = SourceReg; op.fpscr.opcode = 0xEEE1; @@ -1215,7 +1252,7 @@ void CArmOps::StoreFloatRegToArmRegPointer(ArmFpuSingle Reg, ArmReg RegPointer, { CodeLog(" vstr\t%s, [%s]", ArmFpuSingleName(Reg), ArmRegName(RegPointer)); } - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.RnVdImm8.Rn = RegPointer; op.RnVdImm8.op3 = 0; op.RnVdImm8.D = Reg & 1; @@ -1235,7 +1272,7 @@ void CArmOps::SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Sour if (DestReg <= 7 && SourceReg1 <= 7 && SourceReg2 <= 7) { CodeLog(" subs\t%s,%s,%s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg.rt = DestReg; op.Reg.rn = SourceReg1; op.Reg.rm = SourceReg2; @@ -1245,7 +1282,7 @@ void CArmOps::SubArmRegFromArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Sour else { CodeLog(" sub.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = SourceReg1; op.imm5.s = 0; op.imm5.opcode = 0x75D; @@ -1267,7 +1304,7 @@ void CArmOps::SubConstFromArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Cons if (DestReg <= 7 && DestReg == SourceReg && (Const & (~0xFF)) == 0) { CodeLog(" subs\t%s, #0x%X", ArmRegName(DestReg), Const); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Imm8.imm8 = (uint8_t)Const; op.Imm8.rdn = DestReg; op.Imm8.opcode = 0x7; @@ -1276,7 +1313,7 @@ void CArmOps::SubConstFromArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Cons else if ((Const & (~0x7FF)) == 0) { CodeLog(" sub.w\t%s, %s, #0x%X", ArmRegName(DestReg), ArmRegName(SourceReg), Const); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.RnRdImm12.Rn = SourceReg; op.RnRdImm12.s = 0; op.RnRdImm12.opcode = 0x15; @@ -1340,7 +1377,7 @@ void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg) if (SourceReg <= 7 && DestReg <= 7) { CodeLog(" eors\t%s, %s", ArmRegName(DestReg), ArmRegName(SourceReg)); - ArmThumbOpcode op = { 0 }; + ArmThumbOpcode op = {0}; op.Reg2.rn = DestReg; op.Reg2.rm = SourceReg; op.Reg2.opcode = 0x101; @@ -1357,7 +1394,7 @@ void CArmOps::XorArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg Source PreOpCheck(DestReg, false, __FILE__, __LINE__); CodeLog(" eor.w\t%s, %s, %s", ArmRegName(DestReg), ArmRegName(SourceReg1), ArmRegName(SourceReg2)); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm5.rn = SourceReg1; op.imm5.s = 0; op.imm5.opcode = 0x754; @@ -1383,7 +1420,7 @@ void CArmOps::XorConstToArmReg(ArmReg DestReg, uint32_t value) { uint16_t CompressedValue = ThumbCompressConst(value); CodeLog(" eor\t%s, %s, #%d", ArmRegName(DestReg), ArmRegName(DestReg), value); - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.imm8_3_1.rn = DestReg; op.imm8_3_1.s = 0; op.imm8_3_1.opcode = 0x4; @@ -1534,7 +1571,7 @@ void CArmOps::SetJump20(uint32_t * Loc, uint32_t * JumpLoc) CodeLog("%s: target %X pc %X immediate: %X", __FUNCTION__, target, pc, immediate); g_Notify->BreakPoint(__FILE__, __LINE__); } - Arm32Opcode op = { 0 }; + Arm32Opcode op = {0}; op.Hex = *Loc; if (op.Branch20.val12 == 0) { @@ -1615,12 +1652,30 @@ bool CArmOps::ArmCompareInverse(ArmCompareType CompareType) CArmOps::ArmCompareType CArmOps::ArmCompareInverseType(ArmCompareType CompareType) { - if (CompareType == ArmBranch_Equal) { return ArmBranch_Notequal; } - if (CompareType == ArmBranch_Notequal) { return ArmBranch_Equal; } - if (CompareType == ArmBranch_GreaterThanOrEqual) { return ArmBranch_LessThan; } - if (CompareType == ArmBranch_LessThan) { return ArmBranch_GreaterThanOrEqual; } - if (CompareType == ArmBranch_GreaterThan) { return ArmBranch_LessThanOrEqual; } - if (CompareType == ArmBranch_LessThanOrEqual) { return ArmBranch_GreaterThan; } + if (CompareType == ArmBranch_Equal) + { + return ArmBranch_Notequal; + } + if (CompareType == ArmBranch_Notequal) + { + return ArmBranch_Equal; + } + if (CompareType == ArmBranch_GreaterThanOrEqual) + { + return ArmBranch_LessThan; + } + if (CompareType == ArmBranch_LessThan) + { + return ArmBranch_GreaterThanOrEqual; + } + if (CompareType == ArmBranch_GreaterThan) + { + return ArmBranch_LessThanOrEqual; + } + if (CompareType == ArmBranch_LessThanOrEqual) + { + return ArmBranch_GreaterThan; + } g_Notify->BreakPoint(__FILE__, __LINE__); return ArmBranch_Equal; } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h index f549d1242..0d8ba165d 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmOps.h @@ -158,7 +158,7 @@ public: void AddArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); void AddConstToArmReg(ArmReg DestReg, uint32_t Const); void AddConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const); - void AndConstToVariable(void *Variable, const char * VariableName, uint32_t Const); + void AndConstToVariable(void * Variable, const char * VariableName, uint32_t Const); void AndConstToArmReg(ArmReg DestReg, ArmReg SourceReg, uint32_t Const); void AndArmRegToArmReg(ArmReg DestReg, ArmReg SourceReg1, ArmReg SourceReg2); void ArmBreakPoint(const char * FileName, uint32_t LineNumber); @@ -218,8 +218,8 @@ public: private: CArmOps(void); - CArmOps(const CArmOps&); - CArmOps& operator=(const CArmOps&); + CArmOps(const CArmOps &); + CArmOps & operator=(const CArmOps &); void CodeLog(_Printf_format_string_ const char * Text, ...); @@ -252,6 +252,6 @@ private: uint16_t m_PushRegisters; }; -#define AddressOf(Addr) CArmOps::GetAddressOf(5,(Addr)) +#define AddressOf(Addr) CArmOps::GetAddressOf(5, (Addr)) #endif \ No newline at end of file diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp index 0f5ffe0ce..1c82872c8 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.cpp @@ -2,22 +2,22 @@ #if defined(__arm__) || defined(_M_ARM) -#include -#include -#include -#include +#include +#include #include #include -#include -#include +#include +#include +#include +#include +#include +#include #include #include -#include #include -#include -#include -#include -#include +#include +#include +#include uint32_t CArmRecompilerOps::m_TempValue = 0; @@ -112,56 +112,56 @@ void CArmRecompilerOps::PostCompileOpcode(void) void CArmRecompilerOps::Compile_TrapCompare(RecompilerTrapCompare CompareType) { - void *FunctAddress = nullptr; - const char *FunctName = nullptr; + void * FunctAddress = nullptr; + const char * FunctName = nullptr; switch (CompareType) { case RecompilerTrapCompare_TEQ: - FunctAddress = (void*)R4300iOp::SPECIAL_TEQ; + FunctAddress = (void *)R4300iOp::SPECIAL_TEQ; FunctName = "R4300iOp::SPECIAL_TEQ"; break; case RecompilerTrapCompare_TNE: - FunctAddress = (void*)R4300iOp::SPECIAL_TNE; + FunctAddress = (void *)R4300iOp::SPECIAL_TNE; FunctName = "R4300iOp::SPECIAL_TNE"; break; case RecompilerTrapCompare_TGE: - FunctAddress = (void*)R4300iOp::SPECIAL_TGE; + FunctAddress = (void *)R4300iOp::SPECIAL_TGE; FunctName = "R4300iOp::SPECIAL_TGE"; break; case RecompilerTrapCompare_TGEU: - FunctAddress = (void*)R4300iOp::SPECIAL_TGEU; + FunctAddress = (void *)R4300iOp::SPECIAL_TGEU; FunctName = "R4300iOp::SPECIAL_TGEU"; break; case RecompilerTrapCompare_TLT: - FunctAddress = (void*)R4300iOp::SPECIAL_TLT; + FunctAddress = (void *)R4300iOp::SPECIAL_TLT; FunctName = "R4300iOp::SPECIAL_TLT"; break; case RecompilerTrapCompare_TLTU: - FunctAddress = (void*)R4300iOp::SPECIAL_TLTU; + FunctAddress = (void *)R4300iOp::SPECIAL_TLTU; FunctName = "R4300iOp::SPECIAL_TLTU"; break; case RecompilerTrapCompare_TEQI: - FunctAddress = (void*)R4300iOp::REGIMM_TEQI; + FunctAddress = (void *)R4300iOp::REGIMM_TEQI; FunctName = "R4300iOp::REGIMM_TEQI"; break; case RecompilerTrapCompare_TNEI: - FunctAddress = (void*)R4300iOp::REGIMM_TNEI; + FunctAddress = (void *)R4300iOp::REGIMM_TNEI; FunctName = "R4300iOp::REGIMM_TNEI"; break; case RecompilerTrapCompare_TGEI: - FunctAddress = (void*)R4300iOp::REGIMM_TGEI; + FunctAddress = (void *)R4300iOp::REGIMM_TGEI; FunctName = "R4300iOp::REGIMM_TGEI"; break; case RecompilerTrapCompare_TGEIU: - FunctAddress = (void*)R4300iOp::REGIMM_TGEIU; + FunctAddress = (void *)R4300iOp::REGIMM_TGEIU; FunctName = "R4300iOp::REGIMM_TGEIU"; break; case RecompilerTrapCompare_TLTI: - FunctAddress = (void*)R4300iOp::REGIMM_TLTI; + FunctAddress = (void *)R4300iOp::REGIMM_TLTI; FunctName = "R4300iOp::REGIMM_TLTI"; break; case RecompilerTrapCompare_TLTIU: - FunctAddress = (void*)R4300iOp::REGIMM_TLTIU; + FunctAddress = (void *)R4300iOp::REGIMM_TLTIU; FunctName = "R4300iOp::REGIMM_TLTIU"; break; default: @@ -170,8 +170,14 @@ void CArmRecompilerOps::Compile_TrapCompare(RecompilerTrapCompare CompareType) if (FunctName != nullptr && FunctAddress != nullptr) { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } CompileInterpterCall(FunctAddress, FunctName); } @@ -324,7 +330,10 @@ void CArmRecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr) { - if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (DelayLinkLocation != nullptr) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } DelayLinkLocation = *g_RecompPos; m_Assembler.BranchLabel8(CArmOps::CArmOps::ArmBranch_Always, "DoDelaySlot"); @@ -335,7 +344,10 @@ void CArmRecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool } if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr) { - if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (DelayLinkLocation != nullptr) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } DelayLinkLocation = *g_RecompPos; m_Assembler.BranchLabel8(CArmOps::CArmOps::ArmBranch_Always, "DoDelaySlot"); @@ -640,8 +652,7 @@ void CArmRecompilerOps::BNE_Compare() { m_Assembler.CompareArmRegToArmReg( Is32Bit(m_Opcode.rs) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) - ); + Is32Bit(m_Opcode.rt) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt)); if (m_Section->m_Jump.FallThrough) { @@ -948,7 +959,7 @@ void CArmRecompilerOps::BNE_Compare() void CArmRecompilerOps::BEQ_Compare() { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) { @@ -978,8 +989,7 @@ void CArmRecompilerOps::BEQ_Compare() m_Assembler.CompareArmRegToArmReg( Is32Bit(m_Opcode.rs) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) - ); + Is32Bit(m_Opcode.rt) ? Map_TempReg(CArmOps::Arm_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { Jump = *g_RecompPos; @@ -1314,7 +1324,7 @@ void CArmRecompilerOps::BGTZ_Compare() } else { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (IsMapped(m_Opcode.rs)) { @@ -1449,7 +1459,7 @@ void CArmRecompilerOps::BLEZ_Compare() } else { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; CArmOps::ArmReg TempRegRs = CArmOps::Arm_Any; if (IsMapped(m_Opcode.rs)) @@ -1519,7 +1529,7 @@ void CArmRecompilerOps::BLEZ_Compare() } else { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (!g_System->b32BitCore()) { @@ -1845,7 +1855,7 @@ void CArmRecompilerOps::J() return; } - m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2);; + m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); m_Section->m_Jump.JumpPC = m_CompilePC; if (m_Section->m_JumpSection != nullptr) { @@ -1987,7 +1997,10 @@ void CArmRecompilerOps::ADDIU() void CArmRecompilerOps::SLTI() { UnMap_GPR(m_Opcode.rt, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SLTI, "R4300iOp32::SLTI"); @@ -2001,7 +2014,10 @@ void CArmRecompilerOps::SLTI() void CArmRecompilerOps::SLTIU() { UnMap_GPR(m_Opcode.rt, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SLTIU, "R4300iOp32::SLTIU"); @@ -2015,7 +2031,10 @@ void CArmRecompilerOps::SLTIU() void CArmRecompilerOps::ANDI() { UnMap_GPR(m_Opcode.rt, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::ANDI, "R4300iOp32::ANDI"); @@ -2094,7 +2113,10 @@ void CArmRecompilerOps::ORI() void CArmRecompilerOps::XORI() { UnMap_GPR(m_Opcode.rt, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::XORI, "R4300iOp32::XORI"); @@ -2124,8 +2146,14 @@ void CArmRecompilerOps::LUI() void CArmRecompilerOps::DADDI() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::DADDI, "R4300iOp32::DADDI"); @@ -2138,8 +2166,14 @@ void CArmRecompilerOps::DADDI() void CArmRecompilerOps::DADDIU() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::DADDIU, "R4300iOp32::DADDIU"); @@ -2152,7 +2186,10 @@ void CArmRecompilerOps::DADDIU() void CArmRecompilerOps::LDL() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2166,7 +2203,10 @@ void CArmRecompilerOps::LDL() void CArmRecompilerOps::LDR() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2222,7 +2262,10 @@ void CArmRecompilerOps::LB() void CArmRecompilerOps::LH() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2236,7 +2279,10 @@ void CArmRecompilerOps::LH() void CArmRecompilerOps::LWL() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2325,7 +2371,10 @@ void CArmRecompilerOps::LW(bool ResultSigned, bool bRecordLLBit) void CArmRecompilerOps::LBU() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2339,7 +2388,10 @@ void CArmRecompilerOps::LBU() void CArmRecompilerOps::LHU() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2353,7 +2405,10 @@ void CArmRecompilerOps::LHU() void CArmRecompilerOps::LWR() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2367,7 +2422,10 @@ void CArmRecompilerOps::LWR() void CArmRecompilerOps::LWU() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2381,8 +2439,14 @@ void CArmRecompilerOps::LWU() void CArmRecompilerOps::SB() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SB, "R4300iOp32::SB"); @@ -2395,8 +2459,14 @@ void CArmRecompilerOps::SB() void CArmRecompilerOps::SH() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SH, "R4300iOp32::SH"); @@ -2409,8 +2479,14 @@ void CArmRecompilerOps::SH() void CArmRecompilerOps::SWL() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SWL, "R4300iOp32::SWL"); @@ -2468,7 +2544,10 @@ void CArmRecompilerOps::SW(bool bCheckLLbit) m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); } - if (IsMapped(m_Opcode.base)) { ProtectGPR(m_Opcode.base); } + if (IsMapped(m_Opcode.base)) + { + ProtectGPR(m_Opcode.base); + } CArmOps::ArmReg TempRegAddress = Map_TempReg(CArmOps::Arm_Any, IsMapped(m_Opcode.base) ? -1 : m_Opcode.base, false); if (IsMapped(m_Opcode.base)) { @@ -2498,8 +2577,14 @@ void CArmRecompilerOps::SW(bool bCheckLLbit) void CArmRecompilerOps::SWR() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SWR, "R4300iOp32::SWR"); @@ -2512,8 +2597,14 @@ void CArmRecompilerOps::SWR() void CArmRecompilerOps::SDL() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SDL, "R4300iOp32::SDL"); @@ -2526,8 +2617,14 @@ void CArmRecompilerOps::SDL() void CArmRecompilerOps::SDR() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SDR, "R4300iOp32::SDR"); @@ -2544,7 +2641,10 @@ void CArmRecompilerOps::CACHE() { return; } - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } switch (m_Opcode.rt) { @@ -2580,7 +2680,10 @@ void CArmRecompilerOps::CACHE() void CArmRecompilerOps::LL() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2641,7 +2744,10 @@ void CArmRecompilerOps::LWC1() void CArmRecompilerOps::LDC1() { CompileCop1Test(); - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::LDC1, "R4300iOp32::LDC1"); @@ -2654,7 +2760,10 @@ void CArmRecompilerOps::LDC1() void CArmRecompilerOps::LD() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } UnMap_GPR(m_Opcode.rt, true); if (g_Settings->LoadBool(Game_32Bit)) { @@ -2668,8 +2777,14 @@ void CArmRecompilerOps::LD() void CArmRecompilerOps::SC() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SC, "R4300iOp32::SC"); @@ -2683,7 +2798,10 @@ void CArmRecompilerOps::SC() void CArmRecompilerOps::SWC1() { CompileCop1Test(); - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SWC1, "R4300iOp32::SWC1"); @@ -2697,7 +2815,10 @@ void CArmRecompilerOps::SWC1() void CArmRecompilerOps::SDC1() { CompileCop1Test(); - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SDC1, "R4300iOp32::SDC1"); @@ -2710,8 +2831,14 @@ void CArmRecompilerOps::SDC1() void CArmRecompilerOps::SD() { - if (m_Opcode.base != 0) { WriteBack_GPR(m_Opcode.base, false); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.base != 0) + { + WriteBack_GPR(m_Opcode.base, false); + } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SD, "R4300iOp32::SD"); @@ -2729,7 +2856,10 @@ void CArmRecompilerOps::SPECIAL_SLL() return; } UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SLL, "R4300iOp32::SPECIAL_SLL"); @@ -2743,7 +2873,10 @@ void CArmRecompilerOps::SPECIAL_SLL() void CArmRecompilerOps::SPECIAL_SRL() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SRL, "R4300iOp32::SPECIAL_SRL"); @@ -2757,7 +2890,10 @@ void CArmRecompilerOps::SPECIAL_SRL() void CArmRecompilerOps::SPECIAL_SRA() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SRA, "R4300iOp32::SPECIAL_SRA"); @@ -2771,8 +2907,14 @@ void CArmRecompilerOps::SPECIAL_SRA() void CArmRecompilerOps::SPECIAL_SLLV() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SLLV, "R4300iOp32::SPECIAL_SLLV"); @@ -2786,8 +2928,14 @@ void CArmRecompilerOps::SPECIAL_SLLV() void CArmRecompilerOps::SPECIAL_SRLV() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SRLV, "R4300iOp32::SPECIAL_SRLV"); @@ -2801,8 +2949,14 @@ void CArmRecompilerOps::SPECIAL_SRLV() void CArmRecompilerOps::SPECIAL_SRAV() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SRAV, "R4300iOp32::SPECIAL_SRAV"); @@ -3031,7 +3185,10 @@ void CArmRecompilerOps::SPECIAL_MFLO() void CArmRecompilerOps::SPECIAL_MTLO() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_MTLO, "R4300iOp32::SPECIAL_MTLO"); @@ -3057,7 +3214,10 @@ void CArmRecompilerOps::SPECIAL_MFHI() void CArmRecompilerOps::SPECIAL_MTHI() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_MTHI, "R4300iOp32::SPECIAL_MTHI"); @@ -3071,8 +3231,14 @@ void CArmRecompilerOps::SPECIAL_MTHI() void CArmRecompilerOps::SPECIAL_DSLLV() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSLLV, "R4300iOp32::SPECIAL_DSLLV"); @@ -3086,8 +3252,14 @@ void CArmRecompilerOps::SPECIAL_DSLLV() void CArmRecompilerOps::SPECIAL_DSRLV() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSRLV, "R4300iOp32::SPECIAL_DSRLV"); @@ -3101,8 +3273,14 @@ void CArmRecompilerOps::SPECIAL_DSRLV() void CArmRecompilerOps::SPECIAL_DSRAV() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSRAV, "R4300iOp32::SPECIAL_DSRAV"); @@ -3115,8 +3293,14 @@ void CArmRecompilerOps::SPECIAL_DSRAV() void CArmRecompilerOps::SPECIAL_MULT() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_MULT, "R4300iOp32::SPECIAL_MULT"); @@ -3129,8 +3313,14 @@ void CArmRecompilerOps::SPECIAL_MULT() void CArmRecompilerOps::SPECIAL_MULTU() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_MULTU, "R4300iOp32::SPECIAL_MULTU"); @@ -3143,8 +3333,14 @@ void CArmRecompilerOps::SPECIAL_MULTU() void CArmRecompilerOps::SPECIAL_DIV() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DIV, "R4300iOp32::SPECIAL_DIV"); @@ -3157,8 +3353,14 @@ void CArmRecompilerOps::SPECIAL_DIV() void CArmRecompilerOps::SPECIAL_DIVU() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DIVU, "R4300iOp32::SPECIAL_DIVU"); @@ -3171,8 +3373,14 @@ void CArmRecompilerOps::SPECIAL_DIVU() void CArmRecompilerOps::SPECIAL_DMULT() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DMULT, "R4300iOp32::SPECIAL_DMULT"); @@ -3185,8 +3393,14 @@ void CArmRecompilerOps::SPECIAL_DMULT() void CArmRecompilerOps::SPECIAL_DMULTU() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DMULTU, "R4300iOp32::SPECIAL_DMULTU"); @@ -3199,8 +3413,14 @@ void CArmRecompilerOps::SPECIAL_DMULTU() void CArmRecompilerOps::SPECIAL_DDIV() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DDIV, "R4300iOp32::SPECIAL_DDIV"); @@ -3213,8 +3433,14 @@ void CArmRecompilerOps::SPECIAL_DDIV() void CArmRecompilerOps::SPECIAL_DDIVU() { - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DDIVU, "R4300iOp32::SPECIAL_DDIVU"); @@ -3228,8 +3454,14 @@ void CArmRecompilerOps::SPECIAL_DDIVU() void CArmRecompilerOps::SPECIAL_ADD() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_ADD, "R4300iOp32::SPECIAL_ADD"); @@ -3243,8 +3475,14 @@ void CArmRecompilerOps::SPECIAL_ADD() void CArmRecompilerOps::SPECIAL_ADDU() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_ADDU, "R4300iOp32::SPECIAL_ADDU"); @@ -3315,8 +3553,14 @@ void CArmRecompilerOps::SPECIAL_SUBU() void CArmRecompilerOps::SPECIAL_AND() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_AND, "R4300iOp32::SPECIAL_AND"); @@ -3330,8 +3574,14 @@ void CArmRecompilerOps::SPECIAL_AND() void CArmRecompilerOps::SPECIAL_OR() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_OR, "R4300iOp32::SPECIAL_OR"); @@ -3388,8 +3638,8 @@ void CArmRecompilerOps::SPECIAL_XOR() { Map_GPR_64bit(m_Opcode.rd, -1); m_Assembler.XorArmRegToArmReg(GetMipsRegMapHi(m_Opcode.rd), - Is32Bit(source1) ? Map_TempReg(CArmOps::Arm_Any, source1, true) : GetMipsRegMapHi(source1), - Is32Bit(source2) ? Map_TempReg(CArmOps::Arm_Any, source2, true) : GetMipsRegMapHi(source2)); + Is32Bit(source1) ? Map_TempReg(CArmOps::Arm_Any, source1, true) : GetMipsRegMapHi(source1), + Is32Bit(source2) ? Map_TempReg(CArmOps::Arm_Any, source2, true) : GetMipsRegMapHi(source2)); m_Assembler.XorArmRegToArmReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source1), GetMipsRegMapLo(source2)); } else @@ -3416,8 +3666,14 @@ void CArmRecompilerOps::SPECIAL_XOR() uint32_t ConstHi = Is32Bit(ConstReg) ? (uint32_t)(GetMipsRegLo_S(ConstReg) >> 31) : GetMipsRegHi(ConstReg); uint32_t ConstLo = GetMipsRegLo(ConstReg); Map_GPR_64bit(m_Opcode.rd, MappedReg); - if (ConstHi != 0) { m_Assembler.XorConstToArmReg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); } - if (ConstLo != 0) { m_Assembler.XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); } + if (ConstHi != 0) + { + m_Assembler.XorConstToArmReg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); + } + if (ConstLo != 0) + { + m_Assembler.XorConstToArmReg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); + } } else { @@ -3491,8 +3747,14 @@ void CArmRecompilerOps::SPECIAL_XOR() void CArmRecompilerOps::SPECIAL_NOR() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_NOR, "R4300iOp32::SPECIAL_NOR"); @@ -3522,8 +3784,14 @@ void CArmRecompilerOps::SPECIAL_SLT() g_Notify->BreakPoint(__FILE__, __LINE__); } UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SLT, "R4300iOp32::SPECIAL_SLT"); @@ -3733,8 +4001,14 @@ void CArmRecompilerOps::SPECIAL_SLT() void CArmRecompilerOps::SPECIAL_SLTU() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_SLTU, "R4300iOp32::SPECIAL_SLTU"); @@ -3748,8 +4022,14 @@ void CArmRecompilerOps::SPECIAL_SLTU() void CArmRecompilerOps::SPECIAL_DADD() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DADD, "R4300iOp32::SPECIAL_DADD"); @@ -3763,8 +4043,14 @@ void CArmRecompilerOps::SPECIAL_DADD() void CArmRecompilerOps::SPECIAL_DADDU() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DADDU, "R4300iOp32::SPECIAL_DADDU"); @@ -3778,8 +4064,14 @@ void CArmRecompilerOps::SPECIAL_DADDU() void CArmRecompilerOps::SPECIAL_DSUB() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSUB, "R4300iOp32::SPECIAL_DSUB"); @@ -3793,8 +4085,14 @@ void CArmRecompilerOps::SPECIAL_DSUB() void CArmRecompilerOps::SPECIAL_DSUBU() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rs != 0) { WriteBack_GPR(m_Opcode.rs, false); } - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rs != 0) + { + WriteBack_GPR(m_Opcode.rs, false); + } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSUBU, "R4300iOp32::SPECIAL_DSUBU"); @@ -3808,7 +4106,10 @@ void CArmRecompilerOps::SPECIAL_DSUBU() void CArmRecompilerOps::SPECIAL_DSLL() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSLL, "R4300iOp32::SPECIAL_DSLL"); @@ -3822,7 +4123,10 @@ void CArmRecompilerOps::SPECIAL_DSLL() void CArmRecompilerOps::SPECIAL_DSRL() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSRL, "R4300iOp32::SPECIAL_DSRL"); @@ -3836,7 +4140,10 @@ void CArmRecompilerOps::SPECIAL_DSRL() void CArmRecompilerOps::SPECIAL_DSRA() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSRA, "R4300iOp32::SPECIAL_DSRA"); @@ -3850,7 +4157,10 @@ void CArmRecompilerOps::SPECIAL_DSRA() void CArmRecompilerOps::SPECIAL_DSLL32() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSLL32, "R4300iOp32::SPECIAL_DSLL32"); @@ -3864,7 +4174,10 @@ void CArmRecompilerOps::SPECIAL_DSLL32() void CArmRecompilerOps::SPECIAL_DSRL32() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSRL32, "R4300iOp32::SPECIAL_DSRL32"); @@ -3878,7 +4191,10 @@ void CArmRecompilerOps::SPECIAL_DSRL32() void CArmRecompilerOps::SPECIAL_DSRA32() { UnMap_GPR(m_Opcode.rd, true); - if (m_Opcode.rt != 0) { WriteBack_GPR(m_Opcode.rt, false); } + if (m_Opcode.rt != 0) + { + WriteBack_GPR(m_Opcode.rt, false); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::SPECIAL_DSRA32, "R4300iOp32::SPECIAL_DSRA32"); @@ -3893,7 +4209,10 @@ void CArmRecompilerOps::SPECIAL_DSRA32() void CArmRecompilerOps::COP0_MF() { - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } switch (m_Opcode.rd) { @@ -3915,15 +4234,18 @@ void CArmRecompilerOps::COP0_MF() void CArmRecompilerOps::COP0_MT() { - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } switch (m_Opcode.rd) { - case 0: // Index - case 2: // EntryLo0 - case 3: // EntryLo1 - case 4: // Context - case 5: // PageMask + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 4: // Context + case 5: // PageMask case 10: // Entry Hi case 12: // Status case 13: // Cause @@ -3943,8 +4265,8 @@ void CArmRecompilerOps::COP0_MT() CompileInterpterCall((void *)R4300iOp::COP0_MT, "R4300iOp::COP0_MT"); } break; - case 6: // Wired - case 9: // Count + case 6: // Wired + case 9: // Count case 11: // Compare m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet, false, true); @@ -3996,7 +4318,7 @@ void CArmRecompilerOps::COP0_CO_TLBWR() m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_SystemTimer, "g_SystemTimer"); m_Assembler.CallFunction((void *)AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t)true, "true"); + m_Assembler.MoveConstToArmReg(CArmOps::Arm_R2, (uint32_t) true, "true"); m_Assembler.MoveVariableToArmReg(&g_Reg->RANDOM_REGISTER, "RANDOM_REGISTER", CArmOps::Arm_R1); m_Assembler.AndConstToArmReg(CArmOps::Arm_R1, CArmOps::Arm_R1, 0x1F); m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)g_TLB, "g_TLB"); @@ -4095,7 +4417,10 @@ void CArmRecompilerOps::COP1_CF() void CArmRecompilerOps::COP1_MT() { CompileCop1Test(); - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (g_Settings->LoadBool(Game_32Bit)) { CompileInterpterCall((void *)R4300iOp32::COP1_MT, "R4300iOp32::COP1_MT"); @@ -4109,7 +4434,10 @@ void CArmRecompilerOps::COP1_MT() void CArmRecompilerOps::COP1_DMT() { CompileCop1Test(); - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (g_Settings->LoadBool(Game_32Bit)) { @@ -4124,7 +4452,10 @@ void CArmRecompilerOps::COP1_DMT() void CArmRecompilerOps::COP1_CT() { CompileCop1Test(); - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt, true); } + if (m_Opcode.rt != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } if (m_Opcode.fs != 31) { @@ -4732,7 +5063,10 @@ void CArmRecompilerOps::UnknownOpcode() m_Assembler.MoveConstToVariable(m_Opcode.Value, &R4300iOp::m_Opcode.Value, "R4300iOp::m_Opcode.Value"); m_Assembler.CallFunction((void *)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); ExitCodeBlock(); - if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) + { + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; + } } void CArmRecompilerOps::EnterCodeBlock() @@ -4869,15 +5203,14 @@ void CArmRecompilerOps::OutputRegisterState(const CRegInfo & SyncTo, const CRegI } m_CodeBlock.Log("SyncTo.GetArmRegMapped(%s) = %X%s%s CurrentSet.GetArmRegMapped(%s) = %X%s%s", - ArmRegName((CArmOps::ArmReg)i), - SyncTo.GetArmRegMapped((CArmOps::ArmReg)i), - SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", - synctoreg.length() > 0 ? stdstr_f(" (%s)", synctoreg.c_str()).c_str() : "", - ArmRegName((CArmOps::ArmReg)i), - CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i), - CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(CurrentSet.GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", - currentreg.length() > 0 ? stdstr_f(" (%s)", currentreg.c_str()).c_str() : "" - ); + ArmRegName((CArmOps::ArmReg)i), + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i), + SyncTo.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(SyncTo.GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", + synctoreg.length() > 0 ? stdstr_f(" (%s)", synctoreg.c_str()).c_str() : "", + ArmRegName((CArmOps::ArmReg)i), + CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i), + CurrentSet.GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(CurrentSet.GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", + currentreg.length() > 0 ? stdstr_f(" (%s)", currentreg.c_str()).c_str() : ""); } } @@ -4889,7 +5222,10 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) #ifdef tofix UnMap_AllFPRs(); #endif - if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } + if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel()) + { + m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); + } m_CodeBlock.Log("Before:"); OutputRegisterState(SyncTo, m_RegWorkingSet); @@ -5034,14 +5370,21 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) for (uint32_t i = 1; i < 32; i++) { m_CodeBlock.Log("SyncTo.GetMipsRegState(%d: %s) = %X GetMipsRegState(%d: %s) = %X", i, CRegName::GPR[i], SyncTo.GetMipsRegState(i), i, CRegName::GPR[i], GetMipsRegState(i)); - if (IsMapped(i) && Is64Bit(i)) { m_CodeBlock.Log("GetMipsRegMapHi(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapHi(i)); } - if (IsMapped(i)) { m_CodeBlock.Log("GetMipsRegMapLo(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapLo(i)); } + if (IsMapped(i) && Is64Bit(i)) + { + m_CodeBlock.Log("GetMipsRegMapHi(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapHi(i)); + } + if (IsMapped(i)) + { + m_CodeBlock.Log("GetMipsRegMapLo(%d: %s) = %X", i, CRegName::GPR[i], GetMipsRegMapLo(i)); + } if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO)) { - switch (GetMipsRegState(i)) { + switch (GetMipsRegState(i)) + { case CRegInfo::STATE_UNKNOWN: continue; case CRegInfo::STATE_MAPPED_64: if (GetMipsRegMapHi(i) == SyncTo.GetMipsRegMapHi(i) && @@ -5080,7 +5423,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) CArmOps::ArmReg Reg = CArmOps::Arm_Unknown, RegHi = CArmOps::Arm_Unknown, GprReg = CArmOps::Arm_Unknown; switch (SyncTo.GetMipsRegState(i)) { - case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break; + case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break; case CRegInfo::STATE_MAPPED_64: Reg = SyncTo.GetMipsRegMapLo(i); RegHi = SyncTo.GetMipsRegMapHi(i); @@ -5267,7 +5610,7 @@ void CArmRecompilerOps::SyncRegState(const CRegInfo & SyncTo) } } -void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason) +void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason) { m_RegWorkingSet = ExitRegSet; for (int32_t i = 0; i < 16; i++) @@ -5346,7 +5689,7 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo } } -void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason, CArmOps::ArmCompareType CompareType) +void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason, CArmOps::ArmCompareType CompareType) { m_Assembler.BranchLabel20(CompareType, stdstr_f("Exit_%d", m_ExitInfo.size()).c_str()); @@ -5474,7 +5817,10 @@ bool CArmRecompilerOps::InheritParentInfo() CCodeSection * Parent = *iter; BLOCK_PARENT BlockParent; - if (Parent->m_CompiledLocation == nullptr) { continue; } + if (Parent->m_CompiledLocation == nullptr) + { + continue; + } if (Parent->m_JumpSection != Parent->m_ContinueSection) { BlockParent.Parent = Parent; @@ -5504,7 +5850,10 @@ bool CArmRecompilerOps::InheritParentInfo() CCodeSection * Parent = *iter; BLOCK_PARENT BlockParent; - if (Parent->m_CompiledLocation != nullptr) { continue; } + if (Parent->m_CompiledLocation != nullptr) + { + continue; + } if (Parent->m_JumpSection != Parent->m_ContinueSection) { BlockParent.Parent = Parent; @@ -5576,7 +5925,10 @@ bool CArmRecompilerOps::InheritParentInfo() // Determine loop register usage if (m_Section->m_InLoop && ParentList.size() > 1) { - if (!SetupRegisterForLoop(m_Section->m_BlockInfo, m_Section->m_RegEnter)) { return false; } + if (!SetupRegisterForLoop(m_Section->m_BlockInfo, m_Section->m_RegEnter)) + { + return false; + } m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } @@ -5585,7 +5937,10 @@ bool CArmRecompilerOps::InheritParentInfo() //x86Reg MemoryStackPos; int i2; - if (i == (size_t)FirstParent) { continue; } + if (i == (size_t)FirstParent) + { + continue; + } Parent = ParentList[i].Parent; if (Parent->m_CompiledLocation == nullptr) { @@ -5593,7 +5948,10 @@ bool CArmRecompilerOps::InheritParentInfo() } CRegInfo * RegSet = &ParentList[i].JumpInfo->RegSet; - if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } + if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) + { + m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); + } // Find parent MapRegState /*MemoryStackPos = x86_Unknown; @@ -5653,7 +6011,8 @@ bool CArmRecompilerOps::InheritParentInfo() g_Notify->BreakPoint(__FILE__, __LINE__); } } - if (IsConst(i2)) { + if (IsConst(i2)) + { if (GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) { switch (RegSet->GetMipsRegState(i2)) @@ -5727,12 +6086,18 @@ bool CArmRecompilerOps::InheritParentInfo() CRegInfo * RegSet; int i2; - if (i == (size_t)FirstParent) { continue; } + if (i == (size_t)FirstParent) + { + continue; + } Parent = ParentList[i].Parent; JumpInfo = ParentList[i].JumpInfo; RegSet = &ParentList[i].JumpInfo->RegSet; - if (JumpInfo->RegSet.GetBlockCycleCount() != 0) { NeedSync = true; } + if (JumpInfo->RegSet.GetBlockCycleCount() != 0) + { + NeedSync = true; + } #ifdef tofix for (i2 = 0; !NeedSync && i2 < 8; i2++) @@ -5759,7 +6124,10 @@ bool CArmRecompilerOps::InheritParentInfo() #endif for (i2 = 0; !NeedSync && i2 < 32; i2++) { - if (NeedSync == true) { break; } + if (NeedSync == true) + { + break; + } if (m_RegWorkingSet.GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) { NeedSync = true; @@ -5795,7 +6163,10 @@ bool CArmRecompilerOps::InheritParentInfo() g_Notify->BreakPoint(__FILE__, __LINE__); } } - if (NeedSync == false) { continue; } + if (NeedSync == false) + { + continue; + } Parent = ParentList[CurrentParent].Parent; JumpInfo = ParentList[CurrentParent].JumpInfo; m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, Label.c_str()); @@ -5828,7 +6199,7 @@ bool CArmRecompilerOps::InheritParentInfo() { UpdateCounters(m_RegWorkingSet, false, true); } - SyncRegState(m_Section->m_RegEnter); // Sync + SyncRegState(m_Section->m_RegEnter); // Sync m_Section->m_RegEnter = m_RegWorkingSet; } @@ -5878,7 +6249,7 @@ void CArmRecompilerOps::JumpToSection(CCodeSection * Section) void CArmRecompilerOps::JumpToUnknown(CJumpInfo * JumpInfo) { m_Assembler.BranchLabel20(CArmOps::CArmOps::ArmBranch_Always, JumpInfo->BranchLabel.c_str()); - JumpInfo->LinkLocation = (uint32_t*)(*g_RecompPos - 4); + JumpInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4); } void CArmRecompilerOps::SetCurrentPC(uint32_t ProgramCounter) @@ -5917,7 +6288,7 @@ PIPELINE_STAGE CArmRecompilerOps::GetNextStepType(void) return m_PipelineStage; } -const R4300iOpcode &CArmRecompilerOps::GetOpcode(void) const +const R4300iOpcode & CArmRecompilerOps::GetOpcode(void) const { return m_Opcode; } @@ -6116,7 +6487,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) PushImm32(Value); PushImm32(PAddr & 0x1FFFFFFF);*/ m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); - m_Assembler.CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); + m_Assembler.CallFunction((void *)((long **)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); m_RegWorkingSet.AfterCallDirect(); break; case 0x04040010: @@ -6139,7 +6510,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04100000: @@ -6158,7 +6532,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04300000: @@ -6273,7 +6650,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04400000: @@ -6349,7 +6729,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04500000: // AI registers @@ -6396,7 +6779,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04600000: @@ -6447,7 +6833,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04700000: @@ -6463,7 +6852,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) { g_Notify->BreakPoint(__FILE__, __LINE__); } - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } break; case 0x04800000: @@ -6618,7 +7010,7 @@ void CArmRecompilerOps::SW_Register(CArmOps::ArmReg Reg, uint32_t VAddr) Push(Reg); PushImm32(PAddr & 0x1FFFFFFF);*/ m_Assembler.MoveConstToArmReg(CArmOps::Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); - m_Assembler.CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); + m_Assembler.CallFunction((void *)((long **)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); m_RegWorkingSet.AfterCallDirect(); break; case 0x0404000C: @@ -6701,7 +7093,8 @@ void CArmRecompilerOps::SW_Register(CArmOps::ArmReg Reg, uint32_t VAddr) } break; case 0x04400000: - switch (PAddr) { + switch (PAddr) + { case 0x04400000: if (g_Plugins->Gfx()->ViStatusChanged != nullptr) { @@ -6772,7 +7165,8 @@ void CArmRecompilerOps::SW_Register(CArmOps::ArmReg Reg, uint32_t VAddr) } break; case 0x04500000: // AI registers - switch (PAddr) { + switch (PAddr) + { case 0x04500000: m_Assembler.MoveArmRegToVariable(Reg, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; case 0x04500004: m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); @@ -7014,7 +7408,10 @@ void CArmRecompilerOps::LB_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr, boo if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } return; } @@ -7044,7 +7441,10 @@ void CArmRecompilerOps::LB_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr, boo break; default: m_CodeBlock.Log(" should be loading from %08X ?", VAddr); - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } } @@ -7339,7 +7739,10 @@ void CArmRecompilerOps::LW_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr) else { m_CodeBlock.Log(" should be loading from %08X ?", VAddr); - if (HaveDebugger()) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (HaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } } } diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h index 501c28575..7166bacbc 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h @@ -1,17 +1,17 @@ #pragma once #if defined(__arm__) || defined(_M_ARM) -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include class CCodeBlock; class CCodeSection; @@ -224,8 +224,8 @@ public: const R4300iOpcode & GetOpcode(void) const; void PreCompileOpcode(void); void PostCompileOpcode(void); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason Reason); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason, CArmOps::ArmCompareType CompareType); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason Reason); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason, CArmOps::ArmCompareType CompareType); void CompileReadTLBMiss(CArmOps::ArmReg AddressReg, CArmOps::ArmReg LookUpReg); void CompileWriteTLBMiss(CArmOps::ArmReg AddressReg, CArmOps::ArmReg LookUpReg); @@ -235,43 +235,133 @@ public: void CompileExecuteBP(void); void CompileExecuteDelaySlotBP(void); - CArmOps & Assembler() { return m_Assembler; } + CArmOps & Assembler() + { + return m_Assembler; + } // Helper functions typedef CRegInfo::REG_STATE REG_STATE; - REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); } - uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); } - uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); } - int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); } - uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); } - int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); } - CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); } - CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); } + REG_STATE GetMipsRegState(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegState(Reg); + } + uint64_t GetMipsReg(int32_t Reg) + { + return m_RegWorkingSet.GetMipsReg(Reg); + } + uint32_t GetMipsRegLo(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegLo(Reg); + } + int32_t GetMipsRegLo_S(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegLo_S(Reg); + } + uint32_t GetMipsRegHi(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegHi(Reg); + } + int32_t GetMipsRegHi_S(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegHi_S(Reg); + } + CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegMapLo(Reg); + } + CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegMapHi(Reg); + } - bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); } - bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); } - bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); } - bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); } - bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); } - bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); } - bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); } - bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); } - bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); } - bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); } - void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); } - void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); } - void UnMap_GPR(uint32_t Reg, bool WriteBackValue){ m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); } - void WriteBack_GPR(uint32_t Reg, bool Unmapping){ m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping); } - CArmOps::ArmReg Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord); } - CArmOps::ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, CArmOps::ArmReg Reg = CArmOps::Arm_Any) { return m_RegWorkingSet.Map_Variable(variable, Reg); } + bool IsKnown(int32_t Reg) + { + return m_RegWorkingSet.IsKnown(Reg); + } + bool IsUnknown(int32_t Reg) + { + return m_RegWorkingSet.IsUnknown(Reg); + } + bool IsMapped(int32_t Reg) + { + return m_RegWorkingSet.IsMapped(Reg); + } + bool IsConst(int32_t Reg) + { + return m_RegWorkingSet.IsConst(Reg); + } + bool IsSigned(int32_t Reg) + { + return m_RegWorkingSet.IsSigned(Reg); + } + bool IsUnsigned(int32_t Reg) + { + return m_RegWorkingSet.IsUnsigned(Reg); + } + bool Is32Bit(int32_t Reg) + { + return m_RegWorkingSet.Is32Bit(Reg); + } + bool Is64Bit(int32_t Reg) + { + return m_RegWorkingSet.Is64Bit(Reg); + } + bool Is32BitMapped(int32_t Reg) + { + return m_RegWorkingSet.Is32BitMapped(Reg); + } + bool Is64BitMapped(int32_t Reg) + { + return m_RegWorkingSet.Is64BitMapped(Reg); + } + void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) + { + m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); + } + void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) + { + m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); + } + void UnMap_GPR(uint32_t Reg, bool WriteBackValue) + { + m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); + } + void WriteBack_GPR(uint32_t Reg, bool Unmapping) + { + m_RegWorkingSet.WriteBack_GPR(Reg, Unmapping); + } + CArmOps::ArmReg Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, bool LoadHiWord) + { + return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord); + } + CArmOps::ArmReg Map_Variable(CArmRegInfo::VARIABLE_MAPPED variable, CArmOps::ArmReg Reg = CArmOps::Arm_Any) + { + return m_RegWorkingSet.Map_Variable(variable, Reg); + } - void ResetRegProtection() { m_RegWorkingSet.ResetRegProtection(); } - void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); } + void ResetRegProtection() + { + m_RegWorkingSet.ResetRegProtection(); + } + void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) + { + m_RegWorkingSet.FixRoundModel(RoundMethod); + } - void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); } - void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); } - bool UnMap_ArmReg(CArmOps::ArmReg Reg) { return m_RegWorkingSet.UnMap_ArmReg(Reg); } + void ProtectGPR(uint32_t Reg) + { + m_RegWorkingSet.ProtectGPR(Reg); + } + void UnProtectGPR(uint32_t Reg) + { + m_RegWorkingSet.UnProtectGPR(Reg); + } + bool UnMap_ArmReg(CArmOps::ArmReg Reg) + { + return m_RegWorkingSet.UnMap_ArmReg(Reg); + } void SW(bool bCheckLLbit); void SW_Const(uint32_t Value, uint32_t VAddr); @@ -279,7 +369,7 @@ public: void LW(bool ResultSigned, bool bRecordLLBit); void LB_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr, bool SignExtend); void LW_KnownAddress(CArmOps::ArmReg Reg, uint32_t VAddr); - void CompileInterpterCall (void * Function, const char * FunctionName); + void CompileInterpterCall(void * Function, const char * FunctionName); void OverflowDelaySlot(bool TestTimer); EXIT_LIST m_ExitInfo; diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp index a4ac3615c..5b8a6eaa9 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.cpp @@ -1,10 +1,10 @@ #include "stdafx.h" #if defined(__arm__) || defined(_M_ARM) -#include #include -#include #include +#include +#include CArmRegInfo::CArmRegInfo(CCodeBlock & CodeBlock, CArmOps & Assembler) : m_CodeBlock(CodeBlock), @@ -26,7 +26,7 @@ CArmRegInfo::CArmRegInfo(CCodeBlock & CodeBlock, CArmOps & Assembler) : } } -CArmRegInfo::CArmRegInfo(const CArmRegInfo& rhs) : +CArmRegInfo::CArmRegInfo(const CArmRegInfo & rhs) : m_CodeBlock(rhs.m_CodeBlock), m_Assembler(rhs.m_CodeBlock.RecompilerOps()->Assembler()) { @@ -37,7 +37,7 @@ CArmRegInfo::~CArmRegInfo() { } -CArmRegInfo& CArmRegInfo::operator=(const CArmRegInfo& right) +CArmRegInfo & CArmRegInfo::operator=(const CArmRegInfo & right) { CRegBase::operator=(right); @@ -57,7 +57,7 @@ CArmRegInfo& CArmRegInfo::operator=(const CArmRegInfo& right) return *this; } -bool CArmRegInfo::operator==(const CArmRegInfo& right) const +bool CArmRegInfo::operator==(const CArmRegInfo & right) const { if (!CRegBase::operator==(right)) { @@ -66,16 +66,34 @@ bool CArmRegInfo::operator==(const CArmRegInfo& right) const for (int32_t count = 0; count < 32; count++) { - if (m_RegMapHi[count] != right.m_RegMapHi[count]) { return false; } - if (m_RegMapLo[count] != right.m_RegMapLo[count]) { return false; } + if (m_RegMapHi[count] != right.m_RegMapHi[count]) + { + return false; + } + if (m_RegMapLo[count] != right.m_RegMapLo[count]) + { + return false; + } } for (int32_t count = 0; count < 16; count++) { - if (m_ArmReg_MapOrder[count] != right.m_ArmReg_MapOrder[count]) { return false; } - if (m_ArmReg_Protected[count] != right.m_ArmReg_Protected[count]) { return false; } - if (m_ArmReg_MappedTo[count] != right.m_ArmReg_MappedTo[count]) { return false; } - if (m_Variable_MappedTo[count] != right.m_Variable_MappedTo[count]) { return false; } + if (m_ArmReg_MapOrder[count] != right.m_ArmReg_MapOrder[count]) + { + return false; + } + if (m_ArmReg_Protected[count] != right.m_ArmReg_Protected[count]) + { + return false; + } + if (m_ArmReg_MappedTo[count] != right.m_ArmReg_MappedTo[count]) + { + return false; + } + if (m_Variable_MappedTo[count] != right.m_Variable_MappedTo[count]) + { + return false; + } } return true; } @@ -95,18 +113,36 @@ bool CArmRegInfo::ShouldPushPopReg(CArmOps::ArmReg Reg) void CArmRegInfo::BeforeCallDirect(void) { - static uint32_t PushPopRegisterList[] = - { - CArmOps::ArmPushPop_R0, CArmOps::ArmPushPop_R1, CArmOps::ArmPushPop_R2, CArmOps::ArmPushPop_R3, CArmOps::ArmPushPop_R4, - CArmOps::ArmPushPop_R5, CArmOps::ArmPushPop_R6, CArmOps::ArmPushPop_R7, CArmOps::ArmPushPop_R8, CArmOps::ArmPushPop_R9, - CArmOps::ArmPushPop_R10, CArmOps::ArmPushPop_R11, CArmOps::ArmPushPop_R12 + static uint32_t PushPopRegisterList[] = { + CArmOps::ArmPushPop_R0, + CArmOps::ArmPushPop_R1, + CArmOps::ArmPushPop_R2, + CArmOps::ArmPushPop_R3, + CArmOps::ArmPushPop_R4, + CArmOps::ArmPushPop_R5, + CArmOps::ArmPushPop_R6, + CArmOps::ArmPushPop_R7, + CArmOps::ArmPushPop_R8, + CArmOps::ArmPushPop_R9, + CArmOps::ArmPushPop_R10, + CArmOps::ArmPushPop_R11, + CArmOps::ArmPushPop_R12, }; - static CArmOps::ArmReg RegisterList[] = - { - CArmOps::Arm_R0, CArmOps::Arm_R1, CArmOps::Arm_R2, CArmOps::Arm_R3, CArmOps::Arm_R4, - CArmOps::Arm_R5, CArmOps::Arm_R6, CArmOps::Arm_R7, CArmOps::Arm_R8, CArmOps::Arm_R9, - CArmOps::Arm_R10, CArmOps::Arm_R11, CArmOps::Arm_R12 + static CArmOps::ArmReg RegisterList[] = { + CArmOps::Arm_R0, + CArmOps::Arm_R1, + CArmOps::Arm_R2, + CArmOps::Arm_R3, + CArmOps::Arm_R4, + CArmOps::Arm_R5, + CArmOps::Arm_R6, + CArmOps::Arm_R7, + CArmOps::Arm_R8, + CArmOps::Arm_R9, + CArmOps::Arm_R10, + CArmOps::Arm_R11, + CArmOps::Arm_R12, }; if (m_InCallDirect) @@ -119,7 +155,10 @@ void CArmRegInfo::BeforeCallDirect(void) int PushPopRegisters = 0; for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) { - if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; } + if (ShouldPushPopReg(RegisterList[i])) + { + PushPopRegisters |= PushPopRegisterList[i]; + } } if (PushPopRegisters == 0) @@ -148,7 +187,10 @@ void CArmRegInfo::BeforeCallDirect(void) PushPopRegisters = 0; for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) { - if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; } + if (ShouldPushPopReg(RegisterList[i])) + { + PushPopRegisters |= PushPopRegisterList[i]; + } } } if ((m_Assembler.PushPopRegisterSize(PushPopRegisters) % 8) != 0) @@ -162,18 +204,40 @@ void CArmRegInfo::BeforeCallDirect(void) void CArmRegInfo::AfterCallDirect(void) { - static uint32_t PushPopRegisterList[] = - { - CArmOps::ArmPushPop_R0, CArmOps::ArmPushPop_R1, CArmOps::ArmPushPop_R2, CArmOps::ArmPushPop_R3, CArmOps::ArmPushPop_R4, - CArmOps::ArmPushPop_R5, CArmOps::ArmPushPop_R6, CArmOps::ArmPushPop_R7, CArmOps::ArmPushPop_R8, CArmOps::ArmPushPop_R9, - CArmOps::ArmPushPop_R10, CArmOps::ArmPushPop_R11, CArmOps::ArmPushPop_R12, CArmOps::ArmPushPop_LR, CArmOps::ArmPushPop_PC + static uint32_t PushPopRegisterList[] = { + CArmOps::ArmPushPop_R0, + CArmOps::ArmPushPop_R1, + CArmOps::ArmPushPop_R2, + CArmOps::ArmPushPop_R3, + CArmOps::ArmPushPop_R4, + CArmOps::ArmPushPop_R5, + CArmOps::ArmPushPop_R6, + CArmOps::ArmPushPop_R7, + CArmOps::ArmPushPop_R8, + CArmOps::ArmPushPop_R9, + CArmOps::ArmPushPop_R10, + CArmOps::ArmPushPop_R11, + CArmOps::ArmPushPop_R12, + CArmOps::ArmPushPop_LR, + CArmOps::ArmPushPop_PC, }; - static CArmOps::ArmReg RegisterList[] = - { - CArmOps::Arm_R0, CArmOps::Arm_R1, CArmOps::Arm_R2, CArmOps::Arm_R3, CArmOps::Arm_R4, - CArmOps::Arm_R5, CArmOps::Arm_R6, CArmOps::Arm_R7, CArmOps::Arm_R8, CArmOps::Arm_R9, - CArmOps::Arm_R10, CArmOps::Arm_R11, CArmOps::Arm_R12, CArmOps::ArmRegLR, CArmOps::ArmRegPC, + static CArmOps::ArmReg RegisterList[] = { + CArmOps::Arm_R0, + CArmOps::Arm_R1, + CArmOps::Arm_R2, + CArmOps::Arm_R3, + CArmOps::Arm_R4, + CArmOps::Arm_R5, + CArmOps::Arm_R6, + CArmOps::Arm_R7, + CArmOps::Arm_R8, + CArmOps::Arm_R9, + CArmOps::Arm_R10, + CArmOps::Arm_R11, + CArmOps::Arm_R12, + CArmOps::ArmRegLR, + CArmOps::ArmRegPC, }; if (!m_InCallDirect) @@ -186,7 +250,10 @@ void CArmRegInfo::AfterCallDirect(void) int PushPopRegisters = 0; for (int i = 0; i < (sizeof(RegisterList) / sizeof(RegisterList[0])); i++) { - if (ShouldPushPopReg(RegisterList[i])) { PushPopRegisters |= PushPopRegisterList[i]; } + if (ShouldPushPopReg(RegisterList[i])) + { + PushPopRegisters |= PushPopRegisterList[i]; + } } if (PushPopRegisters != 0) @@ -227,7 +294,7 @@ void CArmRegInfo::FixRoundModel(FPU_ROUND RoundMethod) if (RoundMethod == RoundDefault) { BeforeCallDirect(); - m_Assembler.MoveVariableToArmReg(_RoundingModel, "_RoundingModel", CArmOps::Arm_R0); + m_Assembler.MoveVariableToArmReg(_RoundingModel, "_RoundingModel", CArmOps::Arm_R0); m_Assembler.CallFunction((void *)fesetround, "fesetround"); AfterCallDirect(); } @@ -258,7 +325,10 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg Reg = FreeArmReg(false); if (Reg < 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); + } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -277,7 +347,7 @@ void CArmRegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg } Reg = GetMipsRegMapLo(MipsReg); } - for (int32_t count = 0; count <= CArmOps::Arm_R15; count++) + for (int32_t count = 0; count <= CArmOps::Arm_R15; count++) { uint32_t Count = GetArmRegMapOrder((CArmOps::ArmReg)count); if (Count > 0) @@ -331,7 +401,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) if (MipsReg == 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nWhy are you trying to map register 0?"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_64bit\n\nWhy are you trying to map register 0?"); + } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -342,7 +415,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) regHi = FreeArmReg(false); if (regHi < 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); + } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -351,7 +427,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) reglo = FreeArmReg(false); if (reglo < 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); + } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -369,7 +448,10 @@ void CArmRegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) regHi = FreeArmReg(false); if (regHi < 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); + } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -475,7 +557,10 @@ void CArmRegInfo::UnMap_GPR(uint32_t MipsReg, bool WriteBackValue) return; } - if (IsUnknown(MipsReg)) { return; } + if (IsUnknown(MipsReg)) + { + return; + } //m_CodeBlock.Log("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"true":"false"); if (IsConst(MipsReg)) { @@ -582,9 +667,18 @@ void CArmRegInfo::WriteBackRegisters() UnMap_AllFPRs(); int32_t ArmRegCount = sizeof(m_ArmReg_MappedTo) / sizeof(m_ArmReg_MappedTo[0]); - for (int32_t i = 1; i < 32; i++) { UnMap_GPR(i, true); } - for (int32_t i = 0; i < ArmRegCount; i++) { UnMap_ArmReg((CArmOps::ArmReg)i); } - for (int32_t i = 0; i < ArmRegCount; i++) { SetArmRegProtected((CArmOps::ArmReg)i, false); } + for (int32_t i = 1; i < 32; i++) + { + UnMap_GPR(i, true); + } + for (int32_t i = 0; i < ArmRegCount; i++) + { + UnMap_ArmReg((CArmOps::ArmReg)i); + } + for (int32_t i = 0; i < ArmRegCount; i++) + { + SetArmRegProtected((CArmOps::ArmReg)i, false); + } for (int32_t count = 1; count < 32; count++) { @@ -628,21 +722,57 @@ CArmOps::ArmReg CArmRegInfo::UnMap_TempReg(bool TempMapping) } CArmOps::ArmReg Reg = CArmOps::Arm_Unknown; - if (GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R7)) { return CArmOps::Arm_R7; } - if (GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R6)) { return CArmOps::Arm_R6; } - if (GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R5)) { return CArmOps::Arm_R5; } - if (GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R4)) { return CArmOps::Arm_R4; } - if (GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R3)) { return CArmOps::Arm_R3; } - if (GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R2)) { return CArmOps::Arm_R2; } - if (GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R1)) { return CArmOps::Arm_R1; } - if (GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R0)) { return CArmOps::Arm_R0; } + if (GetArmRegMapped(CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R7)) + { + return CArmOps::Arm_R7; + } + if (GetArmRegMapped(CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R6)) + { + return CArmOps::Arm_R6; + } + if (GetArmRegMapped(CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R5)) + { + return CArmOps::Arm_R5; + } + if (GetArmRegMapped(CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R4)) + { + return CArmOps::Arm_R4; + } + if (GetArmRegMapped(CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R3)) + { + return CArmOps::Arm_R3; + } + if (GetArmRegMapped(CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R2)) + { + return CArmOps::Arm_R2; + } + if (GetArmRegMapped(CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R1)) + { + return CArmOps::Arm_R1; + } + if (GetArmRegMapped(CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R0)) + { + return CArmOps::Arm_R0; + } if (TempMapping) { - if (GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R11)) { return CArmOps::Arm_R11; } - if (GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R10)) { return CArmOps::Arm_R10; } + if (GetArmRegMapped(CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R11)) + { + return CArmOps::Arm_R11; + } + if (GetArmRegMapped(CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R10)) + { + return CArmOps::Arm_R10; + } + } + if (GetArmRegMapped(CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R9)) + { + return CArmOps::Arm_R9; + } + if (GetArmRegMapped(CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R8)) + { + return CArmOps::Arm_R8; } - if (GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R9)) { return CArmOps::Arm_R9; } - if (GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R8)) { return CArmOps::Arm_R8; } if (Reg != CArmOps::Arm_Unknown) { @@ -742,34 +872,73 @@ CArmOps::ArmReg CArmRegInfo::FreeArmReg(bool TempMapping) g_Notify->BreakPoint(__FILE__, __LINE__); return CArmOps::Arm_Unknown; } - if ((GetArmRegMapped( CArmOps::Arm_R7) == NotMapped || GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R7)) { return CArmOps::Arm_R7; } - if ((GetArmRegMapped( CArmOps::Arm_R6) == NotMapped || GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R6)) { return CArmOps::Arm_R6; } - if ((GetArmRegMapped( CArmOps::Arm_R5) == NotMapped || GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R5)) { return CArmOps::Arm_R5; } - if ((GetArmRegMapped( CArmOps::Arm_R4) == NotMapped || GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R4)) { return CArmOps::Arm_R4; } - if ((GetArmRegMapped( CArmOps::Arm_R3) == NotMapped || GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R3)) { return CArmOps::Arm_R3; } - if ((GetArmRegMapped( CArmOps::Arm_R2) == NotMapped || GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R2)) { return CArmOps::Arm_R2; } - if ((GetArmRegMapped( CArmOps::Arm_R1) == NotMapped || GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R1)) { return CArmOps::Arm_R1; } - if ((GetArmRegMapped( CArmOps::Arm_R0) == NotMapped || GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R0)) { return CArmOps::Arm_R0; } + if ((GetArmRegMapped(CArmOps::Arm_R7) == NotMapped || GetArmRegMapped(CArmOps::Arm_R7) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R7)) + { + return CArmOps::Arm_R7; + } + if ((GetArmRegMapped(CArmOps::Arm_R6) == NotMapped || GetArmRegMapped(CArmOps::Arm_R6) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R6)) + { + return CArmOps::Arm_R6; + } + if ((GetArmRegMapped(CArmOps::Arm_R5) == NotMapped || GetArmRegMapped(CArmOps::Arm_R5) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R5)) + { + return CArmOps::Arm_R5; + } + if ((GetArmRegMapped(CArmOps::Arm_R4) == NotMapped || GetArmRegMapped(CArmOps::Arm_R4) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R4)) + { + return CArmOps::Arm_R4; + } + if ((GetArmRegMapped(CArmOps::Arm_R3) == NotMapped || GetArmRegMapped(CArmOps::Arm_R3) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R3)) + { + return CArmOps::Arm_R3; + } + if ((GetArmRegMapped(CArmOps::Arm_R2) == NotMapped || GetArmRegMapped(CArmOps::Arm_R2) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R2)) + { + return CArmOps::Arm_R2; + } + if ((GetArmRegMapped(CArmOps::Arm_R1) == NotMapped || GetArmRegMapped(CArmOps::Arm_R1) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R1)) + { + return CArmOps::Arm_R1; + } + if ((GetArmRegMapped(CArmOps::Arm_R0) == NotMapped || GetArmRegMapped(CArmOps::Arm_R0) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R0)) + { + return CArmOps::Arm_R0; + } if (TempMapping) { - if ((GetArmRegMapped( CArmOps::Arm_R11) == NotMapped || GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R11)) { return CArmOps::Arm_R11; } - if ((GetArmRegMapped( CArmOps::Arm_R10) == NotMapped || GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R10)) { return CArmOps::Arm_R10; } + if ((GetArmRegMapped(CArmOps::Arm_R11) == NotMapped || GetArmRegMapped(CArmOps::Arm_R11) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R11)) + { + return CArmOps::Arm_R11; + } + if ((GetArmRegMapped(CArmOps::Arm_R10) == NotMapped || GetArmRegMapped(CArmOps::Arm_R10) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R10)) + { + return CArmOps::Arm_R10; + } + } + if ((GetArmRegMapped(CArmOps::Arm_R9) == NotMapped || GetArmRegMapped(CArmOps::Arm_R9) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R9)) + { + return CArmOps::Arm_R9; + } + if ((GetArmRegMapped(CArmOps::Arm_R8) == NotMapped || GetArmRegMapped(CArmOps::Arm_R8) == Temp_Mapped) && !GetArmRegProtected(CArmOps::Arm_R8)) + { + return CArmOps::Arm_R8; } - if ((GetArmRegMapped( CArmOps::Arm_R9) == NotMapped || GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R9)) { return CArmOps::Arm_R9; } - if ((GetArmRegMapped( CArmOps::Arm_R8) == NotMapped || GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped) && !GetArmRegProtected( CArmOps::Arm_R8)) { return CArmOps::Arm_R8; } CArmOps::ArmReg Reg = UnMap_TempReg(TempMapping); - if (Reg != CArmOps::Arm_Unknown) { return Reg; } + if (Reg != CArmOps::Arm_Unknown) + { + return Reg; + } - int32_t MapCount[ CArmOps::Arm_R12]; - CArmOps::ArmReg MapReg[ CArmOps::Arm_R12]; + int32_t MapCount[CArmOps::Arm_R12]; + CArmOps::ArmReg MapReg[CArmOps::Arm_R12]; - for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) + for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) { MapCount[i] = GetArmRegMapOrder((CArmOps::ArmReg)i); MapReg[i] = (CArmOps::ArmReg)i; } - for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) + for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) { bool changed = false; for (int32_t z = 0; z < n - 1; z++) @@ -792,7 +961,7 @@ CArmOps::ArmReg CArmRegInfo::FreeArmReg(bool TempMapping) } } - for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) + for (int32_t i = 0, n = TempMapping ? CArmOps::Arm_R12 : CArmOps::Arm_R10; i < n; i++) { if (((MapCount[i] > 0 && GetArmRegMapped(MapReg[i]) == GPR_Mapped) || GetArmRegMapped(MapReg[i]) == Variable_Mapped) && !GetArmRegProtected((CArmOps::ArmReg)MapReg[i])) { @@ -842,13 +1011,12 @@ void CArmRegInfo::LogRegisterState(void) } m_CodeBlock.Log("GetArmRegMapped(%s) = %X%s%s Protected: %s MapOrder: %d", - m_Assembler.ArmRegName((CArmOps::ArmReg)i), - GetArmRegMapped((CArmOps::ArmReg)i), - GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", - regname.length() > 0 ? stdstr_f(" (%s)", regname.c_str()).c_str() : "", - GetArmRegProtected((CArmOps::ArmReg)i) ? "true" : "false", - GetArmRegMapOrder((CArmOps::ArmReg)i) - ); + m_Assembler.ArmRegName((CArmOps::ArmReg)i), + GetArmRegMapped((CArmOps::ArmReg)i), + GetArmRegMapped((CArmOps::ArmReg)i) == CArmRegInfo::Variable_Mapped ? stdstr_f(" (%s)", CArmRegInfo::VariableMapName(GetVariableMappedTo((CArmOps::ArmReg)i))).c_str() : "", + regname.length() > 0 ? stdstr_f(" (%s)", regname.c_str()).c_str() : "", + GetArmRegProtected((CArmOps::ArmReg)i) ? "true" : "false", + GetArmRegMapOrder((CArmOps::ArmReg)i)); } } @@ -864,18 +1032,54 @@ CArmOps::ArmReg CArmRegInfo::Map_TempReg(CArmOps::ArmReg Reg, int32_t MipsReg, b if (Reg == CArmOps::Arm_Any) { - if (GetArmRegMapped( CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R7)) { Reg = CArmOps::Arm_R7; } - else if (GetArmRegMapped( CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R6)) { Reg = CArmOps::Arm_R6; } - else if (GetArmRegMapped( CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R5)) { Reg = CArmOps::Arm_R5; } - else if (GetArmRegMapped( CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R4)) { Reg = CArmOps::Arm_R4; } - else if (GetArmRegMapped( CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R3)) { Reg = CArmOps::Arm_R3; } - else if (GetArmRegMapped( CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R2)) { Reg = CArmOps::Arm_R2; } - else if (GetArmRegMapped( CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R1)) { Reg = CArmOps::Arm_R1; } - else if (GetArmRegMapped( CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R0)) { Reg = CArmOps::Arm_R0; } - else if (GetArmRegMapped( CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R11)) { Reg = CArmOps::Arm_R11; } - else if (GetArmRegMapped( CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R10)) { Reg = CArmOps::Arm_R10; } - else if (GetArmRegMapped( CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R9)) { Reg = CArmOps::Arm_R9; } - else if (GetArmRegMapped( CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected( CArmOps::Arm_R8)) { Reg = CArmOps::Arm_R8; } + if (GetArmRegMapped(CArmOps::Arm_R7) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R7)) + { + Reg = CArmOps::Arm_R7; + } + else if (GetArmRegMapped(CArmOps::Arm_R6) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R6)) + { + Reg = CArmOps::Arm_R6; + } + else if (GetArmRegMapped(CArmOps::Arm_R5) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R5)) + { + Reg = CArmOps::Arm_R5; + } + else if (GetArmRegMapped(CArmOps::Arm_R4) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R4)) + { + Reg = CArmOps::Arm_R4; + } + else if (GetArmRegMapped(CArmOps::Arm_R3) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R3)) + { + Reg = CArmOps::Arm_R3; + } + else if (GetArmRegMapped(CArmOps::Arm_R2) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R2)) + { + Reg = CArmOps::Arm_R2; + } + else if (GetArmRegMapped(CArmOps::Arm_R1) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R1)) + { + Reg = CArmOps::Arm_R1; + } + else if (GetArmRegMapped(CArmOps::Arm_R0) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R0)) + { + Reg = CArmOps::Arm_R0; + } + else if (GetArmRegMapped(CArmOps::Arm_R11) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R11)) + { + Reg = CArmOps::Arm_R11; + } + else if (GetArmRegMapped(CArmOps::Arm_R10) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R10)) + { + Reg = CArmOps::Arm_R10; + } + else if (GetArmRegMapped(CArmOps::Arm_R9) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R9)) + { + Reg = CArmOps::Arm_R9; + } + else if (GetArmRegMapped(CArmOps::Arm_R8) == Temp_Mapped && !GetArmRegProtected(CArmOps::Arm_R8)) + { + Reg = CArmOps::Arm_R8; + } if (Reg == CArmOps::Arm_Any) { @@ -1013,7 +1217,7 @@ CArmOps::ArmReg CArmRegInfo::Map_Variable(VARIABLE_MAPPED variable, CArmOps::Arm return Reg; } - Reg = variable == VARIABLE_GPR ? CArmOps::Arm_R12 : FreeArmReg(false); + Reg = variable == VARIABLE_GPR ? CArmOps::Arm_R12 : FreeArmReg(false); if (Reg == CArmOps::Arm_Unknown) { WriteTrace(TraceRegisterCache, TraceError, "Failed to find a free register"); @@ -1035,13 +1239,34 @@ CArmOps::ArmReg CArmRegInfo::Map_Variable(VARIABLE_MAPPED variable, CArmOps::Arm m_CodeBlock.Log(" regcache: allocate %s as pointer to %s", m_Assembler.ArmRegName(Reg), VariableMapName(variable)); m_Variable_MappedTo[Reg] = variable; - if (variable == VARIABLE_GPR) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_GPR, "_GPR"); } - else if (variable == VARIABLE_FPR) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_FPR_S, "_FPR_S"); } - else if (variable == VARIABLE_TLB_READMAP) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_ReadMap), "MMU->TLB_ReadMap"); } - else if (variable == VARIABLE_TLB_WRITEMAP) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_WriteMap), "MMU->m_TLB_WriteMap"); } - else if (variable == VARIABLE_TLB_LOAD_ADDRESS) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBLoadAddress), "g_TLBLoadAddress"); } - else if (variable == VARIABLE_TLB_STORE_ADDRESS) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBStoreAddress), "g_TLBStoreAddress"); } - else if (variable == VARIABLE_NEXT_TIMER) { m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_NextTimer), "g_NextTimer"); } + if (variable == VARIABLE_GPR) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_GPR, "_GPR"); + } + else if (variable == VARIABLE_FPR) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)_FPR_S, "_FPR_S"); + } + else if (variable == VARIABLE_TLB_READMAP) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_ReadMap), "MMU->TLB_ReadMap"); + } + else if (variable == VARIABLE_TLB_WRITEMAP) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_MMU->m_TLB_WriteMap), "MMU->m_TLB_WriteMap"); + } + else if (variable == VARIABLE_TLB_LOAD_ADDRESS) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBLoadAddress), "g_TLBLoadAddress"); + } + else if (variable == VARIABLE_TLB_STORE_ADDRESS) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_TLBStoreAddress), "g_TLBStoreAddress"); + } + else if (variable == VARIABLE_NEXT_TIMER) + { + m_Assembler.MoveConstToArmReg(Reg, (uint32_t)(g_NextTimer), "g_NextTimer"); + } else { g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h index 1c100b842..16e39c8cd 100644 --- a/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/Arm/ArmRegInfo.h @@ -1,8 +1,8 @@ #pragma once #if defined(__arm__) || defined(_M_ARM) -#include -#include #include +#include +#include class CArmRegInfo : public CRegBase, @@ -32,13 +32,13 @@ public: }; CArmRegInfo(CCodeBlock & CodeBlock, CArmOps & Assembler); - CArmRegInfo(const CArmRegInfo&); + CArmRegInfo(const CArmRegInfo &); ~CArmRegInfo(); - CArmRegInfo& operator=(const CArmRegInfo&); + CArmRegInfo & operator=(const CArmRegInfo &); - bool operator==(const CArmRegInfo& right) const; - bool operator!=(const CArmRegInfo& right) const; + bool operator==(const CArmRegInfo & right) const; + bool operator!=(const CArmRegInfo & right) const; void BeforeCallDirect(void); void AfterCallDirect(void); @@ -61,21 +61,57 @@ public: bool UnMap_ArmReg(CArmOps::ArmReg Reg); void ResetRegProtection(); - inline CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; } - inline CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; } - inline void SetMipsRegMapLo(int32_t GetMipsReg, CArmOps::ArmReg Reg) { m_RegMapLo[GetMipsReg] = Reg; } - inline void SetMipsRegMapHi(int32_t GetMipsReg, CArmOps::ArmReg Reg) { m_RegMapHi[GetMipsReg] = Reg; } + inline CArmOps::ArmReg GetMipsRegMapLo(int32_t Reg) const + { + return m_RegMapLo[Reg]; + } + inline CArmOps::ArmReg GetMipsRegMapHi(int32_t Reg) const + { + return m_RegMapHi[Reg]; + } + inline void SetMipsRegMapLo(int32_t GetMipsReg, CArmOps::ArmReg Reg) + { + m_RegMapLo[GetMipsReg] = Reg; + } + inline void SetMipsRegMapHi(int32_t GetMipsReg, CArmOps::ArmReg Reg) + { + m_RegMapHi[GetMipsReg] = Reg; + } - inline uint32_t GetArmRegMapOrder(CArmOps::ArmReg Reg) const { return m_ArmReg_MapOrder[Reg]; } - inline bool GetArmRegProtected(CArmOps::ArmReg Reg) const { return m_ArmReg_Protected[Reg]; } - inline REG_MAPPED GetArmRegMapped(CArmOps::ArmReg Reg) const { return m_ArmReg_MappedTo[Reg]; } + inline uint32_t GetArmRegMapOrder(CArmOps::ArmReg Reg) const + { + return m_ArmReg_MapOrder[Reg]; + } + inline bool GetArmRegProtected(CArmOps::ArmReg Reg) const + { + return m_ArmReg_Protected[Reg]; + } + inline REG_MAPPED GetArmRegMapped(CArmOps::ArmReg Reg) const + { + return m_ArmReg_MappedTo[Reg]; + } - inline void SetArmRegMapOrder(CArmOps::ArmReg Reg, uint32_t Order) { m_ArmReg_MapOrder[Reg] = Order; } - inline void SetArmRegProtected(CArmOps::ArmReg Reg, bool Protected) { m_ArmReg_Protected[Reg] = Protected; } - inline void SetArmRegMapped(CArmOps::ArmReg Reg, REG_MAPPED Mapping) { m_ArmReg_MappedTo[Reg] = Mapping; } + inline void SetArmRegMapOrder(CArmOps::ArmReg Reg, uint32_t Order) + { + m_ArmReg_MapOrder[Reg] = Order; + } + inline void SetArmRegProtected(CArmOps::ArmReg Reg, bool Protected) + { + m_ArmReg_Protected[Reg] = Protected; + } + inline void SetArmRegMapped(CArmOps::ArmReg Reg, REG_MAPPED Mapping) + { + m_ArmReg_MappedTo[Reg] = Mapping; + } - inline VARIABLE_MAPPED GetVariableMappedTo(CArmOps::ArmReg Reg) const { return m_Variable_MappedTo[Reg]; } - inline void SetVariableMappedTo(CArmOps::ArmReg Reg, VARIABLE_MAPPED variable) { m_Variable_MappedTo[Reg] = variable; } + inline VARIABLE_MAPPED GetVariableMappedTo(CArmOps::ArmReg Reg) const + { + return m_Variable_MappedTo[Reg]; + } + inline void SetVariableMappedTo(CArmOps::ArmReg Reg, VARIABLE_MAPPED variable) + { + m_Variable_MappedTo[Reg] = variable; + } static const char * VariableMapName(VARIABLE_MAPPED variable); void LogRegisterState(void); @@ -86,7 +122,7 @@ private: CCodeBlock & m_CodeBlock; CArmOps & m_Assembler; - bool ShouldPushPopReg (CArmOps::ArmReg Reg); + bool ShouldPushPopReg(CArmOps::ArmReg Reg); CArmOps::ArmReg m_RegMapHi[32]; CArmOps::ArmReg m_RegMapLo[32]; diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp index 529dbbd28..b94861f81 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp @@ -1,15 +1,16 @@ #include "stdafx.h" -#include + +#include +#include +#include #include #include -#include #include -#include -#include +#include #if defined(ANDROID) && (defined(__arm__) || defined(_M_ARM)) /* bug-fix to implement __clear_cache (missing in Android; http://code.google.com/p/android/issues/detail?id=1803) */ -extern "C" void __clear_cache_android(uint8_t* begin, uint8_t *end); +extern "C" void __clear_cache_android(uint8_t * begin, uint8_t * end); #endif CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, uint32_t VAddrEnter, uint8_t * CompiledLocation) : @@ -26,7 +27,7 @@ CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, uint32_t VAddrEnter, uint8_t * Compi // Make sure function starts at an odd address so that the system knows it is in thumb mode if (((uint32_t)m_CompiledLocation % 2) == 0) { - m_CompiledLocation+=1; + m_CompiledLocation += 1; } #endif #if defined(__i386__) || defined(_M_IX86) @@ -97,7 +98,7 @@ CCodeBlock::~CCodeBlock() } } -bool CCodeBlock::SetSection(CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC) +bool CCodeBlock::SetSection(CCodeSection *& Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC) { if (Section != nullptr) { @@ -451,22 +452,53 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & case R4300i_SPECIAL: switch (Command.funct) { - case R4300i_SPECIAL_SLL: case R4300i_SPECIAL_SRL: case R4300i_SPECIAL_SRA: - case R4300i_SPECIAL_SLLV: case R4300i_SPECIAL_SRLV: case R4300i_SPECIAL_SRAV: - case R4300i_SPECIAL_MFHI: case R4300i_SPECIAL_MTHI: case R4300i_SPECIAL_MFLO: - case R4300i_SPECIAL_MTLO: case R4300i_SPECIAL_DSLLV: case R4300i_SPECIAL_DSRLV: - case R4300i_SPECIAL_DSRAV: case R4300i_SPECIAL_ADD: case R4300i_SPECIAL_ADDU: - case R4300i_SPECIAL_SUB: case R4300i_SPECIAL_SUBU: case R4300i_SPECIAL_AND: - case R4300i_SPECIAL_OR: case R4300i_SPECIAL_XOR: case R4300i_SPECIAL_NOR: - case R4300i_SPECIAL_SLT: case R4300i_SPECIAL_SLTU: case R4300i_SPECIAL_DADD: - case R4300i_SPECIAL_DADDU: case R4300i_SPECIAL_DSUB: case R4300i_SPECIAL_DSUBU: - case R4300i_SPECIAL_DSLL: case R4300i_SPECIAL_DSRL: case R4300i_SPECIAL_DSRA: - case R4300i_SPECIAL_DSLL32: case R4300i_SPECIAL_DSRL32: case R4300i_SPECIAL_DSRA32: - case R4300i_SPECIAL_MULT: case R4300i_SPECIAL_MULTU: case R4300i_SPECIAL_DIV: - case R4300i_SPECIAL_DIVU: case R4300i_SPECIAL_DMULT: case R4300i_SPECIAL_DMULTU: - case R4300i_SPECIAL_DDIV: case R4300i_SPECIAL_DDIVU: case R4300i_SPECIAL_TEQ: - case R4300i_SPECIAL_TNE: case R4300i_SPECIAL_TGE: case R4300i_SPECIAL_TGEU: - case R4300i_SPECIAL_TLT: case R4300i_SPECIAL_TLTU: + case R4300i_SPECIAL_SLL: + case R4300i_SPECIAL_SRL: + case R4300i_SPECIAL_SRA: + case R4300i_SPECIAL_SLLV: + case R4300i_SPECIAL_SRLV: + case R4300i_SPECIAL_SRAV: + case R4300i_SPECIAL_MFHI: + case R4300i_SPECIAL_MTHI: + case R4300i_SPECIAL_MFLO: + case R4300i_SPECIAL_MTLO: + case R4300i_SPECIAL_DSLLV: + case R4300i_SPECIAL_DSRLV: + case R4300i_SPECIAL_DSRAV: + case R4300i_SPECIAL_ADD: + case R4300i_SPECIAL_ADDU: + case R4300i_SPECIAL_SUB: + case R4300i_SPECIAL_SUBU: + case R4300i_SPECIAL_AND: + case R4300i_SPECIAL_OR: + case R4300i_SPECIAL_XOR: + case R4300i_SPECIAL_NOR: + case R4300i_SPECIAL_SLT: + case R4300i_SPECIAL_SLTU: + case R4300i_SPECIAL_DADD: + case R4300i_SPECIAL_DADDU: + case R4300i_SPECIAL_DSUB: + case R4300i_SPECIAL_DSUBU: + case R4300i_SPECIAL_DSLL: + case R4300i_SPECIAL_DSRL: + case R4300i_SPECIAL_DSRA: + case R4300i_SPECIAL_DSLL32: + case R4300i_SPECIAL_DSRL32: + case R4300i_SPECIAL_DSRA32: + case R4300i_SPECIAL_MULT: + case R4300i_SPECIAL_MULTU: + case R4300i_SPECIAL_DIV: + case R4300i_SPECIAL_DIVU: + case R4300i_SPECIAL_DMULT: + case R4300i_SPECIAL_DMULTU: + case R4300i_SPECIAL_DDIV: + case R4300i_SPECIAL_DDIVU: + case R4300i_SPECIAL_TEQ: + case R4300i_SPECIAL_TNE: + case R4300i_SPECIAL_TGE: + case R4300i_SPECIAL_TGEU: + case R4300i_SPECIAL_TLT: + case R4300i_SPECIAL_TLTU: break; case R4300i_SPECIAL_JALR: case R4300i_SPECIAL_JR: @@ -563,8 +595,12 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & LikelyBranch = true; IncludeDelaySlot = true; break; - case R4300i_REGIMM_TEQI: case R4300i_REGIMM_TNEI: case R4300i_REGIMM_TGEI: - case R4300i_REGIMM_TGEIU: case R4300i_REGIMM_TLTI: case R4300i_REGIMM_TLTIU: + case R4300i_REGIMM_TEQI: + case R4300i_REGIMM_TNEI: + case R4300i_REGIMM_TGEI: + case R4300i_REGIMM_TGEIU: + case R4300i_REGIMM_TLTI: + case R4300i_REGIMM_TLTIU: break; default: if (Command.Value == 0x0407000D) @@ -601,8 +637,8 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC = PC + 8; } R4300iOpcode DelaySlot; - if (TargetPC == PC && - g_MMU->MemoryValue32(PC + 4, DelaySlot.Value) && + if (TargetPC == PC && + g_MMU->MemoryValue32(PC + 4, DelaySlot.Value) && !R4300iInstruction(PC, Command.Value).DelaySlotEffectsCompare(DelaySlot.Value)) { PermLoop = true; @@ -639,15 +675,18 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & case R4300i_CP0: switch (Command.rs) { - case R4300i_COP0_MT: case R4300i_COP0_MF: + case R4300i_COP0_MT: + case R4300i_COP0_MF: break; default: if ((Command.rs & 0x10) != 0) { switch (Command.funct) { - case R4300i_COP0_CO_TLBR: case R4300i_COP0_CO_TLBWI: - case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP: + case R4300i_COP0_CO_TLBR: + case R4300i_COP0_CO_TLBWI: + case R4300i_COP0_CO_TLBWR: + case R4300i_COP0_CO_TLBP: break; case R4300i_COP0_CO_ERET: EndBlock = true; @@ -668,12 +707,20 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & case R4300i_CP1: switch (Command.fmt) { - case R4300i_COP1_MF: case R4300i_COP1_DMF: case R4300i_COP1_CF: case R4300i_COP1_MT: - case R4300i_COP1_DMT: case R4300i_COP1_CT: case R4300i_COP1_S: case R4300i_COP1_D: - case R4300i_COP1_W: case R4300i_COP1_L: + case R4300i_COP1_MF: + case R4300i_COP1_DMF: + case R4300i_COP1_CF: + case R4300i_COP1_MT: + case R4300i_COP1_DMT: + case R4300i_COP1_CT: + case R4300i_COP1_S: + case R4300i_COP1_D: + case R4300i_COP1_W: + case R4300i_COP1_L: break; case R4300i_COP1_BC: - switch (Command.ft) { + switch (Command.ft) + { case R4300i_COP1_BC_BCF: case R4300i_COP1_BC_BCT: TargetPC = PC + ((int16_t)Command.offset << 2) + 4; @@ -711,15 +758,42 @@ bool CCodeBlock::AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & return false; } break; - case R4300i_ANDI: case R4300i_ORI: case R4300i_XORI: case R4300i_LUI: - case R4300i_ADDI: case R4300i_ADDIU: case R4300i_SLTI: case R4300i_SLTIU: - case R4300i_DADDI: case R4300i_DADDIU: case R4300i_LDL: case R4300i_LDR: - case R4300i_LB: case R4300i_LH: case R4300i_LWL: case R4300i_LW: - case R4300i_LBU: case R4300i_LHU: case R4300i_LWR: case R4300i_LWU: - case R4300i_SB: case R4300i_SH: case R4300i_SWL: case R4300i_SW: - case R4300i_SDL: case R4300i_SDR: case R4300i_SWR: case R4300i_CACHE: - case R4300i_LL: case R4300i_LWC1: case R4300i_LDC1: case R4300i_LD: - case R4300i_SC: case R4300i_SWC1: case R4300i_SDC1: case R4300i_SD: + case R4300i_ANDI: + case R4300i_ORI: + case R4300i_XORI: + case R4300i_LUI: + case R4300i_ADDI: + case R4300i_ADDIU: + case R4300i_SLTI: + case R4300i_SLTIU: + case R4300i_DADDI: + case R4300i_DADDIU: + case R4300i_LDL: + case R4300i_LDR: + case R4300i_LB: + case R4300i_LH: + case R4300i_LWL: + case R4300i_LW: + case R4300i_LBU: + case R4300i_LHU: + case R4300i_LWR: + case R4300i_LWU: + case R4300i_SB: + case R4300i_SH: + case R4300i_SWL: + case R4300i_SW: + case R4300i_SDL: + case R4300i_SDR: + case R4300i_SWR: + case R4300i_CACHE: + case R4300i_LL: + case R4300i_LWC1: + case R4300i_LDC1: + case R4300i_LD: + case R4300i_SC: + case R4300i_SWC1: + case R4300i_SDC1: + case R4300i_SD: break; case R4300i_BEQL: TargetPC = PC + ((int16_t)Command.offset << 2) + 4; @@ -786,7 +860,8 @@ bool CCodeBlock::Compile() m_RecompilerOps->EnterCodeBlock(); if (g_System->bLinkBlocks()) { - while (m_EnterSection !=nullptr && m_EnterSection->GenerateNativeCode(NextTest())); + while (m_EnterSection != nullptr && m_EnterSection->GenerateNativeCode(NextTest())) + ; } else { @@ -807,7 +882,7 @@ bool CCodeBlock::Compile() } MD5(BlockPtr, BlockSize).get_digest(m_Hash); #if defined(ANDROID) && (defined(__arm__) || defined(_M_ARM)) - __clear_cache((uint8_t *)((uint32_t)m_CompiledLocation & ~1), m_CompiledLocationEnd); + __clear_cache((uint8_t *)((uint32_t)m_CompiledLocation & ~1), m_CompiledLocationEnd); #endif return true; } @@ -831,7 +906,7 @@ void CCodeBlock::Log(_Printf_format_string_ const char * Text, ...) #pragma warning(push) #pragma warning(disable : 4996) size_t nlen = _vscprintf(Text, args) + 1; - char * buffer = (char*)alloca(nlen * sizeof(char)); + char * buffer = (char *)alloca(nlen * sizeof(char)); buffer[nlen - 1] = 0; if (buffer != nullptr) { diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.h b/Source/Project64-core/N64System/Recompiler/CodeBlock.h index 36afeda57..e97fc3bb9 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.h +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.h @@ -1,7 +1,7 @@ #pragma once #include -#include #include +#include #if !defined(_MSC_VER) && !defined(_Printf_format_string_) #define _Printf_format_string_ @@ -17,25 +17,73 @@ public: bool Compile(); - uint32_t VAddrEnter() const { return m_VAddrEnter; } - uint32_t VAddrFirst() const { return m_VAddrFirst; } - uint32_t VAddrLast() const { return m_VAddrLast; } - uint8_t * CompiledLocation() const { return m_CompiledLocation; } - uint8_t * CompiledLocationEnd() const { return m_CompiledLocationEnd; } - int32_t NoOfSections() const { return (int32_t)m_Sections.size() - 1; } - const CCodeSection & EnterSection() const { return *m_EnterSection; } - const MD5Digest & Hash() const { return m_Hash; } - CRecompilerOps *& RecompilerOps() { return m_RecompilerOps; } - const std::string & CodeLog() const { return m_CodeLog; } + uint32_t VAddrEnter() const + { + return m_VAddrEnter; + } + uint32_t VAddrFirst() const + { + return m_VAddrFirst; + } + uint32_t VAddrLast() const + { + return m_VAddrLast; + } + uint8_t * CompiledLocation() const + { + return m_CompiledLocation; + } + uint8_t * CompiledLocationEnd() const + { + return m_CompiledLocationEnd; + } + int32_t NoOfSections() const + { + return (int32_t)m_Sections.size() - 1; + } + const CCodeSection & EnterSection() const + { + return *m_EnterSection; + } + const MD5Digest & Hash() const + { + return m_Hash; + } + CRecompilerOps *& RecompilerOps() + { + return m_RecompilerOps; + } + const std::string & CodeLog() const + { + return m_CodeLog; + } - void SetVAddrFirst(uint32_t VAddr) { m_VAddrFirst = VAddr; } - void SetVAddrLast(uint32_t VAddr) { m_VAddrLast = VAddr; } + void SetVAddrFirst(uint32_t VAddr) + { + m_VAddrFirst = VAddr; + } + void SetVAddrLast(uint32_t VAddr) + { + m_VAddrLast = VAddr; + } - CCodeSection * ExistingSection(uint32_t Addr) { return m_EnterSection->ExistingSection(Addr, NextTest()); } - bool SectionAccessible(uint32_t m_SectionID) { return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); } + CCodeSection * ExistingSection(uint32_t Addr) + { + return m_EnterSection->ExistingSection(Addr, NextTest()); + } + bool SectionAccessible(uint32_t m_SectionID) + { + return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); + } - uint64_t MemContents(int32_t i) const { return m_MemContents[i]; } - uint64_t * MemLocation(int32_t i) const { return m_MemLocation[i]; } + uint64_t MemContents(int32_t i) const + { + return m_MemContents[i]; + } + uint64_t * MemLocation(int32_t i) const + { + return m_MemLocation[i]; + } uint32_t NextTest(); @@ -43,21 +91,21 @@ public: private: CCodeBlock(); - CCodeBlock(const CCodeBlock&); - CCodeBlock& operator=(const CCodeBlock&); + CCodeBlock(const CCodeBlock &); + CCodeBlock & operator=(const CCodeBlock &); bool AnalyseBlock(); bool CreateBlockLinkage(CCodeSection * EnterSection); void DetermineLoops(); void LogSectionInfo(); - bool SetSection(CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC); + bool SetSection(CCodeSection *& Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC); bool AnalyzeInstruction(uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, bool & EndBlock, bool & PermLoop); uint32_t m_VAddrEnter; - uint32_t m_VAddrFirst; // The address of the first opcode in the block - uint32_t m_VAddrLast; // The address of the first opcode in the block - uint8_t * m_CompiledLocation; // What address is this compiled at? + uint32_t m_VAddrFirst; // The address of the first opcode in the block + uint32_t m_VAddrLast; // The address of the first opcode in the block + uint8_t * m_CompiledLocation; // What address is this compiled at? uint8_t * m_CompiledLocationEnd; // What address is this compiled at? typedef std::map SectionMap; diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp index d1210d56a..701155c22 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp @@ -1,16 +1,17 @@ #include "stdafx.h" -#include -#include -#include -#include -#include -#include -#include + +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include -#include -#include +#include CCodeSection::CCodeSection(CCodeBlock & CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed) : m_CodeBlock(CodeBlock), @@ -41,8 +42,8 @@ CCodeSection::~CCodeSection() void CCodeSection::GenerateSectionLinkage() { - CCodeSection * TargetSection[] = { m_ContinueSection, m_JumpSection }; - CJumpInfo * JumpInfo[] = { &m_Cont, &m_Jump }; + CCodeSection * TargetSection[] = {m_ContinueSection, m_JumpSection}; + CJumpInfo * JumpInfo[] = {&m_Cont, &m_Jump}; int i; for (i = 0; i < 2; i++) @@ -90,8 +91,14 @@ void CCodeSection::GenerateSectionLinkage() } else if (TargetSection[i] != nullptr && JumpInfo[i] != nullptr) { - if (!JumpInfo[i]->FallThrough) { continue; } - if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; } + if (!JumpInfo[i]->FallThrough) + { + continue; + } + if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) + { + continue; + } m_RecompilerOps->LinkJump(*JumpInfo[i], (uint32_t)-1); m_RecompilerOps->CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->Reason); //FreeSection(TargetSection[i],Section); @@ -100,9 +107,15 @@ void CCodeSection::GenerateSectionLinkage() } else { - if (m_Cont.LinkLocation == nullptr && m_Cont.FallThrough == false) { m_ContinueSection = nullptr; } - if (m_Jump.LinkLocation == nullptr && m_Jump.FallThrough == false) { m_JumpSection = nullptr; } - if (m_JumpSection == nullptr && m_ContinueSection == nullptr) + if (m_Cont.LinkLocation == nullptr && m_Cont.FallThrough == false) + { + m_ContinueSection = nullptr; + } + if (m_Jump.LinkLocation == nullptr && m_Jump.FallThrough == false) + { + m_JumpSection = nullptr; + } + if (m_JumpSection == nullptr && m_ContinueSection == nullptr) { //FreeSection(TargetSection[0],Section); } @@ -111,9 +124,16 @@ void CCodeSection::GenerateSectionLinkage() TargetSection[0] = m_ContinueSection; TargetSection[1] = m_JumpSection; - for (i = 0; i < 2; i++) { - if (TargetSection[i] == nullptr) { continue; } - if (!JumpInfo[i]->FallThrough) { continue; } + for (i = 0; i < 2; i++) + { + if (TargetSection[i] == nullptr) + { + continue; + } + if (!JumpInfo[i]->FallThrough) + { + continue; + } if (TargetSection[i]->m_CompiledLocation != nullptr) { @@ -147,14 +167,26 @@ void CCodeSection::GenerateSectionLinkage() for (i = 0; i < 2; i++) { - if (TargetSection[i] == nullptr) { continue; } - if (TargetSection[i]->m_ParentSection.empty()) { continue; } + if (TargetSection[i] == nullptr) + { + continue; + } + if (TargetSection[i]->m_ParentSection.empty()) + { + continue; + } for (SECTION_LIST::iterator iter = TargetSection[i]->m_ParentSection.begin(); iter != TargetSection[i]->m_ParentSection.end(); iter++) { CCodeSection * Parent = *iter; - if (Parent->m_CompiledLocation != nullptr) { continue; } - if (Parent->m_InLoop) { continue; } + if (Parent->m_CompiledLocation != nullptr) + { + continue; + } + if (Parent->m_InLoop) + { + continue; + } if (JumpInfo[i]->PermLoop) { m_CodeBlock.Log("PermLoop *** 2"); @@ -195,7 +227,10 @@ void CCodeSection::GenerateSectionLinkage() //CodeLog("Section %d",m_SectionID); for (i = 0; i < 2; i++) { - if (JumpInfo[i]->LinkLocation == nullptr) { continue; } + if (JumpInfo[i]->LinkLocation == nullptr) + { + continue; + } if (TargetSection[i] == nullptr) { m_CodeBlock.Log("ExitBlock (from %d):", m_SectionID); @@ -269,8 +304,14 @@ bool CCodeSection::ParentContinue() for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) { CCodeSection * Parent = *iter; - if (Parent->m_CompiledLocation != nullptr) { continue; } - if (IsAllParentLoops(Parent, true, m_CodeBlock.NextTest())) { continue; } + if (Parent->m_CompiledLocation != nullptr) + { + continue; + } + if (IsAllParentLoops(Parent, true, m_CodeBlock.NextTest())) + { + continue; + } return false; } m_RecompilerOps->SetCurrentSection(this); @@ -291,8 +332,14 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) return false; } m_Test = Test; - if (m_ContinueSection != nullptr && m_ContinueSection->GenerateNativeCode(Test)) { return true; } - if (m_JumpSection != nullptr && m_JumpSection->GenerateNativeCode(Test)) { return true; } + if (m_ContinueSection != nullptr && m_ContinueSection->GenerateNativeCode(Test)) + { + return true; + } + if (m_JumpSection != nullptr && m_JumpSection->GenerateNativeCode(Test)) + { + return true; + } return false; } @@ -389,9 +436,9 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_SPECIAL_TGEU: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TGEU); break; case R4300i_SPECIAL_TLT: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLT); break; case R4300i_SPECIAL_TLTU: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLTU); break; - break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_REGIMM: @@ -410,7 +457,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_REGIMM_TLTI: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLTI); break; case R4300i_REGIMM_TLTIU: m_RecompilerOps->Compile_TrapCompare(RecompilerTrapCompare_TLTIU); break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_BEQ: m_RecompilerOps->Compile_Branch(RecompilerBranchCompare_BEQ, false); break; @@ -468,7 +516,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_COP1_BC_BCFL: m_RecompilerOps->Compile_BranchLikely(RecompilerBranchCompare_COP1BCF, false); break; case R4300i_COP1_BC_BCTL: m_RecompilerOps->Compile_BranchLikely(RecompilerBranchCompare_COP1BCT, false); break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_COP1_S: @@ -493,17 +542,27 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_COP1_FUNCT_CVT_D: m_RecompilerOps->COP1_S_CVT_D(); break; case R4300i_COP1_FUNCT_CVT_W: m_RecompilerOps->COP1_S_CVT_W(); break; case R4300i_COP1_FUNCT_CVT_L: m_RecompilerOps->COP1_S_CVT_L(); break; - case R4300i_COP1_FUNCT_C_F: case R4300i_COP1_FUNCT_C_UN: - case R4300i_COP1_FUNCT_C_EQ: case R4300i_COP1_FUNCT_C_UEQ: - case R4300i_COP1_FUNCT_C_OLT: case R4300i_COP1_FUNCT_C_ULT: - case R4300i_COP1_FUNCT_C_OLE: case R4300i_COP1_FUNCT_C_ULE: - case R4300i_COP1_FUNCT_C_SF: case R4300i_COP1_FUNCT_C_NGLE: - case R4300i_COP1_FUNCT_C_SEQ: case R4300i_COP1_FUNCT_C_NGL: - case R4300i_COP1_FUNCT_C_LT: case R4300i_COP1_FUNCT_C_NGE: - case R4300i_COP1_FUNCT_C_LE: case R4300i_COP1_FUNCT_C_NGT: - m_RecompilerOps->COP1_S_CMP(); break; + case R4300i_COP1_FUNCT_C_F: + case R4300i_COP1_FUNCT_C_UN: + case R4300i_COP1_FUNCT_C_EQ: + case R4300i_COP1_FUNCT_C_UEQ: + case R4300i_COP1_FUNCT_C_OLT: + case R4300i_COP1_FUNCT_C_ULT: + case R4300i_COP1_FUNCT_C_OLE: + case R4300i_COP1_FUNCT_C_ULE: + case R4300i_COP1_FUNCT_C_SF: + case R4300i_COP1_FUNCT_C_NGLE: + case R4300i_COP1_FUNCT_C_SEQ: + case R4300i_COP1_FUNCT_C_NGL: + case R4300i_COP1_FUNCT_C_LT: + case R4300i_COP1_FUNCT_C_NGE: + case R4300i_COP1_FUNCT_C_LE: + case R4300i_COP1_FUNCT_C_NGT: + m_RecompilerOps->COP1_S_CMP(); + break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_COP1_D: @@ -528,17 +587,27 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_COP1_FUNCT_CVT_S: m_RecompilerOps->COP1_D_CVT_S(); break; case R4300i_COP1_FUNCT_CVT_W: m_RecompilerOps->COP1_D_CVT_W(); break; case R4300i_COP1_FUNCT_CVT_L: m_RecompilerOps->COP1_D_CVT_L(); break; - case R4300i_COP1_FUNCT_C_F: case R4300i_COP1_FUNCT_C_UN: - case R4300i_COP1_FUNCT_C_EQ: case R4300i_COP1_FUNCT_C_UEQ: - case R4300i_COP1_FUNCT_C_OLT: case R4300i_COP1_FUNCT_C_ULT: - case R4300i_COP1_FUNCT_C_OLE: case R4300i_COP1_FUNCT_C_ULE: - case R4300i_COP1_FUNCT_C_SF: case R4300i_COP1_FUNCT_C_NGLE: - case R4300i_COP1_FUNCT_C_SEQ: case R4300i_COP1_FUNCT_C_NGL: - case R4300i_COP1_FUNCT_C_LT: case R4300i_COP1_FUNCT_C_NGE: - case R4300i_COP1_FUNCT_C_LE: case R4300i_COP1_FUNCT_C_NGT: - m_RecompilerOps->COP1_D_CMP(); break; + case R4300i_COP1_FUNCT_C_F: + case R4300i_COP1_FUNCT_C_UN: + case R4300i_COP1_FUNCT_C_EQ: + case R4300i_COP1_FUNCT_C_UEQ: + case R4300i_COP1_FUNCT_C_OLT: + case R4300i_COP1_FUNCT_C_ULT: + case R4300i_COP1_FUNCT_C_OLE: + case R4300i_COP1_FUNCT_C_ULE: + case R4300i_COP1_FUNCT_C_SF: + case R4300i_COP1_FUNCT_C_NGLE: + case R4300i_COP1_FUNCT_C_SEQ: + case R4300i_COP1_FUNCT_C_NGL: + case R4300i_COP1_FUNCT_C_LT: + case R4300i_COP1_FUNCT_C_NGE: + case R4300i_COP1_FUNCT_C_LE: + case R4300i_COP1_FUNCT_C_NGT: + m_RecompilerOps->COP1_D_CMP(); + break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_COP1_W: @@ -547,7 +616,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_COP1_FUNCT_CVT_S: m_RecompilerOps->COP1_W_CVT_S(); break; case R4300i_COP1_FUNCT_CVT_D: m_RecompilerOps->COP1_W_CVT_D(); break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_COP1_L: @@ -556,11 +626,13 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_COP1_FUNCT_CVT_S: m_RecompilerOps->COP1_L_CVT_S(); break; case R4300i_COP1_FUNCT_CVT_D: m_RecompilerOps->COP1_L_CVT_D(); break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } break; case R4300i_BEQL: m_RecompilerOps->Compile_BranchLikely(RecompilerBranchCompare_BEQ, false); break; @@ -596,7 +668,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) case R4300i_SDC1: m_RecompilerOps->SDC1(); break; case R4300i_SD: m_RecompilerOps->SD(); break; default: - m_RecompilerOps->UnknownOpcode(); break; + m_RecompilerOps->UnknownOpcode(); + break; } m_RecompilerOps->PostCompileOpcode(); @@ -829,13 +902,22 @@ CCodeSection * CCodeSection::ExistingSection(uint32_t Addr, uint32_t Test) { return this; } - if (m_Test == Test) { return nullptr; } + if (m_Test == Test) + { + return nullptr; + } m_Test = Test; CCodeSection * Section = m_JumpSection ? m_JumpSection->ExistingSection(Addr, Test) : nullptr; - if (Section != nullptr) { return Section; } + if (Section != nullptr) + { + return Section; + } Section = m_ContinueSection ? m_ContinueSection->ExistingSection(Addr, Test) : nullptr; - if (Section != nullptr) { return Section; } + if (Section != nullptr) + { + return Section; + } return nullptr; } @@ -847,7 +929,10 @@ bool CCodeSection::SectionAccessible(uint32_t SectionId, uint32_t Test) return true; } - if (m_Test == Test) { return false; } + if (m_Test == Test) + { + return false; + } m_Test = Test; if (m_ContinueSection && m_ContinueSection->SectionAccessible(SectionId, Test)) @@ -937,18 +1022,39 @@ void CCodeSection::UnlinkParent(CCodeSection * Parent, bool ContinueSection) bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test) { - if (IgnoreIfCompiled && Parent->m_CompiledLocation != nullptr) { return true; } - if (!m_InLoop) { return false; } - if (!Parent->m_InLoop) { return false; } - if (Parent->m_ParentSection.empty()) { return false; } - if (this == Parent) { return true; } - if (Parent->m_Test == Test) { return true; } + if (IgnoreIfCompiled && Parent->m_CompiledLocation != nullptr) + { + return true; + } + if (!m_InLoop) + { + return false; + } + if (!Parent->m_InLoop) + { + return false; + } + if (Parent->m_ParentSection.empty()) + { + return false; + } + if (this == Parent) + { + return true; + } + if (Parent->m_Test == Test) + { + return true; + } Parent->m_Test = Test; for (SECTION_LIST::iterator iter = Parent->m_ParentSection.begin(); iter != Parent->m_ParentSection.end(); iter++) { CCodeSection * ParentSection = *iter; - if (!IsAllParentLoops(ParentSection, IgnoreIfCompiled, Test)) { return false; } + if (!IsAllParentLoops(ParentSection, IgnoreIfCompiled, Test)) + { + return false; + } } return true; } @@ -959,12 +1065,21 @@ bool CCodeSection::DisplaySectionInformation(uint32_t ID, uint32_t Test) { return false; } - if (m_Test == Test) { return false; } + if (m_Test == Test) + { + return false; + } m_Test = Test; if (m_SectionID != ID) { - if (m_ContinueSection != nullptr && m_ContinueSection->DisplaySectionInformation(ID, Test)) { return true; } - if (m_JumpSection != nullptr && m_JumpSection->DisplaySectionInformation(ID, Test)) { return true; } + if (m_ContinueSection != nullptr && m_ContinueSection->DisplaySectionInformation(ID, Test)) + { + return true; + } + if (m_JumpSection != nullptr && m_JumpSection->DisplaySectionInformation(ID, Test)) + { + return true; + } return false; } DisplaySectionInformation(); diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.h b/Source/Project64-core/N64System/Recompiler/CodeSection.h index f6cc4f540..5456f72ec 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.h +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.h @@ -35,14 +35,14 @@ public: uint32_t m_EndPC; CCodeSection * m_ContinueSection; CCodeSection * m_JumpSection; - bool m_EndSection; // If this section does not link, are other sections allowed to find block to link to it? + bool m_EndSection; // If this section does not link, are other sections allowed to find block to link to it? bool m_LinkAllowed; uint32_t m_Test; uint32_t m_Test2; uint8_t * m_CompiledLocation; bool m_InLoop; bool m_DelaySlot; - CRecompilerOps * & m_RecompilerOps; + CRecompilerOps *& m_RecompilerOps; // Register info CRegInfo m_RegEnter; @@ -53,8 +53,8 @@ public: private: CCodeSection(void); - CCodeSection(const CCodeSection&); - CCodeSection& operator=(const CCodeSection&); + CCodeSection(const CCodeSection &); + CCodeSection & operator=(const CCodeSection &); void UnlinkParent(CCodeSection * Parent, bool ContinueSection); void InheritConstants(); diff --git a/Source/Project64-core/N64System/Recompiler/ExitInfo.cpp b/Source/Project64-core/N64System/Recompiler/ExitInfo.cpp index 2c723a49c..031bae668 100644 --- a/Source/Project64-core/N64System/Recompiler/ExitInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/ExitInfo.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" -#include + #include +#include CExitInfo::CExitInfo(CCodeBlock & CodeBlock) : ID(0), diff --git a/Source/Project64-core/N64System/Recompiler/ExitInfo.h b/Source/Project64-core/N64System/Recompiler/ExitInfo.h index abe0280aa..ac87a52b7 100644 --- a/Source/Project64-core/N64System/Recompiler/ExitInfo.h +++ b/Source/Project64-core/N64System/Recompiler/ExitInfo.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include class CCodeBlock; diff --git a/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp b/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp index 6a7ff283c..8dce6549d 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/FunctionInfo.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include -CCompiledFunc::CCompiledFunc( const CCodeBlock & CodeBlock ) : +CCompiledFunc::CCompiledFunc(const CCodeBlock & CodeBlock) : m_EnterPC(CodeBlock.VAddrEnter()), m_MinPC(CodeBlock.VAddrFirst()), m_MaxPC(CodeBlock.VAddrLast()), diff --git a/Source/Project64-core/N64System/Recompiler/FunctionInfo.h b/Source/Project64-core/N64System/Recompiler/FunctionInfo.h index 61ece2af2..452561c99 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionInfo.h +++ b/Source/Project64-core/N64System/Recompiler/FunctionInfo.h @@ -8,23 +8,53 @@ public: typedef void (*Func)(); - const uint32_t EnterPC () const { return m_EnterPC; } - const uint32_t MinPC () const { return m_MinPC; } - const uint32_t MaxPC () const { return m_MaxPC; } - const Func Function () const { return m_Function; } - const uint8_t *FunctionEnd() const { return m_FunctionEnd; } - const MD5Digest& Hash () const { return m_Hash; } + const uint32_t EnterPC() const + { + return m_EnterPC; + } + const uint32_t MinPC() const + { + return m_MinPC; + } + const uint32_t MaxPC() const + { + return m_MaxPC; + } + const Func Function() const + { + return m_Function; + } + const uint8_t * FunctionEnd() const + { + return m_FunctionEnd; + } + const MD5Digest & Hash() const + { + return m_Hash; + } - CCompiledFunc* Next () const { return m_Next; } - void SetNext(CCompiledFunc* Next) { m_Next = Next; } + CCompiledFunc * Next() const + { + return m_Next; + } + void SetNext(CCompiledFunc * Next) + { + m_Next = Next; + } - uint64_t MemContents(int32_t i) { return m_MemContents[i]; } - uint64_t* MemLocation(int32_t i) { return m_MemLocation[i]; } + uint64_t MemContents(int32_t i) + { + return m_MemContents[i]; + } + uint64_t * MemLocation(int32_t i) + { + return m_MemLocation[i]; + } private: CCompiledFunc(void); - CCompiledFunc(const CCompiledFunc&); - CCompiledFunc& operator=(const CCompiledFunc&); + CCompiledFunc(const CCompiledFunc &); + CCompiledFunc & operator=(const CCompiledFunc &); uint32_t m_EnterPC; uint32_t m_MinPC; @@ -34,8 +64,8 @@ private: MD5Digest m_Hash; Func m_Function; - CCompiledFunc* m_Next; - uint64_t m_MemContents[2], * m_MemLocation[2]; + CCompiledFunc * m_Next; + uint64_t m_MemContents[2], *m_MemLocation[2]; }; typedef std::map CCompiledFuncList; diff --git a/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp b/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp index 533832d8f..05269d64f 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp +++ b/Source/Project64-core/N64System/Recompiler/FunctionMap.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + +#include #include #include -#include CFunctionMap::CFunctionMap() : m_JumpTable(nullptr), diff --git a/Source/Project64-core/N64System/Recompiler/FunctionMap.h b/Source/Project64-core/N64System/Recompiler/FunctionMap.h index 348d1dfe2..dcf139c19 100644 --- a/Source/Project64-core/N64System/Recompiler/FunctionMap.h +++ b/Source/Project64-core/N64System/Recompiler/FunctionMap.h @@ -6,7 +6,7 @@ class CFunctionMap : public CGameSettings { protected: - typedef CCompiledFunc * PCCompiledFunc; + typedef CCompiledFunc * PCCompiledFunc; typedef PCCompiledFunc * PCCompiledFunc_TABLE; CFunctionMap(); @@ -16,12 +16,18 @@ protected: void Reset(bool bAllocate); public: - PCCompiledFunc_TABLE * FunctionTable() const { return m_FunctionTable; } - PCCompiledFunc * JumpTable() const { return m_JumpTable; } + PCCompiledFunc_TABLE * FunctionTable() const + { + return m_FunctionTable; + } + PCCompiledFunc * JumpTable() const + { + return m_JumpTable; + } private: void CleanBuffers(); - PCCompiledFunc * m_JumpTable; + PCCompiledFunc * m_JumpTable; PCCompiledFunc_TABLE * m_FunctionTable; }; diff --git a/Source/Project64-core/N64System/Recompiler/JumpInfo.cpp b/Source/Project64-core/N64System/Recompiler/JumpInfo.cpp index 034559709..c8f26d273 100644 --- a/Source/Project64-core/N64System/Recompiler/JumpInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/JumpInfo.cpp @@ -1,18 +1,19 @@ #include "stdafx.h" -#include -#include "SectionInfo.h" + #include "JumpInfo.h" +#include "SectionInfo.h" +#include CJumpInfo::CJumpInfo(CCodeBlock & CodeBlock) : RegSet(CodeBlock, CodeBlock.RecompilerOps()->Assembler()) { - TargetPC = (uint32_t)-1; - JumpPC = (uint32_t)-1; - BranchLabel = ""; - LinkLocation = nullptr; - LinkLocation2 = nullptr; - FallThrough = false; - PermLoop = false; - DoneDelaySlot = false; - Reason = ExitReason_Normal; + TargetPC = (uint32_t)-1; + JumpPC = (uint32_t)-1; + BranchLabel = ""; + LinkLocation = nullptr; + LinkLocation2 = nullptr; + FallThrough = false; + PermLoop = false; + DoneDelaySlot = false; + Reason = ExitReason_Normal; } diff --git a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp index 9e885ae30..723809f82 100644 --- a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp +++ b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp @@ -1,12 +1,13 @@ #include "stdafx.h" -#include -#include "LoopAnalysis.h" +#include "LoopAnalysis.h" +#include + +#include +#include #include #include #include -#include -#include #ifdef _DEBUG #define CHECKED_BUILD 1 @@ -69,7 +70,11 @@ bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bo { bChanged = false; bSkipedSection = false; - if (Section->m_ParentSection.empty()) { g_Notify->BreakPoint(__FILE__, __LINE__); return true; } + if (Section->m_ParentSection.empty()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + return true; + } m_CodeBlock.Log("%s: Block EnterPC: %X Section ID %d Test: %X Section Test: %X CompiledLocation: %X", __FUNCTION__, m_CodeBlock.VAddrEnter(), Section->m_SectionID, m_Test, Section->m_Test, Section->m_CompiledLocation); @@ -89,16 +94,18 @@ bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bo RegisterMap::iterator Continue_itr = m_ContinueRegisters.find(Parent->m_SectionID); RegisterMap::iterator Jump_itr = m_JumpRegisters.find(Parent->m_SectionID); - CCodeSection * TargetSection[] = { Parent->m_ContinueSection, Parent->m_JumpSection }; + CCodeSection * TargetSection[] = {Parent->m_ContinueSection, Parent->m_JumpSection}; CRegInfo * JumpRegInfo[] = - { - Continue_itr == m_ContinueRegisters.end() ? &Parent->m_Cont.RegSet : Continue_itr->second, - Jump_itr == m_JumpRegisters.end() ? &Parent->m_Jump.RegSet : Jump_itr->second - }; + { + Continue_itr == m_ContinueRegisters.end() ? &Parent->m_Cont.RegSet : Continue_itr->second, + Jump_itr == m_JumpRegisters.end() ? &Parent->m_Jump.RegSet : Jump_itr->second}; for (int i = 0; i < 2; i++) { - if (TargetSection[i] != Section) { continue; } + if (TargetSection[i] != Section) + { + continue; + } if (bFirstParent) { bFirstParent = false; @@ -138,19 +145,31 @@ bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bo bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) { - if (Section == nullptr) { return true; } - if (!Section->m_InLoop) { return true; } + if (Section == nullptr) + { + return true; + } + if (!Section->m_InLoop) + { + return true; + } m_CodeBlock.Log("%s: Section %d Block PC: 0x%X", __FUNCTION__, Section->m_SectionID, m_CodeBlock.VAddrEnter()); bool bChanged = false, bSkipedSection = false; if (Section == m_EnterSection && Section->m_Test == m_Test) { - if (!SetupEnterSection(Section, bChanged, bSkipedSection)) { return false; } + if (!SetupEnterSection(Section, bChanged, bSkipedSection)) + { + return false; + } return true; } - if (!SetupEnterSection(Section, bChanged, bSkipedSection)) { return false; } + if (!SetupEnterSection(Section, bChanged, bSkipedSection)) + { + return false; + } if (Section->m_Test == m_Test && !bChanged) { @@ -187,7 +206,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_SPECIAL_SLLV: SPECIAL_SLLV(); break; case R4300i_SPECIAL_SRLV: SPECIAL_SRLV(); break; case R4300i_SPECIAL_SRAV: SPECIAL_SRAV(); break; - case R4300i_SPECIAL_JR: SPECIAL_JR(); break; + case R4300i_SPECIAL_JR: SPECIAL_JR(); break; case R4300i_SPECIAL_JALR: SPECIAL_JALR(); break; case R4300i_SPECIAL_SYSCALL: SPECIAL_SYSCALL(Section); break; case R4300i_SPECIAL_BREAK: SPECIAL_BREAK(Section); break; @@ -226,8 +245,12 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_SPECIAL_DSLL32: SPECIAL_DSLL32(); break; case R4300i_SPECIAL_DSRL32: SPECIAL_DSRL32(); break; case R4300i_SPECIAL_DSRA32: SPECIAL_DSRA32(); break; - case R4300i_SPECIAL_TEQ: case R4300i_SPECIAL_TNE: case R4300i_SPECIAL_TGE: - case R4300i_SPECIAL_TGEU: case R4300i_SPECIAL_TLT: case R4300i_SPECIAL_TLTU: + case R4300i_SPECIAL_TEQ: + case R4300i_SPECIAL_TNE: + case R4300i_SPECIAL_TGE: + case R4300i_SPECIAL_TGEU: + case R4300i_SPECIAL_TLT: + case R4300i_SPECIAL_TLTU: break; default: g_Notify->BreakPoint(__FILE__, __LINE__); @@ -238,8 +261,12 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_REGIMM: switch (m_Command.rt) { - case R4300i_REGIMM_TEQI: case R4300i_REGIMM_TNEI: case R4300i_REGIMM_TGEI: - case R4300i_REGIMM_TGEIU: case R4300i_REGIMM_TLTI: case R4300i_REGIMM_TLTIU: + case R4300i_REGIMM_TEQI: + case R4300i_REGIMM_TNEI: + case R4300i_REGIMM_TGEI: + case R4300i_REGIMM_TGEIU: + case R4300i_REGIMM_TLTI: + case R4300i_REGIMM_TLTIU: break; case R4300i_REGIMM_BLTZ: case R4300i_REGIMM_BGEZ: @@ -400,7 +427,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) break; case R4300i_ADDI: case R4300i_ADDIU: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } /*if (m_Command.rs == 0) { m_Reg.GetMipsRegLo(m_Command.rt) = (int16_t)m_Command.immediate; m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN); @@ -410,11 +440,17 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) break; case R4300i_SLTI: case R4300i_SLTIU: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); break; case R4300i_LUI: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } if (!m_Reg.IsModified(m_Command.rt)) { m_Reg.SetMipsRegLo(m_Command.rt, ((int16_t)m_Command.offset << 16)); @@ -422,25 +458,36 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) } break; case R4300i_ANDI: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); break; case R4300i_ORI: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } if (m_Command.rs == m_Command.rt) { m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); } - if (m_Reg.IsConst(m_Command.rs)) { + if (m_Reg.IsConst(m_Command.rs)) + { m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_CONST_32_SIGN); m_Reg.SetMipsRegLo(m_Command.rt, m_Reg.GetMipsRegLo(m_Command.rs) | m_Command.immediate); } - else { + else + { m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); } break; case R4300i_XORI: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } if (m_Command.rs == m_Command.rt) { m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); @@ -459,7 +506,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) switch (m_Command.rs) { case R4300i_COP0_MF: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); break; case R4300i_COP0_MT: break; @@ -493,7 +543,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_COP1_CF: case R4300i_COP1_MF: case R4300i_COP1_DMF: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); break; case R4300i_COP1_BC: @@ -573,7 +626,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) if (m_PC == m_PC + ((int16_t)m_Command.offset << 2) + 4) { R4300iOpcode DelaySlot; - if (g_MMU->MemoryValue32(m_PC + 4, DelaySlot.Value) && + if (g_MMU->MemoryValue32(m_PC + 4, DelaySlot.Value) && !R4300iInstruction(m_PC, m_Command.Value).DelaySlotEffectsCompare(DelaySlot.Value) && !Section->m_Jump.PermLoop) { @@ -584,7 +637,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) break; case R4300i_DADDI: case R4300i_DADDIU: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } if (m_Command.rs == m_Command.rt) { m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); @@ -620,7 +676,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_LHU: case R4300i_LWR: case R4300i_SC: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); break; case R4300i_SB: break; @@ -635,7 +694,10 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) case R4300i_SWC1: break; case R4300i_LDC1: break; case R4300i_LD: - if (m_Command.rt == 0) { break; } + if (m_Command.rt == 0) + { + break; + } m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); break; case R4300i_SDC1: break; @@ -643,11 +705,26 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) default: m_PipelineStage = PIPELINE_STAGE_END_BLOCK; m_PC -= 4; - if (m_Command.Value == 0x7C1C97C0) { break; } - if (m_Command.Value == 0x7FFFFFFF) { break; } - if (m_Command.Value == 0xF1F3F5F7) { break; } - if (m_Command.Value == 0xC1200000) { break; } - if (m_Command.Value == 0x4C5A5353) { break; } + if (m_Command.Value == 0x7C1C97C0) + { + break; + } + if (m_Command.Value == 0x7FFFFFFF) + { + break; + } + if (m_Command.Value == 0xF1F3F5F7) + { + break; + } + if (m_Command.Value == 0xC1200000) + { + break; + } + if (m_Command.Value == 0x4C5A5353) + { + break; + } g_Notify->DisplayError(stdstr_f("Unhandled R4300i opcode in FillSectionInfo 1\n%s\n%X", R4300iInstruction(m_PC, m_Command.Value).NameAndParam().c_str(), m_Command.Value).c_str()); } @@ -662,7 +739,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) m_PipelineStage = PIPELINE_STAGE_END_BLOCK; SetJumpRegSet(Section, m_Reg); } - else + else { switch (m_PipelineStage) { @@ -710,12 +787,18 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) } } while (m_PipelineStage != PIPELINE_STAGE_END_BLOCK); - if (!CheckLoopRegisterUsage(Section->m_ContinueSection)) { return false; } - if (!CheckLoopRegisterUsage(Section->m_JumpSection)) { return false; } + if (!CheckLoopRegisterUsage(Section->m_ContinueSection)) + { + return false; + } + if (!CheckLoopRegisterUsage(Section->m_JumpSection)) + { + return false; + } return true; } -bool LoopAnalysis::SyncRegState(CRegInfo & RegSet, const CRegInfo& SyncReg) +bool LoopAnalysis::SyncRegState(CRegInfo & RegSet, const CRegInfo & SyncReg) { bool bChanged = false; for (int x = 0; x < 32; x++) @@ -740,7 +823,7 @@ bool LoopAnalysis::SyncRegState(CRegInfo & RegSet, const CRegInfo& SyncReg) return bChanged; } -void LoopAnalysis::SetJumpRegSet(CCodeSection * Section, const CRegInfo &Reg) +void LoopAnalysis::SetJumpRegSet(CCodeSection * Section, const CRegInfo & Reg) { RegisterMap::iterator itr = m_JumpRegisters.find(Section->m_SectionID); if (itr != m_JumpRegisters.end()) @@ -753,7 +836,7 @@ void LoopAnalysis::SetJumpRegSet(CCodeSection * Section, const CRegInfo &Reg) } } -void LoopAnalysis::SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg) +void LoopAnalysis::SetContinueRegSet(CCodeSection * Section, const CRegInfo & Reg) { RegisterMap::iterator itr = m_ContinueRegisters.find(Section->m_SectionID); if (itr != m_ContinueRegisters.end()) @@ -768,25 +851,37 @@ void LoopAnalysis::SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg void LoopAnalysis::SPECIAL_SLL() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SRL() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SRA() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SLLV() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -804,7 +899,10 @@ void LoopAnalysis::SPECIAL_SLLV() void LoopAnalysis::SPECIAL_SRLV() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -822,7 +920,10 @@ void LoopAnalysis::SPECIAL_SRLV() void LoopAnalysis::SPECIAL_SRAV() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -910,7 +1011,10 @@ void LoopAnalysis::SPECIAL_MTLO() void LoopAnalysis::SPECIAL_DSLLV() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -928,7 +1032,10 @@ void LoopAnalysis::SPECIAL_DSLLV() void LoopAnalysis::SPECIAL_DSRLV() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -946,12 +1053,16 @@ void LoopAnalysis::SPECIAL_DSRLV() void LoopAnalysis::SPECIAL_DSRAV() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg_S(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); } @@ -963,67 +1074,100 @@ void LoopAnalysis::SPECIAL_DSRAV() void LoopAnalysis::SPECIAL_ADD() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_ADDU() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SUB() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SUBU() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_AND() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_OR() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_XOR() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_NOR() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SLT() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SLTU() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_DADD() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1031,9 +1175,8 @@ void LoopAnalysis::SPECIAL_DADD() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) + - (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) - ); + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) + + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } else @@ -1044,7 +1187,10 @@ void LoopAnalysis::SPECIAL_DADD() void LoopAnalysis::SPECIAL_DADDU() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1052,9 +1198,8 @@ void LoopAnalysis::SPECIAL_DADDU() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) + - (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) - ); + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) + + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } else @@ -1065,7 +1210,10 @@ void LoopAnalysis::SPECIAL_DADDU() void LoopAnalysis::SPECIAL_DSUB() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1073,9 +1221,8 @@ void LoopAnalysis::SPECIAL_DSUB() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) - - (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) - ); + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) - + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } else @@ -1086,7 +1233,10 @@ void LoopAnalysis::SPECIAL_DSUB() void LoopAnalysis::SPECIAL_DSUBU() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1094,9 +1244,8 @@ void LoopAnalysis::SPECIAL_DSUBU() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) - - (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) - ); + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) - + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt))); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } else @@ -1107,7 +1256,10 @@ void LoopAnalysis::SPECIAL_DSUBU() void LoopAnalysis::SPECIAL_DSLL() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1125,7 +1277,10 @@ void LoopAnalysis::SPECIAL_DSLL() void LoopAnalysis::SPECIAL_DSRL() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1143,7 +1298,10 @@ void LoopAnalysis::SPECIAL_DSRL() void LoopAnalysis::SPECIAL_DSRA() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1161,7 +1319,10 @@ void LoopAnalysis::SPECIAL_DSRA() void LoopAnalysis::SPECIAL_DSLL32() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1179,7 +1340,10 @@ void LoopAnalysis::SPECIAL_DSLL32() void LoopAnalysis::SPECIAL_DSRL32() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); @@ -1197,7 +1361,10 @@ void LoopAnalysis::SPECIAL_DSRL32() void LoopAnalysis::SPECIAL_DSRA32() { - if (m_Command.rd == 0) { return; } + if (m_Command.rd == 0) + { + return; + } if (m_Command.rt == m_Command.rd) { m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); diff --git a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h index 1bd5b07d1..ae2c3ba9d 100644 --- a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h +++ b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.h @@ -1,7 +1,7 @@ #pragma once -#include #include #include +#include #include class CCodeSection; @@ -17,14 +17,14 @@ public: private: LoopAnalysis(); - LoopAnalysis(const LoopAnalysis&); - LoopAnalysis& operator=(const LoopAnalysis&); + LoopAnalysis(const LoopAnalysis &); + LoopAnalysis & operator=(const LoopAnalysis &); bool SetupEnterSection(CCodeSection * Section, bool & bChanged, bool & bSkipedSection); bool CheckLoopRegisterUsage(CCodeSection * Section); - bool SyncRegState(CRegInfo & RegSet, const CRegInfo& SyncReg); - void SetJumpRegSet(CCodeSection * Section, const CRegInfo &Reg); - void SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg); + bool SyncRegState(CRegInfo & RegSet, const CRegInfo & SyncReg); + void SetJumpRegSet(CCodeSection * Section, const CRegInfo & Reg); + void SetContinueRegSet(CCodeSection * Section, const CRegInfo & Reg); // R4300i opcodes: Special void SPECIAL_SLL(); diff --git a/Source/Project64-core/N64System/Recompiler/Recompiler.cpp b/Source/Project64-core/N64System/Recompiler/Recompiler.cpp index 89fa77cfb..004d49a20 100644 --- a/Source/Project64-core/N64System/Recompiler/Recompiler.cpp +++ b/Source/Project64-core/N64System/Recompiler/Recompiler.cpp @@ -1,9 +1,10 @@ #include "stdafx.h" + +#include +#include +#include #include #include -#include -#include -#include CRecompiler::CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation) : m_MMU(MMU), @@ -120,7 +121,7 @@ void CRecompiler::RecompilerMain_VirtualTable() WriteTrace(TraceRecompiler, TraceError, "Failed to allocate PCCompiledFunc"); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); } - memset(table, 0, sizeof(PCCompiledFunc)* (0x1000 >> 2)); + memset(table, 0, sizeof(PCCompiledFunc) * (0x1000 >> 2)); if (g_System->bSMM_Protect()) { WriteTrace(TraceRecompiler, TraceError, "Create Table (%X): Index = %d", table, PC >> 0xC); @@ -272,7 +273,7 @@ void CRecompiler::RecompilerMain_Lookup_validate() FUNCTION_PROFILE::iterator itr = m_BlockProfile.find(info->Function()); if (itr == m_BlockProfile.end()) { - FUNCTION_PROFILE_DATA data = { 0 }; + FUNCTION_PROFILE_DATA data = {0}; data.Address = info->EnterPC(); std::pair res = m_BlockProfile.insert(FUNCTION_PROFILE::value_type(info->Function(), data)); itr = res.first; @@ -395,7 +396,7 @@ CCompiledFunc * CRecompiler::CompileCode() } #if defined(__aarch64__) || defined(__amd64__) || defined(_M_X64) - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); #else if (g_ModuleLogLevel[TraceRecompiler] >= TraceDebug) { @@ -497,14 +498,14 @@ void CRecompiler::ClearRecompCode_Virt(uint32_t Address, int length, REMOVE_REAS } break; case FuncFind_PhysicalLookup: + { + uint32_t pAddr = 0; + if (m_MMU.VAddrToPAddr(Address, pAddr)) { - uint32_t pAddr = 0; - if (m_MMU.VAddrToPAddr(Address, pAddr)) - { - ClearRecompCode_Phys(pAddr, length, Reason); - } + ClearRecompCode_Phys(pAddr, length, Reason); } - break; + } + break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -519,7 +520,7 @@ void CRecompiler::ResetLog() void CRecompiler::ResetMemoryStackPos() { #if defined(__aarch64__) || defined(__amd64__) || defined(_M_X64) - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); #else if (m_Registers.m_GPR[29].UW[0] == 0) { @@ -543,7 +544,7 @@ void CRecompiler::ResetMemoryStackPos() void CRecompiler::DumpFunctionTimes() { #if defined(__aarch64__) || defined(__amd64__) || defined(_M_X64) - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); #else CPath LogFileName(g_Settings->LoadStringVal(Directory_Log).c_str(), "FunctionTimes.csv"); diff --git a/Source/Project64-core/N64System/Recompiler/Recompiler.h b/Source/Project64-core/N64System/Recompiler/Recompiler.h index 321b880ae..e24804df2 100644 --- a/Source/Project64-core/N64System/Recompiler/Recompiler.h +++ b/Source/Project64-core/N64System/Recompiler/Recompiler.h @@ -1,12 +1,12 @@ #pragma once -#include #include +#include +#include #include #include -#include -#include #include +#include class CLog; @@ -18,7 +18,6 @@ class CRecompiler : private CSystemRegisters { public: - enum REMOVE_REASON { Remove_InitialCode, @@ -32,7 +31,7 @@ public: Remove_MemViewer, }; - typedef void(*DelayFunc)(); + typedef void (*DelayFunc)(); public: CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation); @@ -51,12 +50,15 @@ public: void ResetFunctionTimes(); void DumpFunctionTimes(); - uint32_t& MemoryStackPos() { return m_MemoryStack; } + uint32_t & MemoryStackPos() + { + return m_MemoryStack; + } private: CRecompiler(); - CRecompiler(const CRecompiler&); - CRecompiler& operator=(const CRecompiler&); + CRecompiler(const CRecompiler &); + CRecompiler & operator=(const CRecompiler &); CCompiledFunc * CompileCode(); @@ -66,7 +68,7 @@ private: uint64_t TimeTaken; } FUNCTION_PROFILE_DATA; - typedef std::map FUNCTION_PROFILE; + typedef std::map FUNCTION_PROFILE; void RecompilerMain_VirtualTable(); void RecompilerMain_VirtualTable_validate(); @@ -78,7 +80,7 @@ private: void StopLog(); void LogCodeBlock(const CCodeBlock & CodeBlock); - CCompiledFuncList m_Functions; + CCompiledFuncList m_Functions; CMipsMemoryVM & m_MMU; CRegisters & m_Registers; bool & m_EndEmulation; diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp index d158a75ac..0621ea6f2 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp +++ b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.cpp @@ -1,12 +1,13 @@ #include "stdafx.h" + +#include +#include #include #include -#include -#include CRecompMemory::CRecompMemory() : -m_RecompCode(nullptr), -m_RecompSize(0) + m_RecompCode(nullptr), + m_RecompSize(0) { m_RecompPos = nullptr; } @@ -15,7 +16,7 @@ CRecompMemory::~CRecompMemory() { if (m_RecompCode) { - FreeAddressSpace(m_RecompCode,MaxCompileBufferSize + 4); + FreeAddressSpace(m_RecompCode, MaxCompileBufferSize + 4); m_RecompCode = nullptr; } m_RecompPos = nullptr; @@ -37,7 +38,7 @@ bool CRecompMemory::AllocateMemory() if (m_RecompCode == nullptr) { WriteTrace(TraceRecompiler, TraceError, "Failed to commit initial buffer"); - FreeAddressSpace(RecompCodeBase,MaxCompileBufferSize + 4); + FreeAddressSpace(RecompCodeBase, MaxCompileBufferSize + 4); g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return false; } diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h index 8fc155fcb..029dda0fd 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h +++ b/Source/Project64-core/N64System/Recompiler/RecompilerMemory.h @@ -13,17 +13,29 @@ protected: void ShowMemUsed(); public: - uint8_t** RecompPos() { return &m_RecompPos; } + uint8_t ** RecompPos() + { + return &m_RecompPos; + } private: - CRecompMemory(const CRecompMemory&); - CRecompMemory& operator=(const CRecompMemory&); + CRecompMemory(const CRecompMemory &); + CRecompMemory & operator=(const CRecompMemory &); uint8_t * m_RecompCode; - uint32_t m_RecompSize; + uint32_t m_RecompSize; uint8_t * m_RecompPos; - enum { MaxCompileBufferSize = 0x03C00000 }; - enum { InitialCompileBufferSize = 0x00500000 }; - enum { IncreaseCompileBufferSize = 0x00100000 }; + enum + { + MaxCompileBufferSize = 0x03C00000 + }; + enum + { + InitialCompileBufferSize = 0x00500000 + }; + enum + { + IncreaseCompileBufferSize = 0x00100000 + }; }; diff --git a/Source/Project64-core/N64System/Recompiler/RegBase.cpp b/Source/Project64-core/N64System/Recompiler/RegBase.cpp index e88161bed..4796f1110 100644 --- a/Source/Project64-core/N64System/Recompiler/RegBase.cpp +++ b/Source/Project64-core/N64System/Recompiler/RegBase.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" + #include CRegBase::CRegBase() : -m_CycleCount(0), -m_Fpu_Used(false), -m_RoundingModel(RoundUnknown) + m_CycleCount(0), + m_Fpu_Used(false), + m_RoundingModel(RoundUnknown) { for (int32_t i = 0; i < 32; i++) { @@ -14,7 +15,7 @@ m_RoundingModel(RoundUnknown) m_MIPS_RegState[0] = STATE_CONST_32_SIGN; } -bool CRegBase::operator==(const CRegBase& right) const +bool CRegBase::operator==(const CRegBase & right) const { for (uint32_t count = 0; count < 32; count++) { @@ -31,18 +32,27 @@ bool CRegBase::operator==(const CRegBase& right) const return false; } } - if (m_CycleCount != right.m_CycleCount) { return false; } - if (m_Fpu_Used != right.m_Fpu_Used) { return false; } - if (GetRoundingModel() != right.GetRoundingModel()) { return false; } + if (m_CycleCount != right.m_CycleCount) + { + return false; + } + if (m_Fpu_Used != right.m_Fpu_Used) + { + return false; + } + if (GetRoundingModel() != right.GetRoundingModel()) + { + return false; + } return true; } -bool CRegBase::operator!=(const CRegBase& right) const +bool CRegBase::operator!=(const CRegBase & right) const { return !(right == *this); } -CRegBase& CRegBase::operator=(const CRegBase& right) +CRegBase & CRegBase::operator=(const CRegBase & right) { memcpy(&m_MIPS_RegState, &right.m_MIPS_RegState, sizeof(m_MIPS_RegState)); memcpy(&m_MIPS_RegVal, &right.m_MIPS_RegVal, sizeof(m_MIPS_RegVal)); @@ -62,12 +72,12 @@ const char * CRegBase::RoundingModelName(FPU_ROUND RoundType) { switch (RoundType) { - case RoundUnknown: return "RoundUnknown"; - case RoundDefault: return "RoundDefault"; + case RoundUnknown: return "RoundUnknown"; + case RoundDefault: return "RoundDefault"; case RoundTruncate: return "RoundTruncate"; - case RoundNearest: return "RoundNearest"; - case RoundDown: return "RoundDown"; - case RoundUp: return "RoundUp"; + case RoundNearest: return "RoundNearest"; + case RoundDown: return "RoundDown"; + case RoundUp: return "RoundUp"; } return "** Invalid **"; } diff --git a/Source/Project64-core/N64System/Recompiler/RegBase.h b/Source/Project64-core/N64System/Recompiler/RegBase.h index f6ad943e6..4d2ec17f0 100644 --- a/Source/Project64-core/N64System/Recompiler/RegBase.h +++ b/Source/Project64-core/N64System/Recompiler/RegBase.h @@ -16,13 +16,13 @@ public: STATE_32BIT = 0x08, STATE_MODIFIED = 0x10, - STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3 - STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11 + STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3 + STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11 STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15 - STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9 + STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9 STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13 - STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1 + STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1 }; enum FPU_ROUND @@ -35,50 +35,137 @@ public: RoundUp = 4, }; - inline void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) { m_MIPS_RegState[GetMipsReg] = State; } - inline REG_STATE GetMipsRegState(int32_t Reg) const { return m_MIPS_RegState[Reg]; } + inline void SetMipsRegState(int32_t GetMipsReg, REG_STATE State) + { + m_MIPS_RegState[GetMipsReg] = State; + } + inline REG_STATE GetMipsRegState(int32_t Reg) const + { + return m_MIPS_RegState[Reg]; + } - inline bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); } - inline bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); } - inline bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); } + inline bool IsKnown(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); + } + inline bool IsUnknown(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); + } + inline bool IsModified(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); + } - inline bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } - inline bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); } + inline bool IsMapped(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); + } + inline bool IsConst(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); + } - inline bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); } - inline bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); } + inline bool IsSigned(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); + } + inline bool IsUnsigned(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); + } - inline bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); } - inline bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); } + inline bool Is32Bit(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); + } + inline bool Is64Bit(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); + } - inline bool Is32BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); } - inline bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } + inline bool Is32BitMapped(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); + } + inline bool Is64BitMapped(int32_t Reg) const + { + return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); + } - inline uint64_t GetMipsReg(int32_t Reg) const { return m_MIPS_RegVal[Reg].UDW; } - inline int64_t GetMipsReg_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].DW; } - inline uint32_t GetMipsRegLo(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[0]; } - inline int32_t GetMipsRegLo_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[0]; } - inline uint32_t GetMipsRegHi(int32_t Reg) const { return m_MIPS_RegVal[Reg].UW[1]; } - inline int32_t GetMipsRegHi_S(int32_t Reg) const { return m_MIPS_RegVal[Reg].W[1]; } + inline uint64_t GetMipsReg(int32_t Reg) const + { + return m_MIPS_RegVal[Reg].UDW; + } + inline int64_t GetMipsReg_S(int32_t Reg) const + { + return m_MIPS_RegVal[Reg].DW; + } + inline uint32_t GetMipsRegLo(int32_t Reg) const + { + return m_MIPS_RegVal[Reg].UW[0]; + } + inline int32_t GetMipsRegLo_S(int32_t Reg) const + { + return m_MIPS_RegVal[Reg].W[0]; + } + inline uint32_t GetMipsRegHi(int32_t Reg) const + { + return m_MIPS_RegVal[Reg].UW[1]; + } + inline int32_t GetMipsRegHi_S(int32_t Reg) const + { + return m_MIPS_RegVal[Reg].W[1]; + } - inline void SetMipsRegLo(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[0] = Value; } - inline void SetMipsRegHi(int32_t Reg, uint32_t Value) { m_MIPS_RegVal[Reg].UW[1] = Value; } - inline void SetMipsReg(int32_t Reg, uint64_t Value) { m_MIPS_RegVal[Reg].UDW = Value; } - inline void SetMipsReg_S(int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; } + inline void SetMipsRegLo(int32_t Reg, uint32_t Value) + { + m_MIPS_RegVal[Reg].UW[0] = Value; + } + inline void SetMipsRegHi(int32_t Reg, uint32_t Value) + { + m_MIPS_RegVal[Reg].UW[1] = Value; + } + inline void SetMipsReg(int32_t Reg, uint64_t Value) + { + m_MIPS_RegVal[Reg].UDW = Value; + } + inline void SetMipsReg_S(int32_t Reg, int64_t Value) + { + m_MIPS_RegVal[Reg].DW = Value; + } - inline void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; } - inline uint32_t GetBlockCycleCount() const { return m_CycleCount; } + inline void SetBlockCycleCount(uint32_t CyleCount) + { + m_CycleCount = CyleCount; + } + inline uint32_t GetBlockCycleCount() const + { + return m_CycleCount; + } - inline void SetFpuBeenUsed(bool FpuUsed) { m_Fpu_Used = FpuUsed; } - inline bool GetFpuBeenUsed() const { return m_Fpu_Used; } + inline void SetFpuBeenUsed(bool FpuUsed) + { + m_Fpu_Used = FpuUsed; + } + inline bool GetFpuBeenUsed() const + { + return m_Fpu_Used; + } - inline FPU_ROUND GetRoundingModel() const { return m_RoundingModel; } - inline void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; } + inline FPU_ROUND GetRoundingModel() const + { + return m_RoundingModel; + } + inline void SetRoundingModel(FPU_ROUND RoundingModel) + { + m_RoundingModel = RoundingModel; + } - CRegBase& operator=(const CRegBase&); + CRegBase & operator=(const CRegBase &); - bool operator==(const CRegBase& right) const; - bool operator!=(const CRegBase& right) const; + bool operator==(const CRegBase & right) const; + bool operator!=(const CRegBase & right) const; protected: const char * RoundingModelName(FPU_ROUND RoundType); diff --git a/Source/Project64-core/N64System/Recompiler/SectionInfo.h b/Source/Project64-core/N64System/Recompiler/SectionInfo.h index 4ca736c72..784d83ae0 100644 --- a/Source/Project64-core/N64System/Recompiler/SectionInfo.h +++ b/Source/Project64-core/N64System/Recompiler/SectionInfo.h @@ -6,8 +6,8 @@ struct CJumpInfo; struct BLOCK_PARENT { - CCodeSection * Parent; - CJumpInfo * JumpInfo; + CCodeSection * Parent; + CJumpInfo * JumpInfo; }; typedef std::vector BLOCK_PARENT_LIST; diff --git a/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.cpp index 10304ad10..a019ab710 100644 --- a/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.cpp @@ -248,7 +248,7 @@ void CX64RecompilerOps::SC() g_Notify->BreakPoint(__FILE__, __LINE__); } -void CX64RecompilerOps::SWC1() +void CX64RecompilerOps::SWC1() { g_Notify->BreakPoint(__FILE__, __LINE__); } diff --git a/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.h index 048423c49..24b4e732d 100644 --- a/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/x64-86/x64RecompilerOps.h @@ -1,11 +1,11 @@ #pragma once #if defined(__amd64__) || defined(_M_X64) -#include -#include -#include -#include #include +#include +#include +#include +#include class CMipsMemoryVM; class CCodeBlock; @@ -13,7 +13,7 @@ class CCodeSection; class CX64Ops; struct CJumpInfo; -class CX64RecompilerOps +class CX64RecompilerOps { public: CX64RecompilerOps(CMipsMemoryVM & MMU, CCodeBlock & CodeBlock); @@ -213,18 +213,21 @@ public: const R4300iOpcode & GetOpcode(void) const; void PreCompileOpcode(void); void PostCompileOpcode(void); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason); void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false, bool UpdateTimer = true); void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet); void CompileExecuteBP(void); void CompileExecuteDelaySlotBP(void); - CX64Ops & Assembler() { return m_Assembler; } + CX64Ops & Assembler() + { + return m_Assembler; + } private: - CX64RecompilerOps(const CX64RecompilerOps&); - CX64RecompilerOps& operator=(const CX64RecompilerOps&); + CX64RecompilerOps(const CX64RecompilerOps &); + CX64RecompilerOps & operator=(const CX64RecompilerOps &); CX64RegInfo m_RegWorkingSet; CX64Ops m_Assembler; diff --git a/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.cpp index dd8f44581..43db7fcbe 100644 --- a/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.cpp @@ -7,7 +7,7 @@ CX64RegInfo::CX64RegInfo(CCodeBlock & /*CodeBlock*/, CX64Ops & /*Assembler*/) { } -CX64RegInfo::CX64RegInfo(const CX64RegInfo&) +CX64RegInfo::CX64RegInfo(const CX64RegInfo &) { g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -16,7 +16,7 @@ CX64RegInfo::~CX64RegInfo() { } -CX64RegInfo& CX64RegInfo::operator=(const CX64RegInfo & right) +CX64RegInfo & CX64RegInfo::operator=(const CX64RegInfo & right) { CRegBase::operator=(right); g_Notify->BreakPoint(__FILE__, __LINE__); diff --git a/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.h b/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.h index d3005dae7..97437bdd9 100644 --- a/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/x64-86/x64RegInfo.h @@ -11,13 +11,13 @@ class CX64RegInfo : { public: CX64RegInfo(CCodeBlock & CodeBlock, CX64Ops & Assembler); - CX64RegInfo(const CX64RegInfo&); + CX64RegInfo(const CX64RegInfo &); ~CX64RegInfo(); - CX64RegInfo& operator=(const CX64RegInfo&); + CX64RegInfo & operator=(const CX64RegInfo &); - bool operator==(const CX64RegInfo& right) const; - bool operator!=(const CX64RegInfo& right) const; + bool operator==(const CX64RegInfo & right) const; + bool operator!=(const CX64RegInfo & right) const; }; #endif diff --git a/Source/Project64-core/N64System/Recompiler/x64-86/x64ops.h b/Source/Project64-core/N64System/Recompiler/x64-86/x64ops.h index 88fbd588f..88f3492bb 100644 --- a/Source/Project64-core/N64System/Recompiler/x64-86/x64ops.h +++ b/Source/Project64-core/N64System/Recompiler/x64-86/x64ops.h @@ -10,8 +10,8 @@ public: private: CX64Ops(void); - CX64Ops(const CX64Ops&); - CX64Ops& operator=(const CX64Ops&); + CX64Ops(const CX64Ops &); + CX64Ops & operator=(const CX64Ops &); CCodeBlock & m_CodeBlock; }; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 80e38aa89..b4b86567c 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -2,21 +2,21 @@ #if defined(__i386__) || defined(_M_IX86) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include uint32_t CX86RecompilerOps::m_TempValue32 = 0; @@ -323,7 +323,10 @@ void CX86RecompilerOps::PreCompileOpcode(void) void CX86RecompilerOps::PostCompileOpcode(void) { m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - if (!g_System->bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); } + if (!g_System->bRegCaching()) + { + m_RegWorkingSet.WriteBackRegisters(); + } m_RegWorkingSet.UnMap_AllFPRs(); /*if (m_CompilePC >= 0x800933B4 && m_CompilePC <= 0x80093414 && (m_PipelineStage == PIPELINE_STAGE_NORMAL || m_PipelineStage == PIPELINE_STAGE_DO_DELAY_SLOT)) @@ -369,7 +372,7 @@ void CX86RecompilerOps::CompileWriteTLBMiss(CX86Ops::x86Reg AddressReg, CX86Ops: void CX86RecompilerOps::Compile_TrapCompare(RecompilerTrapCompare CompareType) { uint32_t FunctAddress = 0; - const char *FunctName = nullptr; + const char * FunctName = nullptr; switch (CompareType) { case RecompilerTrapCompare_TEQ: @@ -426,11 +429,11 @@ void CX86RecompilerOps::Compile_TrapCompare(RecompilerTrapCompare CompareType) if (FunctName != nullptr && FunctAddress != 0) { - if (IsMapped(m_Opcode.rs)) + if (IsMapped(m_Opcode.rs)) { UnMap_GPR(m_Opcode.rs, true); } - if (IsMapped(m_Opcode.rt)) + if (IsMapped(m_Opcode.rt)) { UnMap_GPR(m_Opcode.rt, true); } @@ -585,7 +588,10 @@ void CX86RecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr) { m_Assembler.JmpLabel8("DoDelaySlot", 0); - if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (DelayLinkLocation != nullptr) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } DelayLinkLocation = (uint8_t *)(*g_RecompPos - 1); m_CodeBlock.Log(" "); @@ -596,7 +602,10 @@ void CX86RecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr) { m_Assembler.JmpLabel8("DoDelaySlot", 0); - if (DelayLinkLocation != nullptr) { g_Notify->BreakPoint(__FILE__, __LINE__); } + if (DelayLinkLocation != nullptr) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } DelayLinkLocation = (uint8_t *)(*g_RecompPos - 1); m_CodeBlock.Log(" "); @@ -863,7 +872,7 @@ void CX86RecompilerOps::Compile_BranchLikely(RecompilerBranchCompare CompareType void CX86RecompilerOps::BNE_Compare() { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) { @@ -892,8 +901,7 @@ void CX86RecompilerOps::BNE_Compare() { m_Assembler.CompX86RegToX86Reg( Is32Bit(m_Opcode.rs) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt) - ); + Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt)); if (m_Section->m_Jump.FallThrough) { @@ -1188,7 +1196,7 @@ void CX86RecompilerOps::BNE_Compare() void CX86RecompilerOps::BEQ_Compare() { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) { @@ -1218,8 +1226,7 @@ void CX86RecompilerOps::BEQ_Compare() m_Assembler.CompX86RegToX86Reg( Is32Bit(m_Opcode.rs) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt) - ); + Is32Bit(m_Opcode.rt) ? Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) : GetMipsRegMapHi(m_Opcode.rt)); if (m_Section->m_Cont.FallThrough) { m_Assembler.JneLabel8("Continue", 0); @@ -1297,7 +1304,8 @@ void CX86RecompilerOps::BEQ_Compare() { m_Assembler.CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); } - if (m_Section->m_Cont.FallThrough) { + if (m_Section->m_Cont.FallThrough) + { m_Assembler.JneLabel8("Continue", 0); Jump = *g_RecompPos - 1; } @@ -1573,7 +1581,7 @@ void CX86RecompilerOps::BGTZ_Compare() } else { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (IsMapped(m_Opcode.rs)) { @@ -1706,7 +1714,7 @@ void CX86RecompilerOps::BLEZ_Compare() } else { - uint8_t *Jump = nullptr; + uint8_t * Jump = nullptr; if (IsMapped(m_Opcode.rs)) { @@ -1769,8 +1777,9 @@ void CX86RecompilerOps::BLEZ_Compare() } } } - else { - uint8_t *Jump = nullptr; + else + { + uint8_t * Jump = nullptr; if (!g_System->b32BitCore()) { @@ -2136,7 +2145,7 @@ void CX86RecompilerOps::J() return; } - m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2);; + m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); m_Section->m_Jump.JumpPC = m_CompilePC; if (m_Section->m_JumpSection != nullptr) { @@ -2317,8 +2326,8 @@ void CX86RecompilerOps::SLTIU() if (IsConst(m_Opcode.rs)) { - uint32_t Result = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) < ((unsigned)((int64_t)((int16_t)m_Opcode.immediate))) ? 1 : 0 : - GetMipsRegLo(m_Opcode.rs) < ((unsigned)((int16_t)m_Opcode.immediate)) ? 1 : 0; + uint32_t Result = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) < ((unsigned)((int64_t)((int16_t)m_Opcode.immediate))) ? 1 : 0 : GetMipsRegLo(m_Opcode.rs) < ((unsigned)((int16_t)m_Opcode.immediate)) ? 1 + : 0; UnMap_GPR(m_Opcode.rt, false); m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, Result); @@ -2387,9 +2396,7 @@ void CX86RecompilerOps::SLTI() if (IsConst(m_Opcode.rs)) { - uint32_t Result = Is64Bit(m_Opcode.rs) ? - ((int64_t)GetMipsReg(m_Opcode.rs) < (int64_t)((int16_t)m_Opcode.immediate) ? 1 : 0) : - (GetMipsRegLo_S(m_Opcode.rs) < (int16_t)m_Opcode.immediate ? 1 : 0); + uint32_t Result = Is64Bit(m_Opcode.rs) ? ((int64_t)GetMipsReg(m_Opcode.rs) < (int64_t)((int16_t)m_Opcode.immediate) ? 1 : 0) : (GetMipsRegLo_S(m_Opcode.rs) < (int16_t)m_Opcode.immediate ? 1 : 0); UnMap_GPR(m_Opcode.rt, false); m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); @@ -2459,7 +2466,7 @@ void CX86RecompilerOps::SLTI() } else { - uint8_t * Jump[2] = { nullptr, nullptr }; + uint8_t * Jump[2] = {nullptr, nullptr}; m_Assembler.CompConstToVariable(((int16_t)m_Opcode.immediate >> 31), &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); m_Assembler.JeLabel8("Low Compare", 0); Jump[0] = *g_RecompPos - 1; @@ -2604,7 +2611,10 @@ void CX86RecompilerOps::XORI() { Map_GPR_64bit(m_Opcode.rt, m_Opcode.rs); } - if (m_Opcode.immediate != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); } + if (m_Opcode.immediate != 0) + { + m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); + } } } @@ -2845,7 +2855,7 @@ void CX86RecompilerOps::LB_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr, boo m_RegWorkingSet.BeforeCallDirect(); m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); m_Assembler.PushImm32(((PAddr + 2) & ~0x3) & 0x1FFFFFFC); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][0], "RomMemoryHandler::Read32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][0], "RomMemoryHandler::Read32", 16); m_RegWorkingSet.AfterCallDirect(); m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); uint8_t Shift = (((PAddr & 1) ^ 3) << 3); @@ -2930,7 +2940,7 @@ void CX86RecompilerOps::LH_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr, boo m_RegWorkingSet.BeforeCallDirect(); m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); m_Assembler.PushImm32(((PAddr + 2) & ~0x3) & 0x1FFFFFFC); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][0], "RomMemoryHandler::Read32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][0], "RomMemoryHandler::Read32", 16); m_RegWorkingSet.AfterCallDirect(); m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); if (SignExtend) @@ -3191,29 +3201,29 @@ void CX86RecompilerOps::LW_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr) } break; case 0x04400000: - { - UpdateCounters(m_RegWorkingSet, false, true); + { + UpdateCounters(m_RegWorkingSet, false, true); - m_RegWorkingSet.BeforeCallDirect(); - m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); - m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][0], "VideoInterfaceHandler::Read32", 16); - m_RegWorkingSet.AfterCallDirect(); - m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); - } + m_RegWorkingSet.BeforeCallDirect(); + m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); + m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][0], "VideoInterfaceHandler::Read32", 16); + m_RegWorkingSet.AfterCallDirect(); + m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); break; + } case 0x04500000: - { - UpdateCounters(m_RegWorkingSet, false, true, false); + { + UpdateCounters(m_RegWorkingSet, false, true, false); - m_RegWorkingSet.BeforeCallDirect(); - m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); - m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][0], "AudioInterfaceHandler::Read32", 16); - m_RegWorkingSet.AfterCallDirect(); - m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); - } + m_RegWorkingSet.BeforeCallDirect(); + m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); + m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][0], "AudioInterfaceHandler::Read32", 16); + m_RegWorkingSet.AfterCallDirect(); + m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); break; + } case 0x04600000: switch (PAddr) { @@ -3315,7 +3325,7 @@ void CX86RecompilerOps::LW_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr) m_RegWorkingSet.BeforeCallDirect(); m_Assembler.PushImm32("m_TempValue32", (uint32_t)&m_TempValue32); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][0], "RomMemoryHandler::Read32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][0], "RomMemoryHandler::Read32", 16); m_RegWorkingSet.AfterCallDirect(); m_Assembler.MoveVariableToX86reg(&m_TempValue32, "m_TempValue32", Reg); } @@ -3965,7 +3975,7 @@ void CX86RecompilerOps::SWC1() PreWriteInstruction(); UnMap_FPR(m_Opcode.ft, true); CX86Ops::x86Reg ValueReg = Map_TempReg(CX86Ops::x86_Unknown, -1, false, false); - m_Assembler.MoveVariableToX86reg(&_FPR_S[m_Opcode.ft], stdstr_f("_FPR_S[%d]", m_Opcode.ft).c_str() , ValueReg); + m_Assembler.MoveVariableToX86reg(&_FPR_S[m_Opcode.ft], stdstr_f("_FPR_S[%d]", m_Opcode.ft).c_str(), ValueReg); m_Assembler.MoveX86PointerToX86reg(ValueReg, ValueReg); CompileStoreMemoryValue(CX86Ops::x86_Unknown, ValueReg, CX86Ops::x86_Unknown, 0, 32); @@ -4291,7 +4301,7 @@ void CX86RecompilerOps::SPECIAL_JR() m_Section->m_Cont.LinkLocation2 = nullptr; R4300iOpcode DelaySlot; - if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && + if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value)) { if (IsConst(m_Opcode.rs)) @@ -4350,7 +4360,7 @@ void CX86RecompilerOps::SPECIAL_JALR() if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { R4300iOpcode DelaySlot; - if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && + if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value) && (m_CompilePC & 0xFFC) != 0xFFC) { if (IsConst(m_Opcode.rs)) @@ -4397,7 +4407,7 @@ void CX86RecompilerOps::SPECIAL_JALR() else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE) { R4300iOpcode DelaySlot; - if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && + if (g_MMU->MemoryValue32(m_CompilePC + 4, DelaySlot.Value) && R4300iInstruction(m_CompilePC, m_Opcode.Value).DelaySlotEffectsCompare(DelaySlot.Value)) { CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, ExitReason_Normal, true, nullptr); @@ -4440,7 +4450,10 @@ void CX86RecompilerOps::SPECIAL_SYSCALL() void CX86RecompilerOps::SPECIAL_MFLO() { - if (m_Opcode.rd == 0) { return; } + if (m_Opcode.rd == 0) + { + return; + } Map_GPR_64bit(m_Opcode.rd, -1); m_Assembler.MoveVariableToX86reg(&_RegLO->UW[0], "_RegLO->UW[0]", GetMipsRegMapLo(m_Opcode.rd)); @@ -4491,7 +4504,10 @@ void CX86RecompilerOps::SPECIAL_MTLO() void CX86RecompilerOps::SPECIAL_MFHI() { - if (m_Opcode.rd == 0) { return; } + if (m_Opcode.rd == 0) + { + return; + } Map_GPR_64bit(m_Opcode.rd, -1); m_Assembler.MoveVariableToX86reg(&_RegHI->UW[0], "_RegHI->UW[0]", GetMipsRegMapLo(m_Opcode.rd)); @@ -4699,7 +4715,7 @@ void CX86RecompilerOps::SPECIAL_MULT() m_Assembler.MoveX86regToVariable(CX86Ops::x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); m_Assembler.MoveX86regToVariable(CX86Ops::x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - m_Assembler.ShiftRightSignImmed(CX86Ops::x86_EAX, 31); // Paired + m_Assembler.ShiftRightSignImmed(CX86Ops::x86_EAX, 31); // Paired m_Assembler.ShiftRightSignImmed(CX86Ops::x86_EDX, 31); m_Assembler.MoveX86regToVariable(CX86Ops::x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); m_Assembler.MoveX86regToVariable(CX86Ops::x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); @@ -4716,7 +4732,7 @@ void CX86RecompilerOps::SPECIAL_MULTU() m_Assembler.MoveX86regToVariable(CX86Ops::x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); m_Assembler.MoveX86regToVariable(CX86Ops::x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - m_Assembler.ShiftRightSignImmed(CX86Ops::x86_EAX, 31); // Paired + m_Assembler.ShiftRightSignImmed(CX86Ops::x86_EAX, 31); // Paired m_Assembler.ShiftRightSignImmed(CX86Ops::x86_EDX, 31); m_Assembler.MoveX86regToVariable(CX86Ops::x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); m_Assembler.MoveX86regToVariable(CX86Ops::x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); @@ -4724,7 +4740,7 @@ void CX86RecompilerOps::SPECIAL_MULTU() void CX86RecompilerOps::SPECIAL_DIV() { - CX86Ops::x86Reg RegRs = CX86Ops::x86_Unknown, RegRsHi = CX86Ops::x86_Unknown, DivReg = CX86Ops::x86_Unknown; + CX86Ops::x86Reg RegRs = CX86Ops::x86_Unknown, RegRsHi = CX86Ops::x86_Unknown, DivReg = CX86Ops::x86_Unknown; uint8_t * JumpNotDiv0 = nullptr; uint8_t * JumpEnd = nullptr; uint8_t * JumpEnd2 = nullptr; @@ -4779,7 +4795,7 @@ void CX86RecompilerOps::SPECIAL_DIV() m_Assembler.MoveConstToVariable(0x00000000, &_RegHI->UW[1], "_RegHI->UW[1]"); return; } - + m_RegWorkingSet.SetX86Protected(x86RegIndex_EAX, true); UnMap_X86reg(CX86Ops::x86_EDX); m_RegWorkingSet.SetX86Protected(x86RegIndex_EAX, false); @@ -5088,7 +5104,7 @@ void CX86RecompilerOps::SPECIAL_DMULTU() m_Assembler.AddX86RegToX86Reg(CX86Ops::x86_EAX, CX86Ops::x86_EBX); m_Assembler.AddConstToX86Reg(CX86Ops::x86_EDX, 0); m_Assembler.AddX86RegToX86Reg(CX86Ops::x86_EAX, CX86Ops::x86_ESI); - m_Assembler.AddConstToX86Reg(CX86Ops::x86_EDX, 0); // EDX:EAX + m_Assembler.AddConstToX86Reg(CX86Ops::x86_EDX, 0); // EDX:EAX /* _RegLO->UDW += ((uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]) << 32; */ /* [low+4] += ebx + esi */ @@ -5336,9 +5352,8 @@ void CX86RecompilerOps::SPECIAL_AND() if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - (Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) & - (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)) - ); + (Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) & + (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))); if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) { @@ -5546,9 +5561,8 @@ void CX86RecompilerOps::SPECIAL_OR() if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - (Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) | - (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)) - ); + (Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) | + (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))); if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) { m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); @@ -5626,7 +5640,10 @@ void CX86RecompilerOps::SPECIAL_OR() { int Value = GetMipsRegLo(ConstReg); Map_GPR_32bit(m_Opcode.rd, true, MappedReg); - if (Value != 0) { m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); } + if (Value != 0) + { + m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); + } } } } @@ -5720,7 +5737,10 @@ void CX86RecompilerOps::SPECIAL_XOR() if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - if (HaveDebugger()) { g_Notify->DisplayError("XOR 1"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("XOR 1"); + } CX86RecompilerOps::UnknownOpcode(); } else @@ -5774,8 +5794,14 @@ void CX86RecompilerOps::SPECIAL_XOR() ConstHi = Is32Bit(ConstReg) ? (uint32_t)(GetMipsRegLo_S(ConstReg) >> 31) : GetMipsRegHi(ConstReg); ConstLo = GetMipsRegLo(ConstReg); Map_GPR_64bit(m_Opcode.rd, MappedReg); - if (ConstHi != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); } - if (ConstLo != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); } + if (ConstHi != 0) + { + m_Assembler.XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); + } + if (ConstLo != 0) + { + m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); + } } else { @@ -5788,7 +5814,10 @@ void CX86RecompilerOps::SPECIAL_XOR() { Map_GPR_32bit(m_Opcode.rd, IsSigned(MappedReg), MappedReg); } - if (Value != 0) { m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); } + if (Value != 0) + { + m_Assembler.XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); + } } } } @@ -5868,9 +5897,8 @@ void CX86RecompilerOps::SPECIAL_NOR() if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - ~((Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) | - (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))) - ); + ~((Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) | + (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)))); if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) { m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); @@ -5939,7 +5967,8 @@ void CX86RecompilerOps::SPECIAL_NOR() m_Assembler.OrConstToX86Reg((uint32_t)(Value >> 32), GetMipsRegMapHi(m_Opcode.rd)); } uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); - if (dwValue != 0) { + if (dwValue != 0) + { m_Assembler.OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); } } @@ -5947,7 +5976,10 @@ void CX86RecompilerOps::SPECIAL_NOR() { int Value = GetMipsRegLo(ConstReg); Map_GPR_32bit(m_Opcode.rd, true, MappedReg); - if (Value != 0) { m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); } + if (Value != 0) + { + m_Assembler.OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); + } } } } @@ -6063,12 +6095,11 @@ void CX86RecompilerOps::SPECIAL_SLT() if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) { - uint8_t *Jump[2]; + uint8_t * Jump[2]; m_Assembler.CompX86RegToX86Reg( Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false), - Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) - ); + Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false)); m_Assembler.JeLabel8("Low Compare", 0); Jump[0] = *g_RecompPos - 1; m_Assembler.SetlVariable(&m_BranchCompare, "m_BranchCompare"); @@ -6111,12 +6142,11 @@ void CX86RecompilerOps::SPECIAL_SLT() ProtectGPR(MappedReg); if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - uint8_t *Jump[2]; + uint8_t * Jump[2]; m_Assembler.CompConstToX86reg( Is64Bit(MappedReg) ? GetMipsRegMapHi(MappedReg) : Map_TempReg(CX86Ops::x86_Unknown, MappedReg, true, false), - Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31) - ); + Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31)); m_Assembler.JeLabel8("Low Compare", 0); Jump[0] = *g_RecompPos - 1; if (MappedReg == m_Opcode.rs) @@ -6185,7 +6215,7 @@ void CX86RecompilerOps::SPECIAL_SLT() { uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - uint8_t *Jump[2]; + uint8_t * Jump[2]; if (!g_System->b32BitCore()) { @@ -6312,7 +6342,7 @@ void CX86RecompilerOps::SPECIAL_SLT() } else { - uint8_t *Jump[2] = { nullptr, nullptr }; + uint8_t * Jump[2] = {nullptr, nullptr}; CX86Ops::x86Reg Reg = Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false); m_Assembler.CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); @@ -6379,12 +6409,11 @@ void CX86RecompilerOps::SPECIAL_SLTU() if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) { - uint8_t *Jump[2]; + uint8_t * Jump[2]; m_Assembler.CompX86RegToX86Reg( Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false), - Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false) - ); + Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, true, false)); m_Assembler.JeLabel8("Low Compare", 0); Jump[0] = *g_RecompPos - 1; m_Assembler.SetbVariable(&m_BranchCompare, "m_BranchCompare"); @@ -6416,14 +6445,17 @@ void CX86RecompilerOps::SPECIAL_SLTU() { uint32_t ConstHi, ConstLo, ConstReg, MappedReg; CX86Ops::x86Reg MappedRegHi, MappedRegLo; - uint8_t *Jump[2]; + uint8_t * Jump[2]; ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; ConstLo = GetMipsRegLo_S(ConstReg); ConstHi = GetMipsRegLo_S(ConstReg) >> 31; - if (Is64Bit(ConstReg)) { ConstHi = GetMipsRegHi(ConstReg); } + if (Is64Bit(ConstReg)) + { + ConstHi = GetMipsRegHi(ConstReg); + } ProtectGPR(MappedReg); MappedRegLo = GetMipsRegMapLo(MappedReg); @@ -6489,7 +6521,7 @@ void CX86RecompilerOps::SPECIAL_SLTU() { uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - uint8_t *Jump[2] = { nullptr, nullptr }; + uint8_t * Jump[2] = {nullptr, nullptr}; ProtectGPR(KnownReg); if (g_System->b32BitCore()) @@ -6592,7 +6624,7 @@ void CX86RecompilerOps::SPECIAL_SLTU() } else { - uint8_t *Jump[2] = { nullptr, nullptr }; + uint8_t * Jump[2] = {nullptr, nullptr}; CX86Ops::x86Reg Reg = Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rs, true, false); m_Assembler.CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); @@ -6723,7 +6755,10 @@ void CX86RecompilerOps::SPECIAL_DADDU() int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - if (IsMapped(source2)) { ProtectGPR(source2); } + if (IsMapped(source2)) + { + ProtectGPR(source2); + } Map_GPR_64bit(m_Opcode.rd, source1); if (IsConst(source2)) { @@ -6840,9 +6875,8 @@ void CX86RecompilerOps::SPECIAL_DSUBU() } m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) - - Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt) - ); + Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) - Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) + : (int64_t)GetMipsRegLo_S(m_Opcode.rt)); if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) { m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); @@ -6867,7 +6901,10 @@ void CX86RecompilerOps::SPECIAL_DSUBU() m_Assembler.SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } + if (IsMapped(m_Opcode.rt)) + { + ProtectGPR(m_Opcode.rt); + } Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs); if (IsConst(m_Opcode.rt)) { @@ -7095,7 +7132,8 @@ void CX86RecompilerOps::SPECIAL_DSRL32() CX86RecompilerOps::UnknownOpcode(); } } - else { + else + { Map_GPR_32bit(m_Opcode.rd, false, -1); m_Assembler.MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1], CRegName::GPR_Hi[m_Opcode.rt], GetMipsRegMapLo(m_Opcode.rd)); if ((uint8_t)m_Opcode.sa != 0) @@ -7145,7 +7183,8 @@ void CX86RecompilerOps::SPECIAL_DSRA32() CX86RecompilerOps::UnknownOpcode(); } } - else { + else + { Map_GPR_32bit(m_Opcode.rd, true, -1); m_Assembler.MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1], CRegName::GPR_Lo[m_Opcode.rt], GetMipsRegMapLo(m_Opcode.rd)); if ((uint8_t)m_Opcode.sa != 0) @@ -7172,15 +7211,15 @@ void CX86RecompilerOps::COP0_MF() void CX86RecompilerOps::COP0_MT() { - uint8_t *Jump; + uint8_t * Jump; switch (m_Opcode.rd) { - case 0: // Index - case 2: // EntryLo0 - case 3: // EntryLo1 - case 4: // Context - case 5: // PageMask + case 0: // Index + case 2: // EntryLo0 + case 3: // EntryLo1 + case 4: // Context + case 5: // PageMask case 10: // Entry Hi case 14: // EPC case 16: // Config @@ -7250,34 +7289,35 @@ void CX86RecompilerOps::COP0_MT() m_RegWorkingSet.AfterCallDirect(); break; case 12: // Status + { + CX86Ops::x86Reg OldStatusReg = Map_TempReg(CX86Ops::x86_Unknown, -1, false, false); + m_Assembler.MoveVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); + if (IsConst(m_Opcode.rt)) { - CX86Ops::x86Reg OldStatusReg = Map_TempReg(CX86Ops::x86_Unknown, -1, false, false); - m_Assembler.MoveVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); - if (IsConst(m_Opcode.rt)) - { - m_Assembler.MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - else if (IsMapped(m_Opcode.rt)) - { - m_Assembler.MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - else { - m_Assembler.MoveX86regToVariable(Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, false, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - m_Assembler.XorVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); - m_Assembler.TestConstToX86Reg(STATUS_FR, OldStatusReg); - m_Assembler.JeLabel8("FpuFlagFine", 0); - Jump = *g_RecompPos - 1; - m_RegWorkingSet.BeforeCallDirect(); - m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::FixFpuLocations), "CRegisters::FixFpuLocations", 4); - m_RegWorkingSet.AfterCallDirect(); - m_Assembler.SetJump8(Jump, *g_RecompPos); - - m_RegWorkingSet.BeforeCallDirect(); - m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts", 4); - m_RegWorkingSet.AfterCallDirect(); + m_Assembler.MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } + else if (IsMapped(m_Opcode.rt)) + { + m_Assembler.MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else + { + m_Assembler.MoveX86regToVariable(Map_TempReg(CX86Ops::x86_Unknown, m_Opcode.rt, false, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + m_Assembler.XorVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); + m_Assembler.TestConstToX86Reg(STATUS_FR, OldStatusReg); + m_Assembler.JeLabel8("FpuFlagFine", 0); + Jump = *g_RecompPos - 1; + m_RegWorkingSet.BeforeCallDirect(); + m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::FixFpuLocations), "CRegisters::FixFpuLocations", 4); + m_RegWorkingSet.AfterCallDirect(); + m_Assembler.SetJump8(Jump, *g_RecompPos); + + m_RegWorkingSet.BeforeCallDirect(); + m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts", 4); + m_RegWorkingSet.AfterCallDirect(); break; + } case 6: // Wired UpdateCounters(m_RegWorkingSet, false, true); m_RegWorkingSet.BeforeCallDirect(); @@ -7392,7 +7432,7 @@ void CX86RecompilerOps::ChangeDefaultRoundingModel() { case 0: *_RoundingModel = FE_TONEAREST; break; case 1: *_RoundingModel = FE_TOWARDZERO; break; - case 2: *_RoundingModel = FE_UPWARD; break; + case 2: *_RoundingModel = FE_UPWARD; break; case 3: *_RoundingModel = FE_DOWNWARD; break; } } @@ -7483,7 +7523,8 @@ void CX86RecompilerOps::COP1_DMT() if ((m_Opcode.fs & 1) == 0) { - if (RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Float) || RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Dword)) { + if (RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Float) || RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Dword)) + { UnMap_FPR(m_Opcode.fs + 1, true); } } @@ -7851,9 +7892,18 @@ void CX86RecompilerOps::COP1_S_CMP() } CompileCop1Test(); - if ((m_Opcode.funct & 7) == 0) { CX86RecompilerOps::UnknownOpcode(); } - if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } - if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } + if ((m_Opcode.funct & 7) == 0) + { + CX86RecompilerOps::UnknownOpcode(); + } + if ((m_Opcode.funct & 2) != 0) + { + cmp |= 0x4000; + } + if ((m_Opcode.funct & 4) != 0) + { + cmp |= 0x0100; + } Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Float); Map_TempReg(CX86Ops::x86_EAX, 0, false, false); @@ -8225,9 +8275,18 @@ void CX86RecompilerOps::COP1_D_CMP() } CompileCop1Test(); - if ((m_Opcode.funct & 7) == 0) { CX86RecompilerOps::UnknownOpcode(); } - if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } - if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } + if ((m_Opcode.funct & 7) == 0) + { + CX86RecompilerOps::UnknownOpcode(); + } + if ((m_Opcode.funct & 2) != 0) + { + cmp |= 0x4000; + } + if ((m_Opcode.funct & 4) != 0) + { + cmp |= 0x0100; + } Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Double); Map_TempReg(CX86Ops::x86_EAX, 0, false, false); @@ -8335,7 +8394,10 @@ void CX86RecompilerOps::UnknownOpcode() m_Assembler.MoveConstToVariable(m_Opcode.Value, &R4300iOp::m_Opcode.Value, "R4300iOp::m_Opcode.Value"); m_Assembler.CallFunc((uint32_t)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); m_Assembler.Ret(); - if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } + if (m_PipelineStage == PIPELINE_STAGE_NORMAL) + { + m_PipelineStage = PIPELINE_STAGE_END_BLOCK; + } } void CX86RecompilerOps::ClearCachedInstructionInfo() @@ -8343,7 +8405,7 @@ void CX86RecompilerOps::ClearCachedInstructionInfo() m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet, false, true); m_Assembler.MoveConstToVariable(m_CompilePC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); - if (g_SyncSystem) + if (g_SyncSystem) { m_Assembler.CallThis((uint32_t)g_BaseSystem, AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem", 4); } @@ -8386,7 +8448,7 @@ void CX86RecompilerOps::TestBreakpoint(CX86Ops::x86Reg AddressReg, uint32_t Func m_RegWorkingSet.AfterCallDirect(); m_Assembler.CompConstToVariable(0, &memory_breakpoint_found, "memory_breakpoint_found"); m_Assembler.JeLabel8("NoBreakPoint", 0); - uint8_t * Jump = *g_RecompPos - 1; + uint8_t * Jump = *g_RecompPos - 1; m_Assembler.MoveConstToVariable(0, &memory_breakpoint_found, "memory_breakpoint_found"); ExitCodeBlock(); m_CodeBlock.Log(" "); @@ -8503,7 +8565,10 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo) bool changed = false; UnMap_AllFPRs(); - if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } + if (m_RegWorkingSet.GetRoundingModel() != SyncTo.GetRoundingModel()) + { + m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); + } CX86Ops::x86Reg MemStackReg = Get_MemoryStack(); CX86Ops::x86Reg TargetStackReg = SyncTo.Get_MemoryStack(); @@ -8537,7 +8602,7 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo) (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO)) { - switch (GetMipsRegState(i)) + switch (GetMipsRegState(i)) { case CRegInfo::STATE_UNKNOWN: continue; case CRegInfo::STATE_MAPPED_64: @@ -8576,139 +8641,139 @@ void CX86RecompilerOps::SyncRegState(const CRegInfo & SyncTo) switch (SyncTo.GetMipsRegState(i)) { - case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break; + case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break; case CRegInfo::STATE_MAPPED_64: + { + CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i); + CX86Ops::x86Reg x86RegHi = SyncTo.GetMipsRegMapHi(i); + UnMap_X86reg(Reg); + UnMap_X86reg(x86RegHi); + switch (GetMipsRegState(i)) { - CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i); - CX86Ops::x86Reg x86RegHi = SyncTo.GetMipsRegMapHi(i); - UnMap_X86reg(Reg); - UnMap_X86reg(x86RegHi); - switch (GetMipsRegState(i)) - { - case CRegInfo::STATE_UNKNOWN: - m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); - m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], x86RegHi); - break; - case CRegInfo::STATE_MAPPED_64: - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapHi(i), x86RegHi); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapHi(i)), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_SIGN: - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), x86RegHi); - m_Assembler.ShiftRightSignImmed(x86RegHi, 31); - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_ZERO: - m_Assembler.XorX86RegToX86Reg(x86RegHi, x86RegHi); - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_CONST_64: - m_Assembler.MoveConstToX86reg(GetMipsRegHi(i), x86RegHi); - m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); - break; - case CRegInfo::STATE_CONST_32_SIGN: - m_Assembler.MoveConstToX86reg(GetMipsRegLo_S(i) >> 31, x86RegHi); - m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); - break; - default: - m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i)); - g_Notify->BreakPoint(__FILE__, __LINE__); - continue; - } - m_RegWorkingSet.SetMipsRegMapLo(i, Reg); - m_RegWorkingSet.SetMipsRegMapHi(i, x86RegHi); - m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_64); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(x86RegHi), CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1); - m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(x86RegHi), 1); + case CRegInfo::STATE_UNKNOWN: + m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); + m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], x86RegHi); + break; + case CRegInfo::STATE_MAPPED_64: + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapHi(i), x86RegHi); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapHi(i)), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_SIGN: + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), x86RegHi); + m_Assembler.ShiftRightSignImmed(x86RegHi, 31); + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_ZERO: + m_Assembler.XorX86RegToX86Reg(x86RegHi, x86RegHi); + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_CONST_64: + m_Assembler.MoveConstToX86reg(GetMipsRegHi(i), x86RegHi); + m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); + break; + case CRegInfo::STATE_CONST_32_SIGN: + m_Assembler.MoveConstToX86reg(GetMipsRegLo_S(i) >> 31, x86RegHi); + m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); + break; + default: + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILE__, __LINE__); + continue; } + m_RegWorkingSet.SetMipsRegMapLo(i, Reg); + m_RegWorkingSet.SetMipsRegMapHi(i, x86RegHi); + m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_64); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(x86RegHi), CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1); + m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(x86RegHi), 1); break; + } case CRegInfo::STATE_MAPPED_32_SIGN: + { + CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i); + UnMap_X86reg(Reg); + switch (GetMipsRegState(i)) { - CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i); - UnMap_X86reg(Reg); - switch (GetMipsRegState(i)) + case CRegInfo::STATE_UNKNOWN: m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); break; + case CRegInfo::STATE_CONST_32_SIGN: m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); break; + case CRegInfo::STATE_MAPPED_32_SIGN: + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_ZERO: + if (GetMipsRegMapLo(i) != Reg) { - case CRegInfo::STATE_UNKNOWN: m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); break; - case CRegInfo::STATE_CONST_32_SIGN: m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); break; - case CRegInfo::STATE_MAPPED_32_SIGN: m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_ZERO: - if (GetMipsRegMapLo(i) != Reg) - { - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - } - break; - case CRegInfo::STATE_MAPPED_64: - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapHi(i)), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_CONST_64: - m_CodeBlock.Log("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i)); - default: - m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); - g_Notify->BreakPoint(__FILE__, __LINE__); } - m_RegWorkingSet.SetMipsRegMapLo(i, Reg); - m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1); + break; + case CRegInfo::STATE_MAPPED_64: + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapHi(i)), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_CONST_64: + m_CodeBlock.Log("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i)); + default: + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILE__, __LINE__); } + m_RegWorkingSet.SetMipsRegMapLo(i, Reg); + m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1); break; + } case CRegInfo::STATE_MAPPED_32_ZERO: + { + CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i); + UnMap_X86reg(Reg); + switch (GetMipsRegState(i)) { - CX86Ops::x86Reg Reg = SyncTo.GetMipsRegMapLo(i); - UnMap_X86reg(Reg); - switch (GetMipsRegState(i)) + case CRegInfo::STATE_MAPPED_64: + case CRegInfo::STATE_UNKNOWN: + m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); + break; + case CRegInfo::STATE_MAPPED_32_ZERO: + m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_SIGN: + if (g_System->b32BitCore()) { - case CRegInfo::STATE_MAPPED_64: - case CRegInfo::STATE_UNKNOWN: - m_Assembler.MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); - break; - case CRegInfo::STATE_MAPPED_32_ZERO: m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_SIGN: - if (g_System->b32BitCore()) - { - m_Assembler.MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(GetMipsRegMapLo(i)), CRegInfo::NotMapped); - } - else - { - m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); - g_Notify->BreakPoint(__FILE__, __LINE__); - } - break; - case CRegInfo::STATE_CONST_32_SIGN: - if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) - { - m_CodeBlock.Log("Sign problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); - m_CodeBlock.Log("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); - g_Notify->BreakPoint(__FILE__, __LINE__); - } - m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); - break; - default: + } + else + { m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); g_Notify->BreakPoint(__FILE__, __LINE__); } - m_RegWorkingSet.SetMipsRegMapLo(i, Reg); - m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i)); - m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1); + break; + case CRegInfo::STATE_CONST_32_SIGN: + if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) + { + m_CodeBlock.Log("Sign problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); + m_CodeBlock.Log("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); + g_Notify->BreakPoint(__FILE__, __LINE__); + } + m_Assembler.MoveConstToX86reg(GetMipsRegLo(i), Reg); + break; + default: + m_CodeBlock.Log("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILE__, __LINE__); } + m_RegWorkingSet.SetMipsRegMapLo(i, Reg); + m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i)); + m_RegWorkingSet.SetX86Mapped(GetIndexFromX86Reg(Reg), CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86MapOrder(GetIndexFromX86Reg(Reg), 1); break; + } default: m_CodeBlock.Log("%d - %d reg: %s (%d)", SyncTo.GetMipsRegState(i), GetMipsRegState(i), CRegName::GPR[i], i); g_Notify->BreakPoint(__FILE__, __LINE__); @@ -8769,7 +8834,10 @@ bool CX86RecompilerOps::InheritParentInfo() CCodeSection * Parent = *iter; BLOCK_PARENT BlockParent; - if (Parent->m_CompiledLocation == nullptr) { continue; } + if (Parent->m_CompiledLocation == nullptr) + { + continue; + } if (Parent->m_JumpSection != Parent->m_ContinueSection) { BlockParent.Parent = Parent; @@ -8799,7 +8867,10 @@ bool CX86RecompilerOps::InheritParentInfo() CCodeSection * Parent = *iter; BLOCK_PARENT BlockParent; - if (Parent->m_CompiledLocation != nullptr) { continue; } + if (Parent->m_CompiledLocation != nullptr) + { + continue; + } if (Parent->m_JumpSection != Parent->m_ContinueSection) { BlockParent.Parent = Parent; @@ -8874,7 +8945,10 @@ bool CX86RecompilerOps::InheritParentInfo() // Determine loop registry usage if (m_Section->m_InLoop && ParentList.size() > 1) { - if (!SetupRegisterForLoop(m_Section->m_CodeBlock, m_Section->m_RegEnter)) { return false; } + if (!SetupRegisterForLoop(m_Section->m_CodeBlock, m_Section->m_RegEnter)) + { + return false; + } m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } @@ -8883,7 +8957,10 @@ bool CX86RecompilerOps::InheritParentInfo() CX86Ops::x86Reg MemoryStackPos; int i2; - if (i == (size_t)FirstParent) { continue; } + if (i == (size_t)FirstParent) + { + continue; + } Parent = ParentList[i].Parent; if (Parent->m_CompiledLocation == nullptr) { @@ -8891,7 +8968,10 @@ bool CX86RecompilerOps::InheritParentInfo() } CRegInfo * RegSet = &ParentList[i].JumpInfo->RegSet; - if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } + if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) + { + m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); + } // Find parent MapRegState MemoryStackPos = CX86Ops::x86_Unknown; @@ -8951,7 +9031,8 @@ bool CX86RecompilerOps::InheritParentInfo() g_Notify->BreakPoint(__FILE__, __LINE__); } } - if (IsConst(i2)) { + if (IsConst(i2)) + { if (GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) { switch (RegSet->GetMipsRegState(i2)) @@ -9023,12 +9104,18 @@ bool CX86RecompilerOps::InheritParentInfo() CRegInfo * RegSet; int i2; - if (i == (size_t)FirstParent) { continue; } + if (i == (size_t)FirstParent) + { + continue; + } Parent = ParentList[i].Parent; JumpInfo = ParentList[i].JumpInfo; RegSet = &ParentList[i].JumpInfo->RegSet; - if (JumpInfo->RegSet.GetBlockCycleCount() != 0) { NeedSync = true; } + if (JumpInfo->RegSet.GetBlockCycleCount() != 0) + { + NeedSync = true; + } for (i2 = 0; !NeedSync && i2 < 8; i2++) { @@ -9051,7 +9138,10 @@ bool CX86RecompilerOps::InheritParentInfo() } for (i2 = 0; !NeedSync && i2 < 32; i2++) { - if (NeedSync == true) { break; } + if (NeedSync == true) + { + break; + } if (m_RegWorkingSet.GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) { NeedSync = true; @@ -9087,7 +9177,10 @@ bool CX86RecompilerOps::InheritParentInfo() g_Notify->BreakPoint(__FILE__, __LINE__); } } - if (NeedSync == false) { continue; } + if (NeedSync == false) + { + continue; + } Parent = ParentList[CurrentParent].Parent; JumpInfo = ParentList[CurrentParent].JumpInfo; m_Assembler.JmpLabel32(Label.c_str(), 0); @@ -9120,7 +9213,7 @@ bool CX86RecompilerOps::InheritParentInfo() { UpdateCounters(m_RegWorkingSet, false, true); } - SyncRegState(m_Section->m_RegEnter); // Sync + SyncRegState(m_Section->m_RegEnter); // Sync m_Section->m_RegEnter = m_RegWorkingSet; } @@ -9172,7 +9265,7 @@ void CX86RecompilerOps::JumpToSection(CCodeSection * Section) void CX86RecompilerOps::JumpToUnknown(CJumpInfo * JumpInfo) { m_Assembler.JmpLabel32(JumpInfo->BranchLabel.c_str(), 0); - JumpInfo->LinkLocation = (uint32_t*)(*g_RecompPos - 4); + JumpInfo->LinkLocation = (uint32_t *)(*g_RecompPos - 4); } void CX86RecompilerOps::SetCurrentPC(uint32_t ProgramCounter) @@ -9364,12 +9457,12 @@ void CX86RecompilerOps::OverflowDelaySlot(bool TestTimer) m_PipelineStage = PIPELINE_STAGE_END_BLOCK; } -void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason) +void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason) { CompileExit(JumpPC, TargetPC, ExitRegSet, reason, true, nullptr); } -void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason reason, bool CompileNow, void(CX86Ops::*x86Jmp)(const char * Label, uint32_t Value)) +void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason reason, bool CompileNow, void (CX86Ops::*x86Jmp)(const char * Label, uint32_t Value)) { if (!CompileNow) { @@ -9529,22 +9622,22 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo ExitCodeBlock(); break; case ExitReason_DoSysCall: - { - bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; - m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay); - m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException", 4); - ExitCodeBlock(); - } + { + bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; + m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay); + m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException", 4); + ExitCodeBlock(); break; + } case ExitReason_COP1Unuseable: - { - bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; - m_Assembler.PushImm32("1", 1); - m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay); - m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException", 12); - ExitCodeBlock(); - } + { + bool bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT; + m_Assembler.PushImm32("1", 1); + m_Assembler.PushImm32(bDelay ? "true" : "false", bDelay); + m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException", 12); + ExitCodeBlock(); break; + } case ExitReason_ResetRecompCode: g_Notify->BreakPoint(__FILE__, __LINE__); ExitCodeBlock(); @@ -9690,7 +9783,7 @@ void CX86RecompilerOps::CompileLoadMemoryValue(CX86Ops::x86Reg AddressReg, CX86O } else { - m_Assembler.X86BreakPoint(__FILE__,__LINE__); + m_Assembler.X86BreakPoint(__FILE__, __LINE__); } if (OpsExecuted != 0) { @@ -10049,7 +10142,7 @@ void CX86RecompilerOps::SB_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value << ((3 - (PAddr & 3)) * 8)); m_Assembler.PushImm32(PAddr); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); } else if (BreakOnUnhandledMemory()) @@ -10159,7 +10252,7 @@ void CX86RecompilerOps::SH_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value << ((2 - (PAddr & 2)) * 8)); m_Assembler.PushImm32(PAddr); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); } else if (BreakOnUnhandledMemory()) @@ -10314,7 +10407,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x04040010: @@ -10356,113 +10449,114 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) switch (PAddr) { case 0x04300000: + { + uint32_t ModValue; + ModValue = 0x7F; + if ((Value & MI_CLR_INIT) != 0) { - uint32_t ModValue; - ModValue = 0x7F; - if ((Value & MI_CLR_INIT) != 0) - { - ModValue |= MI_MODE_INIT; - } - if ((Value & MI_CLR_EBUS) != 0) - { - ModValue |= MI_MODE_EBUS; - } - if ((Value & MI_CLR_RDRAM) != 0) - { - ModValue |= MI_MODE_RDRAM; - } - if (ModValue != 0) - { - m_Assembler.AndConstToVariable(~ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG"); - } + ModValue |= MI_MODE_INIT; + } + if ((Value & MI_CLR_EBUS) != 0) + { + ModValue |= MI_MODE_EBUS; + } + if ((Value & MI_CLR_RDRAM) != 0) + { + ModValue |= MI_MODE_RDRAM; + } + if (ModValue != 0) + { + m_Assembler.AndConstToVariable(~ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG"); + } - ModValue = (Value & 0x7F); - if ((Value & MI_SET_INIT) != 0) - { - ModValue |= MI_MODE_INIT; - } - if ((Value & MI_SET_EBUS) != 0) - { - ModValue |= MI_MODE_EBUS; - } - if ((Value & MI_SET_RDRAM) != 0) - { - ModValue |= MI_MODE_RDRAM; - } - if (ModValue != 0) { - m_Assembler.OrConstToVariable(ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG"); - } - if ((Value & MI_CLR_DP_INTR) != 0) - { - m_Assembler.AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); - m_Assembler.AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->m_GfxIntrReg, "m_GfxIntrReg"); - } + ModValue = (Value & 0x7F); + if ((Value & MI_SET_INIT) != 0) + { + ModValue |= MI_MODE_INIT; + } + if ((Value & MI_SET_EBUS) != 0) + { + ModValue |= MI_MODE_EBUS; + } + if ((Value & MI_SET_RDRAM) != 0) + { + ModValue |= MI_MODE_RDRAM; + } + if (ModValue != 0) + { + m_Assembler.OrConstToVariable(ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG"); + } + if ((Value & MI_CLR_DP_INTR) != 0) + { + m_Assembler.AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + m_Assembler.AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->m_GfxIntrReg, "m_GfxIntrReg"); } break; + } case 0x0430000C: + { + uint32_t ModValue; + ModValue = 0; + if ((Value & MI_INTR_MASK_CLR_SP) != 0) { - uint32_t ModValue; - ModValue = 0; - if ((Value & MI_INTR_MASK_CLR_SP) != 0) - { - ModValue |= MI_INTR_MASK_SP; - } - if ((Value & MI_INTR_MASK_CLR_SI) != 0) - { - ModValue |= MI_INTR_MASK_SI; - } - if ((Value & MI_INTR_MASK_CLR_AI) != 0) - { - ModValue |= MI_INTR_MASK_AI; - } - if ((Value & MI_INTR_MASK_CLR_VI) != 0) - { - ModValue |= MI_INTR_MASK_VI; - } - if ((Value & MI_INTR_MASK_CLR_PI) != 0) - { - ModValue |= MI_INTR_MASK_PI; - } - if ((Value & MI_INTR_MASK_CLR_DP) != 0) - { - ModValue |= MI_INTR_MASK_DP; - } - if (ModValue != 0) - { - m_Assembler.AndConstToVariable(~ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG"); - } + ModValue |= MI_INTR_MASK_SP; + } + if ((Value & MI_INTR_MASK_CLR_SI) != 0) + { + ModValue |= MI_INTR_MASK_SI; + } + if ((Value & MI_INTR_MASK_CLR_AI) != 0) + { + ModValue |= MI_INTR_MASK_AI; + } + if ((Value & MI_INTR_MASK_CLR_VI) != 0) + { + ModValue |= MI_INTR_MASK_VI; + } + if ((Value & MI_INTR_MASK_CLR_PI) != 0) + { + ModValue |= MI_INTR_MASK_PI; + } + if ((Value & MI_INTR_MASK_CLR_DP) != 0) + { + ModValue |= MI_INTR_MASK_DP; + } + if (ModValue != 0) + { + m_Assembler.AndConstToVariable(~ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG"); + } - ModValue = 0; - if ((Value & MI_INTR_MASK_SET_SP) != 0) - { - ModValue |= MI_INTR_MASK_SP; - } - if ((Value & MI_INTR_MASK_SET_SI) != 0) - { - ModValue |= MI_INTR_MASK_SI; - } - if ((Value & MI_INTR_MASK_SET_AI) != 0) - { - ModValue |= MI_INTR_MASK_AI; - } - if ((Value & MI_INTR_MASK_SET_VI) != 0) - { - ModValue |= MI_INTR_MASK_VI; - } - if ((Value & MI_INTR_MASK_SET_PI) != 0) - { - ModValue |= MI_INTR_MASK_PI; - } - if ((Value & MI_INTR_MASK_SET_DP) != 0) - { - ModValue |= MI_INTR_MASK_DP; - } - if (ModValue != 0) - { - m_Assembler.OrConstToVariable(ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG"); - } + ModValue = 0; + if ((Value & MI_INTR_MASK_SET_SP) != 0) + { + ModValue |= MI_INTR_MASK_SP; + } + if ((Value & MI_INTR_MASK_SET_SI) != 0) + { + ModValue |= MI_INTR_MASK_SI; + } + if ((Value & MI_INTR_MASK_SET_AI) != 0) + { + ModValue |= MI_INTR_MASK_AI; + } + if ((Value & MI_INTR_MASK_SET_VI) != 0) + { + ModValue |= MI_INTR_MASK_VI; + } + if ((Value & MI_INTR_MASK_SET_PI) != 0) + { + ModValue |= MI_INTR_MASK_PI; + } + if ((Value & MI_INTR_MASK_SET_DP) != 0) + { + ModValue |= MI_INTR_MASK_DP; + } + if (ModValue != 0) + { + m_Assembler.OrConstToVariable(ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG"); } break; + } default: if (BreakOnUnhandledMemory()) { @@ -10479,7 +10573,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); } else @@ -10548,7 +10642,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][1], "AudioInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][1], "AudioInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x04600000: @@ -10567,7 +10661,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler)[0][1], "PeripheralInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler)[0][1], "PeripheralInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x04600014: m_Assembler.MoveConstToVariable((Value & 0xFF), &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); break; @@ -10651,16 +10745,16 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) break; } case 0x1fc00000: - { - UpdateCounters(m_RegWorkingSet, false, true, false); + { + UpdateCounters(m_RegWorkingSet, false, true, false); - m_RegWorkingSet.BeforeCallDirect(); - m_Assembler.PushImm32(Value); - m_Assembler.PushImm32(PAddr | 0xA0000000); - m_Assembler.CallThis((uint32_t)g_MMU, AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory", 4); - m_RegWorkingSet.AfterCallDirect(); - } + m_RegWorkingSet.BeforeCallDirect(); + m_Assembler.PushImm32(Value); + m_Assembler.PushImm32(PAddr | 0xA0000000); + m_Assembler.CallThis((uint32_t)g_MMU, AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory", 4); + m_RegWorkingSet.AfterCallDirect(); break; + } default: if (PAddr >= 0x10000000 && PAddr < 0x20000000) { @@ -10668,7 +10762,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.PushImm32(Value); m_Assembler.PushImm32(PAddr); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); } else @@ -10745,7 +10839,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x04040010: @@ -10804,7 +10898,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler*)&g_MMU->m_MIPSInterfaceHandler, (uint32_t)((long**)(MemoryHandler*)&g_MMU->m_MIPSInterfaceHandler)[0][1], "MIPSInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_MIPSInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_MIPSInterfaceHandler)[0][1], "MIPSInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x0430000C: @@ -10830,7 +10924,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); } else @@ -10905,7 +10999,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][1], "AudioInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_AudioInterfaceHandler)[0][1], "AudioInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x04600000: @@ -10924,7 +11018,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler)[0][1], "PeripheralInterfaceHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_PeripheralInterfaceHandler)[0][1], "PeripheralInterfaceHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x04600014: @@ -11054,7 +11148,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr & 0x1FFFFFFF); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_ISViewerHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_ISViewerHandler)[0][1], "ISViewerHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_ISViewerHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_ISViewerHandler)[0][1], "ISViewerHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); break; case 0x1FC00000: @@ -11068,7 +11162,7 @@ void CX86RecompilerOps::SW_Register(CX86Ops::x86Reg Reg, uint32_t VAddr) m_Assembler.PushImm32(0xFFFFFFFF); m_Assembler.Push(Reg); m_Assembler.PushImm32(PAddr); - m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long**)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); + m_Assembler.CallThis((uint32_t)(MemoryHandler *)&g_MMU->m_RomMemoryHandler, (uint32_t)((long **)(MemoryHandler *)&g_MMU->m_RomMemoryHandler)[0][1], "RomMemoryHandler::Write32", 16); m_RegWorkingSet.AfterCallDirect(); } else diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h index 1d4a0e98f..dc354f70b 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h @@ -1,17 +1,17 @@ #pragma once #if defined(__i386__) || defined(_M_IX86) -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include class CCodeBlock; class CCodeSection; @@ -230,7 +230,7 @@ public: const R4300iOpcode & GetOpcode(void) const; void PreCompileOpcode(void); void PostCompileOpcode(void); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason Reason); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason Reason); void CompileReadTLBMiss(uint32_t VirtualAddress, CX86Ops::x86Reg LookUpReg); void CompileReadTLBMiss(CX86Ops::x86Reg AddressReg, CX86Ops::x86Reg LookUpReg); @@ -243,60 +243,183 @@ public: static void ChangeDefaultRoundingModel(); void OverflowDelaySlot(bool TestTimer); - CX86Ops & Assembler() { return m_Assembler; } + CX86Ops & Assembler() + { + return m_Assembler; + } // Helper functions typedef CRegInfo::REG_STATE REG_STATE; - REG_STATE GetMipsRegState(int32_t Reg) { return m_RegWorkingSet.GetMipsRegState(Reg); } - uint64_t GetMipsReg(int32_t Reg) { return m_RegWorkingSet.GetMipsReg(Reg); } - int64_t GetMipsReg_S(int32_t Reg) { return m_RegWorkingSet.GetMipsReg_S(Reg); } - uint32_t GetMipsRegLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo(Reg); } - int32_t GetMipsRegLo_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); } - uint32_t GetMipsRegHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi(Reg); } - int32_t GetMipsRegHi_S(int32_t Reg) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); } - CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); } - CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); } + REG_STATE GetMipsRegState(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegState(Reg); + } + uint64_t GetMipsReg(int32_t Reg) + { + return m_RegWorkingSet.GetMipsReg(Reg); + } + int64_t GetMipsReg_S(int32_t Reg) + { + return m_RegWorkingSet.GetMipsReg_S(Reg); + } + uint32_t GetMipsRegLo(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegLo(Reg); + } + int32_t GetMipsRegLo_S(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegLo_S(Reg); + } + uint32_t GetMipsRegHi(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegHi(Reg); + } + int32_t GetMipsRegHi_S(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegHi_S(Reg); + } + CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegMapLo(Reg); + } + CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) + { + return m_RegWorkingSet.GetMipsRegMapHi(Reg); + } - bool IsKnown(int32_t Reg) { return m_RegWorkingSet.IsKnown(Reg); } - bool IsUnknown(int32_t Reg) { return m_RegWorkingSet.IsUnknown(Reg); } - bool IsMapped(int32_t Reg) { return m_RegWorkingSet.IsMapped(Reg); } - bool IsConst(int32_t Reg) { return m_RegWorkingSet.IsConst(Reg); } - bool IsSigned(int32_t Reg) { return m_RegWorkingSet.IsSigned(Reg); } - bool IsUnsigned(int32_t Reg) { return m_RegWorkingSet.IsUnsigned(Reg); } - bool Is32Bit(int32_t Reg) { return m_RegWorkingSet.Is32Bit(Reg); } - bool Is64Bit(int32_t Reg) { return m_RegWorkingSet.Is64Bit(Reg); } - bool Is32BitMapped(int32_t Reg) { return m_RegWorkingSet.Is32BitMapped(Reg); } - bool Is64BitMapped(int32_t Reg) { return m_RegWorkingSet.Is64BitMapped(Reg); } + bool IsKnown(int32_t Reg) + { + return m_RegWorkingSet.IsKnown(Reg); + } + bool IsUnknown(int32_t Reg) + { + return m_RegWorkingSet.IsUnknown(Reg); + } + bool IsMapped(int32_t Reg) + { + return m_RegWorkingSet.IsMapped(Reg); + } + bool IsConst(int32_t Reg) + { + return m_RegWorkingSet.IsConst(Reg); + } + bool IsSigned(int32_t Reg) + { + return m_RegWorkingSet.IsSigned(Reg); + } + bool IsUnsigned(int32_t Reg) + { + return m_RegWorkingSet.IsUnsigned(Reg); + } + bool Is32Bit(int32_t Reg) + { + return m_RegWorkingSet.Is32Bit(Reg); + } + bool Is64Bit(int32_t Reg) + { + return m_RegWorkingSet.Is64Bit(Reg); + } + bool Is32BitMapped(int32_t Reg) + { + return m_RegWorkingSet.Is32BitMapped(Reg); + } + bool Is64BitMapped(int32_t Reg) + { + return m_RegWorkingSet.Is64BitMapped(Reg); + } - void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) { m_RegWorkingSet.FixRoundModel(RoundMethod); } - void ChangeFPURegFormat(int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel) { m_RegWorkingSet.ChangeFPURegFormat(Reg, OldFormat, NewFormat, RoundingModel); } - void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format) { m_RegWorkingSet.Load_FPR_ToTop(Reg, RegToLoad, Format); } - bool RegInStack(int32_t Reg, CRegInfo::FPU_STATE Format) { return m_RegWorkingSet.RegInStack(Reg, Format); } - CX86Ops::x86FpuValues StackPosition(int32_t Reg) { return m_RegWorkingSet.StackPosition(Reg); } - void UnMap_AllFPRs() { m_RegWorkingSet.UnMap_AllFPRs(); } - void UnMap_FPR(uint32_t Reg, bool WriteBackValue) { m_RegWorkingSet.UnMap_FPR(Reg, WriteBackValue); } + void FixRoundModel(CRegInfo::FPU_ROUND RoundMethod) + { + m_RegWorkingSet.FixRoundModel(RoundMethod); + } + void ChangeFPURegFormat(int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel) + { + m_RegWorkingSet.ChangeFPURegFormat(Reg, OldFormat, NewFormat, RoundingModel); + } + void Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format) + { + m_RegWorkingSet.Load_FPR_ToTop(Reg, RegToLoad, Format); + } + bool RegInStack(int32_t Reg, CRegInfo::FPU_STATE Format) + { + return m_RegWorkingSet.RegInStack(Reg, Format); + } + CX86Ops::x86FpuValues StackPosition(int32_t Reg) + { + return m_RegWorkingSet.StackPosition(Reg); + } + void UnMap_AllFPRs() + { + m_RegWorkingSet.UnMap_AllFPRs(); + } + void UnMap_FPR(uint32_t Reg, bool WriteBackValue) + { + m_RegWorkingSet.UnMap_FPR(Reg, WriteBackValue); + } - CX86Ops::x86Reg FreeX86Reg() { return m_RegWorkingSet.FreeX86Reg(); } - CX86Ops::x86Reg Free8BitX86Reg() { return m_RegWorkingSet.Free8BitX86Reg(); } - void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); } - void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) { m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); } - CX86Ops::x86Reg Get_MemoryStack() { return m_RegWorkingSet.Get_MemoryStack(); } - CX86Ops::x86Reg Map_MemoryStack(CX86Ops::x86Reg Reg, bool bMapRegister, bool LoadValue = true) { return m_RegWorkingSet.Map_MemoryStack(Reg, bMapRegister, LoadValue); } - CX86Ops::x86Reg Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord, bool Reg8Bit) { return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord, Reg8Bit); } - void ProtectGPR(uint32_t Reg) { m_RegWorkingSet.ProtectGPR(Reg); } - void UnProtectGPR(uint32_t Reg) { m_RegWorkingSet.UnProtectGPR(Reg); } - void ResetX86Protection() { m_RegWorkingSet.ResetX86Protection(); } - CX86Ops::x86Reg UnMap_TempReg() { return m_RegWorkingSet.UnMap_TempReg(); } - void UnMap_GPR(uint32_t Reg, bool WriteBackValue) { m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); } - bool UnMap_X86reg(CX86Ops::x86Reg Reg) { return m_RegWorkingSet.UnMap_X86reg(Reg); } + CX86Ops::x86Reg FreeX86Reg() + { + return m_RegWorkingSet.FreeX86Reg(); + } + CX86Ops::x86Reg Free8BitX86Reg() + { + return m_RegWorkingSet.Free8BitX86Reg(); + } + void Map_GPR_32bit(int32_t Reg, bool SignValue, int32_t MipsRegToLoad) + { + m_RegWorkingSet.Map_GPR_32bit(Reg, SignValue, MipsRegToLoad); + } + void Map_GPR_64bit(int32_t Reg, int32_t MipsRegToLoad) + { + m_RegWorkingSet.Map_GPR_64bit(Reg, MipsRegToLoad); + } + CX86Ops::x86Reg Get_MemoryStack() + { + return m_RegWorkingSet.Get_MemoryStack(); + } + CX86Ops::x86Reg Map_MemoryStack(CX86Ops::x86Reg Reg, bool bMapRegister, bool LoadValue = true) + { + return m_RegWorkingSet.Map_MemoryStack(Reg, bMapRegister, LoadValue); + } + CX86Ops::x86Reg Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord, bool Reg8Bit) + { + return m_RegWorkingSet.Map_TempReg(Reg, MipsReg, LoadHiWord, Reg8Bit); + } + void ProtectGPR(uint32_t Reg) + { + m_RegWorkingSet.ProtectGPR(Reg); + } + void UnProtectGPR(uint32_t Reg) + { + m_RegWorkingSet.UnProtectGPR(Reg); + } + void ResetX86Protection() + { + m_RegWorkingSet.ResetX86Protection(); + } + CX86Ops::x86Reg UnMap_TempReg() + { + return m_RegWorkingSet.UnMap_TempReg(); + } + void UnMap_GPR(uint32_t Reg, bool WriteBackValue) + { + m_RegWorkingSet.UnMap_GPR(Reg, WriteBackValue); + } + bool UnMap_X86reg(CX86Ops::x86Reg Reg) + { + return m_RegWorkingSet.UnMap_X86reg(Reg); + } public: - uint32_t CompilePC() { return m_CompilePC; } + uint32_t CompilePC() + { + return m_CompilePC; + } private: - CX86RecompilerOps(const CX86RecompilerOps&); - CX86RecompilerOps& operator=(const CX86RecompilerOps&); + CX86RecompilerOps(const CX86RecompilerOps &); + CX86RecompilerOps & operator=(const CX86RecompilerOps &); CX86Ops::x86Reg BaseOffsetAddress(bool UseBaseRegister); void CompileLoadMemoryValue(CX86Ops::x86Reg AddressReg, CX86Ops::x86Reg ValueReg, CX86Ops::x86Reg ValueRegHi, uint8_t ValueSize, bool SignExtend); @@ -313,7 +436,7 @@ private: void LW_KnownAddress(CX86Ops::x86Reg Reg, uint32_t VAddr); void LW(bool ResultSigned, bool bRecordLLBit); void SW(bool bCheckLLbit); - void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, ExitReason Reason, bool CompileNow, void(CX86Ops::*x86Jmp)(const char * Label, uint32_t Value)); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo & ExitRegSet, ExitReason Reason, bool CompileNow, void (CX86Ops::*x86Jmp)(const char * Label, uint32_t Value)); void ResetMemoryStack(); EXIT_LIST m_ExitInfo; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp index 59963058d..577da2e0a 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp @@ -1,18 +1,18 @@ #include "stdafx.h" #if defined(__i386__) || defined(_M_IX86) -#include #include #include #include +#include +#include #include #include -#include uint32_t CX86RegInfo::m_fpuControl = 0; -const char *Format_Name[] = { "Unknown", "dword", "qword", "float", "double" }; +const char * Format_Name[] = {"Unknown", "dword", "qword", "float", "double"}; x86RegIndex GetIndexFromX86Reg(const CX86Ops::x86Reg & Reg) { @@ -74,7 +74,7 @@ CX86RegInfo::CX86RegInfo(CCodeBlock & CodeBlock, CX86Ops & Assembler) : } } -CX86RegInfo::CX86RegInfo(const CX86RegInfo& rhs) : +CX86RegInfo::CX86RegInfo(const CX86RegInfo & rhs) : m_CodeBlock(rhs.m_CodeBlock), m_Assembler(rhs.m_CodeBlock.RecompilerOps()->Assembler()) { @@ -85,7 +85,7 @@ CX86RegInfo::~CX86RegInfo() { } -CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right) +CX86RegInfo & CX86RegInfo::operator=(const CX86RegInfo & right) { CRegBase::operator=(right); m_Stack_TopPos = right.m_Stack_TopPos; @@ -111,7 +111,7 @@ CX86RegInfo& CX86RegInfo::operator=(const CX86RegInfo& right) return *this; } -bool CX86RegInfo::operator==(const CX86RegInfo& right) const +bool CX86RegInfo::operator==(const CX86RegInfo & right) const { if (!CRegBase::operator==(right)) { @@ -122,30 +122,57 @@ bool CX86RegInfo::operator==(const CX86RegInfo& right) const for (count = 0; count < 10; count++) { - if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count]) { return false; } - if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count]) { return false; } - if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count]) { return false; } + if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count]) + { + return false; + } + if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count]) + { + return false; + } + if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count]) + { + return false; + } + } + if (m_Stack_TopPos != right.m_Stack_TopPos) + { + return false; } - if (m_Stack_TopPos != right.m_Stack_TopPos) { return false; } for (count = 0; count < 8; count++) { - if (m_x86fpu_MappedTo[count] != right.m_x86fpu_MappedTo[count]) { return false; } - if (m_x86fpu_State[count] != right.m_x86fpu_State[count]) { return false; } - if (m_x86fpu_RoundingModel[count] != right.m_x86fpu_RoundingModel[count]) { return false; } + if (m_x86fpu_MappedTo[count] != right.m_x86fpu_MappedTo[count]) + { + return false; + } + if (m_x86fpu_State[count] != right.m_x86fpu_State[count]) + { + return false; + } + if (m_x86fpu_RoundingModel[count] != right.m_x86fpu_RoundingModel[count]) + { + return false; + } } return true; } -bool CX86RegInfo::operator!=(const CX86RegInfo& right) const +bool CX86RegInfo::operator!=(const CX86RegInfo & right) const { return !(right == *this); } CX86RegInfo::REG_STATE CX86RegInfo::ConstantsType(int64_t Value) { - if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0)) { return STATE_CONST_32_SIGN; } - if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0)) { return STATE_CONST_32_SIGN; } + if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0)) + { + return STATE_CONST_32_SIGN; + } + if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0)) + { + return STATE_CONST_32_SIGN; + } return STATE_CONST_64; } @@ -189,12 +216,12 @@ void CX86RegInfo::FixRoundModel(FPU_ROUND RoundMethod) { #ifdef _WIN32 static const unsigned int msRound[4] = - { - 0x00000000, //_RC_NEAR - 0x00000300, //_RC_CHOP - 0x00000200, //_RC_UP - 0x00000100, //_RC_DOWN - }; + { + 0x00000000, //_RC_NEAR + 0x00000300, //_RC_CHOP + 0x00000200, //_RC_UP + 0x00000100, //_RC_DOWN + }; CX86Ops::x86Reg RoundReg = Map_TempReg(CX86Ops::x86_Unknown, -1, false, false); m_Assembler.MoveVariableToX86reg(&g_Reg->m_RoundingModel, "m_RoundingModel", RoundReg); @@ -265,8 +292,16 @@ void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Forma m_CodeBlock.Log("CurrentRoundingModel: %s FpuRoundingModel(StackTopPos()): %s", RoundingModelName(GetRoundingModel()), RoundingModelName(FpuRoundingModel(StackTopPos()))); int32_t i; - if (RegToLoad < 0) { g_Notify->DisplayError("Load_FPR_ToTop\nRegToLoad < 0 ???"); return; } - if (Reg < 0) { g_Notify->DisplayError("Load_FPR_ToTop\nReg < 0 ???"); return; } + if (RegToLoad < 0) + { + g_Notify->DisplayError("Load_FPR_ToTop\nRegToLoad < 0 ???"); + return; + } + if (Reg < 0) + { + g_Notify->DisplayError("Load_FPR_ToTop\nReg < 0 ???"); + return; + } if (Format == FPU_Double || Format == FPU_Qword) { @@ -427,7 +462,10 @@ void CX86RegInfo::Load_FPR_ToTop(int32_t Reg, int32_t RegToLoad, FPU_STATE Forma m_Assembler.fpuLoadQwordFromX86Reg(&StackTopPos(), TempReg); break; default: - if (HaveDebugger()) { g_Notify->DisplayError(stdstr_f("Load_FPR_ToTop\nUnkown format to load %d", Format).c_str()); } + if (HaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("Load_FPR_ToTop\nUnkown format to load %d", Format).c_str()); + } } SetX86Protected(GetIndexFromX86Reg(TempReg), false); FpuRoundingModel(StackTopPos()) = RoundDefault; @@ -453,15 +491,36 @@ CX86Ops::x86FpuValues CX86RegInfo::StackPosition(int32_t Reg) CX86Ops::x86Reg CX86RegInfo::FreeX86Reg() { - if (GetX86Mapped(x86RegIndex_EDI) == NotMapped && !GetX86Protected(x86RegIndex_EDI)) { return CX86Ops::x86_EDI; } - if (GetX86Mapped(x86RegIndex_ESI) == NotMapped && !GetX86Protected(x86RegIndex_ESI)) { return CX86Ops::x86_ESI; } - if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX)) { return CX86Ops::x86_EBX; } - if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX)) { return CX86Ops::x86_EAX; } - if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX)) { return CX86Ops::x86_EDX; } - if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX)) { return CX86Ops::x86_ECX; } + if (GetX86Mapped(x86RegIndex_EDI) == NotMapped && !GetX86Protected(x86RegIndex_EDI)) + { + return CX86Ops::x86_EDI; + } + if (GetX86Mapped(x86RegIndex_ESI) == NotMapped && !GetX86Protected(x86RegIndex_ESI)) + { + return CX86Ops::x86_ESI; + } + if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX)) + { + return CX86Ops::x86_EBX; + } + if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX)) + { + return CX86Ops::x86_EAX; + } + if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX)) + { + return CX86Ops::x86_EDX; + } + if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX)) + { + return CX86Ops::x86_ECX; + } CX86Ops::x86Reg Reg = UnMap_TempReg(); - if (Reg != CX86Ops::x86_Unknown) { return Reg; } + if (Reg != CX86Ops::x86_Unknown) + { + return Reg; + } uint32_t MapCount[x86RegIndex_Size]; x86RegIndex MapReg[x86RegIndex_Size]; @@ -497,7 +556,10 @@ CX86Ops::x86Reg CX86RegInfo::FreeX86Reg() return (CX86Ops::x86Reg)MapReg[i]; } } - if (GetX86Mapped(MapReg[i]) == Stack_Mapped) { StackReg = GetX86RegFromIndex(MapReg[i]); } + if (GetX86Mapped(MapReg[i]) == Stack_Mapped) + { + StackReg = GetX86RegFromIndex(MapReg[i]); + } } if (StackReg != CX86Ops::x86_Unknown) { @@ -510,13 +572,28 @@ CX86Ops::x86Reg CX86RegInfo::FreeX86Reg() CX86Ops::x86Reg CX86RegInfo::Free8BitX86Reg() { - if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX)) { return CX86Ops::x86_EBX; } - if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX)) { return CX86Ops::x86_EAX; } - if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX)) { return CX86Ops::x86_EDX; } - if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX)) { return CX86Ops::x86_ECX; } + if (GetX86Mapped(x86RegIndex_EBX) == NotMapped && !GetX86Protected(x86RegIndex_EBX)) + { + return CX86Ops::x86_EBX; + } + if (GetX86Mapped(x86RegIndex_EAX) == NotMapped && !GetX86Protected(x86RegIndex_EAX)) + { + return CX86Ops::x86_EAX; + } + if (GetX86Mapped(x86RegIndex_EDX) == NotMapped && !GetX86Protected(x86RegIndex_EDX)) + { + return CX86Ops::x86_EDX; + } + if (GetX86Mapped(x86RegIndex_ECX) == NotMapped && !GetX86Protected(x86RegIndex_ECX)) + { + return CX86Ops::x86_ECX; + } CX86Ops::x86Reg Reg = UnMap_8BitTempReg(); - if (Reg > 0) { return Reg; } + if (Reg > 0) + { + return Reg; + } uint32_t MapCount[10]; x86RegIndex MapReg[10]; @@ -544,7 +621,10 @@ CX86Ops::x86Reg CX86RegInfo::Free8BitX86Reg() { if (MapCount[i] > 0) { - if (!CX86Ops::Is8BitReg((CX86Ops::x86Reg)i)) { continue; } + if (!CX86Ops::Is8BitReg((CX86Ops::x86Reg)i)) + { + continue; + } if (UnMap_X86reg((CX86Ops::x86Reg)i)) { return (CX86Ops::x86Reg)i; @@ -558,7 +638,10 @@ CX86Ops::x86Reg CX86RegInfo::UnMap_8BitTempReg() { for (uint32_t i = 0; i < x86RegIndex_Size; i++) { - if (!CX86Ops::Is8BitReg(GetX86RegFromIndex((x86RegIndex)i))) { continue; } + if (!CX86Ops::Is8BitReg(GetX86RegFromIndex((x86RegIndex)i))) + { + continue; + } if (GetX86Mapped((x86RegIndex)i) == Temp_Mapped) { if (GetX86Protected((x86RegIndex)i) == false) @@ -655,7 +738,10 @@ void CX86RegInfo::Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsReg Reg = FreeX86Reg(); if (Reg < 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); + } g_Notify->BreakPoint(__FILE__, __LINE__); return; } @@ -718,7 +804,10 @@ void CX86RegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) CX86Ops::x86Reg x86Hi = CX86Ops::x86_Unknown, x86lo = CX86Ops::x86_Unknown; if (MipsReg == 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map register 0?"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map register 0?"); + } return; } @@ -728,13 +817,20 @@ void CX86RegInfo::Map_GPR_64bit(int32_t MipsReg, int32_t MipsRegToLoad) x86Hi = FreeX86Reg(); if (x86Hi < 0) { - if (HaveDebugger()) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); } + if (HaveDebugger()) + { + g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); + } return; } SetX86Protected(GetIndexFromX86Reg(x86Hi), true); x86lo = FreeX86Reg(); - if (x86lo < 0) { g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); return; } + if (x86lo < 0) + { + g_Notify->DisplayError("Map_GPR_64bit\n\nOut of registers"); + return; + } SetX86Protected(GetIndexFromX86Reg(x86lo), true); m_CodeBlock.Log(" regcache: allocate %s to hi word of %s", CX86Ops::x86_Name(x86Hi), CRegName::GPR[MipsReg]); @@ -844,14 +940,38 @@ CX86Ops::x86Reg CX86RegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, b { if (!Reg8Bit && Reg == CX86Ops::x86_Unknown) { - if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) { Reg = CX86Ops::x86_EAX; } - else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) { Reg = CX86Ops::x86_EBX; } - else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) { Reg = CX86Ops::x86_ECX; } - else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) { Reg = CX86Ops::x86_EDX; } - else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI)) { Reg = CX86Ops::x86_ESI; } - else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI)) { Reg = CX86Ops::x86_EDI; } - else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP)) { Reg = CX86Ops::x86_EBP; } - else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP)) { Reg = CX86Ops::x86_ESP; } + if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) + { + Reg = CX86Ops::x86_EAX; + } + else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) + { + Reg = CX86Ops::x86_EBX; + } + else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) + { + Reg = CX86Ops::x86_ECX; + } + else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) + { + Reg = CX86Ops::x86_EDX; + } + else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI)) + { + Reg = CX86Ops::x86_ESI; + } + else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI)) + { + Reg = CX86Ops::x86_EDI; + } + else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP)) + { + Reg = CX86Ops::x86_EBP; + } + else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP)) + { + Reg = CX86Ops::x86_ESP; + } if (Reg == CX86Ops::x86_Unknown) { @@ -866,10 +986,22 @@ CX86Ops::x86Reg CX86RegInfo::Map_TempReg(CX86Ops::x86Reg Reg, int32_t MipsReg, b } else if (Reg8Bit && Reg == CX86Ops::x86_Unknown) { - if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) { Reg = CX86Ops::x86_EAX; } - else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) { Reg = CX86Ops::x86_EBX; } - else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) { Reg = CX86Ops::x86_ECX; } - else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) { Reg = CX86Ops::x86_EDX; } + if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) + { + Reg = CX86Ops::x86_EAX; + } + else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) + { + Reg = CX86Ops::x86_EBX; + } + else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) + { + Reg = CX86Ops::x86_ECX; + } + else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) + { + Reg = CX86Ops::x86_EDX; + } if (Reg == CX86Ops::x86_Unknown) { @@ -1073,9 +1205,15 @@ void CX86RegInfo::UnMap_AllFPRs() int32_t StartPos = StackTopPos(); for (int32_t i = 0; i < 8; i++) { - if (m_x86fpu_MappedTo[(StartPos + i) & 7] != -1) { m_Assembler.fpuIncStack(&StackTopPos()); } + if (m_x86fpu_MappedTo[(StartPos + i) & 7] != -1) + { + m_Assembler.fpuIncStack(&StackTopPos()); + } + } + if (StackPos != StackTopPos()) + { + continue; } - if (StackPos != StackTopPos()) { continue; } return; } } @@ -1085,10 +1223,16 @@ void CX86RegInfo::UnMap_FPR(int32_t Reg, bool WriteBackValue) char Name[50]; int32_t i; - if (Reg < 0) { return; } + if (Reg < 0) + { + return; + } for (i = 0; i < 8; i++) { - if (m_x86fpu_MappedTo[i] != Reg) { continue; } + if (m_x86fpu_MappedTo[i] != Reg) + { + continue; + } m_CodeBlock.Log(" regcache: unallocate %s from ST(%d)", CRegName::FPR[Reg], (i - StackTopPos() + 8) & 7); if (WriteBackValue) { @@ -1179,7 +1323,10 @@ void CX86RegInfo::UnMap_GPR(uint32_t Reg, bool WriteBackValue) return; } - if (IsUnknown(Reg)) { return; } + if (IsUnknown(Reg)) + { + return; + } //m_CodeBlock.Log("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"true":"false"); if (IsConst(Reg)) { @@ -1252,14 +1399,38 @@ CX86Ops::x86Reg CX86RegInfo::UnMap_TempReg() { CX86Ops::x86Reg Reg = CX86Ops::x86_Unknown; - if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) { Reg = CX86Ops::x86_EAX; } - else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) { Reg = CX86Ops::x86_EBX; } - else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) { Reg = CX86Ops::x86_ECX; } - else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) { Reg = CX86Ops::x86_EDX; } - else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI)) { Reg = CX86Ops::x86_ESI; } - else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI)) { Reg = CX86Ops::x86_EDI; } - else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP)) { Reg = CX86Ops::x86_EBP; } - else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP)) { Reg = CX86Ops::x86_ESP; } + if (GetX86Mapped(x86RegIndex_EAX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EAX)) + { + Reg = CX86Ops::x86_EAX; + } + else if (GetX86Mapped(x86RegIndex_EBX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBX)) + { + Reg = CX86Ops::x86_EBX; + } + else if (GetX86Mapped(x86RegIndex_ECX) == Temp_Mapped && !GetX86Protected(x86RegIndex_ECX)) + { + Reg = CX86Ops::x86_ECX; + } + else if (GetX86Mapped(x86RegIndex_EDX) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDX)) + { + Reg = CX86Ops::x86_EDX; + } + else if (GetX86Mapped(x86RegIndex_ESI) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESI)) + { + Reg = CX86Ops::x86_ESI; + } + else if (GetX86Mapped(x86RegIndex_EDI) == Temp_Mapped && !GetX86Protected(x86RegIndex_EDI)) + { + Reg = CX86Ops::x86_EDI; + } + else if (GetX86Mapped(x86RegIndex_EBP) == Temp_Mapped && !GetX86Protected(x86RegIndex_EBP)) + { + Reg = CX86Ops::x86_EBP; + } + else if (GetX86Mapped(x86RegIndex_ESP) == Temp_Mapped && !GetX86Protected(x86RegIndex_ESP)) + { + Reg = CX86Ops::x86_ESP; + } if (Reg != CX86Ops::x86_Unknown) { @@ -1338,8 +1509,14 @@ void CX86RegInfo::WriteBackRegisters() bool bEdiZero = false; bool bEsiSign = false; - for (uint32_t i = 0; i < x86RegIndex_Size; i++) { SetX86Protected((x86RegIndex)i, false); } - for (uint32_t i = 0; i < x86RegIndex_Size; i++) { UnMap_X86reg(GetX86RegFromIndex((x86RegIndex)i)); } + for (uint32_t i = 0; i < x86RegIndex_Size; i++) + { + SetX86Protected((x86RegIndex)i, false); + } + for (uint32_t i = 0; i < x86RegIndex_Size; i++) + { + UnMap_X86reg(GetX86RegFromIndex((x86RegIndex)i)); + } for (count = 1; count < 32; count++) { diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h index f91ba9b78..bd1506a33 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h @@ -1,9 +1,9 @@ #pragma once #if defined(__i386__) || defined(_M_IX86) +#include #include #include -#include #include enum x86RegIndex @@ -48,13 +48,13 @@ public: }; CX86RegInfo(CCodeBlock & CodeBlock, CX86Ops & Assembler); - CX86RegInfo(const CX86RegInfo&); + CX86RegInfo(const CX86RegInfo &); ~CX86RegInfo(); - CX86RegInfo& operator=(const CX86RegInfo&); + CX86RegInfo & operator=(const CX86RegInfo &); - bool operator==(const CX86RegInfo& right) const; - bool operator!=(const CX86RegInfo& right) const; + bool operator==(const CX86RegInfo & right) const; + bool operator!=(const CX86RegInfo & right) const; static REG_STATE ConstantsType(int64_t Value); @@ -84,24 +84,66 @@ public: bool UnMap_X86reg(CX86Ops::x86Reg Reg); void WriteBackRegisters(); - CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) const { return m_RegMapLo[Reg]; } - CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) const { return m_RegMapHi[Reg]; } + CX86Ops::x86Reg GetMipsRegMapLo(int32_t Reg) const + { + return m_RegMapLo[Reg]; + } + CX86Ops::x86Reg GetMipsRegMapHi(int32_t Reg) const + { + return m_RegMapHi[Reg]; + } - uint32_t GetX86MapOrder(x86RegIndex Reg) const { return m_x86reg_MapOrder[Reg]; } - bool GetX86Protected(x86RegIndex Reg) const { return m_x86reg_Protected[Reg]; } - REG_MAPPED GetX86Mapped(x86RegIndex Reg) const { return m_x86reg_MappedTo[Reg]; } + uint32_t GetX86MapOrder(x86RegIndex Reg) const + { + return m_x86reg_MapOrder[Reg]; + } + bool GetX86Protected(x86RegIndex Reg) const + { + return m_x86reg_Protected[Reg]; + } + REG_MAPPED GetX86Mapped(x86RegIndex Reg) const + { + return m_x86reg_MappedTo[Reg]; + } - void SetMipsRegMapLo(int32_t GetMipsReg, CX86Ops::x86Reg Reg) { m_RegMapLo[GetMipsReg] = Reg; } - void SetMipsRegMapHi(int32_t GetMipsReg, CX86Ops::x86Reg Reg) { m_RegMapHi[GetMipsReg] = Reg; } + void SetMipsRegMapLo(int32_t GetMipsReg, CX86Ops::x86Reg Reg) + { + m_RegMapLo[GetMipsReg] = Reg; + } + void SetMipsRegMapHi(int32_t GetMipsReg, CX86Ops::x86Reg Reg) + { + m_RegMapHi[GetMipsReg] = Reg; + } - void SetX86MapOrder(x86RegIndex Reg, uint32_t Order) { m_x86reg_MapOrder[Reg] = Order; } - void SetX86Protected(x86RegIndex Reg, bool Protected) { m_x86reg_Protected[Reg] = Protected; } - void SetX86Mapped(x86RegIndex Reg, REG_MAPPED Mapping) { m_x86reg_MappedTo[Reg] = Mapping; } + void SetX86MapOrder(x86RegIndex Reg, uint32_t Order) + { + m_x86reg_MapOrder[Reg] = Order; + } + void SetX86Protected(x86RegIndex Reg, bool Protected) + { + m_x86reg_Protected[Reg] = Protected; + } + void SetX86Mapped(x86RegIndex Reg, REG_MAPPED Mapping) + { + m_x86reg_MappedTo[Reg] = Mapping; + } - int32_t & StackTopPos() { return m_Stack_TopPos; } - int32_t & FpuMappedTo(int32_t Reg) { return m_x86fpu_MappedTo[Reg]; } - FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; } - FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; } + int32_t & StackTopPos() + { + return m_Stack_TopPos; + } + int32_t & FpuMappedTo(int32_t Reg) + { + return m_x86fpu_MappedTo[Reg]; + } + FPU_STATE & FpuState(int32_t Reg) + { + return m_x86fpu_State[Reg]; + } + FPU_ROUND & FpuRoundingModel(int32_t Reg) + { + return m_x86fpu_RoundingModel[Reg]; + } private: CX86RegInfo(); diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp index b375b402e..bc9e72ff6 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.cpp @@ -1,14 +1,14 @@ #include "stdafx.h" #if defined(__i386__) || defined(_M_IX86) -#include #include -#include #include +#include +#include -char CX86Ops::m_fpupop[2][2] = -{ - "", "p" +char CX86Ops::m_fpupop[2][2] = { + "", + "p", }; CX86Ops::CX86Ops(CCodeBlock & CodeBlock) : @@ -36,7 +36,7 @@ void CX86Ops::AdcX86regToVariable(x86Reg reg, void * Variable, const char * Vari AddCode32((uint32_t)Variable); } -void CX86Ops::AdcConstToVariable(void *Variable, const char * VariableName, uint8_t Constant) +void CX86Ops::AdcConstToVariable(void * Variable, const char * VariableName, uint8_t Constant) { CodeLog(" adc dword ptr [%s], %Xh", VariableName, Constant); AddCode16(0x1583); @@ -72,7 +72,7 @@ void CX86Ops::AdcX86RegToX86Reg(x86Reg Destination, x86Reg Source) AddCode16((uint16_t)(0xC013 + (Source * 0x100) + (Destination * 0x800))); } -void CX86Ops::AddConstToVariable(uint32_t Const, void *Variable, const char * VariableName) +void CX86Ops::AddConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CodeLog(" add dword ptr [%s], 0x%X", VariableName, Const); AddCode16(0x0581); @@ -127,7 +127,7 @@ void CX86Ops::AddX86RegToX86Reg(x86Reg Destination, x86Reg Source) AddCode16((uint16_t)(0xC003 + (Source * 0x100) + (Destination * 0x800))); } -void CX86Ops::AndConstToVariable(uint32_t Const, void *Variable, const char * VariableName) +void CX86Ops::AndConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CodeLog(" and dword ptr [%s], 0x%X", VariableName, Const); AddCode16(0x2581); @@ -150,7 +150,7 @@ void CX86Ops::AndConstToX86Reg(x86Reg reg, uint32_t Const) } } -void CX86Ops::AndVariableDispToX86Reg(void *Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, Multipler Multiply) +void CX86Ops::AndVariableDispToX86Reg(void * Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, Multipler Multiply) { CodeLog(" and %s, dword ptr [%s+%s*%i]", x86_Name(reg), VariableName, x86_Name(AddrReg), Multiply); @@ -320,8 +320,8 @@ void CX86Ops::DecX86reg(x86Reg reg) case x86_EDX: AddCode16(0xCAFF); break; case x86_ESI: AddCode16(0xCEFF); break; case x86_EDI: AddCode16(0xCFFF); break; - case x86_ESP: AddCode8(0x4C); break; - case x86_EBP: AddCode8(0x4D); break; + case x86_ESP: AddCode8(0x4C); break; + case x86_EBP: AddCode8(0x4D); break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -393,8 +393,8 @@ void CX86Ops::IncX86reg(x86Reg reg) case x86_EDX: AddCode16(0xC2FF); break; case x86_ESI: AddCode16(0xC6FF); break; case x86_EDI: AddCode16(0xC7FF); break; - case x86_ESP: AddCode8(0x44); break; - case x86_EBP: AddCode8(0x45); break; + case x86_ESP: AddCode8(0x44); break; + case x86_EBP: AddCode8(0x45); break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } @@ -547,7 +547,8 @@ void CX86Ops::JmpIndirectReg(x86Reg reg) { CodeLog(" jmp dword ptr [%s]", x86_Name(reg)); - switch (reg) { + switch (reg) + { case x86_EAX: AddCode16(0x20ff); break; case x86_EBX: AddCode16(0x23ff); break; case x86_ECX: AddCode16(0x21ff); break; @@ -588,7 +589,7 @@ void CX86Ops::JneLabel8(const char * Label, uint8_t Value) AddCode8(Value); } -void CX86Ops::JneLabel32(const char *Label, uint32_t Value) +void CX86Ops::JneLabel32(const char * Label, uint32_t Value) { CodeLog(" jne $%s", Label); AddCode16(0x850F); @@ -602,49 +603,49 @@ void CX86Ops::JnsLabel8(const char * Label, uint8_t Value) AddCode8(Value); } -void CX86Ops::JnsLabel32(const char *Label, uint32_t Value) +void CX86Ops::JnsLabel32(const char * Label, uint32_t Value) { CodeLog(" jns $%s", Label); AddCode16(0x890F); AddCode32(Value); } -void CX86Ops::JnzLabel8(const char *Label, uint8_t Value) +void CX86Ops::JnzLabel8(const char * Label, uint8_t Value) { CodeLog(" jnz $%s", Label); AddCode8(0x75); AddCode8(Value); } -void CX86Ops::JnzLabel32(const char *Label, uint32_t Value) +void CX86Ops::JnzLabel32(const char * Label, uint32_t Value) { CodeLog(" jnz $%s", Label); AddCode16(0x850F); AddCode32(Value); } -void CX86Ops::JsLabel32(const char *Label, uint32_t Value) +void CX86Ops::JsLabel32(const char * Label, uint32_t Value) { CodeLog(" js $%s", Label); AddCode16(0x880F); AddCode32(Value); } -void CX86Ops::JoLabel32(const char *Label, uint32_t Value) +void CX86Ops::JoLabel32(const char * Label, uint32_t Value) { CodeLog(" jo $%s", Label); AddCode16(0x800F); AddCode32(Value); } -void CX86Ops::JzLabel8(const char *Label, uint8_t Value) +void CX86Ops::JzLabel8(const char * Label, uint8_t Value) { CodeLog(" jz $%s", Label); AddCode8(0x74); AddCode8(Value); } -void CX86Ops::JzLabel32(const char *Label, uint32_t Value) +void CX86Ops::JzLabel32(const char * Label, uint32_t Value) { CodeLog(" jz $%s", Label); AddCode16(0x840F); @@ -657,7 +658,8 @@ void CX86Ops::LeaRegReg(x86Reg RegDest, x86Reg RegSrc, uint32_t Const, Multipler { CodeLog(" lea %s, [%s*%i+%X]", x86_Name(RegDest), x86_Name(RegSrc), multiplier, Const); } - else { + else + { CodeLog(" lea %s, [%s*%i]", x86_Name(RegDest), x86_Name(RegSrc), multiplier); } @@ -772,7 +774,7 @@ void CX86Ops::MoveConstByteToN64Mem(uint8_t Const, x86Reg AddrReg) AddCode8(Const); } -void CX86Ops::MoveConstByteToVariable(uint8_t Const, void *Variable, const char * VariableName) +void CX86Ops::MoveConstByteToVariable(uint8_t Const, void * Variable, const char * VariableName) { CodeLog(" mov byte ptr [%s], %Xh", VariableName, Const); AddCode16(0x05C6); @@ -801,7 +803,7 @@ void CX86Ops::MoveConstHalfToN64Mem(uint16_t Const, x86Reg AddrReg) AddCode16(Const); } -void CX86Ops::MoveConstHalfToVariable(uint16_t Const, void *Variable, const char * VariableName) +void CX86Ops::MoveConstHalfToVariable(uint16_t Const, void * Variable, const char * VariableName) { CodeLog(" mov word ptr [%s], %Xh", VariableName, Const); AddCode8(0x66); @@ -908,7 +910,7 @@ void CX86Ops::MoveConstToN64MemDisp(uint32_t Const, x86Reg AddrReg, uint8_t Disp AddCode32(Const); } -void CX86Ops::MoveConstToVariable(uint32_t Const, void *Variable, const char * VariableName) +void CX86Ops::MoveConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { CodeLog(" mov dword ptr [%s], %Xh", VariableName, Const); AddCode16(0x05C7); @@ -982,7 +984,8 @@ void CX86Ops::MoveConstToX86regPointer(uint32_t Const, x86Reg AddrReg1, x86Reg A AddCode16(0x04C7); - switch (AddrReg1) { + switch (AddrReg1) + { case x86_EAX: Param = 0x00; break; case x86_EBX: Param = 0x03; break; case x86_ECX: Param = 0x01; break; @@ -993,7 +996,8 @@ void CX86Ops::MoveConstToX86regPointer(uint32_t Const, x86Reg AddrReg1, x86Reg A g_Notify->BreakPoint(__FILE__, __LINE__); } - switch (AddrReg2) { + switch (AddrReg2) + { case x86_EAX: Param += 0x00; break; case x86_EBX: Param += 0x18; break; case x86_ECX: Param += 0x08; break; @@ -1099,7 +1103,9 @@ void CX86Ops::MoveN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) case x86_EAX: x86Command += 0x8000; break; case x86_EBX: x86Command += 0x9800; break; case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; + case x86_EDX: + x86Command += 0x9000; + break; // case x86_ESI: x86Command += 0xB000; break; // case x86_EDI: x86Command += 0xB800; break; // case x86_ESP: case x86_EBP: @@ -1317,7 +1323,7 @@ void CX86Ops::MoveSxN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) AddCode32((uint32_t)g_MMU->Rdram()); } -void CX86Ops::MoveSxVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveSxVariableToX86regByte(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" movsx %s, byte ptr [%s]", x86_Name(reg), VariableName); @@ -1339,7 +1345,7 @@ void CX86Ops::MoveSxVariableToX86regByte(void *Variable, const char * VariableNa AddCode32((uint32_t)Variable); } -void CX86Ops::MoveSxVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveSxVariableToX86regHalf(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" movsx %s, word ptr [%s]", x86_Name(reg), VariableName); @@ -1361,7 +1367,7 @@ void CX86Ops::MoveSxVariableToX86regHalf(void *Variable, const char * VariableNa AddCode32((uint32_t)Variable); } -void CX86Ops::MoveVariableToX86reg(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveVariableToX86reg(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" mov %s, dword ptr [%s]", x86_Name(reg), VariableName); switch (reg) @@ -1380,7 +1386,7 @@ void CX86Ops::MoveVariableToX86reg(void *Variable, const char * VariableName, x8 AddCode32((uint32_t)Variable); } -void CX86Ops::MoveVariableDispToX86Reg(void *Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, int32_t Multiplier) +void CX86Ops::MoveVariableDispToX86Reg(void * Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, int32_t Multiplier) { int x = 0; CodeLog(" mov %s, dword ptr [%s+%s*%i]", x86_Name(reg), VariableName, x86_Name(AddrReg), Multiplier); @@ -1430,7 +1436,7 @@ void CX86Ops::MoveVariableDispToX86Reg(void *Variable, const char * VariableName AddCode32((uint32_t)Variable); } -void CX86Ops::MoveVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveVariableToX86regByte(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" mov %s, byte ptr [%s]", x86_ByteName(reg), VariableName); @@ -1446,7 +1452,7 @@ void CX86Ops::MoveVariableToX86regByte(void *Variable, const char * VariableName AddCode32((uint32_t)Variable); } -void CX86Ops::MoveVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveVariableToX86regHalf(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" mov %s, word ptr [%s]", x86_HalfName(reg), VariableName); @@ -2253,7 +2259,7 @@ void CX86Ops::MoveZxN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) AddCode32((uint32_t)(g_MMU->Rdram())); } -void CX86Ops::MoveZxVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveZxVariableToX86regByte(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" movzx %s, byte ptr [%s]", x86_Name(reg), VariableName); @@ -2275,7 +2281,7 @@ void CX86Ops::MoveZxVariableToX86regByte(void *Variable, const char * VariableNa AddCode32((uint32_t)(Variable)); } -void CX86Ops::MoveZxVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::MoveZxVariableToX86regHalf(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" movzx %s, word ptr [%s]", x86_Name(reg), VariableName); @@ -2350,7 +2356,8 @@ void CX86Ops::OrConstToX86Reg(uint32_t Const, x86Reg reg) CodeLog(" or %s, %Xh", x86_Name(reg), Const); if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - switch (reg) { + switch (reg) + { case x86_EAX: AddCode16(0xC881); break; case x86_EBX: AddCode16(0xCB81); break; case x86_ECX: AddCode16(0xC981); break; @@ -2524,7 +2531,8 @@ void CX86Ops::PushImm32(const char * String, uint32_t Value) AddCode32(Value); } -void CX86Ops::Ret(void) { +void CX86Ops::Ret(void) +{ CodeLog(" ret"); AddCode8(0xC3); } @@ -3022,7 +3030,7 @@ void CX86Ops::SbbX86RegToX86Reg(x86Reg Destination, x86Reg Source) AddCode16(x86Command); } -void CX86Ops::SubConstFromVariable(uint32_t Const, void *Variable, const char * VariableName) +void CX86Ops::SubConstFromVariable(uint32_t Const, void * Variable, const char * VariableName) { CodeLog(" sub dword ptr [%s], 0x%X", VariableName, Const); @@ -3285,7 +3293,7 @@ void CX86Ops::XorX86RegToX86Reg(x86Reg Source, x86Reg Destination) AddCode16(x86Command); } -void CX86Ops::XorVariableToX86reg(void *Variable, const char * VariableName, x86Reg reg) +void CX86Ops::XorVariableToX86reg(void * Variable, const char * VariableName, x86Reg reg) { CodeLog(" Xor %s, dword ptr [%s]", x86_Name(reg), VariableName); @@ -3311,7 +3319,7 @@ void CX86Ops::fpuAbs(void) AddCode16(0xE1D9); } -void CX86Ops::fpuAddDword(void *Variable, const char * VariableName) +void CX86Ops::fpuAddDword(void * Variable, const char * VariableName) { CodeLog(" fadd ST(0), dword ptr [%s]", VariableName); AddCode16(0x05D8); @@ -3335,7 +3343,7 @@ void CX86Ops::fpuAddDwordRegPointer(x86Reg x86Pointer) } } -void CX86Ops::fpuAddQword(void *Variable, const char * VariableName) +void CX86Ops::fpuAddQword(void * Variable, const char * VariableName) { CodeLog(" fadd ST(0), qword ptr [%s]", VariableName); AddCode16(0x05DC); @@ -3362,7 +3370,8 @@ void CX86Ops::fpuAddQwordRegPointer(x86Reg x86Pointer) void CX86Ops::fpuAddReg(x86FpuValues x86reg) { CodeLog(" fadd ST(0), %s", fpu_Name(x86reg)); - switch (x86reg) { + switch (x86reg) + { case x86_ST0: AddCode16(0xC0D8); break; case x86_ST1: AddCode16(0xC1D8); break; case x86_ST2: AddCode16(0xC2D8); break; @@ -3397,7 +3406,7 @@ void CX86Ops::fpuAddRegPop(int32_t * StackPos, x86FpuValues reg) } } -void CX86Ops::fpuComDword(void *Variable, const char * VariableName, bool Pop) +void CX86Ops::fpuComDword(void * Variable, const char * VariableName, bool Pop) { CodeLog(" fcom%s ST(0), dword ptr [%s]", m_fpupop[Pop], VariableName); AddCode16(Pop ? 0x1DD8 : 0x15D8); @@ -3429,7 +3438,7 @@ void CX86Ops::fpuComDwordRegPointer(x86Reg x86Pointer, bool Pop) AddCode16(x86Command); } -void CX86Ops::fpuComQword(void *Variable, const char * VariableName, bool Pop) +void CX86Ops::fpuComQword(void * Variable, const char * VariableName, bool Pop) { CodeLog(" fcom%s ST(0), qword ptr [%s]", m_fpupop[Pop], VariableName); AddCode16(Pop ? 0x1DDC : 0x15DC); @@ -3482,7 +3491,7 @@ void CX86Ops::fpuComReg(x86FpuValues x86reg, bool Pop) } } -void CX86Ops::fpuDivDword(void *Variable, const char * VariableName) +void CX86Ops::fpuDivDword(void * Variable, const char * VariableName) { CodeLog(" fdiv ST(0), dword ptr [%s]", VariableName); AddCode16(0x35D8); @@ -3506,7 +3515,7 @@ void CX86Ops::fpuDivDwordRegPointer(x86Reg x86Pointer) } } -void CX86Ops::fpuDivQword(void *Variable, const char * VariableName) +void CX86Ops::fpuDivQword(void * Variable, const char * VariableName) { CodeLog(" fdiv ST(0), qword ptr [%s]", VariableName); AddCode16(0x35DC); @@ -3620,14 +3629,14 @@ void CX86Ops::fpuIncStack(int32_t * StackPos) AddCode16(0xF7D9); } -void CX86Ops::fpuLoadControl(void *Variable, const char * VariableName) +void CX86Ops::fpuLoadControl(void * Variable, const char * VariableName) { CodeLog(" fldcw [%s]", VariableName); AddCode16(0x2DD9); AddCode32((uint32_t)Variable); } -void CX86Ops::fpuLoadDword(int32_t * StackPos, void *Variable, const char * VariableName) +void CX86Ops::fpuLoadDword(int32_t * StackPos, void * Variable, const char * VariableName) { CodeLog(" fld dword ptr [%s]", VariableName); *StackPos = (*StackPos - 1) & 7; @@ -3691,7 +3700,7 @@ void CX86Ops::fpuLoadInt32bFromN64Mem(int32_t * StackPos, x86Reg x86reg) AddCode32((uint32_t)g_MMU->Rdram()); } -void CX86Ops::fpuLoadIntegerDword(int32_t * StackPos, void *Variable, const char * VariableName) +void CX86Ops::fpuLoadIntegerDword(int32_t * StackPos, void * Variable, const char * VariableName) { CodeLog(" fild dword ptr [%s]", VariableName); *StackPos = (*StackPos - 1) & 7; @@ -3717,7 +3726,7 @@ void CX86Ops::fpuLoadIntegerDwordFromX86Reg(int32_t * StackPos, x86Reg x86reg) } } -void CX86Ops::fpuLoadIntegerQword(int32_t * StackPos, void *Variable, const char * VariableName) +void CX86Ops::fpuLoadIntegerQword(int32_t * StackPos, void * Variable, const char * VariableName) { CodeLog(" fild qword ptr [%s]", VariableName); *StackPos = (*StackPos - 1) & 7; @@ -3743,7 +3752,7 @@ void CX86Ops::fpuLoadIntegerQwordFromX86Reg(int32_t * StackPos, x86Reg x86reg) } } -void CX86Ops::fpuLoadQword(int32_t * StackPos, void *Variable, const char * VariableName) +void CX86Ops::fpuLoadQword(int32_t * StackPos, void * Variable, const char * VariableName) { CodeLog(" fld qword ptr [%s]", VariableName); *StackPos = (*StackPos - 1) & 7; @@ -3808,7 +3817,7 @@ void CX86Ops::fpuLoadReg(int32_t * StackPos, x86FpuValues Reg) } } -void CX86Ops::fpuMulDword(void *Variable, const char * VariableName) +void CX86Ops::fpuMulDword(void * Variable, const char * VariableName) { CodeLog(" fmul ST(0), dword ptr [%s]", VariableName); AddCode16(0x0DD8); @@ -3832,7 +3841,7 @@ void CX86Ops::fpuMulDwordRegPointer(x86Reg x86Pointer) } } -void CX86Ops::fpuMulQword(void *Variable, const char * VariableName) +void CX86Ops::fpuMulQword(void * Variable, const char * VariableName) { CodeLog(" fmul ST(0), qword ptr [%s]", VariableName); AddCode16(0x0DDC); @@ -3912,14 +3921,14 @@ void CX86Ops::fpuSqrt(void) AddCode16(0xFAD9); } -void CX86Ops::fpuStoreControl(void *Variable, const char * VariableName) +void CX86Ops::fpuStoreControl(void * Variable, const char * VariableName) { CodeLog(" fnstcw [%s]", VariableName); AddCode16(0x3DD9); AddCode32((uint32_t)Variable); } -void CX86Ops::fpuStoreDword(int32_t * StackPos, void *Variable, const char * VariableName, bool pop) +void CX86Ops::fpuStoreDword(int32_t * StackPos, void * Variable, const char * VariableName, bool pop) { CodeLog(" fst%s dword ptr [%s]", m_fpupop[pop], VariableName); @@ -3987,7 +3996,7 @@ void CX86Ops::fpuStoreDwordToN64Mem(int32_t * StackPos, x86Reg x86reg, bool Pop) AddCode32((uint32_t)g_MMU->Rdram()); } -void CX86Ops::fpuStoreIntegerDword(int32_t * StackPos, void *Variable, const char * VariableName, bool pop) +void CX86Ops::fpuStoreIntegerDword(int32_t * StackPos, void * Variable, const char * VariableName, bool pop) { CodeLog(" fist%s dword ptr [%s]", m_fpupop[pop], VariableName); @@ -4027,7 +4036,7 @@ void CX86Ops::fpuStoreIntegerDwordFromX86Reg(int32_t * StackPos, x86Reg x86reg, AddCode8(pop ? (Command + 0x8) : Command); } -void CX86Ops::fpuStoreIntegerQword(int32_t * StackPos, void *Variable, const char * VariableName, bool pop) +void CX86Ops::fpuStoreIntegerQword(int32_t * StackPos, void * Variable, const char * VariableName, bool pop) { CodeLog(" fist%s qword ptr [%s]", m_fpupop[pop], VariableName); @@ -4058,7 +4067,8 @@ void CX86Ops::fpuStoreIntegerQwordFromX86Reg(int32_t * StackPos, x86Reg x86reg, AddCode8(0xDF); - switch (x86reg) { + switch (x86reg) + { case x86_EAX: Command = 0x30; break; case x86_EBX: Command = 0x33; break; case x86_ECX: Command = 0x31; break; @@ -4106,7 +4116,7 @@ void CX86Ops::fpuStoreStatus(void) AddCode16(0xE0DF); } -void CX86Ops::fpuSubDword(void *Variable, const char * VariableName) +void CX86Ops::fpuSubDword(void * Variable, const char * VariableName) { CodeLog(" fsub ST(0), dword ptr [%s]", VariableName); AddCode16(0x25D8); @@ -4130,14 +4140,14 @@ void CX86Ops::fpuSubDwordRegPointer(x86Reg x86Pointer) } } -void CX86Ops::fpuSubDwordReverse(void *Variable, const char * VariableName) +void CX86Ops::fpuSubDwordReverse(void * Variable, const char * VariableName) { CodeLog(" fsubr ST(0), dword ptr [%s]", VariableName); AddCode16(0x2DD8); AddCode32((uint32_t)Variable); } -void CX86Ops::fpuSubQword(void *Variable, const char * VariableName) +void CX86Ops::fpuSubQword(void * Variable, const char * VariableName) { CodeLog(" fsub ST(0), qword ptr [%s]", VariableName); AddCode16(0x25DC); @@ -4147,7 +4157,8 @@ void CX86Ops::fpuSubQword(void *Variable, const char * VariableName) void CX86Ops::fpuSubQwordRegPointer(x86Reg x86Pointer) { CodeLog(" fsub ST(0), qword ptr [%s]", x86_Name(x86Pointer)); - switch (x86Pointer) { + switch (x86Pointer) + { case x86_EAX: AddCode16(0x20DC); break; case x86_EBX: AddCode16(0x23DC); break; case x86_ECX: AddCode16(0x21DC); break; @@ -4160,7 +4171,7 @@ void CX86Ops::fpuSubQwordRegPointer(x86Reg x86Pointer) } } -void CX86Ops::fpuSubQwordReverse(void *Variable, const char * VariableName) +void CX86Ops::fpuSubQwordReverse(void * Variable, const char * VariableName) { CodeLog(" fsubr ST(0), qword ptr [%s]", VariableName); AddCode16(0x2DDC); @@ -4170,7 +4181,8 @@ void CX86Ops::fpuSubQwordReverse(void *Variable, const char * VariableName) void CX86Ops::fpuSubReg(x86FpuValues x86reg) { CodeLog(" fsub ST(0), %s", fpu_Name(x86reg)); - switch (x86reg) { + switch (x86reg) + { case x86_ST0: AddCode16(0xE0D8); break; case x86_ST1: AddCode16(0xE1D8); break; case x86_ST2: AddCode16(0xE2D8); break; @@ -4188,7 +4200,8 @@ void CX86Ops::fpuSubReg(x86FpuValues x86reg) void CX86Ops::fpuSubRegPop(x86FpuValues x86reg) { CodeLog(" fsubp ST(0), %s", fpu_Name(x86reg)); - switch (x86reg) { + switch (x86reg) + { case x86_ST0: AddCode16(0xE8DE); break; case x86_ST1: AddCode16(0xE9DE); break; case x86_ST2: AddCode16(0xEADE); break; @@ -4205,7 +4218,8 @@ void CX86Ops::fpuSubRegPop(x86FpuValues x86reg) const char * CX86Ops::x86_Name(x86Reg Reg) { - switch (Reg) { + switch (Reg) + { case x86_EAX: return "eax"; case x86_EBX: return "ebx"; case x86_ECX: return "ecx"; @@ -4222,7 +4236,8 @@ const char * CX86Ops::x86_Name(x86Reg Reg) const char * CX86Ops::x86_ByteName(x86Reg Reg) { - switch (Reg) { + switch (Reg) + { case x86_AL: return "al"; case x86_BL: return "bl"; case x86_CL: return "cl"; @@ -4276,9 +4291,9 @@ const char * CX86Ops::fpu_Name(x86FpuValues Reg) bool CX86Ops::Is8BitReg(x86Reg Reg) { return (Reg == x86_EAX) || - (Reg == x86_EBX) || - (Reg == x86_ECX) || - (Reg == x86_EDX); + (Reg == x86_EBX) || + (Reg == x86_ECX) || + (Reg == x86_EDX); } uint8_t CX86Ops::CalcMultiplyCode(Multipler Multiply) @@ -4329,10 +4344,10 @@ void CX86Ops::AddCode8(uint8_t value) #ifdef _DEBUG if (g_RecompPos == nullptr) { - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); } #endif - (*((uint8_t *)(*g_RecompPos))=(uint8_t)(value)); + (*((uint8_t *)(*g_RecompPos)) = (uint8_t)(value)); *g_RecompPos += 1; } @@ -4341,10 +4356,10 @@ void CX86Ops::AddCode16(uint16_t value) #ifdef _DEBUG if (g_RecompPos == nullptr) { - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); } #endif - (*((uint16_t *)(*g_RecompPos))=(uint16_t)(value)); + (*((uint16_t *)(*g_RecompPos)) = (uint16_t)(value)); *g_RecompPos += 2; } @@ -4353,10 +4368,10 @@ void CX86Ops::AddCode32(uint32_t value) #ifdef _DEBUG if (g_RecompPos == nullptr) { - g_Notify->BreakPoint(__FILE__,__LINE__); + g_Notify->BreakPoint(__FILE__, __LINE__); } #endif - (*((uint32_t *)(*g_RecompPos))=(uint32_t)(value)); + (*((uint32_t *)(*g_RecompPos)) = (uint32_t)(value)); *g_RecompPos += 4; } @@ -4372,7 +4387,7 @@ void CX86Ops::CodeLog(_Printf_format_string_ const char * Text, ...) #pragma warning(push) #pragma warning(disable : 4996) size_t nlen = _vscprintf(Text, args) + 1; - char * buffer = (char*)alloca(nlen * sizeof(char)); + char * buffer = (char *)alloca(nlen * sizeof(char)); buffer[nlen - 1] = 0; if (buffer != nullptr) { diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h index 030976e21..9198e2857 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86ops.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86ops.h @@ -22,8 +22,14 @@ public: x86_ESP = 4, x86_Unknown = -1, - x86_AL = 0, x86_BL = 3, x86_CL = 1, x86_DL = 2, - x86_AH = 4, x86_BH = 7, x86_CH = 5, x86_DH = 6 + x86_AL = 0, + x86_BL = 3, + x86_CL = 1, + x86_DL = 2, + x86_AH = 4, + x86_BH = 7, + x86_CH = 5, + x86_DH = 6 }; enum x86FpuValues @@ -59,16 +65,16 @@ public: void WriteX86Label(const char * Label); void AdcX86regToVariable(x86Reg reg, void * Variable, const char * VariableName); - void AdcConstToVariable(void *Variable, const char * VariableName, uint8_t Constant); + void AdcConstToVariable(void * Variable, const char * VariableName, uint8_t Constant); void AdcConstToX86Reg(x86Reg Reg, uint32_t Const); void AdcVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName); void AdcX86RegToX86Reg(x86Reg Destination, x86Reg Source); - void AddConstToVariable(uint32_t Const, void *Variable, const char * VariableName); + void AddConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void AddConstToX86Reg(x86Reg Reg, uint32_t Const); void AddVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName); void AddX86regToVariable(x86Reg reg, void * Variable, const char * VariableName); void AddX86RegToX86Reg(x86Reg Destination, x86Reg Source); - void AndConstToVariable(uint32_t Const, void *Variable, const char * VariableName); + void AndConstToVariable(uint32_t Const, void * Variable, const char * VariableName); void AndConstToX86Reg(x86Reg Reg, uint32_t Const); void AndVariableToX86Reg(void * Variable, const char * VariableName, x86Reg Reg); void AndVariableDispToX86Reg(void * Variable, const char * VariableName, x86Reg Reg, x86Reg AddrReg, Multipler Multiply); @@ -295,8 +301,8 @@ public: private: CX86Ops(void); - CX86Ops(const CX86Ops&); - CX86Ops& operator=(const CX86Ops&); + CX86Ops(const CX86Ops &); + CX86Ops & operator=(const CX86Ops &); void CodeLog(_Printf_format_string_ const char * Text, ...); @@ -309,6 +315,6 @@ private: CCodeBlock & m_CodeBlock; }; -#define AddressOf(Addr) CX86Ops::GetAddressOf(5,(Addr)) +#define AddressOf(Addr) CX86Ops::GetAddressOf(5, (Addr)) #endif diff --git a/Source/Project64-core/N64System/SaveType/Eeprom.cpp b/Source/Project64-core/N64System/SaveType/Eeprom.cpp index dc7c8038a..1d763ab97 100644 --- a/Source/Project64-core/N64System/SaveType/Eeprom.cpp +++ b/Source/Project64-core/N64System/SaveType/Eeprom.cpp @@ -1,11 +1,12 @@ #include "stdafx.h" + +#include #include #include -#include #include CEeprom::CEeprom(bool ReadOnly) : -m_ReadOnly(ReadOnly) + m_ReadOnly(ReadOnly) { memset(m_EEPROM, 0xFF, sizeof(m_EEPROM)); } @@ -33,7 +34,7 @@ void CEeprom::EepromCommand(uint8_t * Command) switch (Command[2]) { case 0: // Check - if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K) + if (g_System->m_SaveUsing != SaveChip_Eeprom_4K && g_System->m_SaveUsing != SaveChip_Eeprom_16K) { Command[1] |= 0x80; break; @@ -110,7 +111,7 @@ void CEeprom::EepromCommand(uint8_t * Command) Command[9] = byte2bcd(curtime.tm_mon + 1); Command[10] = byte2bcd(curtime.tm_year); Command[11] = byte2bcd(curtime.tm_year / 100); - Command[12] = 0x00; // Status + Command[12] = 0x00; // Status break; } break; diff --git a/Source/Project64-core/N64System/SaveType/Eeprom.h b/Source/Project64-core/N64System/SaveType/Eeprom.h index 3270cbc65..b5ce0ea8c 100644 --- a/Source/Project64-core/N64System/SaveType/Eeprom.h +++ b/Source/Project64-core/N64System/SaveType/Eeprom.h @@ -12,8 +12,8 @@ public: private: CEeprom(void); - CEeprom(const CEeprom&); - CEeprom& operator=(const CEeprom&); + CEeprom(const CEeprom &); + CEeprom & operator=(const CEeprom &); void ProcessingError(uint8_t * Command); void LoadEeprom(); @@ -21,6 +21,6 @@ private: void WriteTo(uint8_t * Buffer, int32_t line); uint8_t m_EEPROM[0x800]; - bool m_ReadOnly; - CFile m_File; + bool m_ReadOnly; + CFile m_File; }; diff --git a/Source/Project64-core/N64System/SaveType/FlashRam.cpp b/Source/Project64-core/N64System/SaveType/FlashRam.cpp index 3129db77d..7777fab18 100644 --- a/Source/Project64-core/N64System/SaveType/FlashRam.cpp +++ b/Source/Project64-core/N64System/SaveType/FlashRam.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" + +#include +#include #include #include -#include -#include CFlashRam::CFlashRam(bool ReadOnly) : m_FlashRamPointer(nullptr), @@ -67,8 +68,8 @@ void CFlashRam::DmaFromFlashram(uint8_t * dest, int32_t StartOffset, int32_t len g_Notify->DisplayError(stdstr_f("%s: Reading m_FlashStatus not being handled correctly\nStart: %X len: %X", __FUNCTION__, StartOffset, len).c_str()); } } - *((uint32_t *)(dest)+0) = (uint32_t)((m_FlashStatus >> 32) & 0xFFFFFFFF); - *((uint32_t *)(dest)+1) = (uint32_t)(m_FlashStatus & 0xFFFFFFFF); + *((uint32_t *)(dest) + 0) = (uint32_t)((m_FlashStatus >> 32) & 0xFFFFFFFF); + *((uint32_t *)(dest) + 1) = (uint32_t)(m_FlashStatus & 0xFFFFFFFF); break; default: if (HaveDebugger()) diff --git a/Source/Project64-core/N64System/SaveType/FlashRam.h b/Source/Project64-core/N64System/SaveType/FlashRam.h index 763534a4e..5fab0ac8e 100644 --- a/Source/Project64-core/N64System/SaveType/FlashRam.h +++ b/Source/Project64-core/N64System/SaveType/FlashRam.h @@ -24,8 +24,8 @@ public: private: CFlashRam(void); - CFlashRam(const CFlashRam&); - CFlashRam& operator=(const CFlashRam&); + CFlashRam(const CFlashRam &); + CFlashRam & operator=(const CFlashRam &); bool LoadFlashram(); diff --git a/Source/Project64-core/N64System/SaveType/Sram.cpp b/Source/Project64-core/N64System/SaveType/Sram.cpp index 73363b574..0fca6dfc5 100644 --- a/Source/Project64-core/N64System/SaveType/Sram.cpp +++ b/Source/Project64-core/N64System/SaveType/Sram.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" -#include + #include +#include CSram::CSram(bool ReadOnly) : m_ReadOnly(ReadOnly) @@ -59,7 +60,7 @@ void CSram::DmaFromSram(uint8_t * dest, int32_t StartOffset, uint32_t len) for (uint32_t i = 0; i < len; i++) { m_File.Seek((StartOffset + i) ^ 3, CFile::begin); - m_File.Read((uint8_t*)(((size_t)dest + i) ^ 3), 1); + m_File.Read((uint8_t *)(((size_t)dest + i) ^ 3), 1); } } } @@ -92,7 +93,7 @@ void CSram::DmaToSram(uint8_t * Source, int32_t StartOffset, uint32_t len) for (uint32_t i = 0; i < len; i++) { m_File.Seek((StartOffset + i) ^ 3, CFile::begin); - m_File.Write((uint8_t*)(((size_t)Source + i) ^ 3), 1); + m_File.Write((uint8_t *)(((size_t)Source + i) ^ 3), 1); } } } \ No newline at end of file diff --git a/Source/Project64-core/N64System/SaveType/Sram.h b/Source/Project64-core/N64System/SaveType/Sram.h index c928785fb..12dfcd8ed 100644 --- a/Source/Project64-core/N64System/SaveType/Sram.h +++ b/Source/Project64-core/N64System/SaveType/Sram.h @@ -11,8 +11,8 @@ public: private: CSram(void); - CSram(const CSram&); - CSram& operator=(const CSram&); + CSram(const CSram &); + CSram & operator=(const CSram &); bool LoadSram(); diff --git a/Source/Project64-core/N64System/SpeedLimiter.cpp b/Source/Project64-core/N64System/SpeedLimiter.cpp index 154a5e338..1fc0f1e22 100644 --- a/Source/Project64-core/N64System/SpeedLimiter.cpp +++ b/Source/Project64-core/N64System/SpeedLimiter.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "Project64-core/N64System/SpeedLimiter.h" #include @@ -6,9 +7,9 @@ const uint32_t CSpeedLimiter::m_DefaultSpeed = 60; CSpeedLimiter::CSpeedLimiter() : -m_Frames(0), -m_Speed(m_DefaultSpeed), -m_BaseSpeed(m_DefaultSpeed) + m_Frames(0), + m_Speed(m_DefaultSpeed), + m_BaseSpeed(m_DefaultSpeed) { } @@ -58,7 +59,10 @@ bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate) if (CurrentTimeValue - LastTime >= 1000000) { // Output FPS - if (FrameRate != nullptr) { *FrameRate = m_Frames; } + if (FrameRate != nullptr) + { + *FrameRate = m_Frames; + } m_Frames = 0; m_LastTime = CurrentTime; return true; @@ -66,26 +70,29 @@ bool CSpeedLimiter::Timer_Process(uint32_t * FrameRate) return false; } -void CSpeedLimiter::AlterSpeed( const ESpeedChange SpeedChange ) +void CSpeedLimiter::AlterSpeed(const ESpeedChange SpeedChange) { - int32_t SpeedFactor = 1; - if (SpeedChange == DECREASE_SPEED) { SpeedFactor = -1; } + int32_t SpeedFactor = 1; + if (SpeedChange == DECREASE_SPEED) + { + SpeedFactor = -1; + } - if (m_Speed >= m_DefaultSpeed) - { - m_Speed += 10 * SpeedFactor; - } - else if (m_Speed >= 15) - { - m_Speed += 5 * SpeedFactor; - } - else if ((m_Speed > 1 && SpeedChange == DECREASE_SPEED) || SpeedChange == INCREASE_SPEED) - { - m_Speed += 1 * SpeedFactor; - } + if (m_Speed >= m_DefaultSpeed) + { + m_Speed += 10 * SpeedFactor; + } + else if (m_Speed >= 15) + { + m_Speed += 5 * SpeedFactor; + } + else if ((m_Speed > 1 && SpeedChange == DECREASE_SPEED) || SpeedChange == INCREASE_SPEED) + { + m_Speed += 1 * SpeedFactor; + } - SpeedChanged(m_Speed); - FixSpeedRatio(); + SpeedChanged(m_Speed); + FixSpeedRatio(); } void CSpeedLimiter::SetSpeed(int Speed) diff --git a/Source/Project64-core/N64System/SpeedLimiter.h b/Source/Project64-core/N64System/SpeedLimiter.h index 304ddcbd2..f8e770357 100644 --- a/Source/Project64-core/N64System/SpeedLimiter.h +++ b/Source/Project64-core/N64System/SpeedLimiter.h @@ -8,29 +8,33 @@ class CSpeedLimiter : private CGameSettings { public: - enum ESpeedChange { INCREASE_SPEED, DECREASE_SPEED }; + enum ESpeedChange + { + INCREASE_SPEED, + DECREASE_SPEED + }; CSpeedLimiter(); ~CSpeedLimiter(); void SetHertz(const uint32_t Hertz); - bool Timer_Process(uint32_t* const FrameRate); + bool Timer_Process(uint32_t * const FrameRate); - void AlterSpeed(const ESpeedChange SpeedChange); + void AlterSpeed(const ESpeedChange SpeedChange); void SetSpeed(int Speed); int GetSpeed(void) const; int GetBaseSpeed(void) const; private: - CSpeedLimiter(const CSpeedLimiter&); - CSpeedLimiter& operator=(const CSpeedLimiter&); + CSpeedLimiter(const CSpeedLimiter &); + CSpeedLimiter & operator=(const CSpeedLimiter &); void FixSpeedRatio(); - HighResTimeStamp m_LastTime; + HighResTimeStamp m_LastTime; uint32_t m_Speed, m_BaseSpeed, m_Frames, m_MicroSecondsPerFrame; - static const uint32_t m_DefaultSpeed; + static const uint32_t m_DefaultSpeed; }; diff --git a/Source/Project64-core/N64System/SystemGlobals.cpp b/Source/Project64-core/N64System/SystemGlobals.cpp index 241c7ccdd..c64fe08e7 100644 --- a/Source/Project64-core/N64System/SystemGlobals.cpp +++ b/Source/Project64-core/N64System/SystemGlobals.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SystemGlobals.h" CN64System * g_System = nullptr; @@ -6,14 +7,14 @@ CN64System * g_BaseSystem = nullptr; CN64System * g_SyncSystem = nullptr; CRecompiler * g_Recompiler = nullptr; CMipsMemoryVM * g_MMU = nullptr; // Memory of the N64 -CTLB * g_TLB = nullptr; // TLB unit -CRegisters * g_Reg = nullptr; // Current register set attached to the g_MMU +CTLB * g_TLB = nullptr; // TLB unit +CRegisters * g_Reg = nullptr; // Current register set attached to the g_MMU CNotification * g_Notify = nullptr; CPlugins * g_Plugins = nullptr; -CN64Rom * g_Rom = nullptr; // The current ROM that this system is executing, it can only execute one file at the time -CN64Rom * g_DDRom = nullptr; // 64DD IPL ROM -CN64Disk * g_Disk = nullptr; // 64DD disk -CSystemTimer * g_SystemTimer = nullptr; +CN64Rom * g_Rom = nullptr; // The current ROM that this system is executing, it can only execute one file at the time +CN64Rom * g_DDRom = nullptr; // 64DD IPL ROM +CN64Disk * g_Disk = nullptr; // 64DD disk +CSystemTimer * g_SystemTimer = nullptr; CSystemEvents * g_SystemEvents = nullptr; uint32_t * g_TLBLoadAddress = nullptr; uint32_t * g_TLBStoreAddress = nullptr; diff --git a/Source/Project64-core/N64System/SystemGlobals.h b/Source/Project64-core/N64System/SystemGlobals.h index 4ecb805f7..bb8b196ea 100644 --- a/Source/Project64-core/N64System/SystemGlobals.h +++ b/Source/Project64-core/N64System/SystemGlobals.h @@ -24,11 +24,11 @@ class CPlugins; extern CPlugins * g_Plugins; class CN64Rom; -extern CN64Rom * g_Rom; // The current ROM that this system is executing, it can only execute one file at the time -extern CN64Rom * g_DDRom; // 64DD IPL ROM +extern CN64Rom * g_Rom; // The current ROM that this system is executing, it can only execute one file at the time +extern CN64Rom * g_DDRom; // 64DD IPL ROM class CN64Disk; -extern CN64Disk * g_Disk; // 64DD disk +extern CN64Disk * g_Disk; // 64DD disk class CSystemTimer; extern CSystemTimer * g_SystemTimer; diff --git a/Source/Project64-core/Plugin.h b/Source/Project64-core/Plugin.h index a5c932c1b..61940a928 100644 --- a/Source/Project64-core/Plugin.h +++ b/Source/Project64-core/Plugin.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include #include #include +#include +#include +#include #include diff --git a/Source/Project64-core/Plugins/AudioPlugin.cpp b/Source/Project64-core/Plugins/AudioPlugin.cpp index f68a2fcb7..6a6c47239 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.cpp +++ b/Source/Project64-core/Plugins/AudioPlugin.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" -#include -#include -#include + #include #include +#include +#include #include +#include #include #include #ifdef _WIN32 @@ -32,7 +33,7 @@ bool CAudioPlugin::LoadFunctions(void) g_Settings->SaveBool(Setting_SyncViaAudioEnabled, false); // Find entries for functions in DLL - void(CALL *InitiateAudio)(void); + void(CALL * InitiateAudio)(void); LoadFunction(InitiateAudio); LoadFunction(AiDacrateChanged); LoadFunction(AiLenChanged); @@ -41,15 +42,39 @@ bool CAudioPlugin::LoadFunctions(void) LoadFunction(ProcessAList); // Make sure DLL has all needed functions - if (AiDacrateChanged == nullptr) { UnloadPlugin(); return false; } - if (AiLenChanged == nullptr) { UnloadPlugin(); return false; } - if (AiReadLength == nullptr) { UnloadPlugin(); return false; } - if (InitiateAudio == nullptr) { UnloadPlugin(); return false; } - if (ProcessAList == nullptr) { UnloadPlugin(); return false; } + if (AiDacrateChanged == nullptr) + { + UnloadPlugin(); + return false; + } + if (AiLenChanged == nullptr) + { + UnloadPlugin(); + return false; + } + if (AiReadLength == nullptr) + { + UnloadPlugin(); + return false; + } + if (InitiateAudio == nullptr) + { + UnloadPlugin(); + return false; + } + if (ProcessAList == nullptr) + { + UnloadPlugin(); + return false; + } if (m_PluginInfo.Version >= 0x0102) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } return true; } @@ -57,11 +82,14 @@ bool CAudioPlugin::LoadFunctions(void) bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) { // Get function from DLL - int32_t(CALL *InitiateAudio)(AUDIO_INFO Audio_Info); + int32_t(CALL * InitiateAudio)(AUDIO_INFO Audio_Info); LoadFunction(InitiateAudio); - if (InitiateAudio == nullptr) { return false; } + if (InitiateAudio == nullptr) + { + return false; + } - AUDIO_INFO Info = { 0 }; + AUDIO_INFO Info = {0}; #ifdef _WIN32 Info.hWnd = Window ? Window->GetWindowHandle() : nullptr; @@ -157,7 +185,10 @@ void CAudioPlugin::UnloadPluginDetails(void) void CAudioPlugin::DacrateChanged(SYSTEM_TYPE Type) { - if (!Initialized()) { return; } + if (!Initialized()) + { + return; + } WriteTrace(TraceAudioPlugin, TraceDebug, "SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL"); //uint32_t Frequency = g_Reg->AI_DACRATE_REG * 30; diff --git a/Source/Project64-core/Plugins/AudioPlugin.h b/Source/Project64-core/Plugins/AudioPlugin.h index a3d953fa6..87bd4853b 100644 --- a/Source/Project64-core/Plugins/AudioPlugin.h +++ b/Source/Project64-core/Plugins/AudioPlugin.h @@ -10,25 +10,34 @@ public: void DacrateChanged(SYSTEM_TYPE Type); bool Initiate(CN64System * System, RenderWindow * Window); - void(CALL *AiLenChanged)(void); - uint32_t(CALL *AiReadLength)(void); - void(CALL *ProcessAList)(void); + void(CALL * AiLenChanged)(void); + uint32_t(CALL * AiReadLength)(void); + void(CALL * ProcessAList)(void); private: - CAudioPlugin(const CAudioPlugin&); - CAudioPlugin& operator=(const CAudioPlugin&); + CAudioPlugin(const CAudioPlugin &); + CAudioPlugin & operator=(const CAudioPlugin &); - virtual int32_t GetDefaultSettingStartRange() const { return FirstAudioDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstAudioSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_AUDIO; } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstAudioDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstAudioSettings; + } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_AUDIO; + } void * m_hAudioThread; bool LoadFunctions(void); void UnloadPluginDetails(void); - void(CALL *AiUpdate) (int32_t Wait); - void(CALL *AiDacrateChanged)(SYSTEM_TYPE Type); + void(CALL * AiUpdate)(int32_t Wait); + void(CALL * AiDacrateChanged)(SYSTEM_TYPE Type); static void AudioThread(CAudioPlugin * _this); }; diff --git a/Source/Project64-core/Plugins/ControllerPlugin.cpp b/Source/Project64-core/Plugins/ControllerPlugin.cpp index 0d1083a29..9528f45a5 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.cpp +++ b/Source/Project64-core/Plugins/ControllerPlugin.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" -#include -#include -#include + #include "ControllerPlugin.h" +#include +#include +#include CControl_Plugin::CControl_Plugin(void) : WM_KeyDown(nullptr), @@ -26,7 +27,7 @@ CControl_Plugin::~CControl_Plugin() bool CControl_Plugin::LoadFunctions(void) { // Find entries for functions in DLL - void(CALL *InitiateControllers)(void); + void(CALL * InitiateControllers)(void); LoadFunction(InitiateControllers); LoadFunction(ControllerCommand); LoadFunction(GetKeys); @@ -38,11 +39,19 @@ bool CControl_Plugin::LoadFunctions(void) LoadFunction(EmulationPaused); // Make sure DLL had all needed functions - if (InitiateControllers == nullptr) { UnloadPlugin(); return false; } + if (InitiateControllers == nullptr) + { + UnloadPlugin(); + return false; + } if (m_PluginInfo.Version >= 0x0102) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } // Allocate our own controller @@ -69,9 +78,12 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) if (m_PluginInfo.Version == 0x0100) { // Get function from DLL - void(CALL *InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]); + void(CALL * InitiateControllers_1_0)(void * hMainWindow, CONTROL Controls[4]); _LoadFunction("InitiateControllers", InitiateControllers_1_0); - if (InitiateControllers_1_0 == nullptr) { return false; } + if (InitiateControllers_1_0 == nullptr) + { + return false; + } #ifdef _WIN32 InitiateControllers_1_0(Window->GetWindowHandle(), m_PluginControllers); #else @@ -96,9 +108,12 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) if (m_PluginInfo.Version == 0x0101) { // Get function from DLL - void(CALL *InitiateControllers_1_1)(CONTROL_INFO ControlInfo); + void(CALL * InitiateControllers_1_1)(CONTROL_INFO ControlInfo); _LoadFunction("InitiateControllers", InitiateControllers_1_1); - if (InitiateControllers_1_1 == nullptr) { return false; } + if (InitiateControllers_1_1 == nullptr) + { + return false; + } InitiateControllers_1_1(ControlInfo); m_Initialized = true; @@ -106,9 +121,12 @@ bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) else if (m_PluginInfo.Version >= 0x0102) { // Get function from DLL - void(CALL *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); + void(CALL * InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); _LoadFunction("InitiateControllers", InitiateControllers_1_2); - if (InitiateControllers_1_2 == nullptr) { return false; } + if (InitiateControllers_1_2 == nullptr) + { + return false; + } InitiateControllers_1_2(&ControlInfo); m_Initialized = true; @@ -138,10 +156,16 @@ void CControl_Plugin::UnloadPluginDetails(void) void CControl_Plugin::UpdateKeys(void) { - if (!m_AllocatedControllers) { return; } + if (!m_AllocatedControllers) + { + return; + } for (int32_t cont = 0; cont < sizeof(m_Controllers) / sizeof(m_Controllers[0]); cont++) { - if (!m_Controllers[cont]->Present()) { continue; } + if (!m_Controllers[cont]->Present()) + { + continue; + } if (!m_Controllers[cont]->m_RawData) { GetKeys(cont, &m_Controllers[cont]->m_Buttons); @@ -151,7 +175,10 @@ void CControl_Plugin::UpdateKeys(void) g_Notify->BreakPoint(__FILE__, __LINE__); } } - if (ReadController) { ReadController(-1, nullptr); } + if (ReadController) + { + ReadController(-1, nullptr); + } } void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin) @@ -171,7 +198,7 @@ void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin) } } -CCONTROL::CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType) : +CCONTROL::CCONTROL(int32_t & Present, int32_t & RawData, int32_t & PlugType) : m_Present(Present), m_RawData(RawData), m_PlugType(PlugType) { m_Buttons.Value = 0; diff --git a/Source/Project64-core/Plugins/ControllerPlugin.h b/Source/Project64-core/Plugins/ControllerPlugin.h index e08b51921..277dced13 100644 --- a/Source/Project64-core/Plugins/ControllerPlugin.h +++ b/Source/Project64-core/Plugins/ControllerPlugin.h @@ -7,10 +7,20 @@ class CControl_Plugin; class CCONTROL { public: - CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType); - inline bool Present(void) const { return m_Present != 0; } - inline uint32_t Buttons(void) const { return m_Buttons.Value; } - inline PluginType Plugin(void) const { return static_cast(m_PlugType); } + CCONTROL(int32_t & Present, int32_t & RawData, int32_t & PlugType); + inline bool Present(void) const + { + return m_Present != 0; + } + inline uint32_t Buttons(void) const + { + return m_Buttons.Value; + } + inline PluginType Plugin(void) const + { + return static_cast(m_PlugType); + } + private: friend class CControl_Plugin; @@ -20,14 +30,14 @@ private: BUTTONS m_Buttons; CCONTROL(void); - CCONTROL(const CCONTROL&); - CCONTROL& operator=(const CCONTROL&); + CCONTROL(const CCONTROL &); + CCONTROL & operator=(const CCONTROL &); }; class CControl_Plugin : public CPlugin { public: - typedef void(CALL * fnGetKeys) (int32_t Control, BUTTONS * Keys); + typedef void(CALL * fnGetKeys)(int32_t Control, BUTTONS * Keys); CControl_Plugin(void); ~CControl_Plugin(); @@ -36,25 +46,40 @@ public: void SetControl(CControl_Plugin const * const Plugin); void UpdateKeys(void); - void(CALL *WM_KeyDown) (uint32_t wParam, uint32_t lParam); - void(CALL *WM_KeyUp) (uint32_t wParam, uint32_t lParam); - void(CALL *WM_KillFocus) (uint32_t wParam, uint32_t lParam); - void(CALL *EmulationPaused) (); - void(CALL *RumbleCommand) (int32_t Control, int32_t bRumble); + void(CALL * WM_KeyDown)(uint32_t wParam, uint32_t lParam); + void(CALL * WM_KeyUp)(uint32_t wParam, uint32_t lParam); + void(CALL * WM_KillFocus)(uint32_t wParam, uint32_t lParam); + void(CALL * EmulationPaused)(); + void(CALL * RumbleCommand)(int32_t Control, int32_t bRumble); fnGetKeys GetKeys; - void(CALL *ReadController) (int32_t Control, uint8_t * Command); - void(CALL *ControllerCommand) (int32_t Control, uint8_t * Command); + void(CALL * ReadController)(int32_t Control, uint8_t * Command); + void(CALL * ControllerCommand)(int32_t Control, uint8_t * Command); - inline CCONTROL const * Controller(int32_t control) { return m_Controllers[control]; } - inline CONTROL * PluginControllers(void) { return m_PluginControllers; } + inline CCONTROL const * Controller(int32_t control) + { + return m_Controllers[control]; + } + inline CONTROL * PluginControllers(void) + { + return m_PluginControllers; + } private: - CControl_Plugin(const CControl_Plugin&); - CControl_Plugin& operator=(const CControl_Plugin&); + CControl_Plugin(const CControl_Plugin &); + CControl_Plugin & operator=(const CControl_Plugin &); - virtual int32_t GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstCtrlSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstCtrlDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstCtrlSettings; + } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_CONTROLLER; + } bool LoadFunctions(void); void UnloadPluginDetails(void); diff --git a/Source/Project64-core/Plugins/GFXPlugin.cpp b/Source/Project64-core/Plugins/GFXPlugin.cpp index a404ebc42..3e0aee40c 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.cpp +++ b/Source/Project64-core/Plugins/GFXPlugin.cpp @@ -1,11 +1,12 @@ #include "stdafx.h" -#include -#include -#include + +#include "GFXPlugin.h" #include #include +#include +#include #include -#include "GFXPlugin.h" +#include CGfxPlugin::CGfxPlugin() : CaptureScreen(nullptr), @@ -39,7 +40,7 @@ CGfxPlugin::~CGfxPlugin() bool CGfxPlugin::LoadFunctions(void) { // Find entries for functions in DLL - int32_t(CALL *InitiateGFX) (void * Gfx_Info); + int32_t(CALL * InitiateGFX)(void * Gfx_Info); LoadFunction(InitiateGFX); LoadFunction(ChangeWindow); LoadFunction(DrawScreen); @@ -62,15 +63,46 @@ bool CGfxPlugin::LoadFunctions(void) LoadFunction(OnRomBrowserMenuItem); // Make sure DLL had all needed functions - if (ChangeWindow == nullptr) { UnloadPlugin(); return false; } - if (DrawScreen == nullptr) { DrawScreen = DummyDrawScreen; } - if (InitiateGFX == nullptr) { UnloadPlugin(); return false; } - if (MoveScreen == nullptr) { MoveScreen = DummyMoveScreen; } - if (ProcessDList == nullptr) { UnloadPlugin(); return false; } - if (UpdateScreen == nullptr) { UnloadPlugin(); return false; } - if (ViStatusChanged == nullptr) { ViStatusChanged = DummyViStatusChanged; } - if (ViWidthChanged == nullptr) { ViWidthChanged = DummyViWidthChanged; } - if (SoftReset == nullptr) { SoftReset = DummySoftReset; } + if (ChangeWindow == nullptr) + { + UnloadPlugin(); + return false; + } + if (DrawScreen == nullptr) + { + DrawScreen = DummyDrawScreen; + } + if (InitiateGFX == nullptr) + { + UnloadPlugin(); + return false; + } + if (MoveScreen == nullptr) + { + MoveScreen = DummyMoveScreen; + } + if (ProcessDList == nullptr) + { + UnloadPlugin(); + return false; + } + if (UpdateScreen == nullptr) + { + UnloadPlugin(); + return false; + } + if (ViStatusChanged == nullptr) + { + ViStatusChanged = DummyViStatusChanged; + } + if (ViWidthChanged == nullptr) + { + ViWidthChanged = DummyViWidthChanged; + } + if (SoftReset == nullptr) + { + SoftReset = DummySoftReset; + } if (m_PluginInfo.Version >= 0x0103) { @@ -80,14 +112,30 @@ bool CGfxPlugin::LoadFunctions(void) LoadFunction(GetDebugInfo); _LoadFunction("InitiateGFXDebugger", InitiateDebugger); - if (ProcessRDPList == nullptr) { UnloadPlugin(); return false; } - if (CaptureScreen == nullptr) { UnloadPlugin(); return false; } - if (ShowCFB == nullptr) { UnloadPlugin(); return false; } + if (ProcessRDPList == nullptr) + { + UnloadPlugin(); + return false; + } + if (CaptureScreen == nullptr) + { + UnloadPlugin(); + return false; + } + if (ShowCFB == nullptr) + { + UnloadPlugin(); + return false; + } } if (m_PluginInfo.Version >= 0x0104) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } if (GetDebugInfo != nullptr) @@ -113,14 +161,14 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) typedef struct { - void * hWnd; // Render window - void * hStatusBar; // If render window does not have a status bar then this is NULL + void * hWnd; // Render window + void * hStatusBar; // If render window does not have a status bar then this is NULL - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary // eg. the first 8 bytes are stored like this: // 4 3 2 1 8 7 6 5 - uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) + uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; uint8_t * DMEM; @@ -152,14 +200,14 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) uint32_t * VI__X_SCALE_REG; uint32_t * VI__Y_SCALE_REG; - void(CALL *CheckInterrupts)(void); + void(CALL * CheckInterrupts)(void); #ifdef ANDROID - void(CALL *SwapBuffers)(void); + void(CALL * SwapBuffers)(void); #endif } GFX_INFO; // Get function from DLL - int32_t(CALL *InitiateGFX)(GFX_INFO Gfx_Info); + int32_t(CALL * InitiateGFX)(GFX_INFO Gfx_Info); _LoadFunction("InitiateGFX", InitiateGFX); if (InitiateGFX == nullptr) { @@ -167,7 +215,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) return false; } - GFX_INFO Info = { 0 }; + GFX_INFO Info = {0}; Info.MemoryBswaped = true; #if defined(ANDROID) || defined(__ANDROID__) @@ -296,7 +344,7 @@ void CGfxPlugin::ProcessMenuItem(int32_t id) void CGfxPlugin::SwapBuffers(void) { RenderWindow * render = g_Plugins ? g_Plugins->MainWindow() : nullptr; - WriteTrace(TraceVideoPlugin, TraceDebug, "Start (render: %p)",render); + WriteTrace(TraceVideoPlugin, TraceDebug, "Start (render: %p)", render); if (render != nullptr) { render->SwapWindow(); diff --git a/Source/Project64-core/Plugins/GFXPlugin.h b/Source/Project64-core/Plugins/GFXPlugin.h index 7847127bb..c016a997c 100644 --- a/Source/Project64-core/Plugins/GFXPlugin.h +++ b/Source/Project64-core/Plugins/GFXPlugin.h @@ -8,34 +8,34 @@ class CGfxPlugin : public CPlugin // Menu // Items should have an ID between 5101 and 5200 void * hGFXMenu; - void(CALL *ProcessMenuItem)(int32_t ID); + void(CALL * ProcessMenuItem)(int32_t ID); // Breakpoints int32_t UseBPoints; char BPPanelName[20]; - void(CALL *Add_BPoint) (void); - void(CALL *CreateBPPanel) (void * hDlg, void * rcBox); - void(CALL *HideBPPanel) (void); - void(CALL *PaintBPPanel) (void * ps); - void(CALL *ShowBPPanel) (void); - void(CALL *RefreshBpoints) (void * hList); - void(CALL *RemoveBpoint) (void * hList, int32_t index); - void(CALL *RemoveAllBpoint) (void); + void(CALL * Add_BPoint)(void); + void(CALL * CreateBPPanel)(void * hDlg, void * rcBox); + void(CALL * HideBPPanel)(void); + void(CALL * PaintBPPanel)(void * ps); + void(CALL * ShowBPPanel)(void); + void(CALL * RefreshBpoints)(void * hList); + void(CALL * RemoveBpoint)(void * hList, int32_t index); + void(CALL * RemoveAllBpoint)(void); // GFX command window - void(CALL *Enter_GFX_Commands_Window)(void); + void(CALL * Enter_GFX_Commands_Window)(void); } GFXDEBUG_INFO; typedef struct { - void(CALL *UpdateBreakPoints)(void); - void(CALL *UpdateMemory)(void); - void(CALL *UpdateR4300iRegisters)(void); - void(CALL *Enter_BPoint_Window)(void); - void(CALL *Enter_R4300i_Commands_Window)(void); - void(CALL *Enter_R4300i_Register_Window)(void); - void(CALL *Enter_RSP_Commands_Window)(void); - void(CALL *Enter_Memory_Window)(void); + void(CALL * UpdateBreakPoints)(void); + void(CALL * UpdateMemory)(void); + void(CALL * UpdateR4300iRegisters)(void); + void(CALL * Enter_BPoint_Window)(void); + void(CALL * Enter_R4300i_Commands_Window)(void); + void(CALL * Enter_R4300i_Register_Window)(void); + void(CALL * Enter_RSP_Commands_Window)(void); + void(CALL * Enter_Memory_Window)(void); } DEBUG_INFO; public: @@ -45,51 +45,73 @@ public: bool LoadFunctions(void); bool Initiate(CN64System * System, RenderWindow * Window); - void(CALL *CaptureScreen) (const char *); - void(CALL *ChangeWindow) (void); - void(CALL *DrawScreen) (void); - void(CALL *DrawStatus) (const char * lpString, int32_t RightAlign); - void(CALL *MoveScreen) (int32_t xpos, int32_t ypos); - void(CALL *ProcessDList) (void); - void(CALL *ProcessRDPList) (void); - void(CALL *ShowCFB) (void); - void(CALL *UpdateScreen) (void); - void(CALL *ViStatusChanged) (void); - void(CALL *ViWidthChanged) (void); - void(CALL *SoftReset) (void); + void(CALL * CaptureScreen)(const char *); + void(CALL * ChangeWindow)(void); + void(CALL * DrawScreen)(void); + void(CALL * DrawStatus)(const char * lpString, int32_t RightAlign); + void(CALL * MoveScreen)(int32_t xpos, int32_t ypos); + void(CALL * ProcessDList)(void); + void(CALL * ProcessRDPList)(void); + void(CALL * ShowCFB)(void); + void(CALL * UpdateScreen)(void); + void(CALL * ViStatusChanged)(void); + void(CALL * ViWidthChanged)(void); + void(CALL * SoftReset)(void); #ifdef ANDROID - void(CALL *SurfaceCreated) (void); - void(CALL *SurfaceChanged) (int w, int h); + void(CALL * SurfaceCreated)(void); + void(CALL * SurfaceChanged)(int w, int h); #endif // ROM browser void *(CALL * GetRomBrowserMenu)(void); // Items should have an ID between 4101 and 4200 void(CALL * OnRomBrowserMenuItem)(int32_t MenuID, void * hParent, uint8_t * HEADER); - void * GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; } + void * GetDebugMenu(void) + { + return m_GFXDebug.hGFXMenu; + } void ProcessMenuItem(int32_t id); private: - CGfxPlugin(const CGfxPlugin&); - CGfxPlugin& operator=(const CGfxPlugin&); + CGfxPlugin(const CGfxPlugin &); + CGfxPlugin & operator=(const CGfxPlugin &); - virtual int32_t GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstGfxSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_VIDEO; } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstGfxDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstGfxSettings; + } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_VIDEO; + } void UnloadPluginDetails(void); GFXDEBUG_INFO m_GFXDebug; - void(CALL *GetDebugInfo) (GFXDEBUG_INFO * GFXDebugInfo); - void(CALL *InitiateDebugger)(DEBUG_INFO DebugInfo); + void(CALL * GetDebugInfo)(GFXDEBUG_INFO * GFXDebugInfo); + void(CALL * InitiateDebugger)(DEBUG_INFO DebugInfo); #ifdef ANDROID static void SwapBuffers(void); #endif - static void CALL DummyDrawScreen(void) {} - static void CALL DummyMoveScreen(int32_t /*xpos*/, int32_t /*ypos*/) {} - static void CALL DummyViStatusChanged(void) {} - static void CALL DummyViWidthChanged(void) {} - static void CALL DummySoftReset(void) {} + static void CALL DummyDrawScreen(void) + { + } + static void CALL DummyMoveScreen(int32_t /*xpos*/, int32_t /*ypos*/) + { + } + static void CALL DummyViStatusChanged(void) + { + } + static void CALL DummyViWidthChanged(void) + { + } + static void CALL DummySoftReset(void) + { + } }; \ No newline at end of file diff --git a/Source/Project64-core/Plugins/Plugin.cpp b/Source/Project64-core/Plugins/Plugin.cpp index 3e439dbca..6eb49dc8b 100644 --- a/Source/Project64-core/Plugins/Plugin.cpp +++ b/Source/Project64-core/Plugins/Plugin.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" -#include -#include -#include + #include +#include +#include +#include CPlugins::CPlugins(SettingID PluginDirSetting, bool SyncPlugins) : m_MainWindow(nullptr), @@ -81,10 +82,22 @@ void CPlugins::PluginChanged(CPlugins * _this) if (bGfxChange || bAudioChange || bRspChange || bContChange) { - if (bGfxChange) { WriteTrace(TracePlugins, TraceDebug, "GFX plugin changed"); } - if (bAudioChange) { WriteTrace(TracePlugins, TraceDebug, "Audio plugin changed"); } - if (bRspChange) { WriteTrace(TracePlugins, TraceDebug, "RSP plugin changed"); } - if (bContChange) { WriteTrace(TracePlugins, TraceDebug, "Controller plugin changed"); } + if (bGfxChange) + { + WriteTrace(TracePlugins, TraceDebug, "GFX plugin changed"); + } + if (bAudioChange) + { + WriteTrace(TracePlugins, TraceDebug, "Audio plugin changed"); + } + if (bRspChange) + { + WriteTrace(TracePlugins, TraceDebug, "RSP plugin changed"); + } + if (bContChange) + { + WriteTrace(TracePlugins, TraceDebug, "Controller plugin changed"); + } if (g_Settings->LoadBool(GameRunning_CPU_Running)) { // Ensure that base system actually exists before we go triggering the event @@ -102,7 +115,7 @@ void CPlugins::PluginChanged(CPlugins * _this) } template -static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy) +static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type *& plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy) { if (plugin != nullptr) { @@ -276,22 +289,46 @@ bool CPlugins::Initiate(CN64System * System) { WriteTrace(TracePlugins, TraceDebug, "Start"); // Check to make sure we have the plugin available to be used - if (m_Gfx == nullptr) { return false; } - if (m_Audio == nullptr) { return false; } - if (m_RSP == nullptr) { return false; } - if (m_Control == nullptr) { return false; } + if (m_Gfx == nullptr) + { + return false; + } + if (m_Audio == nullptr) + { + return false; + } + if (m_RSP == nullptr) + { + return false; + } + if (m_Control == nullptr) + { + return false; + } WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate starting"); - if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate done"); WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate starting"); - if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate done"); WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate starting"); - if (!m_Control->Initiate(System, m_MainWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate done"); WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate starting"); - if (!m_RSP->Initiate(this, System)) { return false; } + if (!m_RSP->Initiate(this, System)) + { + return false; + } WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate done"); WriteTrace(TracePlugins, TraceDebug, "Done"); m_initilized = true; @@ -322,47 +359,71 @@ bool CPlugins::Reset(CN64System * System) bRspChange = true; } - if (bGfxChange) { DestroyGfxPlugin(); } - if (bAudioChange) { DestroyAudioPlugin(); } - if (bRspChange) { DestroyRspPlugin(); } - if (bContChange) { DestroyControlPlugin(); } + if (bGfxChange) + { + DestroyGfxPlugin(); + } + if (bAudioChange) + { + DestroyAudioPlugin(); + } + if (bRspChange) + { + DestroyRspPlugin(); + } + if (bContChange) + { + DestroyControlPlugin(); + } CreatePlugins(); if (m_Gfx && bGfxChange) { WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate starting"); - if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceVideoPlugin, TraceDebug, "GFX initiate done"); } if (m_Audio && bAudioChange) { WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate starting"); - if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceAudioPlugin, TraceDebug, "Audio initiate done"); } if (m_Control && bContChange) { WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate starting"); - if (!m_Control->Initiate(System, m_MainWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) + { + return false; + } WriteTrace(TraceControllerPlugin, TraceDebug, "Control initiate done"); } if (m_RSP && bRspChange) { WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate starting"); - if (!m_RSP->Initiate(this, System)) { return false; } + if (!m_RSP->Initiate(this, System)) + { + return false; + } WriteTrace(TraceRSPPlugin, TraceDebug, "RSP initiate done"); } - if (System) - { - System->RefreshSyncToAudio(); - } + if (System) + { + System->RefreshSyncToAudio(); + } WriteTrace(TracePlugins, TraceDebug, "Done"); return true; } -void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) +void CPlugins::ConfigPlugin(void * hParent, PLUGIN_TYPE Type) { if (g_BaseSystem) { @@ -372,7 +433,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) switch (Type) { case PLUGIN_TYPE_RSP: - if (m_RSP == nullptr || m_RSP->DllConfig == nullptr) { break; } + if (m_RSP == nullptr || m_RSP->DllConfig == nullptr) + { + break; + } if (!m_RSP->Initialized()) { if (!m_RSP->Initiate(this, nullptr)) @@ -383,7 +447,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) m_RSP->DllConfig(hParent); break; case PLUGIN_TYPE_VIDEO: - if (m_Gfx == nullptr || m_Gfx->DllConfig == nullptr) { break; } + if (m_Gfx == nullptr || m_Gfx->DllConfig == nullptr) + { + break; + } if (!m_Gfx->Initialized()) { if (!m_Gfx->Initiate(nullptr, m_MainWindow)) @@ -394,7 +461,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) m_Gfx->DllConfig(hParent); break; case PLUGIN_TYPE_AUDIO: - if (m_Audio == nullptr || m_Audio->DllConfig == nullptr) { break; } + if (m_Audio == nullptr || m_Audio->DllConfig == nullptr) + { + break; + } if (!m_Audio->Initialized()) { if (!m_Audio->Initiate(nullptr, m_MainWindow)) @@ -409,7 +479,10 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) } break; case PLUGIN_TYPE_CONTROLLER: - if (m_Control == nullptr || m_Control->DllConfig == nullptr) { break; } + if (m_Control == nullptr || m_Control->DllConfig == nullptr) + { + break; + } if (!m_Control->Initialized()) { if (!m_Control->Initiate(nullptr, m_MainWindow)) diff --git a/Source/Project64-core/Plugins/Plugin.h b/Source/Project64-core/Plugins/Plugin.h index e3243e0a3..fe6c73130 100644 --- a/Source/Project64-core/Plugins/Plugin.h +++ b/Source/Project64-core/Plugins/Plugin.h @@ -1,76 +1,79 @@ #pragma once -#include #include #include #include +#include // Enums enum SETTING_DATA_TYPE { - Data_DWORD_General = 0, // A uint32_t setting used anywhere - Data_String_General = 1, // A string setting used anywhere - Data_DWORD_Game = 2, // A uint32_t associated with the current game - Data_String_Game = 3, // A string associated with the current game - Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the ROM database - Data_String_RDB = 5, // A string associated with the current game in the ROM database - Data_DWORD_RDB_Setting = 6, // A uint32_t read from the ROM database, with config file + Data_DWORD_General = 0, // A uint32_t setting used anywhere + Data_String_General = 1, // A string setting used anywhere + Data_DWORD_Game = 2, // A uint32_t associated with the current game + Data_String_Game = 3, // A string associated with the current game + Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the ROM database + Data_String_RDB = 5, // A string associated with the current game in the ROM database + Data_DWORD_RDB_Setting = 6, // A uint32_t read from the ROM database, with config file Data_String_RDB_Setting = 7, // A string read from the ROM database, with config file }; typedef struct { - uint32_t dwSize; - int32_t DefaultStartRange; - int32_t SettingStartRange; - int32_t MaximumSettings; - int32_t NoDefault; - int32_t DefaultLocation; + uint32_t dwSize; + int32_t DefaultStartRange; + int32_t SettingStartRange; + int32_t MaximumSettings; + int32_t NoDefault; + int32_t DefaultLocation; void * handle; - uint32_t(*GetSetting) (void * handle, int32_t ID); - const char * (*GetSettingSz) (void * handle, int32_t ID, char * Buffer, int32_t BufferLen); - void(*SetSetting) (void * handle, int32_t ID, uint32_t Value); - void(*SetSettingSz) (void * handle, int32_t ID, const char * Value); - void(*RegisterSetting) (void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type, - SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value); - void(*UseUnregisteredSetting) (int32_t ID); + uint32_t (*GetSetting)(void * handle, int32_t ID); + const char * (*GetSettingSz)(void * handle, int32_t ID, char * Buffer, int32_t BufferLen); + void (*SetSetting)(void * handle, int32_t ID, uint32_t Value); + void (*SetSettingSz)(void * handle, int32_t ID, const char * Value); + void (*RegisterSetting)(void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type, + SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value); + void (*UseUnregisteredSetting)(int32_t ID); } PLUGIN_SETTINGS; typedef struct { - uint32_t(*FindSystemSettingId) (void * handle, const char * Name); + uint32_t (*FindSystemSettingId)(void * handle, const char * Name); } PLUGIN_SETTINGS2; typedef struct { - void(*FlushSettings) (void * handle); + void (*FlushSettings)(void * handle); } PLUGIN_SETTINGS3; typedef struct _PLUGIN_SETTINGS_NOTIFICATION { - typedef void(*SettingChangedFunc)(void *); + typedef void (*SettingChangedFunc)(void *); - void(*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); - void(*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); + void (*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); + void (*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func); } PLUGIN_SETTINGS_NOTIFICATION; typedef struct { - void(*DisplayError)(const char * Message); - void(*FatalError)(const char * Message); - void(*DisplayMessage)(int DisplayTime, const char * Message); - void(*DisplayMessage2)(const char * Message); - void(*BreakPoint)(const char * FileName, int32_t LineNumber); + void (*DisplayError)(const char * Message); + void (*FatalError)(const char * Message); + void (*DisplayMessage)(int DisplayTime, const char * Message); + void (*DisplayMessage2)(const char * Message); + void (*BreakPoint)(const char * FileName, int32_t LineNumber); } PLUGIN_NOTIFICATION; class CSettings; -class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; +class CGfxPlugin; +class CAudioPlugin; +class CRSP_Plugin; +class CControl_Plugin; class CN64System; class CPlugins; #if defined(_WIN32) #include #else -#define __interface struct +#define __interface struct #endif __interface RenderWindow @@ -106,20 +109,41 @@ public: bool ResetInUiThread(CN64System * System); void GameReset(void); - inline CGfxPlugin * Gfx(void) const { return m_Gfx; } - inline CAudioPlugin * Audio(void) const { return m_Audio; } - inline CRSP_Plugin * RSP(void) const { return m_RSP; } - inline CControl_Plugin * Control(void) const { return m_Control; } + inline CGfxPlugin * Gfx(void) const + { + return m_Gfx; + } + inline CAudioPlugin * Audio(void) const + { + return m_Audio; + } + inline CRSP_Plugin * RSP(void) const + { + return m_RSP; + } + inline CControl_Plugin * Control(void) const + { + return m_Control; + } - inline RenderWindow * MainWindow(void) const { return m_MainWindow; } - inline RenderWindow * SyncWindow(void) const { return m_SyncWindow; } + inline RenderWindow * MainWindow(void) const + { + return m_MainWindow; + } + inline RenderWindow * SyncWindow(void) const + { + return m_SyncWindow; + } - inline bool initilized(void) const { return m_initilized; } + inline bool initilized(void) const + { + return m_initilized; + } private: CPlugins(void); - CPlugins(const CPlugins&); - CPlugins& operator=(const CPlugins&); + CPlugins(const CPlugins &); + CPlugins & operator=(const CPlugins &); void DestroyGfxPlugin(void); void DestroyAudioPlugin(void); @@ -135,9 +159,9 @@ private: stdstr m_PluginDir; // Plugins - CGfxPlugin * m_Gfx; - CAudioPlugin * m_Audio; - CRSP_Plugin * m_RSP; + CGfxPlugin * m_Gfx; + CAudioPlugin * m_Audio; + CRSP_Plugin * m_RSP; CControl_Plugin * m_Control; stdstr m_GfxFile; diff --git a/Source/Project64-core/Plugins/PluginBase.cpp b/Source/Project64-core/Plugins/PluginBase.cpp index 43580b253..8a6484088 100644 --- a/Source/Project64-core/Plugins/PluginBase.cpp +++ b/Source/Project64-core/Plugins/PluginBase.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#include #include +#include CPlugin::CPlugin() : DllAbout(nullptr), @@ -46,13 +46,22 @@ bool CPlugin::Load(const char * FileName) } // Get DLL information - void(CALL *GetDllInfo) (PLUGIN_INFO * PluginInfo); + void(CALL * GetDllInfo)(PLUGIN_INFO * PluginInfo); LoadFunction(GetDllInfo); - if (GetDllInfo == nullptr) { return false; } + if (GetDllInfo == nullptr) + { + return false; + } GetDllInfo(&m_PluginInfo); - if (!ValidPluginVersion(m_PluginInfo)) { return false; } - if (m_PluginInfo.Type != type()) { return false; } + if (!ValidPluginVersion(m_PluginInfo)) + { + return false; + } + if (m_PluginInfo.Type != type()) + { + return false; + } LoadFunction(CloseDLL); LoadFunction(RomOpen); @@ -79,8 +88,8 @@ bool CPlugin::Load(const char * FileName) { WriteTrace(PluginTraceType(), TraceDebug, "Found SetSettingNotificationInfo"); PLUGIN_SETTINGS_NOTIFICATION info; - info.RegisterChangeCB = (void(*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sRegisterChangeCB; - info.UnregisterChangeCB = (void(*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sUnregisterChangeCB; + info.RegisterChangeCB = (void (*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sRegisterChangeCB; + info.UnregisterChangeCB = (void (*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sUnregisterChangeCB; SetSettingNotificationInfo(&info); } @@ -89,7 +98,7 @@ bool CPlugin::Load(const char * FileName) { WriteTrace(PluginTraceType(), TraceDebug, "Found SetSettingInfo3"); PLUGIN_SETTINGS3 info; - info.FlushSettings = (void(*)(void * handle))CSettings::FlushSettings; + info.FlushSettings = (void (*)(void * handle))CSettings::FlushSettings; SetSettingInfo3(&info); } @@ -114,11 +123,11 @@ bool CPlugin::Load(const char * FileName) info.NoDefault = Default_None; info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile; info.handle = g_Settings; - info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting; - info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting; - info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz; - info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting; - info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz; + info.RegisterSetting = (void (*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t)) & CSettings::RegisterSetting; + info.GetSetting = (uint32_t(*)(void *, int)) & CSettings::GetSetting; + info.GetSettingSz = (const char * (*)(void *, int, char *, int)) & CSettings::GetSettingSz; + info.SetSetting = (void (*)(void *, int, uint32_t)) & CSettings::SetSetting; + info.SetSettingSz = (void (*)(void *, int, const char *)) & CSettings::SetSettingSz; info.UseUnregisteredSetting = nullptr; SetSettingInfo(&info); @@ -220,10 +229,10 @@ void CPlugin::Close(RenderWindow * Render) WriteTrace(PluginTraceType(), TraceDebug, "(%s): Start", PluginType()); RomClose(Render); m_Initialized = false; - if (CloseDLL != nullptr) - { - CloseDLL(); - } + if (CloseDLL != nullptr) + { + CloseDLL(); + } WriteTrace(PluginTraceType(), TraceDebug, "(%s): Done", PluginType()); } @@ -282,25 +291,64 @@ bool CPlugin::ValidPluginVersion(PLUGIN_INFO & PluginInfo) switch (PluginInfo.Type) { case PLUGIN_TYPE_RSP: - if (PluginInfo.Version == 0x0001) { return true; } - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } + if (PluginInfo.Version == 0x0001) + { + return true; + } + if (PluginInfo.Version == 0x0100) + { + return true; + } + if (PluginInfo.Version == 0x0101) + { + return true; + } + if (PluginInfo.Version == 0x0102) + { + return true; + } + if (PluginInfo.Version == 0x0103) + { + return true; + } break; case PLUGIN_TYPE_VIDEO: - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } - if (PluginInfo.Version == 0x0104) { return true; } + if (PluginInfo.Version == 0x0102) + { + return true; + } + if (PluginInfo.Version == 0x0103) + { + return true; + } + if (PluginInfo.Version == 0x0104) + { + return true; + } break; case PLUGIN_TYPE_AUDIO: - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0101) + { + return true; + } + if (PluginInfo.Version == 0x0102) + { + return true; + } break; case PLUGIN_TYPE_CONTROLLER: - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0100) + { + return true; + } + if (PluginInfo.Version == 0x0101) + { + return true; + } + if (PluginInfo.Version == 0x0102) + { + return true; + } break; } return false; diff --git a/Source/Project64-core/Plugins/PluginBase.h b/Source/Project64-core/Plugins/PluginBase.h index 8bf00cf07..4d77b9e2b 100644 --- a/Source/Project64-core/Plugins/PluginBase.h +++ b/Source/Project64-core/Plugins/PluginBase.h @@ -1,10 +1,10 @@ #pragma once +#include +#include #include #include -#include #include -#include class CPlugin : private CDebugSettings @@ -12,8 +12,14 @@ class CPlugin : public: CPlugin(); virtual ~CPlugin(); - inline const char * PluginName() const { return m_PluginInfo.Name; } - inline bool Initialized() { return m_Initialized; } + inline const char * PluginName() const + { + return m_PluginInfo.Name; + } + inline bool Initialized() + { + return m_Initialized; + } virtual int32_t GetDefaultSettingStartRange() const = 0; virtual int32_t GetSettingStartRange() const = 0; @@ -25,8 +31,8 @@ public: void GameReset(RenderWindow * Render); void Close(RenderWindow * Render); - void(CALL *DllAbout) (void * hWnd); - void(CALL *DllConfig) (void * hParent); + void(CALL * DllAbout)(void * hWnd); + void(CALL * DllConfig)(void * hParent); static bool ValidPluginVersion(PLUGIN_INFO & PluginInfo); @@ -38,11 +44,11 @@ protected: virtual PLUGIN_TYPE type() = 0; virtual bool LoadFunctions(void) = 0; - void(CALL * CloseDLL) (void); - void(CALL * RomOpen) (void); - void(CALL * RomClosed) (void); + void(CALL * CloseDLL)(void); + void(CALL * RomOpen)(void); + void(CALL * RomClosed)(void); void(CALL * PluginOpened)(void); - void(CALL * SetSettingInfo)(PLUGIN_SETTINGS *); + void(CALL * SetSettingInfo)(PLUGIN_SETTINGS *); void(CALL * SetSettingInfo2)(PLUGIN_SETTINGS2 *); void(CALL * SetSettingInfo3)(PLUGIN_SETTINGS3 *); void(CALL * SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *); @@ -61,7 +67,7 @@ protected: // Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments // i.e. _LoadFunction("CloseDLL", CloseDLL); #define LoadFunction(functionName) _LoadFunctionVoid(#functionName, (void **)&functionName) -#define _LoadFunction(functionName,function) _LoadFunctionVoid(functionName, (void **)&function) +#define _LoadFunction(functionName, function) _LoadFunctionVoid(functionName, (void **)&function) private: static void DisplayError(const char * Message); diff --git a/Source/Project64-core/Plugins/RSPPlugin.cpp b/Source/Project64-core/Plugins/RSPPlugin.cpp index a3cee4849..741448233 100644 --- a/Source/Project64-core/Plugins/RSPPlugin.cpp +++ b/Source/Project64-core/Plugins/RSPPlugin.cpp @@ -1,15 +1,19 @@ #include "stdafx.h" -#include + +#include "GFXPlugin.h" +#include "RSPPlugin.h" #include #include -#include #include #include -#include "RSPPlugin.h" -#include "GFXPlugin.h" +#include +#include #include -void DummyFunc1(int a) { a += 1; } +void DummyFunc1(int a) +{ + a += 1; +} CRSP_Plugin::CRSP_Plugin(void) : DoRspCycles(nullptr), @@ -30,23 +34,46 @@ CRSP_Plugin::~CRSP_Plugin() bool CRSP_Plugin::LoadFunctions(void) { // Find entries for functions in DLL - void(CALL *InitiateRSP)(void); + void(CALL * InitiateRSP)(void); LoadFunction(InitiateRSP); LoadFunction(DoRspCycles); _LoadFunction("GetRspDebugInfo", GetDebugInfo); _LoadFunction("InitiateRSPDebugger", InitiateDebugger); LoadFunction(EnableDebugging); - if (EnableDebugging == nullptr) { EnableDebugging = DummyFunc1; } + if (EnableDebugging == nullptr) + { + EnableDebugging = DummyFunc1; + } // Make sure DLL had all needed functions - if (DoRspCycles == nullptr) { UnloadPlugin(); return false; } - if (InitiateRSP == nullptr) { UnloadPlugin(); return false; } - if (RomClosed == nullptr) { UnloadPlugin(); return false; } - if (CloseDLL == nullptr) { UnloadPlugin(); return false; } + if (DoRspCycles == nullptr) + { + UnloadPlugin(); + return false; + } + if (InitiateRSP == nullptr) + { + UnloadPlugin(); + return false; + } + if (RomClosed == nullptr) + { + UnloadPlugin(); + return false; + } + if (CloseDLL == nullptr) + { + UnloadPlugin(); + return false; + } if (m_PluginInfo.Version >= 0x0102) { - if (PluginOpened == nullptr) { UnloadPlugin(); return false; } + if (PluginOpened == nullptr) + { + UnloadPlugin(); + return false; + } } // Get debug info if possible @@ -72,8 +99,8 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) typedef struct { void * hInst; - int MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary - uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) + int MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary + uint8_t * HEADER; // This is the ROM header (first 40h bytes of the ROM) // This will be in the same memory format as the rest of the memory uint8_t * RDRAM; uint8_t * DMEM; @@ -100,14 +127,14 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) uint32_t * DPC__PIPEBUSY_REG; uint32_t * DPC__TMEM_REG; - void(CALL *CheckInterrupts)(void); - void(CALL *ProcessDlist)(void); - void(CALL *ProcessAlist)(void); - void(CALL *ProcessRdpList)(void); - void(CALL *ShowCFB)(void); + void(CALL * CheckInterrupts)(void); + void(CALL * ProcessDlist)(void); + void(CALL * ProcessAlist)(void); + void(CALL * ProcessRdpList)(void); + void(CALL * ShowCFB)(void); } RSP_INFO_1_3; - RSP_INFO_1_3 Info = { 0 }; + RSP_INFO_1_3 Info = {0}; #ifdef _WIN32 Info.hInst = (Plugins != nullptr && Plugins->MainWindow() != nullptr) ? Plugins->MainWindow()->GetModuleInstance() : nullptr; @@ -116,9 +143,9 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) #endif Info.CheckInterrupts = DummyCheckInterrupts; Info.MemoryBswaped = (System == nullptr); // Only true when the system's not yet loaded - + // Get function from DLL - void(CALL *InitiateRSP) (RSP_INFO_1_3 RSP_Info, uint32_t * Cycles); + void(CALL * InitiateRSP)(RSP_INFO_1_3 RSP_Info, uint32_t * Cycles); LoadFunction(InitiateRSP); if (InitiateRSP == nullptr) { @@ -208,12 +235,12 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) InitiateRSP(Info, &m_CycleCount); } - else + else { typedef struct { void * hInst; - int MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary + int MemoryBswaped; // If this is set to TRUE, then the memory has been pre-bswap'd on a DWORD (32-bit) boundary uint8_t * RDRAM; uint8_t * DMEM; uint8_t * IMEM; @@ -239,14 +266,14 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) uint32_t * DPC__PIPEBUSY_REG; uint32_t * DPC__TMEM_REG; - void(CALL *CheckInterrupts)(void); - void(CALL *ProcessDlist)(void); - void(CALL *ProcessAlist)(void); - void(CALL *ProcessRdpList)(void); - void(CALL *ShowCFB)(void); + void(CALL * CheckInterrupts)(void); + void(CALL * ProcessDlist)(void); + void(CALL * ProcessAlist)(void); + void(CALL * ProcessRdpList)(void); + void(CALL * ShowCFB)(void); } RSP_INFO_1_1; - RSP_INFO_1_1 Info = { 0 }; + RSP_INFO_1_1 Info = {0}; #ifdef _WIN32 Info.hInst = (Plugins != nullptr && Plugins->MainWindow() != nullptr) ? Plugins->MainWindow()->GetModuleInstance() : nullptr; @@ -255,9 +282,9 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) #endif Info.CheckInterrupts = DummyCheckInterrupts; Info.MemoryBswaped = (System == nullptr); // Only true when the system's not yet loaded - + // Get function from DLL - void(CALL *InitiateRSP) (RSP_INFO_1_1 RSP_Info, uint32_t * Cycles); + void(CALL * InitiateRSP)(RSP_INFO_1_1 RSP_Info, uint32_t * Cycles); LoadFunction(InitiateRSP); if (InitiateRSP == nullptr) { diff --git a/Source/Project64-core/Plugins/RSPPlugin.h b/Source/Project64-core/Plugins/RSPPlugin.h index 838376aa9..5da2392af 100644 --- a/Source/Project64-core/Plugins/RSPPlugin.h +++ b/Source/Project64-core/Plugins/RSPPlugin.h @@ -3,37 +3,39 @@ class CRSP_Plugin : public CPlugin { - typedef struct { + typedef struct + { // Menu // Items should have an ID between 5001 and 5100 void * hRSPMenu; - void(CALL *ProcessMenuItem) (int32_t ID); + void(CALL * ProcessMenuItem)(int32_t ID); // Breakpoints int32_t UseBPoints; char BPPanelName[20]; - void(CALL *Add_BPoint) (void); - void(CALL *CreateBPPanel) (void); - void(CALL *HideBPPanel) (void); - void(CALL *PaintBPPanel) (void); - void(CALL *ShowBPPanel) (void); - void(CALL *RefreshBpoints) (void * hList); - void(CALL *RemoveBpoint) (void * hList, int32_t index); - void(CALL *RemoveAllBpoint) (void); + void(CALL * Add_BPoint)(void); + void(CALL * CreateBPPanel)(void); + void(CALL * HideBPPanel)(void); + void(CALL * PaintBPPanel)(void); + void(CALL * ShowBPPanel)(void); + void(CALL * RefreshBpoints)(void * hList); + void(CALL * RemoveBpoint)(void * hList, int32_t index); + void(CALL * RemoveAllBpoint)(void); // RSP command window - void(CALL *Enter_RSP_Commands_Window)(void); + void(CALL * Enter_RSP_Commands_Window)(void); } RSPDEBUG_INFO; - typedef struct { - void(CALL *UpdateBreakPoints)(void); - void(CALL *UpdateMemory)(void); - void(CALL *UpdateR4300iRegisters)(void); - void(CALL *Enter_BPoint_Window)(void); - void(CALL *Enter_R4300i_Commands_Window)(void); - void(CALL *Enter_R4300i_Register_Window)(void); - void(CALL *Enter_RSP_Commands_Window)(void); - void(CALL *Enter_Memory_Window)(void); + typedef struct + { + void(CALL * UpdateBreakPoints)(void); + void(CALL * UpdateMemory)(void); + void(CALL * UpdateR4300iRegisters)(void); + void(CALL * Enter_BPoint_Window)(void); + void(CALL * Enter_R4300i_Commands_Window)(void); + void(CALL * Enter_R4300i_Register_Window)(void); + void(CALL * Enter_RSP_Commands_Window)(void); + void(CALL * Enter_Memory_Window)(void); } DEBUG_INFO; public: @@ -42,26 +44,38 @@ public: bool Initiate(CPlugins * Plugins, CN64System * System); - uint32_t(CALL *DoRspCycles)(uint32_t); - void(CALL *EnableDebugging)(int32_t Enable); + uint32_t(CALL * DoRspCycles)(uint32_t); + void(CALL * EnableDebugging)(int32_t Enable); - void * GetDebugMenu(void) { return m_RSPDebug.hRSPMenu; } + void * GetDebugMenu(void) + { + return m_RSPDebug.hRSPMenu; + } void ProcessMenuItem(int32_t id); private: - CRSP_Plugin(const CRSP_Plugin&); - CRSP_Plugin& operator=(const CRSP_Plugin&); + CRSP_Plugin(const CRSP_Plugin &); + CRSP_Plugin & operator=(const CRSP_Plugin &); - PLUGIN_TYPE type() { return PLUGIN_TYPE_RSP; } - virtual int32_t GetDefaultSettingStartRange() const { return FirstRSPDefaultSet; } - virtual int32_t GetSettingStartRange() const { return FirstRSPSettings; } + PLUGIN_TYPE type() + { + return PLUGIN_TYPE_RSP; + } + virtual int32_t GetDefaultSettingStartRange() const + { + return FirstRSPDefaultSet; + } + virtual int32_t GetSettingStartRange() const + { + return FirstRSPSettings; + } bool LoadFunctions(void); void UnloadPluginDetails(void); RSPDEBUG_INFO m_RSPDebug; - uint32_t m_CycleCount; + uint32_t m_CycleCount; - void(CALL *GetDebugInfo) (RSPDEBUG_INFO * GFXDebugInfo); - void(CALL *InitiateDebugger)(DEBUG_INFO DebugInfo); + void(CALL * GetDebugInfo)(RSPDEBUG_INFO * GFXDebugInfo); + void(CALL * InitiateDebugger)(DEBUG_INFO DebugInfo); }; diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index 9333171f2..ea2bbb2ef 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -1,15 +1,15 @@ #include "stdafx.h" + #include "RomList.h" #include -#include #include +#include #ifdef _WIN32 #include #endif -static const char* ROM_extensions[] = -{ +static const char * ROM_extensions[] = { #ifdef _WIN32 "7z", #endif @@ -123,7 +123,7 @@ void CRomList::RefreshRomListThread(void) void CRomList::AddRomToList(const char * RomLocation) { WriteTrace(TraceRomList, TraceVerbose, "Start (RomLocation: \"%s\")", RomLocation); - ROM_INFO RomInfo = { 0 }; + ROM_INFO RomInfo = {0}; strncpy(RomInfo.szFullFileName, RomLocation, (sizeof(RomInfo.szFullFileName) / sizeof(RomInfo.szFullFileName[0])) - 1); if (FillRomInfo(&RomInfo)) @@ -249,7 +249,10 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) continue; } WriteTrace(TraceUserInterface, TraceDebug, "9"); - if (!CN64Rom::IsValidRomImage(RomData)) { continue; } + if (!CN64Rom::IsValidRomImage(RomData)) + { + continue; + } WriteTrace(TraceUserInterface, TraceDebug, "10"); ByteSwapRomData(RomData, sizeof(RomData)); WriteTrace(TraceUserInterface, TraceDebug, "11"); @@ -344,7 +347,10 @@ bool CRomList::LoadDataFromRomFile(const char * FileName, uint8_t * Data, int32_ char zname[132]; unzFile file; file = unzOpen(FileName); - if (file == nullptr) { return false; } + if (file == nullptr) + { + return false; + } port = unzGoToFirstFile(file); FoundRom = false; @@ -424,7 +430,7 @@ bool CRomList::LoadDataFromRomFile(const char * FileName, uint8_t * Data, int32_ // Could still be a disk image // System data - const uint8_t blocks[7] = { 2, 3, 10, 11, 1, 8, 9 }; + const uint8_t blocks[7] = {2, 3, 10, 11, 1, 8, 9}; for (int i = 0; i < 7; i++) { sysdataoffset = 0x4D08 * blocks[i]; diff --git a/Source/Project64-core/RomList/RomList.h b/Source/Project64-core/RomList/RomList.h index 5b62815f5..24e98841e 100644 --- a/Source/Project64-core/RomList/RomList.h +++ b/Source/Project64-core/RomList/RomList.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include -#include #include +#include +#include #include class CRomList @@ -54,9 +54,15 @@ public: protected: typedef std::vector ROMINFO_LIST; - virtual void RomListReset(void) {} - virtual void RomAddedToList(int32_t /*ListPos*/) {} - virtual void RomListLoaded(void) {} + virtual void RomListReset(void) + { + } + virtual void RomAddedToList(int32_t /*ListPos*/) + { + } + virtual void RomListLoaded(void) + { + } MD5 RomListHash(strlist & FileList); void AddFileNameToList(strlist & FileList, const stdstr & Directory, CPath & File); @@ -77,7 +83,7 @@ private: static void RefreshRomListStatic(CRomList * _this); static void ByteSwapRomData(uint8_t * Data, int32_t DataLen); - CPath m_GameDir; + CPath m_GameDir; CIniFile * m_NotesIniFile; CIniFile * m_ExtIniFile; CIniFile * m_RomIniFile; @@ -87,6 +93,6 @@ private: CThread m_RefreshThread; CIniFileBase::SectionList m_GameIdentifiers; - #define DISKSIZE_MAME 0x0435B0C0 - #define DISKSIZE_SDK 0x03DEC800 +#define DISKSIZE_MAME 0x0435B0C0 +#define DISKSIZE_SDK 0x03DEC800 }; diff --git a/Source/Project64-core/Settings.h b/Source/Project64-core/Settings.h index 4195d300d..25c436af6 100644 --- a/Source/Project64-core/Settings.h +++ b/Source/Project64-core/Settings.h @@ -18,7 +18,7 @@ enum SettingDataType class CSettings { public: - typedef void(*SettingChangedFunc)(void *); + typedef void (*SettingChangedFunc)(void *); CSettings(void); ~CSettings(void); @@ -82,12 +82,12 @@ public: bool IsSettingSet(SettingID Type); // Static functions for plugins - static uint32_t GetSetting(CSettings * _this, SettingID Type); + static uint32_t GetSetting(CSettings * _this, SettingID Type); static const char * GetSettingSz(CSettings * _this, SettingID Type, char * Buffer, uint32_t BufferSize); static void SetSetting(CSettings * _this, SettingID ID, uint32_t Value); static void SetSettingSz(CSettings * _this, SettingID ID, const char * Value); static void RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType, - SettingType Type, const char * Category, const char * DefaultStr, uint32_t Value); + SettingType Type, const char * Category, const char * DefaultStr, uint32_t Value); static uint32_t FindSetting(CSettings * _this, const char * Name); static void FlushSettings(CSettings * _this); static void sRegisterChangeCB(CSettings * _this, SettingID Type, void * Data, SettingChangedFunc Func); diff --git a/Source/Project64-core/Settings/DebugSettings.cpp b/Source/Project64-core/Settings/DebugSettings.cpp index b41f1f9e4..6ae96d045 100644 --- a/Source/Project64-core/Settings/DebugSettings.cpp +++ b/Source/Project64-core/Settings/DebugSettings.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "DebugSettings.h" int CDebugSettings::m_RefCount = 0; diff --git a/Source/Project64-core/Settings/DebugSettings.h b/Source/Project64-core/Settings/DebugSettings.h index 289d0ca6f..4bfa7a848 100644 --- a/Source/Project64-core/Settings/DebugSettings.h +++ b/Source/Project64-core/Settings/DebugSettings.h @@ -8,27 +8,90 @@ public: CDebugSettings(); virtual ~CDebugSettings(); - static inline bool HaveDebugger(void) { return m_HaveDebugger; } - static inline bool isDebugging(void) { return m_Debugging; } - static inline bool isStepping(void) { return m_Stepping; } - static inline bool SkipOp(void) { return m_SkipOp; } - static inline bool WaitingForStep(void) { return m_WaitingForStep; } - static inline bool bRecordRecompilerAsm(void) { return m_bRecordRecompilerAsm; } - static inline bool bShowTLBMisses(void) { return m_bShowTLBMisses; } - static inline bool bRecordExecutionTimes(void) { return m_RecordExecutionTimes; } - static inline bool HaveExecutionBP(void) { return m_HaveExecutionBP; } - static inline bool HaveWriteBP(void) { return m_HaveWriteBP; } - static inline bool HaveReadBP(void) { return m_HaveReadBP; } - static inline bool bShowPifRamErrors(void) { return m_bShowPifRamErrors; } - static inline bool bCPULoggingEnabled(void) { return m_bCPULoggingEnabled; } - static inline uint32_t ExceptionBreakpoints(void) { return m_ExceptionBreakpoints; } - static inline uint32_t FpExceptionBreakpoints(void) { return m_FpExceptionBreakpoints; } - static inline uint32_t IntrBreakpoints(void) { return m_IntrBreakpoints; } - static inline uint32_t RcpIntrBreakpoints(void) { return m_RcpIntrBreakpoints; } - static inline bool EndOnPermLoop(void) { return m_EndOnPermLoop; } - static inline bool BreakOnUnhandledMemory(void) { return m_BreakOnUnhandledMemory; } - static inline bool BreakOnAddressError(void) { return m_BreakOnAddressError; } - static inline bool StepOnBreakOpCode(void) { return m_StepOnBreakOpCode; } + static inline bool HaveDebugger(void) + { + return m_HaveDebugger; + } + static inline bool isDebugging(void) + { + return m_Debugging; + } + static inline bool isStepping(void) + { + return m_Stepping; + } + static inline bool SkipOp(void) + { + return m_SkipOp; + } + static inline bool WaitingForStep(void) + { + return m_WaitingForStep; + } + static inline bool bRecordRecompilerAsm(void) + { + return m_bRecordRecompilerAsm; + } + static inline bool bShowTLBMisses(void) + { + return m_bShowTLBMisses; + } + static inline bool bRecordExecutionTimes(void) + { + return m_RecordExecutionTimes; + } + static inline bool HaveExecutionBP(void) + { + return m_HaveExecutionBP; + } + static inline bool HaveWriteBP(void) + { + return m_HaveWriteBP; + } + static inline bool HaveReadBP(void) + { + return m_HaveReadBP; + } + static inline bool bShowPifRamErrors(void) + { + return m_bShowPifRamErrors; + } + static inline bool bCPULoggingEnabled(void) + { + return m_bCPULoggingEnabled; + } + static inline uint32_t ExceptionBreakpoints(void) + { + return m_ExceptionBreakpoints; + } + static inline uint32_t FpExceptionBreakpoints(void) + { + return m_FpExceptionBreakpoints; + } + static inline uint32_t IntrBreakpoints(void) + { + return m_IntrBreakpoints; + } + static inline uint32_t RcpIntrBreakpoints(void) + { + return m_RcpIntrBreakpoints; + } + static inline bool EndOnPermLoop(void) + { + return m_EndOnPermLoop; + } + static inline bool BreakOnUnhandledMemory(void) + { + return m_BreakOnUnhandledMemory; + } + static inline bool BreakOnAddressError(void) + { + return m_BreakOnAddressError; + } + static inline bool StepOnBreakOpCode(void) + { + return m_StepOnBreakOpCode; + } private: static void StaticRefreshSettings(CDebugSettings * _this) diff --git a/Source/Project64-core/Settings/GameSettings.cpp b/Source/Project64-core/Settings/GameSettings.cpp index 616018e9d..fcd4fe0fe 100644 --- a/Source/Project64-core/Settings/GameSettings.cpp +++ b/Source/Project64-core/Settings/GameSettings.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" -#include + #include +#include #include bool CGameSettings::m_UseHleGfx = true; @@ -89,10 +90,16 @@ void CGameSettings::RefreshGameSettings() { m_CountPerOp = 2; } - if (m_OverClockModifier < 1) { m_OverClockModifier = 1; } - if (m_OverClockModifier > 20) { m_OverClockModifier = 20; } + if (m_OverClockModifier < 1) + { + m_OverClockModifier = 1; + } + if (m_OverClockModifier > 20) + { + m_OverClockModifier = 20; + } m_DiskSeekTimingType = (DISK_SEEK_TYPE)g_Settings->LoadDword(Game_DiskSeekTiming); - RefreshSyncToAudio(); + RefreshSyncToAudio(); WriteTrace(TraceN64System, TraceDebug, "Done"); } @@ -104,7 +111,7 @@ void CGameSettings::SpeedChanged(int SpeedLimit) void CGameSettings::RefreshSyncToAudio(void) { - m_bSyncToAudio = g_Settings->LoadBool(Game_SyncViaAudio) && g_Settings->LoadBool(Setting_SyncViaAudioEnabled) && g_Settings->LoadBool(Plugin_EnableAudio); + m_bSyncToAudio = g_Settings->LoadBool(Game_SyncViaAudio) && g_Settings->LoadBool(Setting_SyncViaAudioEnabled) && g_Settings->LoadBool(Plugin_EnableAudio); } void CGameSettings::SetOverClockModifier(bool EnhancmentOverClock, uint32_t EnhancmentOverClockModifier) @@ -120,8 +127,14 @@ void CGameSettings::SetOverClockModifier(bool EnhancmentOverClock, uint32_t Enha { m_OverClockModifier = g_Settings->LoadDword(Game_OverClockModifier); } - if (m_OverClockModifier < 1) { m_OverClockModifier = 1; } - if (m_OverClockModifier > 20) { m_OverClockModifier = 20; } + if (m_OverClockModifier < 1) + { + m_OverClockModifier = 1; + } + if (m_OverClockModifier > 20) + { + m_OverClockModifier = 20; + } } void CGameSettings::EnableDiskChanged(void *) diff --git a/Source/Project64-core/Settings/GameSettings.h b/Source/Project64-core/Settings/GameSettings.h index 18ca71f54..5cf70dd87 100644 --- a/Source/Project64-core/Settings/GameSettings.h +++ b/Source/Project64-core/Settings/GameSettings.h @@ -11,35 +11,116 @@ public: void RefreshGameSettings(void); - inline static bool UseHleGfx(void) { return m_UseHleGfx; } - inline static bool bRegCaching(void) { return m_RegCaching; } - inline static bool bLinkBlocks(void) { return m_bLinkBlocks && !CDebugSettings::HaveWriteBP() && !CDebugSettings::HaveReadBP(); } - inline static FUNC_LOOKUP_METHOD LookUpMode(void) { return (FUNC_LOOKUP_METHOD)m_LookUpMode; } - inline static uint32_t CountPerOp(void) { return m_CountPerOp; } - inline static uint32_t ViRefreshRate(void) { return m_ViRefreshRate; } - inline static uint32_t AiCountPerBytes(void) { return m_AiCountPerBytes; } - inline static bool bDelayDP(void) { return m_DelayDP; } - inline static bool bDelaySI(void) { return m_DelaySI; } - inline static bool bRandomizeSIPIInterrupts(void) { return m_bRandomizeSIPIInterrupts; } - inline static uint32_t RdramSize(void) { return m_RdramSize; } - inline static bool bFixedAudio(void) { return m_bFixedAudio; } - inline static bool bSyncToAudio(void) { return m_bSyncToAudio; } - inline static bool FullSpeed(void) { return m_FullSpeed; } - inline static bool bFastSP(void) { return m_bFastSP; } - inline static bool b32BitCore(void) { return m_b32Bit; } - inline static bool RspAudioSignal(void) { return m_RspAudioSignal; } - inline static bool bSMM_StoreInstruc(void) { return m_bSMM_StoreInstruc; } - inline static bool bSMM_Protect(void) { return m_bSMM_Protect; } - inline static bool bSMM_ValidFunc(void) { return m_bSMM_ValidFunc; } - inline static bool bSMM_PIDMA(void) { return m_bSMM_PIDMA; } - inline static bool bSMM_TLB(void) { return m_bSMM_TLB; } - inline static SYSTEM_TYPE SystemType(void) { return m_SystemType; } - inline static CPU_TYPE CpuType(void) { return m_CpuType; } - inline static uint32_t OverClockModifier(void) { return m_OverClockModifier; } - inline static DISK_SEEK_TYPE DiskSeekTimingType(void) { return m_DiskSeekTimingType; }; - inline static bool EnableDisk(void) { return m_EnableDisk; } + inline static bool UseHleGfx(void) + { + return m_UseHleGfx; + } + inline static bool bRegCaching(void) + { + return m_RegCaching; + } + inline static bool bLinkBlocks(void) + { + return m_bLinkBlocks && !CDebugSettings::HaveWriteBP() && !CDebugSettings::HaveReadBP(); + } + inline static FUNC_LOOKUP_METHOD LookUpMode(void) + { + return (FUNC_LOOKUP_METHOD)m_LookUpMode; + } + inline static uint32_t CountPerOp(void) + { + return m_CountPerOp; + } + inline static uint32_t ViRefreshRate(void) + { + return m_ViRefreshRate; + } + inline static uint32_t AiCountPerBytes(void) + { + return m_AiCountPerBytes; + } + inline static bool bDelayDP(void) + { + return m_DelayDP; + } + inline static bool bDelaySI(void) + { + return m_DelaySI; + } + inline static bool bRandomizeSIPIInterrupts(void) + { + return m_bRandomizeSIPIInterrupts; + } + inline static uint32_t RdramSize(void) + { + return m_RdramSize; + } + inline static bool bFixedAudio(void) + { + return m_bFixedAudio; + } + inline static bool bSyncToAudio(void) + { + return m_bSyncToAudio; + } + inline static bool FullSpeed(void) + { + return m_FullSpeed; + } + inline static bool bFastSP(void) + { + return m_bFastSP; + } + inline static bool b32BitCore(void) + { + return m_b32Bit; + } + inline static bool RspAudioSignal(void) + { + return m_RspAudioSignal; + } + inline static bool bSMM_StoreInstruc(void) + { + return m_bSMM_StoreInstruc; + } + inline static bool bSMM_Protect(void) + { + return m_bSMM_Protect; + } + inline static bool bSMM_ValidFunc(void) + { + return m_bSMM_ValidFunc; + } + inline static bool bSMM_PIDMA(void) + { + return m_bSMM_PIDMA; + } + inline static bool bSMM_TLB(void) + { + return m_bSMM_TLB; + } + inline static SYSTEM_TYPE SystemType(void) + { + return m_SystemType; + } + inline static CPU_TYPE CpuType(void) + { + return m_CpuType; + } + inline static uint32_t OverClockModifier(void) + { + return m_OverClockModifier; + } + inline static DISK_SEEK_TYPE DiskSeekTimingType(void) + { + return m_DiskSeekTimingType; + }; + inline static bool EnableDisk(void) + { + return m_EnableDisk; + } - void RefreshSyncToAudio(void); + void RefreshSyncToAudio(void); static void SetOverClockModifier(bool EnhancmentOverClock, uint32_t EnhancmentOverClockModifier); protected: @@ -47,8 +128,8 @@ protected: static void EnableDiskChanged(void); private: - CGameSettings(const CGameSettings&); - CGameSettings& operator=(const CGameSettings&); + CGameSettings(const CGameSettings &); + CGameSettings & operator=(const CGameSettings &); static void EnableDiskChanged(void *); diff --git a/Source/Project64-core/Settings/LoggingSettings.cpp b/Source/Project64-core/Settings/LoggingSettings.cpp index 939fc72d2..208552988 100644 --- a/Source/Project64-core/Settings/LoggingSettings.cpp +++ b/Source/Project64-core/Settings/LoggingSettings.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" + #include "LoggingSettings.h" -int CLogSettings::m_RefCount = 0; +int CLogSettings::m_RefCount = 0; bool CLogSettings::m_GenerateLog = 0; bool CLogSettings::m_LogRDRamRegisters = 0; bool CLogSettings::m_LogSPRegisters = 0; @@ -30,96 +31,96 @@ bool CLogSettings::m_LogUnknown = 0; CLogSettings::CLogSettings() { - m_RefCount += 1; - if (m_RefCount == 1) - { - g_Settings->RegisterChangeCB(Logging_GenerateLog, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogRDRamRegisters, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogSPRegisters, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogDPCRegisters, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogDPSRegisters, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogMIPSInterface, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogVideoInterface, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogAudioInterface, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogPerInterface, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogRDRAMInterface, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogSerialInterface, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogPRDMAOperations, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogPRDirectMemLoads, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogPRDMAMemLoads, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogPRDirectMemStores, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogPRDMAMemStores, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogControllerPak, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogCP0changes, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogCP0reads, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogTLB, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogExceptions, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_NoInterrupts, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogCache, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogRomHeader, nullptr, RefreshSettings); - g_Settings->RegisterChangeCB(Logging_LogUnknown, nullptr, RefreshSettings); - RefreshSettings(nullptr); - } + m_RefCount += 1; + if (m_RefCount == 1) + { + g_Settings->RegisterChangeCB(Logging_GenerateLog, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogRDRamRegisters, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogSPRegisters, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogDPCRegisters, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogDPSRegisters, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogMIPSInterface, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogVideoInterface, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogAudioInterface, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPerInterface, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogRDRAMInterface, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogSerialInterface, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDMAOperations, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDirectMemLoads, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDMAMemLoads, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDirectMemStores, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDMAMemStores, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogControllerPak, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogCP0changes, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogCP0reads, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogTLB, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogExceptions, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_NoInterrupts, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogCache, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogRomHeader, nullptr, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogUnknown, nullptr, RefreshSettings); + RefreshSettings(nullptr); + } } CLogSettings::~CLogSettings() { - m_RefCount -= 1; - if (m_RefCount == 0) - { - g_Settings->UnregisterChangeCB(Logging_GenerateLog, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogRDRamRegisters, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogSPRegisters, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogDPCRegisters, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogDPSRegisters, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogMIPSInterface, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogVideoInterface, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogAudioInterface, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogPerInterface, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogRDRAMInterface, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogSerialInterface, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogPRDMAOperations, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemLoads, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemLoads, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemStores, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemStores, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogControllerPak, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogCP0changes, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogCP0reads, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogTLB, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogExceptions, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_NoInterrupts, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogCache, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogRomHeader, nullptr, RefreshSettings); - g_Settings->UnregisterChangeCB(Logging_LogUnknown, nullptr, RefreshSettings); - } + m_RefCount -= 1; + if (m_RefCount == 0) + { + g_Settings->UnregisterChangeCB(Logging_GenerateLog, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogRDRamRegisters, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogSPRegisters, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogDPCRegisters, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogDPSRegisters, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogMIPSInterface, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogVideoInterface, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogAudioInterface, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPerInterface, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogRDRAMInterface, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogSerialInterface, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDMAOperations, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemLoads, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemLoads, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemStores, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemStores, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogControllerPak, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogCP0changes, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogCP0reads, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogTLB, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogExceptions, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_NoInterrupts, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogCache, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogRomHeader, nullptr, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogUnknown, nullptr, RefreshSettings); + } } void CLogSettings::RefreshSettings(void *) { - m_GenerateLog = g_Settings->LoadBool(Logging_GenerateLog); - m_LogRDRamRegisters = g_Settings->LoadBool(Logging_LogRDRamRegisters); - m_LogSPRegisters = g_Settings->LoadBool(Logging_LogSPRegisters); - m_LogDPCRegisters = g_Settings->LoadBool(Logging_LogDPCRegisters); - m_LogDPSRegisters = g_Settings->LoadBool(Logging_LogDPSRegisters); - m_LogMIPSInterface = g_Settings->LoadBool(Logging_LogMIPSInterface); - m_LogVideoInterface = g_Settings->LoadBool(Logging_LogVideoInterface); - m_LogAudioInterface = g_Settings->LoadBool(Logging_LogAudioInterface); - m_LogPerInterface = g_Settings->LoadBool(Logging_LogPerInterface); - m_LogRDRAMInterface = g_Settings->LoadBool(Logging_LogRDRAMInterface); - m_LogSerialInterface = g_Settings->LoadBool(Logging_LogSerialInterface); - m_LogPRDMAOperations = g_Settings->LoadBool(Logging_LogPRDMAOperations); - m_LogPRDirectMemLoads = g_Settings->LoadBool(Logging_LogPRDirectMemLoads); - m_LogPRDMAMemLoads = g_Settings->LoadBool(Logging_LogPRDMAMemLoads); - m_LogPRDirectMemStores = g_Settings->LoadBool(Logging_LogPRDirectMemStores); - m_LogPRDMAMemStores = g_Settings->LoadBool(Logging_LogPRDMAMemStores); - m_LogControllerPak = g_Settings->LoadBool(Logging_LogControllerPak); - m_LogCP0changes = g_Settings->LoadBool(Logging_LogCP0changes); - m_LogCP0reads = g_Settings->LoadBool(Logging_LogCP0reads); - m_LogTLB = g_Settings->LoadBool(Logging_LogTLB); - m_LogExceptions = g_Settings->LoadBool(Logging_LogExceptions); - m_NoInterrupts = g_Settings->LoadBool(Logging_NoInterrupts); - m_LogCache = g_Settings->LoadBool(Logging_LogCache); - m_LogRomHeader = g_Settings->LoadBool(Logging_LogRomHeader); - m_LogUnknown = g_Settings->LoadBool(Logging_LogUnknown); + m_GenerateLog = g_Settings->LoadBool(Logging_GenerateLog); + m_LogRDRamRegisters = g_Settings->LoadBool(Logging_LogRDRamRegisters); + m_LogSPRegisters = g_Settings->LoadBool(Logging_LogSPRegisters); + m_LogDPCRegisters = g_Settings->LoadBool(Logging_LogDPCRegisters); + m_LogDPSRegisters = g_Settings->LoadBool(Logging_LogDPSRegisters); + m_LogMIPSInterface = g_Settings->LoadBool(Logging_LogMIPSInterface); + m_LogVideoInterface = g_Settings->LoadBool(Logging_LogVideoInterface); + m_LogAudioInterface = g_Settings->LoadBool(Logging_LogAudioInterface); + m_LogPerInterface = g_Settings->LoadBool(Logging_LogPerInterface); + m_LogRDRAMInterface = g_Settings->LoadBool(Logging_LogRDRAMInterface); + m_LogSerialInterface = g_Settings->LoadBool(Logging_LogSerialInterface); + m_LogPRDMAOperations = g_Settings->LoadBool(Logging_LogPRDMAOperations); + m_LogPRDirectMemLoads = g_Settings->LoadBool(Logging_LogPRDirectMemLoads); + m_LogPRDMAMemLoads = g_Settings->LoadBool(Logging_LogPRDMAMemLoads); + m_LogPRDirectMemStores = g_Settings->LoadBool(Logging_LogPRDirectMemStores); + m_LogPRDMAMemStores = g_Settings->LoadBool(Logging_LogPRDMAMemStores); + m_LogControllerPak = g_Settings->LoadBool(Logging_LogControllerPak); + m_LogCP0changes = g_Settings->LoadBool(Logging_LogCP0changes); + m_LogCP0reads = g_Settings->LoadBool(Logging_LogCP0reads); + m_LogTLB = g_Settings->LoadBool(Logging_LogTLB); + m_LogExceptions = g_Settings->LoadBool(Logging_LogExceptions); + m_NoInterrupts = g_Settings->LoadBool(Logging_NoInterrupts); + m_LogCache = g_Settings->LoadBool(Logging_LogCache); + m_LogRomHeader = g_Settings->LoadBool(Logging_LogRomHeader); + m_LogUnknown = g_Settings->LoadBool(Logging_LogUnknown); } \ No newline at end of file diff --git a/Source/Project64-core/Settings/LoggingSettings.h b/Source/Project64-core/Settings/LoggingSettings.h index e4a739e3e..ca614d492 100644 --- a/Source/Project64-core/Settings/LoggingSettings.h +++ b/Source/Project64-core/Settings/LoggingSettings.h @@ -6,40 +6,115 @@ public: CLogSettings(); virtual ~CLogSettings(); - inline static bool GenerateLog ( void ) { return m_GenerateLog; } + inline static bool GenerateLog(void) + { + return m_GenerateLog; + } // Registers log - inline static bool LogRDRamRegisters ( void ) { return m_LogRDRamRegisters; } - inline static bool LogSPRegisters ( void ) { return m_LogSPRegisters; } - inline static bool LogDPCRegisters ( void ) { return m_LogDPCRegisters; } - inline static bool LogDPSRegisters ( void ) { return m_LogDPSRegisters; } - inline static bool LogMIPSInterface ( void ) { return m_LogMIPSInterface; } - inline static bool LogVideoInterface ( void ) { return m_LogVideoInterface; } - inline static bool LogAudioInterface ( void ) { return m_LogAudioInterface; } - inline static bool LogPerInterface ( void ) { return m_LogPerInterface; } - inline static bool LogRDRAMInterface ( void ) { return m_LogRDRAMInterface; } - inline static bool LogSerialInterface ( void ) { return m_LogSerialInterface; } + inline static bool LogRDRamRegisters(void) + { + return m_LogRDRamRegisters; + } + inline static bool LogSPRegisters(void) + { + return m_LogSPRegisters; + } + inline static bool LogDPCRegisters(void) + { + return m_LogDPCRegisters; + } + inline static bool LogDPSRegisters(void) + { + return m_LogDPSRegisters; + } + inline static bool LogMIPSInterface(void) + { + return m_LogMIPSInterface; + } + inline static bool LogVideoInterface(void) + { + return m_LogVideoInterface; + } + inline static bool LogAudioInterface(void) + { + return m_LogAudioInterface; + } + inline static bool LogPerInterface(void) + { + return m_LogPerInterface; + } + inline static bool LogRDRAMInterface(void) + { + return m_LogRDRAMInterface; + } + inline static bool LogSerialInterface(void) + { + return m_LogSerialInterface; + } // PIF RAM log - inline static bool LogPRDMAOperations ( void ) { return m_LogPRDMAOperations; } - inline static bool LogPRDirectMemLoads ( void ) { return m_LogPRDirectMemLoads; } - inline static bool LogPRDMAMemLoads ( void ) { return m_LogPRDMAMemLoads; } - inline static bool LogPRDirectMemStores ( void ) { return m_LogPRDirectMemStores; } - inline static bool LogPRDMAMemStores ( void ) { return m_LogPRDMAMemStores; } - inline static bool LogControllerPak ( void ) { return m_LogControllerPak; } + inline static bool LogPRDMAOperations(void) + { + return m_LogPRDMAOperations; + } + inline static bool LogPRDirectMemLoads(void) + { + return m_LogPRDirectMemLoads; + } + inline static bool LogPRDMAMemLoads(void) + { + return m_LogPRDMAMemLoads; + } + inline static bool LogPRDirectMemStores(void) + { + return m_LogPRDirectMemStores; + } + inline static bool LogPRDMAMemStores(void) + { + return m_LogPRDMAMemStores; + } + inline static bool LogControllerPak(void) + { + return m_LogControllerPak; + } // Special log - inline static bool LogCP0changes ( void ) { return m_LogCP0changes; } - inline static bool LogCP0reads ( void ) { return m_LogCP0reads; } - inline static bool LogTLB ( void ) { return m_LogTLB; } - inline static bool LogExceptions ( void ) { return m_LogExceptions; } - inline static bool LogNoInterrupts ( void ) { return m_NoInterrupts; } - inline static bool LogCache ( void ) { return m_LogCache; } - inline static bool LogRomHeader ( void ) { return m_LogRomHeader; } - inline static bool LogUnknown ( void ) { return m_LogUnknown; } + inline static bool LogCP0changes(void) + { + return m_LogCP0changes; + } + inline static bool LogCP0reads(void) + { + return m_LogCP0reads; + } + inline static bool LogTLB(void) + { + return m_LogTLB; + } + inline static bool LogExceptions(void) + { + return m_LogExceptions; + } + inline static bool LogNoInterrupts(void) + { + return m_NoInterrupts; + } + inline static bool LogCache(void) + { + return m_LogCache; + } + inline static bool LogRomHeader(void) + { + return m_LogRomHeader; + } + inline static bool LogUnknown(void) + { + return m_LogUnknown; + } private: - static void RefreshSettings ( void * ); + static void RefreshSettings(void *); static bool m_GenerateLog; diff --git a/Source/Project64-core/Settings/N64SystemSettings.cpp b/Source/Project64-core/Settings/N64SystemSettings.cpp index 39904d694..c33ac3b18 100644 --- a/Source/Project64-core/Settings/N64SystemSettings.cpp +++ b/Source/Project64-core/Settings/N64SystemSettings.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "N64SystemSettings.h" #include diff --git a/Source/Project64-core/Settings/N64SystemSettings.h b/Source/Project64-core/Settings/N64SystemSettings.h index 02bf1ee3d..947a0aa76 100644 --- a/Source/Project64-core/Settings/N64SystemSettings.h +++ b/Source/Project64-core/Settings/N64SystemSettings.h @@ -6,12 +6,30 @@ protected: CN64SystemSettings(); virtual ~CN64SystemSettings(); - inline static bool bBasicMode(void) { return m_bBasicMode; } - inline static bool bDisplayFrameRate(void) { return m_bDisplayFrameRate; } - inline static bool bShowCPUPer(void) { return m_bShowCPUPer; } - inline static bool bShowDListAListCount(void) { return m_bShowDListAListCount; } - inline static bool bLimitFPS(void) { return m_bLimitFPS; } - inline static bool UpdateControllerOnRefresh(void) { return m_UpdateControllerOnRefresh; } + inline static bool bBasicMode(void) + { + return m_bBasicMode; + } + inline static bool bDisplayFrameRate(void) + { + return m_bDisplayFrameRate; + } + inline static bool bShowCPUPer(void) + { + return m_bShowCPUPer; + } + inline static bool bShowDListAListCount(void) + { + return m_bShowDListAListCount; + } + inline static bool bLimitFPS(void) + { + return m_bLimitFPS; + } + inline static bool UpdateControllerOnRefresh(void) + { + return m_UpdateControllerOnRefresh; + } private: static void RefreshSettings(void *); diff --git a/Source/Project64-core/Settings/RecompilerSettings.cpp b/Source/Project64-core/Settings/RecompilerSettings.cpp index 3db95507c..a02134a0d 100644 --- a/Source/Project64-core/Settings/RecompilerSettings.cpp +++ b/Source/Project64-core/Settings/RecompilerSettings.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "RecompilerSettings.h" int CRecompilerSettings::m_RefCount = 0; diff --git a/Source/Project64-core/Settings/RecompilerSettings.h b/Source/Project64-core/Settings/RecompilerSettings.h index 5d2a124da..34c1d2bb0 100644 --- a/Source/Project64-core/Settings/RecompilerSettings.h +++ b/Source/Project64-core/Settings/RecompilerSettings.h @@ -8,7 +8,10 @@ public: CRecompilerSettings(); virtual ~CRecompilerSettings(); - static inline bool bShowRecompMemSize(void) { return m_bShowRecompMemSize; } + static inline bool bShowRecompMemSize(void) + { + return m_bShowRecompMemSize; + } private: static void StaticRefreshSettings(CRecompilerSettings * _this) diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp index ed31c33b7..aa93b1850 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-Application.h" #include @@ -164,7 +165,7 @@ bool CSettingTypeApplication::Load(uint32_t /*Index*/, uint32_t & Value) const bool bRes = m_SettingsIniFile->GetNumber(SectionName(), m_KeyNameIdex.c_str(), Value, Value); if (!bRes && m_DefaultSetting != Default_None) { - Value = m_DefaultSetting == Default_Constant ? m_DefaultValue: g_Settings->LoadDword(m_DefaultSetting); + Value = m_DefaultSetting == Default_Constant ? m_DefaultValue : g_Settings->LoadDword(m_DefaultSetting); } return bRes; } @@ -227,7 +228,7 @@ void CSettingTypeApplication::Save(uint32_t Index, bool Value) if (m_DefaultSetting != Default_None && ((m_DefaultSetting == Default_Constant && m_DefaultValue == (uint32_t)Value) || - (m_DefaultSetting != Default_Constant && (indexed ? g_Settings->LoadBoolIndex(m_DefaultSetting, Index) : g_Settings->LoadBool(m_DefaultSetting)) == Value))) + (m_DefaultSetting != Default_Constant && (indexed ? g_Settings->LoadBoolIndex(m_DefaultSetting, Index) : g_Settings->LoadBool(m_DefaultSetting)) == Value))) { m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), nullptr); } @@ -241,7 +242,7 @@ void CSettingTypeApplication::Save(uint32_t /*Index*/, uint32_t Value) { if (m_DefaultSetting != Default_None && ((m_DefaultSetting == Default_Constant && m_DefaultValue == Value) || - (m_DefaultSetting != Default_Constant && g_Settings->LoadDword(m_DefaultSetting) == Value))) + (m_DefaultSetting != Default_Constant && g_Settings->LoadDword(m_DefaultSetting) == Value))) { m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), nullptr); } @@ -259,8 +260,8 @@ void CSettingTypeApplication::Save(uint32_t Index, const std::string & Value) void CSettingTypeApplication::Save(uint32_t /*Index*/, const char * Value) { if (m_DefaultSetting != Default_None && Value != nullptr && - ((m_DefaultSetting == Default_Constant && strcmp(m_DefaultStr,Value) == 0) || - (m_DefaultSetting != Default_Constant && strcmp(g_Settings->LoadStringVal(m_DefaultSetting).c_str(),Value) == 0))) + ((m_DefaultSetting == Default_Constant && strcmp(m_DefaultStr, Value) == 0) || + (m_DefaultSetting != Default_Constant && strcmp(g_Settings->LoadStringVal(m_DefaultSetting).c_str(), Value) == 0))) { m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), nullptr); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h index bc8061190..f669fe8b1 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Application.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Application.h @@ -13,8 +13,14 @@ public: CSettingTypeApplication(const char * Section, const char * Name, SettingID DefaultSetting); virtual ~CSettingTypeApplication(); - virtual bool IndexBasedSetting(void) const { return false; } - virtual SettingType GetSettingType(void) const { return SettingType_CfgFile; } + virtual bool IndexBasedSetting(void) const + { + return false; + } + virtual SettingType GetSettingType(void) const + { + return SettingType_CfgFile; + } virtual bool IsSettingSet(void) const; // Return the values @@ -42,7 +48,10 @@ public: static void Flush(void); static void ResetAll(void); - const char * GetKeyName(void) const { return m_KeyName.c_str(); } + const char * GetKeyName(void) const + { + return m_KeyName.c_str(); + } protected: const char * m_DefaultStr; @@ -59,6 +68,6 @@ protected: virtual const char * SectionName(void) const; private: - CSettingTypeApplication(const CSettingTypeApplication&); - CSettingTypeApplication& operator=(const CSettingTypeApplication&); + CSettingTypeApplication(const CSettingTypeApplication &); + CSettingTypeApplication & operator=(const CSettingTypeApplication &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp index 411e6a353..9c8b99849 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-Application.h" #include "SettingsType-ApplicationIndex.h" diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h index c0b828e7b..272a80f6d 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationIndex.h @@ -10,7 +10,10 @@ public: CSettingTypeApplicationIndex(const char * Section, const char * Name, SettingID DefaultSetting); ~CSettingTypeApplicationIndex(); - virtual bool IndexBasedSetting(void) const { return true; } + virtual bool IndexBasedSetting(void) const + { + return true; + } // Return the values virtual bool Load(uint32_t Index, bool & Value) const; @@ -33,6 +36,6 @@ public: private: CSettingTypeApplicationIndex(void); - CSettingTypeApplicationIndex(const CSettingTypeApplicationIndex&); - CSettingTypeApplicationIndex& operator=(const CSettingTypeApplicationIndex&); + CSettingTypeApplicationIndex(const CSettingTypeApplicationIndex &); + CSettingTypeApplicationIndex & operator=(const CSettingTypeApplicationIndex &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp index 83d47ae3a..20fb4bd7c 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.cpp @@ -1,10 +1,11 @@ #include "stdafx.h" + #include "SettingsType-Application.h" #include "SettingsType-ApplicationPath.h" #include CSettingTypeApplicationPath::CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting) : -CSettingTypeApplication(Section, Name, DefaultSetting) + CSettingTypeApplication(Section, Name, DefaultSetting) { } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h index 72b8e59fd..e029c5d7b 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-ApplicationPath.h @@ -6,18 +6,18 @@ class CSettingTypeApplicationPath : public: virtual ~CSettingTypeApplicationPath(); - CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting ); + CSettingTypeApplicationPath(const char * Section, const char * Name, SettingID DefaultSetting); bool IsSettingSet(void) const; // Return the values - virtual bool Load ( int32_t Index, stdstr & Value ) const; + virtual bool Load(int32_t Index, stdstr & Value) const; private: CSettingTypeApplicationPath(void); - CSettingTypeApplicationPath(const CSettingTypeApplicationPath&); - CSettingTypeApplicationPath& operator=(const CSettingTypeApplicationPath&); + CSettingTypeApplicationPath(const CSettingTypeApplicationPath &); + CSettingTypeApplicationPath & operator=(const CSettingTypeApplicationPath &); - CSettingTypeApplicationPath(const char * Section, const char * Name, const char * DefaultValue ); - CSettingTypeApplicationPath(const char * Section, const char * Name, bool DefaultValue ); - CSettingTypeApplicationPath(const char * Section, const char * Name, uint32_t DefaultValue ); + CSettingTypeApplicationPath(const char * Section, const char * Name, const char * DefaultValue); + CSettingTypeApplicationPath(const char * Section, const char * Name, bool DefaultValue); + CSettingTypeApplicationPath(const char * Section, const char * Name, uint32_t DefaultValue); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-Base.h b/Source/Project64-core/Settings/SettingType/SettingsType-Base.h index 71cd26d84..591b2b4a1 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-Base.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-Base.h @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include enum SettingType @@ -20,14 +20,14 @@ enum SettingType SettingType_NumberVariable = 10, SettingType_StringVariable = 11, SettingType_SelectedDirectory = 12, - SettingType_RdbSetting = 13, - SettingType_Enhancement = 14, + SettingType_RdbSetting = 13, + SettingType_Enhancement = 14, }; class CSettingType { public: - virtual ~CSettingType() {}; + virtual ~CSettingType(){}; virtual SettingType GetSettingType(void) const = 0; virtual bool IndexBasedSetting(void) const = 0; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp index efe46a83b..ebabfaf00 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-Application.h" #include "SettingsType-GameSetting.h" diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h index 95abb63b4..764bcf2d5 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSetting.h @@ -11,30 +11,36 @@ public: CSettingTypeGame(const char * Name, SettingID DefaultSetting); virtual ~CSettingTypeGame(); - virtual bool IndexBasedSetting ( void ) const { return false; } - virtual SettingType GetSettingType ( void ) const { return SettingType_GameSetting; } + virtual bool IndexBasedSetting(void) const + { + return false; + } + virtual SettingType GetSettingType(void) const + { + return SettingType_GameSetting; + } - static void Initialize( void ); - static void CleanUp ( void ); + static void Initialize(void); + static void CleanUp(void); // Return the values - virtual bool Load (uint32_t Index, bool & Value) const; - virtual bool Load (uint32_t Index, uint32_t & Value) const; - virtual bool Load (uint32_t Index, std::string & Value) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; // Return the default values - virtual void LoadDefault (uint32_t Index, bool & Value) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; - virtual void LoadDefault (uint32_t Index, std::string & Value) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - virtual void Save (uint32_t Index, bool Value); - virtual void Save (uint32_t Index, uint32_t Value); - virtual void Save (uint32_t Index, const std::string & Value); - virtual void Save (uint32_t Index, const char * Value); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index); + virtual void Delete(uint32_t Index); protected: static bool m_RdbEditor; @@ -47,6 +53,6 @@ protected: private: CSettingTypeGame(void); - CSettingTypeGame(const CSettingTypeGame&); - CSettingTypeGame& operator=(const CSettingTypeGame&); + CSettingTypeGame(const CSettingTypeGame &); + CSettingTypeGame & operator=(const CSettingTypeGame &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp index 258e28089..4472b4a31 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.cpp @@ -1,16 +1,17 @@ #include "stdafx.h" + #include "SettingsType-Application.h" #include "SettingsType-GameSetting.h" #include "SettingsType-GameSettingIndex.h" -CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting ) : +CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting) : CSettingTypeGame("", DefaultSetting), m_PreIndex(PreIndex), m_PostIndex(PostIndex) { } -CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue ) : +CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue) : CSettingTypeGame("", DefaultValue), m_PreIndex(PreIndex), m_PostIndex(PostIndex) @@ -24,7 +25,7 @@ CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * { } -CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue ) : +CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue) : CSettingTypeGame("", DefaultValue), m_PreIndex(PreIndex), m_PostIndex(PostIndex) @@ -35,67 +36,67 @@ CSettingTypeGameIndex::~CSettingTypeGameIndex() { } -bool CSettingTypeGameIndex::Load (uint32_t Index, bool & Value ) const +bool CSettingTypeGameIndex::Load(uint32_t Index, bool & Value) const { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - return CSettingTypeGame::Load(Index,Value); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + return CSettingTypeGame::Load(Index, Value); } -bool CSettingTypeGameIndex::Load (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +bool CSettingTypeGameIndex::Load(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeGameIndex::Load (uint32_t Index, std::string & Value ) const +bool CSettingTypeGameIndex::Load(uint32_t Index, std::string & Value) const { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - return CSettingTypeGame::Load(0,Value); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + return CSettingTypeGame::Load(0, Value); } // Return the default values -void CSettingTypeGameIndex::LoadDefault (uint32_t Index, bool & Value ) const +void CSettingTypeGameIndex::LoadDefault(uint32_t Index, bool & Value) const { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeGame::LoadDefault(0,Value); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeGame::LoadDefault(0, Value); } -void CSettingTypeGameIndex::LoadDefault (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +void CSettingTypeGameIndex::LoadDefault(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeGameIndex::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeGameIndex::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } // Update the settings -void CSettingTypeGameIndex::Save (uint32_t Index, bool Value ) +void CSettingTypeGameIndex::Save(uint32_t Index, bool Value) { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeGame::Save(Index,Value); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeGame::Save(Index, Value); } void CSettingTypeGameIndex::Save(uint32_t Index, uint32_t Value) { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeGame::Save(0,Value); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeGame::Save(0, Value); } -void CSettingTypeGameIndex::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeGameIndex::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeGameIndex::Save (uint32_t Index, const char * Value ) +void CSettingTypeGameIndex::Save(uint32_t Index, const char * Value) { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeGame::Save(0,Value); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeGame::Save(0, Value); } -void CSettingTypeGameIndex::Delete (uint32_t Index ) +void CSettingTypeGameIndex::Delete(uint32_t Index) { - m_KeyNameIdex = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); + m_KeyNameIdex = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); CSettingTypeGame::Delete(0); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h index f2c6cf956..d413edc1f 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-GameSettingIndex.h @@ -4,38 +4,44 @@ class CSettingTypeGameIndex : public CSettingTypeGame { public: - CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue ); - CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue ); + CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue); + CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue); CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, bool DefaultSetting); CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting); ~CSettingTypeGameIndex(); - virtual bool IndexBasedSetting ( void ) const { return true; } - virtual SettingType GetSettingType ( void ) const { return SettingType_GameSetting; } + virtual bool IndexBasedSetting(void) const + { + return true; + } + virtual SettingType GetSettingType(void) const + { + return SettingType_GameSetting; + } // Return the values - virtual bool Load ( uint32_t Index, bool & Value ) const; - virtual bool Load ( uint32_t Index, uint32_t & Value ) const; - virtual bool Load ( uint32_t Index, std::string & Value ) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; // Return the default values - virtual void LoadDefault (uint32_t Index, bool & Value ) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; - virtual void LoadDefault (uint32_t Index, std::string & Value ) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - virtual void Save (uint32_t Index, bool Value ); - virtual void Save (uint32_t Index, uint32_t Value ); - virtual void Save (uint32_t Index, const std::string & Value ); - virtual void Save (uint32_t Index, const char * Value ); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index ); + virtual void Delete(uint32_t Index); private: CSettingTypeGameIndex(void); - CSettingTypeGameIndex(const CSettingTypeGameIndex&); - CSettingTypeGameIndex& operator=(const CSettingTypeGameIndex&); + CSettingTypeGameIndex(const CSettingTypeGameIndex &); + CSettingTypeGameIndex & operator=(const CSettingTypeGameIndex &); std::string m_PreIndex, m_PostIndex; }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp index 90b6be924..a22d3979d 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBCpuType.cpp @@ -1,15 +1,16 @@ #include "stdafx.h" -#include "SettingsType-RomDatabase.h" + #include "SettingsType-RDBCpuType.h" +#include "SettingsType-RomDatabase.h" #include -CSettingTypeRDBCpuType::CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting ) : - CSettingTypeRomDatabase(Name,DefaultSetting) +CSettingTypeRDBCpuType::CSettingTypeRDBCpuType(const char * Name, SettingID DefaultSetting) : + CSettingTypeRomDatabase(Name, DefaultSetting) { } -CSettingTypeRDBCpuType::CSettingTypeRDBCpuType(const char * Name, uint32_t DefaultValue ) : - CSettingTypeRomDatabase(Name,DefaultValue) +CSettingTypeRDBCpuType::CSettingTypeRDBCpuType(const char * Name, uint32_t DefaultValue) : + CSettingTypeRomDatabase(Name, DefaultValue) { } @@ -17,97 +18,111 @@ CSettingTypeRDBCpuType::~CSettingTypeRDBCpuType() { } -bool CSettingTypeRDBCpuType::Load (uint32_t /*Index*/, bool & /*Value*/ ) const +bool CSettingTypeRDBCpuType::Load(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeRDBCpuType::Load (uint32_t Index, uint32_t & Value ) const +bool CSettingTypeRDBCpuType::Load(uint32_t Index, uint32_t & Value) const { stdstr strValue; - bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); + bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(), m_KeyName.c_str(), m_DefaultStr, strValue); if (!bRes) { - LoadDefault(Index,Value); + LoadDefault(Index, Value); return false; } const char * String = strValue.c_str(); - if (_stricmp(String,"Interpreter") == 0) { Value = CPU_Interpreter; } - else if (_stricmp(String,"Recompiler") == 0) { Value = CPU_Recompiler; } - else if (_stricmp(String,"SyncCores") == 0) { Value = CPU_SyncCores; } - else if (_stricmp(String,"Default") == 0) + if (_stricmp(String, "Interpreter") == 0) { - LoadDefault(Index,Value); + Value = CPU_Interpreter; + } + else if (_stricmp(String, "Recompiler") == 0) + { + Value = CPU_Recompiler; + } + else if (_stricmp(String, "SyncCores") == 0) + { + Value = CPU_SyncCores; + } + else if (_stricmp(String, "Default") == 0) + { + LoadDefault(Index, Value); return false; } - else { g_Notify->BreakPoint(__FILE__, __LINE__); } + else + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } return true; } -bool CSettingTypeRDBCpuType::Load (uint32_t /*Index*/, std::string & /*Value*/ ) const +bool CSettingTypeRDBCpuType::Load(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } // Return the default values -void CSettingTypeRDBCpuType::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const +void CSettingTypeRDBCpuType::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBCpuType::LoadDefault (uint32_t /*Index*/, uint32_t & Value ) const +void CSettingTypeRDBCpuType::LoadDefault(uint32_t /*Index*/, uint32_t & Value) const { if (m_DefaultSetting != Default_None) { if (m_DefaultSetting == Default_Constant) { Value = m_DefaultValue; - } else { - g_Settings->LoadDword(m_DefaultSetting,Value); + } + else + { + g_Settings->LoadDword(m_DefaultSetting, Value); } } } -void CSettingTypeRDBCpuType::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeRDBCpuType::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } // Update the settings -void CSettingTypeRDBCpuType::Save (uint32_t /*Index*/, bool /*Value*/ ) +void CSettingTypeRDBCpuType::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBCpuType::Save (uint32_t /*Index*/, uint32_t Value ) +void CSettingTypeRDBCpuType::Save(uint32_t /*Index*/, uint32_t Value) { stdstr strValue; switch (Value) { case CPU_Interpreter: strValue = "Interpreter"; break; - case CPU_Recompiler: strValue = "Recompiler"; break; - case CPU_SyncCores: strValue = "SyncCores"; break; + case CPU_Recompiler: strValue = "Recompiler"; break; + case CPU_SyncCores: strValue = "SyncCores"; break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),strValue.c_str()); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), strValue.c_str()); } -void CSettingTypeRDBCpuType::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeRDBCpuType::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBCpuType::Save (uint32_t /*Index*/, const char * /*Value*/ ) +void CSettingTypeRDBCpuType::Save(uint32_t /*Index*/, const char * /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBCpuType::Delete(uint32_t /*Index*/ ) +void CSettingTypeRDBCpuType::Delete(uint32_t /*Index*/) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),nullptr); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), nullptr); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp index 1e92a6bc1..78a157251 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.cpp @@ -1,14 +1,15 @@ #include "stdafx.h" -#include "SettingsType-RomDatabase.h" -#include "SettingsType-RDBOnOff.h" -CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting ) : - CSettingTypeRomDatabase(Name,DefaultSetting) +#include "SettingsType-RDBOnOff.h" +#include "SettingsType-RomDatabase.h" + +CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, SettingID DefaultSetting) : + CSettingTypeRomDatabase(Name, DefaultSetting) { } -CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, uint32_t DefaultValue ) : - CSettingTypeRomDatabase(Name,DefaultValue) +CSettingTypeRDBOnOff::CSettingTypeRDBOnOff(const char * Name, uint32_t DefaultValue) : + CSettingTypeRomDatabase(Name, DefaultValue) { } @@ -16,87 +17,98 @@ CSettingTypeRDBOnOff::~CSettingTypeRDBOnOff() { } -bool CSettingTypeRDBOnOff::Load (uint32_t Index, bool & Value ) const +bool CSettingTypeRDBOnOff::Load(uint32_t Index, bool & Value) const { stdstr strValue; - bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); + bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(), m_KeyName.c_str(), m_DefaultStr, strValue); if (!bRes) { - LoadDefault(Index,Value); + LoadDefault(Index, Value); return false; } const char * String = strValue.c_str(); - if (_stricmp(String,"On") == 0) { Value = true; } - else if (_stricmp(String,"Off") == 0) { Value = false; } - else if (_stricmp(String,"Global") == 0 || _stricmp(String,"default")) + if (_stricmp(String, "On") == 0) { - LoadDefault(Index,Value); + Value = true; + } + else if (_stricmp(String, "Off") == 0) + { + Value = false; + } + else if (_stricmp(String, "Global") == 0 || _stricmp(String, "default")) + { + LoadDefault(Index, Value); return false; } - else { g_Notify->BreakPoint(__FILE__, __LINE__); } + else + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } return true; } -bool CSettingTypeRDBOnOff::Load (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +bool CSettingTypeRDBOnOff::Load(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeRDBOnOff::Load (uint32_t /*Index*/, std::string & /*Value*/ ) const +bool CSettingTypeRDBOnOff::Load(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } // Return the default values -void CSettingTypeRDBOnOff::LoadDefault (uint32_t /*Index*/, bool & Value ) const +void CSettingTypeRDBOnOff::LoadDefault(uint32_t /*Index*/, bool & Value) const { if (m_DefaultSetting != Default_None) { if (m_DefaultSetting == Default_Constant) { Value = m_DefaultValue != 0; - } else { - g_Settings->LoadBool(m_DefaultSetting,Value); + } + else + { + g_Settings->LoadBool(m_DefaultSetting, Value); } } } -void CSettingTypeRDBOnOff::LoadDefault (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +void CSettingTypeRDBOnOff::LoadDefault(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBOnOff::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeRDBOnOff::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } // Update the settings -void CSettingTypeRDBOnOff::Save (uint32_t /*Index*/, bool Value ) +void CSettingTypeRDBOnOff::Save(uint32_t /*Index*/, bool Value) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),Value? "On" : "Off"); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), Value ? "On" : "Off"); } -void CSettingTypeRDBOnOff::Save (uint32_t /*Index*/, uint32_t /*Value*/ ) +void CSettingTypeRDBOnOff::Save(uint32_t /*Index*/, uint32_t /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBOnOff::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeRDBOnOff::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBOnOff::Save (uint32_t /*Index*/, const char * /*Value*/ ) +void CSettingTypeRDBOnOff::Save(uint32_t /*Index*/, const char * /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBOnOff::Delete(uint32_t /*Index*/ ) +void CSettingTypeRDBOnOff::Delete(uint32_t /*Index*/) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),nullptr); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), nullptr); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h index 7a0b9a65d..59dc96abd 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBOnOff.h @@ -1,4 +1,5 @@ #pragma once +#include class CSettingTypeRDBOnOff : public CSettingTypeRomDatabase @@ -9,26 +10,26 @@ public: ~CSettingTypeRDBOnOff(); // Return the values - virtual bool Load (uint32_t Index, bool & Value) const; - virtual bool Load (uint32_t Index, uint32_t & Value) const; - virtual bool Load (uint32_t Index, std::string & Value) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; // Return the default values - virtual void LoadDefault (uint32_t Index, bool & Value) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; - virtual void LoadDefault (uint32_t Index, std::string & Value) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - virtual void Save (uint32_t Index, bool Value ); - virtual void Save (uint32_t Index, uint32_t Value ); - virtual void Save (uint32_t Index, const std::string & Value ); - virtual void Save (uint32_t Index, const char * Value ); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index ); + virtual void Delete(uint32_t Index); private: CSettingTypeRDBOnOff(void); - CSettingTypeRDBOnOff(const CSettingTypeRDBOnOff&); - CSettingTypeRDBOnOff& operator=(const CSettingTypeRDBOnOff&); + CSettingTypeRDBOnOff(const CSettingTypeRDBOnOff &); + CSettingTypeRDBOnOff & operator=(const CSettingTypeRDBOnOff &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp index 1c4515a4a..088543756 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.cpp @@ -1,16 +1,17 @@ #include "stdafx.h" -#include "SettingsType-RomDatabase.h" + #include "SettingsType-RDBRamSize.h" +#include "SettingsType-RomDatabase.h" // == 8 ? 0x800000 : 0x400000 -CSettingTypeRDBRDRamSize::CSettingTypeRDBRDRamSize(const char * Name, SettingID DefaultSetting ) : - CSettingTypeRomDatabase(Name,DefaultSetting) +CSettingTypeRDBRDRamSize::CSettingTypeRDBRDRamSize(const char * Name, SettingID DefaultSetting) : + CSettingTypeRomDatabase(Name, DefaultSetting) { } -CSettingTypeRDBRDRamSize::CSettingTypeRDBRDRamSize(const char * Name, uint32_t DefaultValue ) : - CSettingTypeRomDatabase(Name,DefaultValue) +CSettingTypeRDBRDRamSize::CSettingTypeRDBRDRamSize(const char * Name, uint32_t DefaultValue) : + CSettingTypeRomDatabase(Name, DefaultValue) { } @@ -18,19 +19,19 @@ CSettingTypeRDBRDRamSize::~CSettingTypeRDBRDRamSize() { } -bool CSettingTypeRDBRDRamSize::Load (uint32_t /*Index*/, bool & /*Value*/ ) const +bool CSettingTypeRDBRDRamSize::Load(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeRDBRDRamSize::Load (uint32_t Index, uint32_t & Value ) const +bool CSettingTypeRDBRDRamSize::Load(uint32_t Index, uint32_t & Value) const { uint32_t ulValue; - bool bRes = m_SettingsIniFile->GetNumber(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultValue,ulValue); + bool bRes = m_SettingsIniFile->GetNumber(m_SectionIdent->c_str(), m_KeyName.c_str(), m_DefaultValue, ulValue); if (!bRes) { - LoadDefault(Index,ulValue); + LoadDefault(Index, ulValue); } Value = 0x400000; if (ulValue == 8 || ulValue == 0x800000) @@ -40,50 +41,50 @@ bool CSettingTypeRDBRDRamSize::Load (uint32_t Index, uint32_t & Value ) const return bRes; } -bool CSettingTypeRDBRDRamSize::Load (uint32_t /*Index*/, std::string & /*Value*/ ) const +bool CSettingTypeRDBRDRamSize::Load(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } // Return the default values -void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const +void CSettingTypeRDBRDRamSize::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, uint32_t & Value ) const +void CSettingTypeRDBRDRamSize::LoadDefault(uint32_t /*Index*/, uint32_t & Value) const { Value = m_DefaultSetting == Default_Constant ? m_DefaultValue : g_Settings->LoadDword(m_DefaultSetting); } -void CSettingTypeRDBRDRamSize::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeRDBRDRamSize::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } // Update the settings -void CSettingTypeRDBRDRamSize::Save (uint32_t /*Index*/, bool /*Value*/ ) +void CSettingTypeRDBRDRamSize::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBRDRamSize::Save (uint32_t /*Index*/, uint32_t Value ) +void CSettingTypeRDBRDRamSize::Save(uint32_t /*Index*/, uint32_t Value) { - m_SettingsIniFile->SaveNumber(m_SectionIdent->c_str(),m_KeyName.c_str(),Value == 0x800000 ? 8 : 4); + m_SettingsIniFile->SaveNumber(m_SectionIdent->c_str(), m_KeyName.c_str(), Value == 0x800000 ? 8 : 4); } -void CSettingTypeRDBRDRamSize::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeRDBRDRamSize::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBRDRamSize::Save (uint32_t /*Index*/, const char * /*Value*/ ) +void CSettingTypeRDBRDRamSize::Save(uint32_t /*Index*/, const char * /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBRDRamSize::Delete(uint32_t /*Index*/ ) +void CSettingTypeRDBRDRamSize::Delete(uint32_t /*Index*/) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),nullptr); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), nullptr); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h index 09ce60995..0215fb8ad 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBRamSize.h @@ -1,34 +1,35 @@ #pragma once +#include class CSettingTypeRDBRDRamSize : public CSettingTypeRomDatabase { public: - CSettingTypeRDBRDRamSize(const char * Name, SettingID DefaultSetting ); - CSettingTypeRDBRDRamSize(const char * Name, uint32_t DefaultValue ); + CSettingTypeRDBRDRamSize(const char * Name, SettingID DefaultSetting); + CSettingTypeRDBRDRamSize(const char * Name, uint32_t DefaultValue); ~CSettingTypeRDBRDRamSize(); // Return the values - virtual bool Load (uint32_t Index, bool & Value ) const; - virtual bool Load (uint32_t Index, uint32_t & Value ) const; - virtual bool Load (uint32_t Index, std::string & Value ) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; // Return the default values - virtual void LoadDefault (uint32_t Index, bool & Value ) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; - virtual void LoadDefault (uint32_t Index, std::string & Value ) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - virtual void Save (uint32_t Index, bool Value ); - virtual void Save (uint32_t Index, uint32_t Value ); - virtual void Save (uint32_t Index, const std::string & Value ); - virtual void Save (uint32_t Index, const char * Value ); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index ); + virtual void Delete(uint32_t Index); private: CSettingTypeRDBRDRamSize(void); - CSettingTypeRDBRDRamSize(const CSettingTypeRDBRDRamSize&); - CSettingTypeRDBRDRamSize& operator=(const CSettingTypeRDBRDRamSize&); + CSettingTypeRDBRDRamSize(const CSettingTypeRDBRDRamSize &); + CSettingTypeRDBRDRamSize & operator=(const CSettingTypeRDBRDRamSize &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp index 17905fe0c..fa6d24781 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.cpp @@ -1,15 +1,16 @@ #include "stdafx.h" -#include "SettingsType-RomDatabase.h" + #include "SettingsType-RDBSaveChip.h" +#include "SettingsType-RomDatabase.h" #include -CSettingTypeRDBSaveChip::CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting ) : - CSettingTypeRomDatabase(Name,DefaultSetting) +CSettingTypeRDBSaveChip::CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting) : + CSettingTypeRomDatabase(Name, DefaultSetting) { } -CSettingTypeRDBSaveChip::CSettingTypeRDBSaveChip(const char * Name, uint32_t DefaultValue ) : - CSettingTypeRomDatabase(Name,DefaultValue) +CSettingTypeRDBSaveChip::CSettingTypeRDBSaveChip(const char * Name, uint32_t DefaultValue) : + CSettingTypeRomDatabase(Name, DefaultValue) { } @@ -17,100 +18,119 @@ CSettingTypeRDBSaveChip::~CSettingTypeRDBSaveChip() { } -bool CSettingTypeRDBSaveChip::Load (uint32_t /*Index*/, bool & /*Value*/ ) const +bool CSettingTypeRDBSaveChip::Load(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeRDBSaveChip::Load (uint32_t Index, uint32_t & Value ) const +bool CSettingTypeRDBSaveChip::Load(uint32_t Index, uint32_t & Value) const { stdstr strValue; - bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(),m_KeyName.c_str(),m_DefaultStr,strValue); + bool bRes = m_SettingsIniFile->GetString(m_SectionIdent->c_str(), m_KeyName.c_str(), m_DefaultStr, strValue); if (!bRes) { - LoadDefault(Index,Value); + LoadDefault(Index, Value); return false; } const char * String = strValue.c_str(); - if (_stricmp(String,"First save type") == 0) { Value = (uint32_t)SaveChip_Auto; } - else if (_stricmp(String,"4kbit EEPROM") == 0) { Value = SaveChip_Eeprom_4K; } - else if (_stricmp(String,"16kbit EEPROM") == 0) { Value = SaveChip_Eeprom_16K; } - else if (_stricmp(String,"SRAM") == 0) { Value = SaveChip_Sram; } - else if (_stricmp(String,"FlashRAM") == 0) { Value = SaveChip_FlashRam; } - else if (_stricmp(String,"default") == 0) + if (_stricmp(String, "First save type") == 0) { - LoadDefault(Index,Value); + Value = (uint32_t)SaveChip_Auto; + } + else if (_stricmp(String, "4kbit EEPROM") == 0) + { + Value = SaveChip_Eeprom_4K; + } + else if (_stricmp(String, "16kbit EEPROM") == 0) + { + Value = SaveChip_Eeprom_16K; + } + else if (_stricmp(String, "SRAM") == 0) + { + Value = SaveChip_Sram; + } + else if (_stricmp(String, "FlashRAM") == 0) + { + Value = SaveChip_FlashRam; + } + else if (_stricmp(String, "default") == 0) + { + LoadDefault(Index, Value); return false; - } else { + } + else + { g_Notify->BreakPoint(__FILE__, __LINE__); } return true; } -bool CSettingTypeRDBSaveChip::Load (uint32_t /*Index*/, std::string & /*Value*/ ) const +bool CSettingTypeRDBSaveChip::Load(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } // Return the default values -void CSettingTypeRDBSaveChip::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const +void CSettingTypeRDBSaveChip::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBSaveChip::LoadDefault (uint32_t /*Index*/, uint32_t & Value ) const +void CSettingTypeRDBSaveChip::LoadDefault(uint32_t /*Index*/, uint32_t & Value) const { if (m_DefaultSetting != Default_None) { if (m_DefaultSetting == Default_Constant) { Value = m_DefaultValue; - } else { - g_Settings->LoadDword(m_DefaultSetting,Value); + } + else + { + g_Settings->LoadDword(m_DefaultSetting, Value); } } } -void CSettingTypeRDBSaveChip::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeRDBSaveChip::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } // Update the settings -void CSettingTypeRDBSaveChip::Save (uint32_t /*Index*/, bool /*Value*/ ) +void CSettingTypeRDBSaveChip::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBSaveChip::Save (uint32_t /*Index*/, uint32_t Value ) +void CSettingTypeRDBSaveChip::Save(uint32_t /*Index*/, uint32_t Value) { switch ((SAVE_CHIP_TYPE)Value) { - case SaveChip_Auto: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"First save type"); break; - case SaveChip_Eeprom_4K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"4kbit EEPROM"); break; - case SaveChip_Eeprom_16K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"16kbit EEPROM"); break; - case SaveChip_Sram: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"SRAM"); break; - case SaveChip_FlashRam: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),"FlashRAM"); break; + case SaveChip_Auto: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), "First save type"); break; + case SaveChip_Eeprom_4K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), "4kbit EEPROM"); break; + case SaveChip_Eeprom_16K: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), "16kbit EEPROM"); break; + case SaveChip_Sram: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), "SRAM"); break; + case SaveChip_FlashRam: m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), "FlashRAM"); break; default: g_Notify->BreakPoint(__FILE__, __LINE__); } } -void CSettingTypeRDBSaveChip::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeRDBSaveChip::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBSaveChip::Save (uint32_t /*Index*/, const char * /*Value*/ ) +void CSettingTypeRDBSaveChip::Save(uint32_t /*Index*/, const char * /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRDBSaveChip::Delete(uint32_t /*Index*/ ) +void CSettingTypeRDBSaveChip::Delete(uint32_t /*Index*/) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),nullptr); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), nullptr); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h index 52d7b5fad..8e2c515ea 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBSaveChip.h @@ -1,34 +1,35 @@ #pragma once +#include class CSettingTypeRDBSaveChip : public CSettingTypeRomDatabase { public: - CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting ); - CSettingTypeRDBSaveChip(const char * Name, uint32_t DefaultValue ); + CSettingTypeRDBSaveChip(const char * Name, SettingID DefaultSetting); + CSettingTypeRDBSaveChip(const char * Name, uint32_t DefaultValue); ~CSettingTypeRDBSaveChip(); // Return the values - virtual bool Load (uint32_t Index, bool & Value ) const; - virtual bool Load (uint32_t Index, uint32_t & Value ) const; - virtual bool Load (uint32_t Index, std::string & Value ) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; // Return the default values - virtual void LoadDefault (uint32_t Index, bool & Value ) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value ) const; - virtual void LoadDefault (uint32_t Index, std::string & Value ) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - virtual void Save (uint32_t Index, bool Value ); - virtual void Save (uint32_t Index, uint32_t Value ); - virtual void Save (uint32_t Index, const std::string & Value ); - virtual void Save (uint32_t Index, const char * Value ); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index ); + virtual void Delete(uint32_t Index); private: CSettingTypeRDBSaveChip(void); - CSettingTypeRDBSaveChip(const CSettingTypeRDBSaveChip&); - CSettingTypeRDBSaveChip& operator=(const CSettingTypeRDBSaveChip&); + CSettingTypeRDBSaveChip(const CSettingTypeRDBSaveChip &); + CSettingTypeRDBSaveChip & operator=(const CSettingTypeRDBSaveChip &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp index 110246b6c..7b28c0a43 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.cpp @@ -1,14 +1,15 @@ #include "stdafx.h" -#include "SettingsType-RomDatabase.h" + #include "SettingsType-RDBYesNo.h" +#include "SettingsType-RomDatabase.h" CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(const char * Name, SettingID DefaultSetting) : -CSettingTypeRomDatabase(Name, DefaultSetting) + CSettingTypeRomDatabase(Name, DefaultSetting) { } CSettingTypeRDBYesNo::CSettingTypeRDBYesNo(const char * Name, uint32_t DefaultValue) : -CSettingTypeRomDatabase(Name, DefaultValue) + CSettingTypeRomDatabase(Name, DefaultValue) { } @@ -71,7 +72,8 @@ void CSettingTypeRDBYesNo::LoadDefault(uint32_t /*Index*/, bool & Value) const { Value = m_DefaultValue != 0; } - else { + else + { g_Settings->LoadBool(m_DefaultSetting, Value); } } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.h b/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.h index f919c80ed..ea03b0849 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RDBYesNo.h @@ -1,4 +1,5 @@ #pragma once +#include class CSettingTypeRDBYesNo : public CSettingTypeRomDatabase @@ -9,26 +10,26 @@ public: ~CSettingTypeRDBYesNo(); //return the values - virtual bool Load (uint32_t Index, bool & Value) const; - virtual bool Load (uint32_t Index, uint32_t & Value) const; - virtual bool Load (uint32_t Index, std::string & Value) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; //return the default values - virtual void LoadDefault (uint32_t Index, bool & Value) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; - virtual void LoadDefault (uint32_t Index, std::string & Value) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; //Update the settings - virtual void Save (uint32_t Index, bool Value); - virtual void Save (uint32_t Index, uint32_t Value); - virtual void Save (uint32_t Index, const std::string & Value); - virtual void Save (uint32_t Index, const char * Value); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index ); + virtual void Delete(uint32_t Index); private: CSettingTypeRDBYesNo(void); - CSettingTypeRDBYesNo(const CSettingTypeRDBYesNo&); - CSettingTypeRDBYesNo& operator=(const CSettingTypeRDBYesNo&); + CSettingTypeRDBYesNo(const CSettingTypeRDBYesNo &); + CSettingTypeRDBYesNo & operator=(const CSettingTypeRDBYesNo &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp index 75a213da0..7e9bf9b51 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-RelativePath.h" CSettingTypeRelativePath::CSettingTypeRelativePath(const char * Directory, const char * FileName) : @@ -67,7 +68,7 @@ void CSettingTypeRelativePath::Delete(uint32_t /*Index*/) void CSettingTypeRelativePath::BuildPath(void) { - CPath FullPath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),""); + CPath FullPath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(), ""); FullPath.AppendDirectory(m_Directory.c_str()); FullPath.SetNameExtension(m_FileName.c_str()); m_FullPath = (const char *)FullPath; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h index 40d18c749..3c017479f 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RelativePath.h @@ -9,36 +9,51 @@ public: CSettingTypeRelativePath(const char * Directory, const char * FileName); ~CSettingTypeRelativePath(); - bool IndexBasedSetting (void) const { return false; } - SettingType GetSettingType (void) const { return SettingType_RelativePath; } - bool IsSettingSet (void) const { return false; } + bool IndexBasedSetting(void) const + { + return false; + } + SettingType GetSettingType(void) const + { + return SettingType_RelativePath; + } + bool IsSettingSet(void) const + { + return false; + } //return the values - bool Load (uint32_t /*Index*/, bool & /*Value*/) const { return false; }; - bool Load (uint32_t /*Index*/, uint32_t & /*Value*/) const { return false; }; - bool Load (uint32_t Index, std::string & Value) const; + bool Load(uint32_t /*Index*/, bool & /*Value*/) const + { + return false; + }; + bool Load(uint32_t /*Index*/, uint32_t & /*Value*/) const + { + return false; + }; + bool Load(uint32_t Index, std::string & Value) const; //return the default values - void LoadDefault (uint32_t Index, bool & Value) const; - void LoadDefault (uint32_t Index, uint32_t & Value) const; - void LoadDefault (uint32_t Index, std::string & Value) const; + void LoadDefault(uint32_t Index, bool & Value) const; + void LoadDefault(uint32_t Index, uint32_t & Value) const; + void LoadDefault(uint32_t Index, std::string & Value) const; //Update the settings - void Save (uint32_t Index, bool Value); - void Save (uint32_t Index, uint32_t Value); - void Save (uint32_t Index, const std::string & Value); - void Save (uint32_t Index, const char * Value); + void Save(uint32_t Index, bool Value); + void Save(uint32_t Index, uint32_t Value); + void Save(uint32_t Index, const std::string & Value); + void Save(uint32_t Index, const char * Value); // Delete the setting - void Delete (uint32_t Index ); + void Delete(uint32_t Index); private: CSettingTypeRelativePath(void); - CSettingTypeRelativePath(const CSettingTypeRelativePath&); - CSettingTypeRelativePath& operator=(const CSettingTypeRelativePath&); + CSettingTypeRelativePath(const CSettingTypeRelativePath &); + CSettingTypeRelativePath & operator=(const CSettingTypeRelativePath &); static void RefreshSettings(void * _this); - void BuildPath ( void ); + void BuildPath(void); std::string m_FullPath; std::string m_Directory; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp index 1ed885b19..e199330a2 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-RomDatabase.h" CIniFile * CSettingTypeRomDatabase::m_SettingsIniFile = nullptr; @@ -127,32 +128,32 @@ void CSettingTypeRomDatabase::GameChanged(void * /*Data */) bool CSettingTypeRomDatabase::Load(uint32_t & Value) const { - bool bRes = false; - if (m_VideoSetting) - { - bRes = m_VideoIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); - } - else if (m_AudioSetting) - { - bRes = m_AudioIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); - } - else - { - bRes = m_SettingsIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); - } - return bRes; + bool bRes = false; + if (m_VideoSetting) + { + bRes = m_VideoIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); + } + else if (m_AudioSetting) + { + bRes = m_AudioIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); + } + else + { + bRes = m_SettingsIniFile->GetNumber(Section(), m_KeyName.c_str(), Value, Value); + } + return bRes; } bool CSettingTypeRomDatabase::Load(uint32_t Index, bool & Value) const { uint32_t temp_value = Value; - if (Load(temp_value)) - { - Value = temp_value != 0; - return true; - } - LoadDefault(Index, Value); - return false; + if (Load(temp_value)) + { + Value = temp_value != 0; + return true; + } + LoadDefault(Index, Value); + return false; } bool CSettingTypeRomDatabase::Load(uint32_t Index, uint32_t & Value) const @@ -160,8 +161,8 @@ bool CSettingTypeRomDatabase::Load(uint32_t Index, uint32_t & Value) const if (!Load(Value)) { LoadDefault(Index, Value); - return false; - } + return false; + } return true; } @@ -201,7 +202,8 @@ void CSettingTypeRomDatabase::LoadDefault(uint32_t /*Index*/, bool & Value) cons { Value = m_DefaultValue != 0; } - else { + else + { g_Settings->LoadBool(m_DefaultSetting, Value); } } @@ -223,7 +225,8 @@ void CSettingTypeRomDatabase::LoadDefault(uint32_t /*Index*/, std::string & Valu { Value = m_DefaultStr; } - else { + else + { g_Settings->LoadStringVal(m_DefaultSetting, Value); } } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h index 1b5752132..4738777bd 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabase.h @@ -14,9 +14,18 @@ public: virtual ~CSettingTypeRomDatabase(); - virtual bool IndexBasedSetting(void) const { return false; } - virtual SettingType GetSettingType(void) const { return SettingType_RomDatabase; } - virtual bool IsSettingSet(void) const { return false; } + virtual bool IndexBasedSetting(void) const + { + return false; + } + virtual SettingType GetSettingType(void) const + { + return SettingType_RomDatabase; + } + virtual bool IsSettingSet(void) const + { + return false; + } // Return the values virtual bool Load(uint32_t Index, bool & Value) const; @@ -47,10 +56,13 @@ protected: static bool IsVideoSetting(const char * Name); static bool IsAudioSetting(const char * Name); static const char * StripNameSection(const char * Name); - virtual const char * Section(void) const { return m_SectionIdent->c_str(); } + virtual const char * Section(void) const + { + return m_SectionIdent->c_str(); + } mutable std::string m_KeyName; - const char *const m_DefaultStr; + const char * const m_DefaultStr; const int32_t m_DefaultValue; const SettingID m_DefaultSetting; const bool m_DeleteOnDefault; @@ -64,8 +76,8 @@ protected: private: CSettingTypeRomDatabase(); - CSettingTypeRomDatabase(const CSettingTypeRomDatabase&); - CSettingTypeRomDatabase& operator=(const CSettingTypeRomDatabase&); + CSettingTypeRomDatabase(const CSettingTypeRomDatabase &); + CSettingTypeRomDatabase & operator=(const CSettingTypeRomDatabase &); - bool Load(uint32_t & Value) const; + bool Load(uint32_t & Value) const; }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp index 2d3ccec21..1387bf5ea 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp @@ -1,30 +1,31 @@ #include "stdafx.h" + #include "SettingsType-RomDatabase.h" #include "SettingsType-RomDatabaseIndex.h" -CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue ) : - CSettingTypeRomDatabase("",DefaultValue), +CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue) : + CSettingTypeRomDatabase("", DefaultValue), m_PreIndex(PreIndex), m_PostIndex(PostIndex) { } -CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue ) : - CSettingTypeRomDatabase("",DefaultValue), +CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue) : + CSettingTypeRomDatabase("", DefaultValue), m_PreIndex(PreIndex), m_PostIndex(PostIndex) { } -CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue ) : - CSettingTypeRomDatabase("",DefaultValue, false), +CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue) : + CSettingTypeRomDatabase("", DefaultValue, false), m_PreIndex(PreIndex), m_PostIndex(PostIndex) { } -CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting ) : - CSettingTypeRomDatabase("",DefaultSetting), +CSettingTypeRomDatabaseIndex::CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting) : + CSettingTypeRomDatabase("", DefaultSetting), m_PreIndex(PreIndex), m_PostIndex(PostIndex) { @@ -34,63 +35,63 @@ CSettingTypeRomDatabaseIndex::~CSettingTypeRomDatabaseIndex() { } -bool CSettingTypeRomDatabaseIndex::Load (uint32_t /*Index*/, bool & /*Value*/ ) const +bool CSettingTypeRomDatabaseIndex::Load(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeRomDatabaseIndex::Load (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +bool CSettingTypeRomDatabaseIndex::Load(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeRomDatabaseIndex::Load (uint32_t Index, std::string & Value ) const +bool CSettingTypeRomDatabaseIndex::Load(uint32_t Index, std::string & Value) const { - m_KeyName = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - return CSettingTypeRomDatabase::Load(0,Value); + m_KeyName = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + return CSettingTypeRomDatabase::Load(0, Value); } -void CSettingTypeRomDatabaseIndex::LoadDefault (uint32_t Index, bool & Value ) const +void CSettingTypeRomDatabaseIndex::LoadDefault(uint32_t Index, bool & Value) const { - m_KeyName = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeRomDatabase::LoadDefault(0,Value); + m_KeyName = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeRomDatabase::LoadDefault(0, Value); } -void CSettingTypeRomDatabaseIndex::LoadDefault (uint32_t Index, uint32_t & Value ) const +void CSettingTypeRomDatabaseIndex::LoadDefault(uint32_t Index, uint32_t & Value) const { - m_KeyName = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeRomDatabase::LoadDefault(0,Value); + m_KeyName = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeRomDatabase::LoadDefault(0, Value); } -void CSettingTypeRomDatabaseIndex::LoadDefault (uint32_t Index, std::string & Value ) const +void CSettingTypeRomDatabaseIndex::LoadDefault(uint32_t Index, std::string & Value) const { - m_KeyName = stdstr_f("%s%d%s",m_PreIndex.c_str(),Index,m_PostIndex.c_str()); - CSettingTypeRomDatabase::LoadDefault(0,Value); + m_KeyName = stdstr_f("%s%d%s", m_PreIndex.c_str(), Index, m_PostIndex.c_str()); + CSettingTypeRomDatabase::LoadDefault(0, Value); } -void CSettingTypeRomDatabaseIndex::Save (uint32_t /*Index*/, bool /*Value*/ ) +void CSettingTypeRomDatabaseIndex::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRomDatabaseIndex::Save (uint32_t /*Index*/, uint32_t /*Value*/ ) +void CSettingTypeRomDatabaseIndex::Save(uint32_t /*Index*/, uint32_t /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRomDatabaseIndex::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeRomDatabaseIndex::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRomDatabaseIndex::Save (uint32_t /*Index*/, const char * /*Value*/ ) +void CSettingTypeRomDatabaseIndex::Save(uint32_t /*Index*/, const char * /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeRomDatabaseIndex::Delete (uint32_t /*Index*/ ) +void CSettingTypeRomDatabaseIndex::Delete(uint32_t /*Index*/) { - m_SettingsIniFile->SaveString(m_SectionIdent->c_str(),m_KeyName.c_str(),nullptr); + m_SettingsIniFile->SaveString(m_SectionIdent->c_str(), m_KeyName.c_str(), nullptr); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h index 521a6b40c..5b881a76e 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseIndex.h @@ -4,38 +4,41 @@ class CSettingTypeRomDatabaseIndex : public CSettingTypeRomDatabase { public: - CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue ); - CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue ); - CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue ); - CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting ); + CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue); + CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue); + CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue); + CSettingTypeRomDatabaseIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting); virtual ~CSettingTypeRomDatabaseIndex(); - virtual bool IndexBasedSetting ( void ) const { return true; } + virtual bool IndexBasedSetting(void) const + { + return true; + } // Return the values - virtual bool Load (uint32_t Index, bool & Value) const; - virtual bool Load (uint32_t Index, uint32_t & Value) const; - virtual bool Load (uint32_t Index, std::string & Value) const; + virtual bool Load(uint32_t Index, bool & Value) const; + virtual bool Load(uint32_t Index, uint32_t & Value) const; + virtual bool Load(uint32_t Index, std::string & Value) const; // Return the default values - virtual void LoadDefault (uint32_t Index, bool & Value) const; - virtual void LoadDefault (uint32_t Index, uint32_t & Value) const; - virtual void LoadDefault (uint32_t Index, std::string & Value) const; + virtual void LoadDefault(uint32_t Index, bool & Value) const; + virtual void LoadDefault(uint32_t Index, uint32_t & Value) const; + virtual void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - virtual void Save (uint32_t Index, bool Value); - virtual void Save (uint32_t Index, uint32_t Value); - virtual void Save (uint32_t Index, const std::string & Value); - virtual void Save (uint32_t Index, const char * Value); + virtual void Save(uint32_t Index, bool Value); + virtual void Save(uint32_t Index, uint32_t Value); + virtual void Save(uint32_t Index, const std::string & Value); + virtual void Save(uint32_t Index, const char * Value); // Delete the setting - virtual void Delete (uint32_t Index ); + virtual void Delete(uint32_t Index); private: CSettingTypeRomDatabaseIndex(void); - CSettingTypeRomDatabaseIndex(const CSettingTypeRomDatabaseIndex&); - CSettingTypeRomDatabaseIndex& operator=(const CSettingTypeRomDatabaseIndex&); + CSettingTypeRomDatabaseIndex(const CSettingTypeRomDatabaseIndex &); + CSettingTypeRomDatabaseIndex & operator=(const CSettingTypeRomDatabaseIndex &); std::string m_PreIndex, m_PostIndex; }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp index 7b859d121..104c829d2 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-RomDatabaseSetting.h" CSettingTypeRomDatabaseSetting::CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, uint32_t DefaultValue, bool DeleteOnDefault) : diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.h index 07cbeb589..88b6dbf07 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomDatabaseSetting.h @@ -6,22 +6,28 @@ class CSettingTypeRomDatabaseSetting : public CSettingTypeRomDatabase { public: - CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, const char * DefaultValue, bool DeleteOnDefault = false ); - CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, bool DefaultValue, bool DeleteOnDefault = false ); - CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, uint32_t DefaultValue, bool DeleteOnDefault = false ); - CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false ); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, const char * DefaultValue, bool DeleteOnDefault = false); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, bool DefaultValue, bool DeleteOnDefault = false); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, uint32_t DefaultValue, bool DeleteOnDefault = false); + CSettingTypeRomDatabaseSetting(const char * SectionIdent, const char * Name, SettingID DefaultSetting, bool DeleteOnDefault = false); virtual ~CSettingTypeRomDatabaseSetting(); - virtual SettingType GetSettingType ( void ) const { return SettingType_RdbSetting; } + virtual SettingType GetSettingType(void) const + { + return SettingType_RdbSetting; + } private: - virtual const char * Section ( void ) const { return m_SectionIdent.c_str(); } + virtual const char * Section(void) const + { + return m_SectionIdent.c_str(); + } stdstr m_SectionIdent; private: CSettingTypeRomDatabaseSetting(void); - CSettingTypeRomDatabaseSetting(const CSettingTypeRomDatabaseSetting&); - CSettingTypeRomDatabaseSetting& operator=(const CSettingTypeRomDatabaseSetting&); + CSettingTypeRomDatabaseSetting(const CSettingTypeRomDatabaseSetting &); + CSettingTypeRomDatabaseSetting & operator=(const CSettingTypeRomDatabaseSetting &); }; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h b/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h index 229758a4b..874c43e13 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-RomSetting.h @@ -10,25 +10,28 @@ public: CSettingTypeRomDatabase(const char * Name, SettingID DefaultSetting); ~CSettingTypeRomDatabase(); - virtual SettingLocation GetSettingsLocation ( void ) const { return SettingLocation_RomDatabase; } + virtual SettingLocation GetSettingsLocation(void) const + { + return SettingLocation_RomDatabase; + } // Return the values - virtual bool Load (int32_t Index, bool & Value) const; - virtual bool Load (int32_t Index, uint32_t & Value) const; - virtual bool Load (int32_t Index, stdstr & Value) const; + virtual bool Load(int32_t Index, bool & Value) const; + virtual bool Load(int32_t Index, uint32_t & Value) const; + virtual bool Load(int32_t Index, stdstr & Value) const; // Update the settings - virtual void Save (int32_t Index, bool Value); - virtual void Save (int32_t Index, uint32_t Value); - virtual void Save (int32_t Index, const stdstr & Value); - virtual void Save (int32_t Index, const char * Value); + virtual void Save(int32_t Index, bool Value); + virtual void Save(int32_t Index, uint32_t Value); + virtual void Save(int32_t Index, const stdstr & Value); + virtual void Save(int32_t Index, const char * Value); - static void Initilize ( void ); + static void Initilize(void); private: CSettingTypeRomDatabase(void); - CSettingTypeRomDatabase(const CSettingTypeRomDatabase&); - CSettingTypeRomDatabase& operator=(const CSettingTypeRomDatabase&); + CSettingTypeRomDatabase(const CSettingTypeRomDatabase &); + CSettingTypeRomDatabase & operator=(const CSettingTypeRomDatabase &); const const char * m_KeyName; const const char * m_DefaultStr; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp index 026791219..fa3d4f110 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-SelectedDirectory.h" CSettingTypeSelectedDirectory::CSettingTypeSelectedDirectory(const char * Name, SettingID InitialDir, SettingID SelectedDir, SettingID UseSelected, SettingID NotifyChangeId) : diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h index f76f3a9c4..f8379f3fa 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-SelectedDirectory.h @@ -9,11 +9,20 @@ public: CSettingTypeSelectedDirectory(const char * Name, SettingID InitialDir, SettingID SelectedDir, SettingID UseSelected, SettingID NotifyChangeId); ~CSettingTypeSelectedDirectory(); - virtual bool IndexBasedSetting(void) const { return false; } - virtual SettingType GetSettingType(void) const { return SettingType_SelectedDirectory; } + virtual bool IndexBasedSetting(void) const + { + return false; + } + virtual SettingType GetSettingType(void) const + { + return SettingType_SelectedDirectory; + } virtual bool IsSettingSet(void) const; - const char * GetName(void) const { return m_Name.c_str(); } + const char * GetName(void) const + { + return m_Name.c_str(); + } // Return the values virtual bool Load(uint32_t Index, bool & Value) const; @@ -36,8 +45,8 @@ public: private: CSettingTypeSelectedDirectory(void); - CSettingTypeSelectedDirectory(const CSettingTypeSelectedDirectory&); - CSettingTypeSelectedDirectory& operator=(const CSettingTypeSelectedDirectory&); + CSettingTypeSelectedDirectory(const CSettingTypeSelectedDirectory &); + CSettingTypeSelectedDirectory & operator=(const CSettingTypeSelectedDirectory &); static void DirectoryChanged(CSettingTypeSelectedDirectory * _this); diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp index 25a203a15..a99d6c6ac 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-TempBool.h" CSettingTypeTempBool::CSettingTypeTempBool(bool initialValue, const char * Name) : @@ -54,15 +55,15 @@ void CSettingTypeTempBool::Save(uint32_t /*Index*/, bool Value) void CSettingTypeTempBool::Save(uint32_t /*Index*/, uint32_t Value) { - if (Value == 0 || Value != 0) - { - m_value = Value != 0; - m_changed = true; - } - else - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } + if (Value == 0 || Value != 0) + { + m_value = Value != 0; + m_changed = true; + } + else + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } } void CSettingTypeTempBool::Save(uint32_t /*Index*/, const std::string & /*Value*/) diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h index 078592020..0eab930fa 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempBool.h @@ -9,11 +9,23 @@ public: CSettingTypeTempBool(bool initialValue, const char * name = nullptr); ~CSettingTypeTempBool(); - bool IndexBasedSetting(void) const { return false; } - SettingType GetSettingType(void) const { return SettingType_BoolVariable; } - bool IsSettingSet(void) const { return m_changed; } + bool IndexBasedSetting(void) const + { + return false; + } + SettingType GetSettingType(void) const + { + return SettingType_BoolVariable; + } + bool IsSettingSet(void) const + { + return m_changed; + } - const char * GetName(void) const { return m_Name.c_str(); } + const char * GetName(void) const + { + return m_Name.c_str(); + } // Return the values bool Load(uint32_t Index, bool & Value) const; @@ -36,8 +48,8 @@ public: private: CSettingTypeTempBool(void); - CSettingTypeTempBool(const CSettingTypeTempBool&); - CSettingTypeTempBool& operator=(const CSettingTypeTempBool&); + CSettingTypeTempBool(const CSettingTypeTempBool &); + CSettingTypeTempBool & operator=(const CSettingTypeTempBool &); bool m_value; bool m_changed; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp index 1bee12c04..969759190 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-TempNumber.h" CSettingTypeTempNumber::CSettingTypeTempNumber(uint32_t initialValue) : @@ -7,65 +8,65 @@ CSettingTypeTempNumber::CSettingTypeTempNumber(uint32_t initialValue) : { } -CSettingTypeTempNumber::~CSettingTypeTempNumber ( void ) +CSettingTypeTempNumber::~CSettingTypeTempNumber(void) { } -bool CSettingTypeTempNumber::Load (uint32_t /*Index*/, bool & /*Value*/ ) const +bool CSettingTypeTempNumber::Load(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return true; } -bool CSettingTypeTempNumber::Load (uint32_t /*Index*/, uint32_t & Value ) const +bool CSettingTypeTempNumber::Load(uint32_t /*Index*/, uint32_t & Value) const { Value = m_value; return false; } -bool CSettingTypeTempNumber::Load (uint32_t /*Index*/, std::string & /*Value*/ ) const +bool CSettingTypeTempNumber::Load(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } // Return the default values -void CSettingTypeTempNumber::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const +void CSettingTypeTempNumber::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempNumber::LoadDefault (uint32_t /*Index*/, uint32_t & Value ) const +void CSettingTypeTempNumber::LoadDefault(uint32_t /*Index*/, uint32_t & Value) const { - Value = m_initialValue; + Value = m_initialValue; } -void CSettingTypeTempNumber::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeTempNumber::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempNumber::Save (uint32_t /*Index*/, bool /*Value*/ ) +void CSettingTypeTempNumber::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempNumber::Save (uint32_t /*Index*/, uint32_t Value ) +void CSettingTypeTempNumber::Save(uint32_t /*Index*/, uint32_t Value) { m_value = Value; } -void CSettingTypeTempNumber::Save (uint32_t /*Index*/, const std::string & /*Value*/ ) +void CSettingTypeTempNumber::Save(uint32_t /*Index*/, const std::string & /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempNumber::Save (uint32_t /*Index*/, const char * /*Value*/ ) +void CSettingTypeTempNumber::Save(uint32_t /*Index*/, const char * /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempNumber::Delete(uint32_t /*Index*/ ) +void CSettingTypeTempNumber::Delete(uint32_t /*Index*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h index 11baa3a4f..50386b2ad 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempNumber.h @@ -9,33 +9,42 @@ public: CSettingTypeTempNumber(uint32_t initialValue); ~CSettingTypeTempNumber(); - bool IndexBasedSetting ( void ) const { return false; } - SettingType GetSettingType ( void ) const { return SettingType_NumberVariable; } - bool IsSettingSet(void) const { return false; } + bool IndexBasedSetting(void) const + { + return false; + } + SettingType GetSettingType(void) const + { + return SettingType_NumberVariable; + } + bool IsSettingSet(void) const + { + return false; + } // Return the values - bool Load (uint32_t Index, bool & Value ) const; - bool Load (uint32_t Index, uint32_t & Value ) const; - bool Load (uint32_t Index, std::string & Value ) const; + bool Load(uint32_t Index, bool & Value) const; + bool Load(uint32_t Index, uint32_t & Value) const; + bool Load(uint32_t Index, std::string & Value) const; // Return the default values - void LoadDefault (uint32_t Index, bool & Value ) const; - void LoadDefault (uint32_t Index, uint32_t & Value ) const; - void LoadDefault (uint32_t Index, std::string & Value ) const; + void LoadDefault(uint32_t Index, bool & Value) const; + void LoadDefault(uint32_t Index, uint32_t & Value) const; + void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - void Save (uint32_t Index, bool Value ); - void Save (uint32_t Index, uint32_t Value ); - void Save (uint32_t Index, const std::string & Value ); - void Save (uint32_t Index, const char * Value ); + void Save(uint32_t Index, bool Value); + void Save(uint32_t Index, uint32_t Value); + void Save(uint32_t Index, const std::string & Value); + void Save(uint32_t Index, const char * Value); // Delete the setting - void Delete (uint32_t Index ); + void Delete(uint32_t Index); private: CSettingTypeTempNumber(void); - CSettingTypeTempNumber(const CSettingTypeTempNumber&); - CSettingTypeTempNumber& operator=(const CSettingTypeTempNumber&); + CSettingTypeTempNumber(const CSettingTypeTempNumber &); + CSettingTypeTempNumber & operator=(const CSettingTypeTempNumber &); uint32_t m_value; uint32_t m_initialValue; diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp index 7fd2d7646..f388165e3 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "SettingsType-TempString.h" CSettingTypeTempString::CSettingTypeTempString(const char * initialValue) : @@ -6,65 +7,65 @@ CSettingTypeTempString::CSettingTypeTempString(const char * initialValue) : { } -CSettingTypeTempString::~CSettingTypeTempString ( void ) +CSettingTypeTempString::~CSettingTypeTempString(void) { } -bool CSettingTypeTempString::Load (uint32_t /*Index*/, bool & /*Value*/ ) const +bool CSettingTypeTempString::Load(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeTempString::Load (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +bool CSettingTypeTempString::Load(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); return false; } -bool CSettingTypeTempString::Load (uint32_t /*Index*/, std::string & Value ) const +bool CSettingTypeTempString::Load(uint32_t /*Index*/, std::string & Value) const { Value = m_value; return true; } // Return the default values -void CSettingTypeTempString::LoadDefault (uint32_t /*Index*/, bool & /*Value*/ ) const +void CSettingTypeTempString::LoadDefault(uint32_t /*Index*/, bool & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempString::LoadDefault (uint32_t /*Index*/, uint32_t & /*Value*/ ) const +void CSettingTypeTempString::LoadDefault(uint32_t /*Index*/, uint32_t & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempString::LoadDefault (uint32_t /*Index*/, std::string & /*Value*/ ) const +void CSettingTypeTempString::LoadDefault(uint32_t /*Index*/, std::string & /*Value*/) const { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempString::Save (uint32_t /*Index*/, bool /*Value*/ ) +void CSettingTypeTempString::Save(uint32_t /*Index*/, bool /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempString::Save (uint32_t /*Index*/, uint32_t /*Value*/ ) +void CSettingTypeTempString::Save(uint32_t /*Index*/, uint32_t /*Value*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } -void CSettingTypeTempString::Save (uint32_t /*Index*/, const std::string & Value ) +void CSettingTypeTempString::Save(uint32_t /*Index*/, const std::string & Value) { m_value = Value; } -void CSettingTypeTempString::Save (uint32_t /*Index*/, const char * Value ) +void CSettingTypeTempString::Save(uint32_t /*Index*/, const char * Value) { m_value = Value; } -void CSettingTypeTempString::Delete(uint32_t /*Index*/ ) +void CSettingTypeTempString::Delete(uint32_t /*Index*/) { g_Notify->BreakPoint(__FILE__, __LINE__); } diff --git a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h index b99e3dbb9..52fa67fbc 100644 --- a/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h +++ b/Source/Project64-core/Settings/SettingType/SettingsType-TempString.h @@ -9,33 +9,42 @@ public: CSettingTypeTempString(const char * initialValue); ~CSettingTypeTempString(); - bool IndexBasedSetting ( void ) const { return false; } - SettingType GetSettingType ( void ) const { return SettingType_StringVariable; } - bool IsSettingSet(void) const { return false; } + bool IndexBasedSetting(void) const + { + return false; + } + SettingType GetSettingType(void) const + { + return SettingType_StringVariable; + } + bool IsSettingSet(void) const + { + return false; + } // Return the values - bool Load (uint32_t Index, bool & Value ) const; - bool Load (uint32_t Index, uint32_t & Value ) const; - bool Load (uint32_t Index, std::string & Value ) const; + bool Load(uint32_t Index, bool & Value) const; + bool Load(uint32_t Index, uint32_t & Value) const; + bool Load(uint32_t Index, std::string & Value) const; // Return the default values - void LoadDefault (uint32_t Index, bool & Value ) const; - void LoadDefault (uint32_t Index, uint32_t & Value ) const; - void LoadDefault (uint32_t Index, std::string & Value ) const; + void LoadDefault(uint32_t Index, bool & Value) const; + void LoadDefault(uint32_t Index, uint32_t & Value) const; + void LoadDefault(uint32_t Index, std::string & Value) const; // Update the settings - void Save (uint32_t Index, bool Value ); - void Save (uint32_t Index, uint32_t Value ); - void Save (uint32_t Index, const std::string & Value ); - void Save (uint32_t Index, const char * Value ); + void Save(uint32_t Index, bool Value); + void Save(uint32_t Index, uint32_t Value); + void Save(uint32_t Index, const std::string & Value); + void Save(uint32_t Index, const char * Value); // Delete the setting - void Delete (uint32_t Index ); + void Delete(uint32_t Index); private: CSettingTypeTempString(void); - CSettingTypeTempString(const CSettingTypeTempString&); - CSettingTypeTempString& operator=(const CSettingTypeTempString&); + CSettingTypeTempString(const CSettingTypeTempString &); + CSettingTypeTempString & operator=(const CSettingTypeTempString &); std::string m_value; }; diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index ad17c75df..a236d9f09 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -57,23 +57,23 @@ enum SettingID Setting_LanguageDirDefault, Setting_CurrentLanguage, Setting_EnableDisk, - Setting_SyncViaAudioEnabled, - Setting_Enhancement, + Setting_SyncViaAudioEnabled, + Setting_Enhancement, Setting_DiskSaveType, Setting_UpdateControllerOnRefresh, // Default settings Default_RDRamSize, - Default_UseHleGfx, - Default_ViRefreshRate, - Default_AiCountPerBytes, - Default_CounterFactor, - Default_32Bit, - Default_SyncViaAudio, - Default_FixedAudio, - Default_UnalignedDMA, - Default_RandomizeSIPIInterrupts, - Default_SMM_Protect_Memory, + Default_UseHleGfx, + Default_ViRefreshRate, + Default_AiCountPerBytes, + Default_CounterFactor, + Default_32Bit, + Default_SyncViaAudio, + Default_FixedAudio, + Default_UnalignedDMA, + Default_RandomizeSIPIInterrupts, + Default_SMM_Protect_Memory, Default_DiskSeekTiming, // RDB settings @@ -111,7 +111,7 @@ enum SettingID Rdb_CRC_Recalc, Rdb_UnalignedDMA, Rdb_RandomizeSIPIInterrupts, - Rdb_RPCKey, + Rdb_RPCKey, Rdb_DiskSeekTiming, // Individual game settings @@ -168,7 +168,7 @@ enum SettingID Game_FullSpeed, Game_UnalignedDMA, Game_RandomizeSIPIInterrupts, - Game_RPCKey, + Game_RPCKey, Game_DiskSeekTiming, // General game running info @@ -328,13 +328,22 @@ enum SettingID Logging_LogRomHeader, Logging_LogUnknown, - FirstUISettings = MaxPluginSetting + 1, LastUISettings = FirstUISettings + MaxPluginSetting, - FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, - FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, - FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, - FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, - FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, - FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, - FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, - FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, + FirstUISettings = MaxPluginSetting + 1, + LastUISettings = FirstUISettings + MaxPluginSetting, + FirstRSPDefaultSet, + LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, + FirstRSPSettings, + LastRSPSettings = FirstRSPSettings + MaxPluginSetting, + FirstGfxDefaultSet, + LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, + FirstGfxSettings, + LastGfxSettings = FirstGfxSettings + MaxPluginSetting, + FirstAudioDefaultSet, + LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, + FirstAudioSettings, + LastAudioSettings = FirstAudioSettings + MaxPluginSetting, + FirstCtrlDefaultSet, + LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, + FirstCtrlSettings, + LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, }; diff --git a/Source/Project64-core/stdafx.h b/Source/Project64-core/stdafx.h index a078f14e2..7cde93536 100644 --- a/Source/Project64-core/stdafx.h +++ b/Source/Project64-core/stdafx.h @@ -1,12 +1,12 @@ #include #include -#include #include #include +#include +#include "Version.h" #include #include -#include "Version.h" #include #include diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h index 2827ba975..d439a3136 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabData.h @@ -71,8 +71,7 @@ struct TabRecord class TabData { public: - static constexpr FieldPair GPRFields[] = - { + static constexpr FieldPair GPRFields[] = { {IDC_R0_LBL, IDC_R0_EDIT}, {IDC_R1_LBL, IDC_R1_EDIT}, {IDC_R2_LBL, IDC_R2_EDIT}, @@ -109,8 +108,7 @@ public: static constexpr TabRecord GPR = TabRecord{sizeof(GPRFields), GPRFields}; - static constexpr FieldPair FPRFields[] = - { + static constexpr FieldPair FPRFields[] = { {IDC_F0_LBL, IDC_F0_EDIT}, {IDC_F1_LBL, IDC_F1_EDIT}, {IDC_F2_LBL, IDC_F2_EDIT}, @@ -147,8 +145,7 @@ public: static constexpr TabRecord FPR = TabRecord{sizeof(FPRFields), FPRFields}; - static constexpr FieldPair COP0Fields[] = - { + static constexpr FieldPair COP0Fields[] = { {IDC_COP0_0_LBL, IDC_COP0_0_EDIT}, {IDC_COP0_1_LBL, IDC_COP0_1_EDIT}, {IDC_COP0_2_LBL, IDC_COP0_2_EDIT}, @@ -172,8 +169,7 @@ public: static constexpr TabRecord COP0 = TabRecord{sizeof(COP0Fields), COP0Fields}; - static constexpr FieldPair RDRAMFields[] = - { + static constexpr FieldPair RDRAMFields[] = { {IDC_RDRAM00_LBL, IDC_RDRAM00_EDIT}, {IDC_RDRAM04_LBL, IDC_RDRAM04_EDIT}, {IDC_RDRAM08_LBL, IDC_RDRAM08_EDIT}, @@ -188,8 +184,7 @@ public: static constexpr TabRecord RDRAM = TabRecord{sizeof(RDRAMFields), RDRAMFields}; - static constexpr FieldPair SPFields[] = - { + static constexpr FieldPair SPFields[] = { {IDC_SP00_LBL, IDC_SP00_EDIT}, {IDC_SP04_LBL, IDC_SP04_EDIT}, {IDC_SP08_LBL, IDC_SP08_EDIT}, @@ -202,8 +197,7 @@ public: static constexpr TabRecord SP = TabRecord{sizeof(SPFields), SPFields}; - static constexpr FieldPair DPCFields[] = - { + static constexpr FieldPair DPCFields[] = { {IDC_DPC00_LBL, IDC_DPC00_EDIT}, {IDC_DPC04_LBL, IDC_DPC04_EDIT}, {IDC_DPC08_LBL, IDC_DPC08_EDIT}, @@ -216,8 +210,7 @@ public: static constexpr TabRecord DPC = TabRecord{sizeof(DPCFields), DPCFields}; - static constexpr FieldPair MIFields[] = - { + static constexpr FieldPair MIFields[] = { {IDC_MI00_LBL, IDC_MI00_EDIT}, {IDC_MI04_LBL, IDC_MI04_EDIT}, {IDC_MI08_LBL, IDC_MI08_EDIT}, @@ -226,8 +219,7 @@ public: static constexpr TabRecord MI = TabRecord{sizeof(MIFields), MIFields}; - static constexpr FieldPair VIFields[] = - { + static constexpr FieldPair VIFields[] = { {IDC_VI00_LBL, IDC_VI00_EDIT}, {IDC_VI04_LBL, IDC_VI04_EDIT}, {IDC_VI08_LBL, IDC_VI08_EDIT}, @@ -246,8 +238,7 @@ public: static constexpr TabRecord VI = TabRecord{sizeof(VIFields), VIFields}; - static constexpr FieldPair AIFields[] = - { + static constexpr FieldPair AIFields[] = { {IDC_AI00_LBL, IDC_AI00_EDIT}, {IDC_AI04_LBL, IDC_AI04_EDIT}, {IDC_AI08_LBL, IDC_AI08_EDIT}, @@ -258,8 +249,7 @@ public: static constexpr TabRecord AI = TabRecord{sizeof(AIFields), AIFields}; - static constexpr FieldPair PIFields[] = - { + static constexpr FieldPair PIFields[] = { {IDC_PI00_LBL, IDC_PI00_EDIT}, {IDC_PI04_LBL, IDC_PI04_EDIT}, {IDC_PI08_LBL, IDC_PI08_EDIT}, @@ -277,8 +267,7 @@ public: static constexpr TabRecord PI = TabRecord{sizeof(PIFields), PIFields}; - static constexpr FieldPair RIFields[] = - { + static constexpr FieldPair RIFields[] = { {IDC_RI00_LBL, IDC_RI00_EDIT}, {IDC_RI04_LBL, IDC_RI04_EDIT}, {IDC_RI08_LBL, IDC_RI08_EDIT}, @@ -291,8 +280,7 @@ public: static constexpr TabRecord RI = TabRecord{sizeof(RIFields), RIFields}; - static constexpr FieldPair SIFields[] = - { + static constexpr FieldPair SIFields[] = { {IDC_SI00_LBL, IDC_SI00_EDIT}, {IDC_SI04_LBL, IDC_SI04_EDIT}, {IDC_SI08_LBL, IDC_SI08_EDIT}, @@ -301,8 +289,7 @@ public: static constexpr TabRecord SI = TabRecord{sizeof(SIFields), SIFields}; - static constexpr FieldPair DDFields[] = - { + static constexpr FieldPair DDFields[] = { {IDC_DD00_LBL, IDC_DD00_EDIT}, {IDC_DD04_LBL, IDC_DD04_EDIT}, {IDC_DD08_LBL, IDC_DD08_EDIT}, diff --git a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h index 6abf662ea..c54a059d5 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-RegisterTabs.h @@ -96,8 +96,7 @@ private: static constexpr FieldPair SPPC = {IDC_SP_PC_LBL, IDC_SP_PC_EDIT}; - static constexpr char* ExceptionCodes[] = - { + static constexpr char * ExceptionCodes[] = { "Interrupt", "TLB mod", "TLB load/fetch", diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp index 89ac4ef79..55d6de95b 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_cpu.cpp @@ -19,16 +19,18 @@ static duk_ret_t ThrowRegInvalidError(duk_context * ctx); static duk_ret_t ThrowRegContextUnavailableError(duk_context * ctx); static duk_ret_t ThrowRegAssignmentTypeError(duk_context * ctx); +// clang-format off +#define REG_PROXY_FUNCTIONS(getter, setter) { \ + { "get", getter, 2 }, \ + { "set", setter, 3 }, \ + { nullptr, nullptr, 0 } \ +} +// clang-format on + void ScriptAPI::Define_cpu(duk_context * ctx) { // todo cleanup - #define REG_PROXY_FUNCTIONS(getter, setter) { \ - { "get", getter, 2 }, \ - { "set", setter, 3 }, \ - { nullptr, nullptr, 0 } \ - } - const struct { const char * key; diff --git a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_fs.cpp b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_fs.cpp index 73e0fd554..5ae62c9fe 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_fs.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptAPI/ScriptAPI_fs.cpp @@ -66,6 +66,7 @@ duk_ret_t ScriptAPI::js_fs_open(duk_context * ctx) bool bModeValid = false; + // clang-format off const char * validModes[] = { "r", "rb", "w", "wb", @@ -73,8 +74,9 @@ duk_ret_t ScriptAPI::js_fs_open(duk_context * ctx) "r+", "rb+", "r+b", "w+", "wb+", "w+b", "a+", "ab+", "a+b", - nullptr + nullptr, }; + // clang-format on for (int i = 0; validModes[i] != nullptr; i++) { @@ -388,7 +390,11 @@ duk_ret_t ScriptAPI::js_fs_Stats__constructor(duk_context * ctx) {nullptr, 0}, }; - struct { const char *key; time_t time; } dates[3] = { + struct + { + const char * key; + time_t time; + } dates[3] = { {"atime", stats.st_atime * 1000}, {"mtime", stats.st_mtime * 1000}, {"ctime", stats.st_ctime * 1000}, diff --git a/Source/Project64/UserInterface/WTLControls/TooltipDialog.h b/Source/Project64/UserInterface/WTLControls/TooltipDialog.h index c366a7c0d..8dda14b6d 100644 --- a/Source/Project64/UserInterface/WTLControls/TooltipDialog.h +++ b/Source/Project64/UserInterface/WTLControls/TooltipDialog.h @@ -51,6 +51,18 @@ public: } }; -#define BEGIN_TOOLTIP_MAP() static const _ToolTipMap* _GetToolTipMap() { static const _ToolTipMap map[] = { -#define TOOLTIP(ctrlId, text) { ctrlId, text }, -#define END_TOOLTIP_MAP() { 0 } }; return map; } +#define BEGIN_TOOLTIP_MAP() \ + static const _ToolTipMap * _GetToolTipMap() \ + { \ + static const _ToolTipMap map[] = { + +#define END_TOOLTIP_MAP() \ + { \ + 0 \ + } \ + } \ + ; \ + return map; \ + } + +#define TOOLTIP(ctrlId, text) {ctrlId, text},