From 1ea7d4ebe9dcf522faa13cab513f88c3217ba011 Mon Sep 17 00:00:00 2001 From: Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com> Date: Sun, 26 May 2024 14:24:13 -0400 Subject: [PATCH] v1.1.0 (#271) * Update RT64 to correctly report errors for shader model 5.1 GPUs * Fixed Windows filesystem error crash * Force audio driver selection to wasapi on Windows to prevent audio issue --- CMakeLists.txt | 20 ++++++++++---------- lib/rt64 | 2 +- src/main/main.cpp | 4 ++++ src/recomp/pi.cpp | 29 ++++++++++++++++++----------- src/ui/ui_launcher.cpp | 2 +- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 299dadf..6262d24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,16 +87,6 @@ add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/RecompiledPatches/patches_bin.c DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.bin ) -# Generate mm_shader_cache.c from the MM shader cache if it exists -if (EXISTS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin) - set(HAS_MM_SHADER_CACHE TRUE) - add_compile_definitions(HAS_MM_SHADER_CACHE) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h - COMMAND file_to_c ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin mm_shader_cache_bytes ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h - DEPENDS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin - ) -endif() - # Recompile patches elf into patches.c add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/RecompiledPatches/patches.c @@ -111,6 +101,16 @@ add_custom_command(OUTPUT # Main executable add_executable(Zelda64Recompiled) +# Generate mm_shader_cache.c from the MM shader cache if it exists +if (EXISTS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin) + set(HAS_MM_SHADER_CACHE TRUE) + target_compile_definitions(Zelda64Recompiled PRIVATE HAS_MM_SHADER_CACHE) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h + COMMAND file_to_c ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin mm_shader_cache_bytes ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h + DEPENDS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin + ) +endif() + set (SOURCES ${CMAKE_SOURCE_DIR}/ultramodern/audio.cpp ${CMAKE_SOURCE_DIR}/ultramodern/events.cpp diff --git a/lib/rt64 b/lib/rt64 index 64b9e16..1adcbea 160000 --- a/lib/rt64 +++ b/lib/rt64 @@ -1 +1 @@ -Subproject commit 64b9e166f75b4dc44a59983b67c3e9ecc1f4cfd7 +Subproject commit 1adcbea31a04f2403da729eb5dfed3950dd7ec52 diff --git a/src/main/main.cpp b/src/main/main.cpp index e2a60f5..3cc2893 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -323,6 +323,10 @@ int main(int argc, char** argv) { SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi); #endif +#ifdef _WIN32 + // Force wasapi on Windows, as there seems to be some issue with sample queueing with directsound currently. + SDL_setenv("SDL_AUDIODRIVER", "wasapi", true); +#endif //printf("Current dir: %ls\n", std::filesystem::current_path().c_str()); // Initialize SDL audio and set the output frequency. diff --git a/src/recomp/pi.cpp b/src/recomp/pi.cpp index 224e7b0..592a234 100644 --- a/src/recomp/pi.cpp +++ b/src/recomp/pi.cpp @@ -112,20 +112,27 @@ std::filesystem::path get_save_file_path_backup() { } void update_save_file() { - std::ofstream save_file{ get_save_file_path_temp(), std::ios_base::binary }; + { + std::ofstream save_file{ get_save_file_path_temp(), std::ios_base::binary }; - if (save_file.good()) { - std::lock_guard lock{ save_context.save_buffer_mutex }; - save_file.write(save_context.save_buffer.data(), save_context.save_buffer.size()); - if (std::filesystem::exists(get_save_file_path())) { - std::filesystem::rename(get_save_file_path(),get_save_file_path_backup()); - } else { - printf("\nSavefile doesn't exist. Skip renaming."); + if (save_file.good()) { + std::lock_guard lock{ save_context.save_buffer_mutex }; + save_file.write(save_context.save_buffer.data(), save_context.save_buffer.size()); } - std::filesystem::rename(get_save_file_path_temp(),get_save_file_path()); - } else { + else { + recomp::message_box("Failed to write to the save file. Check your file permissions. If you have moved your appdata folder to Dropbox or similar, this can cause issues."); + } + } + std::error_code ec; + if (std::filesystem::exists(get_save_file_path(), ec)) { + std::filesystem::copy_file(get_save_file_path(), get_save_file_path_backup(), std::filesystem::copy_options::overwrite_existing, ec); + if (ec) { + printf("[ERROR] Failed to copy save file backup\n"); + } + } + std::filesystem::copy_file(get_save_file_path_temp(), get_save_file_path(), std::filesystem::copy_options::overwrite_existing, ec); + if (ec) { recomp::message_box("Failed to write to the save file. Check your file permissions. If you have moved your appdata folder to Dropbox or similar, this can cause issues."); - //std::exit(EXIT_FAILURE); } } diff --git a/src/ui/ui_launcher.cpp b/src/ui/ui_launcher.cpp index 5c25218..fe56352 100644 --- a/src/ui/ui_launcher.cpp +++ b/src/ui/ui_launcher.cpp @@ -6,7 +6,7 @@ #include "nfd.h" #include -std::string version_number = "v1.0.1"; +std::string version_number = "v1.1.0"; Rml::DataModelHandle model_handle; bool mm_rom_valid = false;