Changes to fix compilation on linux

This commit is contained in:
Mr-Wiseguy 2024-04-21 14:18:33 -04:00
parent 68ee43f5ac
commit a6e34bb49b
8 changed files with 39 additions and 18 deletions

View File

@ -20,7 +20,9 @@ endif()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/") if (WIN32)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/")
endif()
set(RT64_STATIC TRUE) set(RT64_STATIC TRUE)
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/rt64 ${CMAKE_BINARY_DIR}/rt64) add_subdirectory(${CMAKE_SOURCE_DIR}/lib/rt64 ${CMAKE_BINARY_DIR}/rt64)
@ -90,7 +92,7 @@ add_custom_command(OUTPUT
${CMAKE_SOURCE_DIR}/RecompiledPatches/recomp_overlays.inl ${CMAKE_SOURCE_DIR}/RecompiledPatches/recomp_overlays.inl
${CMAKE_SOURCE_DIR}/RecompiledPatches/funcs.h ${CMAKE_SOURCE_DIR}/RecompiledPatches/funcs.h
${CMAKE_SOURCE_DIR}/src/recomp/patch_loading.cpp ${CMAKE_SOURCE_DIR}/src/recomp/patch_loading.cpp
COMMAND RecompPort patches.toml && ${CMAKE_COMMAND} -E touch ${CMAKE_SOURCE_DIR}/src/recomp/patch_loading.cpp COMMAND ./N64Recomp patches.toml && ${CMAKE_COMMAND} -E touch ${CMAKE_SOURCE_DIR}/src/recomp/patch_loading.cpp
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.bin DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.bin
) )
@ -211,6 +213,29 @@ if (WIN32)
target_sources(Zelda64Recompiled PRIVATE ${CMAKE_SOURCE_DIR}/icons/app.rc) target_sources(Zelda64Recompiled PRIVATE ${CMAKE_SOURCE_DIR}/icons/app.rc)
endif() endif()
if (LINUX)
find_package(X11 REQUIRED)
message(STATUS "X11_FOUND = ${X11_FOUND}")
message(STATUS "X11_Xrandr_FOUND = ${X11_Xrandr_FOUND}")
message(STATUS "X11_INCLUDE_DIR = ${X11_INCLUDE_DIR}")
message(STATUS "X11_LIBRARIES = ${X11_LIBRARIES}")
include_directories(${X11_INCLUDE_DIR} ${X11_Xrandr_INCLUDE_PATH})
target_link_libraries(Zelda64Recompiled PRIVATE ${X11_LIBRARIES} ${X11_Xrandr_LIB})
find_package(Freetype REQUIRED)
message(STATUS "FREETYPE_FOUND = ${FREETYPE_FOUND}")
message(STATUS "FREETYPE_INCLUDE_DIRS = ${FREETYPE_INCLUDE_DIRS}")
message(STATUS "FREETYPE_LIBRARIES = ${FREETYPE_LIBRARIES}")
include_directories(${FREETYPE_LIBRARIES})
target_link_libraries(Zelda64Recompiled PRIVATE ${FREETYPE_LIBRARIES})
target_link_libraries(Zelda64Recompiled PRIVATE "-latomic")
endif()
target_link_libraries(Zelda64Recompiled PRIVATE target_link_libraries(Zelda64Recompiled PRIVATE
PatchesLib PatchesLib
RecompiledFuncs RecompiledFuncs
@ -237,7 +262,7 @@ if (${WIN32})
set (DXC "${PROJECT_SOURCE_DIR}/lib/rt64/src/contrib/dxc/bin/x64/dxc.exe") set (DXC "${PROJECT_SOURCE_DIR}/lib/rt64/src/contrib/dxc/bin/x64/dxc.exe")
add_compile_definitions(NOMINMAX) add_compile_definitions(NOMINMAX)
else() else()
set (DXC "LD_LIBRARY_PATH=${PROJECT_SOURCE_DIR}/lib/rt64/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/src/src/contrib/dxc/lib/x64" "${PROJECT_SOURCE_DIR}/lib/rt64/src/contrib/dxc/bin/x64/dxc")
endif() endif()
build_vertex_shader(Zelda64Recompiled "shaders/InterfaceVS.hlsl" "shaders/InterfaceVS.hlsl") build_vertex_shader(Zelda64Recompiled "shaders/InterfaceVS.hlsl" "shaders/InterfaceVS.hlsl")

View File

@ -114,7 +114,7 @@ std::filesystem::path recomp::get_app_folder_path() {
} }
if (homedir != nullptr) { if (homedir != nullptr) {
recomp_dir = std::filesystem::path{homedir} / (std::string{"."} + recomp::program_id); recomp_dir = std::filesystem::path{homedir} / (std::u8string{u8"."} + std::u8string{recomp::program_id});
} }
#endif #endif

View File

@ -380,12 +380,9 @@ void recomp::set_rumble(bool on) {
InputState.rumble_active = on; InputState.rumble_active = on;
} }
static float lerp(float from, float to, float amount) {
return (from + (to - from) * amount);
}
static float smoothstep(float from, float to, float amount) { static float smoothstep(float from, float to, float amount) {
amount = (amount * amount) * (3.0f - 2.0f * amount); amount = (amount * amount) * (3.0f - 2.0f * amount);
return lerp(from, to, amount); return std::lerp(from, to, amount);
} }
// Update rumble to attempt to mimic the way n64 rumble ramps up and falls off // Update rumble to attempt to mimic the way n64 rumble ramps up and falls off

View File

@ -39,7 +39,7 @@ extern "C" void recomp_powf(uint8_t* rdram, recomp_context* ctx) {
float a = _arg<0, float>(rdram, ctx); float a = _arg<0, float>(rdram, ctx);
float b = ctx->f14.fl; //_arg<1, float>(rdram, ctx); float b = ctx->f14.fl; //_arg<1, float>(rdram, ctx);
_return(ctx, std::powf(a, b)); _return(ctx, std::pow(a, b));
} }
extern "C" void recomp_get_target_framerate(uint8_t* rdram, recomp_context* ctx) { extern "C" void recomp_get_target_framerate(uint8_t* rdram, recomp_context* ctx) {

View File

@ -17,12 +17,6 @@
#include "../ultramodern/ultramodern.hpp" #include "../ultramodern/ultramodern.hpp"
#include "../../RecompiledPatches/patches_bin.h" #include "../../RecompiledPatches/patches_bin.h"
#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __attribute__((visibility("default")))
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
inline uint32_t byteswap(uint32_t val) { inline uint32_t byteswap(uint32_t val) {
return _byteswap_ulong(val); return _byteswap_ulong(val);
@ -49,7 +43,7 @@ bool check_hash(const std::vector<uint8_t>& rom_data, uint64_t expected_hash) {
return calculated_hash == expected_hash; return calculated_hash == expected_hash;
} }
std::vector<uint8_t> read_file(const std::filesystem::path& path) { static std::vector<uint8_t> read_file(const std::filesystem::path& path) {
std::vector<uint8_t> ret; std::vector<uint8_t> ret;
std::ifstream file{ path, std::ios::binary}; std::ifstream file{ path, std::ios::binary};

View File

@ -68,7 +68,7 @@ struct TextureHandle {
std::unique_ptr<RT64::RenderDescriptorSet> set; std::unique_ptr<RT64::RenderDescriptorSet> set;
}; };
std::vector<char> read_file(const std::filesystem::path& filepath) { static std::vector<char> read_file(const std::filesystem::path& filepath) {
std::vector<char> ret{}; std::vector<char> ret{};
std::ifstream input_file{ filepath, std::ios::binary }; std::ifstream input_file{ filepath, std::ios::binary };

View File

@ -175,7 +175,11 @@ ultramodern::RT64Context::RT64Context(uint8_t* rdram, ultramodern::WindowHandle
} }
// Set up the RT64 application. // Set up the RT64 application.
if (!app->setup(window_handle.thread_id)) { uint32_t thread_id = 0;
#ifdef _WIN32
thread_id = window_handle.thread_id;
#endif
if (!app->setup(thread_id)) {
app = nullptr; app = nullptr;
return; return;
} }

View File

@ -20,6 +20,7 @@
# undef None # undef None
# undef Status # undef Status
# undef LockMask # undef LockMask
# undef Always
#endif #endif
struct UltraThreadContext { struct UltraThreadContext {