diff --git a/README.md b/README.md index e6fff89..3e79603 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ git clone --recurse-submodules https://github.com/hedge-dev/UnleashedRecomp.git 3. Decompress `shader.ar` and place the resulting file in `./UnleashedRecompLib/private/`. 4. Open the repository directory in Visual Studio 2022 *(not Preview)* and wait for CMake generation to complete. 5. Under Solution Explorer, right-click and choose "Switch to CMake Targets View". -6. Expand the root project and right-click the **PowerRecomp** project and choose "Set as Startup Item", then run it and wait for recompilation to complete. -7. After code recompilation, right-click the **ShaderRecomp** project and choose "Set as Startup Item", then run it and wait for recompilation to complete. -8. After shader recompilation, expand the **UnleashedRecompLib** project and open `CMakeLists.txt`, then save (CTRL+S) to force CMake cache regeneration to populate the recompiled code. -9. Right-click the **UnleashedRecomp** project and choose "Set as Startup Item" and then choose "Add Debug Configuration". -10. Add a `currentDir` property to the first element under `configurations` in the generated JSON and set its value to the path to your game directory (where root is the directory containing `dlc`, `game`, `save`, `update`, etc). -11. Start debugging **UnleashedRecomp**. \ No newline at end of file +6. Right-click the **UnleashedRecomp** project and choose "Set as Startup Item", then choose "Add Debug Configuration". +7. Add a `currentDir` property to the first element under `configurations` in the generated JSON and set its value to the path to your game directory (where root is the directory containing `dlc`, `game`, `save`, `update`, etc). +8. Start debugging **UnleashedRecomp**. The initial compilation might take a while to complete due to code and shader recompilation. \ No newline at end of file diff --git a/UnleashedRecompLib/CMakeLists.txt b/UnleashedRecompLib/CMakeLists.txt index 8561424..8aeaaaa 100644 --- a/UnleashedRecompLib/CMakeLists.txt +++ b/UnleashedRecompLib/CMakeLists.txt @@ -3,19 +3,44 @@ project("UnleashedRecompLib") add_compile_options( "/fp:strict" "-march=sandybridge" - "-fno-strict-aliasing") + "-fno-strict-aliasing" +) -file(GLOB SWA_PPC_RECOMPILED_SOURCES "ppc/*.cpp") -file(GLOB SWA_SHADER_RECOMPILED_SOURCES "shader/*.cpp") -add_library(UnleashedRecompLib "main.cpp" ${SWA_PPC_RECOMPILED_SOURCES} "shader/shader_cache.h" ${SWA_SHADER_RECOMPILED_SOURCES}) +target_compile_definitions(PowerRecomp PRIVATE CONFIG_FILE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/config/SWA.toml\") -target_include_directories(UnleashedRecompLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +set(SWA_PPC_RECOMPILED_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/ppc/ppc_config.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ppc/ppc_context.h" + "${CMAKE_CURRENT_SOURCE_DIR}/ppc/ppc_func_mapping.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/ppc/ppc_recomp_shared.h" +) -target_precompile_headers(UnleashedRecompLib PUBLIC ppc/ppc_recomp_shared.h) +foreach(i RANGE 0 260) + list(APPEND SWA_PPC_RECOMPILED_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ppc/ppc_recomp.${i}.cpp") +endforeach() -target_compile_definitions(PowerRecomp PRIVATE - CONFIG_FILE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/config/SWA.toml\") +add_custom_command( + OUTPUT ${SWA_PPC_RECOMPILED_SOURCES} + COMMAND PowerRecomp + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/config/SWA.toml" +) target_compile_definitions(ShaderRecomp PRIVATE SHADER_RECOMP_INPUT=\"${CMAKE_CURRENT_SOURCE_DIR}/private\" - SHADER_RECOMP_OUTPUT=\"${CMAKE_CURRENT_SOURCE_DIR}/shader/shader_cache.cpp\") + SHADER_RECOMP_OUTPUT=\"${CMAKE_CURRENT_SOURCE_DIR}/shader/shader_cache.cpp\" +) + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/shader/shader_cache.cpp" + COMMAND ShaderRecomp + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/private/shader.ar" +) + +add_library(UnleashedRecompLib + ${SWA_PPC_RECOMPILED_SOURCES} + "shader/shader_cache.h" + "shader/shader_cache.cpp" +) + +target_include_directories(UnleashedRecompLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_precompile_headers(UnleashedRecompLib PUBLIC "ppc/ppc_recomp_shared.h") diff --git a/UnleashedRecompLib/main.cpp b/UnleashedRecompLib/main.cpp deleted file mode 100644 index e69de29..0000000