diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index abf4065..0000000 --- a/CMakePresets.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "version": 3, - "configurePresets": [ - { - "name": "windows-base", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "CMAKE_C_COMPILER": "cl.exe", - "CMAKE_CXX_COMPILER": "cl.exe" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - } - }, - { - "name": "x64-debug", - "displayName": "x64 Debug", - "inherits": "windows-base", - "architecture": { - "value": "x64", - "strategy": "external" - }, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "x64-release", - "displayName": "x64 Release", - "inherits": "x64-debug", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - }, - { - "name": "x86-debug", - "displayName": "x86 Debug", - "inherits": "windows-base", - "architecture": { - "value": "x86", - "strategy": "external" - }, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "x86-release", - "displayName": "x86 Release", - "inherits": "x86-debug", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - } - ] -} diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 0000000..5b03594 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,28 @@ +{ + "configurations": [ + { + "name": "x64-Clang-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "clang_cl_x64_x64" ], + "variables": [] + }, + { + "name": "x64-Clang-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "clang_cl_x64_x64" ], + "variables": [] + } + ] +} \ No newline at end of file diff --git a/PowerRecomp/recompiler.cpp b/PowerRecomp/recompiler.cpp index dd9231d..365662f 100644 --- a/PowerRecomp/recompiler.cpp +++ b/PowerRecomp/recompiler.cpp @@ -1745,10 +1745,7 @@ bool Recompiler::Recompile(const Function& fn) println("PPC_FUNC(sub_{}) {{", fn.base); } - println("\t__assume((reinterpret_cast(base) & 0xFFFFFFFF) == 0);"); - println("\tPPCRegister temp;"); - println("\tPPCVRegister vtemp;"); - println("\tuint32_t ea;\n"); + println("\tPPC_FUNC_PROLOGUE();"); auto switchTable = switchTables.end(); bool allRecompiled = true; @@ -1817,13 +1814,13 @@ void Recompiler::Recompile(const char* directoryPath) for (size_t i = 0; i < functions.size(); i++) { - if ((i % 100) == 0) + if ((i % 256) == 0) { SaveCurrentOutData(directoryPath); println("#include \"ppc_recomp_shared.h\"\n"); } - if ((i % 2000) == 0 || (i == (functions.size() - 1))) + if ((i % 2048) == 0 || (i == (functions.size() - 1))) std::println("Recompiling functions... {}%", static_cast(i + 1) / functions.size() * 100.0f); Recompile(functions[i]); diff --git a/PowerRecomp/swa_recompiler.cpp b/PowerRecomp/swa_recompiler.cpp index fec1036..7d35d1b 100644 --- a/PowerRecomp/swa_recompiler.cpp +++ b/PowerRecomp/swa_recompiler.cpp @@ -115,6 +115,7 @@ void SWARecompiler::Analyse() else if (f.base == 0x82DE38A0) f.size = 0x16C; else if (f.base == 0x830B7DD0) f.size = 0x74; else if (f.base == 0x831B0BA0) f.size = 0xA0; + else if (f.base == 0x8305D168) f.size = 0x278; }; for (const auto& section : image.sections) @@ -145,7 +146,6 @@ void SWARecompiler::Analyse() } data = section.data; - const Symbol* prevSymbol = nullptr; while (data < dataEnd) { @@ -168,7 +168,6 @@ void SWARecompiler::Analyse() { assert(fnSymbol->address == base); - prevSymbol = &*fnSymbol; base += fnSymbol->size; data += fnSymbol->size; } diff --git a/PowerSample/CMakeLists.txt b/PowerSample/CMakeLists.txt index cd40ea0..073dc6a 100644 --- a/PowerSample/CMakeLists.txt +++ b/PowerSample/CMakeLists.txt @@ -1,12 +1,9 @@ project("PowerSample") -set(CMAKE_CXX_COMPILER "clang-cl") -set(CMAKE_C_COMPILER "clang-cl") add_compile_options( - "/clang:-march=x86-64-v3" - "/clang:-Wall" - "/clang:-Wno-unused-label" - "/clang:-Wno-unused-variable") + "-march=x86-64-v3" + "-Wno-unused-label" + "-Wno-unused-variable") file(GLOB RecompiledFiles *.cpp) add_library(PowerSample ${RecompiledFiles}) diff --git a/PowerUtils/ppc_context.h b/PowerUtils/ppc_context.h index 4ba0d60..6a36566 100644 --- a/PowerUtils/ppc_context.h +++ b/PowerUtils/ppc_context.h @@ -20,6 +20,12 @@ #define PPC_FUNC(x) extern "C" void x(PPCContext& __restrict ctx, uint8_t* base) noexcept +#define PPC_FUNC_PROLOGUE() \ + __assume((reinterpret_cast(base) & 0xFFFFFFFF) == 0); \ + PPCRegister temp; \ + PPCVRegister vtemp; \ + uint32_t ea + #define PPC_LOAD_U8(x) *(uint8_t*)(base + (x)) #define PPC_LOAD_U16(x) _byteswap_ushort(*(uint16_t*)(base + (x))) #define PPC_LOAD_U32(x) _byteswap_ulong(*(uint32_t*)(base + (x)))