diff --git a/librecomp/CMakeLists.txt b/librecomp/CMakeLists.txt index 2445453..745769a 100644 --- a/librecomp/CMakeLists.txt +++ b/librecomp/CMakeLists.txt @@ -29,7 +29,15 @@ add_library(librecomp STATIC "${CMAKE_CURRENT_SOURCE_DIR}/src/ultra_translation.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/vi.cpp") -target_include_directories(librecomp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_include_directories(librecomp PRIVATE "${CMAKE_SOURCE_DIR}/rt64/src/contrib") +target_include_directories(librecomp PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_SOURCE_DIR}/ultramodern/include" + "${CMAKE_SOURCE_DIR}/thirdparty/concurrentqueue" +) +target_include_directories(librecomp PRIVATE + "${CMAKE_SOURCE_DIR}/rt64/src/contrib" +) + target_compile_options(librecomp PRIVATE -Wno-deprecated-declarations) + target_link_libraries(librecomp PRIVATE ultramodern) diff --git a/librecomp/include/recomp_game.h b/librecomp/include/recomp_game.h index 39b2828..fccbfc9 100644 --- a/librecomp/include/recomp_game.h +++ b/librecomp/include/recomp_game.h @@ -43,6 +43,10 @@ namespace recomp { void message_box(const char* message); std::filesystem::path get_app_folder_path(); std::u8string current_game_id(); + + // TODO: implement both + const std::u8string& get_program_id(); + void set_program_id(const std::u8string& program_id); } #endif diff --git a/librecomp/src/recomp.cpp b/librecomp/src/recomp.cpp index ced7c38..b16f5d6 100644 --- a/librecomp/src/recomp.cpp +++ b/librecomp/src/recomp.cpp @@ -1,6 +1,3 @@ -#ifdef _WIN32 -#include -#endif #include #include #include @@ -10,6 +7,14 @@ #include #include #include +#include + +#ifdef _WIN32 +#include +#elif defined(__linux__) +#include +#endif + #include "recomp.h" #include "recomp_overlays.h" #include "recomp_game.h" @@ -97,7 +102,7 @@ std::filesystem::path recomp::get_app_folder_path() { PWSTR known_path = NULL; HRESULT result = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &known_path); if (result == S_OK) { - recomp_dir = std::filesystem::path{known_path} / recomp::program_id; + recomp_dir = std::filesystem::path{known_path} / recomp::get_program_id(); } CoTaskMemFree(known_path); @@ -109,7 +114,7 @@ std::filesystem::path recomp::get_app_folder_path() { } if (homedir != nullptr) { - recomp_dir = std::filesystem::path{homedir} / (std::u8string{u8".config/"} + std::u8string{recomp::program_id}); + recomp_dir = std::filesystem::path{homedir} / (std::u8string{u8".config/"} + recomp::get_program_id()); } #endif @@ -447,9 +452,9 @@ void recomp::start(ultramodern::WindowHandle window_handle, const ultramodern::a std::thread game_thread{[](ultramodern::WindowHandle window_handle, uint8_t* rdram) { debug_printf("[Recomp] Starting\n"); - + ultramodern::set_native_thread_name("Game Start Thread"); - + ultramodern::preinit(rdram, window_handle); game_status.wait(GameStatus::None); @@ -458,25 +463,31 @@ void recomp::start(ultramodern::WindowHandle window_handle, const ultramodern::a switch (game_status.load()) { // TODO refactor this to allow a project to specify what entrypoint function to run for a give game. case GameStatus::Running: - if (!recomp::load_stored_rom(current_game.value())) { - recomp::message_box("Error opening stored ROM! Please restart this program."); + { + if (!recomp::load_stored_rom(current_game.value())) { + recomp::message_box("Error opening stored ROM! Please restart this program."); + } + + auto find_it = game_roms.find(current_game.value()); + const recomp::GameEntry& game_entry = find_it->second; + + ultramodern::load_shader_cache(game_entry.cache_data); + init(rdram, &context); + try { + recomp_entrypoint(rdram, &context); + } catch (ultramodern::thread_terminated& terminated) { + + } } - - auto find_it = game_roms.find(current_game.value()); - const recomp::GameEntry& game_entry = find_it->second; - - ultramodern::load_shader_cache(game_entry.cache_data); - init(rdram, &context); - try { - recomp_entrypoint(rdram, &context); - } catch (ultramodern::thread_terminated& terminated) { - - } break; + case GameStatus::Quit: break; + + case GameStatus::None: + break; } - + debug_printf("[Recomp] Quitting\n"); }, window_handle, rdram_buffer.get()};