diff --git a/CMakeLists.txt b/CMakeLists.txt index c659a485..80e9b08e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -537,3 +537,22 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") ) endif() endif() + +include(ExternalProject) +ExternalProject_Add(Torch + PREFIX Torch + SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch +) +ExternalProject_Get_Property(Torch install_dir) +set(TORCH_EXECUTABLE ${install_dir}/src/Torch-build/$/torch) +add_custom_target( + ExtractAssets + DEPENDS Torch + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 + COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64 + # COMMAND ${TORCH_EXECUTABLE} pack assets starship.otr + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr" + # COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" +) \ No newline at end of file diff --git a/config.yml b/config.yml index 8a2b8854..69ba91ea 100644 --- a/config.yml +++ b/config.yml @@ -8,7 +8,7 @@ f7475fb11e7e6830f82883412638e8390791ab87: sort: OFFSET # logging: ERROR output: - binary: starship.otr + binary: sf64.otr code: src/assets headers: include/assets modding: src/assets @@ -27,7 +27,7 @@ d064229a32cc05ab85e2381ce07744eb3ffaf530: gbi: F3DEX sort: OFFSET output: - binary: starship.otr + binary: sf64.otr code: src/assets headers: include/assets modding: src/assets diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 5669c4e0..f7636761 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -45,7 +44,7 @@ GameEngine::GameEngine() { if (const std::string cube_path = Ship::Context::GetPathRelativeToAppDirectory("starship.otr"); std::filesystem::exists(cube_path)) { OTRFiles.push_back(cube_path); } - if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) { + if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sf64.otr"); std::filesystem::exists(sm64_otr_path)) { OTRFiles.push_back(sm64_otr_path); } if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { @@ -80,7 +79,6 @@ GameEngine::GameEngine() { loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast(LUS::ResourceType::Vertex), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast(LUS::ResourceType::Matrix), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(LUS::ResourceType::Array), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Blob", static_cast(LUS::ResourceType::Blob), 0); } diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp index da0809dc..68c3a3c6 100644 --- a/src/port/GBIMiddleware.cpp +++ b/src/port/GBIMiddleware.cpp @@ -2,7 +2,6 @@ #include "Engine.h" #include "DisplayList.h" -#include "Array.h" extern "C" int GameEngine_OTRSigCheck(const char* data); @@ -31,24 +30,16 @@ extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) { } extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { - auto data = reinterpret_cast(texAddr); + char* imgData = (char*)texAddr; - if (texAddr != 0 && GameEngine_OTRSigCheck(data)) { - const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data); - const auto type = static_cast(res->GetInitData()->Type); + if (texAddr != 0 && GameEngine_OTRSigCheck(imgData)) { + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); - switch(type) { - case LUS::ResourceType::DisplayList: - texAddr = reinterpret_cast(&std::static_pointer_cast(res)->Instructions[0]); - break; - case LUS::ResourceType::Array: - texAddr = reinterpret_cast(std::static_pointer_cast(res)->Vertices.data()); - break; - default: - texAddr = reinterpret_cast(res->GetRawPointer()); - break; + if (res->GetInitData()->Type == (uint32_t) LUS::ResourceType::DisplayList) + texAddr = (uintptr_t)&((std::static_pointer_cast(res))->Instructions[0]); + else { + texAddr = (uintptr_t) res->GetRawPointer(); } } - __gSPInvalidateTexCache(pkt, texAddr); -} +} \ No newline at end of file diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index f73353f0..442738fe 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -111,16 +111,15 @@ void DrawSettingsMenu(){ // })) { // audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f)); // } - // + // static std::unordered_map audioBackendNames = { // { Ship::AudioBackend::WASAPI, "Windows Audio Session API" }, - // { Ship::AudioBackend::PULSE, "PulseAudio" }, // { Ship::AudioBackend::SDL, "SDL" }, // }; - // + // ImGui::Text("Audio API (Needs reload)"); // auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); - // + // if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); // } @@ -136,7 +135,7 @@ void DrawSettingsMenu(){ // if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { // UIWidgets::ReEnableComponent(""); // } - // + // ImGui::EndMenu(); // } @@ -188,7 +187,7 @@ void DrawSettingsMenu(){ { // FPS Slider const int minFps = 30; static int maxFps; - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { maxFps = 360; } else { maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); @@ -256,12 +255,12 @@ void DrawSettingsMenu(){ Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; + CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::FAST3D_DXGI_DX11; UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, { .disabled = matchingRefreshRate }); #endif - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::Tooltip( "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " "visual and does not impact game logic, execution of glitches etc.\n\n" @@ -275,7 +274,7 @@ void DrawSettingsMenu(){ } } // END FPS Slider - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::Spacer(0); if (ImGui::Button("Match Refresh Rate")) { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); @@ -290,7 +289,7 @@ void DrawSettingsMenu(){ UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); @@ -300,17 +299,16 @@ void DrawSettingsMenu(){ static std::unordered_map windowBackendNames = { - { Ship::WindowBackend::DX11, "DirectX" }, - { Ship::WindowBackend::SDL_OPENGL, "OpenGL"}, - { Ship::WindowBackend::SDL_METAL, "Metal" }, - { Ship::WindowBackend::GX2, "GX2"} + { Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" }, + { Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL"}, + { Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" } }; ImGui::Text("Renderer API (Needs reload)"); Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); Ship::WindowBackend configWindowBackend; int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (configWindowBackendId != -1 && configWindowBackendId < static_cast(Ship::WindowBackend::BACKEND_COUNT)) { + if (configWindowBackendId != -1 && configWindowBackendId < static_cast(Ship::WindowBackend::WINDOW_BACKEND_COUNT)) { configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; @@ -364,7 +362,7 @@ void DrawSettingsMenu(){ void DrawMenuBarIcon() { static bool gameIconLoaded = false; if (!gameIconLoaded) { - // Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png"); + // Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("Game_Icon", "textures/icons/gIcon.png", ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); gameIconLoaded = false; }