mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2024-11-23 21:29:22 +01:00
Rename cmake project, embed data for custom code directly into executable instead of a separate file
This commit is contained in:
parent
86d805de8d
commit
de35dfc8a8
@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(MMRecomp)
|
project(Zelda64Recompiled)
|
||||||
set(CMAKE_C_STANDARD 17)
|
set(CMAKE_C_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@ -66,6 +66,7 @@ target_include_directories(PatchesLib PRIVATE
|
|||||||
|
|
||||||
target_sources(PatchesLib PRIVATE
|
target_sources(PatchesLib PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c
|
${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c
|
||||||
|
${CMAKE_SOURCE_DIR}/RecompiledPatches/patches_bin.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set_source_files_properties(${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
|
set_source_files_properties(${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
|
||||||
@ -77,6 +78,12 @@ add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/patches/patches.elf
|
|||||||
BYPRODUCTS ${CMAKE_SOURCE_DIR}/patches/patches.bin}
|
BYPRODUCTS ${CMAKE_SOURCE_DIR}/patches/patches.bin}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Generate patches_bin.c from patches.bin
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/RecompiledPatches/patches_bin.c
|
||||||
|
COMMAND file_to_c ${CMAKE_SOURCE_DIR}/patches/patches.bin mm_patches_bin ${CMAKE_SOURCE_DIR}/RecompiledPatches/patches_bin.c ${CMAKE_SOURCE_DIR}/RecompiledPatches/patches_bin.h
|
||||||
|
DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.elf ${CMAKE_SOURCE_DIR}/patches/patches.bin
|
||||||
|
)
|
||||||
|
|
||||||
# Recompile patches elf into patches.c
|
# Recompile patches elf into patches.c
|
||||||
add_custom_command(OUTPUT
|
add_custom_command(OUTPUT
|
||||||
${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c
|
${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c
|
||||||
@ -89,7 +96,7 @@ add_custom_command(OUTPUT
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Main executable
|
# Main executable
|
||||||
add_executable(MMRecomp)
|
add_executable(Zelda64Recompiled)
|
||||||
|
|
||||||
set (SOURCES
|
set (SOURCES
|
||||||
${CMAKE_SOURCE_DIR}/ultramodern/audio.cpp
|
${CMAKE_SOURCE_DIR}/ultramodern/audio.cpp
|
||||||
@ -153,7 +160,7 @@ set (SOURCES
|
|||||||
${CMAKE_SOURCE_DIR}/lib/RmlUi/Backends/RmlUi_Platform_SDL.cpp
|
${CMAKE_SOURCE_DIR}/lib/RmlUi/Backends/RmlUi_Platform_SDL.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(MMRecomp PRIVATE
|
target_include_directories(Zelda64Recompiled PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/include
|
${CMAKE_SOURCE_DIR}/include
|
||||||
${CMAKE_SOURCE_DIR}/lib/concurrentqueue
|
${CMAKE_SOURCE_DIR}/lib/concurrentqueue
|
||||||
${CMAKE_SOURCE_DIR}/lib/GamepadMotionHelpers
|
${CMAKE_SOURCE_DIR}/lib/GamepadMotionHelpers
|
||||||
@ -170,7 +177,7 @@ target_include_directories(MMRecomp PRIVATE
|
|||||||
${CMAKE_BINARY_DIR}/shaders
|
${CMAKE_BINARY_DIR}/shaders
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(MMRecomp PRIVATE
|
target_compile_options(Zelda64Recompiled PRIVATE
|
||||||
-march=nehalem
|
-march=nehalem
|
||||||
-fno-strict-aliasing
|
-fno-strict-aliasing
|
||||||
-fms-extensions
|
-fms-extensions
|
||||||
@ -185,23 +192,23 @@ if (WIN32)
|
|||||||
URL_HASH MD5=d8173db078e54040c666f411c5a6afff
|
URL_HASH MD5=d8173db078e54040c666f411c5a6afff
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(sdl2)
|
FetchContent_MakeAvailable(sdl2)
|
||||||
target_include_directories(MMRecomp PRIVATE
|
target_include_directories(Zelda64Recompiled PRIVATE
|
||||||
${sdl2_SOURCE_DIR}/include
|
${sdl2_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
target_link_directories(MMRecomp PRIVATE
|
target_link_directories(Zelda64Recompiled PRIVATE
|
||||||
${sdl2_SOURCE_DIR}/lib/x64
|
${sdl2_SOURCE_DIR}/lib/x64
|
||||||
)
|
)
|
||||||
|
|
||||||
# Copy SDL2 and dxc DLLs to output folder as post build step
|
# Copy SDL2 and dxc DLLs to output folder as post build step
|
||||||
add_custom_command(TARGET MMRecomp POST_BUILD
|
add_custom_command(TARGET Zelda64Recompiled POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
"${sdl2_SOURCE_DIR}/lib/x64/SDL2.dll"
|
"${sdl2_SOURCE_DIR}/lib/x64/SDL2.dll"
|
||||||
"${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/contrib/dxc/bin/x64/dxil.dll"
|
"${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/contrib/dxc/bin/x64/dxil.dll"
|
||||||
"${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/contrib/dxc/bin/x64/dxcompiler.dll"
|
"${CMAKE_SOURCE_DIR}/lib/RT64-HLE/src/contrib/dxc/bin/x64/dxcompiler.dll"
|
||||||
$<TARGET_FILE_DIR:MMRecomp>)
|
$<TARGET_FILE_DIR:Zelda64Recompiled>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(MMRecomp PRIVATE
|
target_link_libraries(Zelda64Recompiled PRIVATE
|
||||||
PatchesLib
|
PatchesLib
|
||||||
RecompiledFuncs
|
RecompiledFuncs
|
||||||
SDL2
|
SDL2
|
||||||
@ -230,14 +237,14 @@ else()
|
|||||||
set (DXC "LD_LIBRARY_PATH=${PROJECT_SOURCE_DIR}/lib/RT64-HLE/src/src/contrib/dxc/lib/x64" "${PROJECT_SOURCE_DIR}/src/contrib/dxc/bin/x64/dxc")
|
set (DXC "LD_LIBRARY_PATH=${PROJECT_SOURCE_DIR}/lib/RT64-HLE/src/src/contrib/dxc/lib/x64" "${PROJECT_SOURCE_DIR}/src/contrib/dxc/bin/x64/dxc")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
build_vertex_shader(MMRecomp "shaders/InterfaceVS.hlsl" "shaders/InterfaceVS.hlsl")
|
build_vertex_shader(Zelda64Recompiled "shaders/InterfaceVS.hlsl" "shaders/InterfaceVS.hlsl")
|
||||||
build_pixel_shader (MMRecomp "shaders/InterfacePS.hlsl" "shaders/InterfacePS.hlsl")
|
build_pixel_shader (Zelda64Recompiled "shaders/InterfacePS.hlsl" "shaders/InterfacePS.hlsl")
|
||||||
|
|
||||||
target_sources(MMRecomp PRIVATE ${SOURCES})
|
target_sources(Zelda64Recompiled PRIVATE ${SOURCES})
|
||||||
|
|
||||||
set_property(TARGET MMRecomp PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
set_property(TARGET Zelda64Recompiled PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
||||||
|
|
||||||
add_custom_command(TARGET MMRecomp POST_BUILD
|
add_custom_command(TARGET Zelda64Recompiled POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
${CMAKE_BINARY_DIR}/${RT64_DLL}
|
${CMAKE_BINARY_DIR}/${RT64_DLL}
|
||||||
${CMAKE_SOURCE_DIR}
|
${CMAKE_SOURCE_DIR}
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
{
|
{
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"project": "CMakeLists.txt",
|
"project": "CMakeLists.txt",
|
||||||
"projectTarget": "MMRecomp.exe",
|
"projectTarget": "Zelda64Recompiled.exe",
|
||||||
"name": "MMRecomp.exe",
|
"name": "Zelda64Recompiled.exe",
|
||||||
"currentDir": "${workspaceRoot}"
|
"currentDir": "${workspaceRoot}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "recomp_config.h"
|
#include "recomp_config.h"
|
||||||
#include "xxHash/xxh3.h"
|
#include "xxHash/xxh3.h"
|
||||||
#include "../ultramodern/ultramodern.hpp"
|
#include "../ultramodern/ultramodern.hpp"
|
||||||
|
#include "../../RecompiledPatches/patches_bin.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define EXPORT __declspec(dllexport)
|
#define EXPORT __declspec(dllexport)
|
||||||
@ -310,24 +311,8 @@ extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size);
|
|||||||
extern "C" void unload_overlays(int32_t ram_addr, uint32_t size);
|
extern "C" void unload_overlays(int32_t ram_addr, uint32_t size);
|
||||||
|
|
||||||
void read_patch_data(uint8_t* rdram, gpr patch_data_address) {
|
void read_patch_data(uint8_t* rdram, gpr patch_data_address) {
|
||||||
const char patches_data_file_path[] = "patches/patches.bin";
|
for (size_t i = 0; i < sizeof(mm_patches_bin); i++) {
|
||||||
std::ifstream patches_data_file{ patches_data_file_path, std::ios::binary };
|
MEM_B(i, patch_data_address) = mm_patches_bin[i];
|
||||||
|
|
||||||
if (!patches_data_file) {
|
|
||||||
fprintf(stderr, "Failed to open patches data file: %s\n", patches_data_file_path);
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
patches_data_file.seekg(0, std::ios::end);
|
|
||||||
size_t patches_data_size = patches_data_file.tellg();
|
|
||||||
patches_data_file.seekg(0, std::ios::beg);
|
|
||||||
|
|
||||||
std::unique_ptr<uint8_t[]> patches_data = std::make_unique<uint8_t[]>(patches_data_size);
|
|
||||||
|
|
||||||
patches_data_file.read(reinterpret_cast<char*>(patches_data.get()), patches_data_size);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < patches_data_size; i++) {
|
|
||||||
MEM_B(i, patch_data_address) = patches_data[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user