From 73447f05ab4bc915e13cf4222f536ffc656bfb0a Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 2 Aug 2022 18:09:02 -0400 Subject: [PATCH 01/31] Revert Goron Spin Fix (#1003) * Fixes Goron Wakeup animations * Cleanup of some unneeded code. * Fixes comment spacing * Revert goron's back to spinny behavior with smooth transitions. --- soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c index 4ea819f332..fb4fa44916 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -140,8 +140,6 @@ typedef enum { /* 10 */ ENGO2_ANIM_10, /* 11 */ ENGO2_ANIM_11, /* 12 */ ENGO2_ANIM_12, - /* 13 */ ENGO2_ANIM_13, // Fixed Goron Wakeup Animation - /* 14 */ ENGO2_ANIM_14 // Fixed Biggoron Wakeup Animation } EnGo2Animation; static AnimationInfo sAnimationInfo[] = { @@ -151,8 +149,7 @@ static AnimationInfo sAnimationInfo[] = { { &gGoronAnim_002D80, 1.0f, 0.0f, -1.0f, 0x02, -8.0f }, { &gGoronAnim_00161C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_001A00, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_0021D0, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x01, -8.0f }, { &gGoronAnim_000750, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, - { &gGoronAnim_000D5C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, { &gGoronAnim_004930, 0.0f, 0.0f, -1.0f, 0x00, 0.0f }, - { &gGoronAnim_004930, 0.0f, 1.0f, -1.0f, 0x01, 0.0f }, + { &gGoronAnim_000D5C, 1.0f, 0.0f, -1.0f, 0x00, -8.0f }, }; static EnGo2DustEffectData sDustEffectData[2][4] = { @@ -1344,10 +1341,10 @@ void EnGo2_WakeUp(EnGo2* this, GlobalContext* globalCtx) { } if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { OnePointCutscene_Init(globalCtx, 4200, -99, &this->actor, MAIN_CAM); - Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ((CVar_GetS32("gGoronSpeen", 0) == 1) ? ENGO2_ANIM_10 : ENGO2_ANIM_14)); + Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENGO2_ANIM_10); this->skelAnime.playSpeed = 0.5f; } else { - Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ((CVar_GetS32("gGoronSpeen", 0) == 1) ? ENGO2_ANIM_1 : ENGO2_ANIM_13)); + Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENGO2_ANIM_1); this->skelAnime.playSpeed = 1.0f; } this->actionFunc = func_80A46B40; From d9443d98f0e0af2ff977620c194b31c774450258 Mon Sep 17 00:00:00 2001 From: David Chavez Date: Wed, 3 Aug 2022 00:09:33 +0200 Subject: [PATCH 02/31] Store RGBA Cvar as JSON object (#996) * Store RGBA Cvar as JSON object * Use existing split string method * Extract key setting to var --- .../libultraship/Lib/Mercury/Mercury.cpp | 16 +++------- .../libultraship/Lib/Mercury/Mercury.h | 2 ++ soh/soh/Enhancements/debugconsole.cpp | 31 ++++++++++--------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/libultraship/libultraship/Lib/Mercury/Mercury.cpp b/libultraship/libultraship/Lib/Mercury/Mercury.cpp index d6bf734ea0..009b9c0f98 100644 --- a/libultraship/libultraship/Lib/Mercury/Mercury.cpp +++ b/libultraship/libultraship/Lib/Mercury/Mercury.cpp @@ -6,6 +6,7 @@ #include #include #include +#include namespace fs = std::filesystem; using json = nlohmann::json; @@ -16,18 +17,9 @@ Mercury::Mercury(std::string path) : path_(std::move(path)) { this->reload(); } -std::vector split(const std::string& s, const char delimiter) { - std::vector result; - std::stringstream ss(s); - std::string item; - while (getline(ss, item, delimiter)) { - result.push_back(item); - } - return result; -} - std::string Mercury::formatNestedKey(const std::string& key) { - const std::vector dots = split(key, '.'); + std::vector dots = StringHelper::Split(key, "."); + std::string tmp; if (dots.size() > 1) for (const auto& dot : dots) { @@ -40,7 +32,7 @@ std::string Mercury::formatNestedKey(const std::string& key) { } json Mercury::nested(const std::string& key) { - std::vector dots = split(key, '.'); + std::vector dots = StringHelper::Split(key, "."); if (!this->vjson.is_object()) return this->vjson; json gjson = this->vjson.unflatten(); diff --git a/libultraship/libultraship/Lib/Mercury/Mercury.h b/libultraship/libultraship/Lib/Mercury/Mercury.h index 5c2646d362..92cb2097ee 100644 --- a/libultraship/libultraship/Lib/Mercury/Mercury.h +++ b/libultraship/libultraship/Lib/Mercury/Mercury.h @@ -4,6 +4,8 @@ #include #include "../nlohmann/json.hpp" +static const std::string mercuryRGBAObjectType = "RGBA"; + class Mercury { protected: std::string path_; diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index ba866b0624..73c54b742a 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -568,20 +568,18 @@ void DebugConsole_LoadCVars() { switch (value.type()) { case nlohmann::detail::value_t::array: break; - case nlohmann::detail::value_t::string: - if (StringHelper::StartsWith(value.get(), "#")) - { - uint32_t val = std::stoul(&value.get().c_str()[1], nullptr, 16); + case nlohmann::detail::value_t::object: + if (value["Type"].get() == mercuryRGBAObjectType) { Color_RGBA8 clr; - clr.r = val >> 24; - clr.g = val >> 16; - clr.b = val >> 8; - clr.a = val & 0xFF; - - CVar_SetRGBA(item.key().c_str(), clr); + clr.r = value["R"].get(); + clr.g = value["G"].get(); + clr.b = value["B"].get(); + clr.a = value["A"].get(); } - else - CVar_SetString(item.key().c_str(), value.get().c_str()); + + break; + case nlohmann::detail::value_t::string: + CVar_SetString(item.key().c_str(), value.get().c_str()); break; case nlohmann::detail::value_t::boolean: CVar_SetS32(item.key().c_str(), value.get()); @@ -618,10 +616,13 @@ void DebugConsole_SaveCVars() pConf->setFloat(key, cvar.second->value.valueFloat); else if (cvar.second->type == CVarType::RGBA) { + auto keyStr = key.c_str(); Color_RGBA8 clr = cvar.second->value.valueRGBA; - uint32_t val = (clr.r << 24) + (clr.g << 16) + (clr.b << 8) + clr.a; - std::string str = StringHelper::Sprintf("#%08X", val); - pConf->setString(key, str); + pConf->setUInt(StringHelper::Sprintf("%s.R", keyStr), clr.r); + pConf->setUInt(StringHelper::Sprintf("%s.G", keyStr), clr.r); + pConf->setUInt(StringHelper::Sprintf("%s.B", keyStr), clr.r); + pConf->setUInt(StringHelper::Sprintf("%s.A", keyStr), clr.r); + pConf->setString(StringHelper::Sprintf("%s.Type", keyStr), mercuryRGBAObjectType); } } From 7eba85c3b42ab1ebb2844f329596c311456c74ac Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 2 Aug 2022 18:09:53 -0400 Subject: [PATCH 03/31] Prevents blocking Song of Time check by shielding. (#1001) --- soh/src/code/z_play.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index aa91e43a55..a42fb2f78c 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -200,7 +200,8 @@ void GivePlayerRandoRewardSongOfTime(GlobalContext* globalCtx, RandomizerCheck c !Flags_GetTreasure(globalCtx, 0x1F) && gSaveContext.nextTransition == 0xFF) { GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(check, GI_SONG_OF_TIME); GiveItemWithoutActor(globalCtx, getItemId); - Flags_SetTreasure(globalCtx, 0x1F); + player->pendingFlag.flagID = 0x1F; + player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } } From b3c3882b12a6c8810675abf00c9b3173d9e35114 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Sun, 31 Jul 2022 23:14:54 -0400 Subject: [PATCH 04/31] LUS Cleanup: Make ControlDeck a member of Window --- libultraship/libultraship/ControlDeck.cpp | 16 ++++++++++++ libultraship/libultraship/ControlDeck.h | 9 +++++-- libultraship/libultraship/ImGuiImpl.cpp | 2 +- libultraship/libultraship/InputEditor.cpp | 21 +++++++-------- libultraship/libultraship/Window.cpp | 31 ++++++++++++++--------- libultraship/libultraship/Window.h | 12 +++++---- soh/soh/OTRGlobals.cpp | 15 ++++++----- 7 files changed, 67 insertions(+), 39 deletions(-) diff --git a/libultraship/libultraship/ControlDeck.cpp b/libultraship/libultraship/ControlDeck.cpp index fd6511f783..6e90e1ea39 100644 --- a/libultraship/libultraship/ControlDeck.cpp +++ b/libultraship/libultraship/ControlDeck.cpp @@ -152,3 +152,19 @@ void Ship::ControlDeck::SaveControllerSettings() { Config->save(); } + +std::shared_ptr Ship::ControlDeck::GetPhysicalDevice(int deviceSlot) { + return physicalDevices[deviceSlot]; +} + +size_t Ship::ControlDeck::GetNumPhysicalDevices() { + return physicalDevices.size(); +} + +int Ship::ControlDeck::GetVirtualDevice(int slot) { + return virtualDevices[slot]; +} + +size_t Ship::ControlDeck::GetNumVirtualDevices() { + return virtualDevices.size(); +} \ No newline at end of file diff --git a/libultraship/libultraship/ControlDeck.h b/libultraship/libultraship/ControlDeck.h index fbbaca7abf..7c0f6ea63e 100644 --- a/libultraship/libultraship/ControlDeck.h +++ b/libultraship/libultraship/ControlDeck.h @@ -8,13 +8,18 @@ namespace Ship { class ControlDeck { public: - std::vector virtualDevices; - std::vector> physicalDevices = {}; void Init(uint8_t* controllerBits); void ScanPhysicalDevices(); void WriteToPad(OSContPad* pad) const; void LoadControllerSettings(); void SaveControllerSettings(); void SetPhysicalDevice(int slot, int deviceSlot); + std::shared_ptr GetPhysicalDevice(int deviceSlot); + size_t GetNumPhysicalDevices(); + int GetVirtualDevice(int slot); + size_t GetNumVirtualDevices(); + private: + std::vector virtualDevices; + std::vector> physicalDevices = {}; }; } diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index ef1aec4317..f19ce7eac1 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -792,7 +792,7 @@ namespace SohImGui { bool menu_bar = CVar_GetS32("gOpenMenuBar", 0); CVar_SetS32("gOpenMenuBar", !menu_bar); needs_save = true; - GlobalCtx2::GetInstance()->GetWindow()->dwMenubar = menu_bar; + GlobalCtx2::GetInstance()->GetWindow()->SetMenuBar(menu_bar); ShowCursor(menu_bar, Dialogues::dMenubar); GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->SaveControllerSettings(); if (CVar_GetS32("gControlNav", 0)) { diff --git a/libultraship/libultraship/InputEditor.cpp b/libultraship/libultraship/InputEditor.cpp index eb191cc203..7ebe497526 100644 --- a/libultraship/libultraship/InputEditor.cpp +++ b/libultraship/libultraship/InputEditor.cpp @@ -16,8 +16,8 @@ namespace Ship { } std::shared_ptr GetControllerPerSlot(int slot) { - const std::vector vDevices = Window::ControllerApi->virtualDevices; - return Window::ControllerApi->physicalDevices[vDevices[slot]]; + auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); + return controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(slot)); } void InputEditor::DrawButton(const char* label, int n64Btn) { @@ -82,20 +82,17 @@ namespace Ship { } void InputEditor::DrawControllerSchema() { - - const std::vector vDevices = Window::ControllerApi->virtualDevices; - const std::vector> devices = Window::ControllerApi->physicalDevices; - - std::shared_ptr Backend = devices[vDevices[CurrentPort]]; - DeviceProfile& profile =Backend->profiles[CurrentPort]; + auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); + auto Backend = controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(CurrentPort)); + DeviceProfile& profile = Backend->profiles[CurrentPort]; float sensitivity = profile.Thresholds[SENSITIVITY]; bool IsKeyboard = Backend->GetGuid() == "Keyboard" || Backend->GetGuid() == "Auto" || !Backend->Connected(); const char* ControllerName = Backend->GetControllerName(); if (ControllerName != nullptr && ImGui::BeginCombo("##ControllerEntries", ControllerName)) { - for (uint8_t i = 0; i < devices.size(); i++) { - if (ImGui::Selectable(devices[i]->GetControllerName(), i == vDevices[CurrentPort])) { - Window::ControllerApi->SetPhysicalDevice(CurrentPort, i); + for (uint8_t i = 0; i < controlDeck->GetNumPhysicalDevices(); i++) { + if (ImGui::Selectable(controlDeck->GetPhysicalDevice(i)->GetControllerName(), i == controlDeck->GetVirtualDevice(CurrentPort))) { + controlDeck->SetPhysicalDevice(CurrentPort, i); } } ImGui::EndCombo(); @@ -104,7 +101,7 @@ namespace Ship { ImGui::SameLine(); if(ImGui::Button("Refresh")) { - Window::ControllerApi->ScanPhysicalDevices(); + controlDeck->ScanPhysicalDevices(); } SohImGui::BeginGroupPanel("Buttons", ImVec2(150, 20)); diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index 39d4aad06e..0773a3f31c 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -57,7 +57,7 @@ extern "C" { } #endif - Ship::Window::ControllerApi->Init(controllerBits); + Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->Init(controllerBits); return 0; } @@ -77,7 +77,7 @@ extern "C" { pad->gyro_y = 0; if (!CVar_GetS32("gOpenMenuBar", 0)) { - Ship::Window::ControllerApi->WriteToPad(pad); + Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->WriteToPad(pad); } ModInternal::ExecuteHooks(pad); @@ -221,7 +221,7 @@ namespace Ship { int32_t Window::lastScancode; - Window::Window(std::shared_ptr Context) : Context(Context), APlayer(nullptr) { + Window::Window(std::shared_ptr Context) : Context(Context), APlayer(nullptr), ControllerApi(nullptr) { WmApi = nullptr; RenderingApi = nullptr; bIsFullscreen = false; @@ -259,8 +259,9 @@ namespace Ship { std::shared_ptr pConf = GlobalCtx2::GetInstance()->GetConfig(); CreateDefaults(); + InitializeAudioPlayer(); + InitializeControlDeck(); - SetAudioPlayer(); bIsFullscreen = pConf->getBool("Window.Fullscreen.Enabled", false); if (bIsFullscreen) { @@ -279,7 +280,7 @@ namespace Ship { WmApi->set_fullscreen_changed_callback(OnFullscreenChanged); WmApi->set_keyboard_callbacks(KeyDown, KeyUp, AllKeysUp); - ModInternal::RegisterHook([]() { + ModInternal::RegisterHook([this]() { ControllerApi->SaveControllerSettings(); }); } @@ -347,8 +348,9 @@ namespace Ship { lastScancode = -1; bool bIsProcessed = false; - const auto pad = dynamic_cast(ControllerApi->physicalDevices[ControllerApi->physicalDevices.size() - 2].get()); - if (pad != nullptr) { + auto controlDeck = GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); + const auto pad = dynamic_cast(controlDeck->GetPhysicalDevice(controlDeck->GetNumPhysicalDevices() - 2).get()); + if (pad != nullptr) { if (pad->ReleaseButton(dwScancode)) { bIsProcessed = true; } @@ -359,9 +361,9 @@ namespace Ship { bool Window::KeyDown(int32_t dwScancode) { bool bIsProcessed = false; - - const auto pad = dynamic_cast(ControllerApi->physicalDevices[ControllerApi->physicalDevices.size() - 2].get()); - if (pad != nullptr) { + auto controlDeck = GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); + const auto pad = dynamic_cast(controlDeck->GetPhysicalDevice(controlDeck->GetNumPhysicalDevices() - 2).get()); + if (pad != nullptr) { if (pad->PressButton(dwScancode)) { bIsProcessed = true; } @@ -374,7 +376,8 @@ namespace Ship { void Window::AllKeysUp(void) { - const auto pad = dynamic_cast(ControllerApi->physicalDevices[ControllerApi->physicalDevices.size() - 2].get()); + auto controlDeck = GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); + const auto pad = dynamic_cast(controlDeck->GetPhysicalDevice(controlDeck->GetNumPhysicalDevices() - 2).get()); if (pad != nullptr) { pad->ReleaseAllButtons(); } @@ -400,7 +403,7 @@ namespace Ship { return dwHeight; } - void Window::SetAudioPlayer() { + void Window::InitializeAudioPlayer() { #ifdef _WIN32 APlayer = std::make_shared(); #elif defined(__linux) @@ -409,4 +412,8 @@ namespace Ship { APlayer = std::make_shared(); #endif } + + void Window::InitializeControlDeck() { + ControllerApi = std::make_shared(); + } } diff --git a/libultraship/libultraship/Window.h b/libultraship/libultraship/Window.h index 1fa43abeb2..52737dd379 100644 --- a/libultraship/libultraship/Window.h +++ b/libultraship/libultraship/Window.h @@ -16,7 +16,6 @@ namespace Ship { class Window { public: static int32_t lastScancode; - inline static ControlDeck* ControllerApi = new ControlDeck; Window(std::shared_ptr Context); ~Window(); @@ -32,12 +31,12 @@ namespace Ship { void ToggleFullscreen(); void SetFullscreen(bool bIsFullscreen); void ShowCursor(bool hide); - bool IsFullscreen() { return bIsFullscreen; } uint32_t GetCurrentWidth(); uint32_t GetCurrentHeight(); - ControlDeck* GetControlDeck() { return ControllerApi; }; - uint32_t dwMenubar; + uint32_t GetMenuBar() { return dwMenubar; } + void SetMenuBar(uint32_t dwMenuBar) { this->dwMenubar = dwMenuBar; } + std::shared_ptr GetControlDeck() { return ControllerApi; }; std::shared_ptr GetContext() { return Context.lock(); } std::shared_ptr GetAudioPlayer() { return APlayer; } const char* GetKeyName(int scancode) { return WmApi->get_key_name(scancode); } @@ -48,15 +47,18 @@ namespace Ship { static bool KeyUp(int32_t dwScancode); static void AllKeysUp(void); static void OnFullscreenChanged(bool bIsNowFullscreen); - void SetAudioPlayer(); + void InitializeControlDeck(); + void InitializeAudioPlayer(); std::weak_ptr Context; std::shared_ptr APlayer; + std::shared_ptr ControllerApi; GfxRenderingAPI* RenderingApi; GfxWindowManagerAPI* WmApi; bool bIsFullscreen; uint32_t dwWidth; uint32_t dwHeight; + uint32_t dwMenubar; }; } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index d1d9ebb731..625fdfba88 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1306,10 +1306,11 @@ extern "C" uint32_t OTRGetCurrentHeight() { } extern "C" void OTRControllerCallback(ControllerCallback* controller) { - const auto controllers = Ship::Window::ControllerApi->virtualDevices; + auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); - for (int i = 0; i < controllers.size(); ++i) { - Ship::Window::ControllerApi->physicalDevices[controllers[i]]->WriteToSource(i, controller); + for (int i = 0; i < controlDeck->GetNumVirtualDevices(); ++i) { + auto physicalDevice = controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(i)); + physicalDevice->WriteToSource(i, controller); } } @@ -1363,11 +1364,11 @@ extern "C" void AudioPlayer_Play(const uint8_t* buf, uint32_t len) { } extern "C" int Controller_ShouldRumble(size_t i) { + auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); - const auto controllers = Ship::Window::ControllerApi->virtualDevices; - - for (const auto virtual_entry : controllers) { - if (Ship::Window::ControllerApi->physicalDevices[virtual_entry]->CanRumble()) { + for (int i = 0; i < controlDeck->GetNumVirtualDevices(); ++i) { + auto physicalDevice = controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(i)); + if (physicalDevice->CanRumble()) { return 1; } } From c1659d3dcff2a36fb221e33e885cefc884f8e0dc Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 21:58:30 -0400 Subject: [PATCH 05/31] Adds a function for grabbing physical device from virtual slot. --- libultraship/libultraship/ControlDeck.cpp | 244 +++++++++++----------- libultraship/libultraship/ControlDeck.h | 1 + libultraship/libultraship/InputEditor.cpp | 4 +- libultraship/libultraship/Window.cpp | 4 +- soh/soh/OTRGlobals.cpp | 4 +- 5 files changed, 132 insertions(+), 125 deletions(-) diff --git a/libultraship/libultraship/ControlDeck.cpp b/libultraship/libultraship/ControlDeck.cpp index 6e90e1ea39..31eb900679 100644 --- a/libultraship/libultraship/ControlDeck.cpp +++ b/libultraship/libultraship/ControlDeck.cpp @@ -7,164 +7,170 @@ #include "SDLController.h" #include -uint8_t* controllerBits; +namespace Ship { + uint8_t* controllerBits; -void Ship::ControlDeck::Init(uint8_t* bits) { - ScanPhysicalDevices(); - controllerBits = bits; -} + void ControlDeck::Init(uint8_t* bits) { + ScanPhysicalDevices(); + controllerBits = bits; + } -void Ship::ControlDeck::ScanPhysicalDevices() { + void ControlDeck::ScanPhysicalDevices() { - virtualDevices.clear(); - physicalDevices.clear(); + virtualDevices.clear(); + physicalDevices.clear(); - for (int i = 0; i < SDL_NumJoysticks(); i++) { - if (SDL_IsGameController(i)) { - auto sdl = std::make_shared(i); - sdl->Open(); - physicalDevices.push_back(sdl); - } - } + for (int i = 0; i < SDL_NumJoysticks(); i++) { + if (SDL_IsGameController(i)) { + auto sdl = std::make_shared(i); + sdl->Open(); + physicalDevices.push_back(sdl); + } + } - physicalDevices.push_back(std::make_shared("Auto", "Auto", true)); - physicalDevices.push_back(std::make_shared()); - physicalDevices.push_back(std::make_shared("Disconnected", "None", false)); + physicalDevices.push_back(std::make_shared("Auto", "Auto", true)); + physicalDevices.push_back(std::make_shared()); + physicalDevices.push_back(std::make_shared("Disconnected", "None", false)); - for (const auto& device : physicalDevices) { - for (int i = 0; i < MAXCONTROLLERS; i++) { - device->CreateDefaultBinding(i); - } - } + for (const auto& device : physicalDevices) { + for (int i = 0; i < MAXCONTROLLERS; i++) { + device->CreateDefaultBinding(i); + } + } - for (int i = 0; i < MAXCONTROLLERS; i++) { - virtualDevices.push_back(i == 0 ? 0 : static_cast(physicalDevices.size()) - 1); - } + for (int i = 0; i < MAXCONTROLLERS; i++) { + virtualDevices.push_back(i == 0 ? 0 : static_cast(physicalDevices.size()) - 1); + } - LoadControllerSettings(); -} + LoadControllerSettings(); + } -void Ship::ControlDeck::SetPhysicalDevice(int slot, int deviceSlot) { - const std::shared_ptr backend = physicalDevices[deviceSlot]; - virtualDevices[slot] = deviceSlot; - *controllerBits |= (backend->Connected()) << slot; -} + void ControlDeck::SetPhysicalDevice(int slot, int deviceSlot) { + const std::shared_ptr backend = physicalDevices[deviceSlot]; + virtualDevices[slot] = deviceSlot; + *controllerBits |= (backend->Connected()) << slot; + } -void Ship::ControlDeck::WriteToPad(OSContPad* pad) const { - for (size_t i = 0; i < virtualDevices.size(); i++) { - const std::shared_ptr backend = physicalDevices[virtualDevices[i]]; - if (backend->GetGuid() == "Auto") { - for (const auto& device : physicalDevices) { - device->Read(&pad[i], i); - } - continue; - } - backend->Read(&pad[i], i); - } -} + void ControlDeck::WriteToPad(OSContPad* pad) const { + for (size_t i = 0; i < virtualDevices.size(); i++) { + const std::shared_ptr backend = physicalDevices[virtualDevices[i]]; + if (backend->GetGuid() == "Auto") { + for (const auto& device : physicalDevices) { + device->Read(&pad[i], i); + } + continue; + } + backend->Read(&pad[i], i); + } + } #define NESTED(key, ...) StringHelper::Sprintf("Controllers.%s.Slot_%d." key, device->GetGuid().c_str(), slot, __VA_ARGS__) -void Ship::ControlDeck::LoadControllerSettings() { - std::shared_ptr Config = GlobalCtx2::GetInstance()->GetConfig(); + void ControlDeck::LoadControllerSettings() { + std::shared_ptr Config = GlobalCtx2::GetInstance()->GetConfig(); - for (auto const& val : Config->rjson["Controllers"]["Deck"].items()) { - int slot = std::stoi(val.key().substr(5)); + for (auto const& val : Config->rjson["Controllers"]["Deck"].items()) { + int slot = std::stoi(val.key().substr(5)); - for (size_t dev = 0; dev < physicalDevices.size(); dev++) { - std::string guid = physicalDevices[dev]->GetGuid(); - if(guid != val.value()) continue; + for (size_t dev = 0; dev < physicalDevices.size(); dev++) { + std::string guid = physicalDevices[dev]->GetGuid(); + if (guid != val.value()) continue; - virtualDevices[slot] = dev; - } - } + virtualDevices[slot] = dev; + } + } - for (size_t i = 0; i < virtualDevices.size(); i++) { - std::shared_ptr backend = physicalDevices[virtualDevices[i]]; - Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid()); - } + for (size_t i = 0; i < virtualDevices.size(); i++) { + std::shared_ptr backend = physicalDevices[virtualDevices[i]]; + Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid()); + } - for (const auto& device : physicalDevices) { + for (const auto& device : physicalDevices) { - std::string guid = device->GetGuid(); + std::string guid = device->GetGuid(); - for (int slot = 0; slot < MAXCONTROLLERS; slot++) { + for (int slot = 0; slot < MAXCONTROLLERS; slot++) { - if (!(Config->rjson["Controllers"].contains(guid) && Config->rjson["Controllers"][guid].contains(StringHelper::Sprintf("Slot_%d", slot)))) continue; + if (!(Config->rjson["Controllers"].contains(guid) && Config->rjson["Controllers"][guid].contains(StringHelper::Sprintf("Slot_%d", slot)))) continue; - auto& profile = device->profiles[slot]; - auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)]; + auto& profile = device->profiles[slot]; + auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)]; - profile.Mappings.clear(); - profile.Thresholds.clear(); - profile.UseRumble = Config->getBool(NESTED("Rumble.Enabled", "")); - profile.RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", "")); - profile.UseGyro = Config->getBool(NESTED("Gyro.Enabled", "")); + profile.Mappings.clear(); + profile.Thresholds.clear(); + profile.UseRumble = Config->getBool(NESTED("Rumble.Enabled", "")); + profile.RumbleStrength = Config->getFloat(NESTED("Rumble.Strength", "")); + profile.UseGyro = Config->getBool(NESTED("Gyro.Enabled", "")); - for (auto const& val : rawProfile["Thresholds"].items()) { - profile.Thresholds[static_cast(std::stoi(val.key()))] = val.value(); - } + for (auto const& val : rawProfile["Thresholds"].items()) { + profile.Thresholds[static_cast(std::stoi(val.key()))] = val.value(); + } - for (auto const& val : rawProfile["Mappings"].items()) { - device->SetButtonMapping(slot, std::stoi(val.key().substr(4)), val.value()); - } - } - } -} + for (auto const& val : rawProfile["Mappings"].items()) { + device->SetButtonMapping(slot, std::stoi(val.key().substr(4)), val.value()); + } + } + } + } -void Ship::ControlDeck::SaveControllerSettings() { - std::shared_ptr Config = GlobalCtx2::GetInstance()->GetConfig(); + void ControlDeck::SaveControllerSettings() { + std::shared_ptr Config = GlobalCtx2::GetInstance()->GetConfig(); - for (size_t i = 0; i < virtualDevices.size(); i++) { - std::shared_ptr backend = physicalDevices[virtualDevices[i]]; - Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid()); - } + for (size_t i = 0; i < virtualDevices.size(); i++) { + std::shared_ptr backend = physicalDevices[virtualDevices[i]]; + Config->setString(StringHelper::Sprintf("Controllers.Deck.Slot_%d", (int)i), backend->GetGuid()); + } - for (const auto& device : physicalDevices) { + for (const auto& device : physicalDevices) { - int slot = 0; - std::string guid = device->GetGuid(); + int slot = 0; + std::string guid = device->GetGuid(); - for (const auto& profile : device->profiles) { + for (const auto& profile : device->profiles) { - if (!device->Connected()) continue; + if (!device->Connected()) continue; - auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)]; - Config->setBool(NESTED("Rumble.Enabled", ""), profile.UseRumble); - Config->setFloat(NESTED("Rumble.Strength", ""), profile.RumbleStrength); - Config->setBool(NESTED("Gyro.Enabled", ""), profile.UseGyro); + auto rawProfile = Config->rjson["Controllers"][guid][StringHelper::Sprintf("Slot_%d", slot)]; + Config->setBool(NESTED("Rumble.Enabled", ""), profile.UseRumble); + Config->setFloat(NESTED("Rumble.Strength", ""), profile.RumbleStrength); + Config->setBool(NESTED("Gyro.Enabled", ""), profile.UseGyro); - for (auto const& val : rawProfile["Mappings"].items()) { - Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1); - } + for (auto const& val : rawProfile["Mappings"].items()) { + Config->setInt(NESTED("Mappings.%s", val.key().c_str()), -1); + } - for (auto const& [key, val] : profile.Thresholds) { - Config->setFloat(NESTED("Thresholds.%d", key), val); - } + for (auto const& [key, val] : profile.Thresholds) { + Config->setFloat(NESTED("Thresholds.%d", key), val); + } - for (auto const& [key, val] : profile.Mappings) { - Config->setInt(NESTED("Mappings.BTN_%d", val), key); - } + for (auto const& [key, val] : profile.Mappings) { + Config->setInt(NESTED("Mappings.BTN_%d", val), key); + } - slot++; - } - } + slot++; + } + } - Config->save(); -} + Config->save(); + } -std::shared_ptr Ship::ControlDeck::GetPhysicalDevice(int deviceSlot) { - return physicalDevices[deviceSlot]; -} + std::shared_ptr ControlDeck::GetPhysicalDevice(int deviceSlot) { + return physicalDevices[deviceSlot]; + } -size_t Ship::ControlDeck::GetNumPhysicalDevices() { - return physicalDevices.size(); -} + size_t ControlDeck::GetNumPhysicalDevices() { + return physicalDevices.size(); + } -int Ship::ControlDeck::GetVirtualDevice(int slot) { - return virtualDevices[slot]; -} + int ControlDeck::GetVirtualDevice(int slot) { + return virtualDevices[slot]; + } -size_t Ship::ControlDeck::GetNumVirtualDevices() { - return virtualDevices.size(); + size_t ControlDeck::GetNumVirtualDevices() { + return virtualDevices.size(); + } + + std::shared_ptr ControlDeck::GetPhysicalDeviceFromVirtualSlot(int slot) { + return GetPhysicalDevice(GetVirtualDevice(slot)); + } } \ No newline at end of file diff --git a/libultraship/libultraship/ControlDeck.h b/libultraship/libultraship/ControlDeck.h index 7c0f6ea63e..58c258ca8c 100644 --- a/libultraship/libultraship/ControlDeck.h +++ b/libultraship/libultraship/ControlDeck.h @@ -15,6 +15,7 @@ namespace Ship { void SaveControllerSettings(); void SetPhysicalDevice(int slot, int deviceSlot); std::shared_ptr GetPhysicalDevice(int deviceSlot); + std::shared_ptr GetPhysicalDeviceFromVirtualSlot(int slot); size_t GetNumPhysicalDevices(); int GetVirtualDevice(int slot); size_t GetNumVirtualDevices(); diff --git a/libultraship/libultraship/InputEditor.cpp b/libultraship/libultraship/InputEditor.cpp index 7ebe497526..0ad5c09a09 100644 --- a/libultraship/libultraship/InputEditor.cpp +++ b/libultraship/libultraship/InputEditor.cpp @@ -17,7 +17,7 @@ namespace Ship { std::shared_ptr GetControllerPerSlot(int slot) { auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); - return controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(slot)); + return controlDeck->GetPhysicalDeviceFromVirtualSlot(slot); } void InputEditor::DrawButton(const char* label, int n64Btn) { @@ -83,7 +83,7 @@ namespace Ship { void InputEditor::DrawControllerSchema() { auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); - auto Backend = controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(CurrentPort)); + auto Backend = controlDeck->GetPhysicalDeviceFromVirtualSlot(CurrentPort); DeviceProfile& profile = Backend->profiles[CurrentPort]; float sensitivity = profile.Thresholds[SENSITIVITY]; bool IsKeyboard = Backend->GetGuid() == "Keyboard" || Backend->GetGuid() == "Auto" || !Backend->Connected(); diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index 0773a3f31c..9c11f2d6d5 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -350,7 +350,7 @@ namespace Ship { bool bIsProcessed = false; auto controlDeck = GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); const auto pad = dynamic_cast(controlDeck->GetPhysicalDevice(controlDeck->GetNumPhysicalDevices() - 2).get()); - if (pad != nullptr) { + if (pad != nullptr) { if (pad->ReleaseButton(dwScancode)) { bIsProcessed = true; } @@ -363,7 +363,7 @@ namespace Ship { bool bIsProcessed = false; auto controlDeck = GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); const auto pad = dynamic_cast(controlDeck->GetPhysicalDevice(controlDeck->GetNumPhysicalDevices() - 2).get()); - if (pad != nullptr) { + if (pad != nullptr) { if (pad->PressButton(dwScancode)) { bIsProcessed = true; } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 625fdfba88..2bdf80e682 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1309,7 +1309,7 @@ extern "C" void OTRControllerCallback(ControllerCallback* controller) { auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); for (int i = 0; i < controlDeck->GetNumVirtualDevices(); ++i) { - auto physicalDevice = controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(i)); + auto physicalDevice = controlDeck->GetPhysicalDeviceFromVirtualSlot(i); physicalDevice->WriteToSource(i, controller); } } @@ -1367,7 +1367,7 @@ extern "C" int Controller_ShouldRumble(size_t i) { auto controlDeck = Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck(); for (int i = 0; i < controlDeck->GetNumVirtualDevices(); ++i) { - auto physicalDevice = controlDeck->GetPhysicalDevice(controlDeck->GetVirtualDevice(i)); + auto physicalDevice = controlDeck->GetPhysicalDeviceFromVirtualSlot(i); if (physicalDevice->CanRumble()) { return 1; } From 1bf777198194e766b7e0f6a3b1a64ac129b43a43 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Sun, 31 Jul 2022 23:22:02 -0400 Subject: [PATCH 06/31] LUS Cleanup: Utils.cpp is now in namespace Ship. --- libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp | 6 +++--- libultraship/libultraship/Utils.cpp | 12 ++++++------ libultraship/libultraship/Utils.h | 11 ++++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 10ba45ec52..0a5d0ceef6 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -1065,8 +1065,8 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti dotx /= 127.0f; doty /= 127.0f; - dotx = math::clamp(dotx, -1.0f, 1.0f); - doty = math::clamp(doty, -1.0f, 1.0f); + dotx = Ship::Math::clamp(dotx, -1.0f, 1.0f); + doty = Ship::Math::clamp(doty, -1.0f, 1.0f); if (rsp.geometry_mode & G_TEXTURE_GEN_LINEAR) { // Not sure exactly what formula we should use to get accurate values @@ -1118,7 +1118,7 @@ static void gfx_sp_vertex(size_t n_vertices, size_t dest_index, const Vtx *verti if (winv < 0.0f) winv = std::numeric_limits::max(); float fog_z = z * winv * rsp.fog_mul + rsp.fog_offset; - fog_z = math::clamp(fog_z, 0.0f, 255.0f); + fog_z = Ship::Math::clamp(fog_z, 0.0f, 255.0f); d->color.a = fog_z; // Use alpha variable to store fog factor } else { d->color.a = v->cn[3]; diff --git a/libultraship/libultraship/Utils.cpp b/libultraship/libultraship/Utils.cpp index 2b813aee7d..185c21c249 100644 --- a/libultraship/libultraship/Utils.cpp +++ b/libultraship/libultraship/Utils.cpp @@ -5,14 +5,14 @@ #define strdup _strdup #endif -namespace math { - float clamp(float d, float min, float max) { - const float t = d < min ? min : d; - return t > max ? max : t; +namespace Ship { + namespace Math { + float clamp(float d, float min, float max) { + const float t = d < min ? min : d; + return t > max ? max : t; + } } -} -namespace Utils { std::vector SplitText(const std::string text, char separator = ' ', bool keep_quotes = false) { std::vector args; char* input = strdup(text.c_str()); diff --git a/libultraship/libultraship/Utils.h b/libultraship/libultraship/Utils.h index 25c6dd64b4..1dc3d34914 100644 --- a/libultraship/libultraship/Utils.h +++ b/libultraship/libultraship/Utils.h @@ -3,10 +3,11 @@ #include #include -namespace math { - float clamp(float d, float min, float max); -} +namespace Ship { + + namespace Math { + float clamp(float d, float min, float max); + } -namespace Utils { std::vector SplitText(const std::string& text, char separator, bool keep_quotes); -} +} \ No newline at end of file From 352b46c1f5b79be3320e1e91182122e2dd82b08d Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Sun, 31 Jul 2022 23:36:21 -0400 Subject: [PATCH 07/31] LUS Cleanup: Console class is now in the Ship namespace --- libultraship/libultraship/Console.cpp | 312 +++++++++--------- libultraship/libultraship/Console.h | 140 ++++---- libultraship/libultraship/ImGuiImpl.h | 4 +- .../libultraship/Lib/Fast3D/gfx_dxgi.cpp | 1 - .../include/spdlog/sinks/sohconsole_sink.h | 19 +- soh/soh/Enhancements/debugconsole.cpp | 53 ++- 6 files changed, 266 insertions(+), 263 deletions(-) diff --git a/libultraship/libultraship/Console.cpp b/libultraship/libultraship/Console.cpp index 85ba1f78d2..b7158bd3bc 100644 --- a/libultraship/libultraship/Console.cpp +++ b/libultraship/libultraship/Console.cpp @@ -10,115 +10,116 @@ #include "Utils/StringHelper.h" #include "Lib/ImGui/imgui_internal.h" -std::map Bindings; -std::map BindingToggle; +namespace Ship { + std::map Bindings; + std::map BindingToggle; -static bool HelpCommand(const std::vector&) { - INFO("SoH Commands:"); - for(const auto& cmd : SohImGui::console->Commands) { - INFO("%s", (" - " + cmd.first).c_str()); + static bool HelpCommand(const std::vector&) { + INFO("SoH Commands:"); + for (const auto& cmd : SohImGui::console->Commands) { + INFO("%s", (" - " + cmd.first).c_str()); + } + return CMD_SUCCESS; } - return CMD_SUCCESS; -} -static bool ClearCommand(const std::vector&) { - SohImGui::console->Log[SohImGui::console->selected_channel].clear(); - return CMD_SUCCESS; -} + static bool ClearCommand(const std::vector&) { + SohImGui::console->Log[SohImGui::console->selected_channel].clear(); + return CMD_SUCCESS; + } -std::string toLowerCase(std::string in) { - std::string cpy(in); - std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower); - return cpy; -} + std::string toLowerCase(std::string in) { + std::string cpy(in); + std::transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower); + return cpy; + } -static bool BindCommand(const std::vector& args) { - if(args.size() > 2) { - const ImGuiIO* io = &ImGui::GetIO();; - for (size_t k = 0; k < std::size(io->KeysData); k++) { - std::string key(ImGui::GetKeyName(k)); + static bool BindCommand(const std::vector& args) { + if (args.size() > 2) { + const ImGuiIO* io = &ImGui::GetIO();; + for (size_t k = 0; k < std::size(io->KeysData); k++) { + std::string key(ImGui::GetKeyName(k)); - if(toLowerCase(args[1]) == toLowerCase(key)) { - std::vector tmp; - const char* const delim = " "; - std::ostringstream imploded; - std::copy(args.begin() + 2, args.end(), std::ostream_iterator(imploded, delim)); - Bindings[k] = imploded.str(); - INFO("Binding '%s' to %s", args[1].c_str(), Bindings[k].c_str()); - break; + if (toLowerCase(args[1]) == toLowerCase(key)) { + std::vector tmp; + const char* const delim = " "; + std::ostringstream imploded; + std::copy(args.begin() + 2, args.end(), std::ostream_iterator(imploded, delim)); + Bindings[k] = imploded.str(); + INFO("Binding '%s' to %s", args[1].c_str(), Bindings[k].c_str()); + break; + } + } + } + return CMD_SUCCESS; + } + + static bool BindToggleCommand(const std::vector& args) { + if (args.size() > 2) { + const ImGuiIO* io = &ImGui::GetIO();; + for (size_t k = 0; k < std::size(io->KeysData); k++) { + std::string key(ImGui::GetKeyName(k)); + + if (toLowerCase(args[1]) == toLowerCase(key)) { + BindingToggle[k] = args[2]; + INFO("Binding toggle '%s' to %s", args[1].c_str(), BindingToggle[k].c_str()); + break; + } + } + } + return CMD_SUCCESS; + } + + std::string BuildUsage(const CommandEntry& entry) { + std::string usage; + for (const auto& arg : entry.arguments) + usage += StringHelper::Sprintf(arg.optional ? "[%s] " : "<%s> ", arg.info.c_str()); + return usage; + } + + void Console::Init() { + this->InputBuffer = new char[MAX_BUFFER_SIZE]; + strcpy(this->InputBuffer, ""); + this->FilterBuffer = new char[MAX_BUFFER_SIZE]; + strcpy(this->FilterBuffer, ""); + this->Commands["help"] = { HelpCommand, "Shows all the commands" }; + this->Commands["clear"] = { ClearCommand, "Clear the console history" }; + this->Commands["bind"] = { BindCommand, "Binds key to commands" }; + this->Commands["bind-toggle"] = { BindToggleCommand, "Bind key as a bool toggle" }; + } + + void Console::Update() { + for (auto [key, cmd] : Bindings) { + if (ImGui::IsKeyPressed(key)) Dispatch(cmd); + } + for (auto [key, var] : BindingToggle) { + if (ImGui::IsKeyPressed(key)) { + CVar* cvar = CVar_Get(var.c_str()); + Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast(cvar->value.valueS32))); } } } - return CMD_SUCCESS; -} -static bool BindToggleCommand(const std::vector& args) { - if (args.size() > 2) { - const ImGuiIO* io = &ImGui::GetIO();; - for (size_t k = 0; k < std::size(io->KeysData); k++) { - std::string key(ImGui::GetKeyName(k)); + void Console::Draw() { + bool input_focus = false; + if (!this->opened) return; - if (toLowerCase(args[1]) == toLowerCase(key)) { - BindingToggle[k] = args[2]; - INFO("Binding toggle '%s' to %s", args[1].c_str(), BindingToggle[k].c_str()); - break; - } - } - } - return CMD_SUCCESS; -} - -std::string BuildUsage(const CommandEntry& entry) { - std::string usage; - for (const auto& arg : entry.arguments) - usage += StringHelper::Sprintf(arg.optional ? "[%s] " : "<%s> ", arg.info.c_str()); - return usage; -} - -void Console::Init() { - this->InputBuffer = new char[MAX_BUFFER_SIZE]; - strcpy(this->InputBuffer, ""); - this->FilterBuffer = new char[MAX_BUFFER_SIZE]; - strcpy(this->FilterBuffer, ""); - this->Commands["help"] = { HelpCommand, "Shows all the commands" }; - this->Commands["clear"] = { ClearCommand, "Clear the console history" }; - this->Commands["bind"] = { BindCommand, "Binds key to commands" }; - this->Commands["bind-toggle"] = { BindToggleCommand, "Bind key as a bool toggle" }; -} - -void Console::Update() { - for(auto [key, cmd] : Bindings) { - if (ImGui::IsKeyPressed(key)) Dispatch(cmd); - } - for (auto [key, var] : BindingToggle) { - if (ImGui::IsKeyPressed(key)) { - CVar* cvar = CVar_Get(var.c_str()); - Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast(cvar->value.valueS32))); - } - } -} - -void Console::Draw() { - bool input_focus = false; - if (!this->opened) return; - - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoFocusOnAppearing); const ImVec2 pos = ImGui::GetWindowPos(); const ImVec2 size = ImGui::GetWindowSize(); // SohImGui::ShowCursor(ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows | ImGuiHoveredFlags_RectOnly), SohImGui::Dialogues::dConsole); // Renders autocomplete window - if(this->OpenAutocomplete) { + if (this->OpenAutocomplete) { ImGui::SetNextWindowSize(ImVec2(350, std::min(static_cast(this->Autocomplete.size()), 3) * 20.f), ImGuiCond_Once); ImGui::SetNextWindowPos(ImVec2(pos.x + 8, pos.y + size.y - 1)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3)); - ImGui::Begin("##WndAutocomplete", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove ); + ImGui::Begin("##WndAutocomplete", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove); ImGui::BeginChild("AC_Child", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f)); if (ImGui::BeginTable("AC_History", 1)) { - for (const auto &cmd : this->Autocomplete) { - std::string usage = BuildUsage(this->Commands[cmd]); + for (const auto& cmd : this->Autocomplete) { + std::string usage = BuildUsage(this->Commands[cmd]); std::string preview = cmd + " - " + this->Commands[cmd].description; std::string autocomplete = (usage == NULLSTR ? cmd : usage); ImGui::TableNextRow(); @@ -186,53 +187,53 @@ void Console::Draw() { // Renders console history const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f)); - if (ImGui::BeginTable("History", 1)) { + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(.3f, .3f, .3f, 1.0f)); + if (ImGui::BeginTable("History", 1)) { - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) - if (this->selectedId < (int)this->Log.size() - 1) ++this->selectedId; - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) - if (this->selectedId > 0) --this->selectedId; + if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow))) + if (this->selectedId < (int)this->Log.size() - 1)++this->selectedId; + if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow))) + if (this->selectedId > 0)--this->selectedId; - const std::vector channel = this->Log[this->selected_channel]; - for (int i = 0; i < static_cast(channel.size()); i++) { - ConsoleLine line = channel[i]; - if(!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue; - if(this->level_filter != NULLSTR && line.priority != (std::find(priority_filters.begin(), priority_filters.end(), this->level_filter) - priority_filters.begin()) - 1) continue; - std::string id = line.text + "##" + std::to_string(i); - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end(); - ImGui::PushStyleColor(ImGuiCol_Text, this->priority_colors[line.priority]); - if (ImGui::Selectable(id.c_str(), is_selected)) { - if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected) - this->selectedEntries.push_back(i); + const std::vector channel = this->Log[this->selected_channel]; + for (int i = 0; i < static_cast(channel.size()); i++) { + ConsoleLine line = channel[i]; + if (!this->filter.empty() && line.text.find(this->filter) == std::string::npos) continue; + if (this->level_filter != NULLSTR && line.priority != (std::find(priority_filters.begin(), priority_filters.end(), this->level_filter) - priority_filters.begin()) - 1) continue; + std::string id = line.text + "##" + std::to_string(i); + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + const bool is_selected = (this->selectedId == i) || std::find(this->selectedEntries.begin(), this->selectedEntries.end(), i) != this->selectedEntries.end(); + ImGui::PushStyleColor(ImGuiCol_Text, this->priority_colors[line.priority]); + if (ImGui::Selectable(id.c_str(), is_selected)) { + if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_LeftCtrl)) && !is_selected) + this->selectedEntries.push_back(i); - else this->selectedEntries.clear(); - this->selectedId = is_selected ? -1 : i; - } - ImGui::PopStyleColor(); - if (is_selected) ImGui::SetItemDefaultFocus(); + else this->selectedEntries.clear(); + this->selectedId = is_selected ? -1 : i; } - ImGui::EndTable(); + ImGui::PopStyleColor(); + if (is_selected) ImGui::SetItemDefaultFocus(); } - ImGui::PopStyleColor(); - if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) - ImGui::SetScrollHereY(1.0f); + ImGui::EndTable(); + } + ImGui::PopStyleColor(); + if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) + ImGui::SetScrollHereY(1.0f); ImGui::EndChild(); // Renders input textfield constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit | - ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; + ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; ImGui::PushItemWidth(-53); - if(ImGui::InputTextWithHint("##CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { + if (ImGui::InputTextWithHint("##CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) { input_focus = true; - if(this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') + if (this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') this->Dispatch(std::string(this->InputBuffer)); memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); } - if(this->CMDHint != NULLSTR) { + if (this->CMDHint != NULLSTR) { if (ImGui::IsItemFocused()) { ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y + size.y)); ImGui::SameLine(); @@ -246,38 +247,38 @@ void Console::Draw() { ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50); - if(ImGui::Button("Submit") && !input_focus && this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' '){ - this->Dispatch(std::string(this->InputBuffer)); + if (ImGui::Button("Submit") && !input_focus && this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ') { + this->Dispatch(std::string(this->InputBuffer)); memset(this->InputBuffer, 0, MAX_BUFFER_SIZE); } ImGui::SetItemDefaultFocus(); if (input_focus) ImGui::SetKeyboardFocusHere(-1); ImGui::PopItemWidth(); - ImGui::End(); -} - -void Console::Dispatch(const std::string& line) { - this->CMDHint = NULLSTR; - this->History.push_back(line); - this->Log[this->selected_channel].push_back({ "> " + line } ); - const std::vector cmd_args = StringHelper::Split(line, " "); - if (this->Commands.contains(cmd_args[0])) { - const CommandEntry entry = this->Commands[cmd_args[0]]; - if(!entry.handler(cmd_args) && !entry.arguments.empty()) - this->Log[this->selected_channel].push_back({ "[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry), ERROR_LVL}); - return; + ImGui::End(); } - this->Log[this->selected_channel].push_back({ "[SOH] Command not found", ERROR_LVL }); -} -int Console::CallbackStub(ImGuiInputTextCallbackData* data) { - const auto instance = static_cast(data->UserData); - const bool empty_history = instance->History.empty(); - const int history_index = instance->HistoryIndex; - std::string history; + void Console::Dispatch(const std::string& line) { + this->CMDHint = NULLSTR; + this->History.push_back(line); + this->Log[this->selected_channel].push_back({ "> " + line }); + const std::vector cmd_args = StringHelper::Split(line, " "); + if (this->Commands.contains(cmd_args[0])) { + const CommandEntry entry = this->Commands[cmd_args[0]]; + if (!entry.handler(cmd_args) && !entry.arguments.empty()) + this->Log[this->selected_channel].push_back({ "[SOH] Usage: " + cmd_args[0] + " " + BuildUsage(entry), ERROR_LVL }); + return; + } + this->Log[this->selected_channel].push_back({ "[SOH] Command not found", ERROR_LVL }); + } - switch(data->EventKey) { + int Console::CallbackStub(ImGuiInputTextCallbackData* data) { + const auto instance = static_cast(data->UserData); + const bool empty_history = instance->History.empty(); + const int history_index = instance->HistoryIndex; + std::string history; + + switch (data->EventKey) { case ImGuiKey_Tab: instance->Autocomplete.clear(); for (auto& [cmd, entry] : instance->Commands) @@ -287,7 +288,7 @@ int Console::CallbackStub(ImGuiInputTextCallbackData* data) { break; case ImGuiKey_UpArrow: if (empty_history) break; - if(history_index < static_cast(instance->History.size()) - 1) instance->HistoryIndex += 1; + if (history_index < static_cast(instance->History.size()) - 1) instance->HistoryIndex += 1; data->DeleteChars(0, data->BufTextLen); data->InsertChars(0, instance->History[instance->HistoryIndex].c_str()); instance->CMDHint = NULLSTR; @@ -296,7 +297,7 @@ int Console::CallbackStub(ImGuiInputTextCallbackData* data) { if (empty_history) break; if (history_index > -1) instance->HistoryIndex -= 1; data->DeleteChars(0, data->BufTextLen); - if(history_index >= 0) + if (history_index >= 0) data->InsertChars(0, instance->History[history_index].c_str()); instance->CMDHint = NULLSTR; break; @@ -316,16 +317,17 @@ int Console::CallbackStub(ImGuiInputTextCallbackData* data) { } instance->CMDHint = NULLSTR; } + } + return 0; } - return 0; -} -void Console::Append(const std::string& channel, Priority priority, const char* fmt, ...) { - char buf[1024]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); - buf[IM_ARRAYSIZE(buf) - 1] = 0; - va_end(args); - this->Log[channel].push_back({ std::string(buf), priority }); -} + void Console::Append(const std::string& channel, Priority priority, const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf) - 1] = 0; + va_end(args); + this->Log[channel].push_back({ std::string(buf), priority }); + } +} \ No newline at end of file diff --git a/libultraship/libultraship/Console.h b/libultraship/libultraship/Console.h index bfbffd0b9f..a174450e16 100644 --- a/libultraship/libultraship/Console.h +++ b/libultraship/libultraship/Console.h @@ -7,75 +7,77 @@ #include "Lib/ImGui/imgui.h" -#define LOG(msg, ...) SohImGui::console->Append("Main", Priority::LOG_LVL, msg, ##__VA_ARGS__) -#define INFO(msg, ...) SohImGui::console->Append("Main", Priority::INFO_LVL, msg, ##__VA_ARGS__) -#define WARNING(msg, ...) SohImGui::console->Append("Main", Priority::WARNING_LVL, msg, ##__VA_ARGS__) -#define ERROR(msg, ...) SohImGui::console->Append("Main", Priority::ERROR_LVL, msg, ##__VA_ARGS__) -#define CMD_SUCCESS true -#define CMD_FAILED false -#define MAX_BUFFER_SIZE 255 -#define NULLSTR "None" +namespace Ship { + #define LOG(msg, ...) SohImGui::console->Append("Main", Ship::Priority::LOG_LVL, msg, ##__VA_ARGS__) + #define INFO(msg, ...) SohImGui::console->Append("Main", Ship::Priority::INFO_LVL, msg, ##__VA_ARGS__) + #define WARNING(msg, ...) SohImGui::console->Append("Main", Ship::Priority::WARNING_LVL, msg, ##__VA_ARGS__) + #define ERROR(msg, ...) SohImGui::console->Append("Main", Ship::Priority::ERROR_LVL, msg, ##__VA_ARGS__) + #define CMD_SUCCESS true + #define CMD_FAILED false + #define MAX_BUFFER_SIZE 255 + #define NULLSTR "None" -typedef std::function args)> CommandHandler; + typedef std::function args)> CommandHandler; -enum Priority { - INFO_LVL, - LOG_LVL, - WARNING_LVL, - ERROR_LVL -}; - -enum class ArgumentType { - TEXT, NUMBER, PLAYER_POS, PLAYER_ROT -}; - -struct CommandArgument { - std::string info; - ArgumentType type = ArgumentType::NUMBER; - bool optional = false; -}; - -struct CommandEntry { - CommandHandler handler; - std::string description; - std::vector arguments; -}; - -struct ConsoleLine { - std::string text; - Priority priority = Priority::INFO_LVL; - std::string channel = "Main"; -}; - -class Console { - int selectedId = -1; - std::vector selectedEntries; - std::string filter; - std::string level_filter = NULLSTR; - std::vector log_channels = { "Main", "SoH Logging"}; - std::vector priority_filters = { "None", "Info", "Log", "Warning", "Error" }; - std::vector priority_colors = { - ImVec4(1.0f, 1.0f, 1.0f, 1.0f), - ImVec4(0.2f, 1.0f, 0.2f, 1.0f), - ImVec4(0.9f, 0.8f, 0.4f, 0.01f), - ImVec4(1.0f, 0.2f, 0.2f, 1.0f) + enum Priority { + INFO_LVL, + LOG_LVL, + WARNING_LVL, + ERROR_LVL }; -public: - std::map> Log; - std::map Commands; - std::vector Autocomplete; - std::vector History; - std::string CMDHint = NULLSTR; - char* FilterBuffer = nullptr; - char* InputBuffer = nullptr; - bool OpenAutocomplete = false; - int HistoryIndex = -1; - std::string selected_channel = "Main"; - bool opened = false; - void Init(); - void Update(); - void Draw(); - void Append(const std::string& channel, Priority priority, const char* fmt, ...) IM_FMTARGS(4); - void Dispatch(const std::string& line); - static int CallbackStub(ImGuiInputTextCallbackData* data); -}; \ No newline at end of file + + enum class ArgumentType { + TEXT, NUMBER, PLAYER_POS, PLAYER_ROT + }; + + struct CommandArgument { + std::string info; + ArgumentType type = ArgumentType::NUMBER; + bool optional = false; + }; + + struct CommandEntry { + CommandHandler handler; + std::string description; + std::vector arguments; + }; + + struct ConsoleLine { + std::string text; + Priority priority = Priority::INFO_LVL; + std::string channel = "Main"; + }; + + class Console { + int selectedId = -1; + std::vector selectedEntries; + std::string filter; + std::string level_filter = NULLSTR; + std::vector log_channels = { "Main", "SoH Logging" }; + std::vector priority_filters = { "None", "Info", "Log", "Warning", "Error" }; + std::vector priority_colors = { + ImVec4(1.0f, 1.0f, 1.0f, 1.0f), + ImVec4(0.2f, 1.0f, 0.2f, 1.0f), + ImVec4(0.9f, 0.8f, 0.4f, 0.01f), + ImVec4(1.0f, 0.2f, 0.2f, 1.0f) + }; + public: + std::map> Log; + std::map Commands; + std::vector Autocomplete; + std::vector History; + std::string CMDHint = NULLSTR; + char* FilterBuffer = nullptr; + char* InputBuffer = nullptr; + bool OpenAutocomplete = false; + int HistoryIndex = -1; + std::string selected_channel = "Main"; + bool opened = false; + void Init(); + void Update(); + void Draw(); + void Append(const std::string& channel, Priority priority, const char* fmt, ...) IM_FMTARGS(4); + void Dispatch(const std::string& line); + static int CallbackStub(ImGuiInputTextCallbackData* data); + }; +} \ No newline at end of file diff --git a/libultraship/libultraship/ImGuiImpl.h b/libultraship/libultraship/ImGuiImpl.h index 01235d4112..6913fce61f 100644 --- a/libultraship/libultraship/ImGuiImpl.h +++ b/libultraship/libultraship/ImGuiImpl.h @@ -69,7 +69,7 @@ namespace SohImGui { WindowDrawFunc drawFunc; } CustomWindow; - extern Console* console; + extern Ship::Console* console; extern Ship::InputEditor* controller; extern Ship::GameOverlay* overlay; extern bool needs_save; @@ -92,7 +92,7 @@ namespace SohImGui { void Render(void); void CancelFrame(void); void ShowCursor(bool hide, Dialogues w); - void BindCmd(const std::string& cmd, CommandEntry entry); + void BindCmd(const std::string& cmd, Ship::CommandEntry entry); void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled=false, bool isHidden=false); void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1)); void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp index 6e0c2e4d6d..aabeb0acf8 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp @@ -358,7 +358,6 @@ static void gfx_dxgi_show_cursor(bool hide) { * @bug When menubar is open in windowed mode and you toggle fullscreen * ShowCursor no longer responds. Debugging shows the bool to be correct. **/ - INFO("renderer: %s", hide ? "true" : "false"); ShowCursor(hide); } diff --git a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h index b9d3cdbf34..9f71bdee42 100644 --- a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h +++ b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h @@ -34,7 +34,7 @@ public: protected: void sink_it_(const details::log_msg &msg) override { - const Priority priority = convert_to_soh(msg.level); + const Ship::Priority priority = convert_to_soh(msg.level); memory_buf_t formatted; if (use_raw_msg_) { @@ -53,24 +53,25 @@ protected: void flush_() override {} private: - static Priority convert_to_soh(spdlog::level::level_enum level) { + static Ship::Priority convert_to_soh(spdlog::level::level_enum level) + { switch (level) { case spdlog::level::trace: - return Priority::INFO_LVL; + return Ship::Priority::INFO_LVL; case spdlog::level::debug: - return Priority::LOG_LVL; + return Ship::Priority::LOG_LVL; case spdlog::level::info: - return Priority::LOG_LVL; + return Ship::Priority::LOG_LVL; case spdlog::level::warn: - return Priority::WARNING_LVL; + return Ship::Priority::WARNING_LVL; case spdlog::level::err: - return Priority::ERROR_LVL; + return Ship::Priority::ERROR_LVL; case spdlog::level::critical: - return Priority::ERROR_LVL; + return Ship::Priority::ERROR_LVL; default: break; } - return Priority::LOG_LVL; + return Ship::Priority::LOG_LVL; } std::string tag_; diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 73c54b742a..ba5fb0b34e 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -463,50 +463,49 @@ void DebugConsole_Init(void) { CMD_REGISTER("kill", { KillPlayerHandler, "Commit suicide." }); CMD_REGISTER("map", { LoadSceneHandler, "Load up kak?" }); CMD_REGISTER("rupee", { RuppeHandler, "Set your rupee counter.", { - {"amount", ArgumentType::NUMBER } + {"amount", Ship::ArgumentType::NUMBER } }}); - CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { { "Item ID", ArgumentType::NUMBER } } }); - CMD_REGISTER("health", { SetPlayerHealthHandler, "Set the health of the player.", { - {"health", ArgumentType::NUMBER } + CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { { "Item ID", Ship::ArgumentType::NUMBER } } }); + CMD_REGISTER("health", { SetPlayerHealthHandler, "Set the health of the player.", { { "health", Ship::ArgumentType::NUMBER } }}); - CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { - { "actor_id", ArgumentType::NUMBER }, - { "data", ArgumentType::NUMBER }, - { "x", ArgumentType::PLAYER_POS, true }, - { "y", ArgumentType::PLAYER_POS, true }, - { "z", ArgumentType::PLAYER_POS, true }, - { "rx", ArgumentType::PLAYER_ROT, true }, - { "ry", ArgumentType::PLAYER_ROT, true }, - { "rz", ArgumentType::PLAYER_ROT, true } + CMD_REGISTER("spawn", { ActorSpawnHandler, "Spawn an actor.", { { "actor_id", Ship::ArgumentType::NUMBER }, + { "data", Ship::ArgumentType::NUMBER }, + { "x", Ship::ArgumentType::PLAYER_POS, true }, + { "y", Ship::ArgumentType::PLAYER_POS, true }, + { "z", Ship::ArgumentType::PLAYER_POS, true }, + { "rx", Ship::ArgumentType::PLAYER_ROT, true }, + { "ry", Ship::ArgumentType::PLAYER_ROT, true }, + { "rz", Ship::ArgumentType::PLAYER_ROT, true } }}); - CMD_REGISTER("pos", { SetPosHandler, "Sets the position of the player.", { - { "x", ArgumentType::PLAYER_POS, true }, - { "y", ArgumentType::PLAYER_POS, true }, - { "z", ArgumentType::PLAYER_POS, true } + CMD_REGISTER("pos", { SetPosHandler, "Sets the position of the player.", { { "x", Ship::ArgumentType::PLAYER_POS, true }, + { "y", Ship::ArgumentType::PLAYER_POS, true }, + { "z", Ship::ArgumentType::PLAYER_POS, true } }}); CMD_REGISTER("set", { SetCVarHandler, "Sets a console variable.", - { { "varName", ArgumentType::TEXT }, { "varValue", ArgumentType::TEXT } } }); - CMD_REGISTER("get", { GetCVarHandler, "Gets a console variable.", { { "varName", ArgumentType::TEXT } } }); + { { "varName", Ship::ArgumentType::TEXT }, { "varValue", Ship::ArgumentType::TEXT } } }); + CMD_REGISTER("get", { GetCVarHandler, "Gets a console variable.", { { "varName", Ship::ArgumentType::TEXT } } }); CMD_REGISTER("reset", { ResetHandler, "Resets the game." }); CMD_REGISTER("ammo", { AmmoHandler, "Changes ammo of an item.", - { { "item", ArgumentType::TEXT }, - { "count", ArgumentType::NUMBER } } }); + { { "item", Ship::ArgumentType::TEXT }, { "count", Ship::ArgumentType::NUMBER } } }); CMD_REGISTER("bottle", { BottleHandler, "Changes item in a bottle slot.", - { { "item", ArgumentType::TEXT }, { "slot", ArgumentType::NUMBER } } }); + { { "item", Ship::ArgumentType::TEXT }, { "slot", Ship::ArgumentType::NUMBER } } }); CMD_REGISTER("item", { ItemHandler, "Sets item ID in arg 1 into slot arg 2. No boundary checks. Use with caution.", - { { "slot", ArgumentType::NUMBER }, { "item id", ArgumentType::NUMBER } } }); - CMD_REGISTER("entrance", - { EntranceHandler, "Sends player to the entered entrance (hex)", { { "entrance", ArgumentType::NUMBER } } }); + { { "slot", Ship::ArgumentType::NUMBER }, { "item id", Ship::ArgumentType::NUMBER } } }); + CMD_REGISTER("entrance", { EntranceHandler, + "Sends player to the entered entrance (hex)", + { { "entrance", Ship::ArgumentType::NUMBER } } }); CMD_REGISTER("save_state", { SaveStateHandler, "Save a state." }); CMD_REGISTER("load_state", { LoadStateHandler, "Load a state." }); - CMD_REGISTER("set_slot", { StateSlotSelectHandler, "Selects a SaveState slot", { - { "Slot number", ArgumentType::NUMBER, } + CMD_REGISTER("set_slot", { StateSlotSelectHandler, "Selects a SaveState slot", { { + "Slot number", + Ship::ArgumentType::NUMBER, + } } }); DebugConsole_LoadCVars(); } From 1de525900dbfea9b44f70531e0a82c2629a9ba57 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 22:10:26 -0400 Subject: [PATCH 08/31] Removes unnecessary Environment.cpp file. --- libultraship/libultraship/Environment.cpp | 16 ---------------- libultraship/libultraship/Environment.h | 8 -------- libultraship/libultraship/ImGuiImpl.cpp | 3 +-- .../libultraship/Lib/Fast3D/gfx_opengl.cpp | 1 - libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp | 9 +++++---- libultraship/libultraship/Lib/Fast3D/gfx_pc.h | 2 ++ libultraship/libultraship/libultraship.vcxproj | 2 -- .../libultraship/libultraship.vcxproj.filters | 9 --------- 8 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 libultraship/libultraship/Environment.cpp delete mode 100644 libultraship/libultraship/Environment.h diff --git a/libultraship/libultraship/Environment.cpp b/libultraship/libultraship/Environment.cpp deleted file mode 100644 index 53d0f330b3..0000000000 --- a/libultraship/libultraship/Environment.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "Environment.h" - -#include -#include - -std::map environmentVars; - -namespace SohUtils { - void saveEnvironmentVar(const std::string& key, const std::string& value) { - environmentVars[key] = value; - } - - std::string getEnvironmentVar(const std::string& key) { - return environmentVars[key]; - } -} \ No newline at end of file diff --git a/libultraship/libultraship/Environment.h b/libultraship/libultraship/Environment.h deleted file mode 100644 index 4d6ab33462..0000000000 --- a/libultraship/libultraship/Environment.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -namespace SohUtils { - void saveEnvironmentVar(const std::string& key, const std::string& value); - std::string getEnvironmentVar(const std::string& key); -} \ No newline at end of file diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index f19ce7eac1..a1b44a6df3 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -8,7 +8,6 @@ #include #include "Archive.h" -#include "Environment.h" #include "GameSettings.h" #include "Console.h" #include "Hooks.h" @@ -1626,7 +1625,7 @@ namespace SohImGui { pos = ImVec2(size.x / 2 - sw / 2, 0); size = ImVec2(sw, size.y); } - std::string fb_str = SohUtils::getEnvironmentVar("framebuffer"); + std::string fb_str = gfxFramebuffer; if (!fb_str.empty()) { uintptr_t fbuf = (uintptr_t)std::stoull(fb_str); //ImGui::ImageSimple(reinterpret_cast(fbuf), pos, size); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp index ad683e047b..3d199ef714 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_opengl.cpp @@ -44,7 +44,6 @@ #include "gfx_cc.h" #include "gfx_rendering_api.h" #include "../../ImGuiImpl.h" -#include "../../Environment.h" #include "../../GlobalCtx2.h" #include "gfx_pc.h" diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 0a5d0ceef6..d855012ef5 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -32,7 +32,6 @@ #include "../../luslog.h" #include "../StrHash64.h" #include "../../ImGuiImpl.h" -#include "../../Environment.h" #include "../../GameVersions.h" #include "../../ResourceMgr.h" #include "../../Utils.h" @@ -49,6 +48,8 @@ extern "C" { int ResourceMgr_OTRSigCheck(char* imgData); } +std::string gfxFramebuffer; + using namespace std; #define SEG_ADDR(seg, addr) (addr | (seg << 24) | 1) @@ -2782,7 +2783,7 @@ void gfx_run(Gfx *commands, const std::unordered_map& mtx_replaceme rendering_state.scissor = {}; gfx_run_dl(commands); gfx_flush(); - SohUtils::saveEnvironmentVar("framebuffer", string()); + gfxFramebuffer = string(); if (game_renders_to_framebuffer) { gfx_rapi->start_draw_to_framebuffer(0, 1); gfx_rapi->clear_framebuffer(); @@ -2792,12 +2793,12 @@ void gfx_run(Gfx *commands, const std::unordered_map& mtx_replaceme if (different_size) { gfx_rapi->resolve_msaa_color_buffer(game_framebuffer_msaa_resolved, game_framebuffer); - SohUtils::saveEnvironmentVar("framebuffer", std::to_string((uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer_msaa_resolved))); + gfxFramebuffer = std::to_string((uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer_msaa_resolved)); } else { gfx_rapi->resolve_msaa_color_buffer(0, game_framebuffer); } } else { - SohUtils::saveEnvironmentVar("framebuffer", std::to_string((uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer))); + gfxFramebuffer = std::to_string((uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer)); } } SohImGui::DrawFramebufferAndGameInput(); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h index 4e620ef2d3..931093079a 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h @@ -14,6 +14,8 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 +extern std::string gfxFramebuffer; + struct GfxRenderingAPI; struct GfxWindowManagerAPI; diff --git a/libultraship/libultraship/libultraship.vcxproj b/libultraship/libultraship/libultraship.vcxproj index 4d7eab9b42..52df7d3959 100644 --- a/libultraship/libultraship/libultraship.vcxproj +++ b/libultraship/libultraship/libultraship.vcxproj @@ -258,7 +258,6 @@ - @@ -354,7 +353,6 @@ - diff --git a/libultraship/libultraship/libultraship.vcxproj.filters b/libultraship/libultraship/libultraship.vcxproj.filters index fa5c505aa4..f84250c290 100644 --- a/libultraship/libultraship/libultraship.vcxproj.filters +++ b/libultraship/libultraship/libultraship.vcxproj.filters @@ -67,9 +67,6 @@ {ccd6359f-e357-41ca-9b89-5f509dd30649} - - {94ca4b98-cee2-48e6-a88b-68b8d2fed287} - {0dca2d94-45ba-4916-b03a-1dd5f949114c} @@ -321,9 +318,6 @@ Source Files\Audio - - Source Files\CustomImpl\Environment - Source Files\CustomImpl\Utils @@ -605,9 +599,6 @@ Source Files\Lib\ImGui - - Source Files\CustomImpl\Environment - Source Files\CustomImpl\Utils From 67d5ba08ab64bf3c913480a276b6e0886272ec2d Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 22:34:45 -0400 Subject: [PATCH 09/31] Converts gfxFramebuffer to be a pointer. --- libultraship/libultraship/ImGuiImpl.cpp | 8 +++----- libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp | 8 ++++---- libultraship/libultraship/Lib/Fast3D/gfx_pc.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index a1b44a6df3..5581dd5a3b 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1625,12 +1625,10 @@ namespace SohImGui { pos = ImVec2(size.x / 2 - sw / 2, 0); size = ImVec2(sw, size.y); } - std::string fb_str = gfxFramebuffer; - if (!fb_str.empty()) { - uintptr_t fbuf = (uintptr_t)std::stoull(fb_str); - //ImGui::ImageSimple(reinterpret_cast(fbuf), pos, size); + if (gfxFramebuffer != NULL) { + //ImGui::ImageSimple(reinterpret_cast(gfxFramebuffer), pos, size); ImGui::SetCursorPos(pos); - ImGui::Image(reinterpret_cast(fbuf), size); + ImGui::Image(reinterpret_cast(gfxFramebuffer), size); } ImGui::End(); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index d855012ef5..0660d6ebd5 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -48,7 +48,7 @@ extern "C" { int ResourceMgr_OTRSigCheck(char* imgData); } -std::string gfxFramebuffer; +uintptr_t gfxFramebuffer; using namespace std; @@ -2783,7 +2783,7 @@ void gfx_run(Gfx *commands, const std::unordered_map& mtx_replaceme rendering_state.scissor = {}; gfx_run_dl(commands); gfx_flush(); - gfxFramebuffer = string(); + gfxFramebuffer = NULL; if (game_renders_to_framebuffer) { gfx_rapi->start_draw_to_framebuffer(0, 1); gfx_rapi->clear_framebuffer(); @@ -2793,12 +2793,12 @@ void gfx_run(Gfx *commands, const std::unordered_map& mtx_replaceme if (different_size) { gfx_rapi->resolve_msaa_color_buffer(game_framebuffer_msaa_resolved, game_framebuffer); - gfxFramebuffer = std::to_string((uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer_msaa_resolved)); + gfxFramebuffer = (uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer_msaa_resolved); } else { gfx_rapi->resolve_msaa_color_buffer(0, game_framebuffer); } } else { - gfxFramebuffer = std::to_string((uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer)); + gfxFramebuffer = (uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer); } } SohImGui::DrawFramebufferAndGameInput(); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h index 931093079a..feab8e3d93 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.h +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.h @@ -14,7 +14,7 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 -extern std::string gfxFramebuffer; +extern uintptr_t gfxFramebuffer; struct GfxRenderingAPI; struct GfxWindowManagerAPI; From 7267b60a264d65d45d9a518f8d433ff10b4156c9 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 23:16:15 -0400 Subject: [PATCH 10/31] gfxFramebuffer is now only compared or set to 0 rather than NULL --- libultraship/libultraship/ImGuiImpl.cpp | 2 +- libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 5581dd5a3b..eb417c98f1 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1625,7 +1625,7 @@ namespace SohImGui { pos = ImVec2(size.x / 2 - sw / 2, 0); size = ImVec2(sw, size.y); } - if (gfxFramebuffer != NULL) { + if (gfxFramebuffer) { //ImGui::ImageSimple(reinterpret_cast(gfxFramebuffer), pos, size); ImGui::SetCursorPos(pos); ImGui::Image(reinterpret_cast(gfxFramebuffer), size); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 0660d6ebd5..25030afbee 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -2783,7 +2783,7 @@ void gfx_run(Gfx *commands, const std::unordered_map& mtx_replaceme rendering_state.scissor = {}; gfx_run_dl(commands); gfx_flush(); - gfxFramebuffer = NULL; + gfxFramebuffer = 0; if (game_renders_to_framebuffer) { gfx_rapi->start_draw_to_framebuffer(0, 1); gfx_rapi->clear_framebuffer(); From b89cc25df3e26717a76c7a847494e14fb05d9595 Mon Sep 17 00:00:00 2001 From: aMannus Date: Wed, 3 Aug 2022 05:46:39 +0200 Subject: [PATCH 11/31] Fixed deku stick on B and horse swordless (#995) --- soh/src/code/z_parameter.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 4c7443f9fb..eecf1be8bd 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1363,6 +1363,12 @@ void Inventory_SwapAgeEquipment(void) { u16 temp; if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + // When becoming adult, remove swordless flag since we'll get master sword + // Only in rando to keep swordless link bugs in vanilla + if (gSaveContext.n64ddFlag) { + gSaveContext.infTable[29] &= ~1; + } + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (i != 0) { gSaveContext.childEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; @@ -1423,6 +1429,12 @@ void Inventory_SwapAgeEquipment(void) { gSaveContext.equips.equipment = gSaveContext.adultEquips.equipment; } } else { + // When becoming child, set swordless flag if player doesn't have kokiri sword + // Only in rando to keep swordless link bugs in vanilla + if (gSaveContext.n64ddFlag && (1 << 0 & gSaveContext.inventory.equipment) == 0) { + gSaveContext.infTable[29] |= 1; + } + for (i = 0; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { gSaveContext.adultEquips.buttonItems[i] = gSaveContext.equips.buttonItems[i]; From 27e0f19dac4a2b429430414712a45d0585f9092e Mon Sep 17 00:00:00 2001 From: InfoManiac742 <26778801+InfoManiac742@users.noreply.github.com> Date: Tue, 2 Aug 2022 20:47:57 -0700 Subject: [PATCH 12/31] Remember save location (#980) * Remember save location * Clarified grotto caveat * Update ImGuiImpl.cpp --- libultraship/libultraship/ImGuiImpl.cpp | 3 + soh/src/code/z_sram.c | 113 ++++++++++++------------ 2 files changed, 61 insertions(+), 55 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index eb417c98f1..555878b30f 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1013,6 +1013,9 @@ namespace SohImGui { Tooltip("Allow Link to put items away without having to wait around"); EnhancementCheckbox("Mask Select in Inventory", "gMaskSelect"); Tooltip("After completing the mask trading sub-quest, press A and any direction on the mask slot to change masks"); + EnhancementCheckbox("Remember Save Location", "gRememberSaveLocation"); + Tooltip("When loading a save, places Link at the last entrance he went through.\n" + "This doesn't work if the save was made in a grotto."); ImGui::EndMenu(); } diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 7670762c59..080c5ea9df 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -442,62 +442,65 @@ void Sram_OpenSave() { Save_LoadFile(); - switch (gSaveContext.savedSceneNum) { - case SCENE_YDAN: - case SCENE_DDAN: - case SCENE_BDAN: - case SCENE_BMORI1: - case SCENE_HIDAN: - case SCENE_MIZUSIN: - case SCENE_JYASINZOU: - case SCENE_HAKADAN: - case SCENE_HAKADANCH: - case SCENE_ICE_DOUKUTO: - case SCENE_GANON: - case SCENE_MEN: - case SCENE_GERUDOWAY: - case SCENE_GANONTIKA: - gSaveContext.entranceIndex = dungeonEntrances[gSaveContext.savedSceneNum]; - break; - case SCENE_YDAN_BOSS: - gSaveContext.entranceIndex = 0; - break; - case SCENE_DDAN_BOSS: - gSaveContext.entranceIndex = 4; - break; - case SCENE_BDAN_BOSS: - gSaveContext.entranceIndex = 0x28; - break; - case SCENE_MORIBOSSROOM: - gSaveContext.entranceIndex = 0x169; - break; - case SCENE_FIRE_BS: - gSaveContext.entranceIndex = 0x165; - break; - case SCENE_MIZUSIN_BS: - gSaveContext.entranceIndex = 0x10; - break; - case SCENE_JYASINBOSS: - gSaveContext.entranceIndex = 0x82; - break; - case SCENE_HAKADAN_BS: - gSaveContext.entranceIndex = 0x37; - break; - case SCENE_GANON_SONOGO: - case SCENE_GANONTIKA_SONOGO: - case SCENE_GANON_BOSS: - case SCENE_GANON_FINAL: - case SCENE_GANON_DEMO: - gSaveContext.entranceIndex = 0x41B; - break; + if (!CVar_GetS32("gRememberSaveLocation", 0) || gSaveContext.savedSceneNum == SCENE_YOUSEI_IZUMI_TATE || + gSaveContext.savedSceneNum == SCENE_KAKUSIANA) { + switch (gSaveContext.savedSceneNum) { + case SCENE_YDAN: + case SCENE_DDAN: + case SCENE_BDAN: + case SCENE_BMORI1: + case SCENE_HIDAN: + case SCENE_MIZUSIN: + case SCENE_JYASINZOU: + case SCENE_HAKADAN: + case SCENE_HAKADANCH: + case SCENE_ICE_DOUKUTO: + case SCENE_GANON: + case SCENE_MEN: + case SCENE_GERUDOWAY: + case SCENE_GANONTIKA: + gSaveContext.entranceIndex = dungeonEntrances[gSaveContext.savedSceneNum]; + break; + case SCENE_YDAN_BOSS: + gSaveContext.entranceIndex = 0; + break; + case SCENE_DDAN_BOSS: + gSaveContext.entranceIndex = 4; + break; + case SCENE_BDAN_BOSS: + gSaveContext.entranceIndex = 0x28; + break; + case SCENE_MORIBOSSROOM: + gSaveContext.entranceIndex = 0x169; + break; + case SCENE_FIRE_BS: + gSaveContext.entranceIndex = 0x165; + break; + case SCENE_MIZUSIN_BS: + gSaveContext.entranceIndex = 0x10; + break; + case SCENE_JYASINBOSS: + gSaveContext.entranceIndex = 0x82; + break; + case SCENE_HAKADAN_BS: + gSaveContext.entranceIndex = 0x37; + break; + case SCENE_GANON_SONOGO: + case SCENE_GANONTIKA_SONOGO: + case SCENE_GANON_BOSS: + case SCENE_GANON_FINAL: + case SCENE_GANON_DEMO: + gSaveContext.entranceIndex = 0x41B; + break; - default: - if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) { - gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4; - } else { - gSaveContext.entranceIndex = 0xBB; - } - break; + default: + if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) { + gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4; + } else { + gSaveContext.entranceIndex = 0xBB; + } + break; + } } osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex); From db33604171bd09d33ddde83508da852e246df3d2 Mon Sep 17 00:00:00 2001 From: Nycz <63111944+Nycz-lab@users.noreply.github.com> Date: Wed, 3 Aug 2022 05:48:41 +0200 Subject: [PATCH 13/31] added Cheat Sync Time (#957) * added Cheat Sync Time This syncs the ingame time with the real world time. I wasnt quite sure where to put the code so im sorry if this is bad i just wanted to contribute to this project. * Update soh/src/code/z_play.c Co-authored-by: Christopher Leggett * Update z_play.c added suggestions from leggettc18 * Update z_play.c Co-authored-by: Christopher Leggett --- libultraship/libultraship/ImGuiImpl.cpp | 3 +++ soh/src/code/z_play.c | 28 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 555878b30f..e6f7a31c68 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1416,6 +1416,9 @@ namespace SohImGui { Tooltip("Prevents the Deku Shield from burning on contact with fire"); EnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded"); Tooltip("This allows you to put up your shield with any two-handed weapon in hand except for Deku Sticks"); + Tooltip("This allows you to put up your shield with any two-handed weapon in hand\nexcept for Deku Sticks"); + EnhancementCheckbox("Time Sync", "gTimeSync"); + Tooltip("This syncs the ingame time with the real world time"); { static int32_t betaQuestEnabled = CVar_GetS32("gEnableBetaQuest", 0); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index d5bcb5bebf..f999797158 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -7,6 +7,8 @@ #include "../libultraship/ImGuiImpl.h" #include "soh/frame_interpolation.h" +#include + void* D_8012D1F0 = NULL; //UNK_TYPE D_8012D1F4 = 0; // unused Input* D_8012D1F8 = NULL; @@ -1444,6 +1446,18 @@ void Gameplay_Draw(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx); } +time_t Gameplay_GetRealTime() { + time_t t1, t2; + struct tm* tms; + time(&t1); + tms = localtime(&t1); + tms->tm_hour = 0; + tms->tm_min = 0; + tms->tm_sec = 0; + t2 = mktime(tms); + return t1 - t2; +} + void Gameplay_Main(GameState* thisx) { GlobalContext* globalCtx = (GlobalContext*)thisx; @@ -1487,6 +1501,20 @@ void Gameplay_Main(GameState* thisx) { if (1 && HREG(63)) { LOG_NUM("1", 1); } + + if (CVar_GetS32("gTimeSync", 0)) { + const int maxRealDaySeconds = 86400; + const int maxInGameDayTicks = 65536; + + int secs = (int)Gameplay_GetRealTime(); + float percent = (float)secs / (float)maxRealDaySeconds; + + int newIngameTime = maxInGameDayTicks * percent; + + gSaveContext.dayTime = newIngameTime; + + } + } // original name: "Game_play_demo_mode_check" From fe02818d512d300b75ed8d38f0a0d9a0fd32f2de Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Tue, 2 Aug 2022 23:48:51 -0400 Subject: [PATCH 14/31] Randomizer: Ocarina of Time Ice Trap Fix (#964) * Fixes Ice Trap on OoT check from preventing SoT check * Removes unneeded GlobalContext argument. --- soh/soh/OTRGlobals.cpp | 5 +++++ soh/soh/OTRGlobals.h | 1 + soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 05c572bf3b..615c9a8a62 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1502,6 +1502,11 @@ extern "C" s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerChec return OTRGlobals::Instance->gRandomizer->GetRandomizedItemIdFromKnownCheck(randomizerCheck, ogId); } +extern "C" bool Randomizer_ObtainedFreestandingIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId, Actor* actor) { + return gSaveContext.n64ddFlag && (actor->parent != NULL) && + Randomizer_GetItemIdFromKnownCheck(randomizerCheck, ogId) == GI_ICE_TRAP; +} + extern "C" bool Randomizer_ItemIsIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId) { return gSaveContext.n64ddFlag && Randomizer_GetItemIdFromKnownCheck(randomizerCheck, ogId) == GI_ICE_TRAP; } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 90efaf8c4e..3df4b2022a 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -97,6 +97,7 @@ s16 Randomizer_GetItemModelFromId(s16 itemId); s32 Randomizer_GetItemIDFromGetItemID(s32 getItemId); s32 Randomizer_GetRandomizedItemId(GetItemID ogId, s16 actorId, s16 actorParams, s16 sceneNum); s32 Randomizer_GetItemIdFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); +bool Randomizer_ObtainedFreestandingIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId, Actor* actor); bool Randomizer_ItemIsIceTrap(RandomizerCheck randomizerCheck, GetItemID ogId); #endif diff --git a/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c b/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c index 9992d08b3e..9e0fcf4c98 100644 --- a/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c +++ b/soh/src/overlays/actors/ovl_Item_Ocarina/z_item_ocarina.c @@ -168,7 +168,8 @@ void ItemOcarina_DoNothing(ItemOcarina* this, GlobalContext* globalCtx) { } void ItemOcarina_StartSoTCutscene(ItemOcarina* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { + if (Actor_TextboxIsClosing(&this->actor, globalCtx) || + Randomizer_ObtainedFreestandingIceTrap(RC_HF_OCARINA_OF_TIME_ITEM, GI_OCARINA_OOT, &this->actor)) { if (!gSaveContext.n64ddFlag) { globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gHyruleFieldZeldaSongOfTimeCs); gSaveContext.cutsceneTrigger = 1; From 6d0d608e38906624408e3a4e6fc697c238b89f5b Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Tue, 2 Aug 2022 22:51:07 -0500 Subject: [PATCH 15/31] Unrestricted warping in randomizer (#951) --- soh/src/code/z_message_PAL.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index afc69e8142..29d3ee4ff0 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -2737,7 +2737,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { if (msgCtx->lastPlayedSong < OCARINA_SONG_SARIAS && (msgCtx->ocarinaAction < OCARINA_ACTION_PLAYBACK_MINUET || msgCtx->ocarinaAction >= OCARINA_ACTION_PLAYBACK_SARIA)) { - if (msgCtx->disableWarpSongs || interfaceCtx->restrictions.warpSongs == 3) { + if (msgCtx->disableWarpSongs || (interfaceCtx->restrictions.warpSongs == 3 && !gSaveContext.n64ddFlag)) { Message_StartTextbox(globalCtx, 0x88C, NULL); // "You can't warp here!" globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; } else if ((gSaveContext.eventInf[0] & 0xF) != 1) { From 2d60c772bf0d9369155305253c3d14dc23ea90c1 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 00:07:52 -0400 Subject: [PATCH 16/31] LUS Cleanup: Controllers cleanup (#1016) --- libultraship/libultraship/ControlDeck.h | 1 - libultraship/libultraship/InputEditor.h | 2 - libultraship/libultraship/VirtualController.h | 56 ++++++++++--------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/libultraship/libultraship/ControlDeck.h b/libultraship/libultraship/ControlDeck.h index 58c258ca8c..15cba08e96 100644 --- a/libultraship/libultraship/ControlDeck.h +++ b/libultraship/libultraship/ControlDeck.h @@ -2,7 +2,6 @@ #include "Controller.h" #include -#include namespace Ship { diff --git a/libultraship/libultraship/InputEditor.h b/libultraship/libultraship/InputEditor.h index 39bddd51d3..81b1997eca 100644 --- a/libultraship/libultraship/InputEditor.h +++ b/libultraship/libultraship/InputEditor.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "Lib/ImGui/imgui.h" namespace Ship { diff --git a/libultraship/libultraship/VirtualController.h b/libultraship/libultraship/VirtualController.h index 017373e55c..825d7df59b 100644 --- a/libultraship/libultraship/VirtualController.h +++ b/libultraship/libultraship/VirtualController.h @@ -4,32 +4,34 @@ #include "Controller.h" -class VirtualController final : public Ship::Controller { -public: - VirtualController(const std::string& CUID, const std::string& KeyName, bool Connected) { - GUID = CUID; - isConnected = Connected; - ButtonName = KeyName; - } +namespace Ship { + class VirtualController final : public Controller { + public: + VirtualController(const std::string& CUID, const std::string& KeyName, bool Connected) { + GUID = CUID; + isConnected = Connected; + ButtonName = KeyName; + } - std::map, int32_t> ReadButtonPress(); - void ReadFromSource(int32_t slot) override {} - const char* GetControllerName() override { return GUID.c_str(); } - const char* GetButtonName(int slot, int n64Button) override { return ButtonName.c_str(); } - void WriteToSource(int32_t slot, ControllerCallback* controller) override { } - bool Connected() const override { return isConnected; } - bool CanRumble() const override { return false; } - bool CanGyro() const override { return false; } + std::map, int32_t> ReadButtonPress(); + void ReadFromSource(int32_t slot) override {} + const char* GetControllerName() override { return GUID.c_str(); } + const char* GetButtonName(int slot, int n64Button) override { return ButtonName.c_str(); } + void WriteToSource(int32_t slot, ControllerCallback* controller) override { } + bool Connected() const override { return isConnected; } + bool CanRumble() const override { return false; } + bool CanGyro() const override { return false; } - void ClearRawPress() override {} - int32_t ReadRawPress() override { return -1; } - bool HasPadConf() const { return true; } - std::optional GetPadConfSection() { return "Unk"; } - void CreateDefaultBinding(int32_t slot) override {} -protected: - std::string ButtonName; - bool isConnected = false; - std::string GetControllerType() { return "Unk"; } - std::string GetConfSection() { return "Unk"; } - std::string GetBindingConfSection() { return "Unk"; } -}; + void ClearRawPress() override {} + int32_t ReadRawPress() override { return -1; } + bool HasPadConf() const { return true; } + std::optional GetPadConfSection() { return "Unk"; } + void CreateDefaultBinding(int32_t slot) override {} + protected: + std::string ButtonName; + bool isConnected = false; + std::string GetControllerType() { return "Unk"; } + std::string GetConfSection() { return "Unk"; } + std::string GetBindingConfSection() { return "Unk"; } + }; +} \ No newline at end of file From 8431cddb1470343cf19ce932df6bcd8b2351b781 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 23:32:37 -0400 Subject: [PATCH 17/31] LUS Cleanup: GameOverlay and moves various GUI related files to it's own filter. --- libultraship/libultraship/GameOverlay.cpp | 403 +++++++++--------- libultraship/libultraship/GameOverlay.h | 24 +- .../libultraship/libultraship.vcxproj.filters | 42 +- 3 files changed, 238 insertions(+), 231 deletions(-) diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index ccbdc142c8..01d889dd63 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -10,219 +10,226 @@ #include "Lib/ImGui/imgui_internal.h" #include "Utils/StringHelper.h" -void Ship::GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) { - ImGuiIO& io = ImGui::GetIO(); - std::shared_ptr base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive(); - std::shared_ptr font = std::make_shared(); - base->LoadFile(path, false, font); - if (font->bIsLoaded) { - char* font_data = new char[font->dwBufferSize]; - memcpy(font_data, font->buffer.get(), font->dwBufferSize); - Fonts[name] = io.Fonts->AddFontFromMemoryTTF(font_data, font->dwBufferSize, fontSize); +namespace Ship { + void GameOverlay::LoadFont(const std::string& name, const std::string& path, float fontSize) { + ImGuiIO& io = ImGui::GetIO(); + std::shared_ptr base = GlobalCtx2::GetInstance()->GetResourceManager()->GetArchive(); + std::shared_ptr font = std::make_shared(); + base->LoadFile(path, false, font); + if (font->bIsLoaded) { + char* font_data = new char[font->dwBufferSize]; + memcpy(font_data, font->buffer.get(), font->dwBufferSize); + Fonts[name] = io.Fonts->AddFontFromMemoryTTF(font_data, font->dwBufferSize, fontSize); + } } -} -void Ship::GameOverlay::TextDraw(float x, float y, bool shadow, ImVec4 color, const char* fmt, ...) { - char buf[1024]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); - buf[IM_ARRAYSIZE(buf) - 1] = 0; - va_end(args); + void GameOverlay::TextDraw(float x, float y, bool shadow, ImVec4 color, const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf) - 1] = 0; + va_end(args); - ImGui::PushStyleColor(ImGuiCol_Text, color); - ImGui::PushFont(Fonts[this->CurrentFont]); - if (shadow) { - ImGui::SetCursorPos(ImVec2(x + 1, y + 1)); - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(.0f, .0f, .0f, color.w)); + ImGui::PushStyleColor(ImGuiCol_Text, color); + ImGui::PushFont(Fonts[this->CurrentFont]); + if (shadow) { + ImGui::SetCursorPos(ImVec2(x + 1, y + 1)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(.0f, .0f, .0f, color.w)); + ImGui::Text(buf, args); + } + ImGui::PopStyleColor(); + ImGui::SetCursorPos(ImVec2(x, y)); ImGui::Text(buf, args); + ImGui::PopFont(); + ImGui::PopStyleColor(); } - ImGui::PopStyleColor(); - ImGui::SetCursorPos(ImVec2(x, y)); - ImGui::Text(buf, args); - ImGui::PopFont(); - ImGui::PopStyleColor(); -} -void Ship::GameOverlay::TextDrawNotification(float duration, bool shadow, const char* fmt, ...) { - char buf[1024]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); - buf[IM_ARRAYSIZE(buf) - 1] = 0; - va_end(args); - this->RegisteredOverlays[StringHelper::Sprintf("NotificationID:%d%d", rand(), this->RegisteredOverlays.size())] = new Overlay({ OverlayType::NOTIFICATION, ImStrdup(buf), duration, duration }); - NeedsCleanup = true; -} - -void Ship::GameOverlay::CleanupNotifications() { - if(!NeedsCleanup) return; - for (auto it = this->RegisteredOverlays.begin(); it != this->RegisteredOverlays.end(); ) { - if (it->second->type == OverlayType::NOTIFICATION && it->second->duration <= 0.0f) { - it = this->RegisteredOverlays.erase(it); - } else { - ++it; - } + void GameOverlay::TextDrawNotification(float duration, bool shadow, const char* fmt, ...) { + char buf[1024]; + va_list args; + va_start(args, fmt); + vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); + buf[IM_ARRAYSIZE(buf) - 1] = 0; + va_end(args); + this->RegisteredOverlays[StringHelper::Sprintf("NotificationID:%d%d", rand(), this->RegisteredOverlays.size())] = new Overlay({ OverlayType::NOTIFICATION, ImStrdup(buf), duration, duration }); + NeedsCleanup = true; } - NeedsCleanup = false; -} -float Ship::GameOverlay::GetScreenWidth() { - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - return viewport->Size.x; -} - -float Ship::GameOverlay::GetScreenHeight() { - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - return viewport->Size.y; -} - -float Ship::GameOverlay::GetStringWidth(const char* text) { - return CalculateTextSize(text).x; -} - -ImVec2 Ship::GameOverlay::CalculateTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) { - ImGuiContext& g = *GImGui; - - const char* text_display_end; - if (hide_text_after_double_hash) - text_display_end = ImGui::FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string - else - text_display_end = text_end; - - GameOverlay* overlay = SohImGui::overlay; - - ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont]; - const float font_size = font->FontSize; - if (text == text_display_end) - return ImVec2(0.0f, font_size); - ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); - - // Round - // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. - // FIXME: Investigate using ceilf or e.g. - // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c - // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html - text_size.x = IM_FLOOR(text_size.x + 0.99999f); - - return text_size; -} - -void Ship::GameOverlay::Init() { - this->LoadFont("Press Start 2P", "assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf", 12.0f); - this->LoadFont("Fipps", "assets/ship_of_harkinian/fonts/Fipps-Regular.otf", 32.0f); - const std::string DefaultFont = this->Fonts.begin()->first; - if(!this->Fonts.empty()) { - const std::string font = CVar_GetString("gOverlayFont", ImStrdup(DefaultFont.c_str())); - for (auto& [name, _] : this->Fonts) { - if (font.starts_with(name)) { - this->CurrentFont = name; - break; + void GameOverlay::CleanupNotifications() { + if (!NeedsCleanup) return; + for (auto it = this->RegisteredOverlays.begin(); it != this->RegisteredOverlays.end(); ) { + if (it->second->type == OverlayType::NOTIFICATION && it->second->duration <= 0.0f) { + it = this->RegisteredOverlays.erase(it); } - this->CurrentFont = DefaultFont; - } - } - SohImGui::console->Commands["overlay"] = { OverlayCommand, "Draw an overlay using a cvar value" }; -} - -void Ship::GameOverlay::DrawSettings() { - ImGui::Text("Overlays Text Font"); - if (ImGui::BeginCombo("##TextFont", this->CurrentFont.c_str())) { - for (auto& [name, font] : this->Fonts) { - if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) { - this->CurrentFont = name; - CVar_SetString("gOverlayFont", ImStrdup(name.c_str())); - SohImGui::needs_save = true; + else { + ++it; } - - } - ImGui::EndCombo(); - } -} - - -void Ship::GameOverlay::Draw() { - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - - ImGui::SetNextWindowPos(viewport->Pos, ImGuiCond_Always); - ImGui::SetNextWindowSize(viewport->Size, ImGuiCond_Always); - ImGui::Begin("SoHOverlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | - ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs); - - this->CleanupNotifications(); - - float textY = 50; - float notY = 0; - - for (auto &[key, overlay] : this->RegisteredOverlays) { - - if (overlay->type == OverlayType::TEXT) { - const char* text = ImStrdup(overlay->value); - const CVar* var = CVar_Get(text); - ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - - switch (var->type) { - case CVarType::Float: - this->TextDraw(30, textY, true, color, "%s %.2f", text, var->value.valueFloat); - break; - case CVarType::S32: - this->TextDraw(30, textY, true, color, "%s %d", text, var->value.valueS32); - break; - case CVarType::String: - this->TextDraw(30, textY, true, color, "%s %s", text, var->value.valueStr); - break; - case CVarType::RGBA: - this->TextDraw(30, textY, true, color, "#%08X", text, var->value.valueRGBA); - break; - } - - free((void*) text); - textY += 30; - } - - if (overlay->type == OverlayType::NOTIFICATION && overlay->duration > 0) { - const char* text = overlay->value; - const float duration = overlay->duration / overlay->fadeTime; - - const ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, duration); - const float textWidth = this->GetStringWidth(overlay->value); - - this->TextDraw(GetScreenWidth() - textWidth - 40, GetScreenHeight() - 40 - notY, true, color, text); - notY += 30; - overlay->duration -= .05f; } + NeedsCleanup = false; } - ImGui::End(); -} - - -bool Ship::OverlayCommand(const std::vector& args) { - if (args.size() < 3) { - return CMD_FAILED; + float GameOverlay::GetScreenWidth() { + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + return viewport->Size.x; } - if (CVar_Get(args[2].c_str()) != nullptr) { - const char* key = args[2].c_str(); + float GameOverlay::GetScreenHeight() { + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + return viewport->Size.y; + } + + float GameOverlay::GetStringWidth(const char* text) { + return CalculateTextSize(text).x; + } + + ImVec2 GameOverlay::CalculateTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) { + ImGuiContext& g = *GImGui; + + const char* text_display_end; + if (hide_text_after_double_hash) + text_display_end = ImGui::FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string + else + text_display_end = text_end; + GameOverlay* overlay = SohImGui::overlay; - if (args[1] == "add") { - if (!overlay->RegisteredOverlays.contains(key)) { - overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); - INFO("Added overlay: %s ", key); - } else { - ERROR("Overlay already exists: %s", key); - } - } else if (args[1] == "remove") { - if (overlay->RegisteredOverlays.contains(key)) { - overlay->RegisteredOverlays.erase(key); - INFO("Removed overlay: %s ", key); - } else { - ERROR("Overlay not found: %s ", key); - } - } - } else { - ERROR("CVar %s does not exist", args[2].c_str()); + + ImFont* font = overlay->CurrentFont == "Default" ? g.Font : overlay->Fonts[overlay->CurrentFont]; + const float font_size = font->FontSize; + if (text == text_display_end) + return ImVec2(0.0f, font_size); + ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); + + // Round + // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. + // FIXME: Investigate using ceilf or e.g. + // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c + // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html + text_size.x = IM_FLOOR(text_size.x + 0.99999f); + + return text_size; } - return CMD_SUCCESS; -} \ No newline at end of file + void GameOverlay::Init() { + this->LoadFont("Press Start 2P", "assets/ship_of_harkinian/fonts/PressStart2P-Regular.ttf", 12.0f); + this->LoadFont("Fipps", "assets/ship_of_harkinian/fonts/Fipps-Regular.otf", 32.0f); + const std::string DefaultFont = this->Fonts.begin()->first; + if (!this->Fonts.empty()) { + const std::string font = CVar_GetString("gOverlayFont", ImStrdup(DefaultFont.c_str())); + for (auto& [name, _] : this->Fonts) { + if (font.starts_with(name)) { + this->CurrentFont = name; + break; + } + this->CurrentFont = DefaultFont; + } + } + SohImGui::console->Commands["overlay"] = { OverlayCommand, "Draw an overlay using a cvar value" }; + } + + void GameOverlay::DrawSettings() { + ImGui::Text("Overlays Text Font"); + if (ImGui::BeginCombo("##TextFont", this->CurrentFont.c_str())) { + for (auto& [name, font] : this->Fonts) { + if (ImGui::Selectable(name.c_str(), name == this->CurrentFont)) { + this->CurrentFont = name; + CVar_SetString("gOverlayFont", ImStrdup(name.c_str())); + SohImGui::needs_save = true; + } + + } + ImGui::EndCombo(); + } + } + + + void GameOverlay::Draw() { + const ImGuiViewport* viewport = ImGui::GetMainViewport(); + + ImGui::SetNextWindowPos(viewport->Pos, ImGuiCond_Always); + ImGui::SetNextWindowSize(viewport->Size, ImGuiCond_Always); + ImGui::Begin("SoHOverlay", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoInputs); + + this->CleanupNotifications(); + + float textY = 50; + float notY = 0; + + for (auto& [key, overlay] : this->RegisteredOverlays) { + + if (overlay->type == OverlayType::TEXT) { + const char* text = ImStrdup(overlay->value); + const CVar* var = CVar_Get(text); + ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + + switch (var->type) { + case CVarType::Float: + this->TextDraw(30, textY, true, color, "%s %.2f", text, var->value.valueFloat); + break; + case CVarType::S32: + this->TextDraw(30, textY, true, color, "%s %d", text, var->value.valueS32); + break; + case CVarType::String: + this->TextDraw(30, textY, true, color, "%s %s", text, var->value.valueStr); + break; + case CVarType::RGBA: + this->TextDraw(30, textY, true, color, "#%08X", text, var->value.valueRGBA); + break; + } + + free((void*)text); + textY += 30; + } + + if (overlay->type == OverlayType::NOTIFICATION && overlay->duration > 0) { + const char* text = overlay->value; + const float duration = overlay->duration / overlay->fadeTime; + + const ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, duration); + const float textWidth = this->GetStringWidth(overlay->value); + + this->TextDraw(GetScreenWidth() - textWidth - 40, GetScreenHeight() - 40 - notY, true, color, text); + notY += 30; + overlay->duration -= .05f; + } + } + + ImGui::End(); + } + + + bool OverlayCommand(const std::vector& args) { + if (args.size() < 3) { + return CMD_FAILED; + } + + if (CVar_Get(args[2].c_str()) != nullptr) { + const char* key = args[2].c_str(); + GameOverlay* overlay = SohImGui::overlay; + if (args[1] == "add") { + if (!overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays[key] = new Overlay({ OverlayType::TEXT, ImStrdup(key), -1.0f }); + INFO("Added overlay: %s ", key); + } + else { + ERROR("Overlay already exists: %s", key); + } + } + else if (args[1] == "remove") { + if (overlay->RegisteredOverlays.contains(key)) { + overlay->RegisteredOverlays.erase(key); + INFO("Removed overlay: %s ", key); + } + else { + ERROR("Overlay not found: %s ", key); + } + } + } + else { + ERROR("CVar %s does not exist", args[2].c_str()); + } + + return CMD_SUCCESS; + } +} diff --git a/libultraship/libultraship/GameOverlay.h b/libultraship/libultraship/GameOverlay.h index c9290390e4..061d259ba8 100644 --- a/libultraship/libultraship/GameOverlay.h +++ b/libultraship/libultraship/GameOverlay.h @@ -3,21 +3,21 @@ #include #include "Lib/ImGui/imgui.h" -#include #include -enum class OverlayType { - TEXT, IMAGE, NOTIFICATION -}; - -struct Overlay { - OverlayType type; - const char* value; - float fadeTime; - float duration; -}; - namespace Ship { + + enum class OverlayType { + TEXT, IMAGE, NOTIFICATION + }; + + struct Overlay { + OverlayType type; + const char* value; + float fadeTime; + float duration; + }; + class GameOverlay { public: std::unordered_map RegisteredOverlays; diff --git a/libultraship/libultraship/libultraship.vcxproj.filters b/libultraship/libultraship/libultraship.vcxproj.filters index f84250c290..d807349a29 100644 --- a/libultraship/libultraship/libultraship.vcxproj.filters +++ b/libultraship/libultraship/libultraship.vcxproj.filters @@ -82,9 +82,6 @@ {bd6557f1-9480-413b-b0cd-843f8efc1939} - - {3285ab8a-06d8-4dac-9af9-efb2a9723ab1} - {db6e02cc-fc4c-4138-8219-1d281ad93ec2} @@ -97,6 +94,9 @@ {010dc29b-d1f6-4793-a4e7-4156aa4fcdd6} + + {5d68254f-662d-4e8c-a57f-de0d8e1d4a58} + @@ -300,12 +300,6 @@ Source Files\Lib\ImGui - - Source Files\CustomImpl - - - Source Files\CustomImpl - Source Files\Lib\ImGui @@ -342,9 +336,6 @@ Source Files\CustomImpl - - Source Files\CustomImpl\Overlay - Source Files\Resources\Files @@ -360,6 +351,15 @@ Source Files\Lib\Mercury + + Source Files\GUI + + + Source Files\GUI + + + Source Files\GUI + @@ -587,12 +587,6 @@ Source Files\Lib\ImGui - - Source Files\CustomImpl - - - Source Files\CustomImpl - Source Files\Lib\ImGui @@ -647,9 +641,6 @@ Header Files - - Source Files\CustomImpl\Overlay - Header Files\Resources\Files @@ -677,5 +668,14 @@ Source Files\Controller + + Source Files\GUI + + + Source Files\GUI + + + Source Files\GUI + \ No newline at end of file From fd379896d6ae16f91a85ee6039e22f6dc6bc5a33 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 23:14:25 -0400 Subject: [PATCH 18/31] LUS Cleanup: Clean up hooks system. --- libultraship/libultraship/GameSettings.cpp | 4 ++-- libultraship/libultraship/Hooks.cpp | 10 --------- libultraship/libultraship/Hooks.h | 22 +++---------------- libultraship/libultraship/ImGuiImpl.cpp | 6 ++--- .../libultraship/Lib/Fast3D/gfx_dxgi.cpp | 2 +- .../libultraship/Lib/Fast3D/gfx_pc.cpp | 2 +- .../libultraship/Lib/Fast3D/gfx_sdl2.cpp | 4 ++-- libultraship/libultraship/Window.cpp | 15 +++++-------- .../libultraship/libultraship.vcxproj | 1 - .../libultraship/libultraship.vcxproj.filters | 3 --- soh/soh/OTRGlobals.cpp | 10 ++++----- soh/soh/OTRGlobals.h | 1 + soh/src/code/audioMgr.c | 4 ++-- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 1 - 14 files changed, 26 insertions(+), 59 deletions(-) delete mode 100644 libultraship/libultraship/Hooks.cpp diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index e3f95ad76a..d6af513993 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -41,8 +41,8 @@ namespace Game { } void InitSettings() { - ModInternal::RegisterHook(UpdateAudio); - ModInternal::RegisterHook([] { + Ship::RegisterHook(UpdateAudio); + Ship::RegisterHook([] { gfx_get_current_rendering_api()->set_texture_filter((FilteringMode) CVar_GetS32("gTextureFilter", FILTER_THREE_POINT)); SohImGui::console->opened = CVar_GetS32("gConsoleEnabled", 0); SohImGui::controller->Opened = CVar_GetS32("gControllerConfigurationEnabled", 0); diff --git a/libultraship/libultraship/Hooks.cpp b/libultraship/libultraship/Hooks.cpp deleted file mode 100644 index 2b66ed318e..0000000000 --- a/libultraship/libultraship/Hooks.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Hooks.h" -#include -#include -#include -#include -#include - -void ModInternal_ExecuteAudioInitHooks() { - ModInternal::ExecuteHooks(); -} diff --git a/libultraship/libultraship/Hooks.h b/libultraship/libultraship/Hooks.h index 411cffe42e..5f29a831cd 100644 --- a/libultraship/libultraship/Hooks.h +++ b/libultraship/libultraship/Hooks.h @@ -1,15 +1,12 @@ #pragma once -#ifdef __cplusplus - #include - #include "UltraController.h" -#include "Controller.h" #define DEFINE_HOOK(name, type) struct name { typedef std::function fn; } -namespace ModInternal { +namespace Ship { + class Controller; template struct RegisteredHooks { @@ -29,22 +26,9 @@ namespace ModInternal { } DEFINE_HOOK(ControllerRead, void(OSContPad* cont_pad)); - DEFINE_HOOK(ControllerRawInput, void(Ship::Controller* backend, uint32_t raw)); + DEFINE_HOOK(ControllerRawInput, void(Controller* backend, uint32_t raw)); DEFINE_HOOK(AudioInit, void()); DEFINE_HOOK(LoadTexture, void(const char* path, uint8_t** texture)); DEFINE_HOOK(GfxInit, void()); DEFINE_HOOK(ExitGame, void()); - } - -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -void ModInternal_ExecuteAudioInitHooks(); - -#ifdef __cplusplus -} -#endif diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index e6f7a31c68..1a0a79bf91 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -24,7 +24,7 @@ #include "Lib/stb/stb_image.h" #include "Lib/Fast3D/gfx_rendering_api.h" #include "Lib/spdlog/include/spdlog/common.h" -#include "Utils/StringHelper.h" +#include "UltraController.h" #if __APPLE__ #include @@ -385,7 +385,7 @@ namespace SohImGui { ImGui::GetStyle().ScaleAllSizes(2); #endif - ModInternal::RegisterHook([] { + Ship::RegisterHook([] { if (GlobalCtx2::GetInstance()->GetWindow()->IsFullscreen()) ShowCursor(CVar_GetS32("gOpenMenuBar", 0), Dialogues::dLoadSettings); @@ -402,7 +402,7 @@ namespace SohImGui { LoadTexture("C-Down", "assets/ship_of_harkinian/buttons/CDown.png"); }); - ModInternal::RegisterHook([](OSContPad* cont_pad) { + Ship::RegisterHook([](OSContPad* cont_pad) { pads = cont_pad; }); diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp index aabeb0acf8..1bf67891b2 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp @@ -240,7 +240,7 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par dxgi.current_height = (uint32_t)(l_param >> 16); break; case WM_DESTROY: - ModInternal::ExecuteHooks(); + Ship::ExecuteHooks(); exit(0); case WM_PAINT: if (dxgi.in_paint) { diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp index 25030afbee..8aebec9e22 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_pc.cpp @@ -2699,7 +2699,7 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co //gfx_lookup_or_create_shader_program(precomp_shaders[i]); } - ModInternal::ExecuteHooks(); + Ship::ExecuteHooks(); } struct GfxRenderingAPI *gfx_get_current_rendering_api(void) { diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index 2576bc17b1..06d88b78c4 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -239,7 +239,7 @@ static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) { #ifdef __SWITCH__ Ship::Switch::Exit(); #endif - ModInternal::ExecuteHooks(); + Ship::ExecuteHooks(); } static void gfx_sdl_get_dimensions(uint32_t *width, uint32_t *height) { @@ -309,7 +309,7 @@ static void gfx_sdl_handle_events(void) { Game::SaveSettings(); break; case SDL_QUIT: - ModInternal::ExecuteHooks(); + Ship::ExecuteHooks(); SDL_Quit(); // bandaid fix for linux window closing issue exit(0); } diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index 9c11f2d6d5..d3bdee369b 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -1,7 +1,6 @@ #include "Window.h" #include "spdlog/spdlog.h" #include "KeyboardController.h" -#include "SDLController.h" #include "GlobalCtx2.h" #include "DisplayList.h" #include "Vertex.h" @@ -11,22 +10,20 @@ #include "Blob.h" #include "Matrix.h" #include "AudioPlayer.h" +#include "Hooks.h" +#include "UltraController.h" #include "WasapiAudioPlayer.h" #include "PulseAudioPlayer.h" -#include "SDLAudioPlayer.h" #include "Lib/Fast3D/gfx_pc.h" #include "Lib/Fast3D/gfx_sdl.h" #include "Lib/Fast3D/gfx_opengl.h" -#include "stox.h" #if __APPLE__ #include #else #include #endif -#include #include #include -#include "Hooks.h" #include "Console.h" #include "Cvar.h" @@ -80,7 +77,7 @@ extern "C" { Ship::GlobalCtx2::GetInstance()->GetWindow()->GetControlDeck()->WriteToPad(pad); } - ModInternal::ExecuteHooks(pad); + Ship::ExecuteHooks(pad); } const char* ResourceMgr_GetNameByCRC(uint64_t crc) { @@ -126,7 +123,7 @@ extern "C" { if (hashStr != nullptr) { const auto res = LOAD_TEX(hashStr->c_str()); - ModInternal::ExecuteHooks(hashStr->c_str(), &res->imageData); + Ship::ExecuteHooks(hashStr->c_str(), &res->imageData); return reinterpret_cast(res->imageData); } else { @@ -153,7 +150,7 @@ extern "C" { char* ResourceMgr_LoadTexByName(char* texPath) { const auto res = LOAD_TEX(texPath); - ModInternal::ExecuteHooks(texPath, &res->imageData); + Ship::ExecuteHooks(texPath, &res->imageData); return (char*)res->imageData; } @@ -280,7 +277,7 @@ namespace Ship { WmApi->set_fullscreen_changed_callback(OnFullscreenChanged); WmApi->set_keyboard_callbacks(KeyDown, KeyUp, AllKeysUp); - ModInternal::RegisterHook([this]() { + Ship::RegisterHook([this]() { ControllerApi->SaveControllerSettings(); }); } diff --git a/libultraship/libultraship/libultraship.vcxproj b/libultraship/libultraship/libultraship.vcxproj index 52df7d3959..95250d4b1a 100644 --- a/libultraship/libultraship/libultraship.vcxproj +++ b/libultraship/libultraship/libultraship.vcxproj @@ -282,7 +282,6 @@ - diff --git a/libultraship/libultraship/libultraship.vcxproj.filters b/libultraship/libultraship/libultraship.vcxproj.filters index d807349a29..bf51936824 100644 --- a/libultraship/libultraship/libultraship.vcxproj.filters +++ b/libultraship/libultraship/libultraship.vcxproj.filters @@ -327,9 +327,6 @@ Source Files\ModManager - - Source Files\CustomImpl\Hooks - Source Files\Logging diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 2bdf80e682..41347264ec 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -4,9 +4,7 @@ #include #include #include -#include #include "GlobalCtx2.h" -#include "GameSettings.h" #include "ResourceMgr.h" #include "DisplayList.h" #include "PlayerAnimation.h" @@ -22,11 +20,9 @@ #else #include #endif -#include #include #include #include -#include #include "Lib/stb/stb_image.h" #define DRMP3_IMPLEMENTATION #include "Lib/dr_libs/mp3.h" @@ -40,10 +36,10 @@ #include #include "Enhancements/n64_weird_frame_data.inc" #include "soh/frame_interpolation.h" -#include "Utils/BitConverter.h" #include "variables.h" #include "macros.h" #include +#include "Hooks.h" #ifdef __APPLE__ #include @@ -1376,6 +1372,10 @@ extern "C" int Controller_ShouldRumble(size_t i) { return 0; } +extern "C" void Hooks_ExecuteAudioInit() { + Ship::ExecuteHooks(); +} + extern "C" void* getN64WeirdFrame(s32 i) { char* weirdFrameBytes = reinterpret_cast(n64WeirdFrames); return &weirdFrameBytes[i + sizeof(n64WeirdFrames)]; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index d838b94dfd..018c3c9414 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -85,6 +85,7 @@ int AudioPlayer_GetDesiredBuffered(void); void AudioPlayer_Play(const uint8_t* buf, uint32_t len); void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples); int Controller_ShouldRumble(size_t i); +void Hooks_ExecuteAudioInit(); void* getN64WeirdFrame(s32 i); Sprite* GetSeedTexture(uint8_t index); void Randomizer_LoadSettings(const char* spoilerFileName); diff --git a/soh/src/code/audioMgr.c b/soh/src/code/audioMgr.c index dc826aa5c0..35c21ab950 100644 --- a/soh/src/code/audioMgr.c +++ b/soh/src/code/audioMgr.c @@ -1,6 +1,6 @@ #include "global.h" -#include "Hooks.h" #include +#include "soh/OTRGlobals.h" void func_800C3C80(AudioMgr* audioMgr) { AudioTask* task; @@ -108,7 +108,7 @@ void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedCon AudioLoad_SetDmaHandler(DmaMgr_DmaHandler); Audio_InitSound(); osSendMesgPtr(&audioMgr->unk_C8, NULL, OS_MESG_BLOCK); - ModInternal_ExecuteAudioInitHooks(); + Hooks_ExecuteAudioInit(); // Removed due to crash //IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->unk_74); hasInitialized = true; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 2735ed9b42..66967e9a45 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -12,7 +12,6 @@ #include "textures/map_name_static/map_name_static.h" #include "textures/map_48x85_static/map_48x85_static.h" #include "vt.h" -#include "Hooks.h" #include "soh/frame_interpolation.h" From 4ce19e144833d93ed4cb03d836ebb7aa67063093 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 20:04:29 -0400 Subject: [PATCH 19/31] LUS Cleanup: Only including the correct audio player header file. --- libultraship/libultraship/AudioPlayer.h | 9 +++++++++ libultraship/libultraship/Window.cpp | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libultraship/libultraship/AudioPlayer.h b/libultraship/libultraship/AudioPlayer.h index 346239624b..739531c511 100644 --- a/libultraship/libultraship/AudioPlayer.h +++ b/libultraship/libultraship/AudioPlayer.h @@ -1,5 +1,14 @@ #pragma once #include "stdint.h" +#ifndef _MSC_VER +#include "SDLAudioPlayer.h" +#endif +#ifdef _MSC_VER +#include "WasapiAudioPlayer.h" +#endif +#ifdef __APPLE__ +#include "PulseAudioPlayer.h" +#endif namespace Ship { class AudioPlayer { diff --git a/libultraship/libultraship/Window.cpp b/libultraship/libultraship/Window.cpp index d3bdee369b..86e1e12e01 100644 --- a/libultraship/libultraship/Window.cpp +++ b/libultraship/libultraship/Window.cpp @@ -12,8 +12,6 @@ #include "AudioPlayer.h" #include "Hooks.h" #include "UltraController.h" -#include "WasapiAudioPlayer.h" -#include "PulseAudioPlayer.h" #include "Lib/Fast3D/gfx_pc.h" #include "Lib/Fast3D/gfx_sdl.h" #include "Lib/Fast3D/gfx_opengl.h" From 7675309e3fd0583da1f10a4cdd9db99c60de5817 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 20:20:15 -0400 Subject: [PATCH 20/31] Moves specific audio player header file include to after the definition of AudioPlayer class in AudioPlayer.h --- libultraship/libultraship/AudioPlayer.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libultraship/libultraship/AudioPlayer.h b/libultraship/libultraship/AudioPlayer.h index 739531c511..cd8aa75cbf 100644 --- a/libultraship/libultraship/AudioPlayer.h +++ b/libultraship/libultraship/AudioPlayer.h @@ -1,14 +1,5 @@ #pragma once #include "stdint.h" -#ifndef _MSC_VER -#include "SDLAudioPlayer.h" -#endif -#ifdef _MSC_VER -#include "WasapiAudioPlayer.h" -#endif -#ifdef __APPLE__ -#include "PulseAudioPlayer.h" -#endif namespace Ship { class AudioPlayer { @@ -23,3 +14,13 @@ namespace Ship { constexpr int GetSampleRate() const { return 44100; } }; } + +#if !_MSC_VER && !__APPLE__ +#include "SDLAudioPlayer.h" +#endif +#ifdef _MSC_VER +#include "WasapiAudioPlayer.h" +#endif +#ifdef __APPLE__ +#include "PulseAudioPlayer.h" +#endif From e68fac14c892e9658e9707ad4a40f3df08abf8cc Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 20:40:33 -0400 Subject: [PATCH 21/31] Uses correct audio player per platform now. --- libultraship/libultraship/AudioPlayer.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libultraship/libultraship/AudioPlayer.h b/libultraship/libultraship/AudioPlayer.h index cd8aa75cbf..c2b010babb 100644 --- a/libultraship/libultraship/AudioPlayer.h +++ b/libultraship/libultraship/AudioPlayer.h @@ -16,11 +16,11 @@ namespace Ship { } #if !_MSC_VER && !__APPLE__ +#endif +#ifdef _WIN32 +#include "WasapiAudioPlayer.h" +#elif defined(__linux) +#include "PulseAudioPlayer.h" +#else #include "SDLAudioPlayer.h" #endif -#ifdef _MSC_VER -#include "WasapiAudioPlayer.h" -#endif -#ifdef __APPLE__ -#include "PulseAudioPlayer.h" -#endif From 212d774613525d764084476bb5d5462dec951abc Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 20:56:04 -0400 Subject: [PATCH 22/31] Clean up unnecessary compiler checks. --- libultraship/libultraship/AudioPlayer.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/libultraship/libultraship/AudioPlayer.h b/libultraship/libultraship/AudioPlayer.h index c2b010babb..863cac8751 100644 --- a/libultraship/libultraship/AudioPlayer.h +++ b/libultraship/libultraship/AudioPlayer.h @@ -15,8 +15,6 @@ namespace Ship { }; } -#if !_MSC_VER && !__APPLE__ -#endif #ifdef _WIN32 #include "WasapiAudioPlayer.h" #elif defined(__linux) From 6d3d5e7da5e8728adcf678a9febfb01aa86746c0 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 21:22:07 -0400 Subject: [PATCH 23/31] LUS Cleanup: Removes unnecessary ModManager class. --- libultraship/libultraship/GameOverlay.cpp | 1 - libultraship/libultraship/GlobalCtx2.cpp | 5 - libultraship/libultraship/ImGuiImpl.cpp | 1 - libultraship/libultraship/ModManager.cpp | 23 ---- libultraship/libultraship/ModManager.h | 12 -- libultraship/libultraship/ModModule.h | 19 --- libultraship/libultraship/TextureMod.cpp | 128 ------------------ libultraship/libultraship/TextureMod.h | 55 -------- .../libultraship/libultraship.vcxproj | 5 - .../libultraship/libultraship.vcxproj.filters | 21 --- 10 files changed, 270 deletions(-) delete mode 100644 libultraship/libultraship/ModManager.cpp delete mode 100644 libultraship/libultraship/ModManager.h delete mode 100644 libultraship/libultraship/ModModule.h delete mode 100644 libultraship/libultraship/TextureMod.cpp delete mode 100644 libultraship/libultraship/TextureMod.h diff --git a/libultraship/libultraship/GameOverlay.cpp b/libultraship/libultraship/GameOverlay.cpp index 01d889dd63..00bab575fb 100644 --- a/libultraship/libultraship/GameOverlay.cpp +++ b/libultraship/libultraship/GameOverlay.cpp @@ -6,7 +6,6 @@ #include "ResourceMgr.h" #include "Console.h" #include "ImGuiImpl.h" -#include "TextureMod.h" #include "Lib/ImGui/imgui_internal.h" #include "Utils/StringHelper.h" diff --git a/libultraship/libultraship/GlobalCtx2.cpp b/libultraship/libultraship/GlobalCtx2.cpp index 5eb449ad37..4d6046de39 100644 --- a/libultraship/libultraship/GlobalCtx2.cpp +++ b/libultraship/libultraship/GlobalCtx2.cpp @@ -7,7 +7,6 @@ #include "spdlog/sinks/rotating_file_sink.h" #include "spdlog/sinks/stdout_color_sinks.h" #include "spdlog/sinks/sohconsole_sink.h" -#include "ModManager.h" #ifdef __APPLE__ #include "OSXFolderManager.h" #elif defined(__SWITCH__) @@ -16,7 +15,6 @@ namespace Ship { std::weak_ptr GlobalCtx2::Context; - ModManager* INSTANCE; std::shared_ptr GlobalCtx2::GetInstance() { return Context.lock(); } @@ -56,7 +54,6 @@ namespace Ship { GlobalCtx2::~GlobalCtx2() { SPDLOG_INFO("destruct GlobalCtx2"); - INSTANCE->Exit(); } void GlobalCtx2::InitWindow() { @@ -84,8 +81,6 @@ namespace Ship { #ifdef __SWITCH__ Ship::Switch::Init(PostInitPhase); #endif - INSTANCE = new ModManager(ResMan); - INSTANCE->Init(); } void GlobalCtx2::InitLogging() { diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 1a0a79bf91..583d36f014 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -15,7 +15,6 @@ #include "Lib/ImGui/imgui_internal.h" #include "GlobalCtx2.h" #include "ResourceMgr.h" -#include "TextureMod.h" #include "Window.h" #include "Cvar.h" #include "GameOverlay.h" diff --git a/libultraship/libultraship/ModManager.cpp b/libultraship/libultraship/ModManager.cpp deleted file mode 100644 index 8aa2715dee..0000000000 --- a/libultraship/libultraship/ModManager.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "ModManager.h" -#include "TextureMod.h" -#include "ModModule.h" -#include "ImGuiImpl.h" - -namespace Ship { - std::vector modules; - - void ModManager::Init() { - // ResManager->GetArchive()->loa - // modules.push_back(new TextureModule(this)); - // std::shared_ptr archive = std::make_shared("mods/TexMods.otr", "", false); - for (auto& mod : modules) { - mod->Init(); - // mod->Open(archive); - } - } - - void ModManager::Exit() { - for (auto& mod : modules) - mod->Exit(); - } -} \ No newline at end of file diff --git a/libultraship/libultraship/ModManager.h b/libultraship/libultraship/ModManager.h deleted file mode 100644 index ca25355b58..0000000000 --- a/libultraship/libultraship/ModManager.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "ResourceMgr.h" - -namespace Ship { - class ModManager { - public: - std::shared_ptr ResManager; - explicit ModManager(std::shared_ptr manager) : ResManager(manager) {} - void Init(); - void Exit(); - }; -} \ No newline at end of file diff --git a/libultraship/libultraship/ModModule.h b/libultraship/libultraship/ModModule.h deleted file mode 100644 index da62273dbb..0000000000 --- a/libultraship/libultraship/ModModule.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "ModManager.h" -#include "Hooks.h" -#include "Console.h" -#include "Archive.h" - -namespace Ship { - class ModModule { - protected: - ModManager* Manager; - public: - virtual ~ModModule() = default; - explicit ModModule(ModManager* Manager) : Manager(Manager) {} - virtual void Init() = 0; - virtual void Open(std::shared_ptr archive) = 0; - virtual void Close(Ship::Archive archive) = 0; - virtual void Exit() = 0; - }; -} \ No newline at end of file diff --git a/libultraship/libultraship/TextureMod.cpp b/libultraship/libultraship/TextureMod.cpp deleted file mode 100644 index 87f17ed2ca..0000000000 --- a/libultraship/libultraship/TextureMod.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "TextureMod.h" - -#if 0 - -#include -#include -#include -#include -#include -#include "Lib/stb/stb_image.h" -#include "Lib/Fast3D/gfx_pc.h" -#define STB_IMAGE_WRITE_IMPLEMENTATION -#include "Lib/stb/stb_image_write.h" -#include "Lib/Fast3D/gfx_rendering_api.h" -#include "SohImGuiImpl.h" - -namespace fs = std::filesystem; - -namespace Ship { - void TextureModule::Init() { - BIND_HOOK(LOOKUP_TEXTURE, Hook_LookupTexture); - BIND_HOOK(GRAYOUT_TEXTURE, Hook_GrayScaleFilter); - BIND_HOOK(INVALIDATE_TEXTURE, Hook_InvalidateTexture); - - SohImGui::BindCmd("reload", { .handler = [&](const std::vector&) { - INFO("Reloading all textures!"); - gfx_texture_cache_clear(); - this->TexturePool.clear(); - this->TextureCache.clear(); - return true; - } }); - } - - void TextureModule::Open(std::shared_ptr archive) { - this->LoadedOTRS.push_back(archive); - } - - void TextureModule::Close(Ship::Archive otr) { - // Remove all loaded textures - // this->LoadedOTRS.erase(std::find(this->LoadedOTRS.begin(), this->LoadedOTRS.end(), otr)); - } - - void TextureModule::Hook_LookupTexture(HookEvent call) { - const auto raw_path = BIND_PTR("path", char*); - if (raw_path == nullptr) return; - - const auto api = BIND_PTR("gfx_api", GfxRenderingAPI*); - const auto path = std::string(raw_path) + ".png"; - const auto node = BIND_PTR("node", TextureCacheNode**); - const auto fmt = BIND_VAR("fmt", uint32_t*); - const auto siz = BIND_VAR("siz", uint32_t*); - const auto tile = BIND_VAR("tile", int*); - const auto palette = BIND_VAR("palette", uint32_t*); - const auto orig_addr = BIND_VAR("addr", const uint8_t**); - - // INFO("The game is trying to load %s", path.c_str()); - - if (this->TextureCache.contains(path) && this->TextureCache[path][tile] != nullptr) { - *node = this->TextureCache[path][tile]; - api->select_texture(tile, (*node)->second.texture_id); - call->cancelled = true; - return; - } - - // OTRTODO: Implement loading order - TextureData* tex_data = nullptr; - if (!this->TexturePool.contains(path)) { - std::shared_ptr raw_data = std::make_shared(); - this->Manager->ResManager->GetArchive()->LoadPatchFile(path, false, raw_data); - - if (raw_data->bIsLoaded) { - char* tdata = new char[raw_data->dwBufferSize]; - memcpy(tdata, raw_data->buffer.get(), raw_data->dwBufferSize); - tex_data = new TextureData({ .data = tdata, .size = raw_data->dwBufferSize }); - INFO("Loaded %s", path.c_str()); - this->TexturePool[path] = tex_data; - } - } - - if (tex_data == nullptr) - return; - - if (!this->TextureCache.contains(path)) this->TextureCache[path].resize(10); - - TextureCacheKey key = { orig_addr, { }, static_cast(fmt), static_cast(siz), static_cast(palette) }; - TextureCacheValue value = { api->new_texture(), 0, 0, false }; - const auto entry = new TextureCacheNode(key, value); - api->select_texture(tile, entry->second.texture_id); - api->set_sampler_parameters(tile, false, 0, 0); - *node = entry; - - uint8_t* img_data = stbi_load_from_memory(reinterpret_cast(tex_data->data), tex_data->size, &tex_data->width, &tex_data->height, nullptr, 4); - - if (!img_data) - return; - - switch (tex_data->color_modifier) { - case GRAYSCALE: { - GrayOutTexture(img_data, tex_data->width, tex_data->height); - } - default:; - } - - std::cout << "Uploading to the GPU" << std::endl; - api->upload_texture(img_data, tex_data->width, tex_data->height); - this->TextureCache[path][tile] = entry; - - stbi_image_free(img_data); - call->cancelled = true; - } - - - void TextureModule::Hook_GrayScaleFilter(HookEvent event) { - // this->Exit(); - } - - void TextureModule::Hook_InvalidateTexture(HookEvent event) { - // this->Exit(); - } - - void TextureModule::Exit() { - TextureCache.clear(); - TexturePool.clear(); - LoadedOTRS.clear(); - } -} - -#endif diff --git a/libultraship/libultraship/TextureMod.h b/libultraship/libultraship/TextureMod.h deleted file mode 100644 index 5f41873cae..0000000000 --- a/libultraship/libultraship/TextureMod.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "ModModule.h" -#include -#include "Lib/Fast3D/gfx_pc.h" - -#if 0 - -namespace Ship { - enum TextureMod { - GRAYSCALE, - NONE - }; - - struct TextureData { - char* data; - uint32_t size; - int width; - int height; - char* loaded_data; - std::shared_ptr parent; - TextureMod color_modifier = NONE; - }; - - class TextureModule : public ModModule { - public: - explicit TextureModule(ModManager* Manager) : ModModule(Manager) {} - private: - std::vector> LoadedOTRS; - std::map TexturePool; - std::map> TextureCache; - void Init() override; - void Open(std::shared_ptr archive) override; - void Close(Ship::Archive mod) override; - void Exit() override; - protected: - void Hook_LookupTexture(HookEvent event); - void Hook_GrayScaleFilter(HookEvent event); - void Hook_InvalidateTexture(HookEvent event); - }; - - inline void GrayOutTexture(uint8_t* data, int width, int height) { - for (int x = 0; x < width * height * 4; x += 4) { - - int red = data[x]; - int green = data[x + 1]; - int blue = data[x + 2]; - int gray = (red + green + blue) / 3; - data[x] = gray; - data[x + 1] = gray; - data[x + 2] = gray; - } - } -} - -#endif diff --git a/libultraship/libultraship/libultraship.vcxproj b/libultraship/libultraship/libultraship.vcxproj index 95250d4b1a..f677dfe5ea 100644 --- a/libultraship/libultraship/libultraship.vcxproj +++ b/libultraship/libultraship/libultraship.vcxproj @@ -267,7 +267,6 @@ - @@ -332,7 +331,6 @@ - @@ -364,8 +362,6 @@ - - @@ -404,7 +400,6 @@ - diff --git a/libultraship/libultraship/libultraship.vcxproj.filters b/libultraship/libultraship/libultraship.vcxproj.filters index bf51936824..b7fe847ce8 100644 --- a/libultraship/libultraship/libultraship.vcxproj.filters +++ b/libultraship/libultraship/libultraship.vcxproj.filters @@ -70,12 +70,6 @@ {0dca2d94-45ba-4916-b03a-1dd5f949114c} - - {8e970531-d0cd-4c29-9800-a7e6edc92036} - - - {05f273a3-f147-430e-9853-aeef59e6288d} - {cc8de11b-7305-4482-853f-7f0f843eef28} @@ -321,12 +315,6 @@ Source Files\Globals - - Source Files\ModManager\ModModule - - - Source Files\ModManager - Source Files\Logging @@ -614,15 +602,6 @@ Source Files\Lib\stb - - Source Files\ModManager\ModModule - - - Source Files\ModManager - - - Source Files\ModManager\ModModule - Source Files\CustomImpl\Hooks From 8c9d067657e55c38346f2dc814e85d68233c7b89 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 22:25:27 -0400 Subject: [PATCH 24/31] LUS Cleanup: CVars functions are now consistent --- libultraship/libultraship/Cvar.cpp | 6 ++---- libultraship/libultraship/Cvar.h | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index d5b3af7508..c20aec25a4 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -4,8 +4,6 @@ #include #include #include -#include -#include "imgui_internal.h" std::map, std::less<>> cvars; @@ -96,7 +94,7 @@ extern "C" void CVar_SetS32(const char* name, int32_t value) { cvar->value.valueS32 = value; } -void CVar_SetFloat(const char* name, float value) { +extern "C" void CVar_SetFloat(const char* name, float value) { auto& cvar = cvars[name]; if (!cvar) { cvar = std::make_unique(); @@ -111,7 +109,7 @@ extern "C" void CVar_SetString(const char* name, const char* value) { cvar = std::make_unique(); } cvar->type = CVarType::String; - cvar->value.valueStr = ImStrdup(value); + cvar->value.valueStr = _strdup(value); } extern "C" void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue) { diff --git a/libultraship/libultraship/Cvar.h b/libultraship/libultraship/Cvar.h index b8f294be60..e6225610d8 100644 --- a/libultraship/libultraship/Cvar.h +++ b/libultraship/libultraship/Cvar.h @@ -32,14 +32,13 @@ extern "C" CVar * CVar_Get(const char* name); extern "C" { #endif -//#include int32_t CVar_GetS32(const char* name, int32_t defaultValue); float CVar_GetFloat(const char* name, float defaultValue); +void CVar_SetFloat(const char* name, float value); const char* CVar_GetString(const char* name, const char* defaultValue); void CVar_SetS32(const char* name, int32_t value); void CVar_SetString(const char* name, const char* value); - Color_RGB8 CVar_GetRGB(const char* name, Color_RGB8 defaultValue); Color_RGBA8 CVar_GetRGBA(const char* name, Color_RGBA8 defaultValue); void CVar_SetRGBA(const char* name, Color_RGBA8 value); @@ -56,11 +55,8 @@ void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue); #ifdef __cplusplus #include #include -#include #include -//extern "C" CVar * CVar_Get(const char* name); extern std::map, std::less<>> cvars; -void CVar_SetFloat(const char* name, float value); #endif #endif From 619038816494ea9046e11988cfde2030106bbcaf Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Tue, 2 Aug 2022 23:20:17 -0400 Subject: [PATCH 25/31] Now using posix strdrup on non-msvc builds. --- libultraship/libultraship/Cvar.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index c20aec25a4..c4fe75cc71 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -109,7 +109,11 @@ extern "C" void CVar_SetString(const char* name, const char* value) { cvar = std::make_unique(); } cvar->type = CVarType::String; +#ifdef _MSC_VER cvar->value.valueStr = _strdup(value); +#else + cvar->value.valueStr = strdup(value); +#endif } extern "C" void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue) { From 97adc4a7f2831b3f114a0824307b1756aba71a14 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 20:16:17 -0400 Subject: [PATCH 26/31] Changes string.h include in CVar.cpp --- libultraship/libultraship/Cvar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index c4fe75cc71..fa536e1bb4 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -1,6 +1,6 @@ #include "Cvar.h" #include -#include +#include #include #include #include From 0f7a88bd5a34e1ff21e6a7a3ef5ac9b81cafb0f8 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 22:36:13 -0400 Subject: [PATCH 27/31] This should fix (all?) 60fps interpolation issues left. (#938) * This should fix (all?) 60fps interpolation issues left. Resolves #631 #917 * Update z_fishing.c * Re-adds Emil's interpolation in certain places. * move open/close disps out of if statments checking timer based vars, revert fishing to use recordopen/closed child * move disps out of ifs for morpha * use recordopen/recordclose for volv * recordopen/recordclose for ganondorf * switch back to recordopen/recordclose for ganondorf floor * Frame interpolation now uses a 64bit parameter rather than 32. * More 60fps fixes * Fix close child typo * add todo calls to recordopen/recordclose * fix build * revert long long frame interpolation * add some epochs * add more epochs * bongo epochs * the rest of the epochs * fix the typo fix the build * interpolation fixes pr cleanup * init/cleanup bongo epochs * bongo hand trails * Fixes niw feathers * Fixes bongo bongo hands, and replaces epoch * i with epoch + i * don't update epochs Co-authored-by: briaguya --- soh/include/z64effect.h | 6 ++- soh/src/code/speed_meter.c | 4 +- soh/src/code/z_actor.c | 4 ++ soh/src/code/z_eff_shield_particle.c | 7 ++- soh/src/code/z_eff_spark.c | 6 +++ soh/src/code/z_kankyo.c | 28 ++++++++-- soh/src/code/z_lifemeter.c | 7 +++ .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 6 +++ .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h | 3 +- .../ovl_Bg_Jya_Megami/z_bg_jya_megami.c | 7 +++ .../ovl_Bg_Jya_Megami/z_bg_jya_megami.h | 3 +- .../z_bg_spot00_hanebasi.c | 7 +++ .../actors/ovl_Boss_Dodongo/z_boss_dodongo.c | 4 ++ .../actors/ovl_Boss_Dodongo/z_boss_dodongo.h | 3 +- .../overlays/actors/ovl_Boss_Fd/z_boss_fd.c | 6 +++ .../overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c | 5 ++ .../overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h | 3 +- .../actors/ovl_Boss_Ganon/z_boss_ganon.c | 30 +++++++++-- .../actors/ovl_Boss_Ganon2/z_boss_ganon2.c | 27 ++++++++++ .../overlays/actors/ovl_Boss_Mo/z_boss_mo.c | 7 +++ .../overlays/actors/ovl_Boss_Sst/z_boss_sst.c | 25 +++++++++ .../overlays/actors/ovl_Boss_Sst/z_boss_sst.h | 3 +- .../overlays/actors/ovl_Boss_Tw/z_boss_tw.c | 53 ++++++++++++++++++- .../overlays/actors/ovl_Boss_Tw/z_boss_tw.h | 1 + .../overlays/actors/ovl_Boss_Va/z_boss_va.c | 6 +++ .../overlays/actors/ovl_Demo_6K/z_demo_6k.c | 14 ++++- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 25 +++++++++ .../actors/ovl_Efc_Erupc/z_efc_erupc.c | 7 +++ .../actors/ovl_Efc_Erupc/z_efc_erupc.h | 3 +- .../overlays/actors/ovl_Eff_Dust/z_eff_dust.c | 13 +++++ .../ovl_En_Anubice_Fire/z_en_anubice_fire.c | 6 +++ .../ovl_En_Anubice_Fire/z_en_anubice_fire.h | 3 +- soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c | 6 +++ soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h | 3 +- soh/src/overlays/actors/ovl_En_Bx/z_en_bx.c | 6 +++ soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h | 3 +- .../actors/ovl_En_Clear_Tag/z_en_clear_tag.c | 23 ++++++++ .../actors/ovl_En_Clear_Tag/z_en_clear_tag.h | 3 +- .../actors/ovl_En_Encount2/z_en_encount2.c | 6 +++ .../actors/ovl_En_Encount2/z_en_encount2.h | 3 +- soh/src/overlays/actors/ovl_En_Fd/z_en_fd.c | 11 ++++ soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h | 1 + soh/src/overlays/actors/ovl_En_Fw/z_en_fw.c | 6 +++ soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h | 1 + soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c | 7 +++ soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h | 1 + .../actors/ovl_En_G_Switch/z_en_g_switch.c | 4 ++ .../actors/ovl_En_G_Switch/z_en_g_switch.h | 1 + soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c | 4 ++ soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h | 1 + soh/src/overlays/actors/ovl_En_Go/z_en_go.c | 8 +-- soh/src/overlays/actors/ovl_En_Go/z_en_go.h | 1 + soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c | 4 ++ soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c | 4 ++ soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h | 1 + soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c | 6 +++ soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h | 1 + soh/src/overlays/actors/ovl_En_Ny/z_en_ny.c | 4 ++ soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h | 1 + .../ovl_En_Po_Sisters/z_en_po_sisters.c | 7 ++- .../ovl_En_Po_Sisters/z_en_po_sisters.h | 1 + .../ovl_En_Syateki_Niw/z_en_syateki_niw.c | 4 ++ .../ovl_En_Syateki_Niw/z_en_syateki_niw.h | 1 + soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c | 4 ++ soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h | 1 + .../actors/ovl_En_Viewer/z_en_viewer.c | 5 ++ .../actors/ovl_En_Viewer/z_en_viewer.h | 1 + .../overlays/actors/ovl_Fishing/z_fishing.c | 21 ++++++-- .../overlays/actors/ovl_Mir_Ray/z_mir_ray.c | 5 ++ .../ovl_Object_Kankyo/z_object_kankyo.c | 2 + .../ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c | 4 ++ .../ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h | 1 + 72 files changed, 474 insertions(+), 35 deletions(-) diff --git a/soh/include/z64effect.h b/soh/include/z64effect.h index 1b35d46b61..8dce5b6a37 100644 --- a/soh/include/z64effect.h +++ b/soh/include/z64effect.h @@ -25,7 +25,8 @@ typedef struct { /* 0x0C */ Vec3f position; /* 0x18 */ Vec3s unkVelocity; /* 0x1E */ Vec3s unkPosition; -} EffectSparkElement; // size = 0x24 + /* 0x24 */ s32 epoch; +} EffectSparkElement; // size = 0x28 typedef struct { /* 0x000 */ Vec3s position; @@ -117,7 +118,8 @@ typedef struct { /* 0x10 */ f32 startX; /* 0x14 */ s16 yaw; /* 0x16 */ s16 pitch; -} EffectShieldParticleElement; // size = 0x18 + /* 0x18 */ s32 epoch; +} EffectShieldParticleElement; // size = 0x1C typedef struct { /* 0x00 */ u8 numElements; diff --git a/soh/src/code/speed_meter.c b/soh/src/code/speed_meter.c index f645c7bb5b..800eef0f06 100644 --- a/soh/src/code/speed_meter.c +++ b/soh/src/code/speed_meter.c @@ -55,13 +55,13 @@ void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) { uly = this->y; lry = this->y + 2; - OPEN_DISPS(gfxCtx); - /*! @bug if gIrqMgrRetraceTime is 0, CLOSE_DISPS will never be reached */ if (gIrqMgrRetraceTime == 0) { return; } + OPEN_DISPS(gfxCtx); + sSpeedMeterTimeEntryPtr = &sSpeedMeterTimeEntryArray[0]; for (i = 0; i < ARRAY_COUNT(sSpeedMeterTimeEntryArray); i++) { temp = ((f64) * (sSpeedMeterTimeEntryPtr->time) / gIrqMgrRetraceTime) * 64.0; diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 70771880c3..fc6e108258 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -3973,6 +3973,8 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { f32 chainsTranslateX; f32 chainsTranslateY; f32 rotZStep; + static s32 epoch = 0; + epoch++; entry = &sDoorLocksInfo[type]; chainRotZ = entry->chainsRotZInit; @@ -3986,6 +3988,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { chainsTranslateY = cosf(entry->chainAngle - chainRotZ) * (10 - frame) * 0.1f * entry->chainLength; for (i = 0; i < 4; i++) { + FrameInterpolation_RecordOpenChild(entry, epoch + i * 25); Matrix_Put(&baseMtxF); Matrix_RotateZ(chainRotZ, MTXMODE_APPLY); Matrix_Translate(chainsTranslateX, chainsTranslateY, 0.0f, MTXMODE_APPLY); @@ -4005,6 +4008,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { } chainRotZ += rotZStep; + FrameInterpolation_RecordCloseChild(); } Matrix_Put(&baseMtxF); diff --git a/soh/src/code/z_eff_shield_particle.c b/soh/src/code/z_eff_shield_particle.c index a5d9ca53fd..27032a6324 100644 --- a/soh/src/code/z_eff_shield_particle.c +++ b/soh/src/code/z_eff_shield_particle.c @@ -47,6 +47,7 @@ void EffectShieldParticle_Init(void* thisx, void* initParamsx) { elem->endXChange = elem->initialSpeed; elem->yaw = Rand_ZeroOne() * 65534.0f; elem->pitch = Rand_ZeroOne() * 65534.0f; + elem->epoch++; } this->lightDecay = initParams->lightDecay; @@ -156,7 +157,6 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { Color_RGBA8 primColor; Color_RGBA8 envColor; - FrameInterpolation_RecordOpenChild(this, 0); OPEN_DISPS(gfxCtx); if (this != NULL) { @@ -182,6 +182,8 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { gDPPipeSync(POLY_XLU_DISP++); for (elem = &this->elements[0]; elem < &this->elements[this->numElements]; elem++) { + FrameInterpolation_RecordOpenChild(elem, elem->epoch); + Mtx* mtx; MtxF sp104; MtxF spC4; @@ -212,9 +214,10 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(POLY_XLU_DISP++, sVertices, 4, 0); gSP2Triangles(POLY_XLU_DISP++, 0, 1, 2, 0, 0, 3, 1, 0); + + FrameInterpolation_RecordCloseChild(); } } CLOSE_DISPS(gfxCtx); - FrameInterpolation_RecordCloseChild(); } diff --git a/soh/src/code/z_eff_spark.c b/soh/src/code/z_eff_spark.c index 445fd7fea0..5ce6275082 100644 --- a/soh/src/code/z_eff_spark.c +++ b/soh/src/code/z_eff_spark.c @@ -89,6 +89,7 @@ void EffectSpark_Init(void* thisx, void* initParamsx) { elem->unkPosition.x = Rand_ZeroOne() * 65534.0f; elem->unkPosition.y = Rand_ZeroOne() * 65534.0f; elem->unkPosition.z = Rand_ZeroOne() * 65534.0f; + elem->epoch++; } this->timer = 0; @@ -210,6 +211,8 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { Mtx* mtx; f32 temp; + FrameInterpolation_RecordOpenChild(elem, elem->epoch); + SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z); temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) / 64.0f; SkinMatrix_SetScale(&spAC, temp, temp, 1.0f); @@ -264,6 +267,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &sp12C); if (mtx == NULL) { + FrameInterpolation_RecordCloseChild(); goto end; } @@ -273,6 +277,8 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { } gDPPipeSync(POLY_XLU_DISP++); + + FrameInterpolation_RecordCloseChild(); } end: diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index de654dfbb2..de8634f32a 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -3,6 +3,7 @@ #include "vt.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "soh/frame_interpolation.h" typedef enum { /* 0 */ LENS_FLARE_CIRCLE0, @@ -950,7 +951,6 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li Gfx* prevDisplayList; OPEN_DISPS(globalCtx->state.gfxCtx); - prevDisplayList = POLY_OPA_DISP; displayList = Graph_GfxPlusOne(POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, displayList); @@ -1459,6 +1459,8 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env LENS_FLARE_RING, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, LENS_FLARE_CIRCLE1, }; + static s32 epoch = 0; + epoch++; OPEN_DISPS(gfxCtx); @@ -1502,9 +1504,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env unk88Target = cosAngle; } - if (cosAngle < 0.0f) { - - } else { + if (!(cosAngle < 0.0f)) { if (arg9) { u32 shrink = ShrinkWindow_GetCurrentVal(); func_800C016C(globalCtx, &pos, &screenPos); @@ -1517,6 +1517,8 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env } for (i = 0; i < ARRAY_COUNT(lensFlareTypes); i++) { + FrameInterpolation_RecordOpenChild("Lens Flare", epoch + i * 25); + Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); if (arg9) { @@ -1573,6 +1575,8 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env gSPDisplayList(POLY_XLU_DISP++, gLensFlareRingDL); break; } + + FrameInterpolation_RecordCloseChild(); } alphaScale = cosAngle - (1.5f - cosAngle); @@ -1638,6 +1642,8 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* Vec3f unused = { 0.0f, 0.0f, 0.0f }; Vec3f windDirection = { 0.0f, 0.0f, 0.0f }; Player* player = GET_PLAYER(globalCtx); + static s32 epoch = 0; + epoch++; if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100) && (globalCtx->envCtx.unk_EE[2] == 0)) { OPEN_DISPS(gfxCtx); @@ -1667,6 +1673,8 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* // draw rain drops for (i = 0; i < globalCtx->envCtx.unk_EE[1]; i++) { + FrameInterpolation_RecordOpenChild("Rain Drop", epoch + i * 25); + temp2 = Rand_ZeroOne(); temp1 = Rand_ZeroOne(); temp3 = Rand_ZeroOne(); @@ -1692,6 +1700,8 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gRaindropDL); + + FrameInterpolation_RecordCloseChild(); } // draw droplet rings on the ground @@ -1699,6 +1709,8 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* u8 firstDone = false; for (i = 0; i < globalCtx->envCtx.unk_EE[1]; i++) { + FrameInterpolation_RecordOpenChild("Droplet Ring", epoch + i * 25); + if (!firstDone) { func_80093D84(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); @@ -1719,6 +1731,8 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); + + FrameInterpolation_RecordCloseChild(); } } @@ -1911,10 +1925,14 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { s32 pad[2]; Vec3f unused1 = { 0.0f, 0.0f, 0.0f }; Vec3f unused2 = { 0.0f, 0.0f, 0.0f }; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { + FrameInterpolation_RecordOpenChild("Lightning Bolt", epoch + i * 25); + switch (sLightningBolts[i].state) { case LIGHTNING_BOLT_START: dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; @@ -1969,6 +1987,8 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { gSPMatrix(POLY_XLU_DISP++, SEG_ADDR(1, 0), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffLightningDL); } + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index e1bafb3d27..400f0a2752 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -1,5 +1,6 @@ #include "global.h" #include "textures/parameter_static/parameter_static.h" +#include "soh/frame_interpolation.h" s16 Top_LM_Margin = 0; s16 Left_LM_Margin = 0; @@ -412,6 +413,8 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { s32 curCombineModeSet = 0; u8* curBgImgLoaded = NULL; s32 ddHeartCountMinusOne = gSaveContext.inventory.defenseHearts - 1; + static s32 epoch = 0; + epoch++; OPEN_DISPS(gfxCtx); @@ -449,6 +452,8 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { } for (i = 0; i < totalHeartCount; i++) { + FrameInterpolation_RecordOpenChild("HealthMeter Heart", epoch + i * 25); + if ((ddHeartCountMinusOne < 0) || (i > ddHeartCountMinusOne)) { if (i < fullHeartCount) { if (curColorSet != 0) { @@ -624,6 +629,8 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { offsetX = PosX_original; } } + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 7be483bd9a..0f1713ba8b 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -10,6 +10,7 @@ #include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h" #include "scenes/indoors/yousei_izumi_yoko/yousei_izumi_yoko_scene.h" #include "scenes/indoors/daiyousei_izumi/daiyousei_izumi_scene.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25) @@ -960,6 +961,7 @@ void BgDyYoseizo_ParticleInit(BgDyYoseizo* this, Vec3f* initPos, Vec3f* initVelo particle->pitch = 0.0f; particle->yaw = Rand_CenteredFloat(30000.0f); particle->roll = 0.0f; + particle->epoch++; return; } } @@ -1039,6 +1041,8 @@ void BgDyYoseizo_ParticleDraw(BgDyYoseizo* this, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); for (i = 0; i < 200; i++, particle++) { + FrameInterpolation_RecordOpenChild(particle, particle->epoch); + if (particle->alive == 1) { if (phi_s3 == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gGreatFairyParticleAppearDL)); @@ -1060,6 +1064,8 @@ void BgDyYoseizo_ParticleDraw(BgDyYoseizo* this, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gGreatFairyParticleAliveDL)); } + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h index 59abc6065c..401eb8b222 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.h @@ -24,7 +24,8 @@ typedef struct { /* 0x36 */ f32 pitch; /* 0x36 */ f32 yaw; /* 0x40 */ f32 roll; -} BgDyYoseizoParticle; // size = 0x44 + /* 0x44 */ s32 epoch; +} BgDyYoseizoParticle; // size = 0x48 typedef struct BgDyYoseizo { /* 0x0000 */ Actor actor; diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c b/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c index 1ac76f25b4..4b2bb78c5a 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.c @@ -1,6 +1,7 @@ #include "z_bg_jya_megami.h" #include "overlays/effects/ovl_Effect_Ss_Kakera/z_eff_ss_kakera.h" #include "objects/object_jya_obj/object_jya_obj.h" +#include "soh/frame_interpolation.h" #define FLAGS 0 @@ -217,6 +218,7 @@ void BgJyaMegami_SetupExplode(BgJyaMegami* this) { for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { Math_Vec3f_Copy(&this->pieces[i].pos, &this->dyna.actor.world.pos); this->pieces[i].vel.x = sPiecesInit[i].velX; + this->pieces[i].epoch++; } this->explosionTimer = 0; } @@ -326,6 +328,9 @@ void BgJyaMegami_DrawExplode(BgJyaMegami* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { piece = &this->pieces[i]; + + FrameInterpolation_RecordOpenChild(piece, piece->epoch); + Matrix_Translate(piece->pos.x + sPiecesInit[i].unk_00.x, piece->pos.y + sPiecesInit[i].unk_00.y, piece->pos.z + sPiecesInit[i].unk_00.z, MTXMODE_NEW); Matrix_RotateY(piece->rotVelY * (M_PI / 0x8000), MTXMODE_APPLY); @@ -337,6 +342,8 @@ void BgJyaMegami_DrawExplode(BgJyaMegami* this, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, sDLists[i]); + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h b/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h index f4a859c31f..4198781b07 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Megami/z_bg_jya_megami.h @@ -13,7 +13,8 @@ typedef struct { /* 0x0C */ Vec3f vel; /* 0x18 */ s16 rotVelX; /* 0x1A */ s16 rotVelY; -} BgJyaMegamiPiece; // size = 0x1C + /* 0x1C */ s32 epoch; +} BgJyaMegamiPiece; // size = 0x20 typedef struct BgJyaMegami { /* 0x0000 */ DynaPolyActor dyna; diff --git a/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c b/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c index 2385ee163a..d74a396247 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot00_Hanebasi/z_bg_spot00_hanebasi.c @@ -7,6 +7,7 @@ #include "z_bg_spot00_hanebasi.h" #include "objects/object_spot00_objects/object_spot00_objects.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "soh/frame_interpolation.h" #define FLAGS ACTOR_FLAG_4 @@ -260,6 +261,8 @@ void BgSpot00Hanebasi_DrawTorches(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; f32 angle; s32 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -276,6 +279,8 @@ void BgSpot00Hanebasi_DrawTorches(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); for (i = 0; i < 2; i++) { + FrameInterpolation_RecordOpenChild("Hanebasi Torch", epoch + i * 25); + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, ((globalCtx->gameplayFrames + i) * -20) & 0x1FF, 32, 128)); @@ -287,6 +292,8 @@ void BgSpot00Hanebasi_DrawTorches(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 37105d0408..045324978e 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -2,6 +2,7 @@ #include "objects/object_kingdodongo/object_kingdodongo.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "scenes/dungeons/ddan_boss/ddan_boss_room_1.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -150,6 +151,7 @@ void func_808C17C8(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, Vec3f* ar for (i = 0; i < arg5; i++, eff++) { if (eff->unk_24 == 0) { + eff->epoch++; eff->unk_24 = 1; eff->unk_00 = *arg1; eff->unk_0C = *arg2; @@ -1700,6 +1702,7 @@ void BossDodongo_DrawEffects(GlobalContext* globalCtx) { gSPInvalidateTexCache(POLY_XLU_DISP++, 0); for (i = 0; i < 80; i++, eff++) { + FrameInterpolation_RecordOpenChild(eff, eff->epoch); if (eff->unk_24 == 1) { gDPPipeSync(POLY_XLU_DISP++); @@ -1716,6 +1719,7 @@ void BossDodongo_DrawEffects(GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_kingdodongo_DL_009DD0); } + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h index 62aefe8cc0..f920b44a6c 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.h @@ -17,7 +17,8 @@ typedef struct { /* 0x26 */ Color_RGB8 color; /* 0x2A */ s16 alpha; /* 0x2C */ f32 unk_2C; -} BossDodongoEffect; // Size = 0x30 + /* 0x30 */ s32 epoch; +} BossDodongoEffect; // Size = 0x34 typedef struct BossDodongo { /* 0x0000 */ Actor actor; diff --git a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index f1620c2672..8afb08ba15 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -1835,6 +1835,8 @@ void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* this) { s16 i; f32 temp_float; Mtx* tempMat = Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Mtx)); + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); if (this->skinSegments != 0) { @@ -1876,6 +1878,8 @@ void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* this) { Matrix_Push(); for (i = 0; i < 18; i++, tempMat++) { + FrameInterpolation_RecordOpenChild(tempMat, epoch + i * 25); + segIndex = (this->work[BFD_LEAD_BODY_SEG] + sBodyIndex[i + 1]) % 100; Matrix_Translate(this->bodySegsPos[segIndex].x, this->bodySegsPos[segIndex].y, this->bodySegsPos[segIndex].z, MTXMODE_NEW); @@ -1938,6 +1942,8 @@ void BossFd_DrawBody(GlobalContext* globalCtx, BossFd* this) { if (i > 0) { Collider_UpdateSpheres(i + 1, &this->collider); } + + FrameInterpolation_RecordCloseChild(); } Matrix_Pop(); osSyncPrintf("BH\n"); diff --git a/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c b/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c index 5a891887e7..8915c068f0 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c +++ b/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.c @@ -9,6 +9,7 @@ #include "overlays/actors/ovl_Boss_Fd/z_boss_fd.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "vt.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -1146,6 +1147,8 @@ void BossFd2_UpdateMane(BossFd2* this, GlobalContext* globalCtx, Vec3f* head, Ve } for (i = 0; i < 9; i++) { + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); + Matrix_Translate((pos + i)->x, (pos + i)->y, (pos + i)->z, MTXMODE_NEW); Matrix_RotateY((rot + i)->y, MTXMODE_APPLY); Matrix_RotateX((rot + i)->x, MTXMODE_APPLY); @@ -1155,6 +1158,8 @@ void BossFd2_UpdateMane(BossFd2* this, GlobalContext* globalCtx, Vec3f* head, Ve gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gHoleVolvagiaManeModelDL); + + FrameInterpolation_RecordCloseChild(); } Matrix_Pop(); CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h b/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h index afafdbba32..3bc77b0b78 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h +++ b/soh/src/overlays/actors/ovl_Boss_Fd2/z_boss_fd2.h @@ -87,6 +87,7 @@ typedef struct BossFd2 { /* 0x1394 */ BossFd2Cam camData; /* 0x141C */ ColliderJntSph collider; /* 0x143C */ ColliderJntSphElement elements[9]; -} BossFd2; // size = 0x167C + /* 0x167C */ s32 epoch; +} BossFd2; // size = 0x1680 #endif diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index f7a85fc26d..10e118c172 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -3356,6 +3356,8 @@ void BossGanon_DrawShock(BossGanon* this, GlobalContext* globalCtx) { s32 pad; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(gfxCtx); @@ -3369,6 +3371,8 @@ void BossGanon_DrawShock(BossGanon* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); for (i = 0; i < ARRAY_COUNT(player->bodyPartsPos); i++) { + FrameInterpolation_RecordOpenChild("Ganondorf Shock 0", epoch + i * 25); + Matrix_Translate(player->bodyPartsPos[i].x, player->bodyPartsPos[i].y, player->bodyPartsPos[i].z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); @@ -3377,9 +3381,13 @@ void BossGanon_DrawShock(BossGanon* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); + + FrameInterpolation_RecordCloseChild(); } } else { for (i = 1; i < 15; i++) { + FrameInterpolation_RecordOpenChild("Ganondorf Shock 1", epoch + i * 25); + Matrix_Translate(this->unk_2EC[i].x, this->unk_2EC[i].y, this->unk_2EC[i].z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(this->unk_49C[i], this->unk_49C[i], this->unk_49C[i], MTXMODE_APPLY); @@ -3401,6 +3409,8 @@ void BossGanon_DrawShock(BossGanon* this, GlobalContext* globalCtx) { } else { gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); } + + FrameInterpolation_RecordCloseChild(); } } } @@ -3443,9 +3453,9 @@ void BossGanon_DrawHandLightBall(BossGanon* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gDorfLightCoreDL); - - CLOSE_DISPS(gfxCtx); } + + CLOSE_DISPS(gfxCtx); } void BossGanon_DrawBigMagicCharge(BossGanon* this, GlobalContext* globalCtx) { @@ -3453,6 +3463,8 @@ void BossGanon_DrawBigMagicCharge(BossGanon* this, GlobalContext* globalCtx) { f32 yRot; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; s16 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(gfxCtx); @@ -3513,6 +3525,8 @@ void BossGanon_DrawBigMagicCharge(BossGanon* this, GlobalContext* globalCtx) { yRot = BINANG_TO_RAD(this->actor.yawTowardsPlayer); for (i = 0; i < this->unk_1AC; i++) { + FrameInterpolation_RecordOpenChild("Ganondorf Big Magic", epoch + i * 25); + f32 xzRot = (BossGanon_RandZeroOne() - 0.5f) * M_PI * 1.5f; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->unk_294[i]); @@ -3527,10 +3541,12 @@ void BossGanon_DrawBigMagicCharge(BossGanon* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gDorfLightRayTriDL); Matrix_Pop(); - } - CLOSE_DISPS(gfxCtx); + FrameInterpolation_RecordCloseChild(); + } } + + CLOSE_DISPS(gfxCtx); } void BossGanon_DrawTriforce(BossGanon* this, GlobalContext* globalCtx) { @@ -4142,6 +4158,8 @@ void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx) { s16 i; f32 alpha; s32 pad; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -4166,6 +4184,8 @@ void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->unk_1A8 == 1) { for (i = 0; i < 8; i++) { + FrameInterpolation_RecordOpenChild("Ganondorf Light Ball 0", epoch + i * 25); + Matrix_Push(); Matrix_RotateY(i * (M_PI / 8), MTXMODE_APPLY); Matrix_RotateZ(this->fwork[GDF_FWORK_0], MTXMODE_APPLY); @@ -4174,6 +4194,8 @@ void BossGanon_LightBall_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gDorfSquareDL); Matrix_Pop(); + + FrameInterpolation_RecordCloseChild(); } } else if (this->unk_1A8 == 0) { Matrix_ReplaceRotation(&globalCtx->billboardMtxF); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 23fa7fcc9a..ecc084be38 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -5,6 +5,7 @@ #include "objects/object_ganon2/object_ganon2.h" #include "objects/object_ganon_anime3/object_ganon_anime3.h" #include "objects/object_geff/object_geff.h" +#include "soh/frame_interpolation.h" #include @@ -2463,6 +2464,8 @@ void func_80904340(BossGanon2* this, GlobalContext* globalCtx) { f32 angle; f32 sin; f32 cos; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); Matrix_Push(); @@ -2485,6 +2488,7 @@ void func_80904340(BossGanon2* this, GlobalContext* globalCtx) { rand = BossGanon2_RandZeroOne(); for (i = 0; i < 5; i++) { + FrameInterpolation_RecordOpenChild("Ganon 80904340", epoch + i * 25); angle = (i * (2 * M_PI / 5)) + (rand * M_PI); sin = 5000.0f * sinf(angle); cos = 5000.0f * cosf(angle); @@ -2500,6 +2504,7 @@ void func_80904340(BossGanon2* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00D798)); + FrameInterpolation_RecordCloseChild(); } } @@ -2632,6 +2637,8 @@ void BossGanon2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis void func_80904D88(BossGanon2* this, GlobalContext* globalCtx) { s32 pad; s16 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2647,6 +2654,8 @@ void func_80904D88(BossGanon2* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); for (i = 0; i < 15; i++) { + FrameInterpolation_RecordOpenChild("Ganon 80904D88", epoch + i * 25); + Matrix_Translate(this->unk_234[i].x, this->unk_234[i].y, this->unk_234[i].z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(this->unk_30C, this->unk_30C, this->unk_30C, MTXMODE_APPLY); @@ -2654,6 +2663,8 @@ void func_80904D88(BossGanon2* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B378); + + FrameInterpolation_RecordCloseChild(); } } @@ -2690,6 +2701,8 @@ void func_80904FC8(BossGanon2* this, GlobalContext* globalCtx) { void func_8090523C(BossGanon2* this, GlobalContext* globalCtx) { Player* player; f32 phi_f20; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2703,6 +2716,8 @@ void func_8090523C(BossGanon2* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00B308); for (i = 0; i < 11; i++) { + FrameInterpolation_RecordOpenChild("Ganon 8090523C", epoch + i * 25); + Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); Matrix_Translate((i * 250.0f) + 900.0f, 350.0f, 0.0f, MTXMODE_APPLY); @@ -2718,6 +2733,8 @@ void func_8090523C(BossGanon2* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(ovl_Boss_Ganon2_DL_00B378)); + + FrameInterpolation_RecordCloseChild(); } } @@ -2916,6 +2933,8 @@ void func_809060E8(GlobalContext* globalCtx) { BossGanon2Effect* effect; s16 i; BossGanon2Effect* effects; + static s32 epoch = 0; + epoch++; effects = effect = globalCtx->specialEffects; @@ -2925,6 +2944,8 @@ void func_809060E8(GlobalContext* globalCtx) { for (i = 0; i < 1; i++) { if (effect->type == 1) { + FrameInterpolation_RecordOpenChild("Ganon 809060E8 0", epoch + i * 25); + Vec3f spA0; f32 temp_f0; f32 angle; @@ -2958,6 +2979,8 @@ void func_809060E8(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, ovl_Boss_Ganon2_DL_00F188); + + FrameInterpolation_RecordCloseChild(); } } @@ -2965,6 +2988,8 @@ void func_809060E8(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sBossGanon2Particles); i++, effect++) { if (effect->type == 2) { + FrameInterpolation_RecordOpenChild("Ganon 809060E8 1", epoch + i * 25); + if (!usingObjectGEff) { BossGanon2_SetObjectSegment(NULL, globalCtx, OBJECT_GEFF, true); usingObjectGEff++; @@ -2977,6 +3002,8 @@ void func_809060E8(GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gGanonRubbleDL); + + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 7ba83aebfc..b7756765a3 100644 --- a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -348,6 +348,7 @@ void BossMo_Init(Actor* thisx, GlobalContext* globalCtx2) { globalCtx->specialEffects = sEffects; for (i = 0; i < ARRAY_COUNT(sEffects); i++) { sEffects[i].type = MO_FX_NONE; + sEffects[i].epoch++; } this->actor.world.pos.x = 200.0f; this->actor.world.pos.y = MO_WATER_LEVEL(globalCtx) + 50.0f; @@ -2442,6 +2443,8 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { f32 phi_f20; f32 phi_f22; Vec3f sp110; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2462,6 +2465,8 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { BossMo_InitRand(1, 29100, 9786); for (i = 0; i < 41; i++, matrix++) { + FrameInterpolation_RecordOpenChild("Morpha Tentacle", epoch + i * 25); + s32 pad; s32 pad2; @@ -2559,6 +2564,8 @@ void BossMo_DrawTentacle(BossMo* this, GlobalContext* globalCtx) { if ((i < 38) && ((i & 1) == 1)) { BossMo_UpdateTentColliders(this, i / 2, &this->tentCollider, &this->tentPos[i]); } + + FrameInterpolation_RecordCloseChild(); } Matrix_Pop(); diff --git a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index 81686f84b2..1a1a93b075 100644 --- a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -9,6 +9,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_10) @@ -2705,6 +2706,8 @@ s32 BossSst_OverrideHandTrailDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { BossSst* this = (BossSst*)thisx; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -2738,6 +2741,8 @@ void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < end; i++) { if (Math3D_Vec3fDistSq(&trail2->world.pos, &trail->world.pos) > 900.0f) { + FrameInterpolation_RecordOpenChild(trail, 0); + Matrix_SetTranslateRotateYXZ(trail->world.pos.x, trail->world.pos.y, trail->world.pos.z, &trail->world.rot); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); @@ -2749,6 +2754,8 @@ void BossSst_DrawHand(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, BossSst_OverrideHandTrailDraw, NULL, trail, POLY_XLU_DISP); + + FrameInterpolation_RecordCloseChild(); } idx = (idx + 5) % 7; trail2 = trail; @@ -2955,6 +2962,8 @@ void BossSst_SpawnHeadShadow(BossSst* this) { shadow->scale = 1450; shadow->alpha = 254; shadow->status = 65; + + shadow->epoch++; } this->effects[3].status = -1; @@ -2968,6 +2977,7 @@ void BossSst_SpawnHandShadow(BossSst* this) { this->effects[0].scale = 2300; this->effects[0].alpha = 254; this->effects[0].status = 5; + this->effects[0].epoch++; this->effects[1].status = -1; } @@ -2981,6 +2991,7 @@ void BossSst_SpawnShockwave(BossSst* this) { for (i = 0; i < 3; i++) { BossSstEffect* shockwave = &this->effects[i]; + shockwave->epoch++; Math_Vec3f_Copy(&shockwave->pos, &this->actor.world.pos); shockwave->move = (i + 9) * 2; @@ -3035,6 +3046,8 @@ void BossSst_SpawnIceCrystal(BossSst* this, s32 index) { if ((index % 2) == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_PL_FREEZE_S); } + + ice->epoch++; } void BossSst_SpawnIceShard(BossSst* this) { @@ -3050,6 +3063,7 @@ void BossSst_SpawnIceShard(BossSst* this) { for (i = 0; i < 18; i++) { BossSstEffect* ice = &this->effects[i]; + ice->epoch++; Math_Vec3f_Copy(&ice->pos, &spawnPos); ice->status = 1; @@ -3165,6 +3179,8 @@ void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 18; i++) { effect = &this->effects[i]; + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + if (effect->move) { func_8003435C(&effect->pos, globalCtx); if (this->effects[0].status != 0) { @@ -3182,6 +3198,8 @@ void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gBongoIceShardDL); } + + FrameInterpolation_RecordCloseChild(); } } else if (this->effectMode == BONGO_SHOCKWAVE) { f32 scaleY = 0.005f; @@ -3193,6 +3211,7 @@ void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < 3; i++, scaleY -= 0.001f) { effect = &this->effects[i]; + FrameInterpolation_RecordOpenChild(effect, effect->epoch); if (effect->move != 0) { Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); @@ -3205,6 +3224,8 @@ void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFireCircleDL); } + + FrameInterpolation_RecordCloseChild(); } } else if (this->effectMode == BONGO_SHADOW) { gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, 10, 10, 80, 0); @@ -3212,12 +3233,16 @@ void BossSst_DrawEffect(Actor* thisx, GlobalContext* globalCtx) { effect = &this->effects[0]; while (effect->status != -1) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(effect->scale * 0.001f, 1.0f, effect->scale * 0.001f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, sShadowDList); + + FrameInterpolation_RecordCloseChild(); effect++; } } diff --git a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h index 8b2b311d6e..32c12b7fd0 100644 --- a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h +++ b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.h @@ -17,7 +17,8 @@ typedef struct { /* 0x0020 */ s16 move; /* 0x0022 */ s16 status; /* 0x0024 */ u8 alpha; -} BossSstEffect; // size = 0x28 + /* 0x0028 */ s32 epoch; +} BossSstEffect; // size = 0x2C typedef struct { /* 0x0000 */ PosRot world; diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 8d19fdd8e3..1252df4bfa 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -2,6 +2,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_tw/object_tw.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" +#include "soh/frame_interpolation.h" #include @@ -467,6 +468,7 @@ void BossTw_Init(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { sTwEffects[i].type = TWEFF_NONE; + sTwEffects[i].epoch++; } } @@ -3327,6 +3329,8 @@ void func_80942180(BossTw* this, GlobalContext* globalCtx) { void func_809426F0(BossTw* this, GlobalContext* globalCtx) { s32 pad; s16 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -3360,6 +3364,8 @@ void func_809426F0(BossTw* this, GlobalContext* globalCtx) { } for (i = 0; i < 8; i++) { + FrameInterpolation_RecordOpenChild("Twinrova 809426F0", epoch + i * 25); + Matrix_Push(); Matrix_Translate(0.0f, 0.0f, 5000.0f, MTXMODE_APPLY); Matrix_RotateZ(((i * M_PI) * 2.0f * 0.125f) + this->flameRotation, MTXMODE_APPLY); @@ -3373,6 +3379,8 @@ void func_809426F0(BossTw* this, GlobalContext* globalCtx) { G_MTX_LOAD | G_MTX_MODELVIEW | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A430)); Matrix_Pop(); + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -4410,6 +4418,8 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { f32 scaleFactor; s16 tailIdx; s16 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -4420,6 +4430,8 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 200, 20, 0, (s8)this->workf[TAIL_ALPHA]); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); for (i = 9; i >= 0; i--) { + FrameInterpolation_RecordOpenChild("Twinrova Fire Blast", epoch + i * 25); + gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll( globalCtx->state.gfxCtx, 0, ((this->work[CS_TIMER_1] * 3) + (i * 10)) & 0x7F, @@ -4434,6 +4446,8 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A430)); + + FrameInterpolation_RecordCloseChild(); } break; @@ -4444,6 +4458,8 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s8)this->workf[TAIL_ALPHA]); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); for (i = 9; i >= 0; i--) { + FrameInterpolation_RecordOpenChild("Twinrova Ice Blast", epoch + i * 25); + gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll( globalCtx->state.gfxCtx, 0, ((this->work[CS_TIMER_1] * 3) + (i * 0xA)) & 0x7F, @@ -4458,6 +4474,8 @@ void BossTw_BlastDraw(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01AB00)); + + FrameInterpolation_RecordCloseChild(); } break; @@ -4474,6 +4492,8 @@ void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { f32 scaleFactor; s16 tailIdx; s16 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -4484,6 +4504,8 @@ void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); for (i = 9; i >= 0; i--) { + FrameInterpolation_RecordOpenChild("Twinrova Death Ball 0", epoch + i * 25); + gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (((this->work[CS_TIMER_1] * 3) + (i * 0xA))) & 0x7F, (u8)((-this->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, @@ -4498,12 +4520,16 @@ void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A430)); + + FrameInterpolation_RecordCloseChild(); } } else { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, (s8)this->workf[TAIL_ALPHA]); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); for (i = 9; i >= 0; i--) { + FrameInterpolation_RecordOpenChild("Twinrova Death Ball 1", epoch + i * 25); + gSPSegment(POLY_XLU_DISP++, 8, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (((this->work[CS_TIMER_1] * 3) + (i * 0xA))) & 0x7F, (u8)((-this->work[CS_TIMER_1] * 0xF) + (i * 50)), 0x20, 0x40, 1, 0, 0, 0x20, @@ -4518,6 +4544,8 @@ void BossTw_DrawDeathBall(Actor* thisx, GlobalContext* globalCtx2) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01AB00)); + + FrameInterpolation_RecordCloseChild(); } } @@ -4883,6 +4911,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { if (currentEffect->type == 1) { + FrameInterpolation_RecordOpenChild(currentEffect, currentEffect->epoch); + if (sp18F == 0) { gSPDisplayList(POLY_XLU_DISP++, object_tw_DL_01A528); sp18F++; @@ -4896,8 +4926,9 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_tw_DL_01A5A8); - } + FrameInterpolation_RecordCloseChild(); + } currentEffect++; } @@ -4906,6 +4937,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { if (currentEffect->type == 3) { + FrameInterpolation_RecordOpenChild(currentEffect, currentEffect->epoch); + if (sp18F == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); sp18F++; @@ -4921,6 +4954,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01AB00)); + + FrameInterpolation_RecordCloseChild(); } currentEffect++; } @@ -4930,6 +4965,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { if (currentEffect->type == 2) { + FrameInterpolation_RecordOpenChild(currentEffect, currentEffect->epoch); + if (sp18F == 0) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 215, 255, 128); @@ -4946,6 +4983,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A430)); + + FrameInterpolation_RecordCloseChild(); } currentEffect++; @@ -4956,6 +4995,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { if (currentEffect->type == 4) { + FrameInterpolation_RecordOpenChild(currentEffect, currentEffect->epoch); + if (sp18F == 0) { sp18F++; } @@ -4991,6 +5032,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A790)); + + FrameInterpolation_RecordCloseChild(); } currentEffect++; @@ -5004,6 +5047,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { Vec3f off; if (currentEffect->type == TWEFF_PLYR_FRZ) { + FrameInterpolation_RecordOpenChild(currentEffect, currentEffect->epoch); + if (sp18F == 0) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01AA50)); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, 255); @@ -5037,6 +5082,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01AB00)); } + + FrameInterpolation_RecordCloseChild(); } currentEffect++; @@ -5047,6 +5094,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(sTwEffects); i++) { if (currentEffect->type >= 6) { + FrameInterpolation_RecordOpenChild(currentEffect, currentEffect->epoch); + if (currentEffect->work[EFF_ARGS] == 0) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, currentEffect->alpha); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A998)); @@ -5070,6 +5119,8 @@ void BossTw_DrawEffects(GlobalContext* globalCtx) { } else { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(object_tw_DL_01A430)); } + + FrameInterpolation_RecordCloseChild(); } currentEffect++; diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h index 51b664726c..1a4a314384 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.h @@ -43,6 +43,7 @@ typedef struct { /* 0x002E */ s16 work[EFF_WORK_MAX]; /* 0x0034 */ f32 workf[EFF_FWORK_MAX]; /* 0x0044 */ Actor* target; + s32 epoch; } BossTwEffect; typedef enum { diff --git a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index 6f492145bd..b4236ef250 100644 --- a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -4006,6 +4006,8 @@ void BossVa_DrawDoor(GlobalContext* globalCtx, s16 scale) { f32 yScale; f32 segAngle = 0.0f; s32 i; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -4023,6 +4025,8 @@ void BossVa_DrawDoor(GlobalContext* globalCtx, s16 scale) { Matrix_Get(&doorMtx); for (i = 0; i < 8; i++, segAngle -= M_PI / 4) { + FrameInterpolation_RecordOpenChild("Barinade Door", epoch + i * 25); + Matrix_Put(&doorMtx); Matrix_RotateZ(segAngle, MTXMODE_APPLY); Matrix_Translate(0.0f, doorPieceLength[i] * yScale, 0.0f, MTXMODE_APPLY); @@ -4030,6 +4034,8 @@ void BossVa_DrawDoor(GlobalContext* globalCtx, s16 scale) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, doorPieceDispList[i]); + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c b/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c index 0c0a573174..fd131a2445 100644 --- a/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c +++ b/soh/src/overlays/actors/ovl_Demo_6K/z_demo_6k.c @@ -10,6 +10,7 @@ #include "objects/object_demo_6k/object_demo_6k.h" #include "objects/object_gnd_magic/object_gnd_magic.h" #include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" +#include "soh/frame_interpolation.h" #define FLAGS ACTOR_FLAG_4 @@ -563,9 +564,10 @@ void func_80967FFC(Actor* thisx, GlobalContext* globalCtx) { Demo6K* this = (Demo6K*)thisx; s32 pad; u16 timer1 = this->timer1; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); Matrix_RotateX(-M_PI / 2, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -584,6 +586,8 @@ void func_80967FFC(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateZ(-M_PI / 2, MTXMODE_APPLY); for (i = 0; i < 6; i++) { + FrameInterpolation_RecordOpenChild("Demo6K 80967FFC", epoch + i * 25); + Matrix_RotateZ(M_PI / 3, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -591,6 +595,8 @@ void func_80967FFC(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, colors[i][0].r, colors[i][0].g, colors[i][0].b, 255); gDPSetEnvColor(POLY_XLU_DISP++, colors[i][1].r, colors[i][1].g, colors[i][1].b, 255); gSPDisplayList(POLY_XLU_DISP++, object_demo_6k_DL_0022B0); + + FrameInterpolation_RecordCloseChild(); } // required to avoid optimizing out i @@ -689,6 +695,8 @@ void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; u32 frames = globalCtx->state.frames; s32 i; + static s32 epoch = 0; + epoch++; if ((i = (globalCtx->csCtx.state != CS_STATE_IDLE) && (globalCtx->csCtx.npcActions[1] != NULL)) && (globalCtx->csCtx.npcActions[1]->action != 1)) { @@ -699,6 +707,8 @@ void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { Matrix_RotateY((s16)(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000) * (M_PI / 0x8000), MTXMODE_APPLY); for (i = 0; i < 16; i++) { + FrameInterpolation_RecordOpenChild("Demo6K 809688C4", epoch + i * 25); + gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[this->unk_274[i]].r, sEnvColors[this->unk_274[i]].g, sEnvColors[this->unk_274[i]].b, 255); @@ -712,6 +722,8 @@ void func_809688C4(Actor* thisx, GlobalContext* globalCtx2) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); Matrix_Pop(); + + FrameInterpolation_RecordCloseChild(); } gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); diff --git a/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index b365b3038a..6ca6a025be 100644 --- a/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/soh/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -3,6 +3,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_efc_star_field/object_efc_star_field.h" #include "objects/object_toki_objects/object_toki_objects.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -521,6 +522,8 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { f32 translateY; f32 translateZ; s16 j; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -594,6 +597,8 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(sRainScale * 0.001f, sRainScale * 0.001f, sRainScale * 0.001f, MTXMODE_APPLY); for (j = 0; j < 5; j++) { + FrameInterpolation_RecordOpenChild("Kankyo Rain", epoch + i * j * 25); + s32 pad1; if (globalCtx->sceneNum != SCENE_TOKINOMA) { @@ -623,6 +628,8 @@ void DemoKankyo_DrawRain(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); gSPDisplayList(POLY_XLU_DISP++, object_efc_star_field_DL_000080); + + FrameInterpolation_RecordCloseChild(); } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -656,10 +663,14 @@ void DemoKankyo_DrawClouds(Actor* thisx, GlobalContext* globalCtx) { f32 dx; f32 dy; f32 dz; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); for (i = 0; i < 30; i++) { + FrameInterpolation_RecordOpenChild("Kankyo Clouds", epoch + i * 25); + dx = -(Math_SinS(this->unk_150[i].unk_20 - 0x8000) * 120.0f) * (30.0f + (i / 30.0f) * 10.0f); dy = Math_CosS(this->unk_150[i].unk_20 - 0x8000) * 5.0f + 1200.0f; dz = (Math_CosS(this->unk_150[i].unk_20 - 0x8000) * 120.0f) * (30.0f + (i / 30.0f) * 10.0f); @@ -681,6 +692,8 @@ void DemoKankyo_DrawClouds(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, SEG_ADDR(1, 0), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -771,6 +784,8 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { f32 translateZ; PosRot posRot; u8 linkAge = gSaveContext.linkAge; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -778,6 +793,8 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { this->sparkleCounter += 2; } for (i = this->sparkleCounter - 1; i >= 0; i--) { + FrameInterpolation_RecordOpenChild("Kankyo Warp Sparkles", epoch + i * 25); + temp_f22 = 1.0f - (i / (f32)this->sparkleCounter); switch (this->unk_150[i].unk_22) { @@ -891,6 +908,8 @@ void DemoKankyo_DrawWarpSparkles(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, disp); this->unk_150[i].unk_24 += 0x190; } + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -914,6 +933,8 @@ void DemoKankyo_DrawSparkles(Actor* thisx, GlobalContext* globalCtx) { f32 scale; s16 i; PosRot posRot; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -922,6 +943,8 @@ void DemoKankyo_DrawSparkles(Actor* thisx, GlobalContext* globalCtx) { } for (i = this->sparkleCounter - 1; i >= 0; i--) { + FrameInterpolation_RecordOpenChild("Kankyo Sparkles", epoch + i * 25); + temp_f20 = 1.0f - (i / (f32)this->sparkleCounter); switch (this->unk_150[i].unk_22) { @@ -993,6 +1016,8 @@ void DemoKankyo_DrawSparkles(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); this->unk_150[i].unk_24 += 0x190; } + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c b/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c index 08ceebc18d..cf0159eed2 100644 --- a/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c +++ b/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c @@ -1,5 +1,6 @@ #include "z_efc_erupc.h" #include "objects/object_efc_erupc/object_efc_erupc.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -167,6 +168,8 @@ void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalC OPEN_DISPS(gfxCtx); for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) { + FrameInterpolation_RecordOpenChild(particles, particles->epoch); + if (particles->isActive) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_002760); @@ -181,7 +184,10 @@ void EfcErupc_DrawParticles(EfcErupcParticles* particles, GlobalContext* globalC G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_0027D8); } + + FrameInterpolation_RecordCloseChild(); } + CLOSE_DISPS(gfxCtx); } @@ -249,5 +255,6 @@ void EfcErupc_InitParticles(EfcErupcParticles* particles) { for (i = 0; i < EFC_ERUPC_NUM_PARTICLES; i++, particles++) { particles->isActive = false; + particles->epoch++; } } diff --git a/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h b/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h index 6b201cf5df..6e7fa66936 100644 --- a/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h +++ b/soh/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.h @@ -19,7 +19,8 @@ typedef struct { /* 0x30 */ char unk_2C[4]; /* 0x34 */ f32 scale; /* 0x38 */ char unk_34[8]; -} EfcErupcParticles; // size 0x3C + /* 0x3C */ s32 epoch; +} EfcErupcParticles; // size 0x40 #define EFC_ERUPC_NUM_PARTICLES 100 diff --git a/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 15704ef2d2..e3af7ba4da 100644 --- a/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -6,6 +6,7 @@ #include "z_eff_dust.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -268,6 +269,8 @@ void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) { f32* distanceTraveled; s32 i; f32 aux; + static s32 epoch = 0; + epoch++; OPEN_DISPS(gfxCtx); @@ -283,6 +286,8 @@ void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, sEmptyDL); for (i = 0; i < 64; i++) { + FrameInterpolation_RecordOpenChild("Dust 8099E4F4", epoch + i * 25); + if (*distanceTraveled < 1.0f) { aux = 1.0f - (*distanceTraveled * *distanceTraveled); Matrix_Translate(this->actor.world.pos.x + (initialPositions->x * ((this->dx * aux) + (1.0f - this->dx))), @@ -298,6 +303,8 @@ void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffSparklesDL)); } + FrameInterpolation_RecordCloseChild(); + initialPositions++; distanceTraveled++; } @@ -314,6 +321,8 @@ void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx2) { s32 i; f32 aux; Player* player = GET_PLAYER(globalCtx); + static s32 epoch = 0; + epoch++; OPEN_DISPS(gfxCtx); @@ -333,6 +342,8 @@ void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_XLU_DISP++, 0x08, sEmptyDL); for (i = 0; i < 64; i++) { + FrameInterpolation_RecordOpenChild("Dust 8099E784", epoch + i * 25); + if (*distanceTraveled < 1.0f) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, *distanceTraveled * 255); @@ -357,6 +368,8 @@ void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx2) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffSparklesDL)); } + FrameInterpolation_RecordCloseChild(); + initialPositions++; distanceTraveled++; } diff --git a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c index 409dc2a3b5..e01c093c67 100644 --- a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c +++ b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.c @@ -7,6 +7,7 @@ #include "z_en_anubice_fire.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_anubice/object_anubice.h" +#include "soh/frame_interpolation.h" #define FLAGS ACTOR_FLAG_4 @@ -62,6 +63,7 @@ void EnAnubiceFire_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_15A = 30; this->unk_154 = 2.0f; this->scale = 0.0f; + this->epoch++; for (i = 0; i < 6; i++) { this->unk_160[i] = this->actor.world.pos; @@ -230,6 +232,8 @@ void EnAnubiceFire_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Push(); for (i = this->unk_15E; i < 6; ++i) { + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); + f32 scale = this->actor.scale.x - (i * 0.2f); if (scale < 0.0f) { @@ -248,6 +252,8 @@ void EnAnubiceFire_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gAnubiceFireAttackDL); } + FrameInterpolation_RecordCloseChild(); + if (this->scale < 0.1f) { break; } diff --git a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h index 1ea831ffc4..848bcdae9a 100644 --- a/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h +++ b/soh/src/overlays/actors/ovl_En_Anubice_Fire/z_en_anubice_fire.h @@ -19,6 +19,7 @@ typedef struct EnAnubiceFire { /* 0x015E */ s16 unk_15E; /* 0x0178 */ Vec3f unk_160[6]; /* 0x01A8 */ ColliderCylinder cylinder; -} EnAnubiceFire; // size = 0x01F4 + /* 0x01F4 */ s32 epoch; +} EnAnubiceFire; // size = 0x01F8 #endif diff --git a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c index 6b06c50c4a..c2a8782881 100644 --- a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c +++ b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c @@ -6,6 +6,7 @@ #include "z_en_ba.h" #include "objects/object_bxa/object_bxa.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) @@ -107,6 +108,7 @@ void EnBa_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 4; this->upperParams = (thisx->params >> 8) & 0xFF; thisx->params &= 0xFF; + this->epoch++; if (this->actor.params < EN_BA_DEAD_BLOB) { if (Flags_GetSwitch(globalCtx, this->upperParams)) { @@ -489,6 +491,8 @@ void EnBa_Draw(Actor* thisx, GlobalContext* globalCtx) { Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 16, 16, 1, 0, (globalCtx->gameplayFrames * -10) % 128, 32, 32)); for (i = 0; i < 14; i++, mtx++) { + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); + Matrix_Translate(this->unk158[i].x, this->unk158[i].y, this->unk158[i].z, MTXMODE_NEW); Matrix_RotateZYX(this->unk2A8[i].x, this->unk2A8[i].y, this->unk2A8[i].z, MTXMODE_APPLY); Matrix_Scale(this->unk200[i].x, this->unk200[i].y, this->unk200[i].z, MTXMODE_APPLY); @@ -504,6 +508,8 @@ void EnBa_Draw(Actor* thisx, GlobalContext* globalCtx) { } } MATRIX_TOMTX(mtx); + + FrameInterpolation_RecordCloseChild(); } Matrix_Pop(); gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), diff --git a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h index 008ec9597f..a43c33e81a 100644 --- a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h +++ b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.h @@ -32,6 +32,7 @@ typedef struct EnBa { /* 0x031C */ s16 unk31C; /* 0x0320 */ ColliderJntSph collider; /* 0x0340 */ ColliderJntSphElement colliderItems[2]; -} EnBa; // size = 0x03C0 + /* 0x03C0 */ s32 epoch; +} EnBa; // size = 0x03C4 #endif diff --git a/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.c b/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.c index bd4fc57679..7c9749dd3f 100644 --- a/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.c +++ b/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.c @@ -6,6 +6,7 @@ #include "z_en_bx.h" #include "objects/object_bxa/object_bxa.h" +#include "soh/frame_interpolation.h" #define FLAGS ACTOR_FLAG_4 @@ -103,6 +104,7 @@ void EnBx_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_Kill(&this->actor); } thisx->params &= 0xFF; + this->epoch++; } void EnBx_Destroy(Actor* thisx, GlobalContext* globalCtx) { @@ -235,10 +237,14 @@ void EnBx_Draw(Actor* thisx, GlobalContext* globalCtx) { } for (i = 0; i < 4; i++, mtx++) { + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); + Matrix_Translate(this->unk_154[i].x, this->unk_154[i].y, this->unk_154[i].z, MTXMODE_NEW); Matrix_RotateZYX(this->unk_1B4[i].x, this->unk_1B4[i].y, this->unk_1B4[i].z, MTXMODE_APPLY); Matrix_Scale(this->unk_184[i].x, this->unk_184[i].y, this->unk_184[i].z, MTXMODE_APPLY); MATRIX_TOMTX(mtx); + + FrameInterpolation_RecordCloseChild(); } gSPDisplayList(POLY_OPA_DISP++, object_bxa_DL_0022F0); diff --git a/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h b/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h index 189349a0f1..e842ce3a0c 100644 --- a/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h +++ b/soh/src/overlays/actors/ovl_En_Bx/z_en_bx.h @@ -16,6 +16,7 @@ typedef struct EnBx { /* 0x01B4 */ Vec3s unk_1B4[4]; /* 0x01CC */ ColliderCylinder collider; /* 0x0218 */ ColliderQuad colliderQuad; -} EnBx; // size = 0x0298 + /* 0x0298 */ s32 epoch; +} EnBx; // size = 0x029C #endif diff --git a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c index 90a838ad2a..097250ff5d 100644 --- a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c +++ b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.c @@ -2,6 +2,8 @@ #include +#include "soh/frame_interpolation.h" + #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5) void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx); @@ -278,6 +280,7 @@ void EnClearTag_Init(Actor* thisx, GlobalContext* globalCtx) { globalCtx->specialEffects = &sClearTagEffects[0]; for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++) { sClearTagEffects[i].type = CLEAR_TAG_EFFECT_AVAILABLE; + sClearTagEffects[i].epoch++; } this->drawMode = CLEAR_TAG_DRAW_MODE_ALL; } @@ -902,6 +905,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { // Draw all Debris effects. for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + if (effect->type == CLEAR_TAG_EFFECT_DEBRIS) { // Apply the debris effect material if it has not already been applied. if (!isMaterialApplied) { @@ -918,6 +923,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gArwingDebrisEffectDL); } + + FrameInterpolation_RecordCloseChild(); } // Draw all ground flash effects. @@ -925,6 +932,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { isMaterialApplied = false; for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_FLASH) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + // Apply the flash ground effect material if it has not already been applied. if (!isMaterialApplied) { gDPPipeSync(POLY_XLU_DISP++); @@ -941,6 +950,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gArwingFlashEffectGroundDL); + + FrameInterpolation_RecordCloseChild(); } } @@ -949,6 +960,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { isMaterialApplied = false; for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_SMOKE) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + // Apply the smoke effect material if it has not already been applied. if (!isMaterialApplied) { gSPDisplayList(POLY_XLU_DISP++, gArwingFireEffectMaterialDL); @@ -970,6 +983,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gArwingFireEffectDL); + + FrameInterpolation_RecordCloseChild(); } } @@ -978,6 +993,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { isMaterialApplied = false; for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_FIRE) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + // Apply the fire effect material if it has not already been applied. if (!isMaterialApplied) { gSPDisplayList(POLY_XLU_DISP++, gArwingFireEffectMaterialDL); @@ -996,6 +1013,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gArwingFireEffectDL); + + FrameInterpolation_RecordCloseChild(); } } @@ -1004,6 +1023,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { isMaterialApplied = false; for (i = 0; i < CLEAR_TAG_EFFECT_MAX_COUNT; i++, effect++) { if (effect->type == CLEAR_TAG_EFFECT_FLASH) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); + // Apply the flash billboard effect material if it has not already been applied. if (!isMaterialApplied) { gDPPipeSync(POLY_XLU_DISP++); @@ -1019,6 +1040,8 @@ void EnClearTag_DrawEffects(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gArwingFlashEffectDL); + + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h index 707fbb4a5d..4c9b92584e 100644 --- a/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h +++ b/soh/src/overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h @@ -88,7 +88,8 @@ typedef struct EnClearTagEffect { /* 0x0058 */ f32 rotationX; /* 0x005C */ f32 floorHeight; /* 0x0060 */ Vec3f floorTangent; -} EnClearTagEffect; // size = 0x6C + /* 0x006C */ s32 epoch; +} EnClearTagEffect; // size = 0x70 #define CLEAR_TAG_EFFECT_MAX_COUNT 100 diff --git a/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index c5d1e649c5..4f59f89825 100644 --- a/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -2,6 +2,7 @@ #include "overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.h" #include "vt.h" #include "objects/object_efc_star_field/object_efc_star_field.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -303,6 +304,7 @@ void EnEncount2_ParticleInit(EnEncount2* this, Vec3f* particlePos, f32 scale) { particle->moveDirection.y = -20.0f; particle->moveDirection.z = Rand_CenteredFloat(20.0f); particle->isAlive = 1; + particle->epoch++; break; } } @@ -354,6 +356,8 @@ void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[objBankIndex].segment); for (i = 0; i < ARRAY_COUNT(this->particles); particle++, i++) { + FrameInterpolation_RecordOpenChild(particle, particle->epoch); + if (particle->isAlive) { Matrix_Translate(particle->pos.x, particle->pos.y, particle->pos.z, MTXMODE_NEW); Matrix_RotateX(particle->rot.x * (M_PI / 180.0f), MTXMODE_APPLY); @@ -366,6 +370,8 @@ void EnEncount2_ParticleDraw(Actor* thisx, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, object_efc_star_field_DL_000DE0); } + + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h b/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h index 302affd9a3..b4c7db491e 100644 --- a/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h +++ b/soh/src/overlays/actors/ovl_En_Encount2/z_en_encount2.h @@ -14,7 +14,8 @@ typedef struct { /* 0x0010 */ u8 isAlive; /* 0x0014 */ Vec3f moveDirection; /* 0x0020 */ Vec3f rot; -} EnEncount2Particle; // size = 0x2C + /* 0x002C */ s32 epoch; +} EnEncount2Particle; // size = 0x30 typedef struct EnEncount2 { /* 0x0000 */ Actor actor; diff --git a/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.c b/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.c index cd3bd87e7b..0cc83f4e01 100644 --- a/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.c +++ b/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.c @@ -7,6 +7,7 @@ #include "z_en_fd.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_fw/object_fw.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9) @@ -812,6 +813,7 @@ void EnFd_AddEffect(EnFd* this, u8 type, Vec3f* pos, Vec3f* velocity, Vec3f* acc eff->color.a = 255; eff->timer = (s16)(Rand_ZeroOne() * 10.0f); } + eff->epoch++; return; } } @@ -886,6 +888,8 @@ void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { if (eff->type == FD_EFFECT_FLAME) { + FrameInterpolation_RecordOpenChild(eff, eff->epoch); + if (!firstDone) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_7928); @@ -902,8 +906,11 @@ void EnFd_DrawFlames(EnFd* this, GlobalContext* globalCtx) { idx = eff->timer * (8.0f / eff->initialTimer); gSPSegment(POLY_XLU_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(dustTextures[idx])); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerSquareParticleDL); + + FrameInterpolation_RecordCloseChild(); } } + CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -919,6 +926,8 @@ void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { if (eff->type == FD_EFFECT_DOT) { + FrameInterpolation_RecordOpenChild(eff, eff->epoch); + if (!firstDone) { func_80093D84(globalCtx->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerDL_79F8); @@ -933,6 +942,8 @@ void EnFd_DrawDots(EnFd* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerTriangleParticleDL); + + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h b/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h index a00b622c92..7dc990a7e5 100644 --- a/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h +++ b/soh/src/overlays/actors/ovl_En_Fd/z_en_fd.h @@ -25,6 +25,7 @@ typedef struct { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f velocity; /* 0x002C */ Vec3f accel; + s32 epoch; } EnFdEffect; // size = 0x38 typedef struct EnFd { diff --git a/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.c b/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.c index c0f0a048cd..23073ed1a4 100644 --- a/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.c +++ b/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.c @@ -8,6 +8,7 @@ #include "objects/object_fw/object_fw.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9) @@ -421,6 +422,7 @@ void EnFw_AddDust(EnFw* this, Vec3f* initialPos, Vec3f* initialSpeed, Vec3f* acc eff->pos = *initialPos; eff->accel = *accel; eff->velocity = *initialSpeed; + eff->epoch++; return; } } @@ -464,6 +466,8 @@ void EnFw_DrawDust(EnFw* this, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->effects); i++, eff++) { + FrameInterpolation_RecordOpenChild(eff, eff->epoch); + if (eff->type != 0) { if (!firstDone) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0U); @@ -484,6 +488,8 @@ void EnFw_DrawDust(EnFw* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x8, SEGMENTED_TO_VIRTUAL(dustTextures[idx])); gSPDisplayList(POLY_XLU_DISP++, gFlareDancerSquareParticleDL); } + + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h b/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h index f7d245e5e4..0230a2c3d7 100644 --- a/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h +++ b/soh/src/overlays/actors/ovl_En_Fw/z_en_fw.h @@ -19,6 +19,7 @@ typedef struct { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f velocity; /* 0x002C */ Vec3f accel; + s32 epoch; } EnFwEffect; typedef struct EnFw { diff --git a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c index 5381efc5b8..7ee3412b60 100644 --- a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -1,5 +1,6 @@ #include "z_en_fz.h" #include "objects/object_fz/object_fz.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_10) @@ -756,6 +757,7 @@ void EnFz_SpawnIceSmokeNoFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* iceSmoke->xyScale = xyScale / 1000.0f; iceSmoke->primAlpha = 0; iceSmoke->timer = 0; + iceSmoke->epoch++; break; } @@ -780,6 +782,7 @@ void EnFz_SpawnIceSmokeFreeze(EnFz* this, Vec3f* pos, Vec3f* velocity, Vec3f* ac iceSmoke->primAlpha = primAlpha; iceSmoke->timer = 0; iceSmoke->isTimerMod8 = isTimerMod8; + iceSmoke->epoch++; break; } @@ -864,6 +867,8 @@ void EnFz_DrawIceSmoke(EnFz* this, GlobalContext* globalCtx) { func_80093D84(globalCtx->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(this->iceSmoke); i++) { + FrameInterpolation_RecordOpenChild(iceSmoke, iceSmoke->epoch); + if (iceSmoke->type > 0) { gDPPipeSync(POLY_XLU_DISP++); @@ -884,6 +889,8 @@ void EnFz_DrawIceSmoke(EnFz* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gFreezardSteamDL)); } + FrameInterpolation_RecordCloseChild(); + iceSmoke++; } diff --git a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h index 536d2525f4..471a2fce2e 100644 --- a/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h +++ b/soh/src/overlays/actors/ovl_En_Fz/z_en_fz.h @@ -21,6 +21,7 @@ typedef struct { /* 0x0030 */ f32 xyScale; // /* 0x0034 */ f32 xyScaleTarget; /* 0x0038 */ u8 isTimerMod8; // conditional, used to run CollisionCheck_SetAT + s32 epoch; } EnFzEffectSsIceSmoke; // size = 0x3C typedef struct EnFz { diff --git a/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c b/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c index 93c1061d7a..f4740dbb3a 100644 --- a/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c +++ b/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c @@ -12,6 +12,7 @@ #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_tsubo/object_tsubo.h" #include "objects/object_gi_rupy/object_gi_rupy.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -533,6 +534,7 @@ void EnGSwitch_SpawnEffects(EnGSwitch* this, Vec3f* pos, s16 scale, s16 colorIdx f32 pitch; f32 yaw; + effect->epoch++; effect->pos = *pos; effect->scale = scale; effect->colorIdx = colorIdx; @@ -590,6 +592,7 @@ void EnGSwitch_DrawEffects(EnGSwitch* this, GlobalContext* globalCtx) { func_80093D18(globalCtx->state.gfxCtx); for (i = 0; i < this->numEffects; i++, effect++) { if (effect->flag) { + FrameInterpolation_RecordOpenChild(effect, effect->epoch); scale = effect->scale / 10000.0f; Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); @@ -600,6 +603,7 @@ void EnGSwitch_DrawEffects(EnGSwitch* this, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sRupeeTextures[effect->colorIdx])); gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); + FrameInterpolation_RecordCloseChild(); } } CLOSE_DISPS(gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h b/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h index dba5b09c02..366a7d120f 100644 --- a/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h +++ b/soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.h @@ -32,6 +32,7 @@ typedef struct { /* 0x12 */ u8 flag; /* 0x14 */ Vec3f velocity; /* 0x20 */ Vec3f rot; + s32 epoch; } EnGSwitchEffect; // size = 0x2C typedef struct EnGSwitch { diff --git a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c index a92ef3d6d3..31fe04e906 100644 --- a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c +++ b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.c @@ -6,6 +6,7 @@ #include "z_en_gb.h" #include "objects/object_ps/object_ps.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) @@ -184,6 +185,7 @@ void EnGb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionTimer = (s16)Rand_ZeroFloat(100.0f) + 100; for (i = 0; i < ARRAY_COUNT(sCagedSoulPositions); i++) { + this->cagedSouls[i].epoch++; this->cagedSouls[i].infoIdx = (s32)Rand_ZeroFloat(30.0f) % 3; this->cagedSouls[i].unk_14.x = this->cagedSouls[i].translation.x = sCagedSoulPositions[i].x + this->dyna.actor.world.pos.x; @@ -524,6 +526,7 @@ void EnGb_DrawCagedSouls(EnGb* this, GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { s32 idx = this->cagedSouls[i].infoIdx; + FrameInterpolation_RecordOpenChild(&this->cagedSouls[i], this->cagedSouls[i].epoch); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (u32)(sCagedSoulInfo[idx].timerMultiplier * this->frameTimer) % 512, 32, 128)); @@ -548,6 +551,7 @@ void EnGb_DrawCagedSouls(EnGb* this, GlobalContext* globalCtx) { gSPDisplayList(POLY_XLU_DISP++, gPoeSellerCagedSoulDL); Matrix_Pop(); + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h index 5de160ff24..48908d7e59 100644 --- a/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h +++ b/soh/src/overlays/actors/ovl_En_Gb/z_en_gb.h @@ -27,6 +27,7 @@ typedef struct { /* 0x20 */ f32 unk_20; /* 0x24 */ f32 unk_24; /* 0x28 */ f32 unk_28; + s32 epoch; } EnGbCagedSoul; // size = 0x2C typedef struct EnGb { diff --git a/soh/src/overlays/actors/ovl_En_Go/z_en_go.c b/soh/src/overlays/actors/ovl_En_Go/z_en_go.c index 050bfc4d10..e1179fe1b1 100644 --- a/soh/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/soh/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -2,6 +2,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_oF1d_map/object_oF1d_map.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -1133,11 +1134,9 @@ void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->actionFunc == EnGo_CurledUp) { EnGo_DrawCurledUp(this, globalCtx); - return; // needed for match? } else if (this->actionFunc == EnGo_GoronLinkRolling || this->actionFunc == func_80A3FEB4 || this->actionFunc == EnGo_StopRolling || this->actionFunc == func_80A3FEB4) { EnGo_DrawRolling(this, globalCtx); - return; // needed for match? } else { func_800943C8(globalCtx->state.gfxCtx); @@ -1146,9 +1145,9 @@ void EnGo_Draw(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnGo_OverrideLimbDraw, EnGo_PostLimbDraw, &this->actor); - CLOSE_DISPS(globalCtx->state.gfxCtx); EnGo_DrawDust(this, globalCtx); } + CLOSE_DISPS(globalCtx->state.gfxCtx); } void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 initialTimer, f32 scale, f32 scaleStep) { @@ -1158,6 +1157,7 @@ void EnGo_AddDust(EnGo* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 init for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { if (dustEffect->type != 1) { + dustEffect->epoch++; dustEffect->scale = scale; dustEffect->scaleStep = scaleStep; timer = initialTimer; @@ -1218,6 +1218,7 @@ void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx) { firstDone = true; } + FrameInterpolation_RecordOpenChild(dustEffect, dustEffect->epoch); alpha = dustEffect->timer * (255.0f / dustEffect->initialTimer); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); gDPPipeSync(POLY_XLU_DISP++); @@ -1230,6 +1231,7 @@ void EnGo_DrawDust(EnGo* this, GlobalContext* globalCtx) { index = dustEffect->timer * (8.0f / dustEffect->initialTimer); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTex[index])); gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD50); + FrameInterpolation_RecordCloseChild(); } } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Go/z_en_go.h b/soh/src/overlays/actors/ovl_En_Go/z_en_go.h index 2aef4b1685..94bad5babe 100644 --- a/soh/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/soh/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -34,6 +34,7 @@ typedef struct { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f velocity; /* 0x002C */ Vec3f accel; + s32 epoch; } EnGoEffect; // size = 0x38 typedef struct EnGo { diff --git a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c index fb4fa44916..22c19f5f09 100644 --- a/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -2,6 +2,7 @@ #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_oF1d_map/object_oF1d_map.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -176,6 +177,7 @@ void EnGo2_AddDust(EnGo2* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u8 in for (i = 0; i < ARRAY_COUNT(this->dustEffects); i++, dustEffect++) { if (dustEffect->type != 1) { + dustEffect->epoch++; dustEffect->scale = scale; dustEffect->scaleStep = scaleStep; timer = initialTimer; @@ -236,6 +238,7 @@ void EnGo2_DrawDust(EnGo2* this, GlobalContext* globalCtx) { firstDone = true; } + FrameInterpolation_RecordOpenChild(dustEffect, dustEffect->epoch); alpha = dustEffect->timer * (255.0f / dustEffect->initialTimer); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); gDPPipeSync(POLY_XLU_DISP++); @@ -247,6 +250,7 @@ void EnGo2_DrawDust(EnGo2* this, GlobalContext* globalCtx) { index = dustEffect->timer * (8.0f / dustEffect->initialTimer); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sDustTex[index])); gSPDisplayList(POLY_XLU_DISP++, gGoronDL_00FD50); + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 816d485b7b..82c52f724b 100644 --- a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -8,6 +8,7 @@ #include "objects/object_niw/object_niw.h" #include "overlays/actors/ovl_En_Attack_Niw/z_en_attack_niw.h" #include "vt.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) @@ -1145,6 +1146,7 @@ void EnNiw_FeatherSpawn(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { if (feather->type == 0) { + feather->epoch++; feather->type = 1; feather->pos = *pos; feather->vel = *vel; @@ -1202,6 +1204,7 @@ void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx) { for (i = 0; i < ARRAY_COUNT(this->feathers); i++, feather++) { if (feather->type == 1) { + FrameInterpolation_RecordOpenChild(feather, feather->epoch); if (!flag) { gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAppearDL); flag++; @@ -1214,6 +1217,7 @@ void EnNiw_FeatherDraw(EnNiw* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h index d027324968..78d52af335 100644 --- a/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/soh/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -18,6 +18,7 @@ typedef struct { /* 0x002C */ f32 scale; /* 0x0030 */ f32 unk_30; /* 0x0034 */ u8 timer; + s32 epoch; } EnNiwFeather; // size = 0x0038 typedef struct EnNiw { diff --git a/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c b/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c index 129e62d5b8..b2db1621a4 100644 --- a/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -6,6 +6,7 @@ #include "z_en_nwc.h" #include "objects/object_nwc/object_nwc.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -170,6 +171,7 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { if (chick->type != CHICK_NONE) { Mtx* mtx; + FrameInterpolation_RecordOpenChild(chick, chick->epoch); Matrix_SetTranslateRotateYXZ(chick->pos.x, chick->pos.y + chick->height, chick->pos.z, &chick->rot); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); mtx = MATRIX_NEWMTX(globalCtx->state.gfxCtx); @@ -180,6 +182,7 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { gSPDisplayList(dList2++, gCuccoChickEyesDL); gSPMatrix(dList3++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(dList3++, gCuccoChickBeakDL); + FrameInterpolation_RecordCloseChild(); } } @@ -190,6 +193,7 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { for (i = 0; i < this->count; i++, chick++) { if ((chick->type != CHICK_NONE) && (chick->floorPoly != NULL)) { + FrameInterpolation_RecordOpenChild(chick, chick->epoch * 25); func_80038A28(chick->floorPoly, chick->pos.x, chick->floorY, chick->pos.z, &floorMat); Matrix_Put(&floorMat); Matrix_RotateY(chick->rot.y * (M_PI / 0x8000), MTXMODE_APPLY); @@ -197,6 +201,7 @@ void EnNwc_DrawChicks(EnNwc* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCuccoChickShadowDL); + FrameInterpolation_RecordCloseChild(); } } CLOSE_DISPS(globalCtx->state.gfxCtx); @@ -220,6 +225,7 @@ void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { this->count = 16; chick = this->chicks; for (i = 0; i < this->count; i++, chick++) { + chick->epoch++; chick->type = CHICK_NORMAL; chick->pos.x = thisx->world.pos.x + ((Rand_ZeroOne() * 100.0f) - 50.0f); chick->pos.y = thisx->world.pos.y + 20.0f; diff --git a/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h b/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h index 0597ce76c2..fa57bb2f30 100644 --- a/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h +++ b/soh/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h @@ -23,6 +23,7 @@ typedef struct EnNwcChick { /* 0x36 */ u16 height; /* 0x38 */ CollisionPoly* floorPoly; /* 0x44 */ char unk_3C[0x20]; + s32 epoch; } EnNwcChick; // size = 0x5C typedef struct EnNwc { diff --git a/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.c b/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.c index 7d81a324a7..a5831e3ec1 100644 --- a/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.c +++ b/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.c @@ -1,5 +1,6 @@ #include "z_en_ny.h" #include "objects/object_ny/object_ny.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2) @@ -107,6 +108,7 @@ static InitChainEntry sInitChain[] = { void EnNy_Init(Actor* thisx, GlobalContext* globalCtx) { EnNy* this = (EnNy*)thisx; + this->epoch++; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.health = 2; @@ -577,6 +579,7 @@ void EnNy_DrawDeathEffect(Actor* thisx, GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); for (i = 0; i < 8; i++) { if (this->timer < (i + 22)) { + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); temp = &this->unk_1F8[i]; Matrix_Translate(temp->x, temp->y, temp->z, MTXMODE_NEW); scale = this->actor.scale.x * 0.4f * (1.0f + (i * 0.04f)); @@ -584,6 +587,7 @@ void EnNy_DrawDeathEffect(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gEnNyRockBodyDL); + FrameInterpolation_RecordCloseChild(); } } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h b/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h index fd93efcdbf..ebc358254f 100644 --- a/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h +++ b/soh/src/overlays/actors/ovl_En_Ny/z_en_ny.h @@ -30,6 +30,7 @@ typedef struct EnNy { /* 0x01F0 */ f32 unk_1F0; /* 0x01F4 */ f32 unk_1F4; /* 0x01F8 */ Vec3f unk_1F8[16]; + s32 epoch; } EnNy; // size = 0x02B8 #endif diff --git a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 807292c240..d66cdae6c1 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -7,6 +7,7 @@ #include "z_en_po_sisters.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_po_sisters/object_po_sisters.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_9 | ACTOR_FLAG_12 | ACTOR_FLAG_14) @@ -179,6 +180,8 @@ void EnPoSisters_Init(Actor* thisx, GlobalContext* globalCtx) { EnPoSisters* this = (EnPoSisters*)thisx; s32 pad; + this->epoch++; + // Skip Poe Intro Cutscene if (gSaveContext.n64ddFlag && thisx->params == 4124) { Flags_SetSwitch(globalCtx, 0x1B); @@ -1186,7 +1189,7 @@ void EnPoSisters_Update(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnPoSisters* this = (EnPoSisters*)thisx; s16 temp; - + if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; func_80AD9568(this); @@ -1413,6 +1416,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc != func_80ADBEE8) { phi_s5 = -i * 31 + 248; } + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, temp_s7->r, temp_s7->g, temp_s7->b, phi_s5); Matrix_Translate(this->unk_234[i].x, this->unk_234[i].y, this->unk_234[i].z, MTXMODE_NEW); @@ -1425,6 +1429,7 @@ void EnPoSisters_Draw(Actor* thisx, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h index 2b3b7446a9..cc55a1dc9f 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h +++ b/soh/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.h @@ -29,6 +29,7 @@ typedef struct EnPoSisters { /* 0x029C */ LightInfo lightInfo; /* 0x02AC */ ColliderCylinder collider; /* 0x02F8 */ MtxF unk_2F8; + s32 epoch; } EnPoSisters; // size = 0x0338 #endif diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c b/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c index d8e680d900..a21e47ab76 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c +++ b/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.c @@ -7,6 +7,7 @@ #include "z_en_syateki_niw.h" #include "objects/object_niw/object_niw.h" #include "vt.h" +#include "soh/frame_interpolation.h" #define FLAGS ACTOR_FLAG_4 @@ -713,6 +714,7 @@ void func_80B131B8(EnSyatekiNiw* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, f3 for (i = 0; i < 5; i++, ptr++) { if (ptr->unk_00 == 0) { + ptr->epoch++; ptr->unk_00 = 1; ptr->unk_04 = *arg1; ptr->unk_10 = *arg2; @@ -773,6 +775,7 @@ void func_80B13464(EnSyatekiNiw* this, GlobalContext* globalCtx) { flag++; } + FrameInterpolation_RecordOpenChild(ptr, ptr->epoch); Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); Matrix_ReplaceRotation(&globalCtx->billboardMtxF); Matrix_Scale(ptr->unk_2C, ptr->unk_2C, 1.0f, MTXMODE_APPLY); @@ -782,6 +785,7 @@ void func_80B13464(EnSyatekiNiw* this, GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gCuccoParticleAliveDL); + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h b/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h index 6a6398a6f1..dfa493817c 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h +++ b/soh/src/overlays/actors/ovl_En_Syateki_Niw/z_en_syateki_niw.h @@ -18,6 +18,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ u8 unk_34; + s32 epoch; } EnSyatekiNiw_1; // size = 0x38 typedef struct EnSyatekiNiw { diff --git a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c index f87e7e6660..11530b07e4 100644 --- a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -7,6 +7,7 @@ #include "z_en_tk.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_tk/object_tk.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3) #define COLLECTFLAG_GRAVEDIGGING_HEART_PIECE 0x19 @@ -43,6 +44,7 @@ void EnTkEff_Create(EnTk* this, Vec3f* pos, Vec3f* speed, Vec3f* accel, u8 durat for (i = 0; i < ARRAY_COUNT(this->eff); i++) { if (eff->active != 1) { + eff->epoch++; eff->size = size; eff->growth = growth; eff->timeTotal = eff->timeLeft = duration; @@ -107,6 +109,7 @@ void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) { gfxSetup = 1; } + FrameInterpolation_RecordOpenChild(eff, eff->epoch); alpha = eff->timeLeft * (255.0f / eff->timeTotal); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 130, 90, alpha); @@ -121,6 +124,7 @@ void EnTkEff_Draw(EnTk* this, GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(dustTextures[imageIdx])); gSPDisplayList(POLY_XLU_DISP++, gDampeEff2DL); + FrameInterpolation_RecordCloseChild(); } eff++; } diff --git a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 816a7042ca..82fb6eef3d 100644 --- a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -17,6 +17,7 @@ typedef struct EnTkEff { /* 0x0014 */ Vec3f pos; /* 0x0020 */ Vec3f speed; /* 0x002C */ Vec3f accel; + s32 epoch; } EnTkEff; // size = 0x0038 struct EnTk; diff --git a/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c b/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c index b25a42ad90..bf4956f35d 100644 --- a/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -14,6 +14,7 @@ #include "objects/object_gndd/object_gndd.h" #include "objects/object_ganon/object_ganon.h" #include "objects/object_opening_demo1/object_opening_demo1.h" +#include "soh/frame_interpolation.h" #define FLAGS ACTOR_FLAG_4 @@ -793,6 +794,7 @@ void EnViewer_InitFireEffect(EnViewer* this, GlobalContext* globalCtx, s16 i) { eff->endPos.y = -420.0f; eff->endPos.z = -400.0f; eff->scale = (Rand_ZeroOne() * 5.0f + 12.0f) * 0.001f; + eff->epoch++; } else { eff = &this->fireEffects[i]; eff->startPos.x = -100.0f; @@ -802,6 +804,7 @@ void EnViewer_InitFireEffect(EnViewer* this, GlobalContext* globalCtx, s16 i) { eff->endPos.y = -420.0f; eff->endPos.z = -400.0f; eff->scale = (Rand_ZeroOne() * 5.0f + 12.0f) * 0.001f; + eff->epoch++; } if (this) {} } @@ -843,6 +846,7 @@ void EnViewer_DrawFireEffects(EnViewer* this2, GlobalContext* globalCtx) { break; } + FrameInterpolation_RecordOpenChild(&this->fireEffects[i], this->fireEffects[i].epoch); func_80093D84(globalCtx->state.gfxCtx); Matrix_Translate(this->fireEffects[i].pos.x, this->fireEffects[i].pos.y, this->fireEffects[i].pos.z, MTXMODE_NEW); @@ -856,6 +860,7 @@ void EnViewer_DrawFireEffects(EnViewer* this2, GlobalContext* globalCtx) { G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPMatrix(POLY_XLU_DISP++, SEG_ADDR(1, 0), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); + FrameInterpolation_RecordCloseChild(); } CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h b/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h index 6d797cb348..d16613fcf2 100644 --- a/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h +++ b/soh/src/overlays/actors/ovl_En_Viewer/z_en_viewer.h @@ -56,6 +56,7 @@ typedef struct { /* 0x28 */ f32 scale; /* 0x2C */ f32 lerpFactor; /* 0x30 */ u8 state; + s32 epoch; } EnViewerFireEffect; // size = 0x34 typedef struct EnViewer { diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index eb7c0a20a5..5f404c4ad1 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -90,6 +90,7 @@ typedef struct { /* 0x32 */ s16 timer; /* 0x34 */ u8 shouldDraw; /* 0x38 */ f32 drawDistance; + s32 epoch; } FishingProp; // size = 0x3C typedef enum { @@ -115,6 +116,7 @@ typedef struct { /* 0x40 */ s16 unk_40; /* 0x42 */ s16 unk_42; /* 0x44 */ u8 shouldDraw; + s32 epoch; } FishingGroupFish; // size = 0x48 #define LINE_SEG_COUNT 200 @@ -764,6 +766,7 @@ void Fishing_InitPondProps(Fishing* this, GlobalContext* globalCtx) { break; } + prop->epoch++; prop->type = sPondPropInits[i].type; prop->pos.x = sPondPropInits[i].pos.x; prop->pos.y = sPondPropInits[i].pos.y; @@ -929,6 +932,8 @@ void Fishing_Init(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < GROUP_FISH_COUNT; i++) { FishingGroupFish* fish = &sGroupFishes[i]; + fish->epoch++; + fish->type = FS_GROUP_FISH_NORMAL; if (i <= 20) { @@ -1761,6 +1766,8 @@ static f32 sSinkingLureSizes[] = { void Fishing_DrawSinkingLure(GlobalContext* globalCtx) { s16 i; f32 scale; + static s32 epoch = 0; + epoch++; OPEN_DISPS(globalCtx->state.gfxCtx); @@ -1773,6 +1780,7 @@ void Fishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80B7FEA0) < SINKING_LURE_SEG_COUNT) { + FrameInterpolation_RecordOpenChild("Fishing Lures 1", epoch + i * 25); Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80B7FEA0] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); @@ -1781,6 +1789,7 @@ void Fishing_DrawSinkingLure(GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentModelDL); + FrameInterpolation_RecordCloseChild(); } } } else { @@ -1790,6 +1799,7 @@ void Fishing_DrawSinkingLure(GlobalContext* globalCtx) { for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80B7FEA0) < SINKING_LURE_SEG_COUNT) { + FrameInterpolation_RecordOpenChild("Fishing Lures 2", epoch + i * 25); Matrix_Translate(sSinkingLurePos[i].x, sSinkingLurePos[i].y, sSinkingLurePos[i].z, MTXMODE_NEW); scale = sSinkingLureSizes[i + D_80B7FEA0] * 0.04f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); @@ -1798,6 +1808,7 @@ void Fishing_DrawSinkingLure(GlobalContext* globalCtx) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentModelDL); + FrameInterpolation_RecordCloseChild(); } } } @@ -4451,7 +4462,7 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - FrameInterpolation_RecordOpenChild(prop, 0); + FrameInterpolation_RecordOpenChild(prop, prop->epoch); Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); Matrix_RotateY(prop->rotY, MTXMODE_APPLY); @@ -4478,7 +4489,7 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - FrameInterpolation_RecordOpenChild(prop, 0); + FrameInterpolation_RecordOpenChild(prop, prop->epoch); Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); @@ -4502,7 +4513,7 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - FrameInterpolation_RecordOpenChild(prop, 0); + FrameInterpolation_RecordOpenChild(prop, prop->epoch); Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, 1.0f, prop->scale, MTXMODE_APPLY); Matrix_RotateY(prop->lilyPadAngle * (M_PI / 32768), MTXMODE_APPLY); @@ -4529,7 +4540,7 @@ void Fishing_DrawPondProps(GlobalContext* globalCtx) { } if (prop->shouldDraw) { - FrameInterpolation_RecordOpenChild(prop, 0); + FrameInterpolation_RecordOpenChild(prop, prop->epoch); Matrix_Translate(prop->pos.x, prop->pos.y, prop->pos.z, MTXMODE_NEW); Matrix_Scale(prop->scale, prop->scale, prop->scale, MTXMODE_APPLY); Matrix_RotateY(prop->rotY, MTXMODE_APPLY); @@ -4759,6 +4770,7 @@ void Fishing_DrawGroupFishes(GlobalContext* globalCtx) { } if (fish->shouldDraw) { + FrameInterpolation_RecordOpenChild(fish, fish->epoch); Matrix_Translate(fish->pos.x, fish->pos.y, fish->pos.z, MTXMODE_NEW); Matrix_RotateY(((f32)fish->unk_3E * M_PI) / 32768.0f, MTXMODE_APPLY); Matrix_RotateX((-(f32)fish->unk_3C * M_PI) / 32768.0f, MTXMODE_APPLY); @@ -4767,6 +4779,7 @@ void Fishing_DrawGroupFishes(GlobalContext* globalCtx) { gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishModelDL); + FrameInterpolation_RecordCloseChild(); } } fish++; diff --git a/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c b/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c index 5389e24693..c332590ddf 100644 --- a/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c +++ b/soh/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.c @@ -6,6 +6,7 @@ #include "z_mir_ray.h" #include "objects/object_mir_ray/object_mir_ray.h" +#include "soh/frame_interpolation.h" #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_5) @@ -481,6 +482,8 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 i; MirRayShieldReflection reflection[6]; s32 temp; + static s32 epoch = 0; + epoch++; this->reflectIntensity = 0.0f; if ((D_80B8E670 == 0) && !this->unLit && Player_HasMirrorShieldSetToDraw(globalCtx)) { @@ -511,6 +514,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { } for (i = 0; i < 6; i++) { if (reflection[i].reflectionPoly != NULL) { + FrameInterpolation_RecordOpenChild(&reflection[i], epoch + i * 25); Matrix_Translate(reflection[i].pos.x, reflection[i].pos.y, reflection[i].pos.z, MTXMODE_NEW); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); Matrix_Mult(&reflection[i].mtx, MTXMODE_APPLY); @@ -519,6 +523,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 150, reflection[0].opacity); gSPDisplayList(POLY_XLU_DISP++, gShieldBeamImageDL); + FrameInterpolation_RecordCloseChild(); } } diff --git a/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 01c4aa469e..22b7969644 100644 --- a/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/soh/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -924,6 +924,7 @@ void ObjectKankyo_DrawBeams(ObjectKankyo* this2, GlobalContext* globalCtx2) { if (this->requiredObjectLoaded) { for (i = 0; i < 6; i++) { if (this->effects[i].size > 0.001f) { + FrameInterpolation_RecordOpenChild(&this->effects[i], this->effects[i].epoch); Matrix_Translate(beamX[i], beamY[i], beamZ[i], MTXMODE_NEW); Matrix_RotateY(DEG_TO_RAD(beamYaw[i]), MTXMODE_APPLY); Matrix_RotateX(DEG_TO_RAD(beamPitch[i]), MTXMODE_APPLY); @@ -940,6 +941,7 @@ void ObjectKankyo_DrawBeams(ObjectKankyo* this2, GlobalContext* globalCtx2) { globalCtx->state.frames * 10, 32, 64, 1, globalCtx->state.frames * 5, globalCtx->state.frames * 10, 32, 64)); gSPDisplayList(POLY_XLU_DISP++, gDemoKekkaiDL_005FF0); + FrameInterpolation_RecordCloseChild(); } } } diff --git a/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c b/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c index 39d3749250..34bd3446b6 100644 --- a/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c +++ b/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.c @@ -6,6 +6,7 @@ #include "z_eff_ss_bomb2.h" #include "objects/gameplay_keep/gameplay_keep.h" +#include "soh/frame_interpolation.h" #define rScale regs[0] #define rTexIdx regs[1] @@ -54,6 +55,7 @@ u32 EffectSsBomb2_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void this->rEnvColorR = 0; this->rEnvColorG = 0; this->rEnvColorB = 200; + this->epoch++; return 1; } @@ -144,6 +146,7 @@ void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* th Matrix_Put(&mtx2F); for (i = 1; i >= 0; i--) { + FrameInterpolation_RecordOpenChild(this, this->epoch + i * 25); Matrix_Translate(0.0f, 0.0f, depth, MTXMODE_APPLY); Matrix_RotateZ((this->life * 0.02f) + 180.0f, MTXMODE_APPLY); Matrix_Scale(layer2Scale, layer2Scale, layer2Scale, MTXMODE_APPLY); @@ -151,6 +154,7 @@ void EffectSsBomb2_DrawLayered(GlobalContext* globalCtx, u32 index, EffectSs* th G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); layer2Scale -= 0.15f; + FrameInterpolation_RecordCloseChild(); } } } diff --git a/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h b/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h index 454303b50b..93dc280319 100644 --- a/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h +++ b/soh/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h @@ -11,6 +11,7 @@ typedef struct { /* 0x24 */ s16 scale; /* 0x26 */ s16 scaleStep; /* 0x28 */ u8 drawMode; + /* 0x29 */ s32 epoch; } EffectSsBomb2InitParams; // size = 0x30 #endif From dffcbb035eebab6fdb9d824caf6cd12bfa36f3a8 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Wed, 3 Aug 2022 22:43:55 -0400 Subject: [PATCH 28/31] Fixes glitchy dungeon maps. (#1032) --- soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 66967e9a45..6e88d975d4 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -3227,10 +3227,9 @@ void KaleidoScope_LoadDungeonMap(GlobalContext* globalCtx) { char* firstTextureName = sDungeonMapTexs[R_MAP_TEX_INDEX]; char* secondTextureName = sDungeonMapTexs[R_MAP_TEX_INDEX + 1]; - uint32_t firstTextureSize = ResourceMgr_LoadTexSizeByName(firstTextureName); memcpy(interfaceCtx->mapSegment, ResourceMgr_LoadTexByName(firstTextureName), ResourceMgr_LoadTexSizeByName(firstTextureName)); - memcpy(interfaceCtx->mapSegment + (firstTextureSize / 2), ResourceMgr_LoadTexByName(secondTextureName), ResourceMgr_LoadTexSizeByName(secondTextureName)); + memcpy(interfaceCtx->mapSegment + 0x800, ResourceMgr_LoadTexByName(secondTextureName), ResourceMgr_LoadTexSizeByName(secondTextureName)); } void KaleidoScope_UpdateDungeonMap(GlobalContext* globalCtx) { From bd86c792c371356d6a4e4eca4ab60c1209a75d44 Mon Sep 17 00:00:00 2001 From: Ada <60364512+GreatArgorath@users.noreply.github.com> Date: Thu, 4 Aug 2022 03:44:43 +0100 Subject: [PATCH 29/31] Moves release version text (#1028) --- soh/src/overlays/gamestates/ovl_title/z_title.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 699dff6266..cfaf9e26d3 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -39,8 +39,10 @@ void Title_PrintBuildInfo(Gfx** gfxp) { GfxPrint_Printf(&printer, "GCC SHIP"); #endif - GfxPrint_SetPos(&printer, 5, 4); + GfxPrint_SetPos(&printer, 1, 4); GfxPrint_Printf(&printer, "Game Version: %s", gameVersionStr); + GfxPrint_SetPos(&printer, 1, 5); + GfxPrint_Printf(&printer, "Release Version: %s", gBuildVersion); GfxPrint_SetColor(&printer, 255, 255, 255, 255); GfxPrint_SetPos(&printer, 2, 22); @@ -49,8 +51,6 @@ void Title_PrintBuildInfo(Gfx** gfxp) { GfxPrint_Printf(&printer, "Build Date:%s", gBuildDate); GfxPrint_SetPos(&printer, 3, 26); GfxPrint_Printf(&printer, "%s", gBuildTeam); - GfxPrint_SetPos(&printer, 3, 28); - GfxPrint_Printf(&printer, "Release Version: %s", gBuildVersion); g = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); *gfxp = g; From d61d4e508abeebe1c67c687ff74999c49da11a83 Mon Sep 17 00:00:00 2001 From: Baoulettes Date: Thu, 4 Aug 2022 04:45:02 +0200 Subject: [PATCH 30/31] fix same name controller entry being unselectable (#1031) This fix being unable to select both entry of controller that has same ID and Name (for example Mayflash mf103 in my tests got two port both ports has same name and ID. --- libultraship/libultraship/InputEditor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libultraship/libultraship/InputEditor.cpp b/libultraship/libultraship/InputEditor.cpp index f03e94d57a..a0e444e388 100644 --- a/libultraship/libultraship/InputEditor.cpp +++ b/libultraship/libultraship/InputEditor.cpp @@ -95,7 +95,11 @@ namespace Ship { if (ControllerName != nullptr && ImGui::BeginCombo("##ControllerEntries", ControllerName)) { for (uint8_t i = 0; i < devices.size(); i++) { - if (ImGui::Selectable(devices[i]->GetControllerName(), i == vDevices[CurrentPort])) { + std::string DeviceName = devices[i]->GetControllerName(); + if (DeviceName != "Keyboard" && DeviceName != "Auto") { + DeviceName+="##"+std::to_string(i); + } + if (ImGui::Selectable(DeviceName.c_str(), i == vDevices[CurrentPort])) { Window::ControllerApi->SetPhysicalDevice(CurrentPort, i); } } From 78ad2820562e80f31b90853d8536133d8f2604f8 Mon Sep 17 00:00:00 2001 From: vaguerant Date: Thu, 4 Aug 2022 12:47:54 +1000 Subject: [PATCH 31/31] Fix Navi HUD text regression (#1020) * Fix Navi HUD text regression * Fix the fix --- soh/src/code/z_parameter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index eecf1be8bd..617cfa397d 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -3343,8 +3343,8 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { const s16 C_Right_BTN_Pos_ori[] = { C_RIGHT_BUTTON_X+X_Margins_CR, C_RIGHT_BUTTON_Y+Y_Margins_CR }; const s16 C_Up_BTN_Pos_ori[] = { C_UP_BUTTON_X+X_Margins_CU, C_UP_BUTTON_Y+Y_Margins_CU }; const s16 C_Down_BTN_Pos_ori[] = { C_DOWN_BUTTON_X+X_Margins_CD, C_DOWN_BUTTON_Y+Y_Margins_CD }; - s16 LabelX_Navi=8; - s16 LabelY_Navi=4 - !!CVar_GetS32("gNaviTextFix", 0); + s16 LabelX_Navi=7 + !!CVar_GetS32("gNaviTextFix", 0); + s16 LabelY_Navi=4; s16 C_Left_BTN_Pos[2]; //(X,Y) s16 C_Right_BTN_Pos[2]; s16 C_Up_BTN_Pos[2];