From 6da00312950dd7a28d8382064e5a8979dff82745 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Wed, 22 May 2024 09:52:56 -0400 Subject: [PATCH] run clang format (#448) * add linux clang format script * first shot at powershell * whoops * webrequest is slow, try webclient * just get the one file * simplify and maybe make it work? * whoops again * try a different suggestion * why is it always windows * again * try again * bit of path stuff * chmod +x * add action to check * fix workflow name * run clang format --- mm/2s2h/BenGui/BenGui.cpp | 126 +-- mm/2s2h/BenGui/BenMenuBar.cpp | 369 +++---- mm/2s2h/BenGui/BenMenuBar.h | 5 +- mm/2s2h/BenGui/HudEditor.cpp | 140 +-- mm/2s2h/BenGui/HudEditor.h | 25 +- mm/2s2h/BenGui/UIWidgets.cpp | 818 +++++++------- mm/2s2h/BenPort.cpp | 139 +-- mm/2s2h/BenPort.h | 1 - mm/2s2h/DeveloperTools/ActorViewer.cpp | 77 +- mm/2s2h/DeveloperTools/ActorViewer.h | 10 +- mm/2s2h/DeveloperTools/BetterMapSelect.c | 24 +- mm/2s2h/DeveloperTools/CollisionViewer.cpp | 66 +- mm/2s2h/DeveloperTools/CollisionViewer.h | 2 +- mm/2s2h/DeveloperTools/DebugConsole.cpp | 28 +- mm/2s2h/DeveloperTools/DeveloperTools.cpp | 15 +- mm/2s2h/DeveloperTools/EventLog.cpp | 263 +++-- mm/2s2h/DeveloperTools/EventLog.h | 10 +- mm/2s2h/DeveloperTools/SaveEditor.cpp | 552 ++++++---- mm/2s2h/DeveloperTools/SaveEditor.h | 10 +- mm/2s2h/DeveloperTools/WarpPoint.cpp | 20 +- mm/2s2h/Enhancements/Camera/DebugCam.cpp | 77 +- mm/2s2h/Enhancements/Camera/FreeLook.cpp | 57 +- mm/2s2h/Enhancements/Cheats/Infinite.cpp | 3 +- mm/2s2h/Enhancements/Cheats/MoonJump.cpp | 19 +- mm/2s2h/Enhancements/Cutscenes/Cutscenes.cpp | 8 +- mm/2s2h/Enhancements/Cutscenes/Cutscenes.h | 8 +- .../MiscInteractions/SkipDekuSalesman.cpp | 18 +- .../MiscInteractions/SkipScarecrowDance.cpp | 48 +- .../MiscInteractions/SkipTatlInterrupts.cpp | 21 +- .../Cutscenes/SkipIntroSequence.cpp | 11 +- .../StoryCutscenes/SkipClockTowerOpen.cpp | 16 +- mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp | 9 +- mm/2s2h/Enhancements/Enhancements.cpp | 11 +- .../FrameInterpolation/FrameInterpolation.cpp | 814 +++++++------- .../GameInteractor/GameInteractor.cpp | 3 +- .../GameInteractor/GameInteractor.h | 87 +- .../GfxPatcher/AuthenticGfxPatches.cpp | 4 +- mm/2s2h/Enhancements/Graphics/MotionBlur.cpp | 15 +- mm/2s2h/Enhancements/Graphics/MotionBlur.h | 1 - mm/2s2h/Enhancements/Graphics/PlayAsKafei.cpp | 10 +- .../Enhancements/Graphics/TextBasedClock.cpp | 7 +- .../Enhancements/Masks/FastTransformation.cpp | 3 +- .../Minigames/AlwaysWinDoggyRace.cpp | 7 +- .../PlayerMovement/ClimbSpeed.cpp | 2 +- mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp | 2 +- mm/2s2h/Extractor/Extract.cpp | 55 +- mm/2s2h/Extractor/Extract.h | 8 +- mm/2s2h/Extractor/FastCrc32C.c | 11 +- mm/2s2h/Extractor/portable-file-dialogs.h | 997 ++++++++---------- mm/2s2h/SaveManager/Migrations/1.cpp | 3 +- mm/2s2h/SaveManager/SaveManager.cpp | 32 +- mm/2s2h/framebuffer_effects.c | 27 +- mm/2s2h/mixer.c | 292 ++--- .../resource/importer/AnimationFactory.cpp | 6 +- mm/2s2h/resource/importer/AnimationFactory.h | 2 +- .../resource/importer/AudioSampleFactory.cpp | 6 +- .../importer/AudioSequenceFactory.cpp | 2 +- .../importer/AudioSoundFontFactory.cpp | 15 +- .../importer/CollisionHeaderFactory.cpp | 18 +- mm/2s2h/resource/importer/CutsceneFactory.cpp | 2 +- mm/2s2h/resource/importer/CutsceneFactory.h | 3 +- mm/2s2h/resource/importer/KeyFrameFactory.h | 2 +- .../importer/PlayerAnimationFactory.h | 2 +- mm/2s2h/resource/importer/SceneFactory.cpp | 6 +- mm/2s2h/resource/importer/SkeletonFactory.cpp | 13 +- mm/2s2h/resource/importer/SkeletonFactory.h | 2 +- .../resource/importer/SkeletonLimbFactory.cpp | 20 +- .../resource/importer/SkeletonLimbFactory.h | 2 +- mm/2s2h/resource/importer/TextMMFactory.cpp | 5 +- mm/2s2h/resource/importer/TextMMFactory.h | 2 +- .../importer/TextureAnimationFactory.cpp | 5 +- .../importer/TextureAnimationFactory.h | 3 +- .../scenecommand/EndMarkerFactory.cpp | 4 +- .../importer/scenecommand/EndMarkerFactory.h | 3 +- .../scenecommand/SceneCommandFactory.cpp | 3 +- .../scenecommand/SceneCommandFactory.h | 2 +- .../SetActorCutsceneListFactory.cpp | 7 +- .../SetActorCutsceneListFactory.h | 4 +- .../scenecommand/SetActorListFactory.cpp | 6 +- .../scenecommand/SetActorListFactory.h | 4 +- .../SetAlternateHeadersFactory.cpp | 10 +- .../scenecommand/SetAlternateHeadersFactory.h | 4 +- .../SetAnimatedMaterialListFactory.cpp | 11 +- .../SetAnimatedMaterialListFactory.h | 4 +- .../scenecommand/SetCameraSettingsFactory.cpp | 5 +- .../scenecommand/SetCameraSettingsFactory.h | 6 +- .../SetCollisionHeaderFactory.cpp | 10 +- .../scenecommand/SetCollisionHeaderFactory.h | 4 +- .../scenecommand/SetCsCameraFactory.cpp | 8 +- .../scenecommand/SetCsCameraFactory.h | 6 +- .../scenecommand/SetCutscenesFactory.cpp | 5 +- .../scenecommand/SetCutscenesFactory.h | 4 +- .../scenecommand/SetEchoSettingsFactory.cpp | 6 +- .../scenecommand/SetEchoSettingsFactory.h | 4 +- .../scenecommand/SetEntranceListFactory.cpp | 14 +- .../scenecommand/SetEntranceListFactory.h | 4 +- .../scenecommand/SetExitListFactory.cpp | 7 +- .../scenecommand/SetExitListFactory.h | 2 +- .../scenecommand/SetLightListFactory.cpp | 12 +- .../scenecommand/SetLightListFactory.h | 4 +- .../scenecommand/SetLightingSettingsFactory.h | 2 +- .../importer/scenecommand/SetMeshFactory.cpp | 6 +- .../importer/scenecommand/SetMeshFactory.h | 4 +- .../scenecommand/SetMinimapChestsFactory.cpp | 4 +- .../scenecommand/SetMinimapChestsFactory.h | 4 +- .../scenecommand/SetMinimapListFactory.cpp | 5 +- .../scenecommand/SetMinimapListFactory.h | 4 +- .../scenecommand/SetObjectListFactory.cpp | 6 +- .../scenecommand/SetObjectListFactory.h | 4 +- .../scenecommand/SetPathwaysFactory.cpp | 4 +- .../scenecommand/SetPathwaysFactory.h | 4 +- .../scenecommand/SetRoomBehaviorFactory.cpp | 5 +- .../scenecommand/SetRoomBehaviorFactory.h | 2 +- .../scenecommand/SetRoomListFactory.cpp | 8 +- .../scenecommand/SetRoomListFactory.h | 4 +- .../scenecommand/SetSkyboxModifierFactory.cpp | 9 +- .../scenecommand/SetSkyboxModifierFactory.h | 4 +- .../scenecommand/SetSkyboxSettingsFactory.cpp | 7 +- .../scenecommand/SetSkyboxSettingsFactory.h | 4 +- .../scenecommand/SetSoundSettingsFactory.cpp | 4 +- .../scenecommand/SetSoundSettingsFactory.h | 4 +- .../scenecommand/SetSpecialObjectsFactory.cpp | 7 +- .../scenecommand/SetSpecialObjectsFactory.h | 4 +- .../SetStartPositionListFactory.cpp | 7 +- .../SetStartPositionListFactory.h | 4 +- .../scenecommand/SetTimeSettingsFactory.cpp | 4 +- .../scenecommand/SetTimeSettingsFactory.h | 6 +- .../SetTransitionActorListFactory.cpp | 9 +- .../SetTransitionActorListFactory.h | 4 +- .../scenecommand/SetWindSettingsFactory.cpp | 2 +- .../scenecommand/SetWindSettingsFactory.h | 4 +- mm/2s2h/resource/type/2shResourceType.h | 4 +- mm/2s2h/resource/type/Animation.cpp | 4 +- mm/2s2h/resource/type/Animation.h | 144 +-- mm/2s2h/resource/type/AudioSample.h | 89 +- mm/2s2h/resource/type/AudioSequence.h | 5 +- mm/2s2h/resource/type/AudioSoundFont.h | 7 +- mm/2s2h/resource/type/Background.h | 3 +- mm/2s2h/resource/type/CollisionHeader.h | 10 +- mm/2s2h/resource/type/Cutscene.cpp | 2 +- mm/2s2h/resource/type/Cutscene.h | 4 +- mm/2s2h/resource/type/KeyFrame.cpp | 5 +- mm/2s2h/resource/type/KeyFrame.h | 6 +- mm/2s2h/resource/type/Path.h | 2 +- mm/2s2h/resource/type/PlayerAnimation.cpp | 2 +- mm/2s2h/resource/type/PlayerAnimation.h | 3 +- mm/2s2h/resource/type/Scene.cpp | 2 +- mm/2s2h/resource/type/Scene.h | 7 +- mm/2s2h/resource/type/Skeleton.cpp | 15 +- mm/2s2h/resource/type/Skeleton.h | 11 +- mm/2s2h/resource/type/SkeletonLimb.cpp | 2 +- mm/2s2h/resource/type/SkeletonLimb.h | 32 +- mm/2s2h/resource/type/TextMM.cpp | 2 +- mm/2s2h/resource/type/TextMM.h | 6 +- mm/2s2h/resource/type/TextureAnimation.cpp | 10 +- .../resource/type/scenecommand/EndMarker.cpp | 2 +- mm/2s2h/resource/type/scenecommand/RomFile.h | 12 +- .../resource/type/scenecommand/SceneCommand.h | 5 +- .../type/scenecommand/SetActorCutsceneList.h | 10 +- .../type/scenecommand/SetActorList.cpp | 2 +- .../resource/type/scenecommand/SetActorList.h | 4 +- .../type/scenecommand/SetAlternateHeaders.h | 1 - .../type/scenecommand/SetCameraSettings.cpp | 2 +- .../type/scenecommand/SetCameraSettings.h | 4 +- .../type/scenecommand/SetCollisionHeader.cpp | 2 +- .../resource/type/scenecommand/SetCsCamera.h | 2 +- .../type/scenecommand/SetEchoSettings.cpp | 2 +- .../type/scenecommand/SetEchoSettings.h | 2 +- .../type/scenecommand/SetEntranceList.cpp | 2 +- .../type/scenecommand/SetExitList.cpp | 2 +- .../type/scenecommand/SetLightList.cpp | 2 +- .../type/scenecommand/SetLightingSettings.cpp | 2 +- .../resource/type/scenecommand/SetMesh.cpp | 2 +- mm/2s2h/resource/type/scenecommand/SetMesh.h | 54 +- .../type/scenecommand/SetMinimapChests.h | 10 +- .../type/scenecommand/SetMinimapList.h | 5 +- .../type/scenecommand/SetObjectList.cpp | 2 +- .../type/scenecommand/SetRoomList.cpp | 2 +- .../type/scenecommand/SetSkyboxModifier.cpp | 2 +- .../type/scenecommand/SetSkyboxModifier.h | 4 +- .../type/scenecommand/SetSkyboxSettings.cpp | 2 +- .../type/scenecommand/SetSkyboxSettings.h | 8 +- .../type/scenecommand/SetSoundSettings.cpp | 2 +- .../type/scenecommand/SetSoundSettings.h | 6 +- .../type/scenecommand/SetSpecialObjects.cpp | 2 +- .../type/scenecommand/SetSpecialObjects.h | 4 +- .../scenecommand/SetStartPositionList.cpp | 2 +- .../type/scenecommand/SetTimeSettings.cpp | 2 +- .../type/scenecommand/SetTimeSettings.h | 6 +- .../scenecommand/SetTransitionActorList.cpp | 2 +- .../scenecommand/SetTransitionActorList.h | 10 +- .../type/scenecommand/SetWindSettings.cpp | 2 +- .../type/scenecommand/SetWindSettings.h | 8 +- mm/2s2h/z_message_OTR.cpp | 44 +- mm/2s2h/z_play_2SH.cpp | 3 +- mm/2s2h/z_scene_2SH.cpp | 59 +- mm/src/audio/lib/load.c | 2 +- mm/src/audio/lib/playback.c | 6 +- mm/src/audio/lib/seqplayer.c | 2 +- mm/src/audio/lib/synthesis.c | 8 +- mm/src/audio/sequence.c | 7 +- mm/src/audio/voice_external.c | 6 +- mm/src/audio/voice_internal.c | 22 +- mm/src/boot/O2/__osMalloc.c | 4 +- mm/src/boot/O2/debug.c | 2 +- mm/src/boot/O2/loadfragment2.c | 4 +- mm/src/boot/O2/rcp_utils.c | 22 +- mm/src/boot/O2/sleep.c | 20 +- mm/src/boot/fault.c | 160 +-- mm/src/boot/fault_drawer.c | 92 +- mm/src/boot/idle.c | 60 +- mm/src/boot/irqmgr.c | 44 +- mm/src/boot/viconfig.c | 4 +- mm/src/boot/yaz0.c | 14 +- mm/src/boot/z_std_dma.c | 52 +- mm/src/buffers/heaps.c | 1 - mm/src/code/c_keyframe.c | 4 +- mm/src/code/graph.c | 2 +- mm/src/code/object_table.c | 2 +- mm/src/code/padmgr.c | 10 +- mm/src/code/sched.c | 11 +- mm/src/code/stubs.c | 34 +- mm/src/code/su_mtx.c | 9 +- mm/src/code/sys_cfb.c | 2 +- mm/src/code/sys_cmpdma.c | 2 +- mm/src/code/sys_matrix.c | 2 +- mm/src/code/sys_ucode.c | 8 +- mm/src/code/z_actor.c | 50 +- mm/src/code/z_camera.c | 6 +- mm/src/code/z_collision_check.c | 2 +- mm/src/code/z_demo.c | 10 +- mm/src/code/z_eff_shield_particle.c | 2 +- mm/src/code/z_fbdemo_circle.c | 3 +- mm/src/code/z_jpeg.c | 4 +- mm/src/code/z_kaleido_manager.c | 4 +- mm/src/code/z_kanfont.c | 3 +- mm/src/code/z_kankyo.c | 30 +- mm/src/code/z_lifemeter.c | 19 +- mm/src/code/z_map_disp.c | 39 +- mm/src/code/z_message.c | 111 +- mm/src/code/z_message_nes.c | 8 +- mm/src/code/z_overlay.c | 4 +- mm/src/code/z_parameter.c | 592 ++++++----- mm/src/code/z_pause.c | 6 +- mm/src/code/z_play.c | 7 +- mm/src/code/z_play_hireso.c | 28 +- mm/src/code/z_player_lib.c | 24 +- mm/src/code/z_rcp.c | 6 +- mm/src/code/z_room.c | 8 +- mm/src/code/z_scene_table.c | 3 +- mm/src/code/z_shrink_window.c | 24 +- mm/src/code/z_skelanime.c | 2 +- mm/src/code/z_sram_NES.c | 25 +- mm/src/code/z_sub_s.c | 7 +- mm/src/code/z_view.c | 4 +- mm/src/code/z_vimode.c | 12 +- mm/src/code/z_visfbuf.c | 12 +- mm/src/code/z_vr_box.c | 3 +- .../actors/ovl_Arms_Hook/z_arms_hook.c | 5 +- .../z_bg_ikana_bombwall.c | 1 - .../overlays/actors/ovl_Boss_05/z_boss_05.c | 28 +- .../overlays/actors/ovl_Boss_06/z_boss_06.c | 3 +- .../actors/ovl_Demo_Moonend/z_demo_moonend.c | 5 +- .../actors/ovl_Demo_Syoten/z_demo_syoten.c | 5 +- .../actors/ovl_Eff_Change/z_eff_change.c | 2 +- .../overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c | 13 +- .../overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c | 7 +- .../actors/ovl_En_Bigslime/z_en_bigslime.c | 2 - mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c | 12 +- .../overlays/actors/ovl_En_Death/z_en_death.c | 3 +- mm/src/overlays/actors/ovl_En_Dt/z_en_dt.c | 4 +- .../overlays/actors/ovl_En_Egol/z_en_egol.c | 2 +- .../overlays/actors/ovl_En_Fall2/z_en_fall2.c | 4 +- mm/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c | 5 +- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 4 +- mm/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 24 +- .../actors/ovl_En_Knight/z_en_knight.c | 15 +- mm/src/overlays/actors/ovl_En_Mag/z_en_mag.c | 11 +- .../actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c | 4 +- .../overlays/actors/ovl_En_Ossan/z_en_ossan.c | 3 +- .../ovl_En_Po_Composer/z_en_po_composer.c | 6 +- mm/src/overlays/actors/ovl_En_Raf/z_en_raf.c | 15 +- .../overlays/actors/ovl_En_Test/z_en_test.c | 7 +- .../overlays/actors/ovl_En_Test7/z_en_test7.c | 2 +- .../overlays/actors/ovl_En_Toto/z_en_toto.c | 49 +- mm/src/overlays/actors/ovl_En_Wf/z_en_wf.c | 4 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 6 +- .../actors/ovl_Oceff_Storm/z_oceff_storm.c | 3 +- .../actors/ovl_Oceff_Wipe/z_oceff_wipe.c | 4 +- .../actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c | 1 - .../actors/ovl_player_actor/z_player.c | 90 +- .../ovl_file_choose/z_file_choose_NES.c | 11 +- .../ovl_file_choose/z_file_nameset_NES.c | 40 +- .../overlays/gamestates/ovl_title/z_title.c | 9 +- .../ovl_kaleido_scope/z_kaleido_collect.c | 6 +- .../ovl_kaleido_scope/z_kaleido_item.c | 210 ++-- .../ovl_kaleido_scope/z_kaleido_map.c | 38 +- .../ovl_kaleido_scope/z_kaleido_mask.c | 25 +- .../ovl_kaleido_scope/z_kaleido_scope_NES.c | 72 +- mm/windows/resource.h | 12 +- 300 files changed, 4560 insertions(+), 4380 deletions(-) diff --git a/mm/2s2h/BenGui/BenGui.cpp b/mm/2s2h/BenGui/BenGui.cpp index ebf091a33..83826528a 100644 --- a/mm/2s2h/BenGui/BenGui.cpp +++ b/mm/2s2h/BenGui/BenGui.cpp @@ -23,87 +23,87 @@ bool ShouldClearTextureCacheAtEndOfFrame = false; namespace BenGui { - // MARK: - Delegates +// MARK: - Delegates - std::shared_ptr mBenMenuBar; +std::shared_ptr mBenMenuBar; - std::shared_ptr mConsoleWindow; - std::shared_ptr mStatsWindow; - std::shared_ptr mInputEditorWindow; - std::shared_ptr mGfxDebuggerWindow; +std::shared_ptr mConsoleWindow; +std::shared_ptr mStatsWindow; +std::shared_ptr mInputEditorWindow; +std::shared_ptr mGfxDebuggerWindow; - std::shared_ptr mSaveEditorWindow; - std::shared_ptr mHudEditorWindow; - std::shared_ptr mActorViewerWindow; - std::shared_ptr mCollisionViewerWindow; - std::shared_ptr mEventLogWindow; +std::shared_ptr mSaveEditorWindow; +std::shared_ptr mHudEditorWindow; +std::shared_ptr mActorViewerWindow; +std::shared_ptr mCollisionViewerWindow; +std::shared_ptr mEventLogWindow; - void SetupGuiElements() { - auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); +void SetupGuiElements() { + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); - auto& style = ImGui::GetStyle(); - style.FramePadding = ImVec2(4.0f, 6.0f); - style.ItemSpacing = ImVec2(8.0f, 6.0f); - style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray; + auto& style = ImGui::GetStyle(); + style.FramePadding = ImVec2(4.0f, 6.0f); + style.ItemSpacing = ImVec2(8.0f, 6.0f); + style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray; - mBenMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); - gui->SetMenuBar(std::reinterpret_pointer_cast(mBenMenuBar)); + mBenMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); + gui->SetMenuBar(std::reinterpret_pointer_cast(mBenMenuBar)); - if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) { + if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) { #if defined(__SWITCH__) || defined(__WIIU__) - gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press - to access enhancements menu"); + gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press - to access enhancements menu"); #else - gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu"); + gui->GetGameOverlay()->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu"); #endif - } + } - mStatsWindow = gui->GetGuiWindow("Stats"); - if (mStatsWindow == nullptr) { - SPDLOG_ERROR("Could not find stats window"); - } + mStatsWindow = gui->GetGuiWindow("Stats"); + if (mStatsWindow == nullptr) { + SPDLOG_ERROR("Could not find stats window"); + } - mConsoleWindow = gui->GetGuiWindow("Console"); - if (mConsoleWindow == nullptr) { - SPDLOG_ERROR("Could not find console window"); - } + mConsoleWindow = gui->GetGuiWindow("Console"); + if (mConsoleWindow == nullptr) { + SPDLOG_ERROR("Could not find console window"); + } - mInputEditorWindow = gui->GetGuiWindow("Input Editor"); - if (mInputEditorWindow == nullptr) { - SPDLOG_ERROR("Could not find input editor window"); - } + mInputEditorWindow = gui->GetGuiWindow("Input Editor"); + if (mInputEditorWindow == nullptr) { + SPDLOG_ERROR("Could not find input editor window"); + } - mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); - if (mGfxDebuggerWindow == nullptr) { - SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); - } + mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); + if (mGfxDebuggerWindow == nullptr) { + SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); + } - mSaveEditorWindow = std::make_shared("gWindows.SaveEditor", "Save Editor"); - gui->AddGuiWindow(mSaveEditorWindow); + mSaveEditorWindow = std::make_shared("gWindows.SaveEditor", "Save Editor"); + gui->AddGuiWindow(mSaveEditorWindow); - mHudEditorWindow = std::make_shared("gWindows.HudEditor", "Hud Editor"); - gui->AddGuiWindow(mHudEditorWindow); + mHudEditorWindow = std::make_shared("gWindows.HudEditor", "Hud Editor"); + gui->AddGuiWindow(mHudEditorWindow); - mActorViewerWindow = std::make_shared("gWindows.ActorViewer", "Actor Viewer"); - gui->AddGuiWindow(mActorViewerWindow); + mActorViewerWindow = std::make_shared("gWindows.ActorViewer", "Actor Viewer"); + gui->AddGuiWindow(mActorViewerWindow); - mCollisionViewerWindow = std::make_shared("gWindows.CollisionViewer", "Collision Viewer"); - gui->AddGuiWindow(mCollisionViewerWindow); + mCollisionViewerWindow = std::make_shared("gWindows.CollisionViewer", "Collision Viewer"); + gui->AddGuiWindow(mCollisionViewerWindow); - mEventLogWindow = std::make_shared("gWindows.EventLog", "Event Log"); - gui->AddGuiWindow(mEventLogWindow); - } + mEventLogWindow = std::make_shared("gWindows.EventLog", "Event Log"); + gui->AddGuiWindow(mEventLogWindow); +} - void Destroy() { - mBenMenuBar = nullptr; - mStatsWindow = nullptr; - mConsoleWindow = nullptr; - mInputEditorWindow = nullptr; - mGfxDebuggerWindow = nullptr; - mCollisionViewerWindow = nullptr; - mEventLogWindow = nullptr; - - mSaveEditorWindow = nullptr; - mHudEditorWindow = nullptr; - mActorViewerWindow = nullptr; - } +void Destroy() { + mBenMenuBar = nullptr; + mStatsWindow = nullptr; + mConsoleWindow = nullptr; + mInputEditorWindow = nullptr; + mGfxDebuggerWindow = nullptr; + mCollisionViewerWindow = nullptr; + mEventLogWindow = nullptr; + + mSaveEditorWindow = nullptr; + mHudEditorWindow = nullptr; + mActorViewerWindow = nullptr; } +} // namespace BenGui diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 4c2244862..91ad63ab6 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -62,7 +62,8 @@ namespace BenGui { void DrawMenuBarIcon() { static bool gameIconLoaded = false; if (!gameIconLoaded) { - Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Game_Icon", "textures/icons/g2ShipIcon.png"); + Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Game_Icon", + "textures/icons/g2ShipIcon.png"); gameIconLoaded = true; } @@ -88,11 +89,11 @@ void DrawBenMenu() { if (UIWidgets::BeginMenu("2Ship")) { if (UIWidgets::MenuItem("Hide Menu Bar", #if !defined(__SWITCH__) && !defined(__WIIU__) - "F1" + "F1" #else - "[-]" + "[-]" #endif - )) { + )) { Ship::Context::GetInstance()->GetWindow()->GetGui()->GetMenuBar()->ToggleVisibility(); } #if !defined(__SWITCH__) && !defined(__WIIU__) @@ -102,13 +103,13 @@ void DrawBenMenu() { #endif if (UIWidgets::MenuItem("Reset", #ifdef __APPLE__ - "Command-R" + "Command-R" #elif !defined(__SWITCH__) && !defined(__WIIU__) - "Ctrl+R" + "Ctrl+R" #else - "" + "" #endif - )) { + )) { std::reinterpret_pointer_cast( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) ->Dispatch("reset"); @@ -132,30 +133,36 @@ extern std::shared_ptr mInputEditorWindow; void DrawSettingsMenu() { if (UIWidgets::BeginMenu("Settings")) { if (UIWidgets::BeginMenu("Audio")) { - UIWidgets::CVarSliderFloat("Master Volume: %.0f %%", "gSettings.Audio.MasterVolume", 0.0f, 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true }); + UIWidgets::CVarSliderFloat("Master Volume: %.0f %%", "gSettings.Audio.MasterVolume", 0.0f, 1.0f, 1.0f, + { .showButtons = false, .format = "", .isPercentage = true }); - if (UIWidgets::CVarSliderFloat("Main Music Volume: %.0f %%", "gSettings.Audio.MainMusicVolume", 0.0f, 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { + if (UIWidgets::CVarSliderFloat("Main Music Volume: %.0f %%", "gSettings.Audio.MainMusicVolume", 0.0f, 1.0f, + 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { AudioSeq_SetPortVolumeScale(SEQ_PLAYER_BGM_MAIN, CVarGetFloat("gSettings.Audio.MainMusicVolume", 1.0f)); } - if (UIWidgets::CVarSliderFloat("Sub Music Volume: %.0f %%", "gSettings.Audio.SubMusicVolume", 0.0f, 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { + if (UIWidgets::CVarSliderFloat("Sub Music Volume: %.0f %%", "gSettings.Audio.SubMusicVolume", 0.0f, 1.0f, + 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { AudioSeq_SetPortVolumeScale(SEQ_PLAYER_BGM_SUB, CVarGetFloat("gSettings.Audio.SubMusicVolume", 1.0f)); } - if (UIWidgets::CVarSliderFloat("Sound Effects Volume: %.0f %%", "gSettings.Audio.SoundEffectsVolume", 0.0f, 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { + if (UIWidgets::CVarSliderFloat("Sound Effects Volume: %.0f %%", "gSettings.Audio.SoundEffectsVolume", 0.0f, + 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { AudioSeq_SetPortVolumeScale(SEQ_PLAYER_SFX, CVarGetFloat("gSettings.Audio.SoundEffectsVolume", 1.0f)); } - if (UIWidgets::CVarSliderFloat("Fanfare Volume: %.0f %%", "gSettings.Audio.FanfareVolume", 0.0f, 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { + if (UIWidgets::CVarSliderFloat("Fanfare Volume: %.0f %%", "gSettings.Audio.FanfareVolume", 0.0f, 1.0f, 1.0f, + { .showButtons = false, .format = "", .isPercentage = true })) { AudioSeq_SetPortVolumeScale(SEQ_PLAYER_FANFARE, CVarGetFloat("gSettings.Audio.FanfareVolume", 1.0f)); } - if (UIWidgets::CVarSliderFloat("Ambience Volume: %.0f %%", "gSettings.Audio.AmbienceVolume", 0.0f, 1.0f, 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { + if (UIWidgets::CVarSliderFloat("Ambience Volume: %.0f %%", "gSettings.Audio.AmbienceVolume", 0.0f, 1.0f, + 1.0f, { .showButtons = false, .format = "", .isPercentage = true })) { AudioSeq_SetPortVolumeScale(SEQ_PLAYER_AMBIENCE, CVarGetFloat("gSettings.Audio.AmbienceVolume", 1.0f)); } auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); - if (UIWidgets::Combobox("Audio API", ¤tAudioBackend, audioBackendsMap, { - .tooltip = "Sets the audio API used by the game. Requires a relaunch to take effect.", - .disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1, - .disabledTooltip = "Only one audio API is available on this platform." - })) { + if (UIWidgets::Combobox( + "Audio API", ¤tAudioBackend, audioBackendsMap, + { .tooltip = "Sets the audio API used by the game. Requires a relaunch to take effect.", + .disabled = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1, + .disabledTooltip = "Only one audio API is available on this platform." })) { Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(currentAudioBackend); } @@ -163,18 +170,22 @@ void DrawSettingsMenu() { } if (UIWidgets::BeginMenu("Graphics")) { - - #ifndef __APPLE__ + +#ifndef __APPLE__ if (UIWidgets::CVarSliderFloat("Internal Resolution: %f %%", "gInternalResolution", 0.5f, 2.0f, 1.0f)) { - Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( + CVarGetFloat("gInternalResolution", 1)); }; - UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective " "form of anti-aliasing"); -#endif -#ifndef __WIIU__ - if (UIWidgets::CVarSliderInt("MSAA: %d","gMSAAValue", 1, 8, 1)) { + UIWidgets::Tooltip( + "Multiplies your output resolution by the value inputted, as a more intensive but effective " + "form of anti-aliasing"); +#endif +#ifndef __WIIU__ + if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1)) { Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); }; - UIWidgets::Tooltip("Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); + UIWidgets::Tooltip( + "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel"); #endif { // FPS Slider @@ -185,22 +196,27 @@ void DrawSettingsMenu() { } else { maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } - unsigned int currentFps = std::max(std::min(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); + unsigned int currentFps = + std::max(std::min(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); bool matchingRefreshRate = CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", - minFps, maxFps, 20, {.disabled = matchingRefreshRate} ); + minFps, maxFps, 20, { .disabled = matchingRefreshRate }); if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::Tooltip( - "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely visual and does not impact game logic, execution of glitches etc.\n\n A higher target FPS than your monitor's refresh rate will waste resources, and might give a worse result."); - } else { - UIWidgets::Tooltip( "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely visual and does not impact game logic, execution of glitches etc."); + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is " + "purely visual and does not impact game logic, execution of glitches etc.\n\n A higher target " + "FPS than your monitor's refresh rate will waste resources, and might give a worse result."); + } else { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is " + "purely visual and does not impact game logic, execution of glitches etc."); } } // END FPS Slider if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { - //UIWidgets::Spacer(0); + // UIWidgets::Spacer(0); if (ImGui::Button("Match Refresh Rate")) { int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 20 && hz <= 360) { @@ -214,13 +230,17 @@ void DrawSettingsMenu() { UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { - UIWidgets::CVarSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", - "gExtraLatencyThreshold", 0, 360, 80); - UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); + UIWidgets::CVarSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" + : "Jitter fix: >= %d FPS", + "gExtraLatencyThreshold", 0, 360, 80); + UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input " + "lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the " + "CPU to work on one frame while GPU works on the previous frame.\nThis setting " + "should be used when your computer is too slow to do CPU + GPU work in time."); } - //UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - // #endregion */ + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // #endregion */ Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); Ship::WindowBackend configWindowBackend; @@ -244,9 +264,9 @@ void DrawSettingsMenu() { .disabled = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1, .disabledTooltip = "Only one renderer API is available on this platform." })) { Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", - static_cast(configWindowBackend)); + static_cast(configWindowBackend)); Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", - windowBackendsMap.at(configWindowBackend)); + windowBackendsMap.at(configWindowBackend)); Ship::Context::GetInstance()->GetConfig()->Save(); } @@ -271,12 +291,12 @@ void DrawSettingsMenu() { ImGui::EndMenu(); } - // #region 2S2H [Todo] None of this works yet + // #region 2S2H [Todo] None of this works yet /* if (UIWidgets::BeginMenu("Controller")) { */ - if (mInputEditorWindow) { - UIWidgets::WindowButton("Controller Mapping", "gWindows.InputEditor", mInputEditorWindow); - } + if (mInputEditorWindow) { + UIWidgets::WindowButton("Controller Mapping", "gWindows.InputEditor", mInputEditorWindow); + } /* #ifndef __SWITCH__ UIWidgets::CVarCheckbox("Menubar Controller Navigation", "gControlNav", { @@ -288,9 +308,9 @@ void DrawSettingsMenu() { UIWidgets::CVarCheckbox("Show Inputs", "gInputEnabled", { .tooltip = "Shows currently pressed inputs on the bottom right of the screen" }); - UIWidgets::CVarSliderFloat("Input Scale: %.1f", "gInputScale", 1.0f, 3.0f, 1.0f, { + UIWidgets::CVarSliderFloat("Input Scale: %.1f", "gInputScale", 1.0f, 3.0f, 1.0f, { .tooltip = "Sets the on screen size of the displayed inputs from the Show Inputs setting", - .showButtons = false, + .showButtons = false, .format = "" }); UIWidgets::CVarSliderInt("Simulated Input Lag: %d frames", "gSimulatedInputLag", 0, 6, 0, { @@ -312,44 +332,51 @@ void DrawEnhancementsMenu() { if (UIWidgets::BeginMenu("Camera")) { ImGui::SeparatorText("Right Stick Camera"); - UIWidgets::CVarCheckbox("Invert Camera X Axis", "gEnhancements.Camera.RightStick.InvertXAxis", { - .tooltip = "Inverts the Camera X Axis in Free Look." - }); - UIWidgets::CVarCheckbox("Invert Camera Y Axis", "gEnhancements.Camera.RightStick.InvertYAxis", { - .tooltip = "Inverts the Camera Y Axis in Free Look.", - .defaultValue = true - }); - UIWidgets::CVarSliderFloat("Third-Person Horizontal Sensitivity: %.0f", "gEnhancements.Camera.RightStick.CameraSensitivity.X", 0.01f, 5.0f, 1.0f); - UIWidgets::CVarSliderFloat("Third-Person Vertical Sensitivity: %.0f", "gEnhancements.Camera.RightStick.CameraSensitivity.Y", 0.01f, 5.0f, 1.0f); + UIWidgets::CVarCheckbox("Invert Camera X Axis", "gEnhancements.Camera.RightStick.InvertXAxis", + { .tooltip = "Inverts the Camera X Axis in Free Look." }); + UIWidgets::CVarCheckbox("Invert Camera Y Axis", "gEnhancements.Camera.RightStick.InvertYAxis", + { .tooltip = "Inverts the Camera Y Axis in Free Look.", .defaultValue = true }); + UIWidgets::CVarSliderFloat("Third-Person Horizontal Sensitivity: %.0f", + "gEnhancements.Camera.RightStick.CameraSensitivity.X", 0.01f, 5.0f, 1.0f); + UIWidgets::CVarSliderFloat("Third-Person Vertical Sensitivity: %.0f", + "gEnhancements.Camera.RightStick.CameraSensitivity.Y", 0.01f, 5.0f, 1.0f); ImGui::SeparatorText("Free Look"); - if (UIWidgets::CVarCheckbox("Free Look", "gEnhancements.Camera.FreeLook.Enable", { - .tooltip = "Enables free look camera control\nNote: You must remap C buttons off of the right stick in the controller config menu, and map the camera stick to the right stick.", - .disabled = CVarGetInteger("gEnhancements.Camera.DebugCam.Enable", 0) != 0 - })) { + if (UIWidgets::CVarCheckbox( + "Free Look", "gEnhancements.Camera.FreeLook.Enable", + { .tooltip = "Enables free look camera control\nNote: You must remap C buttons off of the right " + "stick in the controller config menu, and map the camera stick to the right stick.", + .disabled = CVarGetInteger("gEnhancements.Camera.DebugCam.Enable", 0) != 0 })) { RegisterCameraFreeLook(); } - UIWidgets::CVarSliderInt("Camera Distance: %d", "gEnhancements.Camera.FreeLook.MaxCameraDistance", 100, 900, 185); - UIWidgets::CVarSliderInt("Camera Transition Speed: %d", "gEnhancements.Camera.FreeLook.TransitionSpeed", 1, 900, 25); - UIWidgets::CVarSliderFloat("Max Camera Height Angle: %.0f°", "gEnhancements.Camera.FreeLook.MaxPitch", -89.0f, 89.0f, 72.0f); - UIWidgets::CVarSliderFloat("Min Camera Height Angle: %.0f°", "gEnhancements.Camera.FreeLook.MinPitch", -89.0f, 89.0f, -49.0f); + UIWidgets::CVarSliderInt("Camera Distance: %d", "gEnhancements.Camera.FreeLook.MaxCameraDistance", 100, 900, + 185); + UIWidgets::CVarSliderInt("Camera Transition Speed: %d", "gEnhancements.Camera.FreeLook.TransitionSpeed", 1, + 900, 25); + UIWidgets::CVarSliderFloat("Max Camera Height Angle: %.0f°", "gEnhancements.Camera.FreeLook.MaxPitch", + -89.0f, 89.0f, 72.0f); + UIWidgets::CVarSliderFloat("Min Camera Height Angle: %.0f°", "gEnhancements.Camera.FreeLook.MinPitch", + -89.0f, 89.0f, -49.0f); f32 maxY = CVarGetFloat("gEnhancements.Camera.FreeLook.MaxPitch", 72.0f); f32 minY = CVarGetFloat("gEnhancements.Camera.FreeLook.MinPitch", -49.0f); CVarSetFloat("gEnhancements.Camera.FreeLook.MaxPitch", std::max(maxY, minY)); CVarSetFloat("gEnhancements.Camera.FreeLook.MinPitch", std::min(maxY, minY)); ImGui::SeparatorText("'Debug' Camera"); - if (UIWidgets::CVarCheckbox("Debug Camera", "gEnhancements.Camera.DebugCam.Enable", { - .tooltip = "Enables free camera control.", - .disabled = CVarGetInteger("gEnhancements.Camera.FreeLook.Enable", 0) != 0 - })) { + if (UIWidgets::CVarCheckbox( + "Debug Camera", "gEnhancements.Camera.DebugCam.Enable", + { .tooltip = "Enables free camera control.", + .disabled = CVarGetInteger("gEnhancements.Camera.FreeLook.Enable", 0) != 0 })) { RegisterDebugCam(); } - UIWidgets::CVarCheckbox("Enable Roll (Six Degrees Of Freedom)", "gEnhancements.Camera.DebugCam.6DOF", { - .tooltip = "This allows for all six degrees of movement with the camera, NOTE: Yaw will work differently in this system, instead rotating around the focal point, rather than a polar axis." - }); - UIWidgets::CVarSliderFloat("Camera Speed: %.0f", "gEnhancements.Camera.DebugCam.CameraSpeed", 0.1f, 3.0f, 0.5f); + UIWidgets::CVarCheckbox( + "Enable Roll (Six Degrees Of Freedom)", "gEnhancements.Camera.DebugCam.6DOF", + { .tooltip = + "This allows for all six degrees of movement with the camera, NOTE: Yaw will work differently in " + "this system, instead rotating around the focal point, rather than a polar axis." }); + UIWidgets::CVarSliderFloat("Camera Speed: %.0f", "gEnhancements.Camera.DebugCam.CameraSpeed", 0.1f, 3.0f, + 0.5f); ImGui::EndMenu(); } @@ -368,48 +395,46 @@ void DrawEnhancementsMenu() { } if (UIWidgets::BeginMenu("Cycle / Saving")) { - UIWidgets::CVarCheckbox("Pause Menu Save", "gEnhancements.Kaleido.PauseSave", { - .tooltip = "Re-introduce the pause menu save system. Pressing B in the pause menu will give you the option to create an Owl Save from your current location. When loading back into the game, you will be placed at your last entrance." - }); - UIWidgets::CVarCheckbox("Do not reset Bottle content", "gEnhancements.Cycle.DoNotResetBottleContent", { - .tooltip = "Playing the Song Of Time will not reset the bottles' content." - }); - UIWidgets::CVarCheckbox("Do not reset Consumables", "gEnhancements.Cycle.DoNotResetConsumables", { - .tooltip = "Playing the Song Of Time will not reset the consumables." - }); - UIWidgets::CVarCheckbox("Do not reset Razor Sword", "gEnhancements.Cycle.DoNotResetRazorSword", { - .tooltip = "Playing the Song Of Time will not reset the Sword back to Kokiri Sword." - }); - UIWidgets::CVarCheckbox("Do not reset Rupees", "gEnhancements.Cycle.DoNotResetRupees", { - .tooltip = "Playing the Song Of Time will not reset the your rupees." - }); - UIWidgets::CVarSliderInt("Save Delay", "gEnhancements.Save.SaveDelay", 0, 5, 0, { - .tooltip = "Sets the delay between pressing save and the save being marked as complete. Original game was 2." - }); + UIWidgets::CVarCheckbox( + "Pause Menu Save", "gEnhancements.Kaleido.PauseSave", + { .tooltip = "Re-introduce the pause menu save system. Pressing B in the pause menu will give you the " + "option to create an Owl Save from your current location. When loading back into the " + "game, you will be placed at your last entrance." }); + UIWidgets::CVarCheckbox("Do not reset Bottle content", "gEnhancements.Cycle.DoNotResetBottleContent", + { .tooltip = "Playing the Song Of Time will not reset the bottles' content." }); + UIWidgets::CVarCheckbox("Do not reset Consumables", "gEnhancements.Cycle.DoNotResetConsumables", + { .tooltip = "Playing the Song Of Time will not reset the consumables." }); + UIWidgets::CVarCheckbox( + "Do not reset Razor Sword", "gEnhancements.Cycle.DoNotResetRazorSword", + { .tooltip = "Playing the Song Of Time will not reset the Sword back to Kokiri Sword." }); + UIWidgets::CVarCheckbox("Do not reset Rupees", "gEnhancements.Cycle.DoNotResetRupees", + { .tooltip = "Playing the Song Of Time will not reset the your rupees." }); + UIWidgets::CVarSliderInt("Save Delay", "gEnhancements.Save.SaveDelay", 0, 5, 0, + { .tooltip = "Sets the delay between pressing save and the save being marked as " + "complete. Original game was 2." }); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Dialogues")) { - UIWidgets::CVarCheckbox("Fast Text", "gEnhancements.Dialogue.FastText", { - .tooltip = "Speeds up text rendering, and enables holding of B progress to next message" - }); - + UIWidgets::CVarCheckbox( + "Fast Text", "gEnhancements.Dialogue.FastText", + { .tooltip = "Speeds up text rendering, and enables holding of B progress to next message" }); + ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Dpad")) { - UIWidgets::CVarCheckbox("Dpad Equips", "gEnhancements.Dpad.DpadEquips", { - .tooltip = "Allows you to equip items to your d-pad" - }); + UIWidgets::CVarCheckbox("Dpad Equips", "gEnhancements.Dpad.DpadEquips", + { .tooltip = "Allows you to equip items to your d-pad" }); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Fixes")) { - UIWidgets::CVarCheckbox("Fix Ammo Count Color", "gFixes.FixAmmoCountEnvColor", { - .tooltip = "Fixes a missing gDPSetEnvColor, which causes the ammo count to be the wrong color prior to obtaining magic or other conditions." - }); + UIWidgets::CVarCheckbox("Fix Ammo Count Color", "gFixes.FixAmmoCountEnvColor", + { .tooltip = "Fixes a missing gDPSetEnvColor, which causes the ammo count to be " + "the wrong color prior to obtaining magic or other conditions." }); ImGui::EndMenu(); } @@ -420,84 +445,77 @@ void DrawEnhancementsMenu() { UIWidgets::CVarCheckbox("24 Hours Clock", "gEnhancements.Graphics.24HoursClock"); MotionBlur_RenderMenuOptions(); ImGui::SeparatorText("Other"); - UIWidgets::CVarCheckbox("Authentic logo", "gEnhancements.Graphics.AuthenticLogo", { - .tooltip = "Hide the game version and build details and display the authentic model and texture on the boot logo start screen" - }); - UIWidgets::CVarCheckbox("Bow Reticle", "gEnhancements.Graphics.BowReticle", { - .tooltip = "Gives the bow a reticle when you draw an arrow" - }); + UIWidgets::CVarCheckbox("Authentic logo", "gEnhancements.Graphics.AuthenticLogo", + { .tooltip = "Hide the game version and build details and display the authentic " + "model and texture on the boot logo start screen" }); + UIWidgets::CVarCheckbox("Bow Reticle", "gEnhancements.Graphics.BowReticle", + { .tooltip = "Gives the bow a reticle when you draw an arrow" }); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Masks")) { UIWidgets::CVarCheckbox("Fast Transformation", "gEnhancements.Masks.FastTransformation"); - UIWidgets::CVarCheckbox("Fierce Deity's Mask Anywhere", "gEnhancements.Masks.FierceDeitysAnywhere", { - .tooltip = "Allow using Fierce Deity's mask outside of boss rooms." - }); + UIWidgets::CVarCheckbox("Fierce Deity's Mask Anywhere", "gEnhancements.Masks.FierceDeitysAnywhere", + { .tooltip = "Allow using Fierce Deity's mask outside of boss rooms." }); UIWidgets::CVarCheckbox("No Blast Mask Cooldown", "gEnhancements.Masks.NoBlastMaskCooldown", {}); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Minigames")) { - UIWidgets::CVarCombobox("Always Win Doggy Race", "gEnhancements.Minigames.AlwaysWinDoggyRace", alwaysWinDoggyraceOptions); + UIWidgets::CVarCombobox("Always Win Doggy Race", "gEnhancements.Minigames.AlwaysWinDoggyRace", + alwaysWinDoggyraceOptions); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Modes")) { - if (UIWidgets::CVarCheckbox("Play As Kafei", "gModes.PlayAsKafei", { - .tooltip = "Requires scene reload to take effect." - })) { + if (UIWidgets::CVarCheckbox("Play As Kafei", "gModes.PlayAsKafei", + { .tooltip = "Requires scene reload to take effect." })) { UpdatePlayAsKafeiSkeletons(); } ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Player Movement")) { - UIWidgets::CVarSliderInt("Climb speed", "gEnhancements.PlayerMovement.ClimbSpeed", 1, 5, 1, { - .tooltip = "Increases the speed at which Link climbs vines and ladders." - }); + UIWidgets::CVarSliderInt("Climb speed", "gEnhancements.PlayerMovement.ClimbSpeed", 1, 5, 1, + { .tooltip = "Increases the speed at which Link climbs vines and ladders." }); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Restorations")) { - UIWidgets::CVarCheckbox("Power Crouch Stab", "gEnhancements.Restorations.PowerCrouchStab", { - .tooltip = "Crouch stabs will use the power of Link's previous melee attack, as is in MM JP 1.0 and OOT." - }); - UIWidgets::CVarCheckbox("Side Rolls", "gEnhancements.Restorations.SideRoll", { - .tooltip = "Restores side rolling from OOT." - }); - UIWidgets::CVarCheckbox("Tatl ISG", "gEnhancements.Restorations.TatlISG", { - .tooltip = "Restores Navi ISG from OOT, but now with Tatl." - }); + UIWidgets::CVarCheckbox( + "Power Crouch Stab", "gEnhancements.Restorations.PowerCrouchStab", + { .tooltip = + "Crouch stabs will use the power of Link's previous melee attack, as is in MM JP 1.0 and OOT." }); + UIWidgets::CVarCheckbox("Side Rolls", "gEnhancements.Restorations.SideRoll", + { .tooltip = "Restores side rolling from OOT." }); + UIWidgets::CVarCheckbox("Tatl ISG", "gEnhancements.Restorations.TatlISG", + { .tooltip = "Restores Navi ISG from OOT, but now with Tatl." }); ImGui::EndMenu(); } if (UIWidgets::BeginMenu("Songs/Playback")) { - UIWidgets::CVarCheckbox("Enable Sun's Song", "gEnhancements.Songs.EnableSunsSong", { - .tooltip = "Enables the partially implemented Sun's Song. RIGHT-DOWN-UP-RIGHT-DOWN-UP to play it. " - "This song will make time move very fast until either Link moves to a different scene, " - "or when the time switches to a new time period." - }); - UIWidgets::CVarCheckbox("Prevent Dropped Ocarina Inputs", "gEnhancements.Playback.NoDropOcarinaInput", { - .tooltip = "Prevent dropping inputs when playing the ocarina quickly" - }); + UIWidgets::CVarCheckbox( + "Enable Sun's Song", "gEnhancements.Songs.EnableSunsSong", + { .tooltip = "Enables the partially implemented Sun's Song. RIGHT-DOWN-UP-RIGHT-DOWN-UP to play it. " + "This song will make time move very fast until either Link moves to a different scene, " + "or when the time switches to a new time period." }); + UIWidgets::CVarCheckbox("Prevent Dropped Ocarina Inputs", "gEnhancements.Playback.NoDropOcarinaInput", + { .tooltip = "Prevent dropping inputs when playing the ocarina quickly" }); ImGui::EndMenu(); } if (mHudEditorWindow) { - UIWidgets::WindowButton("Hud Editor", "gWindows.HudEditor", mHudEditorWindow, { - .tooltip = "Enables the Hud Editor window, allowing you to edit your hud" - }); + UIWidgets::WindowButton("Hud Editor", "gWindows.HudEditor", mHudEditorWindow, + { .tooltip = "Enables the Hud Editor window, allowing you to edit your hud" }); } ImGui::EndMenu(); } - } void DrawCheatsMenu() { @@ -507,9 +525,8 @@ void DrawCheatsMenu() { UIWidgets::CVarCheckbox("Infinite Rupees", "gCheats.InfiniteRupees"); UIWidgets::CVarCheckbox("Infinite Consumables", "gCheats.InfiniteConsumables"); UIWidgets::CVarCheckbox("Unbreakable Razor Sword", "gCheats.UnbreakableRazorSword"); - if (UIWidgets::CVarCheckbox("Moon Jump on L", "gCheats.MoonJumpOnL", { - .tooltip = "Holding L makes you float into the air" - })) { + if (UIWidgets::CVarCheckbox("Moon Jump on L", "gCheats.MoonJumpOnL", + { .tooltip = "Holding L makes you float into the air" })) { RegisterMoonJumpOnL(); } UIWidgets::CVarCheckbox("No Clip", "gCheats.NoClip"); @@ -527,20 +544,13 @@ extern std::shared_ptr mCollisionViewerWindow; extern std::shared_ptr mEventLogWindow; const char* logLevels[] = { - "trace", - "debug", - "info", - "warn", - "error", - "critical", - "off", + "trace", "debug", "info", "warn", "error", "critical", "off", }; void DrawDeveloperToolsMenu() { if (UIWidgets::BeginMenu("Developer Tools", UIWidgets::Colors::Yellow)) { - UIWidgets::CVarCheckbox("Debug Mode", "gDeveloperTools.DebugEnabled", { - .tooltip = "Enables Debug Mode, allowing you to select maps with L + R + Z." - }); + UIWidgets::CVarCheckbox("Debug Mode", "gDeveloperTools.DebugEnabled", + { .tooltip = "Enables Debug Mode, allowing you to select maps with L + R + Z." }); if (CVarGetInteger("gDeveloperTools.DebugEnabled", 0)) { if (UIWidgets::CVarCombobox( @@ -564,20 +574,23 @@ void DrawDeveloperToolsMenu() { if (UIWidgets::CVarCheckbox("Prevent Actor Init", "gDeveloperTools.PreventActorInit")) { RegisterPreventActorInitHooks(); } - if (UIWidgets::CVarCombobox("Log Level", "gDeveloperTools.LogLevel", logLevels, { - .tooltip = "The log level determines which messages are printed to the console. This does not affect the log file output", - .defaultIndex = 1, - })) { - Ship::Context::GetInstance()->GetLogger()->set_level((spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); + if (UIWidgets::CVarCombobox("Log Level", "gDeveloperTools.LogLevel", logLevels, + { + .tooltip = "The log level determines which messages are printed to the " + "console. This does not affect the log file output", + .defaultIndex = 1, + })) { + Ship::Context::GetInstance()->GetLogger()->set_level( + (spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); } - + if (gPlayState != NULL) { ImGui::Separator(); - UIWidgets::Checkbox("Frame Advance", (bool*)&gPlayState->frameAdvCtx.enabled, { - .tooltip = "This allows you to advance through the game one frame at a time on command. " - "To advance a frame, hold Z and tap R on the second controller. Holding Z " - "and R will advance a frame every half second. You can also use the buttons below." - }); + UIWidgets::Checkbox( + "Frame Advance", (bool*)&gPlayState->frameAdvCtx.enabled, + { .tooltip = "This allows you to advance through the game one frame at a time on command. " + "To advance a frame, hold Z and tap R on the second controller. Holding Z " + "and R will advance a frame every half second. You can also use the buttons below." }); if (gPlayState->frameAdvCtx.enabled) { if (UIWidgets::Button("Advance 1", { .size = UIWidgets::Sizes::Inline })) { CVarSetInteger("gDeveloperTools.FrameAdvanceTick", 1); @@ -593,32 +606,34 @@ void DrawDeveloperToolsMenu() { ImGui::Separator(); if (mCollisionViewerWindow) { UIWidgets::WindowButton("Collision Viewer", "gWindows.CollisionViewer", mCollisionViewerWindow, - { .tooltip = "Draws collision to the screen" }); + { .tooltip = "Draws collision to the screen" }); } if (mStatsWindow) { - UIWidgets::WindowButton("Stats", "gWindows.Stats", mStatsWindow, { - .tooltip = "Shows the stats window, with your FPS and frametimes, and the OS you're playing on" - }); + UIWidgets::WindowButton( + "Stats", "gWindows.Stats", mStatsWindow, + { .tooltip = "Shows the stats window, with your FPS and frametimes, and the OS you're playing on" }); } if (mConsoleWindow) { - UIWidgets::WindowButton("Console", "gWindows.Console", mConsoleWindow, { - .tooltip = "Enables the console window, allowing you to input commands, type help for some examples" - }); + UIWidgets::WindowButton( + "Console", "gWindows.Console", mConsoleWindow, + { .tooltip = + "Enables the console window, allowing you to input commands, type help for some examples" }); } if (mGfxDebuggerWindow) { - UIWidgets::WindowButton("Gfx Debugger", "gWindows.GfxDebugger", mGfxDebuggerWindow, { - .tooltip = "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples" - }); + UIWidgets::WindowButton( + "Gfx Debugger", "gWindows.GfxDebugger", mGfxDebuggerWindow, + { .tooltip = + "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples" }); } if (mSaveEditorWindow) { - UIWidgets::WindowButton("Save Editor", "gWindows.SaveEditor", mSaveEditorWindow, { - .tooltip = "Enables the Save Editor window, allowing you to edit your save file" - }); + UIWidgets::WindowButton( + "Save Editor", "gWindows.SaveEditor", mSaveEditorWindow, + { .tooltip = "Enables the Save Editor window, allowing you to edit your save file" }); } if (mActorViewerWindow) { - UIWidgets::WindowButton("Actor Viewer", "gWindows.ActorViewer", mActorViewerWindow, { - .tooltip = "Enables the Actor Viewer window, allowing you to view actors in the world." - }); + UIWidgets::WindowButton( + "Actor Viewer", "gWindows.ActorViewer", mActorViewerWindow, + { .tooltip = "Enables the Actor Viewer window, allowing you to view actors in the world." }); } if (mEventLogWindow) { UIWidgets::WindowButton("Event Log", "gWindows.EventLog", mEventLogWindow); @@ -660,5 +675,5 @@ void BenMenuBar::DrawElement() { ImGui::EndMenuBar(); } } -} +} // namespace BenGui // namespace BenGui diff --git a/mm/2s2h/BenGui/BenMenuBar.h b/mm/2s2h/BenGui/BenMenuBar.h index 02fbcd723..53c21b0a4 100644 --- a/mm/2s2h/BenGui/BenMenuBar.h +++ b/mm/2s2h/BenGui/BenMenuBar.h @@ -12,10 +12,11 @@ namespace BenGui { class BenMenuBar : public Ship::GuiMenuBar { public: using Ship::GuiMenuBar::GuiMenuBar; + protected: void DrawElement() override; - void InitElement() override {}; - void UpdateElement() override {}; + void InitElement() override{}; + void UpdateElement() override{}; }; } // namespace BenGui diff --git a/mm/2s2h/BenGui/HudEditor.cpp b/mm/2s2h/BenGui/HudEditor.cpp index fc4541f0e..150c1c692 100644 --- a/mm/2s2h/BenGui/HudEditor.cpp +++ b/mm/2s2h/BenGui/HudEditor.cpp @@ -8,24 +8,25 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v); HudEditorElementID hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; HudEditorElement hudEditorElements[HUD_EDITOR_ELEMENT_MAX] = { - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_B, "B Button", "B", 167, 17, 100, 255, 120, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_LEFT, "C-Left Button", "CLeft", 227, 18, 255, 240, 0, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_DOWN, "C-Down Button", "CDown", 249, 34, 255, 240, 0, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_RIGHT, "C-Right Button", "CRight", 271, 18, 255, 240, 0, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_A, "A Button", "A", 191, 18, 100, 200, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_UP, "C-Up Button", "CUp", 254, 16, 255, 240, 0, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_D_PAD, "D-Pad", "DPad", 271, 55, 255, 255, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIMAP, "Minimap", "Minimap", 295, 220, 0, 255, 255, 160), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_START, "Start Button", "Start", 136, 17, 255, 130, 60, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_CLOCK, "Three Day Clock", "Clock", 160, 206, 255, 255, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_HEARTS, "Hearts", "Hearts", 30, 26, 255, 70, 50, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MAGIC_METER, "Magic", "Magic", 18, 34, 0, 200, 0, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS, "Timers", "Timers", 26, 46, 255, 255, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH, "Timer - Skull Kid", "SkullKidTimer", 115, 200, 255, 255, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIGAME_COUNTER, "Minigames", "Minigames", 20, 67, 255, 255, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_RUPEE_COUNTER, "Rupees", "Rupees", 26, 206, 200, 255, 100, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_KEY_COUNTER, "Keys", "Keys", 26, 190, 255, 255, 255, 255), - HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER, "Skulltulas", "Skulltulas", 26, 190, 255, 255, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_B, "B Button", "B", 167, 17, 100, 255, 120, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_LEFT, "C-Left Button", "CLeft", 227, 18, 255, 240, 0, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_DOWN, "C-Down Button", "CDown", 249, 34, 255, 240, 0, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_RIGHT, "C-Right Button", "CRight", 271, 18, 255, 240, 0, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_A, "A Button", "A", 191, 18, 100, 200, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_C_UP, "C-Up Button", "CUp", 254, 16, 255, 240, 0, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_D_PAD, "D-Pad", "DPad", 271, 55, 255, 255, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIMAP, "Minimap", "Minimap", 295, 220, 0, 255, 255, 160), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_START, "Start Button", "Start", 136, 17, 255, 130, 60, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_CLOCK, "Three Day Clock", "Clock", 160, 206, 255, 255, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_HEARTS, "Hearts", "Hearts", 30, 26, 255, 70, 50, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MAGIC_METER, "Magic", "Magic", 18, 34, 0, 200, 0, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS, "Timers", "Timers", 26, 46, 255, 255, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH, "Timer - Skull Kid", "SkullKidTimer", 115, 200, 255, 255, + 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_MINIGAME_COUNTER, "Minigames", "Minigames", 20, 67, 255, 255, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_RUPEE_COUNTER, "Rupees", "Rupees", 26, 206, 200, 255, 100, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_KEY_COUNTER, "Keys", "Keys", 26, 190, 255, 255, 255, 255), + HUD_EDITOR_ELEMENT(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER, "Skulltulas", "Skulltulas", 26, 190, 255, 255, 255, 255), }; extern "C" bool HudEditor_ShouldOverrideDraw() { @@ -140,11 +141,7 @@ extern "C" void HudEditor_ModifyDrawValues(s16* rectLeft, s16* rectTop, s16* rec } const char* modeNames[] = { - "Vanilla (4:3)", - "Hidden", - "Movable (Align Center)", - "Movable (Align Left)", - "Movable (Align Right)", + "Vanilla (4:3)", "Hidden", "Movable (Align Center)", "Movable (Align Left)", "Movable (Align Right)", }; const char* presetNames[] = { @@ -162,7 +159,7 @@ enum Presets { }; void HudEditorWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(480,600), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(480, 600), ImGuiCond_FirstUseEver); if (!ImGui::Begin("Hud Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { ImGui::End(); return; @@ -187,23 +184,39 @@ void HudEditorWindow::DrawElement() { } case HudEditor::Presets::WIDESCREEN: { CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_B].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_LEFT].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_DOWN].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_RIGHT].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_LEFT].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_DOWN].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_RIGHT].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_A].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_UP].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_D_PAD].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIMAP].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_START].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_CLOCK].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_43); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_HEARTS].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MAGIC_METER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_43); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIGAME_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_RUPEE_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_KEY_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); - CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER].modeCvar, HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_C_UP].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_D_PAD].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIMAP].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_START].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_RIGHT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_CLOCK].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_43); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_HEARTS].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MAGIC_METER].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_TIMERS_MOON_CRASH].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_43); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_MINIGAME_COUNTER].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_RUPEE_COUNTER].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_KEY_COUNTER].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); + CVarSetInteger(hudEditorElements[HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER].modeCvar, + HUD_EDITOR_ELEMENT_MODE_MOVABLE_LEFT); break; } } @@ -213,39 +226,44 @@ void HudEditorWindow::DrawElement() { for (int i = HUD_EDITOR_ELEMENT_B; i < HUD_EDITOR_ELEMENT_MAX; i++) { ImGui::PushID(hudEditorElements[i].name); ImGui::SeparatorText(hudEditorElements[i].name); - float color[3] = { (float)hudEditorElements[i].defaultR / 255, (float)hudEditorElements[i].defaultG / 255, (float)hudEditorElements[i].defaultB / 255 }; - // BENTODO: This color picker currently doesn't do anything other than serve as a visual indicator. Eventually it will be used to set the color of the element. + float color[3] = { (float)hudEditorElements[i].defaultR / 255, (float)hudEditorElements[i].defaultG / 255, + (float)hudEditorElements[i].defaultB / 255 }; + // BENTODO: This color picker currently doesn't do anything other than serve as a visual indicator. Eventually + // it will be used to set the color of the element. ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::ColorEdit3("Color", color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel); ImGui::PopItemFlag(); ImGui::SameLine(); - if (UIWidgets::CVarCombobox("Mode", hudEditorElements[i].modeCvar, modeNames, { - .labelPosition = UIWidgets::LabelPosition::None - })) { + if (UIWidgets::CVarCombobox("Mode", hudEditorElements[i].modeCvar, modeNames, + { .labelPosition = UIWidgets::LabelPosition::None })) { CVarClear(hudEditorElements[i].xCvar); CVarClear(hudEditorElements[i].yCvar); CVarClear(hudEditorElements[i].scaleCvar); } - if (CVarGetInteger(hudEditorElements[i].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) >= HUD_EDITOR_ELEMENT_MODE_MOVABLE_43) { + if (CVarGetInteger(hudEditorElements[i].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) >= + HUD_EDITOR_ELEMENT_MODE_MOVABLE_43) { if (ImGui::BeginTable("##table", 3, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_NoBordersInBody)) { ImGui::TableNextColumn(); - UIWidgets::CVarSliderInt("X", hudEditorElements[i].xCvar, -10, 330, hudEditorElements[i].defaultX, { - .showButtons = false, - .format = "X: %d", - .labelPosition = UIWidgets::LabelPosition::None, - }); + UIWidgets::CVarSliderInt("X", hudEditorElements[i].xCvar, -10, 330, hudEditorElements[i].defaultX, + { + .showButtons = false, + .format = "X: %d", + .labelPosition = UIWidgets::LabelPosition::None, + }); ImGui::TableNextColumn(); - UIWidgets::CVarSliderInt("Y", hudEditorElements[i].yCvar, -10, 250, hudEditorElements[i].defaultY, { - .showButtons = false, - .format = "Y: %d", - .labelPosition = UIWidgets::LabelPosition::None, - }); + UIWidgets::CVarSliderInt("Y", hudEditorElements[i].yCvar, -10, 250, hudEditorElements[i].defaultY, + { + .showButtons = false, + .format = "Y: %d", + .labelPosition = UIWidgets::LabelPosition::None, + }); ImGui::TableNextColumn(); - UIWidgets::CVarSliderFloat("Scale", hudEditorElements[i].scaleCvar, 0.25f, 4.0f, 1.0f, { - .showButtons = false, - .format = "Scale: %.2f", - .labelPosition = UIWidgets::LabelPosition::None, - }); + UIWidgets::CVarSliderFloat("Scale", hudEditorElements[i].scaleCvar, 0.25f, 4.0f, 1.0f, + { + .showButtons = false, + .format = "Scale: %.2f", + .labelPosition = UIWidgets::LabelPosition::None, + }); ImGui::EndTable(); } } diff --git a/mm/2s2h/BenGui/HudEditor.h b/mm/2s2h/BenGui/HudEditor.h index 3d94217da..a022c95ff 100644 --- a/mm/2s2h/BenGui/HudEditor.h +++ b/mm/2s2h/BenGui/HudEditor.h @@ -8,12 +8,12 @@ #include class HudEditorWindow : public Ship::GuiWindow { - public: - using GuiWindow::GuiWindow; + public: + using GuiWindow::GuiWindow; - void InitElement() override {}; - void DrawElement() override; - void UpdateElement() override {}; + void InitElement() override{}; + void DrawElement() override; + void UpdateElement() override{}; }; extern "C" { @@ -62,7 +62,8 @@ void HudEditor_ModifyRectSizeValues(s16* rectWidth, s16* rectHeight); void HudEditor_ModifyTextureStepValues(s16* dsdx, s16* dtdy); void HudEditor_ModifyMatrixValues(f32* transX, f32* transY); void HudEditor_ModifyKaleidoEquipAnimValues(s16* ulx, s16* uly, s16* shrinkRate); -void HudEditor_ModifyDrawValuesFromBase(s16 baseX, s16 baseY, s16* rectLeft, s16* rectTop, s16* rectWidth, s16* rectHeight, s16* dsdx, s16* dtdy); +void HudEditor_ModifyDrawValuesFromBase(s16 baseX, s16 baseY, s16* rectLeft, s16* rectTop, s16* rectWidth, + s16* rectHeight, s16* dsdx, s16* dtdy); void HudEditor_ModifyDrawValues(s16* rectLeft, s16* rectTop, s16* rectWidth, s16* rectHeight, s16* dsdx, s16* dtdy); typedef struct { @@ -81,13 +82,11 @@ typedef struct { const char* modeCvar; } HudEditorElement; -#define HUD_EDITOR_ELEMENT(id, name, cvar, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA) \ - { \ - id, name, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA, \ - "gHudEditor." cvar ".Position.X", "gHudEditor." cvar ".Position.Y", \ - "gHudEditor." cvar ".Scale", \ - "gHudEditor." cvar ".Color.Value", \ - "gHudEditor." cvar ".Mode" \ +#define HUD_EDITOR_ELEMENT(id, name, cvar, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA) \ + { \ + id, name, defaultX, defaultY, defaultR, defaultG, defaultB, defaultA, "gHudEditor." cvar ".Position.X", \ + "gHudEditor." cvar ".Position.Y", "gHudEditor." cvar ".Scale", "gHudEditor." cvar ".Color.Value", \ + "gHudEditor." cvar ".Mode" \ } extern HudEditorElementID hudEditorActiveElement; diff --git a/mm/2s2h/BenGui/UIWidgets.cpp b/mm/2s2h/BenGui/UIWidgets.cpp index 0e942924b..e7f5eb62e 100644 --- a/mm/2s2h/BenGui/UIWidgets.cpp +++ b/mm/2s2h/BenGui/UIWidgets.cpp @@ -7,477 +7,493 @@ #include namespace UIWidgets { - // Automatically adds newlines to break up text longer than a specified number of characters - // Manually included newlines will still be respected and reset the line length - // If line is midword when it hits the limit, text should break at the last encountered space - char* WrappedText(const char* text, unsigned int charactersPerLine) { - std::string newText(text); - const size_t tipLength = newText.length(); - int lastSpace = -1; - int currentLineLength = 0; - for (unsigned int currentCharacter = 0; currentCharacter < tipLength; currentCharacter++) { - if (newText[currentCharacter] == '\n') { - currentLineLength = 0; - lastSpace = -1; - continue; - } else if (newText[currentCharacter] == ' ') { - lastSpace = currentCharacter; - } - - if ((currentLineLength >= charactersPerLine) && (lastSpace >= 0)) { - newText[lastSpace] = '\n'; - currentLineLength = currentCharacter - lastSpace - 1; - lastSpace = -1; - } - currentLineLength++; +// Automatically adds newlines to break up text longer than a specified number of characters +// Manually included newlines will still be respected and reset the line length +// If line is midword when it hits the limit, text should break at the last encountered space +char* WrappedText(const char* text, unsigned int charactersPerLine) { + std::string newText(text); + const size_t tipLength = newText.length(); + int lastSpace = -1; + int currentLineLength = 0; + for (unsigned int currentCharacter = 0; currentCharacter < tipLength; currentCharacter++) { + if (newText[currentCharacter] == '\n') { + currentLineLength = 0; + lastSpace = -1; + continue; + } else if (newText[currentCharacter] == ' ') { + lastSpace = currentCharacter; } - return strdup(newText.c_str()); + if ((currentLineLength >= charactersPerLine) && (lastSpace >= 0)) { + newText[lastSpace] = '\n'; + currentLineLength = currentCharacter - lastSpace - 1; + lastSpace = -1; + } + currentLineLength++; } - char* WrappedText(const std::string& text, unsigned int charactersPerLine) { - return WrappedText(text.c_str(), charactersPerLine); - } + return strdup(newText.c_str()); +} - void Tooltip(const char* text) { - if (ImGui::IsItemHovered()) { - ImGui::SetTooltip("%s", WrappedText(text)); - } - } +char* WrappedText(const std::string& text, unsigned int charactersPerLine) { + return WrappedText(text.c_str(), charactersPerLine); +} - void PushStyleMenu(const ImVec4& color) { - ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_PopupBg, UIWidgets::Colors::DarkGray); - ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::DarkGray); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 15.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 3.0f); +void Tooltip(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("%s", WrappedText(text)); } +} - void PopStyleMenu() { - ImGui::PopStyleVar(2); - ImGui::PopStyleColor(4); - } +void PushStyleMenu(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_PopupBg, UIWidgets::Colors::DarkGray); + ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::DarkGray); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 15.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 3.0f); +} - bool BeginMenu(const char* label, const ImVec4& color) { - bool dirty = false; - PushStyleMenu(color); - ImGui::SetNextWindowSizeConstraints(ImVec2(200.0f, 0.0f), ImVec2(FLT_MAX, FLT_MAX)); - if (ImGui::BeginMenu(label)) { - dirty = true; - } - PopStyleMenu(); - return dirty; - } +void PopStyleMenu() { + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(4); +} - void PushStyleMenuItem(const ImVec4& color) { - ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20.0f, 15.0f)); +bool BeginMenu(const char* label, const ImVec4& color) { + bool dirty = false; + PushStyleMenu(color); + ImGui::SetNextWindowSizeConstraints(ImVec2(200.0f, 0.0f), ImVec2(FLT_MAX, FLT_MAX)); + if (ImGui::BeginMenu(label)) { + dirty = true; } + PopStyleMenu(); + return dirty; +} - void PopStyleMenuItem() { - ImGui::PopStyleVar(1); - ImGui::PopStyleColor(1); - } +void PushStyleMenuItem(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20.0f, 15.0f)); +} - bool MenuItem(const char* label, const char* shortcut, const ImVec4& color) { - bool dirty = false; - PushStyleMenuItem(color); - if (ImGui::MenuItem(label, shortcut)) { - dirty = true; - } - PopStyleMenuItem(); - return dirty; - } +void PopStyleMenuItem() { + ImGui::PopStyleVar(1); + ImGui::PopStyleColor(1); +} - void PushStyleButton(const ImVec4& color) { - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); +bool MenuItem(const char* label, const char* shortcut, const ImVec4& color) { + bool dirty = false; + PushStyleMenuItem(color); + if (ImGui::MenuItem(label, shortcut)) { + dirty = true; } + PopStyleMenuItem(); + return dirty; +} - void PopStyleButton() { - ImGui::PopStyleVar(3); - ImGui::PopStyleColor(4); - } +void PushStyleButton(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); +} - bool Button(const char* label, const ButtonOptions& options) { - ImGui::BeginDisabled(options.disabled); - PushStyleButton(options.color); - bool dirty = ImGui::Button(label, options.size); - PopStyleButton(); - ImGui::EndDisabled(); - if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); - } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.tooltip)); - } - return dirty; - } +void PopStyleButton() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(4); +} - bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options) { - ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); - std::string buttonText = label; - bool dirty = false; - if (CVarGetInteger(cvarName, 0)) { - buttonText = ICON_FA_WINDOW_CLOSE " " + buttonText; - } else { - buttonText = ICON_FA_EXTERNAL_LINK_SQUARE " " + buttonText; - } - if (Button(buttonText.c_str(), options)) { - windowPtr->ToggleVisibility(); - dirty = true; - } - ImGui::PopStyleVar(); - return dirty; +bool Button(const char* label, const ButtonOptions& options) { + ImGui::BeginDisabled(options.disabled); + PushStyleButton(options.color); + bool dirty = ImGui::Button(label, options.size); + PopStyleButton(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && + strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); } + return dirty; +} - void PushStyleCheckbox(const ImVec4& color) { - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.8f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); - ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(1.0f, 1.0f, 1.0f, 0.7f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); +bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, + const ButtonOptions& options) { + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + std::string buttonText = label; + bool dirty = false; + if (CVarGetInteger(cvarName, 0)) { + buttonText = ICON_FA_WINDOW_CLOSE " " + buttonText; + } else { + buttonText = ICON_FA_EXTERNAL_LINK_SQUARE " " + buttonText; } - - void PopStyleCheckbox() { - ImGui::PopStyleVar(3); - ImGui::PopStyleColor(5); + if (Button(buttonText.c_str(), options)) { + windowPtr->ToggleVisibility(); + dirty = true; } + ImGui::PopStyleVar(); + return dirty; +} - bool Checkbox(const char* label, bool* value, const CheckboxOptions& options) { - ImGui::PushID(label); - bool dirty = false; - float startX = ImGui::GetCursorPosX(); - std::string invisibleLabelStr = "##" + std::string(label); - const char* invisibleLabel = invisibleLabelStr.c_str(); - ImGui::BeginDisabled(options.disabled); - PushStyleCheckbox(options.color); - if (options.alignment == ComponentAlignment::Right) { - if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); - } else if (options.labelPosition == LabelPosition::Above) { - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); - ImGui::Text("%s", label); - ImGui::NewLine(); - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); - } - } else if (options.alignment == ComponentAlignment::Left) { - if (options.labelPosition == LabelPosition::Above) { - ImGui::Text("%s", label); - } - } - dirty = ImGui::Checkbox(invisibleLabel, value); - if (options.alignment == ComponentAlignment::Right) { - if (options.labelPosition == LabelPosition::Near) { - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x * 2); - ImGui::Text("%s", label); - } else if (options.labelPosition == LabelPosition::Far) { - ImGui::SameLine(); - ImGui::SetCursorPosX(startX); - ImGui::Text("%s", label); - } - } else if (options.alignment == ComponentAlignment::Left) { - if (options.labelPosition == LabelPosition::Near) { - ImGui::SameLine(); - ImGui::Text("%s", label); - } else if (options.labelPosition == LabelPosition::Far) { - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); - ImGui::Text("%s", label); - } +void PushStyleCheckbox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(1.0f, 1.0f, 1.0f, 0.7f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); +} + +void PopStyleCheckbox() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(5); +} + +bool Checkbox(const char* label, bool* value, const CheckboxOptions& options) { + ImGui::PushID(label); + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::BeginDisabled(options.disabled); + PushStyleCheckbox(options.color); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far || + options.labelPosition == LabelPosition::None) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - + ImGui::GetStyle().ItemSpacing.x); + } else if (options.labelPosition == LabelPosition::Above) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text("%s", label); + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - + ImGui::GetStyle().ItemSpacing.x); } - PopStyleCheckbox(); - ImGui::EndDisabled(); - if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); - } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text("%s", label); } - ImGui::PopID(); - return dirty; } - - bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options) { - bool dirty = false; - bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); - if (Checkbox(label, &value, options)) { - CVarSetInteger(cvarName, value); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - dirty = true; + dirty = ImGui::Checkbox(invisibleLabel, value); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - + ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::Text("%s", label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(); + ImGui::SetCursorPosX(startX); + ImGui::Text("%s", label); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text("%s", label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text("%s", label); } - return dirty; } - - void PushStyleCombobox(const ImVec4& color) { - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 0.8f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(color.x, color.y, color.z, 0.6f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + PopStyleCheckbox(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && + strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); } + ImGui::PopID(); + return dirty; +} - void PopStyleCombobox() { - ImGui::PopStyleVar(4); - ImGui::PopStyleColor(9); +bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options) { + bool dirty = false; + bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); + if (Checkbox(label, &value, options)) { + CVarSetInteger(cvarName, value); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; } + return dirty; +} - void PushStyleSlider(const ImVec4& color) { - ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(color.x, color.y, color.z, 1.0f)); - ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(1.0, 1.0, 1.0, 0.4f)); - ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(1.0, 1.0, 1.0, 0.5f)); - ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); - } +void PushStyleCombobox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); +} - void PopStyleSlider() { - ImGui::PopStyleVar(4); - ImGui::PopStyleColor(6); - } +void PopStyleCombobox() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(9); +} - bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options) { - bool dirty = false; - std::string invisibleLabelStr = "##" + std::string(label); - const char* invisibleLabel = invisibleLabelStr.c_str(); - ImGui::PushID(label); - ImGui::BeginGroup(); - ImGui::BeginDisabled(options.disabled); - PushStyleSlider(options.color); - if (options.alignment == ComponentAlignment::Left) { - if (options.labelPosition == LabelPosition::Above) { - ImGui::Text(label, *value); - } - } else if (options.alignment == ComponentAlignment::Right) { - if (options.labelPosition == LabelPosition::Above) { - ImGui::NewLine(); - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); - ImGui::Text(label, *value); - } +void PushStyleSlider(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(1.0, 1.0, 1.0, 0.4f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(1.0, 1.0, 1.0, 0.5f)); + ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); +} + +void PopStyleSlider() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(6); +} + +bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, *value); } - if (options.showButtons) { - if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { - *value -= options.step; - if (*value < min) *value = min; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - dirty = true; - } - ImGui::SameLine(0, 3.0f); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); - } else { - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, *value); } - if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) + *value = min; Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } - if (options.showButtons) { - ImGui::SameLine(0, 3.0f); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { - *value += options.step; - if (*value > max) *value = max; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - dirty = true; - } - } - PopStyleSlider(); - ImGui::EndDisabled(); - ImGui::EndGroup(); - if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); - } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.tooltip)); - } - ImGui::PopID(); - return dirty; + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); } - - bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options) { - bool dirty = false; - int32_t value = CVarGetInteger(cvarName, defaultValue); - if (SliderInt(label, &value, min, max, options)) { - CVarSetInteger(cvarName, value); + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) + *value = max; Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } - return dirty; } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && + strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; +} - bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options) { - bool dirty = false; - std::string invisibleLabelStr = "##" + std::string(label); - const char* invisibleLabel = invisibleLabelStr.c_str(); - float valueToDisplay = options.isPercentage ? *value * 100.0f : *value; - float maxToDisplay = options.isPercentage ? max * 100.0f : max; - float minToDisplay = options.isPercentage ? min * 100.0f : min; - ImGui::PushID(label); - ImGui::BeginGroup(); - ImGui::BeginDisabled(options.disabled); - PushStyleSlider(options.color); - if (options.alignment == ComponentAlignment::Left) { - if (options.labelPosition == LabelPosition::Above) { - ImGui::Text(label, valueToDisplay); - } - } else if (options.alignment == ComponentAlignment::Right) { - if (options.labelPosition == LabelPosition::Above) { - ImGui::NewLine(); - ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); - ImGui::Text(label, valueToDisplay); - } +bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, + const IntSliderOptions& options) { + bool dirty = false; + int32_t value = CVarGetInteger(cvarName, defaultValue); + if (SliderInt(label, &value, min, max, options)) { + CVarSetInteger(cvarName, value); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; +} + +bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + float valueToDisplay = options.isPercentage ? *value * 100.0f : *value; + float maxToDisplay = options.isPercentage ? max * 100.0f : max; + float minToDisplay = options.isPercentage ? min * 100.0f : min; + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, valueToDisplay); } - if (options.showButtons) { - if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { - *value -= options.step; - if (*value < min) *value = min; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - dirty = true; - } - ImGui::SameLine(0, 3.0f); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); - } else { - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, valueToDisplay); } - if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) { - *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) + *value = min; Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } - if (options.showButtons) { - ImGui::SameLine(0, 3.0f); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { - *value += options.step; - if (*value > max) *value = max; - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - dirty = true; - } - } - PopStyleSlider(); - ImGui::EndDisabled(); - ImGui::EndGroup(); - if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); - } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { - ImGui::SetTooltip("%s", WrappedText(options.tooltip)); - } - ImGui::PopID(); - return dirty; + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); } - - bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options) { - bool dirty = false; - float value = CVarGetFloat(cvarName, defaultValue); - if (SliderFloat(label, &value, min, max, options)) { - CVarSetFloat(cvarName, value); + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, + options.format, options.flags)) { + *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) + *value = max; Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } - return dirty; } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && + strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; +} - bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaultColor) { - Color_RGBA8 color = CVarGetColor(cvarName, defaultColor); - ImVec4 colorVec = ImVec4(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f); - bool changed = false; - PushStyleCombobox(Colors::Gray); - if (ImGui::ColorEdit3(label, (float*)&colorVec, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoBorder)) { - color.r = (uint8_t)(colorVec.x * 255.0f); - color.g = (uint8_t)(colorVec.y * 255.0f); - color.b = (uint8_t)(colorVec.z * 255.0f); - color.a = (uint8_t)(colorVec.w * 255.0f); - CVarSetColor(cvarName, color); - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - changed = true; - } - PopStyleCombobox(); - return changed; +bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, + const FloatSliderOptions& options) { + bool dirty = false; + float value = CVarGetFloat(cvarName, defaultValue); + if (SliderFloat(label, &value, min, max, options)) { + CVarSetFloat(cvarName, value); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; } + return dirty; +} - void DrawFlagArray32(const std::string& name, uint32_t& flags) { - ImGui::PushID(name.c_str()); - for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) { - if ((flagIndex % 8) != 0) { - ImGui::SameLine(); - } - ImGui::PushID(flagIndex); - uint32_t bitMask = 1 << flagIndex; - bool flag = (flags & bitMask) != 0; - std::string label = std::to_string(flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, {.tooltip = label.c_str(), - .labelPosition = LabelPosition::None })) { - if (flag) { - flags |= bitMask; - } else { - flags &= ~bitMask; - } +bool CVarColorPicker(const char* label, const char* cvarName, Color_RGBA8 defaultColor) { + Color_RGBA8 color = CVarGetColor(cvarName, defaultColor); + ImVec4 colorVec = ImVec4(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f); + bool changed = false; + PushStyleCombobox(Colors::Gray); + if (ImGui::ColorEdit3(label, (float*)&colorVec, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoBorder)) { + color.r = (uint8_t)(colorVec.x * 255.0f); + color.g = (uint8_t)(colorVec.y * 255.0f); + color.b = (uint8_t)(colorVec.z * 255.0f); + color.a = (uint8_t)(colorVec.w * 255.0f); + CVarSetColor(cvarName, color); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + PopStyleCombobox(); + return changed; +} + +void DrawFlagArray32(const std::string& name, uint32_t& flags) { + ImGui::PushID(name.c_str()); + for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint32_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + std::string label = std::to_string(flagIndex); + if (UIWidgets::Checkbox(label.c_str(), &flag, + { .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; } - ImGui::PopID(); } ImGui::PopID(); } + ImGui::PopID(); +} - void DrawFlagArray16(const std::string& name, uint16_t& flags) { - ImGui::PushID(name.c_str()); - for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) { - if ((flagIndex % 8) != 0) { - ImGui::SameLine(); - } - ImGui::PushID(flagIndex); - uint16_t bitMask = 1 << flagIndex; - bool flag = (flags & bitMask) != 0; - std::string label = std::to_string(flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, {.tooltip = label.c_str(), - .labelPosition = LabelPosition::None })) { - if (flag) { - flags |= bitMask; - } else { - flags &= ~bitMask; - } +void DrawFlagArray16(const std::string& name, uint16_t& flags) { + ImGui::PushID(name.c_str()); + for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint16_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + std::string label = std::to_string(flagIndex); + if (UIWidgets::Checkbox(label.c_str(), &flag, + { .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; } - ImGui::PopID(); } ImGui::PopID(); } + ImGui::PopID(); +} - void DrawFlagArray8(const std::string& name, uint8_t& flags) { - ImGui::PushID(name.c_str()); - for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) { - if ((flagIndex % 8) != 0) { - ImGui::SameLine(); - } - ImGui::PushID(flagIndex); - uint8_t bitMask = 1 << flagIndex; - bool flag = (flags & bitMask) != 0; - std::string label = std::to_string(flagIndex); - if (UIWidgets::Checkbox(label.c_str(), &flag, {.tooltip = label.c_str(), - .labelPosition = LabelPosition::None })) { - if (flag) { - flags |= bitMask; - } else { - flags &= ~bitMask; - } +void DrawFlagArray8(const std::string& name, uint8_t& flags) { + ImGui::PushID(name.c_str()); + for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint8_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + std::string label = std::to_string(flagIndex); + if (UIWidgets::Checkbox(label.c_str(), &flag, + { .tooltip = label.c_str(), .labelPosition = LabelPosition::None })) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; } - ImGui::PopID(); } ImGui::PopID(); } + ImGui::PopID(); } +} // namespace UIWidgets diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index 9cb170a11..928f30bd3 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -106,7 +106,6 @@ Color_RGB8 kokiriColor = { 0x1E, 0x69, 0x1B }; Color_RGB8 goronColor = { 0x64, 0x14, 0x00 }; Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 }; - OTRGlobals::OTRGlobals() { std::vector archiveFiles; std::string mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName); @@ -141,13 +140,15 @@ OTRGlobals::OTRGlobals() { OOT_PAL_11, OOT_NTSC_JP_GC_CE, OOT_NTSC_JP_GC, OOT_NTSC_US_GC, OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2 }; // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) - context = Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3); + context = + Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3); // Override LUS defaults - Ship::Context::GetInstance()->GetLogger()->set_level((spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); + Ship::Context::GetInstance()->GetLogger()->set_level( + (spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); - //context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json"); + // context = Ship::Context::CreateUninitializedInstance("Ship of Harkinian", appShortName, "shipofharkinian.json"); auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f); @@ -180,9 +181,9 @@ OTRGlobals::OTRGlobals() { static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); - loader - ->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, - "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); + loader->RegisterResourceFactory(std::make_shared(), + RESOURCE_FORMAT_BINARY, "CollisionHeader", + static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Skeleton", static_cast(SOH::ResourceType::SOH_Skeleton), 0); loader->RegisterResourceFactory(std::make_shared(), @@ -200,7 +201,8 @@ OTRGlobals::OTRGlobals() { RESOURCE_FORMAT_BINARY, "AudioSoundFont", static_cast(SOH::ResourceType::SOH_AudioSoundFont), 2); loader->RegisterResourceFactory(std::make_shared(), - RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast(SOH::ResourceType::SOH_AudioSequence), 2); + RESOURCE_FORMAT_BINARY, "AudioSequence", + static_cast(SOH::ResourceType::SOH_AudioSequence), 2); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Background", static_cast(SOH::ResourceType::SOH_Background), 0); loader->RegisterResourceFactory(std::make_shared(), @@ -212,23 +214,23 @@ OTRGlobals::OTRGlobals() { "KeyFrameSkel", static_cast(SOH::ResourceType::TSH_CKeyFrameSkel), 0); context->GetControlDeck()->SetSinglePlayerMappingMode(true); - //gSaveStateMgr = std::make_shared(); - //gRandomizer = std::make_shared(); + // gSaveStateMgr = std::make_shared(); + // gRandomizer = std::make_shared(); hasMasterQuest = hasOriginal = false; // Move the camera strings from read only memory onto the heap (writable memory) // This is in OTRGlobals right now because this is a place that will only ever be run once at the beginning of // startup. We should probably find some code in db_camera that does initialization and only run once, and then // dealloc on deinitialization. - //cameraStrings = (char**)malloc(sizeof(constCameraStrings)); - //for (int32_t i = 0; i < sizeof(constCameraStrings) / sizeof(char*); i++) { + // cameraStrings = (char**)malloc(sizeof(constCameraStrings)); + // for (int32_t i = 0; i < sizeof(constCameraStrings) / sizeof(char*); i++) { // // OTRTODO: never deallocated... // auto dup = strdup(constCameraStrings[i]); // cameraStrings[i] = dup; //} auto versions = context->GetResourceManager()->GetArchiveManager()->GetGameVersions(); - #if 0 +#if 0 for (uint32_t version : versions) { if (!ValidHashes.contains(version)) { #if defined(__SWITCH__) @@ -266,7 +268,7 @@ OTRGlobals::OTRGlobals() { break; } } - #endif +#endif } OTRGlobals::~OTRGlobals() { @@ -317,7 +319,6 @@ static struct { bool processing; } audio; - void OTRAudio_Thread() { while (audio.running) { { @@ -331,21 +332,21 @@ void OTRAudio_Thread() { } } std::unique_lock Lock(audio.mutex); - //AudioMgr_ThreadEntry(&gAudioMgr); - // 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333.. - // in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528 - //#define SAMPLES_HIGH 560 - //#define SAMPLES_LOW 528 - // PAL values - //#define SAMPLES_HIGH 656 - //#define SAMPLES_LOW 624 - - // 44KHZ values - #define SAMPLES_HIGH 752 - #define SAMPLES_LOW 720 - - #define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 ) - #define NUM_AUDIO_CHANNELS 2 +// AudioMgr_ThreadEntry(&gAudioMgr); +// 528 and 544 relate to 60 fps at 32 kHz 32000/60 = 533.333.. +// in an ideal world, one third of the calls should use num_samples=544 and two thirds num_samples=528 +//#define SAMPLES_HIGH 560 +//#define SAMPLES_LOW 528 +// PAL values +//#define SAMPLES_HIGH 656 +//#define SAMPLES_LOW 624 + +// 44KHZ values +#define SAMPLES_HIGH 752 +#define SAMPLES_LOW 720 + +#define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1) +#define NUM_AUDIO_CHANNELS 2 int samples_left = AudioPlayer_Buffered(); u32 num_audio_samples = samples_left < AudioPlayer_GetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW; @@ -353,10 +354,12 @@ void OTRAudio_Thread() { // 3 is the maximum authentic frame divisor. s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3]; for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) { - AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples); + AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), + num_audio_samples); } - AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE)); + AudioPlayer_Play((u8*)audio_buffer, + num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE)); audio.processing = false; audio.cv_from_thread.notify_one(); @@ -364,8 +367,7 @@ void OTRAudio_Thread() { } // C->C++ Bridge -extern "C" void OTRAudio_Init() -{ +extern "C" void OTRAudio_Init() { // Precache all our samples, sequences, etc... ResourceMgr_LoadDirectory("audio"); @@ -439,9 +441,9 @@ extern "C" void InitOTR() { DebugConsole_Init(); clearMtx = (uintptr_t)&gMtxClear; - //OTRMessage_Init(); + // OTRMessage_Init(); OTRAudio_Init(); - //OTRExtScanner(); + // OTRExtScanner(); time_t now = time(NULL); tm* tm_now = localtime(&now); if (tm_now->tm_mon == 11 && tm_now->tm_mday >= 24 && tm_now->tm_mday <= 25) { @@ -462,11 +464,10 @@ extern "C" void InitOTR() { #endif std::shared_ptr conf = OTRGlobals::Instance->context->GetConfig(); - } extern "C" void SaveManager_ThreadPoolWait() { - //SaveManager::Instance->ThreadPoolWait(); + // SaveManager::Instance->ThreadPoolWait(); } extern "C" void DeinitOTR() { @@ -532,7 +533,7 @@ extern "C" void Graph_StartFrame() { OTRGlobals::Instance->context->GetWindow()->SetLastScancode(-1); switch (dwScancode) { - #if 0 +#if 0 case KbScancode::LUS_KB_F5: { if (CVarGetInteger("gSaveStatesEnabled", 0) == 0) { Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->TextDrawNotification( @@ -608,7 +609,7 @@ extern "C" void Graph_StartFrame() { case KbScancode::LUS_KB_TAB: { // Toggle HD Assets CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); - //ShouldClearTextureCacheAtEndOfFrame = true; + // ShouldClearTextureCacheAtEndOfFrame = true; break; } } @@ -681,13 +682,13 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { last_update_rate = R_UPDATE_RATE; { - std::unique_lock Lock(audio.mutex); - while (audio.processing) { - audio.cv_from_thread.wait(Lock); - } + std::unique_lock Lock(audio.mutex); + while (audio.processing) { + audio.cv_from_thread.wait(Lock); + } } // - //if (ShouldClearTextureCacheAtEndOfFrame) { + // if (ShouldClearTextureCacheAtEndOfFrame) { // gfx_texture_cache_clear(); // Ship::SkeletonPatcher::UpdateSkeletons(); // ShouldClearTextureCacheAtEndOfFrame = false; @@ -734,7 +735,8 @@ extern "C" uint32_t ResourceMgr_GetGameVersion(int index) { } extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { - uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + uint32_t version = + Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; switch (version) { case OOT_NTSC_US_10: @@ -759,7 +761,8 @@ extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { } extern "C" uint32_t ResourceMgr_GetGameRegion(int index) { - uint32_t version = Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; + uint32_t version = + Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[index]; switch (version) { case OOT_NTSC_US_10: @@ -905,9 +908,9 @@ extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) { return nullptr; } -//extern "C" Sprite* GetSeedTexture(uint8_t index) { -// return OTRGlobals::Instance->gRandomizer->GetSeedTexture(index); -//} +// extern "C" Sprite* GetSeedTexture(uint8_t index) { +// return OTRGlobals::Instance->gRandomizer->GetSeedTexture(index); +// } extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) { auto anim = std::static_pointer_cast(GetResourceByName(animPath)); @@ -1059,8 +1062,8 @@ extern "C" Vtx* ResourceMgr_LoadVtxByName(char* path) { } extern "C" SequenceData ResourceMgr_LoadSeqByName(const char* path) { - SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path); - return *sequence; + SequenceData* sequence = (SequenceData*)ResourceGetDataByName(path); + return *sequence; } extern "C" KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path) { return (KeyFrameSkeleton*)ResourceGetDataByName(path); @@ -1069,7 +1072,7 @@ extern "C" KeyFrameSkeleton* ResourceMgr_LoadKeyFrameSkelByName(const char* path extern "C" KeyFrameAnimation* ResourceMgr_LoadKeyFrameAnimByName(const char* path) { return (KeyFrameAnimation*)ResourceGetDataByName(path); } -//std::map cachedCustomSFs; +// std::map cachedCustomSFs; #if 0 extern "C" SoundFontSample* ReadCustomSample(const char* path) { return nullptr; @@ -1181,7 +1184,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel // Therefore we can take this oppurtunity to take note of the Skeleton that is created... if (skelAnime != nullptr) { auto stringPath = std::string(path); - //Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); + // Ship::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); } return skelHeader; @@ -1233,13 +1236,13 @@ void OTRGlobals::CheckSaveFile(size_t sramSize) const { saveFile.close(); } -//extern "C" void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size) { -// SaveManager::ReadSaveFile(GetSaveFile(), addr, dramAddr, size); -//} +// extern "C" void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size) { +// SaveManager::ReadSaveFile(GetSaveFile(), addr, dramAddr, size); +// } -//extern "C" void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size) { -// SaveManager::WriteSaveFile(GetSaveFile(), addr, dramAddr, size); -//} +// extern "C" void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size) { +// SaveManager::WriteSaveFile(GetSaveFile(), addr, dramAddr, size); +// } std::wstring StringToU16(const std::string& s) { std::vector result; @@ -1345,7 +1348,7 @@ extern "C" uint32_t OTRGetCurrentHeight() { } Color_RGB8 GetColorForControllerLED() { - #if 0 +#if 0 auto brightness = CVarGetFloat("gLedBrightness", 1.0f) / 1.0f; Color_RGB8 color = { 0, 0, 0 }; if (brightness > 0.0f) { @@ -1389,7 +1392,7 @@ Color_RGB8 GetColorForControllerLED() { color.g = color.g * brightness; color.b = color.b * brightness; } - #endif +#endif return { 0, 0, 0 }; } @@ -1403,12 +1406,12 @@ extern "C" void OTRControllerCallback(uint8_t rumble) { if (controllerConfigWindow == nullptr) { controllerConfigWindow = std::dynamic_pointer_cast( Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Input Editor")); - // TODO: Add SoH Controller Config window rumble testing to upstream LUS config window - // note: the current implementation may not be desired in LUS, as "true" rumble support - // using osMotor calls is planned: https://github.com/Kenix3/libultraship/issues/9 - // - // } else if (controllerConfigWindow->TestingRumble()) { - // return; + // TODO: Add SoH Controller Config window rumble testing to upstream LUS config window + // note: the current implementation may not be desired in LUS, as "true" rumble support + // using osMotor calls is planned: https://github.com/Kenix3/libultraship/issues/9 + // + // } else if (controllerConfigWindow->TestingRumble()) { + // return; } if (rumble) { diff --git a/mm/2s2h/BenPort.h b/mm/2s2h/BenPort.h index be6ddd671..6babb7c31 100644 --- a/mm/2s2h/BenPort.h +++ b/mm/2s2h/BenPort.h @@ -3,7 +3,6 @@ #pragma once - #define GAME_REGION_NTSC 0 #define GAME_REGION_PAL 1 diff --git a/mm/2s2h/DeveloperTools/ActorViewer.cpp b/mm/2s2h/DeveloperTools/ActorViewer.cpp index 86e1e7188..e87b920e5 100644 --- a/mm/2s2h/DeveloperTools/ActorViewer.cpp +++ b/mm/2s2h/DeveloperTools/ActorViewer.cpp @@ -16,28 +16,15 @@ typedef enum Method { HOLD, } Method; -std::array acMapping = { - "Switch", - "Background", - "Player", - "Explosive", - "NPC", - "Enemy", - "Prop", - "Item/Action", - "Misc.", - "Boss", - "Door", - "Chest" -}; - +std::array acMapping = { "Switch", "Background", "Player", "Explosive", "NPC", "Enemy", + "Prop", "Item/Action", "Misc.", "Boss", "Door", "Chest" }; -#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _humanName}, -#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _humanName}, -#define DEFINE_ACTOR_UNSET(_enumValue) {_enumValue, "Unset"}, +#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _humanName }, +#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _humanName }, +#define DEFINE_ACTOR_UNSET(_enumValue) { _enumValue, "Unset" }, std::unordered_map actorDescriptions = { -#include "tables/actor_table.h" +#include "tables/actor_table.h" }; #undef DEFINE_ACTOR @@ -49,7 +36,8 @@ std::string GetActorDescription(u16 actorNum) { } std::vector GetCurrentSceneActors() { - if (!gPlayState) return {}; + if (!gPlayState) + return {}; std::vector sceneActors; for (size_t category = ACTORCAT_SWITCH; category < ACTORCAT_MAX; category++) { @@ -62,7 +50,6 @@ std::vector GetCurrentSceneActors() { } } return sceneActors; - } static bool needs_reset = false; @@ -127,8 +114,10 @@ void ActorViewerWindow::DrawElement() { display = list[i]; newActorId = i; filler = label; - GameInteractor::Instance->UnregisterGameHookForPtr(preventActorDrawHookId); - GameInteractor::Instance->UnregisterGameHookForPtr(preventActorUpdateHookId); + GameInteractor::Instance->UnregisterGameHookForPtr( + preventActorDrawHookId); + GameInteractor::Instance->UnregisterGameHookForPtr( + preventActorUpdateHookId); preventActorDrawHookId = 0; preventActorUpdateHookId = 0; break; @@ -150,27 +139,29 @@ void ActorViewerWindow::DrawElement() { ImGui::BeginGroup(); if (preventActorDrawHookId) { if (ImGui::Button("Continue Drawing", ImVec2(ImGui::GetFontSize() * 10, 0))) { - GameInteractor::Instance->UnregisterGameHookForPtr(preventActorDrawHookId); + GameInteractor::Instance->UnregisterGameHookForPtr( + preventActorDrawHookId); preventActorDrawHookId = 0; } } else { if (ImGui::Button("Stop Drawing", ImVec2(ImGui::GetFontSize() * 10, 0))) { - preventActorDrawHookId = GameInteractor::Instance->RegisterGameHookForPtr((uintptr_t)display, [](Actor* _, bool* result) { - *result = false; - }); + preventActorDrawHookId = + GameInteractor::Instance->RegisterGameHookForPtr( + (uintptr_t)display, [](Actor* _, bool* result) { *result = false; }); } } ImGui::SameLine(); if (preventActorUpdateHookId) { if (ImGui::Button("Continue Updating", ImVec2(ImGui::GetFontSize() * 10, 0))) { - GameInteractor::Instance->UnregisterGameHookForPtr(preventActorUpdateHookId); + GameInteractor::Instance->UnregisterGameHookForPtr( + preventActorUpdateHookId); preventActorUpdateHookId = 0; } } else { if (ImGui::Button("Stop Updating", ImVec2(ImGui::GetFontSize() * 10, 0))) { - preventActorUpdateHookId = GameInteractor::Instance->RegisterGameHookForPtr((uintptr_t)display, [](Actor* _, bool* result) { - *result = false; - }); + preventActorUpdateHookId = + GameInteractor::Instance->RegisterGameHookForPtr( + (uintptr_t)display, [](Actor* _, bool* result) { *result = false; }); } } ImGui::EndGroup(); @@ -228,7 +219,7 @@ void ActorViewerWindow::DrawElement() { } } - if (UIWidgets::Button("Fetch: Target", {.tooltip = "Grabs actor with target arrow above it."})) { + if (UIWidgets::Button("Fetch: Target", { .tooltip = "Grabs actor with target arrow above it." })) { Player* player = GET_PLAYER(gPlayState); fetch = player->lockOnActor; if (fetch != nullptr) { @@ -240,7 +231,7 @@ void ActorViewerWindow::DrawElement() { display = {}; } } - if (UIWidgets::Button("Fetch: Held", {.tooltip = "Grabs actor Link is currently holding."})) { + if (UIWidgets::Button("Fetch: Held", { .tooltip = "Grabs actor Link is currently holding." })) { Player* player = GET_PLAYER(gPlayState); fetch = player->heldActor; if (fetch != nullptr) { @@ -253,13 +244,11 @@ void ActorViewerWindow::DrawElement() { } } - - if (UIWidgets::Button("Kill", {.color = UIWidgets::Colors::Red}) && display != nullptr && + if (UIWidgets::Button("Kill", { .color = UIWidgets::Colors::Red }) && display != nullptr && display->id != ACTOR_PLAYER) { Actor_Kill(display); } ImGui::TreePop(); - } if (ImGui::TreeNode("New...")) { @@ -288,7 +277,8 @@ void ActorViewerWindow::DrawElement() { ImGui::InputScalar("rZ", ImGuiDataType_S16, &newActor.rot.z); ImGui::EndGroup(); - UIWidgets::CVarCheckbox("Remove Obj Dep?", "gObjDep", { .tooltip = "Allows actors to spawn where/when they normally wouldn't."}); + UIWidgets::CVarCheckbox("Remove Obj Dep?", "gObjDep", + { .tooltip = "Allows actors to spawn where/when they normally wouldn't." }); if (UIWidgets::Button("Fetch from Link")) { Player* player = GET_PLAYER(gPlayState); @@ -296,16 +286,17 @@ void ActorViewerWindow::DrawElement() { newActor.rot = player->actor.world.rot; } - if (UIWidgets::Button("Spawn", {.color = UIWidgets::Colors::Green})) { + if (UIWidgets::Button("Spawn", { .color = UIWidgets::Colors::Green })) { Actor_Spawn(&gPlayState->actorCtx, gPlayState, newActor.id, newActor.pos.x, newActor.pos.y, - newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params); + newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params); } - if (UIWidgets::Button("Spawn as Child", {.color = UIWidgets::Colors::Green})) { + if (UIWidgets::Button("Spawn as Child", { .color = UIWidgets::Colors::Green })) { Actor* parent = display; if (parent != nullptr) { Actor_SpawnAsChild(&gPlayState->actorCtx, parent, gPlayState, newActor.id, newActor.pos.x, - newActor.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, newActor.params); + newActor.pos.y, newActor.pos.z, newActor.rot.x, newActor.rot.y, newActor.rot.z, + newActor.params); } else { Audio_PlaySfx(NA_SE_SY_ERROR); } @@ -320,10 +311,8 @@ void ActorViewerWindow::DrawElement() { } else { ImGui::Text("Playstate needed for actors!"); } - ImGui::End(); + ImGui::End(); } void ActorViewerWindow::InitElement() { - } - diff --git a/mm/2s2h/DeveloperTools/ActorViewer.h b/mm/2s2h/DeveloperTools/ActorViewer.h index 5361816bd..a93a9b68c 100644 --- a/mm/2s2h/DeveloperTools/ActorViewer.h +++ b/mm/2s2h/DeveloperTools/ActorViewer.h @@ -3,10 +3,10 @@ #include class ActorViewerWindow : public Ship::GuiWindow { - public: - using GuiWindow::GuiWindow; + public: + using GuiWindow::GuiWindow; - void InitElement() override; - void DrawElement() override; - void UpdateElement() override {}; + void InitElement() override; + void DrawElement() override; + void UpdateElement() override{}; }; diff --git a/mm/2s2h/DeveloperTools/BetterMapSelect.c b/mm/2s2h/DeveloperTools/BetterMapSelect.c index bf79aaf96..b8a37840e 100644 --- a/mm/2s2h/DeveloperTools/BetterMapSelect.c +++ b/mm/2s2h/DeveloperTools/BetterMapSelect.c @@ -25,12 +25,13 @@ void BetterMapSelect_LoadFileSelect(MapSelectState* mapSelectState) { } // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, entranceSceneId, _betterMapSelectIndex, humanName) \ +#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \ + entranceSceneId, _betterMapSelectIndex, humanName) \ { humanName, BetterMapSelect_LoadGame, ENTRANCE(entranceSceneId, 0) }, #define DEFINE_SCENE_UNSET(_enumValue) static SceneSelectEntry sBetterScenes[104] = { - #include "tables/scene_table.h" +#include "tables/scene_table.h" { "File Select", BetterMapSelect_LoadFileSelect, 0 }, { "Title Screen", MapSelect_LoadConsoleLogo, 0 }, }; @@ -39,7 +40,8 @@ static SceneSelectEntry sBetterScenes[104] = { #undef DEFINE_SCENE_UNSET // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, entranceSceneId, betterMapSelectIndex, humanName) \ +#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \ + entranceSceneId, betterMapSelectIndex, humanName) \ { humanName, ENTRANCE(entranceSceneId, 0), betterMapSelectIndex }, #define DEFINE_SCENE_UNSET(_enumValue) @@ -50,7 +52,7 @@ typedef struct { } BetterMapSelectInfoEntry; static BetterMapSelectInfoEntry sBetterMapSelectInfo[102] = { - #include "tables/scene_table.h" +#include "tables/scene_table.h" }; #undef DEFINE_SCENE @@ -92,11 +94,7 @@ void BetterMapSelect_Update(MapSelectState* mapSelectState) { } static const char* betterFormLabels[] = { - "Deity", - "Goron", - "Zora", - "Deku", - "Child", + "Deity", "Goron", "Zora", "Deku", "Child", }; void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer) { @@ -122,7 +120,7 @@ void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer } else { GfxPrint_SetColor(printer, 175, 175, 175, 255); } - + sceneName = sBetterScenes[sceneIndex].name; GfxPrint_Printf(printer, "%3d %s", sceneIndex, sceneName); }; @@ -173,11 +171,11 @@ void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer GfxPrint_SetColor(printer, 200, 100, 200, 255); switch (gSaveContext.save.cutsceneIndex) { case 0: - gSaveContext.save.time = CLOCK_TIME(12, 0); + gSaveContext.save.time = CLOCK_TIME(12, 0); stageName = "Afternoon"; break; case 0x8000: - gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 1; stageName = "Morning"; break; case 0x8800: @@ -185,7 +183,7 @@ void BetterMapSelect_PrintMenu(MapSelectState* mapSelectState, GfxPrint* printer stageName = "Night"; break; case 0xFFF0: - gSaveContext.save.time = CLOCK_TIME(12, 0); + gSaveContext.save.time = CLOCK_TIME(12, 0); stageName = "0"; break; case 0xFFF1: diff --git a/mm/2s2h/DeveloperTools/CollisionViewer.cpp b/mm/2s2h/DeveloperTools/CollisionViewer.cpp index bad871296..884425fb0 100644 --- a/mm/2s2h/DeveloperTools/CollisionViewer.cpp +++ b/mm/2s2h/DeveloperTools/CollisionViewer.cpp @@ -74,10 +74,14 @@ void CollisionViewerWindow::DrawElement() { ImGui::SeparatorText("Collision Types"); - UIWidgets::CVarCombobox("Scene", "gCollisionViewer.SceneCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray }); - UIWidgets::CVarCombobox("BG Actors", "gCollisionViewer.BGActorsCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray }); - UIWidgets::CVarCombobox("Col Check", "gCollisionViewer.ColCheckCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray }); - UIWidgets::CVarCombobox("Waterbox", "gCollisionViewer.WaterboxCollisionMode", ColRenderSettingNames, { .color = UIWidgets::Colors::Gray }); + UIWidgets::CVarCombobox("Scene", "gCollisionViewer.SceneCollisionMode", ColRenderSettingNames, + { .color = UIWidgets::Colors::Gray }); + UIWidgets::CVarCombobox("BG Actors", "gCollisionViewer.BGActorsCollisionMode", ColRenderSettingNames, + { .color = UIWidgets::Colors::Gray }); + UIWidgets::CVarCombobox("Col Check", "gCollisionViewer.ColCheckCollisionMode", ColRenderSettingNames, + { .color = UIWidgets::Colors::Gray }); + UIWidgets::CVarCombobox("Waterbox", "gCollisionViewer.WaterboxCollisionMode", ColRenderSettingNames, + { .color = UIWidgets::Colors::Gray }); ImGui::SeparatorText("Colors"); @@ -102,8 +106,10 @@ void CollisionViewerWindow::DrawElement() { UIWidgets::CVarColorPicker("AT", "gCollisionViewer.ATCollisionColor", { 255, 0, 0, 255 }); ImGui::EndTable(); } - UIWidgets::CVarColorPicker("Special Surface (Grass/Sand/Etc)", "gCollisionViewer.SpecialSurfaceColor", { 192, 255, 192, 255 }); - UIWidgets::CVarColorPicker("Interactable (Vines/Crawlspace/Etc)", "gCollisionViewer.InteractableColor", { 192, 0, 192, 255 }); + UIWidgets::CVarColorPicker("Special Surface (Grass/Sand/Etc)", "gCollisionViewer.SpecialSurfaceColor", + { 192, 255, 192, 255 }); + UIWidgets::CVarColorPicker("Interactable (Vines/Crawlspace/Etc)", "gCollisionViewer.InteractableColor", + { 192, 0, 192, 255 }); ImGui::EndDisabled(); @@ -201,9 +207,9 @@ void CreateSphereFace(std::vector>& faces, in // Create 3 new verticies at the midpoints Vec3f vs[3] = { - Vec3f{(v0.n.ob[0] + v1.n.ob[0]) / 2.0f, (v0.n.ob[1] + v1.n.ob[1]) / 2.0f, (v0.n.ob[2] + v1.n.ob[2]) / 2.0f}, - Vec3f{(v1.n.ob[0] + v2.n.ob[0]) / 2.0f, (v1.n.ob[1] + v2.n.ob[1]) / 2.0f, (v1.n.ob[2] + v2.n.ob[2]) / 2.0f}, - Vec3f{(v2.n.ob[0] + v0.n.ob[0]) / 2.0f, (v2.n.ob[1] + v0.n.ob[1]) / 2.0f, (v2.n.ob[2] + v0.n.ob[2]) / 2.0f} + Vec3f{ (v0.n.ob[0] + v1.n.ob[0]) / 2.0f, (v0.n.ob[1] + v1.n.ob[1]) / 2.0f, (v0.n.ob[2] + v1.n.ob[2]) / 2.0f }, + Vec3f{ (v1.n.ob[0] + v2.n.ob[0]) / 2.0f, (v1.n.ob[1] + v2.n.ob[1]) / 2.0f, (v1.n.ob[2] + v2.n.ob[2]) / 2.0f }, + Vec3f{ (v2.n.ob[0] + v0.n.ob[0]) / 2.0f, (v2.n.ob[1] + v0.n.ob[1]) / 2.0f, (v2.n.ob[2] + v0.n.ob[2]) / 2.0f } }; // Normalize vertex positions so they are on the sphere @@ -228,20 +234,20 @@ void CreateSphereData() { float d = (1.0f + sqrtf(5.0f)) / 2.0f; // Create the 12 starting verticies, 4 on each rectangle - base.emplace_back(Vec3f({-1, d, 0})); - base.emplace_back(Vec3f({1, d, 0})); - base.emplace_back(Vec3f({-1, -d, 0})); - base.emplace_back(Vec3f({1, -d, 0})); + base.emplace_back(Vec3f({ -1, d, 0 })); + base.emplace_back(Vec3f({ 1, d, 0 })); + base.emplace_back(Vec3f({ -1, -d, 0 })); + base.emplace_back(Vec3f({ 1, -d, 0 })); - base.emplace_back(Vec3f({0, -1, d})); - base.emplace_back(Vec3f({0, 1, d})); - base.emplace_back(Vec3f({0, -1, -d})); - base.emplace_back(Vec3f({0, 1, -d})); + base.emplace_back(Vec3f({ 0, -1, d })); + base.emplace_back(Vec3f({ 0, 1, d })); + base.emplace_back(Vec3f({ 0, -1, -d })); + base.emplace_back(Vec3f({ 0, 1, -d })); - base.emplace_back(Vec3f({d, 0, -1})); - base.emplace_back(Vec3f({d, 0, 1})); - base.emplace_back(Vec3f({-d, 0, -1})); - base.emplace_back(Vec3f({-d, 0, 1})); + base.emplace_back(Vec3f({ d, 0, -1 })); + base.emplace_back(Vec3f({ d, 0, 1 })); + base.emplace_back(Vec3f({ -d, 0, -1 })); + base.emplace_back(Vec3f({ -d, 0, 1 })); // Normalize verticies so they are on the unit sphere for (Vec3f& v : base) { @@ -350,7 +356,8 @@ void DrawDynapoly(std::vector& dl, CollisionHeader* col, int32_t bgId) { Color_RGBA8 voidCollisionColor = CVarGetColor("gCollisionViewer.VoidCollisionColor", { 255, 0, 0, 255 }); Color_RGBA8 entranceCollisionColor = CVarGetColor("gCollisionViewer.EntranceCollisionColor", { 0, 255, 0, 255 }); Color_RGBA8 slopeCollisionColor = CVarGetColor("gCollisionViewer.SlopeCollisionColor", { 255, 255, 128, 255 }); - Color_RGBA8 hookshotCollisionColor = CVarGetColor("gCollisionViewer.HookshotCollisionColor", { 128, 128, 255, 255 }); + Color_RGBA8 hookshotCollisionColor = + CVarGetColor("gCollisionViewer.HookshotCollisionColor", { 128, 128, 255, 255 }); Color_RGBA8 specialSurfaceColor = CVarGetColor("gCollisionViewer.SpecialSurfaceColor", { 192, 255, 192, 255 }); Color_RGBA8 interactableColor = CVarGetColor("gCollisionViewer.InteractableColor", { 192, 0, 192, 255 }); uint32_t colorR = sceneCollisionColor.r; @@ -448,7 +455,8 @@ void DrawDynapoly(std::vector& dl, CollisionHeader* col, int32_t bgId) { // Draws the scene void DrawSceneCollision() { - ColRenderSetting showSceneColSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.SceneCollisionMode", (uint32_t)ColRenderSetting::Disabled); + ColRenderSetting showSceneColSetting = + (ColRenderSetting)CVarGetInteger("gCollisionViewer.SceneCollisionMode", (uint32_t)ColRenderSetting::Disabled); if (showSceneColSetting == ColRenderSetting::Disabled) { return; @@ -463,7 +471,8 @@ void DrawSceneCollision() { // Draws all Bg Actors void DrawBgActorCollision() { - ColRenderSetting showBgActorSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.BGActorsCollisionMode", (uint32_t)ColRenderSetting::Disabled); + ColRenderSetting showBgActorSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.BGActorsCollisionMode", + (uint32_t)ColRenderSetting::Disabled); if (showBgActorSetting == ColRenderSetting::Disabled) { return; } @@ -591,7 +600,8 @@ void DrawColCheckCollision() { Color_RGBA8 oCollisionColor = CVarGetColor("gCollisionViewer.OCollisionColor", { 255, 255, 255, 255 }); Color_RGBA8 aCollisionColor = CVarGetColor("gCollisionViewer.ACollisionColor", { 0, 0, 255, 255 }); Color_RGBA8 aTCollisionColor = CVarGetColor("gCollisionViewer.ATCollisionColor", { 255, 0, 0, 255 }); - ColRenderSetting showColCheckSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.ColCheckCollisionMode", (uint32_t)ColRenderSetting::Disabled); + ColRenderSetting showColCheckSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.ColCheckCollisionMode", + (uint32_t)ColRenderSetting::Disabled); if (showColCheckSetting == ColRenderSetting::Disabled) { return; } @@ -639,7 +649,8 @@ void DrawWaterbox(std::vector& dl, WaterBox* water, float water_max_depth = // Draws all waterboxes void DrawWaterboxList() { Color_RGBA8 waterboxCollisionColor = CVarGetColor("gCollisionViewer.WaterboxCollisionColor", { 0, 0, 255, 255 }); - ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.WaterboxCollisionMode", (uint32_t)ColRenderSetting::Disabled); + ColRenderSetting showWaterboxSetting = (ColRenderSetting)CVarGetInteger("gCollisionViewer.WaterboxCollisionMode", + (uint32_t)ColRenderSetting::Disabled); if (showWaterboxSetting == ColRenderSetting::Disabled) { return; } @@ -648,7 +659,8 @@ void DrawWaterboxList() { InitGfx(dl, showWaterboxSetting); dl.push_back(gsSPMatrix(&gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH)); - dl.push_back(gsDPSetPrimColor(0, 0, waterboxCollisionColor.r, waterboxCollisionColor.g, waterboxCollisionColor.b, 255)); + dl.push_back( + gsDPSetPrimColor(0, 0, waterboxCollisionColor.r, waterboxCollisionColor.g, waterboxCollisionColor.b, 255)); CollisionHeader* col = gPlayState->colCtx.colHeader; for (int32_t waterboxIndex = 0; waterboxIndex < col->numWaterBoxes; waterboxIndex++) { diff --git a/mm/2s2h/DeveloperTools/CollisionViewer.h b/mm/2s2h/DeveloperTools/CollisionViewer.h index 454f4b9ad..72ce8fc72 100644 --- a/mm/2s2h/DeveloperTools/CollisionViewer.h +++ b/mm/2s2h/DeveloperTools/CollisionViewer.h @@ -17,7 +17,7 @@ class CollisionViewerWindow : public Ship::GuiWindow { void InitElement() override; void DrawElement() override; - void UpdateElement() override {}; + void UpdateElement() override{}; }; #endif diff --git a/mm/2s2h/DeveloperTools/DebugConsole.cpp b/mm/2s2h/DeveloperTools/DebugConsole.cpp index 63c45de3c..35c3c787e 100644 --- a/mm/2s2h/DeveloperTools/DebugConsole.cpp +++ b/mm/2s2h/DeveloperTools/DebugConsole.cpp @@ -17,11 +17,11 @@ extern "C" { #define CMD_REGISTER Ship::Context::GetInstance()->GetConsole()->AddCommand // TODO: Commands should be using the output passed in. -#define ERROR_MESSAGE \ +#define ERROR_MESSAGE \ std::reinterpret_pointer_cast( \ Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendErrorMessage -#define INFO_MESSAGE \ +#define INFO_MESSAGE \ std::reinterpret_pointer_cast( \ Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console")) \ ->SendInfoMessage @@ -132,7 +132,8 @@ static bool ResetHandler(std::shared_ptr Console, std::vector Console, const std::vector& args, std::string* output) { +static bool BHandler(std::shared_ptr Console, const std::vector& args, + std::string* output) { if (args.size() < 2) { ERROR_MESSAGE("[2S2H] Unexpected arguments passed"); return 1; @@ -277,17 +278,16 @@ void DebugConsole_Init(void) { CMD_REGISTER("bItem", { BHandler, "Set an item to the B button.", { { "Item ID", Ship::ArgumentType::NUMBER } } }); - CMD_REGISTER("spawn", - { ActorSpawnHandler, - "Spawn an actor.", - { { "actor id", Ship::ArgumentType::NUMBER }, - { "data", Ship::ArgumentType::NUMBER }, - { "x", Ship::ArgumentType::NUMBER, true }, - { "y", Ship::ArgumentType::NUMBER, true }, - { "z", Ship::ArgumentType::NUMBER, true }, - { "rx", Ship::ArgumentType::NUMBER, true }, - { "ry", Ship::ArgumentType::NUMBER, true }, - { "rz", Ship::ArgumentType::NUMBER, true } } }); + CMD_REGISTER("spawn", { ActorSpawnHandler, + "Spawn an actor.", + { { "actor id", Ship::ArgumentType::NUMBER }, + { "data", Ship::ArgumentType::NUMBER }, + { "x", Ship::ArgumentType::NUMBER, true }, + { "y", Ship::ArgumentType::NUMBER, true }, + { "z", Ship::ArgumentType::NUMBER, true }, + { "rx", Ship::ArgumentType::NUMBER, true }, + { "ry", Ship::ArgumentType::NUMBER, true }, + { "rz", Ship::ArgumentType::NUMBER, true } } }); CMD_REGISTER("pos", { SetPosHandler, "Sets the position of the player.", diff --git a/mm/2s2h/DeveloperTools/DeveloperTools.cpp b/mm/2s2h/DeveloperTools/DeveloperTools.cpp index e1865c570..fe0d9606d 100644 --- a/mm/2s2h/DeveloperTools/DeveloperTools.cpp +++ b/mm/2s2h/DeveloperTools/DeveloperTools.cpp @@ -119,9 +119,8 @@ void RegisterPreventActorUpdateHooks() { } if (CVarGetInteger("gDeveloperTools.PreventActorUpdate", 0)) { - hookId = GameInteractor::Instance->RegisterGameHook([](Actor* actor, bool* result) { - *result = false; - }); + hookId = GameInteractor::Instance->RegisterGameHook( + [](Actor* actor, bool* result) { *result = false; }); } } @@ -133,9 +132,8 @@ void RegisterPreventActorDrawHooks() { } if (CVarGetInteger("gDeveloperTools.PreventActorDraw", 0)) { - hookId = GameInteractor::Instance->RegisterGameHook([](Actor* actor, bool* result) { - *result = false; - }); + hookId = GameInteractor::Instance->RegisterGameHook( + [](Actor* actor, bool* result) { *result = false; }); } } @@ -147,9 +145,8 @@ void RegisterPreventActorInitHooks() { } if (CVarGetInteger("gDeveloperTools.PreventActorInit", 0)) { - hookId = GameInteractor::Instance->RegisterGameHookForFilter(GameInteractor::HookFilter::SActorNotPlayer, [](Actor* actor, bool* result) { - *result = false; - }); + hookId = GameInteractor::Instance->RegisterGameHookForFilter( + GameInteractor::HookFilter::SActorNotPlayer, [](Actor* actor, bool* result) { *result = false; }); } } diff --git a/mm/2s2h/DeveloperTools/EventLog.cpp b/mm/2s2h/DeveloperTools/EventLog.cpp index 7c0f0ba22..f4dd1772d 100644 --- a/mm/2s2h/DeveloperTools/EventLog.cpp +++ b/mm/2s2h/DeveloperTools/EventLog.cpp @@ -26,16 +26,8 @@ typedef enum { } EventLogEntryType; const char* eventLogEntryTypeNames[] = { - "FlagSet", - "FlagUnset", - "SceneFlagSet", - "SceneFlagUnset", - "ActorInit", - "ActorKill", - "SceneInit", - "RoomInit", - "OpenText", - "ItemGive", + "FlagSet", "FlagUnset", "SceneFlagSet", "SceneFlagUnset", "ActorInit", + "ActorKill", "SceneInit", "RoomInit", "OpenText", "ItemGive", }; struct EventLogEntry { @@ -47,29 +39,17 @@ struct EventLogEntry { std::vector eventLogEntries; const char* flagTypeNames[] = { - "", - "weekEventReg", - "eventInf", - "scenesVisible", - "owlActivation", - "chest", - "switch", - "clearedRoom", - "collectible", - "unk_14", - "rooms", - "chest *", - "switch *", - "clearedRoom *", - "collectible *", + "", "weekEventReg", "eventInf", "scenesVisible", "owlActivation", + "chest", "switch", "clearedRoom", "collectible", "unk_14", + "rooms", "chest *", "switch *", "clearedRoom *", "collectible *", }; -#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _debugName}, -#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) {_enumValue, _debugName}, -#define DEFINE_ACTOR_UNSET(_enumValue) {_enumValue, "Unset"}, +#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _debugName }, +#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName, _humanName) { _enumValue, _debugName }, +#define DEFINE_ACTOR_UNSET(_enumValue) { _enumValue, "Unset" }, std::unordered_map actorNames = { -#include "tables/actor_table.h" +#include "tables/actor_table.h" }; #undef DEFINE_ACTOR @@ -77,12 +57,13 @@ std::unordered_map actorNames = { #undef DEFINE_ACTOR_UNSET // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, humanName) \ +#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \ + _entranceSceneId, _betterMapSelectIndex, humanName) \ { enumValue, humanName }, #define DEFINE_SCENE_UNSET(_enumValue) std::unordered_map sceneNames = { -#include "tables/scene_table.h" +#include "tables/scene_table.h" }; #undef DEFINE_SCENE @@ -140,121 +121,139 @@ void RegisterEventLogHooks() { return; } - onFlagSetHookId = GameInteractor::Instance->RegisterGameHook([](FlagType type, u32 flag) { - if (type == FlagType::FLAG_WEEK_EVENT_REG) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_FLAG_SET, - .meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF), - }); - } else if (type == FlagType::FLAG_EVENT_INF) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_FLAG_SET, - .meta = fmt::format("EVENTINF_{:02x}", flag), - }); - } else { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_FLAG_SET, - .meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), - }); - } - TrimEventLog(); - }); + onFlagSetHookId = + GameInteractor::Instance->RegisterGameHook([](FlagType type, u32 flag) { + if (type == FlagType::FLAG_WEEK_EVENT_REG) { + eventLogEntries.insert(eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_FLAG_SET, + .meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF), + }); + } else if (type == FlagType::FLAG_EVENT_INF) { + eventLogEntries.insert(eventLogEntries.begin(), { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_FLAG_SET, + .meta = fmt::format("EVENTINF_{:02x}", flag), + }); + } else { + eventLogEntries.insert( + eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_FLAG_SET, + .meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), + }); + } + TrimEventLog(); + }); - onFlagUnsetHookId = GameInteractor::Instance->RegisterGameHook([](FlagType type, u32 flag) { - if (type == FlagType::FLAG_WEEK_EVENT_REG) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET, - .meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF), - }); - } else if (type == FlagType::FLAG_EVENT_INF) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET, - .meta = fmt::format("EVENTINF_{:02x}", flag), - }); - } else { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET, - .meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), - }); - } - TrimEventLog(); - }); + onFlagUnsetHookId = + GameInteractor::Instance->RegisterGameHook([](FlagType type, u32 flag) { + if (type == FlagType::FLAG_WEEK_EVENT_REG) { + eventLogEntries.insert(eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET, + .meta = fmt::format("WEEKEVENTREG_{:02d}_{:02x}", flag >> 8, flag & 0xFF), + }); + } else if (type == FlagType::FLAG_EVENT_INF) { + eventLogEntries.insert(eventLogEntries.begin(), { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET, + .meta = fmt::format("EVENTINF_{:02x}", flag), + }); + } else { + eventLogEntries.insert( + eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_FLAG_UNSET, + .meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), + }); + } + TrimEventLog(); + }); - onSceneFlagSetHookId = GameInteractor::Instance->RegisterGameHook([](s16 sceneId, FlagType type, u32 flag) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_SET, - .meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), + onSceneFlagSetHookId = GameInteractor::Instance->RegisterGameHook( + [](s16 sceneId, FlagType type, u32 flag) { + eventLogEntries.insert( + eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_SET, + .meta = fmt::format("{}({:02d}) {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), + }); + TrimEventLog(); }); - TrimEventLog(); - }); - onSceneFlagUnsetHookId = GameInteractor::Instance->RegisterGameHook([](s16 sceneId, FlagType type, u32 flag) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_UNSET, - .meta = fmt::format("{}[{:02d}] {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), + onSceneFlagUnsetHookId = GameInteractor::Instance->RegisterGameHook( + [](s16 sceneId, FlagType type, u32 flag) { + eventLogEntries.insert( + eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_SCENE_FLAG_UNSET, + .meta = fmt::format("{}[{:02d}] {:02x}", flagTypeNames[type], flag >> 8, flag & 0xFF), + }); + TrimEventLog(); }); - TrimEventLog(); - }); onActorInitHookId = GameInteractor::Instance->RegisterGameHook([](Actor* actor) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_ACTOR_INIT, - .meta = fmt::format("{} {}", actorNames[actor->id], actor->params), - }); + eventLogEntries.insert(eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_ACTOR_INIT, + .meta = fmt::format("{} {}", actorNames[actor->id], actor->params), + }); TrimEventLog(); }); onActorKillHookId = GameInteractor::Instance->RegisterGameHook([](Actor* actor) { - eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_ACTOR_KILL, - .meta = fmt::format("{} {}", actorNames[actor->id], actor->params), - }); + eventLogEntries.insert(eventLogEntries.begin(), + { + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_ACTOR_KILL, + .meta = fmt::format("{} {}", actorNames[actor->id], actor->params), + }); TrimEventLog(); }); - onSceneInitHookId = GameInteractor::Instance->RegisterGameHook([](s16 sceneId, s8 spawnNum) { + onSceneInitHookId = GameInteractor::Instance->RegisterGameHook([](s16 sceneId, + s8 spawnNum) { eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_SCENE_INIT, - .meta = fmt::format("{} {}", sceneNames[sceneId], spawnNum), - }); + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_SCENE_INIT, + .meta = fmt::format("{} {}", sceneNames[sceneId], spawnNum), + }); TrimEventLog(); }); - onRoomInitHookId = GameInteractor::Instance->RegisterGameHook([](s16 sceneId, s8 roomId) { + onRoomInitHookId = GameInteractor::Instance->RegisterGameHook([](s16 sceneId, + s8 roomId) { eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_ROOM_INIT, - .meta = fmt::format("{} {}", sceneNames[sceneId], roomId), - }); + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_ROOM_INIT, + .meta = fmt::format("{} {}", sceneNames[sceneId], roomId), + }); TrimEventLog(); }); onOpenTextHookId = GameInteractor::Instance->RegisterGameHook([](s16 textId) { eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_OPEN_TEXT, - .meta = fmt::format("0x{:02x}", textId), - }); + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_OPEN_TEXT, + .meta = fmt::format("0x{:02x}", textId), + }); TrimEventLog(); }); onItemGiveHookId = GameInteractor::Instance->RegisterGameHook([](u8 item) { eventLogEntries.insert(eventLogEntries.begin(), { - .timestamp = CurrentTime(), - .type = EVENT_LOG_ENTRY_TYPE_ITEM_GIVE, - .meta = fmt::format("0x{:02x}", item), - }); + .timestamp = CurrentTime(), + .type = EVENT_LOG_ENTRY_TYPE_ITEM_GIVE, + .meta = fmt::format("0x{:02x}", item), + }); TrimEventLog(); }); } @@ -278,31 +277,24 @@ void EventLogWindow::DrawElement() { if (ImGui::BeginPopup("eventLogFiltersPopup")) { bool allChecked = - CVarGetInteger("gEventLog.Filter.FlagSet", 1) && - CVarGetInteger("gEventLog.Filter.FlagUnset", 1) && + CVarGetInteger("gEventLog.Filter.FlagSet", 1) && CVarGetInteger("gEventLog.Filter.FlagUnset", 1) && CVarGetInteger("gEventLog.Filter.SceneFlagSet", 1) && - CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) && - CVarGetInteger("gEventLog.Filter.ActorInit", 1) && - CVarGetInteger("gEventLog.Filter.ActorKill", 1) && - CVarGetInteger("gEventLog.Filter.SceneInit", 1) && - CVarGetInteger("gEventLog.Filter.RoomInit", 1) && - CVarGetInteger("gEventLog.Filter.OpenText", 1) && + CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) && CVarGetInteger("gEventLog.Filter.ActorInit", 1) && + CVarGetInteger("gEventLog.Filter.ActorKill", 1) && CVarGetInteger("gEventLog.Filter.SceneInit", 1) && + CVarGetInteger("gEventLog.Filter.RoomInit", 1) && CVarGetInteger("gEventLog.Filter.OpenText", 1) && CVarGetInteger("gEventLog.Filter.ItemGive", 1); bool someChecked = - CVarGetInteger("gEventLog.Filter.FlagSet", 1) || - CVarGetInteger("gEventLog.Filter.FlagUnset", 1) || + CVarGetInteger("gEventLog.Filter.FlagSet", 1) || CVarGetInteger("gEventLog.Filter.FlagUnset", 1) || CVarGetInteger("gEventLog.Filter.SceneFlagSet", 1) || - CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) || - CVarGetInteger("gEventLog.Filter.ActorInit", 1) || - CVarGetInteger("gEventLog.Filter.ActorKill", 1) || - CVarGetInteger("gEventLog.Filter.SceneInit", 1) || - CVarGetInteger("gEventLog.Filter.RoomInit", 1) || - CVarGetInteger("gEventLog.Filter.OpenText", 1) || + CVarGetInteger("gEventLog.Filter.SceneFlagUnset", 1) || CVarGetInteger("gEventLog.Filter.ActorInit", 1) || + CVarGetInteger("gEventLog.Filter.ActorKill", 1) || CVarGetInteger("gEventLog.Filter.SceneInit", 1) || + CVarGetInteger("gEventLog.Filter.RoomInit", 1) || CVarGetInteger("gEventLog.Filter.OpenText", 1) || CVarGetInteger("gEventLog.Filter.ItemGive", 1); ImGuiContext* g = ImGui::GetCurrentContext(); ImGuiItemFlags backup_item_flags = g->CurrentItemFlags; - if (!allChecked && someChecked) g->CurrentItemFlags |= ImGuiItemFlags_MixedValue; + if (!allChecked && someChecked) + g->CurrentItemFlags |= ImGuiItemFlags_MixedValue; if (UIWidgets::Checkbox("All", &allChecked)) { if (allChecked) { CVarSetInteger("gEventLog.Filter.FlagSet", 1); @@ -376,7 +368,8 @@ void EventLogWindow::DrawElement() { ImGui::TableHeadersRow(); for (int i = 0; i < eventLogEntries.size(); i++) { - if (!CVarGetInteger((std::string("gEventLog.Filter.") + eventLogEntryTypeNames[eventLogEntries[i].type]).c_str(), 1)) { + if (!CVarGetInteger( + (std::string("gEventLog.Filter.") + eventLogEntryTypeNames[eventLogEntries[i].type]).c_str(), 1)) { continue; } diff --git a/mm/2s2h/DeveloperTools/EventLog.h b/mm/2s2h/DeveloperTools/EventLog.h index 9b85b5330..132526c91 100644 --- a/mm/2s2h/DeveloperTools/EventLog.h +++ b/mm/2s2h/DeveloperTools/EventLog.h @@ -3,10 +3,10 @@ #include class EventLogWindow : public Ship::GuiWindow { - public: - using GuiWindow::GuiWindow; + public: + using GuiWindow::GuiWindow; - void InitElement() override; - void DrawElement() override; - void UpdateElement() override {}; + void InitElement() override; + void DrawElement() override; + void UpdateElement() override{}; }; diff --git a/mm/2s2h/DeveloperTools/SaveEditor.cpp b/mm/2s2h/DeveloperTools/SaveEditor.cpp index 0da3d9317..007f29d0e 100644 --- a/mm/2s2h/DeveloperTools/SaveEditor.cpp +++ b/mm/2s2h/DeveloperTools/SaveEditor.cpp @@ -88,13 +88,13 @@ void initSafeItemsForInventorySlot() { char z2ASCII(int code) { int ret; - if (code < 10) { //Digits + if (code < 10) { // Digits ret = code + 0x30; - } else if (code >= 10 && code < 36) { //Uppercase letters + } else if (code >= 10 && code < 36) { // Uppercase letters ret = code + 0x37; - } else if (code >= 36 && code < 62) { //Lowercase letters + } else if (code >= 36 && code < 62) { // Lowercase letters ret = code + 0x3D; - } else if (code == 62) { //Space + } else if (code == 62) { // Space ret = code - 0x1E; } else if (code == 63 || code == 64) { // _ and . ret = code - 0x12; @@ -106,13 +106,13 @@ char z2ASCII(int code) { char ASCII2z(int code) { int ret; - if (code >= 0x30 && code < 0x3A) { //Digits + if (code >= 0x30 && code < 0x3A) { // Digits ret = code - 0x30; - } else if (code >= 0x41 && code < 0x5B) { //Uppercase letters + } else if (code >= 0x41 && code < 0x5B) { // Uppercase letters ret = code - 0x37; - } else if (code >= 0x61 && code < 0x7B) { //Lowercase letters + } else if (code >= 0x61 && code < 0x7B) { // Lowercase letters ret = code - 0x3D; - } else if (code == 0x20 || code == 0x0) { //Space + } else if (code == 0x20 || code == 0x0) { // Space ret = 62; } else if (code == 0x5F || code == 0x2E) { // _ and . ret = code + 0x12; @@ -149,7 +149,8 @@ void DrawGeneralTab() { ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); static char playerNameBuf[9]; - ImGui::InputText("##playerNameInput", getPlayerName(playerNameBuf), 9, ImGuiInputTextFlags_CallbackAlways | ImGuiInputTextFlags_AutoSelectAll, setPlayerName); + ImGui::InputText("##playerNameInput", getPlayerName(playerNameBuf), 9, + ImGuiInputTextFlags_CallbackAlways | ImGuiInputTextFlags_AutoSelectAll, setPlayerName); ImGui::PopStyleVar(2); ImGui::PopStyleColor(1); ImGui::EndGroup(); @@ -178,7 +179,8 @@ void DrawGeneralTab() { } hours += std::to_string(curHours); std::string timeString = hours + ":" + minutes + ampm + " (0x%x)"; - ImGui::SliderScalar("##timeInput", ImGuiDataType_U16, &gSaveContext.save.time, &minTime, &maxTime, timeString.c_str()); + ImGui::SliderScalar("##timeInput", ImGuiDataType_U16, &gSaveContext.save.time, &minTime, &maxTime, + timeString.c_str()); UIWidgets::PopStyleSlider(); ImGui::EndGroup(); @@ -190,14 +192,16 @@ void DrawGeneralTab() { gSaveContext.save.saveInfo.inventory.questItems &= ~0xF0000000; } ImGui::SameLine(); - if (UIWidgets::Button("Reset##resetHealthButton", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Reset##resetHealthButton", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.playerData.doubleDefense = 0; gSaveContext.save.saveInfo.inventory.defenseHearts = 0; gSaveContext.save.saveInfo.playerData.healthCapacity = gSaveContext.save.saveInfo.playerData.health = 3 * 16; gSaveContext.save.saveInfo.inventory.questItems &= ~0xF0000000; } ImGui::SameLine(); - if (UIWidgets::Checkbox("DD", (bool *)&gSaveContext.save.saveInfo.playerData.doubleDefense, { .color = UIWidgets::Colors::Red })) { + if (UIWidgets::Checkbox("DD", (bool*)&gSaveContext.save.saveInfo.playerData.doubleDefense, + { .color = UIWidgets::Colors::Red })) { if (gSaveContext.save.saveInfo.playerData.doubleDefense) { gSaveContext.save.saveInfo.inventory.defenseHearts = 20; } else { @@ -206,11 +210,14 @@ void DrawGeneralTab() { } UIWidgets::PushStyleSlider(UIWidgets::Colors::DarkRed); int16_t heartCount = (int16_t)gSaveContext.save.saveInfo.playerData.healthCapacity / 16; - if (ImGui::SliderScalar("##heartCountSlider", ImGuiDataType_U16, &heartCount, &HEART_COUNT_MIN, &HEART_COUNT_MAX, "Max Hearts: %d")) { + if (ImGui::SliderScalar("##heartCountSlider", ImGuiDataType_U16, &heartCount, &HEART_COUNT_MIN, &HEART_COUNT_MAX, + "Max Hearts: %d")) { gSaveContext.save.saveInfo.playerData.healthCapacity = heartCount * 16; - gSaveContext.save.saveInfo.playerData.health = MIN(gSaveContext.save.saveInfo.playerData.health, gSaveContext.save.saveInfo.playerData.healthCapacity); + gSaveContext.save.saveInfo.playerData.health = + MIN(gSaveContext.save.saveInfo.playerData.health, gSaveContext.save.saveInfo.playerData.healthCapacity); } - ImGui::SliderScalar("##healthSlider", ImGuiDataType_S16, &gSaveContext.save.saveInfo.playerData.health, &S16_ZERO, &gSaveContext.save.saveInfo.playerData.healthCapacity, "Health: %d"); + ImGui::SliderScalar("##healthSlider", ImGuiDataType_S16, &gSaveContext.save.saveInfo.playerData.health, &S16_ZERO, + &gSaveContext.save.saveInfo.playerData.healthCapacity, "Health: %d"); UIWidgets::PopStyleSlider(); ImGui::EndGroup(); @@ -252,7 +259,8 @@ void DrawGeneralTab() { static s32 minSpeed = -3; // Time frozen static s32 maxSpeed = 7; std::string timeSpeedString = "Time Speed: " + std::to_string(gSaveContext.save.timeSpeedOffset + 3); - ImGui::SliderScalar("##timeSpeedInput", ImGuiDataType_S32, &gSaveContext.save.timeSpeedOffset, &minSpeed, &maxSpeed, timeSpeedString.c_str()); + ImGui::SliderScalar("##timeSpeedInput", ImGuiDataType_S32, &gSaveContext.save.timeSpeedOffset, &minSpeed, &maxSpeed, + timeSpeedString.c_str()); UIWidgets::PopStyleSlider(); ImGui::EndGroup(); @@ -265,16 +273,20 @@ void DrawGeneralTab() { BUTTON_ITEM_EQUIP(PLAYER_FORM_DEKU, EQUIP_SLOT_B) = ITEM_DEKU_NUT; } ImGui::SameLine(); - if (UIWidgets::Button("Reset##resetMagicButton", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Reset##resetMagicButton", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.magicCapacity = gSaveContext.save.saveInfo.playerData.magic = 0; gSaveContext.save.saveInfo.playerData.magicLevel = 0; gSaveContext.save.saveInfo.playerData.isMagicAcquired = false; gSaveContext.save.saveInfo.playerData.isDoubleMagicAcquired = false; } UIWidgets::PushStyleSlider(UIWidgets::Colors::DarkGreen); - if (ImGui::SliderScalar("##magicLevelSlider", ImGuiDataType_S8, &gSaveContext.save.saveInfo.playerData.magicLevel, &S8_ZERO, &MAGIC_LEVEL_MAX, MAGIC_LEVEL_NAMES[gSaveContext.save.saveInfo.playerData.magicLevel])) { + if (ImGui::SliderScalar("##magicLevelSlider", ImGuiDataType_S8, &gSaveContext.save.saveInfo.playerData.magicLevel, + &S8_ZERO, &MAGIC_LEVEL_MAX, + MAGIC_LEVEL_NAMES[gSaveContext.save.saveInfo.playerData.magicLevel])) { gSaveContext.magicCapacity = gSaveContext.save.saveInfo.playerData.magicLevel * MAGIC_NORMAL_METER; - gSaveContext.save.saveInfo.playerData.magic = MIN(gSaveContext.save.saveInfo.playerData.magic, gSaveContext.magicCapacity); + gSaveContext.save.saveInfo.playerData.magic = + MIN(gSaveContext.save.saveInfo.playerData.magic, gSaveContext.magicCapacity); switch (gSaveContext.save.saveInfo.playerData.magicLevel) { case 0: gSaveContext.save.saveInfo.playerData.isMagicAcquired = false; @@ -292,7 +304,8 @@ void DrawGeneralTab() { break; } } - ImGui::SliderScalar("##magicSlider", ImGuiDataType_S8, &gSaveContext.save.saveInfo.playerData.magic, &S8_ZERO, &gSaveContext.magicCapacity, "Magic: %d"); + ImGui::SliderScalar("##magicSlider", ImGuiDataType_S8, &gSaveContext.save.saveInfo.playerData.magic, &S8_ZERO, + &gSaveContext.magicCapacity, "Magic: %d"); UIWidgets::PopStyleSlider(); ImGui::EndGroup(); @@ -304,29 +317,29 @@ void DrawGeneralTab() { gSaveContext.save.saveInfo.playerData.rupees = CUR_CAPACITY(UPG_WALLET); } ImGui::SameLine(); - if (UIWidgets::Button("Reset##resetRupeesButton", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Reset##resetRupeesButton", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.playerData.rupees = 0; Inventory_ChangeUpgrade(UPG_WALLET, 0); } UIWidgets::PushStyleSlider(UIWidgets::Colors::Green); u8 currentWalletLevel = CUR_UPG_VALUE(UPG_WALLET); - if (ImGui::SliderScalar("##walletLevelSlider", ImGuiDataType_U8, ¤tWalletLevel, &U8_ZERO, &WALLET_LEVEL_MAX, WALLET_LEVEL_NAMES[currentWalletLevel])) { + if (ImGui::SliderScalar("##walletLevelSlider", ImGuiDataType_U8, ¤tWalletLevel, &U8_ZERO, &WALLET_LEVEL_MAX, + WALLET_LEVEL_NAMES[currentWalletLevel])) { Inventory_ChangeUpgrade(UPG_WALLET, currentWalletLevel); - gSaveContext.save.saveInfo.playerData.rupees = MIN(gSaveContext.save.saveInfo.playerData.rupees, CUR_CAPACITY(UPG_WALLET)); + gSaveContext.save.saveInfo.playerData.rupees = + MIN(gSaveContext.save.saveInfo.playerData.rupees, CUR_CAPACITY(UPG_WALLET)); } s16 walletCapacity = CUR_CAPACITY(UPG_WALLET); - ImGui::SliderScalar("##rupeesSlider", ImGuiDataType_S16, &gSaveContext.save.saveInfo.playerData.rupees, &S16_ZERO, &walletCapacity, "Rupees: %d"); + ImGui::SliderScalar("##rupeesSlider", ImGuiDataType_S16, &gSaveContext.save.saveInfo.playerData.rupees, &S16_ZERO, + &walletCapacity, "Rupees: %d"); UIWidgets::PopStyleSlider(); ImGui::EndGroup(); ImGui::BeginGroup(); - ImGui::Text("Bombers Code: %d %d %d %d %d", - gSaveContext.save.saveInfo.bomberCode[0], - gSaveContext.save.saveInfo.bomberCode[1], - gSaveContext.save.saveInfo.bomberCode[2], - gSaveContext.save.saveInfo.bomberCode[3], - gSaveContext.save.saveInfo.bomberCode[4] - ); + ImGui::Text("Bombers Code: %d %d %d %d %d", gSaveContext.save.saveInfo.bomberCode[0], + gSaveContext.save.saveInfo.bomberCode[1], gSaveContext.save.saveInfo.bomberCode[2], + gSaveContext.save.saveInfo.bomberCode[3], gSaveContext.save.saveInfo.bomberCode[4]); ImGui::Text("Banked Rupees: %d", HS_GET_BANK_RUPEES()); int bankedRupees = HS_GET_BANK_RUPEES(); @@ -365,8 +378,7 @@ void DrawGeneralTab() { ImGui::PopStyleVar(2); } -template -bool contains(C&& c, T e) { +template bool contains(C&& c, T e) { return std::find(std::begin(c), std::end(c), e) != std::end(c); }; @@ -375,7 +387,9 @@ void DrawAmmoInput(InventorySlot slot) { int y = ((int)floor(slot / 6) % 4); ItemId currentItemId = static_cast(gSaveContext.save.saveInfo.inventory.items[slot]); - ImGui::SetCursorPos(ImVec2(x * INV_GRID_WIDTH + INV_GRID_PADDING + 7.0f, y * INV_GRID_HEIGHT + INV_GRID_TOP_MARGIN + INV_GRID_PADDING + (INV_GRID_ICON_SIZE - 2.0f))); + ImGui::SetCursorPos( + ImVec2(x * INV_GRID_WIDTH + INV_GRID_PADDING + 7.0f, + y * INV_GRID_HEIGHT + INV_GRID_TOP_MARGIN + INV_GRID_PADDING + (INV_GRID_ICON_SIZE - 2.0f))); ImGui::PushItemWidth(24.0f); ImGui::PushStyleColor(ImGuiCol_FrameBg, UIWidgets::Colors::Gray); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); @@ -434,7 +448,9 @@ void DrawEquipItemMenu(InventorySlot slot) { void NextItemInSlot(InventorySlot slot) { ItemId currentItemId = static_cast(gSaveContext.save.saveInfo.inventory.items[slot]); - size_t currentItemIndex = find(safeItemsForInventorySlot[slot].begin(), safeItemsForInventorySlot[slot].end(), currentItemId) - safeItemsForInventorySlot[slot].begin(); + size_t currentItemIndex = + find(safeItemsForInventorySlot[slot].begin(), safeItemsForInventorySlot[slot].end(), currentItemId) - + safeItemsForInventorySlot[slot].begin(); if (currentItemId == ITEM_NONE) { gSaveContext.save.saveInfo.inventory.items[slot] = safeItemsForInventorySlot[slot][0]; @@ -442,7 +458,8 @@ void NextItemInSlot(InventorySlot slot) { if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_BOW) { Inventory_ChangeUpgrade(UPG_QUIVER, 1); AMMO(ITEM_BOW) = CUR_CAPACITY(UPG_QUIVER); - } else if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_BOMB || gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_BOMBCHU) { + } else if (gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_BOMB || + gSaveContext.save.saveInfo.inventory.items[slot] == ITEM_BOMBCHU) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { Inventory_ChangeUpgrade(UPG_BOMB_BAG, 1); } @@ -481,41 +498,39 @@ void DrawSlot(InventorySlot slot) { ImGui::PushID(slot); - if ( - currentItemId != ITEM_NONE && - currentItemId <= ITEM_BOW_LIGHT && // gItemSlots only has entries till 77 (ITEM_BOW_LIGHT) + if (currentItemId != ITEM_NONE && + currentItemId <= ITEM_BOW_LIGHT && // gItemSlots only has entries till 77 (ITEM_BOW_LIGHT) gItemSlots[currentItemId] <= SLOT_BOTTLE_6 && // There is only ammo data for the first page - ( - (safeMode && gAmmoItems[gItemSlots[currentItemId]] != ITEM_NONE) || !safeMode - ) - ) { + ((safeMode && gAmmoItems[gItemSlots[currentItemId]] != ITEM_NONE) || !safeMode)) { DrawAmmoInput(slot); } - ImGui::SetCursorPos(ImVec2(x * INV_GRID_WIDTH + INV_GRID_PADDING, y * INV_GRID_HEIGHT + INV_GRID_TOP_MARGIN + INV_GRID_PADDING)); + ImGui::SetCursorPos( + ImVec2(x * INV_GRID_WIDTH + INV_GRID_PADDING, y * INV_GRID_HEIGHT + INV_GRID_TOP_MARGIN + INV_GRID_PADDING)); // isEquipped border ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 1.0f, 1.0f, 0.0f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 1.0f, 1.0f, 0.2f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.0f, 1.0f, 1.0f, 0.1f)); - if ( - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_LEFT] == slot || + if (gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_LEFT] == slot || gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_DOWN] == slot || - gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_RIGHT] == slot - ) { + gSaveContext.save.saveInfo.equips.cButtonSlots[CUR_FORM][EQUIP_SLOT_C_RIGHT] == slot) { ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::White); } else { ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.0f, 1.0f, 1.0f, 0.0f)); } ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f); - ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[safeItemsForInventorySlot[slot][0]]); + ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[safeItemsForInventorySlot[slot][0]]); if (currentItemId != ITEM_NONE) { - textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[currentItemId]); + textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[currentItemId]); } - if (ImGui::ImageButton(textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), 0, ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, currentItemId == ITEM_NONE ? 0.4f : 1.0f))) { + if (ImGui::ImageButton(textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), 0, + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, currentItemId == ITEM_NONE ? 0.4f : 1.0f))) { if (safeMode && safeItemsForInventorySlot[slot].size() < 2) { NextItemInSlot(slot); } else { @@ -532,7 +547,8 @@ void DrawSlot(InventorySlot slot) { ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.0f, 1.0f, 1.0f, 0.2f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(1.0f, 1.0f, 1.0f, 0.1f)); if (ImGui::Button("##invNonePicker", ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE))) { - Inventory_DeleteItem(gSaveContext.save.saveInfo.inventory.items[selectedInventorySlot], selectedInventorySlot); + Inventory_DeleteItem(gSaveContext.save.saveInfo.inventory.items[selectedInventorySlot], + selectedInventorySlot); ImGui::CloseCurrentPopup(); } UIWidgets::Tooltip("None"); @@ -542,8 +558,11 @@ void DrawSlot(InventorySlot slot) { if (((pickerIndex + 1) % 8) != 0) { ImGui::SameLine(); } - ItemId id = safeMode ? safeItemsForInventorySlot[selectedInventorySlot][pickerIndex] : static_cast(pickerIndex); - if (ImGui::ImageButton(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[id]), ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), 0)) { + ItemId id = safeMode ? safeItemsForInventorySlot[selectedInventorySlot][pickerIndex] + : static_cast(pickerIndex); + if (ImGui::ImageButton( + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[id]), + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), 0)) { gSaveContext.save.saveInfo.inventory.items[selectedInventorySlot] = id; ImGui::CloseCurrentPopup(); } @@ -568,7 +587,10 @@ void DrawItemsAndMasksTab() { // Group left side in a child for a scroll bar ImGui::BeginChild("leftSide##items", ImVec2(0, 0), ImGuiChildFlags_AutoResizeX); ImGui::BeginGroup(); - ImGui::BeginChild("itemsBox", ImVec2(INV_GRID_WIDTH * 6 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 4 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("itemsBox", + ImVec2(INV_GRID_WIDTH * 6 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 4 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Items"); for (uint32_t i = SLOT_OCARINA; i <= SLOT_BOTTLE_6; i++) { InventorySlot slot = static_cast(i); @@ -576,7 +598,10 @@ void DrawItemsAndMasksTab() { DrawSlot(slot); } ImGui::EndChild(); - ImGui::BeginChild("masksBox", ImVec2(INV_GRID_WIDTH * 6 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 4 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("masksBox", + ImVec2(INV_GRID_WIDTH * 6 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 4 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Masks"); for (uint32_t i = SLOT_MASK_POSTMAN; i <= SLOT_MASK_FIERCE_DEITY; i++) { InventorySlot slot = static_cast(i); @@ -610,12 +635,13 @@ void DrawItemsAndMasksTab() { for (int32_t i = 0; i <= SLOT_MASK_FIERCE_DEITY; i++) { Inventory_DeleteItem(gSaveContext.save.saveInfo.inventory.items[i], i); } - AMMO(ITEM_BOW) = AMMO(ITEM_BOMB) = AMMO(ITEM_BOMBCHU) = AMMO(ITEM_DEKU_STICK) = AMMO(ITEM_DEKU_NUT) = AMMO(ITEM_MAGIC_BEANS) = AMMO(ITEM_POWDER_KEG) = 0; + AMMO(ITEM_BOW) = AMMO(ITEM_BOMB) = AMMO(ITEM_BOMBCHU) = AMMO(ITEM_DEKU_STICK) = AMMO(ITEM_DEKU_NUT) = + AMMO(ITEM_MAGIC_BEANS) = AMMO(ITEM_POWDER_KEG) = 0; Inventory_ChangeUpgrade(UPG_BOMB_BAG, 0); Inventory_ChangeUpgrade(UPG_QUIVER, 0); } UIWidgets::Checkbox("Safe Mode", &safeMode); - + // Expose inputs to edit raw number values of equips // ImGui::Text("Equips"); // ImGui::Text("C-Buttons"); @@ -631,8 +657,11 @@ void SongInfo(int32_t itemID) { songTooltip = "Sonata of Awakening"; break; case QUEST_SONG_LULLABY: - colorTint = ImVec4(1.0f, 0.313f, 0.156f, (CHECK_QUEST_ITEM(itemID) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) ? 1.0f : 0.4f); - songTooltip = (!CHECK_QUEST_ITEM(itemID) && CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) ? "Goron Lullaby Intro" : "Goron Lullaby"; + colorTint = ImVec4(1.0f, 0.313f, 0.156f, + (CHECK_QUEST_ITEM(itemID) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) ? 1.0f : 0.4f); + songTooltip = (!CHECK_QUEST_ITEM(itemID) && CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) + ? "Goron Lullaby Intro" + : "Goron Lullaby"; break; case QUEST_SONG_BOSSA_NOVA: colorTint = ImVec4(0.392f, 0.588f, 1.0f, CHECK_QUEST_ITEM(itemID) ? 1.0f : 0.4f); @@ -681,23 +710,15 @@ void SongInfo(int32_t itemID) { } } -std::mapquestToItemMap = { - { QUEST_REMAINS_ODOLWA, ITEM_REMAINS_ODOLWA }, - { QUEST_REMAINS_GOHT, ITEM_REMAINS_GOHT }, - { QUEST_REMAINS_GYORG, ITEM_REMAINS_GYORG }, - { QUEST_REMAINS_TWINMOLD, ITEM_REMAINS_TWINMOLD }, - { QUEST_SONG_SONATA, ITEM_SONG_SONATA }, - { QUEST_SONG_LULLABY, ITEM_SONG_LULLABY }, - { QUEST_SONG_BOSSA_NOVA, ITEM_SONG_NOVA }, - { QUEST_SONG_ELEGY, ITEM_SONG_ELEGY }, - { QUEST_SONG_OATH, ITEM_SONG_OATH }, - { QUEST_SONG_SARIA, ITEM_SONG_SARIA }, - { QUEST_SONG_TIME, ITEM_SONG_TIME }, - { QUEST_SONG_HEALING, ITEM_SONG_HEALING }, - { QUEST_SONG_EPONA, ITEM_SONG_EPONA }, - { QUEST_SONG_SOARING, ITEM_SONG_SOARING }, - { QUEST_SONG_STORMS, ITEM_SONG_STORMS }, - { QUEST_SONG_SUN, ITEM_SONG_SUN } +std::map questToItemMap = { + { QUEST_REMAINS_ODOLWA, ITEM_REMAINS_ODOLWA }, { QUEST_REMAINS_GOHT, ITEM_REMAINS_GOHT }, + { QUEST_REMAINS_GYORG, ITEM_REMAINS_GYORG }, { QUEST_REMAINS_TWINMOLD, ITEM_REMAINS_TWINMOLD }, + { QUEST_SONG_SONATA, ITEM_SONG_SONATA }, { QUEST_SONG_LULLABY, ITEM_SONG_LULLABY }, + { QUEST_SONG_BOSSA_NOVA, ITEM_SONG_NOVA }, { QUEST_SONG_ELEGY, ITEM_SONG_ELEGY }, + { QUEST_SONG_OATH, ITEM_SONG_OATH }, { QUEST_SONG_SARIA, ITEM_SONG_SARIA }, + { QUEST_SONG_TIME, ITEM_SONG_TIME }, { QUEST_SONG_HEALING, ITEM_SONG_HEALING }, + { QUEST_SONG_EPONA, ITEM_SONG_EPONA }, { QUEST_SONG_SOARING, ITEM_SONG_SOARING }, + { QUEST_SONG_STORMS, ITEM_SONG_STORMS }, { QUEST_SONG_SUN, ITEM_SONG_SUN } }; void NextQuestInSlot(QuestItem slot) { @@ -721,7 +742,8 @@ void NextQuestInSlot(QuestItem slot) { } else { SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, currentSword + 1); } - BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = + ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_RAZOR) { gSaveContext.save.saveInfo.playerData.swordHealth = 100; } @@ -747,21 +769,28 @@ void DrawQuestSlot(QuestItem slot) { int x = slot % 6; int y = ((int)floor(slot / 6) % 4); ImGui::PushID(slot); - - ImGui::SetCursorPos(ImVec2(x * INV_GRID_WIDTH + INV_GRID_PADDING, y * INV_GRID_HEIGHT + INV_GRID_TOP_MARGIN + INV_GRID_PADDING)); - ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[questToItemMap[slot]]); - if (ImGui::ImageButton(std::to_string(slot).c_str(), textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, CHECK_QUEST_ITEM(slot) ? 1.0f : 0.4f))) { + ImGui::SetCursorPos( + ImVec2(x * INV_GRID_WIDTH + INV_GRID_PADDING, y * INV_GRID_HEIGHT + INV_GRID_TOP_MARGIN + INV_GRID_PADDING)); + + ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[questToItemMap[slot]]); + if (ImGui::ImageButton(std::to_string(slot).c_str(), textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), + ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), + ImVec4(1, 1, 1, CHECK_QUEST_ITEM(slot) ? 1.0f : 0.4f))) { NextQuestInSlot(slot); } - + ImGui::PopID(); } void DrawSong(QuestItem slot) { SongInfo(slot); - if (ImGui::ImageButton(std::to_string(slot).c_str(), Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[questToItemMap[(QuestItem)slot]]), - ImVec2(INV_GRID_ICON_SIZE / 1.5f, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), colorTint)) { + if (ImGui::ImageButton(std::to_string(slot).c_str(), + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[questToItemMap[(QuestItem)slot]]), + ImVec2(INV_GRID_ICON_SIZE / 1.5f, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), colorTint)) { NextQuestInSlot(slot); } if (ImGui::IsItemHovered()) { @@ -791,7 +820,8 @@ void DrawQuestStatusTab() { SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_GILDED); if (gPlayState) { Player_SetEquipmentData(gPlayState, GET_PLAYER(gPlayState)); - BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = + ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_B); } } @@ -809,22 +839,28 @@ void DrawQuestStatusTab() { SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_KOKIRI); if (gPlayState) { Player_SetEquipmentData(gPlayState, GET_PLAYER(gPlayState)); - BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = + ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_B); } } - } - ImGui::BeginChild("remainsBox", ImVec2(INV_GRID_WIDTH * 4 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 1 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("remainsBox", + ImVec2(INV_GRID_WIDTH * 4 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 1 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Boss Remains"); for (int32_t i = QUEST_REMAINS_ODOLWA; i <= QUEST_REMAINS_TWINMOLD; i++) { QuestItem slot = static_cast(i); - + DrawQuestSlot(slot); } ImGui::EndChild(); - ImGui::BeginChild("songBox", ImVec2((INV_GRID_WIDTH / 1.1f) * 6 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 2.15f + INV_GRID_PADDING * 1 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("songBox", + ImVec2((INV_GRID_WIDTH / 1.1f) * 6 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 2.15f + INV_GRID_PADDING * 1 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Songs"); for (int32_t i = QUEST_SONG_TIME; i <= QUEST_SONG_SUN; i++) { DrawSong((QuestItem)i); @@ -833,39 +869,64 @@ void DrawQuestStatusTab() { DrawSong((QuestItem)i); } ImGui::EndChild(); - ImGui::BeginChild("equipBox", ImVec2(INV_GRID_WIDTH * 2.2 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 1 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("equipBox", + ImVec2(INV_GRID_WIDTH * 2.2 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 1 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Equipment"); if (GET_PLAYER_FORM == PLAYER_FORM_FIERCE_DEITY) { - ImTextureID swordTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[ITEM_SWORD_DEITY]); - ImGui::ImageButton(std::to_string(ITEM_SWORD_DEITY).c_str(), swordTextureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); + ImTextureID swordTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[ITEM_SWORD_DEITY]); + ImGui::ImageButton(std::to_string(ITEM_SWORD_DEITY).c_str(), swordTextureId, + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)); } else { - ImTextureID swordTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI]); - if (ImGui::ImageButton(std::to_string(ITEM_SWORD_KOKIRI).c_str(), swordTextureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { + ImTextureID swordTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*) + gItemIcons[ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI]); + if (ImGui::ImageButton(std::to_string(ITEM_SWORD_KOKIRI).c_str(), swordTextureId, + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { NextQuestInSlot(QUEST_SWORD); } } ImGui::SameLine(); if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) == EQUIP_VALUE_SHIELD_HERO) { - ImTextureID shieldTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[ITEM_SHIELD_HERO]); - if (ImGui::ImageButton(std::to_string(ITEM_SHIELD_HERO).c_str(), shieldTextureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { + ImTextureID shieldTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[ITEM_SHIELD_HERO]); + if (ImGui::ImageButton(std::to_string(ITEM_SHIELD_HERO).c_str(), shieldTextureId, + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { NextQuestInSlot(QUEST_SHIELD); } } else { - ImTextureID shieldTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[ITEM_SHIELD_MIRROR]); - if (ImGui::ImageButton(std::to_string(ITEM_SHIELD_MIRROR).c_str(), shieldTextureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { + ImTextureID shieldTextureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[ITEM_SHIELD_MIRROR]); + if (ImGui::ImageButton(std::to_string(ITEM_SHIELD_MIRROR).c_str(), shieldTextureId, + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1))) { NextQuestInSlot(QUEST_SHIELD); } } ImGui::EndChild(); ImGui::SameLine(); - ImGui::BeginChild("notebookBox", ImVec2(INV_GRID_WIDTH * 1 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 1 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("notebookBox", + ImVec2(INV_GRID_WIDTH * 1 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 1 + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Bombers"); - ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName((const char*)gItemIcons[ITEM_BOMBERS_NOTEBOOK]); - if (ImGui::ImageButton(std::to_string(ITEM_BOMBERS_NOTEBOOK).c_str(), textureId, ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK) ? 1.0f : 0.4f))) { + ImTextureID textureId = Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName( + (const char*)gItemIcons[ITEM_BOMBERS_NOTEBOOK]); + if (ImGui::ImageButton(std::to_string(ITEM_BOMBERS_NOTEBOOK).c_str(), textureId, + ImVec2(INV_GRID_ICON_SIZE, INV_GRID_ICON_SIZE), ImVec2(0, 0), ImVec2(1, 1), + ImVec4(0, 0, 0, 0), + ImVec4(1, 1, 1, CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK) ? 1.0f : 0.4f))) { NextQuestInSlot(QUEST_BOMBERS_NOTEBOOK); } ImGui::EndChild(); - ImGui::BeginChild("heartshapedBox", ImVec2(INV_GRID_WIDTH * 2 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT + INV_GRID_PADDING), ImGuiChildFlags_Border); + ImGui::BeginChild("heartshapedBox", + ImVec2(INV_GRID_WIDTH * 2 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT + INV_GRID_PADDING), + ImGuiChildFlags_Border); ImGui::Text("Heart Pieces"); int32_t pohCount = (gSaveContext.save.saveInfo.inventory.questItems & 0xF0000000) >> 28; UIWidgets::PushStyleCombobox(UIWidgets::Colors::Red); @@ -926,7 +987,10 @@ void DrawPlayerTab() { if (gPlayState) { Player* player = GET_PLAYER(gPlayState); - ImGui::BeginChild("playerLocation", ImVec2(INV_GRID_WIDTH * 8 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 1.75f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("playerLocation", + ImVec2(INV_GRID_WIDTH * 8 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 1.75f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); GetPlayerForm(GET_PLAYER_FORM); ImGui::Text("%s Link", curForm); @@ -949,7 +1013,10 @@ void DrawPlayerTab() { UIWidgets::PopStyleCombobox(); ImGui::EndChild(); - ImGui::BeginChild("playerSpeed", ImVec2(INV_GRID_WIDTH * 5 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 2.75f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("playerSpeed", + ImVec2(INV_GRID_WIDTH * 5 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 2.75f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Link's Speed"); UIWidgets::PushStyleCombobox(formColor); ImGui::PushItemWidth(ImGui::GetFontSize() * 6); @@ -963,7 +1030,10 @@ void DrawPlayerTab() { UIWidgets::PopStyleCombobox(); ImGui::EndChild(); - ImGui::BeginChild("playerForm", ImVec2(INV_GRID_WIDTH * 8 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 2.2f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("playerForm", + ImVec2(INV_GRID_WIDTH * 8 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 2.2f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Change Link's Current Form"); for (int i = PLAYER_FORM_FIERCE_DEITY; i <= PLAYER_FORM_HUMAN; i++) { GetPlayerForm(i); @@ -977,7 +1047,8 @@ void DrawPlayerTab() { func_8012F73C(&gPlayState->objectCtx, player->actor.objectSlot, objectId); player->actor.objectSlot = Object_GetSlot(&gPlayState->objectCtx, GAMEPLAY_KEEP); gSaveContext.save.playerForm = i; - s32 objectSlot = Object_GetSlot(&gPlayState->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); + s32 objectSlot = + Object_GetSlot(&gPlayState->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); player->actor.objectSlot = objectSlot; player->actor.shape.rot.z = GET_PLAYER_FORM + 1; player->actor.init = PlayerCall_Init; @@ -1014,7 +1085,8 @@ void DrawPlayerTab() { if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_RAZOR) { gSaveContext.save.saveInfo.playerData.swordHealth = 100; } - BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_B) = + ITEM_SWORD_KOKIRI + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) - EQUIP_VALUE_SWORD_KOKIRI; Interface_LoadItemIconImpl(gPlayState, EQUIP_SLOT_B); } if (isSelected) { @@ -1037,10 +1109,10 @@ void DrawPlayerTab() { } ImGui::EndCombo(); } - + ImGui::PopItemWidth(); UIWidgets::PopStyleCombobox(); - + } else { ImGui::Separator(); ImGui::Text(" No Equipment in this Form"); @@ -1048,9 +1120,13 @@ void DrawPlayerTab() { } ImGui::EndChild(); - ImGui::BeginChild("playerStates", ImVec2(INV_GRID_WIDTH * 8 + INV_GRID_PADDING * 2, INV_GRID_HEIGHT * 0.75f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), ImGuiChildFlags_Border); + ImGui::BeginChild("playerStates", + ImVec2(INV_GRID_WIDTH * 8 + INV_GRID_PADDING * 2, + INV_GRID_HEIGHT * 0.75f + INV_GRID_PADDING * 2 + INV_GRID_TOP_MARGIN), + ImGuiChildFlags_Border); ImGui::Text("Player States"); - uint32_t states[4] = { player->stateFlags1, player->stateFlags2, player->stateFlags3, player->meleeWeaponState }; + uint32_t states[4] = { player->stateFlags1, player->stateFlags2, player->stateFlags3, + player->meleeWeaponState }; if (ImGui::BeginTable("stateTable", 4)) { GetPlayerForm(GET_PLAYER_FORM); @@ -1080,44 +1156,20 @@ void DrawPlayerTab() { } const char* regGroupNames[] = { - "REG (0)", - "SREG (1)", - "OREG (2)", - "PREG (3)", - "QREG (4)", - "MREG (5)", - "YREG (6)", - "DREG (7)", - "UREG (8)", - "IREG (9)", - "ZREG (10)", - "CREG (11)", - "NREG (12)", - "KREG (13)", - "XREG (14)", - "cREG (15)", - "sREG (16)", - "iREG (17)", - "WREG (18)", - "AREG (19)", - "VREG (20)", - "HREG (21)", - "GREG (22)", - "mREG (23)", - "nREG (24)", - "BREG (25)", - "dREG (26)", - "kREG (27)", - "bREG (28)", + "REG (0)", "SREG (1)", "OREG (2)", "PREG (3)", "QREG (4)", "MREG (5)", "YREG (6)", "DREG (7)", + "UREG (8)", "IREG (9)", "ZREG (10)", "CREG (11)", "NREG (12)", "KREG (13)", "XREG (14)", "cREG (15)", + "sREG (16)", "iREG (17)", "WREG (18)", "AREG (19)", "VREG (20)", "HREG (21)", "GREG (22)", "mREG (23)", + "nREG (24)", "BREG (25)", "dREG (26)", "kREG (27)", "bREG (28)", }; // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, humanName) \ +#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \ + _entranceSceneId, _betterMapSelectIndex, humanName) \ { enumValue, humanName }, #define DEFINE_SCENE_UNSET(_enumValue) std::unordered_map sceneList = { -#include "tables/scene_table.h" +#include "tables/scene_table.h" }; #undef DEFINE_SCENE @@ -1125,7 +1177,8 @@ std::unordered_map sceneList = { void DrawRegEditorTab() { UIWidgets::PushStyleSlider(); - ImGui::SliderScalar("Reg Group", ImGuiDataType_U8, &gRegEditor->regGroup, &S8_ZERO, ®_GROUPS_MAX, regGroupNames[gRegEditor->regGroup]); + ImGui::SliderScalar("Reg Group", ImGuiDataType_U8, &gRegEditor->regGroup, &S8_ZERO, ®_GROUPS_MAX, + regGroupNames[gRegEditor->regGroup]); ImGui::SliderScalar("Reg Page", ImGuiDataType_U8, &gRegEditor->regPage, &S8_ZERO, ®_PAGES_MAX, "%d"); UIWidgets::PopStyleSlider(); @@ -1140,7 +1193,10 @@ void DrawRegEditorTab() { ImGui::PushStyleColor(ImGuiCol_FrameBg, UIWidgets::Colors::Gray); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); - ImGui::InputScalar("##regInput", ImGuiDataType_S16, &gRegEditor->data[i + gRegEditor->regPage * REG_PER_PAGE + gRegEditor->regGroup * REG_PER_PAGE * REG_PAGES], NULL, NULL, "%d"); + ImGui::InputScalar( + "##regInput", ImGuiDataType_S16, + &gRegEditor->data[i + gRegEditor->regPage * REG_PER_PAGE + gRegEditor->regGroup * REG_PER_PAGE * REG_PAGES], + NULL, NULL, "%d"); ImGui::PopStyleVar(2); ImGui::PopStyleColor(1); ImGui::EndGroup(); @@ -1152,13 +1208,8 @@ void DrawRegEditorTab() { } const char* flagEditorSections[] = { - "currentSceneFlags", - "weekEventReg", - "eventInf", - "scenesVisible", - "owlActivation", - "permanentSceneFlags", - "cycleSceneFlags", + "currentSceneFlags", "weekEventReg", "eventInf", "scenesVisible", + "owlActivation", "permanentSceneFlags", "cycleSceneFlags", }; void DrawFlagsTab() { @@ -1166,24 +1217,26 @@ void DrawFlagsTab() { ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 8.0f)); ImGui::BeginChild("flagsBox", ImVec2(0, 0), true); static int selectedFlagSection = 0; - UIWidgets::Combobox("Flag Type", &selectedFlagSection, flagEditorSections, { - .alignment = UIWidgets::ComponentAlignment::Left, - .labelPosition = UIWidgets::LabelPosition::None, - }); + UIWidgets::Combobox("Flag Type", &selectedFlagSection, flagEditorSections, + { + .alignment = UIWidgets::ComponentAlignment::Left, + .labelPosition = UIWidgets::LabelPosition::None, + }); static int16_t selectedScene = 0; if (selectedFlagSection == 5 || selectedFlagSection == 6) { ImGui::SameLine(); - UIWidgets::Combobox("Scene", &selectedScene, sceneList, { - .alignment = UIWidgets::ComponentAlignment::Left, - .labelPosition = UIWidgets::LabelPosition::None, - }); + UIWidgets::Combobox("Scene", &selectedScene, sceneList, + { + .alignment = UIWidgets::ComponentAlignment::Left, + .labelPosition = UIWidgets::LabelPosition::None, + }); if (gPlayState != NULL) { ImGui::SameLine(); if (UIWidgets::Button("Current", { - .color = UIWidgets::Colors::Gray, - .size = UIWidgets::Sizes::Inline, - })) { + .color = UIWidgets::Colors::Gray, + .size = UIWidgets::Sizes::Inline, + })) { selectedScene = gPlayState->sceneId; } } @@ -1201,11 +1254,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switches[0]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switches0", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switches0", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[0] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switches0", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switches0", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[0] = 0; } UIWidgets::DrawFlagArray32("##switches0", gPlayState->actorCtx.sceneFlags.switches[0]); @@ -1215,11 +1270,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switches[1]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switches1", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switches1", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[1] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switches1", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switches1", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[1] = 0; } UIWidgets::DrawFlagArray32("##switches1", gPlayState->actorCtx.sceneFlags.switches[1]); @@ -1228,11 +1285,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switches[2]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switches2", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switches2", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[2] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switches2", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switches2", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[2] = 0; } UIWidgets::DrawFlagArray32("##switches2", gPlayState->actorCtx.sceneFlags.switches[2]); @@ -1242,11 +1301,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switches[3]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switches3", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switches3", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[3] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switches3", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switches3", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.switches[3] = 0; } UIWidgets::DrawFlagArray32("##switches3", gPlayState->actorCtx.sceneFlags.switches[3]); @@ -1255,11 +1316,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("chest"); ImGui::SameLine(110); - if (UIWidgets::Button("All##chest", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##chest", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.chest = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##chest", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##chest", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.chest = 0; } UIWidgets::DrawFlagArray32("##chest", gPlayState->actorCtx.sceneFlags.chest); @@ -1269,11 +1332,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("clearedRoom"); ImGui::SameLine(110); - if (UIWidgets::Button("All##clearedRoom", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##clearedRoom", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.clearedRoom = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##clearedRoom", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##clearedRoom", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.clearedRoom = 0; } UIWidgets::DrawFlagArray32("##clearedRoom", gPlayState->actorCtx.sceneFlags.clearedRoom); @@ -1282,11 +1347,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("clearedRoomTemp"); ImGui::SameLine(110); - if (UIWidgets::Button("All##clearedRoomTemp", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##clearedRoomTemp", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.clearedRoomTemp = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##clearedRoomTemp", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##clearedRoomTemp", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.clearedRoomTemp = 0; } UIWidgets::DrawFlagArray32("##clearedRoomTemp", gPlayState->actorCtx.sceneFlags.clearedRoomTemp); @@ -1296,11 +1363,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("collectible[0]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##collectible0", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##collectible0", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[0] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##collectible0", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##collectible0", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[0] = 0; } UIWidgets::DrawFlagArray32("##collectible0", gPlayState->actorCtx.sceneFlags.collectible[0]); @@ -1309,11 +1378,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("collectible[1]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##collectible1", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##collectible1", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[1] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##collectible1", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##collectible1", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[1] = 0; } UIWidgets::DrawFlagArray32("##collectible1", gPlayState->actorCtx.sceneFlags.collectible[1]); @@ -1323,11 +1394,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("collectible[2]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##collectible2", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##collectible2", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[2] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##collectible2", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##collectible2", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[2] = 0; } UIWidgets::DrawFlagArray32("##collectible2", gPlayState->actorCtx.sceneFlags.collectible[2]); @@ -1336,11 +1409,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("collectible[3]"); ImGui::SameLine(110); - if (UIWidgets::Button("All##collectible3", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##collectible3", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[3] = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##collectible3", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##collectible3", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gPlayState->actorCtx.sceneFlags.collectible[3] = 0; } UIWidgets::DrawFlagArray32("##collectible3", gPlayState->actorCtx.sceneFlags.collectible[3]); @@ -1365,15 +1440,17 @@ void DrawFlagsTab() { } break; case 3: - if (UIWidgets::Button("All##scenesVisible", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##scenesVisible", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { for (int i = 0; i < 7; i++) { - gSaveContext.save.saveInfo.scenesVisible[i] = UINT32_MAX; + gSaveContext.save.saveInfo.scenesVisible[i] = UINT32_MAX; } } ImGui::SameLine(); - if (UIWidgets::Button("Clear##scenesVisible", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##scenesVisible", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { for (int i = 0; i < 7; i++) { - gSaveContext.save.saveInfo.scenesVisible[i] = 0; + gSaveContext.save.saveInfo.scenesVisible[i] = 0; } } for (int i = 0; i < 7; i++) { @@ -1383,11 +1460,13 @@ void DrawFlagsTab() { } break; case 4: - if (UIWidgets::Button("All##scenesVisible", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##scenesVisible", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.playerData.owlActivationFlags = UINT16_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##scenesVisible", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##scenesVisible", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.playerData.owlActivationFlags = 0; } UIWidgets::DrawFlagArray16("##scenesVisible", gSaveContext.save.saveInfo.playerData.owlActivationFlags); @@ -1397,11 +1476,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("chest"); ImGui::SameLine(110); - if (UIWidgets::Button("All##chest", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##chest", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].chest = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##chest", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##chest", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].chest = 0; } UIWidgets::DrawFlagArray32("##chest", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].chest); @@ -1411,78 +1492,95 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switch0"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switch0", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switch0", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch0 = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switch0", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switch0", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch0 = 0; } - UIWidgets::DrawFlagArray32("##switch0", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch0); + UIWidgets::DrawFlagArray32("##switch0", + gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch0); ImGui::EndGroup(); ImGui::BeginGroup(); ImGui::AlignTextToFramePadding(); ImGui::Text("collectible"); ImGui::SameLine(110); - if (UIWidgets::Button("All##collectible", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##collectible", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].collectible = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##collectible", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##collectible", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].collectible = 0; } - UIWidgets::DrawFlagArray32("##collectible", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].collectible); + UIWidgets::DrawFlagArray32("##collectible", + gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].collectible); ImGui::EndGroup(); ImGui::SameLine(0, 10.0f); ImGui::BeginGroup(); ImGui::AlignTextToFramePadding(); ImGui::Text("switch1"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switch1", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switch1", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch1 = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switch1", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switch1", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch1 = 0; } - UIWidgets::DrawFlagArray32("##switch1", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch1); + UIWidgets::DrawFlagArray32("##switch1", + gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch1); ImGui::EndGroup(); ImGui::BeginGroup(); ImGui::AlignTextToFramePadding(); ImGui::Text("clearedRoom"); ImGui::SameLine(110); - if (UIWidgets::Button("All##clearedRoom", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##clearedRoom", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].clearedRoom = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##clearedRoom", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##clearedRoom", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].clearedRoom = 0; } - UIWidgets::DrawFlagArray32("##clearedRoom", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].clearedRoom); + UIWidgets::DrawFlagArray32("##clearedRoom", + gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].clearedRoom); ImGui::EndGroup(); ImGui::SameLine(0, 10.0f); ImGui::BeginGroup(); ImGui::AlignTextToFramePadding(); ImGui::Text("unk_14"); ImGui::SameLine(110); - if (UIWidgets::Button("All##unk_14", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##unk_14", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].unk_14 = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##unk_14", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##unk_14", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].unk_14 = 0; } - UIWidgets::DrawFlagArray32("##unk_14", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].unk_14); + UIWidgets::DrawFlagArray32("##unk_14", + gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].unk_14); ImGui::EndGroup(); ImGui::BeginGroup(); ImGui::AlignTextToFramePadding(); ImGui::Text("rooms"); ImGui::SameLine(110); - if (UIWidgets::Button("All##rooms", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##rooms", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].rooms = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##rooms", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##rooms", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].rooms = 0; } UIWidgets::DrawFlagArray32("##rooms", gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].rooms); @@ -1493,11 +1591,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("chest"); ImGui::SameLine(110); - if (UIWidgets::Button("All##chest", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##chest", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].chest = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##chest", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##chest", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].chest = 0; } UIWidgets::DrawFlagArray32("##chest", gSaveContext.cycleSceneFlags[selectedScene].chest); @@ -1507,11 +1607,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switch0"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switch0", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switch0", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch0 = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switch0", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switch0", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch0 = 0; } UIWidgets::DrawFlagArray32("##switch0", gSaveContext.cycleSceneFlags[selectedScene].switch0); @@ -1520,11 +1622,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("collectible"); ImGui::SameLine(110); - if (UIWidgets::Button("All##collectible", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##collectible", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].collectible = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##collectible", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##collectible", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].collectible = 0; } UIWidgets::DrawFlagArray32("##collectible", gSaveContext.cycleSceneFlags[selectedScene].collectible); @@ -1534,11 +1638,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("switch1"); ImGui::SameLine(110); - if (UIWidgets::Button("All##switch1", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##switch1", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch1 = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##switch1", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##switch1", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].switch1 = 0; } UIWidgets::DrawFlagArray32("##switch1", gSaveContext.cycleSceneFlags[selectedScene].switch1); @@ -1547,11 +1653,13 @@ void DrawFlagsTab() { ImGui::AlignTextToFramePadding(); ImGui::Text("clearedRoom"); ImGui::SameLine(110); - if (UIWidgets::Button("All##clearedRoom", { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("All##clearedRoom", + { .color = UIWidgets::Colors::Gray, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].clearedRoom = UINT32_MAX; } ImGui::SameLine(); - if (UIWidgets::Button("Clear##clearedRoom", { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { + if (UIWidgets::Button("Clear##clearedRoom", + { .color = UIWidgets::Colors::Red, .size = UIWidgets::Sizes::Inline })) { gSaveContext.save.saveInfo.permanentSceneFlags[selectedScene].clearedRoom = 0; } UIWidgets::DrawFlagArray32("##clearedRoom", gSaveContext.cycleSceneFlags[selectedScene].clearedRoom); @@ -1564,7 +1672,7 @@ void DrawFlagsTab() { } void SaveEditorWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(480,600), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(480, 600), ImGuiCond_FirstUseEver); if (!ImGui::Begin("Save Editor", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { ImGui::End(); return; diff --git a/mm/2s2h/DeveloperTools/SaveEditor.h b/mm/2s2h/DeveloperTools/SaveEditor.h index 415fd3949..0119ae05f 100644 --- a/mm/2s2h/DeveloperTools/SaveEditor.h +++ b/mm/2s2h/DeveloperTools/SaveEditor.h @@ -3,10 +3,10 @@ #include class SaveEditorWindow : public Ship::GuiWindow { - public: - using GuiWindow::GuiWindow; + public: + using GuiWindow::GuiWindow; - void InitElement() override; - void DrawElement() override; - void UpdateElement() override {}; + void InitElement() override; + void DrawElement() override; + void UpdateElement() override{}; }; diff --git a/mm/2s2h/DeveloperTools/WarpPoint.cpp b/mm/2s2h/DeveloperTools/WarpPoint.cpp index c1e57ae2a..1bf27dee7 100644 --- a/mm/2s2h/DeveloperTools/WarpPoint.cpp +++ b/mm/2s2h/DeveloperTools/WarpPoint.cpp @@ -15,19 +15,21 @@ extern SaveContext gSaveContext; #define CV "gDeveloperTools.WarpPoint." // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, humanName) \ +#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, _restrictionFlags, _persistentCycleFlags, \ + _entranceSceneId, _betterMapSelectIndex, humanName) \ { enumValue, humanName }, #define DEFINE_SCENE_UNSET(_enumValue) std::unordered_map warpPointSceneList = { -#include "tables/scene_table.h" +#include "tables/scene_table.h" }; #undef DEFINE_SCENE #undef DEFINE_SCENE_UNSET void RenderWarpPointSection() { - if (gPlayState == NULL) return; + if (gPlayState == NULL) + return; if (UIWidgets::Button("Set Warp Point")) { Player* player = GET_PLAYER(gPlayState); @@ -58,14 +60,12 @@ void RenderWarpPointSection() { } ImGui::SameLine(); if (UIWidgets::Button("Warp", { .size = UIWidgets::Sizes::Inline })) { - Vec3f pos = { CVarGetFloat(CV "X", 0.0f), - CVarGetFloat(CV "Y", 0.0f), - CVarGetFloat(CV "Z", 0.0f) }; + Vec3f pos = { CVarGetFloat(CV "X", 0.0f), CVarGetFloat(CV "Y", 0.0f), CVarGetFloat(CV "Z", 0.0f) }; - Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_DOWN, - CVarGetInteger(CV "Entrance", ENTRANCE(SOUTH_CLOCK_TOWN, 0)), - CVarGetInteger(CV "Room", 0), PLAYER_PARAMS(0xFF, PLAYER_INITMODE_D), - &pos, CVarGetFloat(CV "Rotation", 0.0f)); + Play_SetRespawnData(&gPlayState->state, RESPAWN_MODE_DOWN, + CVarGetInteger(CV "Entrance", ENTRANCE(SOUTH_CLOCK_TOWN, 0)), + CVarGetInteger(CV "Room", 0), PLAYER_PARAMS(0xFF, PLAYER_INITMODE_D), &pos, + CVarGetFloat(CV "Rotation", 0.0f)); func_80169EFC(&gPlayState->state); } } diff --git a/mm/2s2h/Enhancements/Camera/DebugCam.cpp b/mm/2s2h/Enhancements/Camera/DebugCam.cpp index c38d535cd..0014a3f5d 100644 --- a/mm/2s2h/Enhancements/Camera/DebugCam.cpp +++ b/mm/2s2h/Enhancements/Camera/DebugCam.cpp @@ -25,9 +25,12 @@ Vec3f Camera_RotatePointAroundAxis(Vec3f* point, Vec3f* axis, s16 angle) { f32 q3 = Math_SinS(angle / 2) * axis->z; Vec3f endPoint; - endPoint.x = (SQ(q0) + SQ(q1) - SQ(q2) - SQ(q3)) * point->x + 2 * (q1 * q2 - q0 * q3) * point->y + 2 * (q1 * q3 + q0 * q2) * point->z; - endPoint.y = 2 * (q2 * q1 + q0 * q3) * point->x + (SQ(q0) - SQ(q1) + SQ(q2) - SQ(q3)) * point->y + 2 * (q2 * q3 - q0 * q1) * point->z; - endPoint.z = 2 * (q3 * q1 - q0 * q2) * point->x + 2 * (q3 * q2 + q0 * q1) * point->y + (SQ(q0) - SQ(q1) - SQ(q2) + SQ(q3)) * point->z; + endPoint.x = (SQ(q0) + SQ(q1) - SQ(q2) - SQ(q3)) * point->x + 2 * (q1 * q2 - q0 * q3) * point->y + + 2 * (q1 * q3 + q0 * q2) * point->z; + endPoint.y = 2 * (q2 * q1 + q0 * q3) * point->x + (SQ(q0) - SQ(q1) + SQ(q2) - SQ(q3)) * point->y + + 2 * (q2 * q3 - q0 * q1) * point->z; + endPoint.z = 2 * (q3 * q1 - q0 * q2) * point->x + 2 * (q3 * q2 + q0 * q1) * point->y + + (SQ(q0) - SQ(q1) - SQ(q2) + SQ(q3)) * point->z; return endPoint; } @@ -53,8 +56,8 @@ void Camera_SetRollFromUp(Camera* camera) { // ( preRollUp.x up->x normal.x) // ( preRollUp.y up->y normal.y) // ( preRollUp.z up->z normal.z) - f32 det = preRollUp.x * up->y * normal.z + up->x * normal.y * preRollUp.z + normal.x * preRollUp.y * up->z - - normal.x * up->y * preRollUp.z - normal.y * up->z * preRollUp.x - normal.z * up->x * preRollUp.y; + f32 det = preRollUp.x * up->y * normal.z + up->x * normal.y * preRollUp.z + normal.x * preRollUp.y * up->z - + normal.x * up->y * preRollUp.z - normal.y * up->z * preRollUp.x - normal.z * up->x * preRollUp.y; camera->roll = RAD_TO_BINANG(atan2(-det, -dot) - M_PI); } @@ -84,11 +87,8 @@ void Camera_Rotate6DOF(Camera* camera, f32 pitchDiff, f32 yawDiff) { Vec3f right; Math3D_Vec3f_Cross(up, &camOut, &right); Math3D_Normalize(&right); - Vec3f force = { - up->x * pitchDiff + right.x * yawDiff, - up->y * pitchDiff + right.y * yawDiff, - up->z * pitchDiff + right.z * yawDiff - }; + Vec3f force = { up->x * pitchDiff + right.x * yawDiff, up->y * pitchDiff + right.y * yawDiff, + up->z * pitchDiff + right.z * yawDiff }; f32 angle = Math3D_Vec3fMagnitude(&force); Vec3f rotAxis; @@ -125,7 +125,7 @@ void Camera_DebugCam(Camera* camera) { CVarSetInteger("gEnhancements.Camera.DebugCam.Port", CAMERA_DEBUG_DEFAULT_PORT); } - /* + /* Camera Speed */ @@ -134,22 +134,27 @@ void Camera_DebugCam(Camera* camera) { camSpeed *= 3.0f; } - /* + /* Camera distance */ // Transition speed set to be responsive f32 transitionSpeed = camSpeed * 200.0f; - distTarget = camera->dist + (CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DDOWN) - CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DUP)) * 1200.0f * camSpeed; + distTarget = camera->dist + (CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DDOWN) - + CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DUP)) * + 1200.0f * camSpeed; distTarget = CLAMP_MIN(distTarget, 0.1f); // Smooth step camera away to max camera distance. - camera->dist = Camera_ScaledStepToCeilF(distTarget, camera->dist, transitionSpeed / (ABS(distTarget - camera->dist) + transitionSpeed), 0.0f); + camera->dist = Camera_ScaledStepToCeilF(distTarget, camera->dist, + transitionSpeed / (ABS(distTarget - camera->dist) + transitionSpeed), 0.0f); - /* + /* Set Camera Pitch and Yaw */ - f32 yawDiff = -sCamPlayState->state.input[controllerPort].cur.right_stick_x * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.X", 1.0f)); - f32 pitchDiff = sCamPlayState->state.input[controllerPort].cur.right_stick_y * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.Y", 1.0f)); + f32 yawDiff = -sCamPlayState->state.input[controllerPort].cur.right_stick_x * 10.0f * + (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.X", 1.0f)); + f32 pitchDiff = sCamPlayState->state.input[controllerPort].cur.right_stick_y * 10.0f * + (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.Y", 1.0f)); yawDiff *= GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_X); pitchDiff *= -GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_Y); @@ -161,22 +166,26 @@ void Camera_DebugCam(Camera* camera) { Camera_RotateGeographic(camera, pitchDiff, yawDiff); } - /* + /* Camera Roll */ if (CVarGetInteger("gEnhancements.Camera.DebugCam.6DOF", 0)) { - camera->roll += (CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DLEFT) - CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DRIGHT)) * 1200.0f * camSpeed; + camera->roll += (CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DLEFT) - + CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_DRIGHT)) * + 1200.0f * camSpeed; } else { camera->roll = Camera_ScaledStepToCeilS(0, camera->roll, 0.1f, 5); } - /* + /* Camera Movement */ - + // Movement differences from the point of view of the camera. Use max stick value for buttons scale Vec3f posDiff; posDiff.x = sCamPlayState->state.input[controllerPort].cur.stick_x * camSpeed; - posDiff.y = (CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_Z) - CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_R)) * 120.0f * camSpeed; + posDiff.y = (CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_Z) - + CHECK_BTN_ANY(sCamPlayState->state.input[controllerPort].cur.button, BTN_R)) * + 120.0f * camSpeed; posDiff.z = -sCamPlayState->state.input[controllerPort].cur.stick_y * camSpeed; // Adjust movement to camera's current direction @@ -228,16 +237,18 @@ void RegisterDebugCam() { *should = false; }); - freeCamDisableInputsId = GameInteractor::Instance->RegisterGameHook([](Input* input) { - s32 controllerPort = CVarGetInteger("gEnhancements.Camera.DebugCam.Port", CAMERA_DEBUG_DEFAULT_PORT) - 1; - if (controllerPort > 3 || controllerPort < 0) { - controllerPort = CAMERA_DEBUG_DEFAULT_PORT - 1; - CVarSetInteger("gEnhancements.Camera.DebugCam.Port", CAMERA_DEBUG_DEFAULT_PORT); - } - if (controllerPort == 0) { - // Disable Link Inputs - memset(input, 0, sizeof(Input)); - } - }); + freeCamDisableInputsId = + GameInteractor::Instance->RegisterGameHook([](Input* input) { + s32 controllerPort = + CVarGetInteger("gEnhancements.Camera.DebugCam.Port", CAMERA_DEBUG_DEFAULT_PORT) - 1; + if (controllerPort > 3 || controllerPort < 0) { + controllerPort = CAMERA_DEBUG_DEFAULT_PORT - 1; + CVarSetInteger("gEnhancements.Camera.DebugCam.Port", CAMERA_DEBUG_DEFAULT_PORT); + } + if (controllerPort == 0) { + // Disable Link Inputs + memset(input, 0, sizeof(Input)); + } + }); } } diff --git a/mm/2s2h/Enhancements/Camera/FreeLook.cpp b/mm/2s2h/Enhancements/Camera/FreeLook.cpp index 5d9a76219..63a94f0d0 100644 --- a/mm/2s2h/Enhancements/Camera/FreeLook.cpp +++ b/mm/2s2h/Enhancements/Camera/FreeLook.cpp @@ -90,8 +90,10 @@ bool Camera_FreeLook(Camera* camera) { Camera_ResetActionFuncState(camera, camera->mode); - f32 yawDiff = -sCamPlayState->state.input[0].cur.right_stick_x * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.X", 1.0f)); - f32 pitchDiff = sCamPlayState->state.input[0].cur.right_stick_y * 10.0f * (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.Y", 1.0f)); + f32 yawDiff = -sCamPlayState->state.input[0].cur.right_stick_x * 10.0f * + (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.X", 1.0f)); + f32 pitchDiff = sCamPlayState->state.input[0].cur.right_stick_y * 10.0f * + (CVarGetFloat("gEnhancements.Camera.RightStick.CameraSensitivity.Y", 1.0f)); yaw += yawDiff * GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_X); pitch += pitchDiff * -GameInteractor_InvertControl(GI_INVERT_CAMERA_RIGHT_STICK_Y); @@ -109,7 +111,8 @@ bool Camera_FreeLook(Camera* camera) { f32 distTarget = CVarGetInteger("gEnhancements.Camera.FreeLook.MaxCameraDistance", roData->unk_04); f32 transitionSpeed = CVarGetInteger("gEnhancements.Camera.FreeLook.TransitionSpeed", 25); // Smooth step camera away to max camera distance. Camera collision is calculated later - camera->dist = Camera_ScaledStepToCeilF(distTarget, camera->dist, transitionSpeed / (ABS(distTarget - camera->dist) + transitionSpeed), 0.0f); + camera->dist = Camera_ScaledStepToCeilF(distTarget, camera->dist, + transitionSpeed / (ABS(distTarget - camera->dist) + transitionSpeed), 0.0f); // Setup new camera angle based on the calculations from stick inputs eyeAdjustment.r = camera->dist; @@ -146,38 +149,40 @@ static uint32_t freeLookCameraVBHookId = 0; void RegisterCameraFreeLook() { if (freeLookCameraVBHookId) { - GameInteractor::Instance->UnregisterGameHookForID(freeLookCameraVBHookId); + GameInteractor::Instance->UnregisterGameHookForID( + freeLookCameraVBHookId); freeLookCameraVBHookId = 0; } if (freeLookCameraSettingChangeHookId) { - GameInteractor::Instance->UnregisterGameHook(freeLookCameraSettingChangeHookId); + GameInteractor::Instance->UnregisterGameHook( + freeLookCameraSettingChangeHookId); freeLookCameraSettingChangeHookId = 0; } if (CVarGetInteger("gEnhancements.Camera.FreeLook.Enable", 0)) { freeLookCameraVBHookId = REGISTER_VB_SHOULD(GI_VB_USE_CUSTOM_CAMERA, { - Camera* camera = static_cast(opt); - switch (sCameraSettings[camera->setting].cameraModes[camera->mode].funcId) { - case CAM_FUNC_NORMAL0: - case CAM_FUNC_NORMAL1: - case CAM_FUNC_NORMAL3: - case CAM_FUNC_NORMAL4: - case CAM_FUNC_JUMP2: - case CAM_FUNC_JUMP3: - case CAM_FUNC_BATTLE1: - case CAM_FUNC_UNIQUE2: - if (Camera_CanFreeLook(camera)) { - Camera_FreeLook(camera); - *should = false; - } - break; - default: - break; - } - }); - freeLookCameraSettingChangeHookId = GameInteractor::Instance->RegisterGameHook([](Camera* camera) { - UpdateFreeLookState(camera); + Camera* camera = static_cast(opt); + switch (sCameraSettings[camera->setting].cameraModes[camera->mode].funcId) { + case CAM_FUNC_NORMAL0: + case CAM_FUNC_NORMAL1: + case CAM_FUNC_NORMAL3: + case CAM_FUNC_NORMAL4: + case CAM_FUNC_JUMP2: + case CAM_FUNC_JUMP3: + case CAM_FUNC_BATTLE1: + case CAM_FUNC_UNIQUE2: + if (Camera_CanFreeLook(camera)) { + Camera_FreeLook(camera); + *should = false; + } + break; + default: + break; + } }); + freeLookCameraSettingChangeHookId = + GameInteractor::Instance->RegisterGameHook( + [](Camera* camera) { UpdateFreeLookState(camera); }); } } diff --git a/mm/2s2h/Enhancements/Cheats/Infinite.cpp b/mm/2s2h/Enhancements/Cheats/Infinite.cpp index 2cebeca2e..182bd8338 100644 --- a/mm/2s2h/Enhancements/Cheats/Infinite.cpp +++ b/mm/2s2h/Enhancements/Cheats/Infinite.cpp @@ -5,7 +5,8 @@ void RegisterInfiniteCheats() { GameInteractor::Instance->RegisterGameHook([]() { - if (gPlayState == nullptr) return; + if (gPlayState == nullptr) + return; if (CVarGetInteger("gCheats.InfiniteHealth", 0)) { gSaveContext.save.saveInfo.playerData.health = gSaveContext.save.saveInfo.playerData.healthCapacity; diff --git a/mm/2s2h/Enhancements/Cheats/MoonJump.cpp b/mm/2s2h/Enhancements/Cheats/MoonJump.cpp index 7963e6f4b..f1cb173f8 100644 --- a/mm/2s2h/Enhancements/Cheats/MoonJump.cpp +++ b/mm/2s2h/Enhancements/Cheats/MoonJump.cpp @@ -6,19 +6,22 @@ static uint32_t moonJumpOnLGameStateUpdateHookId = 0; void RegisterMoonJumpOnL() { if (moonJumpOnLGameStateUpdateHookId) { - GameInteractor::Instance->UnregisterGameHook(moonJumpOnLGameStateUpdateHookId); + GameInteractor::Instance->UnregisterGameHook( + moonJumpOnLGameStateUpdateHookId); moonJumpOnLGameStateUpdateHookId = 0; } if (CVarGetInteger("gCheats.MoonJumpOnL", 0)) { - moonJumpOnLGameStateUpdateHookId = GameInteractor::Instance->RegisterGameHook([]() { - if (gPlayState == nullptr) return; + moonJumpOnLGameStateUpdateHookId = + GameInteractor::Instance->RegisterGameHook([]() { + if (gPlayState == nullptr) + return; - Player* player = GET_PLAYER(gPlayState); + Player* player = GET_PLAYER(gPlayState); - if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) { - player->actor.velocity.y = 6.34375f; - } - }); + if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) { + player->actor.velocity.y = 6.34375f; + } + }); } } diff --git a/mm/2s2h/Enhancements/Cutscenes/Cutscenes.cpp b/mm/2s2h/Enhancements/Cutscenes/Cutscenes.cpp index d3e0bc20e..fe480a3f5 100644 --- a/mm/2s2h/Enhancements/Cutscenes/Cutscenes.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/Cutscenes.cpp @@ -2,12 +2,12 @@ void RegisterCutscenes() { // MiscInteractions - RegisterSkipDekuSalesman(); - RegisterSkipScarecrowDance(); - RegisterSkipTatlInterrupts(); + RegisterSkipDekuSalesman(); + RegisterSkipScarecrowDance(); + RegisterSkipTatlInterrupts(); // StoryCutscenes - RegisterSkipClockTowerOpen(); + RegisterSkipClockTowerOpen(); RegisterHideTitleCards(); RegisterSkipEntranceCutscenes(); diff --git a/mm/2s2h/Enhancements/Cutscenes/Cutscenes.h b/mm/2s2h/Enhancements/Cutscenes/Cutscenes.h index 8449439e1..fcd955512 100644 --- a/mm/2s2h/Enhancements/Cutscenes/Cutscenes.h +++ b/mm/2s2h/Enhancements/Cutscenes/Cutscenes.h @@ -4,12 +4,12 @@ void RegisterCutscenes(); // MiscInteractions - void RegisterSkipDekuSalesman(); - void RegisterSkipScarecrowDance(); - void RegisterSkipTatlInterrupts(); +void RegisterSkipDekuSalesman(); +void RegisterSkipScarecrowDance(); +void RegisterSkipTatlInterrupts(); // StoryCutscenes - void RegisterSkipClockTowerOpen(); +void RegisterSkipClockTowerOpen(); void RegisterHideTitleCards(); void RegisterSkipEntranceCutscenes(); diff --git a/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipDekuSalesman.cpp b/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipDekuSalesman.cpp index 439f4e934..5317a27a0 100644 --- a/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipDekuSalesman.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipDekuSalesman.cpp @@ -2,16 +2,18 @@ #include "Enhancements/GameInteractor/GameInteractor.h" extern "C" { - #include "z64.h" - extern SaveContext gSaveContext; - void Flags_SetWeekEventReg(s32 flag); +#include "z64.h" +extern SaveContext gSaveContext; +void Flags_SetWeekEventReg(s32 flag); } void RegisterSkipDekuSalesman() { // prevents him from doing his "fly in" animation - GameInteractor::Instance->RegisterGameHookForID(ACTOR_EN_SELLNUTS, [](Actor* actor, bool* should) { - if (CVarGetInteger("gEnhancements.Cutscenes.SkipMiscInteractions", 0) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_04)) { - SET_WEEKEVENTREG(WEEKEVENTREG_73_04); - } - }); + GameInteractor::Instance->RegisterGameHookForID( + ACTOR_EN_SELLNUTS, [](Actor* actor, bool* should) { + if (CVarGetInteger("gEnhancements.Cutscenes.SkipMiscInteractions", 0) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_73_04); + } + }); } diff --git a/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipScarecrowDance.cpp b/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipScarecrowDance.cpp index f44d9def0..467c2fee1 100644 --- a/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipScarecrowDance.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipScarecrowDance.cpp @@ -2,36 +2,36 @@ #include "Enhancements/GameInteractor/GameInteractor.h" extern "C" { - #include "z64.h" - #include "src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h" +#include "z64.h" +#include "src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h" } void RegisterSkipScarecrowDance() { // Skips to end of "passing time" dance with the scarecrow - GameInteractor::Instance->RegisterGameHookForID(ACTOR_EN_KAKASI, [](Actor* outerActor) { - static uint32_t enKakasiUpdateHook = 0; - static uint32_t enKakasiKillHook = 0; - GameInteractor::Instance->UnregisterGameHookForPtr(enKakasiUpdateHook); - GameInteractor::Instance->UnregisterGameHook(enKakasiKillHook); - enKakasiUpdateHook = 0; - enKakasiKillHook = 0; - - enKakasiUpdateHook = GameInteractor::Instance->RegisterGameHookForPtr((uintptr_t)outerActor, [](Actor* actor) { - EnKakasi* enKakasi = (EnKakasi*)actor; - if ( - CVarGetInteger("gEnhancements.Cutscenes.SkipMiscInteractions", 0) && - enKakasi->actionFunc == EnKakasi_DancingNightAway && - enKakasi->unk190 == 0 - ) { - enKakasi->unk190 = 13; - enKakasi->unk204 = 0; - } - }); - enKakasiKillHook = GameInteractor::Instance->RegisterGameHook([](s8 sceneId, s8 spawnNum) { - GameInteractor::Instance->UnregisterGameHook(enKakasiUpdateHook); + GameInteractor::Instance->RegisterGameHookForID( + ACTOR_EN_KAKASI, [](Actor* outerActor) { + static uint32_t enKakasiUpdateHook = 0; + static uint32_t enKakasiKillHook = 0; + GameInteractor::Instance->UnregisterGameHookForPtr(enKakasiUpdateHook); GameInteractor::Instance->UnregisterGameHook(enKakasiKillHook); enKakasiUpdateHook = 0; enKakasiKillHook = 0; + + enKakasiUpdateHook = GameInteractor::Instance->RegisterGameHookForPtr( + (uintptr_t)outerActor, [](Actor* actor) { + EnKakasi* enKakasi = (EnKakasi*)actor; + if (CVarGetInteger("gEnhancements.Cutscenes.SkipMiscInteractions", 0) && + enKakasi->actionFunc == EnKakasi_DancingNightAway && enKakasi->unk190 == 0) { + enKakasi->unk190 = 13; + enKakasi->unk204 = 0; + } + }); + enKakasiKillHook = + GameInteractor::Instance->RegisterGameHook([](s8 sceneId, s8 spawnNum) { + GameInteractor::Instance->UnregisterGameHook(enKakasiUpdateHook); + GameInteractor::Instance->UnregisterGameHook(enKakasiKillHook); + enKakasiUpdateHook = 0; + enKakasiKillHook = 0; + }); }); - }); } diff --git a/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipTatlInterrupts.cpp b/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipTatlInterrupts.cpp index 5f3281ffa..a56590c5e 100644 --- a/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipTatlInterrupts.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipTatlInterrupts.cpp @@ -4,24 +4,21 @@ #define ELFMSG3_GET_SWITCH_FLAG(thisx) (((thisx)->params & 0x7F00) >> 8) extern "C" { - #include "z64.h" - extern PlayState* gPlayState; - extern SaveContext gSaveContext; - extern u32 gBitFlags[]; - void Flags_SetWeekEventReg(s32 flag); - void Flags_SetSwitch(PlayState* play, s32 flag); - void Actor_Kill(Actor* actor); +#include "z64.h" +extern PlayState* gPlayState; +extern SaveContext gSaveContext; +extern u32 gBitFlags[]; +void Flags_SetWeekEventReg(s32 flag); +void Flags_SetSwitch(PlayState* play, s32 flag); +void Actor_Kill(Actor* actor); } void RegisterSkipTatlInterrupts() { // First time entering Clock Town Interupt REGISTER_VB_SHOULD(GI_VB_PLAY_TRANSITION_CS, { - if ( - gSaveContext.save.entrance == ENTRANCE(SOUTH_CLOCK_TOWN, 0) && - gSaveContext.save.cutsceneIndex == 0 && + if (gSaveContext.save.entrance == ENTRANCE(SOUTH_CLOCK_TOWN, 0) && gSaveContext.save.cutsceneIndex == 0 && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_04) && - CVarGetInteger("gEnhancements.Cutscenes.SkipMiscInteractions", 0) - ) { + CVarGetInteger("gEnhancements.Cutscenes.SkipMiscInteractions", 0)) { Flags_SetWeekEventReg(WEEKEVENTREG_59_04); } }); diff --git a/mm/2s2h/Enhancements/Cutscenes/SkipIntroSequence.cpp b/mm/2s2h/Enhancements/Cutscenes/SkipIntroSequence.cpp index 34b51ac57..b698d138a 100644 --- a/mm/2s2h/Enhancements/Cutscenes/SkipIntroSequence.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/SkipIntroSequence.cpp @@ -2,15 +2,16 @@ #include "Enhancements/GameInteractor/GameInteractor.h" extern "C" { - #include "z64.h" - extern PlayState* gPlayState; - extern SaveContext gSaveContext; +#include "z64.h" +extern PlayState* gPlayState; +extern SaveContext gSaveContext; } void RegisterSkipIntroSequence() { REGISTER_VB_SHOULD(GI_VB_PLAY_TRANSITION_CS, { // Intro cutscene - if (!(gSaveContext.save.entrance == ENTRANCE(CUTSCENE, 0) && gSaveContext.save.cutsceneIndex == 0)) return; + if (!(gSaveContext.save.entrance == ENTRANCE(CUTSCENE, 0) && gSaveContext.save.cutsceneIndex == 0)) + return; if (CVarGetInteger("gEnhancements.Cutscenes.SkipIntroSequence", 0)) { gSaveContext.save.entrance = ENTRANCE(SOUTH_CLOCK_TOWN, 0); @@ -21,7 +22,7 @@ void RegisterSkipIntroSequence() { gSaveContext.save.playerForm = PLAYER_FORM_DEKU; // Mark chest as opened and give the player the Deku Nuts - gSaveContext.cycleSceneFlags[SCENE_OPENINGDAN].chest |= (1 << 0); + gSaveContext.cycleSceneFlags[SCENE_OPENINGDAN].chest |= (1 << 0); Item_Give(gPlayState, ITEM_DEKU_NUTS_10); } }); diff --git a/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp b/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp index d33b9683a..9ee722275 100644 --- a/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp +++ b/mm/2s2h/Enhancements/Cutscenes/StoryCutscenes/SkipClockTowerOpen.cpp @@ -2,20 +2,18 @@ #include "Enhancements/GameInteractor/GameInteractor.h" extern "C" { - #include "z64.h" - void Flags_SetWeekEventReg(s32 flag); - extern SaveContext gSaveContext; +#include "z64.h" +void Flags_SetWeekEventReg(s32 flag); +extern SaveContext gSaveContext; } void RegisterSkipClockTowerOpen() { REGISTER_VB_SHOULD(GI_VB_PLAY_TRANSITION_CS, { // Cutscene where clock tower opens. Will only show if the player is in Clock Town - if ( - ENTRANCE(SOUTH_CLOCK_TOWN, 0) && - gSaveContext.save.cutsceneIndex == 0xFFF1 && - CVarGetInteger("gEnhancements.Cutscenes.SkipStoryCutscenes", 0) - ) { - // Setting the respawn flag to 2 will respawn the player where they were before the cutscene, consistent with the normal behavior + if (ENTRANCE(SOUTH_CLOCK_TOWN, 0) && gSaveContext.save.cutsceneIndex == 0xFFF1 && + CVarGetInteger("gEnhancements.Cutscenes.SkipStoryCutscenes", 0)) { + // Setting the respawn flag to 2 will respawn the player where they were before the cutscene, consistent + // with the normal behavior gSaveContext.respawnFlag = 2; gSaveContext.save.cutsceneIndex = 0; SET_WEEKEVENTREG(WEEKEVENTREG_CLOCK_TOWER_OPENED); diff --git a/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp b/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp index 628e9ac67..d1afedaac 100644 --- a/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp +++ b/mm/2s2h/Enhancements/Cycle/EndOfCycle.cpp @@ -9,9 +9,8 @@ extern "C" { SaveInfo saveInfoCopy; void RegisterEndOfCycleSaveHooks() { - GameInteractor::Instance->RegisterGameHook([]() { - memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); - }); + GameInteractor::Instance->RegisterGameHook( + []() { memcpy(&saveInfoCopy, &gSaveContext.save.saveInfo, sizeof(SaveInfo)); }); GameInteractor::Instance->RegisterGameHook([]() { if (CVarGetInteger("gEnhancements.Cycle.DoNotResetRupees", 0)) { @@ -72,8 +71,8 @@ void RegisterEndOfCycleSaveHooks() { } if (CVarGetInteger("gEnhancements.Cycle.DoNotResetRazorSword", 0) && - ((saveInfoCopy.equips.equipment & gEquipMasks[EQUIP_TYPE_SWORD]) >> - gEquipShifts[EQUIP_TYPE_SWORD]) == EQUIP_VALUE_SWORD_RAZOR) { + ((saveInfoCopy.equips.equipment & gEquipMasks[EQUIP_TYPE_SWORD]) >> gEquipShifts[EQUIP_TYPE_SWORD]) == + EQUIP_VALUE_SWORD_RAZOR) { SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_RAZOR); CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_RAZOR; diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index d1f4118a8..5ec960832 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -8,11 +8,11 @@ void InitEnhancements() { // Cheats RegisterInfiniteCheats(); RegisterMoonJumpOnL(); - RegisterUnbreakableRazorSword(); + RegisterUnbreakableRazorSword(); // Clock RegisterTextBasedClock(); - + // Cycle RegisterEndOfCycleSaveHooks(); @@ -26,19 +26,18 @@ void InitEnhancements() { // Songs RegisterEnableSunsSong(); - + // Restorations RegisterPowerCrouchStab(); RegisterSideRoll(); RegisterTatlISG(); - + // Cutscenes RegisterCutscenes(); - + // Modes RegisterPlayAsKafei(); // Player Movement RegisterClimbSpeed(); - } diff --git a/mm/2s2h/Enhancements/FrameInterpolation/FrameInterpolation.cpp b/mm/2s2h/Enhancements/FrameInterpolation/FrameInterpolation.cpp index a78727239..3c7ebb873 100644 --- a/mm/2s2h/Enhancements/FrameInterpolation/FrameInterpolation.cpp +++ b/mm/2s2h/Enhancements/FrameInterpolation/FrameInterpolation.cpp @@ -76,7 +76,6 @@ void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, MtxF* Matrix_GetCurrent(void); void SkinMatrix_MtxFMtxFMult(MtxF* mfA, MtxF* mfB, MtxF* dest); - } static bool invert_matrix(const float m[16], float invOut[16]); @@ -85,357 +84,362 @@ using namespace std; namespace { - enum class Op { - OpenChild, - CloseChild, - - MatrixPush, - MatrixPop, - MatrixPut, - MatrixMult, - MatrixTranslate, - MatrixScale, - MatrixRotate1Coord, - MatrixRotateZYX, - MatrixTranslateRotateZYX, - MatrixSetTranslateRotateYXZ, - MatrixMtxFToMtx, - MatrixToMtx, - MatrixReplaceRotation, - MatrixRotateAxis, - SkinMatrixMtxFToMtx - }; - - typedef pair label; - - union Data { - Data() { - } - - struct { - MtxF src; - } matrix_put; - - struct { - MtxF mf; - u8 mode; - } matrix_mult; - - struct { - f32 x, y, z; - u8 mode; - } matrix_translate, matrix_scale; - - struct { - u32 coord; - f32 value; - u8 mode; - } matrix_rotate_1_coord; - - struct { - s16 x, y, z; - u8 mode; - } matrix_rotate_zyx; - - struct { - Vec3f translation; - Vec3s rotation; - } matrix_translate_rotate_zyx; - - struct { - f32 translateX, translateY, translateZ; - Vec3s rot; - //MtxF mtx; - bool has_mtx; - } matrix_set_translate_rotate_yxz; - - struct { - MtxF src; - Mtx* dest; - } matrix_mtxf_to_mtx; - - struct { - Mtx* dest; - MtxF src; - bool has_adjusted; - } matrix_to_mtx; - - struct { - MtxF mf; - } matrix_replace_rotation; - - struct { - f32 angle; - Vec3f axis; - u8 mode; - } matrix_rotate_axis; - - struct { - label key; - size_t idx; - } open_child; - }; - - struct Path { - map> children; - map> ops; - vector> items; - }; - - struct Recording { - Path root_path; - }; - - bool is_recording; - vector current_path; - uint32_t camera_epoch; - uint32_t previous_camera_epoch; - Recording current_recording; - Recording previous_recording; - - bool next_is_actor_pos_rot_matrix; - bool has_inv_actor_mtx; - MtxF inv_actor_mtx; - size_t inv_actor_mtx_path_index; - - Data& append(Op op) { - auto& m = current_path.back()->ops[op]; - current_path.back()->items.emplace_back(op, m.size()); - return m.emplace_back(); +enum class Op { + OpenChild, + CloseChild, + + MatrixPush, + MatrixPop, + MatrixPut, + MatrixMult, + MatrixTranslate, + MatrixScale, + MatrixRotate1Coord, + MatrixRotateZYX, + MatrixTranslateRotateZYX, + MatrixSetTranslateRotateYXZ, + MatrixMtxFToMtx, + MatrixToMtx, + MatrixReplaceRotation, + MatrixRotateAxis, + SkinMatrixMtxFToMtx +}; + +typedef pair label; + +union Data { + Data() { } - struct InterpolateCtx { - float step; - float w; - unordered_map mtx_replacements; - MtxF tmp_mtxf, tmp_mtxf2; - Vec3f tmp_vec3f; - Vec3s tmp_vec3s; - MtxF actor_mtx; - - MtxF* new_replacement(Mtx* addr) { - return &mtx_replacements[addr]; - } + struct { + MtxF src; + } matrix_put; + + struct { + MtxF mf; + u8 mode; + } matrix_mult; + + struct { + f32 x, y, z; + u8 mode; + } matrix_translate, matrix_scale; + + struct { + u32 coord; + f32 value; + u8 mode; + } matrix_rotate_1_coord; + + struct { + s16 x, y, z; + u8 mode; + } matrix_rotate_zyx; + + struct { + Vec3f translation; + Vec3s rotation; + } matrix_translate_rotate_zyx; + + struct { + f32 translateX, translateY, translateZ; + Vec3s rot; + // MtxF mtx; + bool has_mtx; + } matrix_set_translate_rotate_yxz; + + struct { + MtxF src; + Mtx* dest; + } matrix_mtxf_to_mtx; + + struct { + Mtx* dest; + MtxF src; + bool has_adjusted; + } matrix_to_mtx; + + struct { + MtxF mf; + } matrix_replace_rotation; + + struct { + f32 angle; + Vec3f axis; + u8 mode; + } matrix_rotate_axis; + + struct { + label key; + size_t idx; + } open_child; +}; + +struct Path { + map> children; + map> ops; + vector> items; +}; + +struct Recording { + Path root_path; +}; + +bool is_recording; +vector current_path; +uint32_t camera_epoch; +uint32_t previous_camera_epoch; +Recording current_recording; +Recording previous_recording; + +bool next_is_actor_pos_rot_matrix; +bool has_inv_actor_mtx; +MtxF inv_actor_mtx; +size_t inv_actor_mtx_path_index; + +Data& append(Op op) { + auto& m = current_path.back()->ops[op]; + current_path.back()->items.emplace_back(op, m.size()); + return m.emplace_back(); +} - void interpolate_mtxf(MtxF* res, MtxF* o, MtxF* n) { - for (size_t i = 0; i < 4; i++) { - for (size_t j = 0; j < 4; j++) { - res->mf[i][j] = w * o->mf[i][j] + step * n->mf[i][j]; - } +struct InterpolateCtx { + float step; + float w; + unordered_map mtx_replacements; + MtxF tmp_mtxf, tmp_mtxf2; + Vec3f tmp_vec3f; + Vec3s tmp_vec3s; + MtxF actor_mtx; + + MtxF* new_replacement(Mtx* addr) { + return &mtx_replacements[addr]; + } + + void interpolate_mtxf(MtxF* res, MtxF* o, MtxF* n) { + for (size_t i = 0; i < 4; i++) { + for (size_t j = 0; j < 4; j++) { + res->mf[i][j] = w * o->mf[i][j] + step * n->mf[i][j]; } } + } - float lerp(f32 o, f32 n) { - return w * o + step * n; - } + float lerp(f32 o, f32 n) { + return w * o + step * n; + } - void lerp_vec3f(Vec3f* res, Vec3f* o, Vec3f* n) { - res->x = lerp(o->x, n->x); - res->y = lerp(o->y, n->y); - res->z = lerp(o->z, n->z); - } + void lerp_vec3f(Vec3f* res, Vec3f* o, Vec3f* n) { + res->x = lerp(o->x, n->x); + res->y = lerp(o->y, n->y); + res->z = lerp(o->z, n->z); + } - float interpolate_angle(f32 o, f32 n) { - if (o == n) - return n; - o = fmodf(o, 2 * M_PI); - if (o < 0.0f) { + float interpolate_angle(f32 o, f32 n) { + if (o == n) + return n; + o = fmodf(o, 2 * M_PI); + if (o < 0.0f) { + o += 2 * M_PI; + } + n = fmodf(n, 2 * M_PI); + if (n < 0.0f) { + n += 2 * M_PI; + } + if (fabsf(o - n) > M_PI) { + if (o < n) { o += 2 * M_PI; - } - n = fmodf(n, 2 * M_PI); - if (n < 0.0f) { + } else { n += 2 * M_PI; } - if (fabsf(o - n) > M_PI) { - if (o < n) { - o += 2 * M_PI; - } else { - n += 2 * M_PI; - } - } - if (fabsf(o - n) > M_PI / 2) { - //return n; - } - return lerp(o, n); } + if (fabsf(o - n) > M_PI / 2) { + // return n; + } + return lerp(o, n); + } - s16 interpolate_angle(s16 os, s16 ns) { - if (os == ns) + s16 interpolate_angle(s16 os, s16 ns) { + if (os == ns) + return ns; + int o = (u16)os; + int n = (u16)ns; + u16 res; + int diff = o - n; + if (-0x8000 <= diff && diff <= 0x8000) { + if (diff < -0x4000 || diff > 0x4000) { return ns; - int o = (u16)os; - int n = (u16)ns; - u16 res; - int diff = o - n; - if (-0x8000 <= diff && diff <= 0x8000) { - if (diff < -0x4000 || diff > 0x4000) { - return ns; - } - res = (u16)(w * o + step * n); + } + res = (u16)(w * o + step * n); + } else { + if (o < n) { + o += 0x10000; } else { - if (o < n) { - o += 0x10000; - } else { - n += 0x10000; - } - diff = o - n; - if (diff < -0x4000 || diff > 0x4000) { - return ns; - } - res = (u16)(w * o + step * n); + n += 0x10000; } - if (os / 327 == ns / 327 && (s16)res / 327 != os / 327) { - int bp = 0; + diff = o - n; + if (diff < -0x4000 || diff > 0x4000) { + return ns; } - return res; + res = (u16)(w * o + step * n); } - - void interpolate_angles(Vec3s* res, Vec3s* o, Vec3s* n) { - res->x = interpolate_angle(o->x, n->x); - res->y = interpolate_angle(o->y, n->y); - res->z = interpolate_angle(o->z, n->z); + if (os / 327 == ns / 327 && (s16)res / 327 != os / 327) { + int bp = 0; } + return res; + } - void interpolate_branch(Path* old_path, Path *new_path) { - for (auto& item : new_path->items) { - Data& new_op = new_path->ops[item.first][item.second]; - - if (item.first == Op::OpenChild) { - if (auto it = old_path->children.find(new_op.open_child.key); - it != old_path->children.end() && new_op.open_child.idx < it->second.size()) { - interpolate_branch(&it->second[new_op.open_child.idx], - &new_path->children.find(new_op.open_child.key)->second[new_op.open_child.idx]); - } else { - interpolate_branch( - &new_path->children.find(new_op.open_child.key)->second[new_op.open_child.idx], - &new_path->children.find(new_op.open_child.key)->second[new_op.open_child.idx]); - } - continue; + void interpolate_angles(Vec3s* res, Vec3s* o, Vec3s* n) { + res->x = interpolate_angle(o->x, n->x); + res->y = interpolate_angle(o->y, n->y); + res->z = interpolate_angle(o->z, n->z); + } + + void interpolate_branch(Path* old_path, Path* new_path) { + for (auto& item : new_path->items) { + Data& new_op = new_path->ops[item.first][item.second]; + + if (item.first == Op::OpenChild) { + if (auto it = old_path->children.find(new_op.open_child.key); + it != old_path->children.end() && new_op.open_child.idx < it->second.size()) { + interpolate_branch(&it->second[new_op.open_child.idx], + &new_path->children.find(new_op.open_child.key)->second[new_op.open_child.idx]); + } else { + interpolate_branch(&new_path->children.find(new_op.open_child.key)->second[new_op.open_child.idx], + &new_path->children.find(new_op.open_child.key)->second[new_op.open_child.idx]); } + continue; + } - if (auto it = old_path->ops.find(item.first); it != old_path->ops.end()) { - if (item.second < it->second.size()) { - Data& old_op = it->second[item.second]; - switch (item.first) { - case Op::OpenChild: - break; - case Op::CloseChild: - break; - - case Op::MatrixPush: - Matrix_Push(); - break; - - case Op::MatrixPop: - Matrix_Pop(); - break; - - case Op::MatrixPut: - interpolate_mtxf(&tmp_mtxf, &old_op.matrix_put.src, &new_op.matrix_put.src); - Matrix_Put(&tmp_mtxf); - break; - - case Op::MatrixMult: - interpolate_mtxf(&tmp_mtxf, &old_op.matrix_mult.mf, &new_op.matrix_mult.mf); - Matrix_Mult(&tmp_mtxf, new_op.matrix_mult.mode); - break; - - case Op::MatrixTranslate: - Matrix_Translate(lerp(old_op.matrix_translate.x, new_op.matrix_translate.x), - lerp(old_op.matrix_translate.y, new_op.matrix_translate.y), - lerp(old_op.matrix_translate.z, new_op.matrix_translate.z), - new_op.matrix_translate.mode); - break; - - case Op::MatrixScale: - Matrix_Scale(lerp(old_op.matrix_scale.x, new_op.matrix_scale.x), - lerp(old_op.matrix_scale.y, new_op.matrix_scale.y), - lerp(old_op.matrix_scale.z, new_op.matrix_scale.z), - new_op.matrix_scale.mode); - break; - - case Op::MatrixRotate1Coord: { - float v = interpolate_angle(old_op.matrix_rotate_1_coord.value, new_op.matrix_rotate_1_coord.value); - u8 mode = new_op.matrix_rotate_1_coord.mode; - switch (new_op.matrix_rotate_1_coord.coord) { - case 0: - Matrix_RotateXF(v, mode); - break; - - case 1: - Matrix_RotateYF(v, mode); - break; - - case 2: - Matrix_RotateZF(v, mode); - break; - } - break; + if (auto it = old_path->ops.find(item.first); it != old_path->ops.end()) { + if (item.second < it->second.size()) { + Data& old_op = it->second[item.second]; + switch (item.first) { + case Op::OpenChild: + break; + case Op::CloseChild: + break; + + case Op::MatrixPush: + Matrix_Push(); + break; + + case Op::MatrixPop: + Matrix_Pop(); + break; + + case Op::MatrixPut: + interpolate_mtxf(&tmp_mtxf, &old_op.matrix_put.src, &new_op.matrix_put.src); + Matrix_Put(&tmp_mtxf); + break; + + case Op::MatrixMult: + interpolate_mtxf(&tmp_mtxf, &old_op.matrix_mult.mf, &new_op.matrix_mult.mf); + Matrix_Mult(&tmp_mtxf, new_op.matrix_mult.mode); + break; + + case Op::MatrixTranslate: + Matrix_Translate(lerp(old_op.matrix_translate.x, new_op.matrix_translate.x), + lerp(old_op.matrix_translate.y, new_op.matrix_translate.y), + lerp(old_op.matrix_translate.z, new_op.matrix_translate.z), + new_op.matrix_translate.mode); + break; + + case Op::MatrixScale: + Matrix_Scale(lerp(old_op.matrix_scale.x, new_op.matrix_scale.x), + lerp(old_op.matrix_scale.y, new_op.matrix_scale.y), + lerp(old_op.matrix_scale.z, new_op.matrix_scale.z), new_op.matrix_scale.mode); + break; + + case Op::MatrixRotate1Coord: { + float v = interpolate_angle(old_op.matrix_rotate_1_coord.value, + new_op.matrix_rotate_1_coord.value); + u8 mode = new_op.matrix_rotate_1_coord.mode; + switch (new_op.matrix_rotate_1_coord.coord) { + case 0: + Matrix_RotateXF(v, mode); + break; + + case 1: + Matrix_RotateYF(v, mode); + break; + + case 2: + Matrix_RotateZF(v, mode); + break; } + break; + } - case Op::MatrixRotateZYX: - Matrix_RotateZYX(interpolate_angle(old_op.matrix_rotate_zyx.x, new_op.matrix_rotate_zyx.x), - interpolate_angle(old_op.matrix_rotate_zyx.y, new_op.matrix_rotate_zyx.y), - interpolate_angle(old_op.matrix_rotate_zyx.z, new_op.matrix_rotate_zyx.z), - new_op.matrix_rotate_zyx.mode); - break; - - case Op::MatrixTranslateRotateZYX: - lerp_vec3f(&tmp_vec3f, &old_op.matrix_translate_rotate_zyx.translation, &new_op.matrix_translate_rotate_zyx.translation); - interpolate_angles(&tmp_vec3s, &old_op.matrix_translate_rotate_zyx.rotation, &new_op.matrix_translate_rotate_zyx.rotation); - Matrix_TranslateRotateZYX(&tmp_vec3f, &tmp_vec3s); - break; - - case Op::MatrixSetTranslateRotateYXZ: - interpolate_angles(&tmp_vec3s, &old_op.matrix_set_translate_rotate_yxz.rot, - &new_op.matrix_set_translate_rotate_yxz.rot); - Matrix_SetTranslateRotateYXZ(lerp(old_op.matrix_set_translate_rotate_yxz.translateX, - new_op.matrix_set_translate_rotate_yxz.translateX), - lerp(old_op.matrix_set_translate_rotate_yxz.translateY, - new_op.matrix_set_translate_rotate_yxz.translateY), - lerp(old_op.matrix_set_translate_rotate_yxz.translateZ, - new_op.matrix_set_translate_rotate_yxz.translateZ), - &tmp_vec3s); - if (new_op.matrix_set_translate_rotate_yxz.has_mtx && old_op.matrix_set_translate_rotate_yxz.has_mtx) { - actor_mtx = *Matrix_GetCurrent(); - } - break; - - case Op::MatrixMtxFToMtx: - interpolate_mtxf(new_replacement(new_op.matrix_mtxf_to_mtx.dest), - &old_op.matrix_mtxf_to_mtx.src, &new_op.matrix_mtxf_to_mtx.src); - break; - - case Op::MatrixToMtx: { - //*new_replacement(new_op.matrix_to_mtx.dest) = *Matrix_GetCurrent(); - if (old_op.matrix_to_mtx.has_adjusted && new_op.matrix_to_mtx.has_adjusted) { - interpolate_mtxf(&tmp_mtxf, &old_op.matrix_to_mtx.src, &new_op.matrix_to_mtx.src); - SkinMatrix_MtxFMtxFMult(&actor_mtx, &tmp_mtxf, new_replacement(new_op.matrix_to_mtx.dest)); - } else { - interpolate_mtxf(new_replacement(new_op.matrix_to_mtx.dest), - &old_op.matrix_to_mtx.src, &new_op.matrix_to_mtx.src); - } - break; + case Op::MatrixRotateZYX: + Matrix_RotateZYX(interpolate_angle(old_op.matrix_rotate_zyx.x, new_op.matrix_rotate_zyx.x), + interpolate_angle(old_op.matrix_rotate_zyx.y, new_op.matrix_rotate_zyx.y), + interpolate_angle(old_op.matrix_rotate_zyx.z, new_op.matrix_rotate_zyx.z), + new_op.matrix_rotate_zyx.mode); + break; + + case Op::MatrixTranslateRotateZYX: + lerp_vec3f(&tmp_vec3f, &old_op.matrix_translate_rotate_zyx.translation, + &new_op.matrix_translate_rotate_zyx.translation); + interpolate_angles(&tmp_vec3s, &old_op.matrix_translate_rotate_zyx.rotation, + &new_op.matrix_translate_rotate_zyx.rotation); + Matrix_TranslateRotateZYX(&tmp_vec3f, &tmp_vec3s); + break; + + case Op::MatrixSetTranslateRotateYXZ: + interpolate_angles(&tmp_vec3s, &old_op.matrix_set_translate_rotate_yxz.rot, + &new_op.matrix_set_translate_rotate_yxz.rot); + Matrix_SetTranslateRotateYXZ(lerp(old_op.matrix_set_translate_rotate_yxz.translateX, + new_op.matrix_set_translate_rotate_yxz.translateX), + lerp(old_op.matrix_set_translate_rotate_yxz.translateY, + new_op.matrix_set_translate_rotate_yxz.translateY), + lerp(old_op.matrix_set_translate_rotate_yxz.translateZ, + new_op.matrix_set_translate_rotate_yxz.translateZ), + &tmp_vec3s); + if (new_op.matrix_set_translate_rotate_yxz.has_mtx && + old_op.matrix_set_translate_rotate_yxz.has_mtx) { + actor_mtx = *Matrix_GetCurrent(); } - - case Op::MatrixReplaceRotation: - interpolate_mtxf(&tmp_mtxf, &old_op.matrix_replace_rotation.mf, &new_op.matrix_replace_rotation.mf); - Matrix_ReplaceRotation(&tmp_mtxf); - break; - - case Op::MatrixRotateAxis: - lerp_vec3f(&tmp_vec3f, &old_op.matrix_rotate_axis.axis, &new_op.matrix_rotate_axis.axis); - Matrix_RotateAxisF(interpolate_angle(old_op.matrix_rotate_axis.angle, new_op.matrix_rotate_axis.angle), - &tmp_vec3f, new_op.matrix_rotate_axis.mode); - break; - - case Op::SkinMatrixMtxFToMtx: - break; + break; + + case Op::MatrixMtxFToMtx: + interpolate_mtxf(new_replacement(new_op.matrix_mtxf_to_mtx.dest), + &old_op.matrix_mtxf_to_mtx.src, &new_op.matrix_mtxf_to_mtx.src); + break; + + case Op::MatrixToMtx: { + //*new_replacement(new_op.matrix_to_mtx.dest) = *Matrix_GetCurrent(); + if (old_op.matrix_to_mtx.has_adjusted && new_op.matrix_to_mtx.has_adjusted) { + interpolate_mtxf(&tmp_mtxf, &old_op.matrix_to_mtx.src, &new_op.matrix_to_mtx.src); + SkinMatrix_MtxFMtxFMult(&actor_mtx, &tmp_mtxf, + new_replacement(new_op.matrix_to_mtx.dest)); + } else { + interpolate_mtxf(new_replacement(new_op.matrix_to_mtx.dest), &old_op.matrix_to_mtx.src, + &new_op.matrix_to_mtx.src); + } + break; } + + case Op::MatrixReplaceRotation: + interpolate_mtxf(&tmp_mtxf, &old_op.matrix_replace_rotation.mf, + &new_op.matrix_replace_rotation.mf); + Matrix_ReplaceRotation(&tmp_mtxf); + break; + + case Op::MatrixRotateAxis: + lerp_vec3f(&tmp_vec3f, &old_op.matrix_rotate_axis.axis, &new_op.matrix_rotate_axis.axis); + Matrix_RotateAxisF( + interpolate_angle(old_op.matrix_rotate_axis.angle, new_op.matrix_rotate_axis.angle), + &tmp_vec3f, new_op.matrix_rotate_axis.mode); + break; + + case Op::SkinMatrixMtxFToMtx: + break; } } } } - }; + } +}; } // anonymous namespace @@ -474,7 +478,7 @@ void FrameInterpolation_RecordOpenChild(const void* a, int b) { void FrameInterpolation_RecordCloseChild(void) { if (!is_recording) return; - //append(Op::CloseChild); + // append(Op::CloseChild); if (has_inv_actor_mtx && current_path.size() == inv_actor_mtx_path_index) { has_inv_actor_mtx = false; } @@ -552,12 +556,12 @@ void FrameInterpolation_RecordMatrixTranslateRotateZYX(Vec3f* translation, Vec3s void FrameInterpolation_RecordMatrixSetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot) { if (!is_recording) return; - auto& d = append(Op::MatrixSetTranslateRotateYXZ).matrix_set_translate_rotate_yxz = { translateX, translateY, translateZ, - *rot }; + auto& d = append(Op::MatrixSetTranslateRotateYXZ).matrix_set_translate_rotate_yxz = { translateX, translateY, + translateZ, *rot }; if (next_is_actor_pos_rot_matrix) { d.has_mtx = true; - //d.mtx = *Matrix_GetCurrent(); - invert_matrix((const float *)Matrix_GetCurrent()->mf, (float *)inv_actor_mtx.mf); + // d.mtx = *Matrix_GetCurrent(); + invert_matrix((const float*)Matrix_GetCurrent()->mf, (float*)inv_actor_mtx.mf); next_is_actor_pos_rot_matrix = false; has_inv_actor_mtx = true; inv_actor_mtx_path_index = current_path.size(); @@ -605,116 +609,52 @@ static bool invert_matrix(const float m[16], float invOut[16]) { float inv[16], det; int i; - inv[0] = m[5] * m[10] * m[15] - - m[5] * m[11] * m[14] - - m[9] * m[6] * m[15] + - m[9] * m[7] * m[14] + - m[13] * m[6] * m[11] - - m[13] * m[7] * m[10]; - - inv[4] = -m[4] * m[10] * m[15] + - m[4] * m[11] * m[14] + - m[8] * m[6] * m[15] - - m[8] * m[7] * m[14] - - m[12] * m[6] * m[11] + - m[12] * m[7] * m[10]; - - inv[8] = m[4] * m[9] * m[15] - - m[4] * m[11] * m[13] - - m[8] * m[5] * m[15] + - m[8] * m[7] * m[13] + - m[12] * m[5] * m[11] - - m[12] * m[7] * m[9]; - - inv[12] = -m[4] * m[9] * m[14] + - m[4] * m[10] * m[13] + - m[8] * m[5] * m[14] - - m[8] * m[6] * m[13] - - m[12] * m[5] * m[10] + - m[12] * m[6] * m[9]; - - inv[1] = -m[1] * m[10] * m[15] + - m[1] * m[11] * m[14] + - m[9] * m[2] * m[15] - - m[9] * m[3] * m[14] - - m[13] * m[2] * m[11] + - m[13] * m[3] * m[10]; - - inv[5] = m[0] * m[10] * m[15] - - m[0] * m[11] * m[14] - - m[8] * m[2] * m[15] + - m[8] * m[3] * m[14] + - m[12] * m[2] * m[11] - - m[12] * m[3] * m[10]; - - inv[9] = -m[0] * m[9] * m[15] + - m[0] * m[11] * m[13] + - m[8] * m[1] * m[15] - - m[8] * m[3] * m[13] - - m[12] * m[1] * m[11] + - m[12] * m[3] * m[9]; - - inv[13] = m[0] * m[9] * m[14] - - m[0] * m[10] * m[13] - - m[8] * m[1] * m[14] + - m[8] * m[2] * m[13] + - m[12] * m[1] * m[10] - - m[12] * m[2] * m[9]; - - inv[2] = m[1] * m[6] * m[15] - - m[1] * m[7] * m[14] - - m[5] * m[2] * m[15] + - m[5] * m[3] * m[14] + - m[13] * m[2] * m[7] - - m[13] * m[3] * m[6]; - - inv[6] = -m[0] * m[6] * m[15] + - m[0] * m[7] * m[14] + - m[4] * m[2] * m[15] - - m[4] * m[3] * m[14] - - m[12] * m[2] * m[7] + - m[12] * m[3] * m[6]; - - inv[10] = m[0] * m[5] * m[15] - - m[0] * m[7] * m[13] - - m[4] * m[1] * m[15] + - m[4] * m[3] * m[13] + - m[12] * m[1] * m[7] - - m[12] * m[3] * m[5]; - - inv[14] = -m[0] * m[5] * m[14] + - m[0] * m[6] * m[13] + - m[4] * m[1] * m[14] - - m[4] * m[2] * m[13] - - m[12] * m[1] * m[6] + - m[12] * m[2] * m[5]; - - inv[3] = -m[1] * m[6] * m[11] + - m[1] * m[7] * m[10] + - m[5] * m[2] * m[11] - - m[5] * m[3] * m[10] - - m[9] * m[2] * m[7] + - m[9] * m[3] * m[6]; - - inv[7] = m[0] * m[6] * m[11] - - m[0] * m[7] * m[10] - - m[4] * m[2] * m[11] + - m[4] * m[3] * m[10] + - m[8] * m[2] * m[7] - - m[8] * m[3] * m[6]; - - inv[11] = -m[0] * m[5] * m[11] + - m[0] * m[7] * m[9] + - m[4] * m[1] * m[11] - - m[4] * m[3] * m[9] - - m[8] * m[1] * m[7] + - m[8] * m[3] * m[5]; - - inv[15] = m[0] * m[5] * m[10] - - m[0] * m[6] * m[9] - - m[4] * m[1] * m[10] + - m[4] * m[2] * m[9] + - m[8] * m[1] * m[6] - + inv[0] = m[5] * m[10] * m[15] - m[5] * m[11] * m[14] - m[9] * m[6] * m[15] + m[9] * m[7] * m[14] + + m[13] * m[6] * m[11] - m[13] * m[7] * m[10]; + + inv[4] = -m[4] * m[10] * m[15] + m[4] * m[11] * m[14] + m[8] * m[6] * m[15] - m[8] * m[7] * m[14] - + m[12] * m[6] * m[11] + m[12] * m[7] * m[10]; + + inv[8] = m[4] * m[9] * m[15] - m[4] * m[11] * m[13] - m[8] * m[5] * m[15] + m[8] * m[7] * m[13] + + m[12] * m[5] * m[11] - m[12] * m[7] * m[9]; + + inv[12] = -m[4] * m[9] * m[14] + m[4] * m[10] * m[13] + m[8] * m[5] * m[14] - m[8] * m[6] * m[13] - + m[12] * m[5] * m[10] + m[12] * m[6] * m[9]; + + inv[1] = -m[1] * m[10] * m[15] + m[1] * m[11] * m[14] + m[9] * m[2] * m[15] - m[9] * m[3] * m[14] - + m[13] * m[2] * m[11] + m[13] * m[3] * m[10]; + + inv[5] = m[0] * m[10] * m[15] - m[0] * m[11] * m[14] - m[8] * m[2] * m[15] + m[8] * m[3] * m[14] + + m[12] * m[2] * m[11] - m[12] * m[3] * m[10]; + + inv[9] = -m[0] * m[9] * m[15] + m[0] * m[11] * m[13] + m[8] * m[1] * m[15] - m[8] * m[3] * m[13] - + m[12] * m[1] * m[11] + m[12] * m[3] * m[9]; + + inv[13] = m[0] * m[9] * m[14] - m[0] * m[10] * m[13] - m[8] * m[1] * m[14] + m[8] * m[2] * m[13] + + m[12] * m[1] * m[10] - m[12] * m[2] * m[9]; + + inv[2] = m[1] * m[6] * m[15] - m[1] * m[7] * m[14] - m[5] * m[2] * m[15] + m[5] * m[3] * m[14] + + m[13] * m[2] * m[7] - m[13] * m[3] * m[6]; + + inv[6] = -m[0] * m[6] * m[15] + m[0] * m[7] * m[14] + m[4] * m[2] * m[15] - m[4] * m[3] * m[14] - + m[12] * m[2] * m[7] + m[12] * m[3] * m[6]; + + inv[10] = m[0] * m[5] * m[15] - m[0] * m[7] * m[13] - m[4] * m[1] * m[15] + m[4] * m[3] * m[13] + + m[12] * m[1] * m[7] - m[12] * m[3] * m[5]; + + inv[14] = -m[0] * m[5] * m[14] + m[0] * m[6] * m[13] + m[4] * m[1] * m[14] - m[4] * m[2] * m[13] - + m[12] * m[1] * m[6] + m[12] * m[2] * m[5]; + + inv[3] = -m[1] * m[6] * m[11] + m[1] * m[7] * m[10] + m[5] * m[2] * m[11] - m[5] * m[3] * m[10] - + m[9] * m[2] * m[7] + m[9] * m[3] * m[6]; + + inv[7] = m[0] * m[6] * m[11] - m[0] * m[7] * m[10] - m[4] * m[2] * m[11] + m[4] * m[3] * m[10] + + m[8] * m[2] * m[7] - m[8] * m[3] * m[6]; + + inv[11] = -m[0] * m[5] * m[11] + m[0] * m[7] * m[9] + m[4] * m[1] * m[11] - m[4] * m[3] * m[9] - + m[8] * m[1] * m[7] + m[8] * m[3] * m[5]; + + inv[15] = m[0] * m[5] * m[10] - m[0] * m[6] * m[9] - m[4] * m[1] * m[10] + m[4] * m[2] * m[9] + m[8] * m[1] * m[6] - m[8] * m[2] * m[5]; det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12]; diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp index a597ed474..a81de9c80 100644 --- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp +++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.cpp @@ -168,7 +168,8 @@ bool GameInteractor_Should(GIVanillaBehavior flag, bool result, void* opt) { GameInteractor::Instance->ExecuteHooks(flag, &result, opt); GameInteractor::Instance->ExecuteHooksForID(flag, flag, &result, opt); if (opt != nullptr) { - GameInteractor::Instance->ExecuteHooksForPtr((uintptr_t)opt, flag, &result, opt); + GameInteractor::Instance->ExecuteHooksForPtr((uintptr_t)opt, flag, + &result, opt); } GameInteractor::Instance->ExecuteHooksForFilter(flag, &result, opt); return result; diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h index af649297e..4b67bcf7e 100644 --- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h +++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h @@ -72,13 +72,11 @@ typedef uint32_t HOOK_ID; } class GameInteractor { -public: + public: static GameInteractor* Instance; // Game State - class State { - - }; + class State {}; // Game Hooks HOOK_ID nextHookId = 1; @@ -98,7 +96,8 @@ class GameInteractor { // General Hooks template HOOK_ID RegisterGameHook(typename H::fn h) { - if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) this->nextHookId = 1; + if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) + this->nextHookId = 1; while (RegisteredGameHooks::functions.find(this->nextHookId) != RegisteredGameHooks::functions.end()) { this->nextHookId++; } @@ -107,7 +106,8 @@ class GameInteractor { return this->nextHookId++; } template void UnregisterGameHook(HOOK_ID hookId) { - if (hookId == 0) return; + if (hookId == 0) + return; HooksToUnregister::hooks.push_back(hookId); } template void ExecuteHooks(Args&&... args) { @@ -122,8 +122,10 @@ class GameInteractor { // ID based Hooks template HOOK_ID RegisterGameHookForID(int32_t id, typename H::fn h) { - if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) this->nextHookId = 1; - while (RegisteredGameHooks::functionsForID[id].find(this->nextHookId) != RegisteredGameHooks::functionsForID[id].end()) { + if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) + this->nextHookId = 1; + while (RegisteredGameHooks::functionsForID[id].find(this->nextHookId) != + RegisteredGameHooks::functionsForID[id].end()) { this->nextHookId++; } @@ -131,15 +133,19 @@ class GameInteractor { return this->nextHookId++; } template void UnregisterGameHookForID(HOOK_ID hookId) { - if (hookId == 0) return; + if (hookId == 0) + return; HooksToUnregister::hooksForID.push_back(hookId); } template void ExecuteHooksForID(int32_t id, Args&&... args) { for (auto& hookId : HooksToUnregister::hooksForID) { - for (auto it = RegisteredGameHooks::functionsForID[id].begin(); it != RegisteredGameHooks::functionsForID[id].end(); ) { + for (auto it = RegisteredGameHooks::functionsForID[id].begin(); + it != RegisteredGameHooks::functionsForID[id].end();) { if (it->first == hookId) { it = RegisteredGameHooks::functionsForID[id].erase(it); - HooksToUnregister::hooksForID.erase(std::remove(HooksToUnregister::hooksForID.begin(), HooksToUnregister::hooksForID.end(), hookId), HooksToUnregister::hooksForID.end()); + HooksToUnregister::hooksForID.erase(std::remove(HooksToUnregister::hooksForID.begin(), + HooksToUnregister::hooksForID.end(), hookId), + HooksToUnregister::hooksForID.end()); } else { ++it; } @@ -152,8 +158,10 @@ class GameInteractor { // PTR based Hooks template HOOK_ID RegisterGameHookForPtr(uintptr_t ptr, typename H::fn h) { - if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) this->nextHookId = 1; - while (RegisteredGameHooks::functionsForPtr[ptr].find(this->nextHookId) != RegisteredGameHooks::functionsForPtr[ptr].end()) { + if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) + this->nextHookId = 1; + while (RegisteredGameHooks::functionsForPtr[ptr].find(this->nextHookId) != + RegisteredGameHooks::functionsForPtr[ptr].end()) { this->nextHookId++; } @@ -161,15 +169,20 @@ class GameInteractor { return this->nextHookId++; } template void UnregisterGameHookForPtr(HOOK_ID hookId) { - if (hookId == 0) return; + if (hookId == 0) + return; HooksToUnregister::hooksForPtr.push_back(hookId); } template void ExecuteHooksForPtr(uintptr_t ptr, Args&&... args) { for (auto& hookId : HooksToUnregister::hooksForPtr) { - for (auto it = RegisteredGameHooks::functionsForPtr[ptr].begin(); it != RegisteredGameHooks::functionsForPtr[ptr].end(); ) { + for (auto it = RegisteredGameHooks::functionsForPtr[ptr].begin(); + it != RegisteredGameHooks::functionsForPtr[ptr].end();) { if (it->first == hookId) { it = RegisteredGameHooks::functionsForPtr[ptr].erase(it); - HooksToUnregister::hooksForPtr.erase(std::remove(HooksToUnregister::hooksForPtr.begin(), HooksToUnregister::hooksForPtr.end(), hookId), HooksToUnregister::hooksForPtr.end()); + HooksToUnregister::hooksForPtr.erase(std::remove(HooksToUnregister::hooksForPtr.begin(), + HooksToUnregister::hooksForPtr.end(), + hookId), + HooksToUnregister::hooksForPtr.end()); } else { ++it; } @@ -182,8 +195,10 @@ class GameInteractor { // Filter based Hooks template HOOK_ID RegisterGameHookForFilter(typename H::filter f, typename H::fn h) { - if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) this->nextHookId = 1; - while (RegisteredGameHooks::functionsForFilter.find(this->nextHookId) != RegisteredGameHooks::functionsForFilter.end()) { + if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) + this->nextHookId = 1; + while (RegisteredGameHooks::functionsForFilter.find(this->nextHookId) != + RegisteredGameHooks::functionsForFilter.end()) { this->nextHookId++; } @@ -191,7 +206,8 @@ class GameInteractor { return this->nextHookId++; } template void UnregisterGameHookForFilter(HOOK_ID hookId) { - if (hookId == 0) return; + if (hookId == 0) + return; HooksToUnregister::hooksForFilter.push_back(hookId); } template void ExecuteHooksForFilter(Args&&... args) { @@ -207,7 +223,7 @@ class GameInteractor { } class HookFilter { - public: + public: static auto ActorNotPlayer(Actor* actor) { return actor->id != ACTOR_PLAYER; } @@ -216,15 +232,11 @@ class GameInteractor { return actor->id != ACTOR_PLAYER; } static auto ActorMatchIdAndParams(int16_t id, int16_t params) { - return [id, params](Actor* actor) { - return actor->id == id && actor->params == params; - }; + return [id, params](Actor* actor) { return actor->id == id && actor->params == params; }; } // For use with Should hooks static auto SActorMatchIdAndParams(int16_t id, int16_t params) { - return [id, params](Actor* actor, bool* result) { - return actor->id == id && actor->params == params; - }; + return [id, params](Actor* actor, bool* result) { return actor->id == id && actor->params == params; }; } }; @@ -238,22 +250,22 @@ class GameInteractor { DEFINE_HOOK(OnSceneInit, (s8 sceneId, s8 spawnNum)); DEFINE_HOOK(OnRoomInit, (s8 sceneId, s8 roomNum)); - DEFINE_HOOK(ShouldActorInit, (Actor* actor, bool* should)); - DEFINE_HOOK(OnActorInit, (Actor* actor)); - DEFINE_HOOK(ShouldActorUpdate, (Actor* actor, bool* should)); - DEFINE_HOOK(OnActorUpdate, (Actor* actor)); - DEFINE_HOOK(ShouldActorDraw, (Actor* actor, bool* should)); - DEFINE_HOOK(OnActorDraw, (Actor* actor)); - DEFINE_HOOK(OnActorKill, (Actor* actor)); + DEFINE_HOOK(ShouldActorInit, (Actor * actor, bool* should)); + DEFINE_HOOK(OnActorInit, (Actor * actor)); + DEFINE_HOOK(ShouldActorUpdate, (Actor * actor, bool* should)); + DEFINE_HOOK(OnActorUpdate, (Actor * actor)); + DEFINE_HOOK(ShouldActorDraw, (Actor * actor, bool* should)); + DEFINE_HOOK(OnActorDraw, (Actor * actor)); + DEFINE_HOOK(OnActorKill, (Actor * actor)); DEFINE_HOOK(OnSceneFlagSet, (s16 sceneId, FlagType flagType, u32 flag)); DEFINE_HOOK(OnSceneFlagUnset, (s16 sceneId, FlagType flagType, u32 flag)); DEFINE_HOOK(OnFlagSet, (FlagType flagType, u32 flag)); DEFINE_HOOK(OnFlagUnset, (FlagType flagType, u32 flag)); - DEFINE_HOOK(OnCameraChangeModeFlags, (Camera* camera)); + DEFINE_HOOK(OnCameraChangeModeFlags, (Camera * camera)); - DEFINE_HOOK(OnPassPlayerInputs, (Input* input)); + DEFINE_HOOK(OnPassPlayerInputs, (Input * input)); DEFINE_HOOK(OnOpenText, (u16 textId)); @@ -299,8 +311,9 @@ bool GameInteractor_ShouldItemGive(u8 item); void GameInteractor_ExecuteOnItemGive(u8 item); bool GameInteractor_Should(GIVanillaBehavior flag, bool result, void* optionalArg); -#define REGISTER_VB_SHOULD(flag, body) \ - GameInteractor::Instance->RegisterGameHookForID(flag, [](GIVanillaBehavior _, bool* should, void* opt) body) +#define REGISTER_VB_SHOULD(flag, body) \ + GameInteractor::Instance->RegisterGameHookForID( \ + flag, [](GIVanillaBehavior _, bool* should, void* opt) body) int GameInteractor_InvertControl(GIInvertType type); diff --git a/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp b/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp index 90e5db6b6..78da2596a 100644 --- a/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp +++ b/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp @@ -24,8 +24,8 @@ void PatchMiniGameCrossAndCircleSymbols() { // The X and O displayed in mini-games are incorrectly set to FMT_I instead of FMT_IA, // Fast3D throws an assert and does nothing as FMT_I with SIZ_16 is not a valid texture type. // Patching all the relevant instructions to use FMT_IA matching the exported texture - const char* dLists[] = { gShootingGalleryOctorokCrossDL, gShootingGalleryOctorokCircleDL, - gObjJgameLightIncorrectDL, gObjJgameLightCorrectDL }; + const char* dLists[] = { gShootingGalleryOctorokCrossDL, gShootingGalleryOctorokCircleDL, gObjJgameLightIncorrectDL, + gObjJgameLightCorrectDL }; for (auto& dl : dLists) { Gfx* instructions = ResourceMgr_LoadGfxByName(dl); diff --git a/mm/2s2h/Enhancements/Graphics/MotionBlur.cpp b/mm/2s2h/Enhancements/Graphics/MotionBlur.cpp index 4ffee97ed..d7afd78e1 100644 --- a/mm/2s2h/Enhancements/Graphics/MotionBlur.cpp +++ b/mm/2s2h/Enhancements/Graphics/MotionBlur.cpp @@ -11,14 +11,16 @@ const char* motionBlurOptions[] = { "Dynamic (default)", "Always Off", "Always O void MotionBlur_RenderMenuOptions() { ImGui::SeparatorText("Motion Blur"); - UIWidgets::CVarCombobox("Motion Blur Mode", "gEnhancements.Graphics.MotionBlur.Mode", motionBlurOptions, { - .labelPosition = UIWidgets::LabelPosition::None, - }); + UIWidgets::CVarCombobox("Motion Blur Mode", "gEnhancements.Graphics.MotionBlur.Mode", motionBlurOptions, + { + .labelPosition = UIWidgets::LabelPosition::None, + }); UIWidgets::CVarCheckbox( "Interpolate", "gEnhancements.Graphics.MotionBlur.Interpolate", - { .tooltip = "Change motion blur capture to also happen on interpolated frames instead of only on game frames.\n" - "This notably reduces the overall motion blur strength but smooths out the trails." }); + { .tooltip = + "Change motion blur capture to also happen on interpolated frames instead of only on game frames.\n" + "This notably reduces the overall motion blur strength but smooths out the trails." }); if (CVarGetInteger("gEnhancements.Graphics.MotionBlur.Mode", 0) == 0) { UIWidgets::Checkbox("On/Off", (bool*)&R_MOTION_BLUR_ENABLED); @@ -39,7 +41,8 @@ extern "C" void MotionBlur_Override(u8* status, s32* alpha) { *status = 0; *alpha = 0; } else if (CVarGetInteger("gEnhancements.Graphics.MotionBlur.Mode", 0) == 2) { - if (*status == 0) *status = 2; + if (*status == 0) + *status = 2; *alpha = CVarGetInteger("gEnhancements.Graphics.MotionBlur.Strength", 180); } } diff --git a/mm/2s2h/Enhancements/Graphics/MotionBlur.h b/mm/2s2h/Enhancements/Graphics/MotionBlur.h index f17441bd5..0719d0c17 100644 --- a/mm/2s2h/Enhancements/Graphics/MotionBlur.h +++ b/mm/2s2h/Enhancements/Graphics/MotionBlur.h @@ -9,7 +9,6 @@ void MotionBlur_RenderMenuOptions(); extern "C" { #endif - void MotionBlur_Override(u8* status, s32* alpha); #ifdef __cplusplus diff --git a/mm/2s2h/Enhancements/Graphics/PlayAsKafei.cpp b/mm/2s2h/Enhancements/Graphics/PlayAsKafei.cpp index f16c6d09e..9b3e6b45e 100644 --- a/mm/2s2h/Enhancements/Graphics/PlayAsKafei.cpp +++ b/mm/2s2h/Enhancements/Graphics/PlayAsKafei.cpp @@ -31,7 +31,8 @@ void UpdatePlayAsKafeiSkeletons() { void UpdatePlayAsKafeiOther() { if (CVarGetInteger("gModes.PlayAsKafei", 0)) { - ResourceMgr_PatchGfxByName(gLinkHumanWaistDL, "gLinkHumanWaistDL0", 0, gsSPDisplayListOTRFilePath(gKafeiWaistDL)); + ResourceMgr_PatchGfxByName(gLinkHumanWaistDL, "gLinkHumanWaistDL0", 0, + gsSPDisplayListOTRFilePath(gKafeiWaistDL)); ResourceMgr_PatchGfxByName(gLinkHumanWaistDL, "gLinkHumanWaistDL1", 1, gsSPEndDisplayList()); sPlayerEyesTextures[PLAYER_FORM_HUMAN][0] = (TexturePtr)gKafeiEyesOpenTex; @@ -50,7 +51,7 @@ void UpdatePlayAsKafeiOther() { } else { ResourceMgr_UnpatchGfxByName(gLinkHumanWaistDL, "gLinkHumanWaistDL0"); ResourceMgr_UnpatchGfxByName(gLinkHumanWaistDL, "gLinkHumanWaistDL1"); - + sPlayerEyesTextures[PLAYER_FORM_HUMAN][0] = (TexturePtr)gLinkHumanEyesOpenTex; sPlayerEyesTextures[PLAYER_FORM_HUMAN][1] = (TexturePtr)gLinkHumanEyesHalfTex; sPlayerEyesTextures[PLAYER_FORM_HUMAN][2] = (TexturePtr)gLinkHumanEyesClosedTex; @@ -80,7 +81,6 @@ void RegisterPlayAsKafei() { UpdatePlayAsKafeiSkeletons(); UpdatePlayAsKafeiOther(); - GameInteractor::Instance->RegisterGameHook([] (s8 sceneId, s8 spawnNum) { - UpdatePlayAsKafeiOther(); - }); + GameInteractor::Instance->RegisterGameHook( + [](s8 sceneId, s8 spawnNum) { UpdatePlayAsKafeiOther(); }); } diff --git a/mm/2s2h/Enhancements/Graphics/TextBasedClock.cpp b/mm/2s2h/Enhancements/Graphics/TextBasedClock.cpp index a7ce7aa32..70b70ccc2 100644 --- a/mm/2s2h/Enhancements/Graphics/TextBasedClock.cpp +++ b/mm/2s2h/Enhancements/Graphics/TextBasedClock.cpp @@ -14,7 +14,6 @@ extern PlayState* gPlayState; void RegisterTextBasedClock() { REGISTER_VB_SHOULD(GI_VB_PREVENT_CLOCK_DISPLAY, { - if (CVarGetInteger("gEnhancements.Graphics.ClockType", CLOCK_TYPE_ORIGINAL) == CLOCK_TYPE_TEXT_BASED) { *should = true; @@ -29,11 +28,13 @@ void RegisterTextBasedClock() { (gPlayState->msgCtx.msgMode == MSGMODE_NONE) || ((gPlayState->msgCtx.currentTextId >= 0x100) && (gPlayState->msgCtx.currentTextId <= 0x200)) || (gSaveContext.gameMode == GAMEMODE_END_CREDITS)) && - !FrameAdvance_IsEnabled(&gPlayState->state) && !Environment_IsTimeStopped() && (gSaveContext.save.day <= 3)) { + !FrameAdvance_IsEnabled(&gPlayState->state) && !Environment_IsTimeStopped() && + (gSaveContext.save.day <= 3)) { OPEN_DISPS(gPlayState->state.gfxCtx); - if ((gPlayState->pauseCtx.state == PAUSE_STATE_OFF) && (gPlayState->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if ((gPlayState->pauseCtx.state == PAUSE_STATE_OFF) && + (gPlayState->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { Gfx_SetupDL39_Overlay(gPlayState->state.gfxCtx); u16 curMinutes = (s32)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60; diff --git a/mm/2s2h/Enhancements/Masks/FastTransformation.cpp b/mm/2s2h/Enhancements/Masks/FastTransformation.cpp index 53538f3cc..27a0e0498 100644 --- a/mm/2s2h/Enhancements/Masks/FastTransformation.cpp +++ b/mm/2s2h/Enhancements/Masks/FastTransformation.cpp @@ -28,7 +28,8 @@ void RegisterFastTransformation() { func_8012F73C(&gPlayState->objectCtx, player->actor.objectSlot, objectId); player->actor.objectSlot = Object_GetSlot(&gPlayState->objectCtx, GAMEPLAY_KEEP); - s32 objectSlot = Object_GetSlot(&gPlayState->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); + s32 objectSlot = + Object_GetSlot(&gPlayState->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); player->actor.objectSlot = objectSlot; player->actor.shape.rot.z = GET_PLAYER_FORM + 1; player->actor.init = PlayerCall_Init; diff --git a/mm/2s2h/Enhancements/Minigames/AlwaysWinDoggyRace.cpp b/mm/2s2h/Enhancements/Minigames/AlwaysWinDoggyRace.cpp index b0e00122c..2121476aa 100644 --- a/mm/2s2h/Enhancements/Minigames/AlwaysWinDoggyRace.cpp +++ b/mm/2s2h/Enhancements/Minigames/AlwaysWinDoggyRace.cpp @@ -3,12 +3,11 @@ #include "Enhancements/Enhancements.h" extern "C" { - #include - extern SaveContext gSaveContext; - extern u8 gItemSlots[77]; +#include +extern SaveContext gSaveContext; +extern u8 gItemSlots[77]; } - void RegisterAlwaysWinDoggyRace() { REGISTER_VB_SHOULD(GI_VB_DOGGY_RACE_SET_MAX_SPEED, { uint8_t selectedOption = CVarGetInteger("gEnhancements.Minigames.AlwaysWinDoggyRace", 0); diff --git a/mm/2s2h/Enhancements/PlayerMovement/ClimbSpeed.cpp b/mm/2s2h/Enhancements/PlayerMovement/ClimbSpeed.cpp index f170af77a..60296c423 100644 --- a/mm/2s2h/Enhancements/PlayerMovement/ClimbSpeed.cpp +++ b/mm/2s2h/Enhancements/PlayerMovement/ClimbSpeed.cpp @@ -3,7 +3,7 @@ void RegisterClimbSpeed() { REGISTER_VB_SHOULD(GI_VB_SET_CLIMB_SPEED, { - if (CVarGetInteger("gEnhancements.PlayerMovement.ClimbSpeed", 1) >1) { + if (CVarGetInteger("gEnhancements.PlayerMovement.ClimbSpeed", 1) > 1) { f32* speed = static_cast(opt); *speed *= CVarGetInteger("gEnhancements.PlayerMovement.ClimbSpeed", 1); } diff --git a/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp b/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp index a75271b21..e3dcfe00c 100644 --- a/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp +++ b/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp @@ -2,7 +2,7 @@ #include "Enhancements/GameInteractor/GameInteractor.h" extern "C" { - #include +#include } void RegisterEnableSunsSong() { diff --git a/mm/2s2h/Extractor/Extract.cpp b/mm/2s2h/Extractor/Extract.cpp index 95e154522..6c9d2a079 100644 --- a/mm/2s2h/Extractor/Extract.cpp +++ b/mm/2s2h/Extractor/Extract.cpp @@ -62,9 +62,8 @@ static constexpr uint32_t OOT_PAL_11 = 0xB2055FBD; static constexpr uint32_t MM_US_10 = 0x5354631C; static constexpr uint32_t MM_US_GC = 0xB443EB08; -static const std::unordered_map verMap = { - { MM_US_10, "US 1.0" }, - { MM_US_GC, "US GC"}, +static const std::unordered_map verMap = { + { MM_US_10, "US 1.0" }, { MM_US_GC, "US GC" }, //{ OOT_PAL_GC, "PAL Gamecube" }, //{ OOT_PAL_MQ, "PAL MQ" }, //{ OOT_PAL_GC_DBG1, "PAL Debug 1" }, @@ -78,16 +77,16 @@ static const std::unordered_map verMap = { static constexpr std::array goodCrcs = { 0x96F49400, // MM US 1.0 32MB 0xBB434787, // MM GC - //0xfa8c0555, // MQ DBG 64MB (Original overdump) - //0x8652ac4c, // MQ DBG 64MB - //0x5B8A1EB7, // MQ DBG 64MB (Empty overdump) - //0x1f731ffe, // MQ DBG 54MB - //0x044b3982, // NMQ DBG 54MB - //0xEB15D7B9, // NMQ DBG 64MB - //0xDA8E61BF, // GC PAL - //0x7A2FAE68, // GC MQ PAL - //0xFD9913B1, // N64 PAL 1.0 - //0xE033FBBA, // N64 PAL 1.1 + // 0xfa8c0555, // MQ DBG 64MB (Original overdump) + // 0x8652ac4c, // MQ DBG 64MB + // 0x5B8A1EB7, // MQ DBG 64MB (Empty overdump) + // 0x1f731ffe, // MQ DBG 54MB + // 0x044b3982, // NMQ DBG 54MB + // 0xEB15D7B9, // NMQ DBG 64MB + // 0xDA8E61BF, // GC PAL + // 0x7A2FAE68, // GC MQ PAL + // 0xFD9913B1, // N64 PAL 1.0 + // 0xE033FBBA, // N64 PAL 1.1 }; enum class ButtonId : int { @@ -96,7 +95,6 @@ enum class ButtonId : int { FIND, }; - void Extractor::ShowErrorBox(const char* title, const char* text) { #ifdef _WIN32 MessageBoxA(nullptr, text, title, MB_OK | MB_ICONERROR); @@ -198,8 +196,7 @@ void Extractor::FilterRoms(std::vector& roms, RomSearchMode searchM // Rom doesn't claim to be valid // Game type doesn't match search mode - if (!verMap.contains(GetRomVerCrc()) || - (searchMode == RomSearchMode::Vanilla && IsMasterQuest()) || + if (!verMap.contains(GetRomVerCrc()) || (searchMode == RomSearchMode::Vanilla && IsMasterQuest()) || (searchMode == RomSearchMode::MQ && !IsMasterQuest())) { it = roms.erase(it); continue; @@ -242,8 +239,7 @@ void Extractor::GetRoms(std::vector& roms) { // Get the position of the extension character. char* ext = strrchr(dir->d_name, '.'); - if (ext != NULL && (strcmp(ext, ".z64") == 0 || strcmp(ext, ".n64") == 0 || - strcmp(ext, ".v64") == 0)) { + if (ext != NULL && (strcmp(ext, ".z64") == 0 || strcmp(ext, ".n64") == 0 || strcmp(ext, ".v64") == 0)) { roms.push_back(dir->d_name); } } @@ -272,7 +268,8 @@ bool Extractor::GetRomPathFromBox() { box.lpstrFile = nameBuffer; box.nMaxFile = sizeof(nameBuffer) / sizeof(nameBuffer[0]); box.lpstrTitle = "Open Rom"; - box.Flags = OFN_NOCHANGEDIR | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; + box.Flags = + OFN_NOCHANGEDIR | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; box.lpstrFilter = "N64 Roms\0*.z64;*.v64;*.n64\0\0"; if (!GetOpenFileNameA(&box)) { DWORD err = CommDlgExtendedError(); @@ -299,7 +296,7 @@ bool Extractor::GetRomPathFromBox() { return false; } mCurrentRomPath = nameBuffer; - #else +#else auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64 *.n64 *.v64" }).result(); if (selection.empty()) { @@ -307,7 +304,7 @@ bool Extractor::GetRomPathFromBox() { } mCurrentRomPath = selection[0]; - #endif +#endif mCurRomSize = GetCurRomSize(); return true; } @@ -388,7 +385,9 @@ bool Extractor::ManuallySearchForRomMatchingType(RomSearchMode searchMode) { } char msgBuf[150]; - snprintf(msgBuf, 150, "The selected rom does not match the expected game type\nExpected type: %s.\n\nDo you want to search again?", + snprintf( + msgBuf, 150, + "The selected rom does not match the expected game type\nExpected type: %s.\n\nDo you want to search again?", searchMode == RomSearchMode::MQ ? "Master Quest" : "Vanilla"); while ((searchMode == RomSearchMode::Vanilla && IsMasterQuest()) || @@ -522,7 +521,7 @@ const char* Extractor::GetZapdVerStr() const { std::string Extractor::Mkdtemp() { std::string temp_dir = std::filesystem::temp_directory_path().string(); - + // create 6 random alphanumeric characters static const char charset[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; std::random_device rd; @@ -559,7 +558,7 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { std::string curdir = std::filesystem::current_path().string(); #ifdef _WIN32 std::filesystem::copy(installPath + "/assets", tempdir + "/assets", - std::filesystem::copy_options::recursive | std::filesystem::copy_options::update_existing); + std::filesystem::copy_options::recursive | std::filesystem::copy_options::update_existing); #else std::filesystem::create_symlink(installPath + "/assets", tempdir + "/assets"); #endif @@ -593,12 +592,16 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { // Grab a handle to the command window. HWND cmdWindow = GetConsoleWindow(); - // Normally the command window is hidden. We want the window to be shown here so the user can see the progess of the extraction. + // Normally the command window is hidden. We want the window to be shown here so the user can see the progess of the + // extraction. ShowWindow(cmdWindow, SW_SHOW); SetWindowPos(cmdWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); #else // Show extraction in background message until linux/mac can have visual progress - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Extracting", "Extraction will now begin in the background.\n\nPlease be patient for the process to finish. Do not close the main program.", nullptr); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Extracting", + "Extraction will now begin in the background.\n\nPlease be patient for the process to " + "finish. Do not close the main program.", + nullptr); #endif zapd_main(argc, (char**)argv.data()); diff --git a/mm/2s2h/Extractor/Extract.h b/mm/2s2h/Extractor/Extract.h index 6c9b4a078..4109c6196 100644 --- a/mm/2s2h/Extractor/Extract.h +++ b/mm/2s2h/Extractor/Extract.h @@ -20,9 +20,9 @@ static constexpr size_t MB54 = 54 * MB_BASE; static constexpr size_t MB64 = 64 * MB_BASE; enum class RomSearchMode { - Both = 0, - Vanilla = 1, - MQ = 2, + Both = 0, + Vanilla = 1, + MQ = 2, }; class Extractor { @@ -51,7 +51,7 @@ class Extractor { bool ManuallySearchForRomMatchingType(RomSearchMode searchMode); public: - //TODO create some kind of abstraction for message boxes. + // TODO create some kind of abstraction for message boxes. static int ShowYesNoBox(const char* title, const char* text); static void ShowErrorBox(const char* title, const char* text); bool IsMasterQuest() const; diff --git a/mm/2s2h/Extractor/FastCrc32C.c b/mm/2s2h/Extractor/FastCrc32C.c index d88b04beb..2dccda61e 100644 --- a/mm/2s2h/Extractor/FastCrc32C.c +++ b/mm/2s2h/Extractor/FastCrc32C.c @@ -2,7 +2,8 @@ #include // Force the compiler to assume we have support for the CRC32 intrinsic. We will check for our selves later. -// Clang will define both __llvm__ and __GNUC__ but GCC will only define __GNUC__. So we need to check for __llvm__ first. +// Clang will define both __llvm__ and __GNUC__ but GCC will only define __GNUC__. So we need to check for __llvm__ +// first. #if ((defined(__llvm__) && (defined(__x86_64__) || defined(__i386__)))) #pragma clang attribute push(__attribute__((target("crc32"))), apply_to = function) #elif ((defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)))) @@ -11,7 +12,8 @@ #pragma GCC target("sse4.2") #endif -// Include headers for the CRC32 intrinsic and cpuid instruction on windows. No need to do any other checks because it assumes the target will support CRC32 +// Include headers for the CRC32 intrinsic and cpuid instruction on windows. No need to do any other checks because it +// assumes the target will support CRC32 #ifdef _WIN32 #include #include @@ -68,7 +70,8 @@ static const uint32_t crc32Table[256] = { 0xE03E9C81L, 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L }; -// On platforms that we know will never support a crc32 instruction (such as the WiiU) we will skip compiling this function in. +// On platforms that we know will never support a crc32 instruction (such as the WiiU) we will skip compiling this +// function in. #ifndef NO_CRC_INTRIN static uint32_t CRC32IntrinImpl(unsigned char* data, size_t dataSize) { @@ -123,7 +126,7 @@ uint32_t CRC32C(unsigned char* data, size_t dataSize) { #ifdef _WIN32 __cpuid(cpuidData, 1); #elif __APPLE__ || (defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)) -// Every Mac that supports SoH should support this instruction. Also check for ARM64 at the same time + // Every Mac that supports SoH should support this instruction. Also check for ARM64 at the same time return CRC32IntrinImpl(data, dataSize); #else __get_cpuid(1, &cpuidData[0], &cpuidData[1], &cpuidData[2], &cpuidData[3]); diff --git a/mm/2s2h/Extractor/portable-file-dialogs.h b/mm/2s2h/Extractor/portable-file-dialogs.h index 1fc79a291..6deb9ed66 100644 --- a/mm/2s2h/Extractor/portable-file-dialogs.h +++ b/mm/2s2h/Extractor/portable-file-dialogs.h @@ -14,7 +14,7 @@ #if _WIN32 #ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN 1 +#define WIN32_LEAN_AND_MEAN 1 #endif #include #include @@ -22,20 +22,20 @@ #include // IFileDialog #include #include -#include // std::async -#include // GetUserProfileDirectory() +#include // std::async +#include // GetUserProfileDirectory() #elif __EMSCRIPTEN__ #include #else #ifndef _POSIX_C_SOURCE -# define _POSIX_C_SOURCE 2 // for popen() +#define _POSIX_C_SOURCE 2 // for popen() #endif #ifdef __APPLE__ -# ifndef _DARWIN_C_SOURCE -# define _DARWIN_C_SOURCE -# endif +#ifndef _DARWIN_C_SOURCE +#define _DARWIN_C_SOURCE +#endif #endif #include // popen() #include // std::getenv() @@ -58,20 +58,18 @@ // Versions of mingw64 g++ up to 9.3.0 do not have a complete IFileDialog #ifndef PFD_HAS_IFILEDIALOG -# define PFD_HAS_IFILEDIALOG 1 -# if (defined __MINGW64__ || defined __MINGW32__) && defined __GXX_ABI_VERSION -# if __GXX_ABI_VERSION <= 1013 -# undef PFD_HAS_IFILEDIALOG -# define PFD_HAS_IFILEDIALOG 0 -# endif -# endif +#define PFD_HAS_IFILEDIALOG 1 +#if (defined __MINGW64__ || defined __MINGW32__) && defined __GXX_ABI_VERSION +#if __GXX_ABI_VERSION <= 1013 +#undef PFD_HAS_IFILEDIALOG +#define PFD_HAS_IFILEDIALOG 0 +#endif +#endif #endif -namespace pfd -{ +namespace pfd { -enum class button -{ +enum class button { cancel = -1, ok, yes, @@ -81,8 +79,7 @@ enum class button ignore, }; -enum class choice -{ +enum class choice { ok = 0, ok_cancel, yes_no, @@ -91,8 +88,7 @@ enum class choice abort_retry_ignore, }; -enum class icon -{ +enum class icon { info = 0, warning, error, @@ -100,43 +96,44 @@ enum class icon }; // Additional option flags for various dialog constructors -enum class opt : uint8_t -{ +enum class opt : uint8_t { none = 0, // For file open, allow multiselect. - multiselect = 0x1, + multiselect = 0x1, // For file save, force overwrite and disable the confirmation dialog. force_overwrite = 0x2, // For folder select, force path to be the provided argument instead // of the last opened directory, which is the Microsoft-recommended, // user-friendly behaviour. - force_path = 0x4, + force_path = 0x4, }; -inline opt operator |(opt a, opt b) { return opt(uint8_t(a) | uint8_t(b)); } -inline bool operator &(opt a, opt b) { return bool(uint8_t(a) & uint8_t(b)); } +inline opt operator|(opt a, opt b) { + return opt(uint8_t(a) | uint8_t(b)); +} +inline bool operator&(opt a, opt b) { + return bool(uint8_t(a) & uint8_t(b)); +} // The settings class, only exposing to the user a way to set verbose mode // and to force a rescan of installed desktop helpers (zenity, kdialog…). -class settings -{ -public: +class settings { + public: static bool available(); static void verbose(bool value); static void rescan(); -protected: + protected: explicit settings(bool resync = false); - bool check_program(std::string const &program); + bool check_program(std::string const& program); inline bool is_osascript() const; inline bool is_zenity() const; inline bool is_kdialog() const; - enum class flag - { + enum class flag { is_scanned = 0, is_verbose, @@ -150,46 +147,44 @@ class settings }; // Static array of flags for internal state - bool const &flags(flag in_flag) const; + bool const& flags(flag in_flag) const; // Non-const getter for the static array of flags - bool &flags(flag in_flag); + bool& flags(flag in_flag); }; // Internal classes, not to be used by client applications -namespace internal -{ +namespace internal { // Process wait timeout, in milliseconds static int const default_wait_timeout = 20; -class executor -{ +class executor { friend class dialog; -public: + public: // High level function to get the result of a command - std::string result(int *exit_code = nullptr); + std::string result(int* exit_code = nullptr); // High level function to abort bool kill(); #if _WIN32 - void start_func(std::function const &fun); + void start_func(std::function const& fun); static BOOL CALLBACK enum_windows_callback(HWND hwnd, LPARAM lParam); #elif __EMSCRIPTEN__ void start(int exit_code); #else - void start_process(std::vector const &command); + void start_process(std::vector const& command); #endif ~executor(); -protected: + protected: bool ready(int timeout = default_wait_timeout); void stop(); -private: + private: bool m_running = false; std::string m_stdout; int m_exit_code = -1; @@ -207,106 +202,99 @@ class executor #endif }; -class platform -{ -protected: +class platform { + protected: #if _WIN32 // Helper class around LoadLibraryA() and GetProcAddress() with some safety - class dll - { - public: - dll(std::string const &name); + class dll { + public: + dll(std::string const& name); ~dll(); - template class proc - { - public: - proc(dll const &lib, std::string const &sym) - : m_proc(reinterpret_cast((void *)::GetProcAddress(lib.handle, sym.c_str()))) - {} + template class proc { + public: + proc(dll const& lib, std::string const& sym) + : m_proc(reinterpret_cast((void*)::GetProcAddress(lib.handle, sym.c_str()))) { + } - operator bool() const { return m_proc != nullptr; } - operator T *() const { return m_proc; } + operator bool() const { + return m_proc != nullptr; + } + operator T*() const { + return m_proc; + } - private: - T *m_proc; + private: + T* m_proc; }; - private: + private: HMODULE handle; }; // Helper class around CoInitialize() and CoUnInitialize() - class ole32_dll : public dll - { - public: + class ole32_dll : public dll { + public: ole32_dll(); ~ole32_dll(); bool is_initialized(); - private: + private: HRESULT m_state; }; // Helper class around CreateActCtx() and ActivateActCtx() - class new_style_context - { - public: + class new_style_context { + public: new_style_context(); ~new_style_context(); - private: + private: HANDLE create(); ULONG_PTR m_cookie = 0; }; #endif }; -class dialog : protected settings, protected platform -{ -public: +class dialog : protected settings, protected platform { + public: bool ready(int timeout = default_wait_timeout) const; bool kill() const; -protected: + protected: explicit dialog(); std::vector desktop_helper() const; static std::string buttons_to_name(choice _choice); static std::string get_icon_name(icon _icon); - std::string powershell_quote(std::string const &str) const; - std::string osascript_quote(std::string const &str) const; - std::string shell_quote(std::string const &str) const; + std::string powershell_quote(std::string const& str) const; + std::string osascript_quote(std::string const& str) const; + std::string shell_quote(std::string const& str) const; // Keep handle to executing command std::shared_ptr m_async; }; -class file_dialog : public dialog -{ -protected: - enum type - { +class file_dialog : public dialog { + protected: + enum type { open, save, folder, }; - file_dialog(type in_type, - std::string const &title, - std::string const &default_path = "", - std::vector const &filters = {}, - opt options = opt::none); + file_dialog(type in_type, std::string const& title, std::string const& default_path = "", + std::vector const& filters = {}, opt options = opt::none); -protected: + protected: std::string string_result(); std::vector vector_result(); #if _WIN32 static int CALLBACK bffcallback(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData); #if PFD_HAS_IFILEDIALOG - std::string select_folder_vista(IFileDialog *ifd, bool force_path); + std::string select_folder_vista(IFileDialog* ifd, bool force_path); #endif std::wstring m_wtitle; @@ -322,9 +310,8 @@ class file_dialog : public dialog // The path class provides some platform-specific path constants // -class path : protected internal::platform -{ -public: +class path : protected internal::platform { + public: static std::string home(); static std::string separator(); }; @@ -333,29 +320,23 @@ class path : protected internal::platform // The notify widget // -class notify : public internal::dialog -{ -public: - notify(std::string const &title, - std::string const &message, - icon _icon = icon::info); +class notify : public internal::dialog { + public: + notify(std::string const& title, std::string const& message, icon _icon = icon::info); }; // // The message widget // -class message : public internal::dialog -{ -public: - message(std::string const &title, - std::string const &text, - choice _choice = choice::ok_cancel, +class message : public internal::dialog { + public: + message(std::string const& title, std::string const& text, choice _choice = choice::ok_cancel, icon _icon = icon::info); button result(); -private: + private: // Some extra logic to map the exit code to button number std::map m_mappings; }; @@ -364,13 +345,10 @@ class message : public internal::dialog // The open_file, save_file, and open_folder widgets // -class open_file : public internal::file_dialog -{ -public: - open_file(std::string const &title, - std::string const &default_path = "", - std::vector const &filters = { "All Files", "*" }, - opt options = opt::none); +class open_file : public internal::file_dialog { + public: + open_file(std::string const& title, std::string const& default_path = "", + std::vector const& filters = { "All Files", "*" }, opt options = opt::none); #if defined(__has_cpp_attribute) #if __has_cpp_attribute(deprecated) @@ -378,21 +356,16 @@ class open_file : public internal::file_dialog [[deprecated("Use pfd::opt::multiselect instead of allow_multiselect")]] #endif #endif - open_file(std::string const &title, - std::string const &default_path, - std::vector const &filters, + open_file(std::string const& title, std::string const& default_path, std::vector const& filters, bool allow_multiselect); std::vector result(); }; -class save_file : public internal::file_dialog -{ -public: - save_file(std::string const &title, - std::string const &default_path = "", - std::vector const &filters = { "All Files", "*" }, - opt options = opt::none); +class save_file : public internal::file_dialog { + public: + save_file(std::string const& title, std::string const& default_path = "", + std::vector const& filters = { "All Files", "*" }, opt options = opt::none); #if defined(__has_cpp_attribute) #if __has_cpp_attribute(deprecated) @@ -400,20 +373,15 @@ class save_file : public internal::file_dialog [[deprecated("Use pfd::opt::force_overwrite instead of confirm_overwrite")]] #endif #endif - save_file(std::string const &title, - std::string const &default_path, - std::vector const &filters, + save_file(std::string const& title, std::string const& default_path, std::vector const& filters, bool confirm_overwrite); std::string result(); }; -class select_folder : public internal::file_dialog -{ -public: - select_folder(std::string const &title, - std::string const &default_path = "", - opt options = opt::none); +class select_folder : public internal::file_dialog { + public: + select_folder(std::string const& title, std::string const& default_path = "", opt options = opt::none); std::string result(); }; @@ -428,36 +396,30 @@ class select_folder : public internal::file_dialog // internal free functions implementations -namespace internal -{ +namespace internal { #if _WIN32 -static inline std::wstring str2wstr(std::string const &str) -{ +static inline std::wstring str2wstr(std::string const& str) { int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), (int)str.size(), nullptr, 0); std::wstring ret(len, '\0'); MultiByteToWideChar(CP_UTF8, 0, str.c_str(), (int)str.size(), (LPWSTR)ret.data(), (int)ret.size()); return ret; } -static inline std::string wstr2str(std::wstring const &str) -{ +static inline std::string wstr2str(std::wstring const& str) { int len = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), (int)str.size(), nullptr, 0, nullptr, nullptr); std::string ret(len, '\0'); WideCharToMultiByte(CP_UTF8, 0, str.c_str(), (int)str.size(), (LPSTR)ret.data(), (int)ret.size(), nullptr, nullptr); return ret; } -static inline bool is_vista() -{ +static inline bool is_vista() { OSVERSIONINFOEXW osvi; memset(&osvi, 0, sizeof(osvi)); - DWORDLONG const mask = VerSetConditionMask( - VerSetConditionMask( - VerSetConditionMask( - 0, VER_MAJORVERSION, VER_GREATER_EQUAL), - VER_MINORVERSION, VER_GREATER_EQUAL), - VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + DWORDLONG const mask = + VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL), + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); osvi.dwOSVersionInfoSize = sizeof(osvi); osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_VISTA); osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA); @@ -469,22 +431,17 @@ static inline bool is_vista() // This is necessary until C++20 which will have std::string::ends_with() etc. -static inline bool ends_with(std::string const &str, std::string const &suffix) -{ - return suffix.size() <= str.size() && - str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; +static inline bool ends_with(std::string const& str, std::string const& suffix) { + return suffix.size() <= str.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -static inline bool starts_with(std::string const &str, std::string const &prefix) -{ - return prefix.size() <= str.size() && - str.compare(0, prefix.size(), prefix) == 0; +static inline bool starts_with(std::string const& str, std::string const& prefix) { + return prefix.size() <= str.size() && str.compare(0, prefix.size(), prefix) == 0; } // This is necessary until C++17 which will have std::filesystem::is_directory -static inline bool is_directory(std::string const &path) -{ +static inline bool is_directory(std::string const& path) { #if _WIN32 auto attr = GetFileAttributesA(path.c_str()); return attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY); @@ -499,13 +456,11 @@ static inline bool is_directory(std::string const &path) // This is necessary because getenv is not thread-safe -static inline std::string getenv(std::string const &str) -{ +static inline std::string getenv(std::string const& str) { #if _MSC_VER - char *buf = nullptr; + char* buf = nullptr; size_t size = 0; - if (_dupenv_s(&buf, &size, str.c_str()) == 0 && buf) - { + if (_dupenv_s(&buf, &size, str.c_str()) == 0 && buf) { std::string ret(buf); free(buf); return ret; @@ -521,8 +476,7 @@ static inline std::string getenv(std::string const &str) // settings implementation -inline settings::settings(bool resync) -{ +inline settings::settings(bool resync) { flags(flag::is_scanned) &= !resync; if (flags(flag::is_scanned)) @@ -542,8 +496,7 @@ inline settings::settings(bool resync) flags(flag::has_kdialog) = check_program("kdialog"); // If multiple helpers are available, try to default to the best one - if (flags(flag::has_zenity) && flags(flag::has_kdialog)) - { + if (flags(flag::has_zenity) && flags(flag::has_kdialog)) { auto desktop_name = internal::getenv("XDG_SESSION_DESKTOP"); if (desktop_name == std::string("gnome")) flags(flag::has_kdialog) = false; @@ -555,8 +508,7 @@ inline settings::settings(bool resync) flags(flag::is_scanned) = true; } -inline bool settings::available() -{ +inline bool settings::available() { #if _WIN32 return true; #elif __APPLE__ @@ -566,26 +518,21 @@ inline bool settings::available() return false; #else settings tmp; - return tmp.flags(flag::has_zenity) || - tmp.flags(flag::has_matedialog) || - tmp.flags(flag::has_qarma) || + return tmp.flags(flag::has_zenity) || tmp.flags(flag::has_matedialog) || tmp.flags(flag::has_qarma) || tmp.flags(flag::has_kdialog); #endif } -inline void settings::verbose(bool value) -{ +inline void settings::verbose(bool value) { settings().flags(flag::is_verbose) = value; } -inline void settings::rescan() -{ +inline void settings::rescan() { settings(/* resync = */ true); } // Check whether a program is present using “which”. -inline bool settings::check_program(std::string const &program) -{ +inline bool settings::check_program(std::string const& program) { #if _WIN32 (void)program; return false; @@ -595,14 +542,13 @@ inline bool settings::check_program(std::string const &program) #else int exit_code = -1; internal::executor async; - async.start_process({"/bin/sh", "-c", "which " + program}); + async.start_process({ "/bin/sh", "-c", "which " + program }); async.result(&exit_code); return exit_code == 0; #endif } -inline bool settings::is_osascript() const -{ +inline bool settings::is_osascript() const { #if __APPLE__ return true; #else @@ -610,32 +556,25 @@ inline bool settings::is_osascript() const #endif } -inline bool settings::is_zenity() const -{ - return flags(flag::has_zenity) || - flags(flag::has_matedialog) || - flags(flag::has_qarma); +inline bool settings::is_zenity() const { + return flags(flag::has_zenity) || flags(flag::has_matedialog) || flags(flag::has_qarma); } -inline bool settings::is_kdialog() const -{ +inline bool settings::is_kdialog() const { return flags(flag::has_kdialog); } -inline bool const &settings::flags(flag in_flag) const -{ +inline bool const& settings::flags(flag in_flag) const { static bool flags[size_t(flag::max_flag)]; return flags[size_t(in_flag)]; } -inline bool &settings::flags(flag in_flag) -{ - return const_cast(static_cast(this)->flags(in_flag)); +inline bool& settings::flags(flag in_flag) { + return const_cast(static_cast(this)->flags(in_flag)); } // path implementation -inline std::string path::home() -{ +inline std::string path::home() { #if _WIN32 // First try the USERPROFILE environment variable auto user_profile = internal::getenv("USERPROFILE"); @@ -645,10 +584,9 @@ inline std::string path::home() HANDLE token = nullptr; DWORD len = MAX_PATH; char buf[MAX_PATH] = { '\0' }; - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) - { + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) { dll userenv("userenv.dll"); - dll::proc get_user_profile_directory(userenv, "GetUserProfileDirectoryA"); + dll::proc get_user_profile_directory(userenv, "GetUserProfileDirectoryA"); get_user_profile_directory(token, buf, &len); CloseHandle(token); if (*buf) @@ -676,8 +614,7 @@ inline std::string path::home() return "/"; } -inline std::string path::separator() -{ +inline std::string path::separator() { #if _WIN32 return "\\"; #else @@ -687,25 +624,21 @@ inline std::string path::separator() // executor implementation -inline std::string internal::executor::result(int *exit_code /* = nullptr */) -{ +inline std::string internal::executor::result(int* exit_code /* = nullptr */) { stop(); if (exit_code) *exit_code = m_exit_code; return m_stdout; } -inline bool internal::executor::kill() -{ +inline bool internal::executor::kill() { #if _WIN32 - if (m_future.valid()) - { + if (m_future.valid()) { // Close all windows that weren’t open when we started the future auto previous_windows = m_windows; EnumWindows(&enum_windows_callback, (LPARAM)this); for (auto hwnd : m_windows) - if (previous_windows.find(hwnd) == previous_windows.end()) - { + if (previous_windows.find(hwnd) == previous_windows.end()) { SendMessage(hwnd, WM_CLOSE, 0, 0); // Also send IDNO in case of a Yes/No or Abort/Retry/Ignore messagebox SendMessage(hwnd, WM_COMMAND, IDNO, 0); @@ -722,9 +655,8 @@ inline bool internal::executor::kill() } #if _WIN32 -inline BOOL CALLBACK internal::executor::enum_windows_callback(HWND hwnd, LPARAM lParam) -{ - auto that = (executor *)lParam; +inline BOOL CALLBACK internal::executor::enum_windows_callback(HWND hwnd, LPARAM lParam) { + auto that = (executor*)lParam; DWORD pid; auto tid = GetWindowThreadProcessId(hwnd, &pid); @@ -735,12 +667,10 @@ inline BOOL CALLBACK internal::executor::enum_windows_callback(HWND hwnd, LPARAM #endif #if _WIN32 -inline void internal::executor::start_func(std::function const &fun) -{ +inline void internal::executor::start_func(std::function const& fun) { stop(); - auto trampoline = [fun, this]() - { + auto trampoline = [fun, this]() { // Save our thread id so that the caller can cancel us m_tid = GetCurrentThreadId(); EnumWindows(&enum_windows_callback, (LPARAM)this); @@ -755,14 +685,12 @@ inline void internal::executor::start_func(std::function con } #elif __EMSCRIPTEN__ -inline void internal::executor::start(int exit_code) -{ +inline void internal::executor::start(int exit_code) { m_exit_code = exit_code; } #else -inline void internal::executor::start_process(std::vector const &command) -{ +inline void internal::executor::start_process(std::vector const& command) { stop(); m_stdout.clear(); m_exit_code = -1; @@ -778,8 +706,7 @@ inline void internal::executor::start_process(std::vector const &co close(in[m_pid ? 0 : 1]); close(out[m_pid ? 1 : 0]); - if (m_pid == 0) - { + if (m_pid == 0) { dup2(in[0], STDIN_FILENO); dup2(out[1], STDOUT_FILENO); @@ -788,9 +715,9 @@ inline void internal::executor::start_process(std::vector const &co dup2(fd, STDERR_FILENO); close(fd); - std::vector args; + std::vector args; std::transform(command.cbegin(), command.cend(), std::back_inserter(args), - [](std::string const &s) { return const_cast(s.c_str()); }); + [](std::string const& s) { return const_cast(s.c_str()); }); args.push_back(nullptr); // null-terminate argv[] execvp(args[0], args.data()); @@ -806,28 +733,23 @@ inline void internal::executor::start_process(std::vector const &co } #endif -inline internal::executor::~executor() -{ +inline internal::executor::~executor() { stop(); } -inline bool internal::executor::ready(int timeout /* = default_wait_timeout */) -{ +inline bool internal::executor::ready(int timeout /* = default_wait_timeout */) { if (!m_running) return true; #if _WIN32 - if (m_future.valid()) - { + if (m_future.valid()) { auto status = m_future.wait_for(std::chrono::milliseconds(timeout)); - if (status != std::future_status::ready) - { + if (status != std::future_status::ready) { // On Windows, we need to run the message pump. If the async // thread uses a Windows API dialog, it may be attached to the // main thread and waiting for messages that only we can dispatch. MSG msg; - while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) - { + while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -842,8 +764,7 @@ inline bool internal::executor::ready(int timeout /* = default_wait_timeout */) #else char buf[BUFSIZ]; ssize_t received = read(m_fd, buf, BUFSIZ); // Flawfinder: ignore - if (received > 0) - { + if (received > 0) { m_stdout += std::string(buf, received); return false; } @@ -854,8 +775,7 @@ inline bool internal::executor::ready(int timeout /* = default_wait_timeout */) // a little while. int status; pid_t child = waitpid(m_pid, &status, WNOHANG); - if (child != m_pid && (child >= 0 || errno != ECHILD)) - { + if (child != m_pid && (child >= 0 || errno != ECHILD)) { // FIXME: this happens almost always at first iteration std::this_thread::sleep_for(std::chrono::milliseconds(timeout)); return false; @@ -869,8 +789,7 @@ inline bool internal::executor::ready(int timeout /* = default_wait_timeout */) return true; } -inline void internal::executor::stop() -{ +inline void internal::executor::stop() { // Loop until the user closes the dialog while (!ready()) ; @@ -879,12 +798,10 @@ inline void internal::executor::stop() // dll implementation #if _WIN32 -inline internal::platform::dll::dll(std::string const &name) - : handle(::LoadLibraryA(name.c_str())) -{} +inline internal::platform::dll::dll(std::string const& name) : handle(::LoadLibraryA(name.c_str())) { +} -inline internal::platform::dll::~dll() -{ +inline internal::platform::dll::~dll() { if (handle) ::FreeLibrary(handle); } @@ -893,23 +810,19 @@ inline internal::platform::dll::~dll() // ole32_dll implementation #if _WIN32 -inline internal::platform::ole32_dll::ole32_dll() - : dll("ole32.dll") -{ +inline internal::platform::ole32_dll::ole32_dll() : dll("ole32.dll") { // Use COINIT_MULTITHREADED because COINIT_APARTMENTTHREADED causes crashes. // See https://github.com/samhocevar/portable-file-dialogs/issues/51 - auto coinit = proc(*this, "CoInitializeEx"); + auto coinit = proc(*this, "CoInitializeEx"); m_state = coinit(nullptr, COINIT_MULTITHREADED); } -inline internal::platform::ole32_dll::~ole32_dll() -{ +inline internal::platform::ole32_dll::~ole32_dll() { if (is_initialized()) - proc(*this, "CoUninitialize")(); + proc(*this, "CoUninitialize")(); } -inline bool internal::platform::ole32_dll::is_initialized() -{ +inline bool internal::platform::ole32_dll::is_initialized() { return m_state == S_OK || m_state == S_FALSE; } #endif @@ -917,8 +830,7 @@ inline bool internal::platform::ole32_dll::is_initialized() // new_style_context implementation #if _WIN32 -inline internal::platform::new_style_context::new_style_context() -{ +inline internal::platform::new_style_context::new_style_context() { // Only create one activation context for the whole app lifetime. static HANDLE hctx = create(); @@ -926,13 +838,11 @@ inline internal::platform::new_style_context::new_style_context() ActivateActCtx(hctx, &m_cookie); } -inline internal::platform::new_style_context::~new_style_context() -{ +inline internal::platform::new_style_context::~new_style_context() { DeactivateActCtx(0, m_cookie); } -inline HANDLE internal::platform::new_style_context::create() -{ +inline HANDLE internal::platform::new_style_context::create() { // This “hack” seems to be necessary for this code to work on windows XP. // Without it, dialogs do not show and close immediately. GetError() // returns 0 so I don’t know what causes this. I was not able to reproduce @@ -947,13 +857,18 @@ inline HANDLE internal::platform::new_style_context::create() std::string sys_dir(len, '\0'); ::GetSystemDirectoryA(&sys_dir[0], len); - ACTCTXA act_ctx = - { + ACTCTXA act_ctx = { // Do not set flag ACTCTX_FLAG_SET_PROCESS_DEFAULT, since it causes a // crash with error “default context is already set”. sizeof(act_ctx), ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID, - "shell32.dll", 0, 0, sys_dir.c_str(), (LPCSTR)124, nullptr, 0, + "shell32.dll", + 0, + 0, + sys_dir.c_str(), + (LPCSTR)124, + nullptr, + 0, }; return ::CreateActCtxA(&act_ctx); @@ -962,54 +877,54 @@ inline HANDLE internal::platform::new_style_context::create() // dialog implementation -inline bool internal::dialog::ready(int timeout /* = default_wait_timeout */) const -{ +inline bool internal::dialog::ready(int timeout /* = default_wait_timeout */) const { return m_async->ready(timeout); } -inline bool internal::dialog::kill() const -{ +inline bool internal::dialog::kill() const { return m_async->kill(); } -inline internal::dialog::dialog() - : m_async(std::make_shared()) -{ +inline internal::dialog::dialog() : m_async(std::make_shared()) { } -inline std::vector internal::dialog::desktop_helper() const -{ +inline std::vector internal::dialog::desktop_helper() const { #if __APPLE__ return { "osascript" }; #else return { flags(flag::has_zenity) ? "zenity" - : flags(flag::has_matedialog) ? "matedialog" - : flags(flag::has_qarma) ? "qarma" - : flags(flag::has_kdialog) ? "kdialog" - : "echo" }; + : flags(flag::has_matedialog) ? "matedialog" + : flags(flag::has_qarma) ? "qarma" + : flags(flag::has_kdialog) ? "kdialog" + : "echo" }; #endif } -inline std::string internal::dialog::buttons_to_name(choice _choice) -{ - switch (_choice) - { - case choice::ok_cancel: return "okcancel"; - case choice::yes_no: return "yesno"; - case choice::yes_no_cancel: return "yesnocancel"; - case choice::retry_cancel: return "retrycancel"; - case choice::abort_retry_ignore: return "abortretryignore"; - /* case choice::ok: */ default: return "ok"; +inline std::string internal::dialog::buttons_to_name(choice _choice) { + switch (_choice) { + case choice::ok_cancel: + return "okcancel"; + case choice::yes_no: + return "yesno"; + case choice::yes_no_cancel: + return "yesnocancel"; + case choice::retry_cancel: + return "retrycancel"; + case choice::abort_retry_ignore: + return "abortretryignore"; + /* case choice::ok: */ default: + return "ok"; } } -inline std::string internal::dialog::get_icon_name(icon _icon) -{ - switch (_icon) - { - case icon::warning: return "warning"; - case icon::error: return "error"; - case icon::question: return "question"; +inline std::string internal::dialog::get_icon_name(icon _icon) { + switch (_icon) { + case icon::warning: + return "warning"; + case icon::error: + return "error"; + case icon::question: + return "question"; // Zenity wants "information" but WinForms wants "info" /* case icon::info: */ default: #if _WIN32 @@ -1021,10 +936,9 @@ inline std::string internal::dialog::get_icon_name(icon _icon) } // This is only used for debugging purposes -inline std::ostream& operator <<(std::ostream &s, std::vector const &v) -{ +inline std::ostream& operator<<(std::ostream& s, std::vector const& v) { int not_first = 0; - for (auto &e : v) + for (auto& e : v) s << (not_first++ ? " " : "") << e; return s; } @@ -1033,47 +947,39 @@ inline std::ostream& operator <<(std::ostream &s, std::vector const // FIXME: we should probably get rid of newlines! // FIXME: the \" sequence seems unsafe, too! // XXX: this is no longer used but I would like to keep it around just in case -inline std::string internal::dialog::powershell_quote(std::string const &str) const -{ +inline std::string internal::dialog::powershell_quote(std::string const& str) const { return "'" + std::regex_replace(str, std::regex("['\"]"), "$&$&") + "'"; } // Properly quote a string for osascript: replace \ or " with \\ or \" // XXX: this also used to replace ' with \' when popen was used, but it would be // smarter to do shell_quote(osascript_quote(...)) if this is needed again. -inline std::string internal::dialog::osascript_quote(std::string const &str) const -{ +inline std::string internal::dialog::osascript_quote(std::string const& str) const { return "\"" + std::regex_replace(str, std::regex("[\\\\\"]"), "\\$&") + "\""; } // Properly quote a string for the shell: just replace ' with '\'' // XXX: this is no longer used but I would like to keep it around just in case -inline std::string internal::dialog::shell_quote(std::string const &str) const -{ +inline std::string internal::dialog::shell_quote(std::string const& str) const { return "'" + std::regex_replace(str, std::regex("'"), "'\\''") + "'"; } // file_dialog implementation -inline internal::file_dialog::file_dialog(type in_type, - std::string const &title, - std::string const &default_path /* = "" */, - std::vector const &filters /* = {} */, - opt options /* = opt::none */) -{ +inline internal::file_dialog::file_dialog(type in_type, std::string const& title, + std::string const& default_path /* = "" */, + std::vector const& filters /* = {} */, + opt options /* = opt::none */) { #if _WIN32 std::string filter_list; std::regex whitespace(" *"); - for (size_t i = 0; i + 1 < filters.size(); i += 2) - { + for (size_t i = 0; i + 1 < filters.size(); i += 2) { filter_list += filters[i] + '\0'; filter_list += std::regex_replace(filters[i + 1], whitespace, ";") + '\0'; } filter_list += '\0'; - m_async->start_func([this, in_type, title, default_path, filter_list, - options](int *exit_code) -> std::string - { + m_async->start_func([this, in_type, title, default_path, filter_list, options](int* exit_code) -> std::string { (void)exit_code; m_wtitle = internal::str2wstr(title); m_wdefault_path = internal::str2wstr(default_path); @@ -1086,15 +992,13 @@ inline internal::file_dialog::file_dialog(type in_type, ole32_dll ole32; // Folder selection uses a different method - if (in_type == type::folder) - { + if (in_type == type::folder) { #if PFD_HAS_IFILEDIALOG - if (flags(flag::is_vista)) - { + if (flags(flag::is_vista)) { // On Vista and higher we should be able to use IFileDialog for folder selection - IFileDialog *ifd; - HRESULT hr = dll::proc(ole32, "CoCreateInstance") - (CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ifd)); + IFileDialog* ifd; + HRESULT hr = dll::proc( + ole32, "CoCreateInstance")(CLSID_FileOpenDialog, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&ifd)); // In case CoCreateInstance fails (which it should not), try legacy approach if (SUCCEEDED(hr)) @@ -1108,21 +1012,19 @@ inline internal::file_dialog::file_dialog(type in_type, bi.lpfn = &bffcallback; bi.lParam = (LPARAM)this; - if (flags(flag::is_vista)) - { + if (flags(flag::is_vista)) { if (ole32.is_initialized()) bi.ulFlags |= BIF_NEWDIALOGSTYLE; bi.ulFlags |= BIF_EDITBOX; bi.ulFlags |= BIF_STATUSTEXT; } - auto *list = SHBrowseForFolderW(&bi); + auto* list = SHBrowseForFolderW(&bi); std::string ret; - if (list) - { + if (list) { auto buffer = new wchar_t[MAX_PATH]; SHGetPathFromIDListW(list, buffer); - dll::proc(ole32, "CoTaskMemFree")(list); + dll::proc(ole32, "CoTaskMemFree")(list); ret = internal::wstr2str(buffer); delete[] buffer; } @@ -1139,8 +1041,7 @@ inline internal::file_dialog::file_dialog(type in_type, auto woutput = std::wstring(MAX_PATH * 256, L'\0'); ofn.lpstrFile = (LPWSTR)woutput.data(); ofn.nMaxFile = (DWORD)woutput.size(); - if (!m_wdefault_path.empty()) - { + if (!m_wdefault_path.empty()) { // If a directory was provided, use it as the initial directory. If // a valid path was provided, use it as the initial file. Otherwise, // let the Windows API decide. @@ -1148,10 +1049,9 @@ inline internal::file_dialog::file_dialog(type in_type, if (path_attr != INVALID_FILE_ATTRIBUTES && (path_attr & FILE_ATTRIBUTE_DIRECTORY)) ofn.lpstrInitialDir = m_wdefault_path.c_str(); else if (m_wdefault_path.size() <= woutput.size()) - //second argument is size of buffer, not length of string - StringCchCopyW(ofn.lpstrFile, MAX_PATH*256+1, m_wdefault_path.c_str()); - else - { + // second argument is size of buffer, not length of string + StringCchCopyW(ofn.lpstrFile, MAX_PATH * 256 + 1, m_wdefault_path.c_str()); + else { ofn.lpstrFileTitle = (LPWSTR)m_wdefault_path.data(); ofn.nMaxFileTitle = (DWORD)m_wdefault_path.size(); } @@ -1164,37 +1064,32 @@ inline internal::file_dialog::file_dialog(type in_type, // Apply new visual style (required for windows XP) new_style_context ctx; - if (in_type == type::save) - { + if (in_type == type::save) { if (!(options & opt::force_overwrite)) ofn.Flags |= OFN_OVERWRITEPROMPT; - dll::proc get_save_file_name(comdlg32, "GetSaveFileNameW"); + dll::proc get_save_file_name(comdlg32, "GetSaveFileNameW"); if (get_save_file_name(&ofn) == 0) return ""; return internal::wstr2str(woutput.c_str()); - } - else - { + } else { if (options & opt::multiselect) ofn.Flags |= OFN_ALLOWMULTISELECT; ofn.Flags |= OFN_PATHMUSTEXIST; - dll::proc get_open_file_name(comdlg32, "GetOpenFileNameW"); + dll::proc get_open_file_name(comdlg32, "GetOpenFileNameW"); if (get_open_file_name(&ofn) == 0) return ""; } std::string prefix; - for (wchar_t const *p = woutput.c_str(); *p; ) - { + for (wchar_t const* p = woutput.c_str(); *p;) { auto filename = internal::wstr2str(p); p += wcslen(p); // In multiselect mode, we advance p one wchar further and // check for another filename. If there is one and the // prefix is empty, it means we just read the prefix. - if ((options & opt::multiselect) && *++p && prefix.empty()) - { + if ((options & opt::multiselect) && *++p && prefix.empty()) { prefix = filename + "/"; continue; } @@ -1214,15 +1109,14 @@ inline internal::file_dialog::file_dialog(type in_type, #else auto command = desktop_helper(); - if (is_osascript()) - { + if (is_osascript()) { std::string script = "set ret to choose"; - switch (in_type) - { + switch (in_type) { case type::save: script += " file name"; break; - case type::open: default: + case type::open: + default: script += " file"; if (options & opt::multiselect) script += " with multiple selections allowed"; @@ -1232,8 +1126,7 @@ inline internal::file_dialog::file_dialog(type in_type, break; } - if (default_path.size()) - { + if (default_path.size()) { if (in_type == type::folder || is_directory(default_path)) script += " default location "; else @@ -1243,8 +1136,7 @@ inline internal::file_dialog::file_dialog(type in_type, script += " with prompt " + osascript_quote(title); - if (in_type == type::open) - { + if (in_type == type::open) { // Concatenate all user-provided filter patterns std::string patterns; for (size_t i = 0; i < filters.size() / 2; ++i) @@ -1258,8 +1150,7 @@ inline internal::file_dialog::file_dialog(type in_type, bool has_filter = true; std::sregex_token_iterator iter(patterns.begin(), patterns.end(), sep, -1); std::sregex_token_iterator end; - for ( ; iter != end; ++iter) - { + for (; iter != end; ++iter) { auto pat = iter->str(); if (pat == "*" || pat == "*.*") has_filter = false; @@ -1267,8 +1158,7 @@ inline internal::file_dialog::file_dialog(type in_type, filter_list += "," + osascript_quote(pat.substr(2, pat.size() - 2)); } - if (has_filter && filter_list.size() > 0) - { + if (has_filter && filter_list.size() > 0) { // There is a weird AppleScript bug where file extensions of length != 3 are // ignored, e.g. type{"txt"} works, but type{"json"} does not. Fortunately if // the whole list starts with a 3-character extension, everything works again. @@ -1278,24 +1168,19 @@ inline internal::file_dialog::file_dialog(type in_type, } } - if (in_type == type::open && (options & opt::multiselect)) - { + if (in_type == type::open && (options & opt::multiselect)) { script += "\nset s to \"\""; script += "\nrepeat with i in ret"; script += "\n set s to s & (POSIX path of i) & \"\\n\""; script += "\nend repeat"; script += "\ncopy s to stdout"; - } - else - { + } else { script += "\nPOSIX path of ret"; } command.push_back("-e"); command.push_back(script); - } - else if (is_zenity()) - { + } else if (is_zenity()) { command.push_back("--file-selection"); // If the default path is a directory, make sure it ends with "/" otherwise zenity will @@ -1309,8 +1194,7 @@ inline internal::file_dialog::file_dialog(type in_type, command.push_back(title); command.push_back("--separator=\n"); - for (size_t i = 0; i < filters.size() / 2; ++i) - { + for (size_t i = 0; i < filters.size() / 2; ++i) { command.push_back("--file-filter"); command.push_back(filters[2 * i] + "|" + filters[2 * i + 1]); } @@ -1323,17 +1207,19 @@ inline internal::file_dialog::file_dialog(type in_type, command.push_back("--confirm-overwrite"); if (options & opt::multiselect) command.push_back("--multiple"); - } - else if (is_kdialog()) - { - switch (in_type) - { - case type::save: command.push_back("--getsavefilename"); break; - case type::open: command.push_back("--getopenfilename"); break; - case type::folder: command.push_back("--getexistingdirectory"); break; + } else if (is_kdialog()) { + switch (in_type) { + case type::save: + command.push_back("--getsavefilename"); + break; + case type::open: + command.push_back("--getopenfilename"); + break; + case type::folder: + command.push_back("--getexistingdirectory"); + break; } - if (options & opt::multiselect) - { + if (options & opt::multiselect) { command.push_back("--multiple"); command.push_back("--separate-output"); } @@ -1356,8 +1242,7 @@ inline internal::file_dialog::file_dialog(type in_type, #endif } -inline std::string internal::file_dialog::string_result() -{ +inline std::string internal::file_dialog::string_result() { #if _WIN32 return m_async->result(); #else @@ -1370,16 +1255,14 @@ inline std::string internal::file_dialog::string_result() #endif } -inline std::vector internal::file_dialog::vector_result() -{ +inline std::vector internal::file_dialog::vector_result() { #if _WIN32 m_async->result(); return m_vector_result; #else std::vector ret; auto result = m_async->result(); - for (;;) - { + for (;;) { // Split result along newline characters auto i = result.find('\n'); if (i == 0 || i == std::string::npos) @@ -1393,12 +1276,9 @@ inline std::vector internal::file_dialog::vector_result() #if _WIN32 // Use a static function to pass as BFFCALLBACK for legacy folder select -inline int CALLBACK internal::file_dialog::bffcallback(HWND hwnd, UINT uMsg, - LPARAM, LPARAM pData) -{ - auto inst = (file_dialog *)pData; - switch (uMsg) - { +inline int CALLBACK internal::file_dialog::bffcallback(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData) { + auto inst = (file_dialog*)pData; + switch (uMsg) { case BFFM_INITIALIZED: SendMessage(hwnd, BFFM_SETSELECTIONW, TRUE, (LPARAM)inst->m_wdefault_path.c_str()); break; @@ -1407,23 +1287,19 @@ inline int CALLBACK internal::file_dialog::bffcallback(HWND hwnd, UINT uMsg, } #if PFD_HAS_IFILEDIALOG -inline std::string internal::file_dialog::select_folder_vista(IFileDialog *ifd, bool force_path) -{ +inline std::string internal::file_dialog::select_folder_vista(IFileDialog* ifd, bool force_path) { std::string result; - IShellItem *folder; + IShellItem* folder; // Load library at runtime so app doesn't link it at load time (which will fail on windows XP) dll shell32("shell32.dll"); - dll::proc - create_item(shell32, "SHCreateItemFromParsingName"); + dll::proc create_item(shell32, "SHCreateItemFromParsingName"); if (!create_item) return ""; - auto hr = create_item(m_wdefault_path.c_str(), - nullptr, - IID_PPV_ARGS(&folder)); + auto hr = create_item(m_wdefault_path.c_str(), nullptr, IID_PPV_ARGS(&folder)); // Set default folder if found. This only sets the default folder. If // Windows has any info about the most recently selected folder, it @@ -1431,8 +1307,7 @@ inline std::string internal::file_dialog::select_folder_vista(IFileDialog *ifd, // current directory “is not a good or expected user experience and // should therefore be avoided”: // https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifiledialog-setfolder - if (SUCCEEDED(hr)) - { + if (SUCCEEDED(hr)) { if (force_path) ifd->SetFolder(folder); else @@ -1445,29 +1320,22 @@ inline std::string internal::file_dialog::select_folder_vista(IFileDialog *ifd, ifd->SetTitle(m_wtitle.c_str()); hr = ifd->Show(GetActiveWindow()); - if (SUCCEEDED(hr)) - { + if (SUCCEEDED(hr)) { IShellItem* item; hr = ifd->GetResult(&item); - if (SUCCEEDED(hr)) - { + if (SUCCEEDED(hr)) { wchar_t* wname = nullptr; // This is unlikely to fail because we use FOS_FORCEFILESYSTEM, but try // to output a debug message just in case. - if (SUCCEEDED(item->GetDisplayName(SIGDN_FILESYSPATH, &wname))) - { + if (SUCCEEDED(item->GetDisplayName(SIGDN_FILESYSPATH, &wname))) { result = internal::wstr2str(std::wstring(wname)); - dll::proc(ole32_dll(), "CoTaskMemFree")(wname); - } - else - { - if (SUCCEEDED(item->GetDisplayName(SIGDN_NORMALDISPLAY, &wname))) - { + dll::proc(ole32_dll(), "CoTaskMemFree")(wname); + } else { + if (SUCCEEDED(item->GetDisplayName(SIGDN_NORMALDISPLAY, &wname))) { auto name = internal::wstr2str(std::wstring(wname)); - dll::proc(ole32_dll(), "CoTaskMemFree")(wname); + dll::proc(ole32_dll(), "CoTaskMemFree")(wname); std::cerr << "pfd: failed to get path for " << name << std::endl; - } - else + } else std::cerr << "pfd: item of unknown type selected" << std::endl; } @@ -1484,10 +1352,7 @@ inline std::string internal::file_dialog::select_folder_vista(IFileDialog *ifd, // notify implementation -inline notify::notify(std::string const &title, - std::string const &message, - icon _icon /* = icon::info */) -{ +inline notify::notify(std::string const& title, std::string const& message, icon _icon /* = icon::info */) { if (_icon == icon::question) // Not supported by notifications _icon = icon::info; @@ -1495,9 +1360,10 @@ inline notify::notify(std::string const &title, // Use a static shared pointer for notify_icon so that we can delete // it whenever we need to display a new one, and we can also wait // until the program has finished running. - struct notify_icon_data : public NOTIFYICONDATAW - { - ~notify_icon_data() { Shell_NotifyIconW(NIM_DELETE, this); } + struct notify_icon_data : public NOTIFYICONDATAW { + ~notify_icon_data() { + Shell_NotifyIconW(NIM_DELETE, this); + } }; static std::shared_ptr nid; @@ -1518,7 +1384,8 @@ inline notify::notify(std::string const &title, // - NIF_MESSAGE The uCallbackMessage member is valid. // - NIF_TIP The szTip member is valid. // - NIF_STATE The dwState and dwStateMask members are valid. - // - NIF_INFO Use a balloon ToolTip instead of a standard ToolTip. The szInfo, uTimeout, szInfoTitle, and dwInfoFlags members are valid. + // - NIF_INFO Use a balloon ToolTip instead of a standard ToolTip. The szInfo, uTimeout, szInfoTitle, and + // dwInfoFlags members are valid. // - NIF_GUID Reserved. nid->uFlags = NIF_MESSAGE | NIF_ICON | NIF_INFO; @@ -1529,16 +1396,20 @@ inline notify::notify(std::string const &title, // - NIIF_WARNING A warning icon. // - NIIF_ICON_MASK Version 6.0. Reserved. // - NIIF_NOSOUND Version 6.0. Do not play the associated sound. Applies only to balloon ToolTips - switch (_icon) - { - case icon::warning: nid->dwInfoFlags = NIIF_WARNING; break; - case icon::error: nid->dwInfoFlags = NIIF_ERROR; break; - /* case icon::info: */ default: nid->dwInfoFlags = NIIF_INFO; break; + switch (_icon) { + case icon::warning: + nid->dwInfoFlags = NIIF_WARNING; + break; + case icon::error: + nid->dwInfoFlags = NIIF_ERROR; + break; + /* case icon::info: */ default: + nid->dwInfoFlags = NIIF_INFO; + break; } - ENUMRESNAMEPROC icon_enum_callback = [](HMODULE, LPCTSTR, LPTSTR lpName, LONG_PTR lParam) -> BOOL - { - ((NOTIFYICONDATAW *)lParam)->hIcon = ::LoadIcon(GetModuleHandle(nullptr), lpName); + ENUMRESNAMEPROC icon_enum_callback = [](HMODULE, LPCTSTR, LPTSTR lpName, LONG_PTR lParam) -> BOOL { + ((NOTIFYICONDATAW*)lParam)->hIcon = ::LoadIcon(GetModuleHandle(nullptr), lpName); return false; }; @@ -1559,22 +1430,16 @@ inline notify::notify(std::string const &title, #else auto command = desktop_helper(); - if (is_osascript()) - { + if (is_osascript()) { command.push_back("-e"); - command.push_back("display notification " + osascript_quote(message) + - " with title " + osascript_quote(title)); - } - else if (is_zenity()) - { + command.push_back("display notification " + osascript_quote(message) + " with title " + osascript_quote(title)); + } else if (is_zenity()) { command.push_back("--notification"); command.push_back("--window-icon"); command.push_back(get_icon_name(_icon)); command.push_back("--text"); command.push_back(title + "\n" + message); - } - else if (is_kdialog()) - { + } else if (is_kdialog()) { command.push_back("--icon"); command.push_back(get_icon_name(_icon)); command.push_back("--title"); @@ -1593,31 +1458,46 @@ inline notify::notify(std::string const &title, // message implementation -inline message::message(std::string const &title, - std::string const &text, - choice _choice /* = choice::ok_cancel */, - icon _icon /* = icon::info */) -{ +inline message::message(std::string const& title, std::string const& text, choice _choice /* = choice::ok_cancel */, + icon _icon /* = icon::info */) { #if _WIN32 // Use MB_SYSTEMMODAL rather than MB_TOPMOST to ensure the message window is brought // to front. See https://github.com/samhocevar/portable-file-dialogs/issues/52 UINT style = MB_SYSTEMMODAL; - switch (_icon) - { - case icon::warning: style |= MB_ICONWARNING; break; - case icon::error: style |= MB_ICONERROR; break; - case icon::question: style |= MB_ICONQUESTION; break; - /* case icon::info: */ default: style |= MB_ICONINFORMATION; break; + switch (_icon) { + case icon::warning: + style |= MB_ICONWARNING; + break; + case icon::error: + style |= MB_ICONERROR; + break; + case icon::question: + style |= MB_ICONQUESTION; + break; + /* case icon::info: */ default: + style |= MB_ICONINFORMATION; + break; } - switch (_choice) - { - case choice::ok_cancel: style |= MB_OKCANCEL; break; - case choice::yes_no: style |= MB_YESNO; break; - case choice::yes_no_cancel: style |= MB_YESNOCANCEL; break; - case choice::retry_cancel: style |= MB_RETRYCANCEL; break; - case choice::abort_retry_ignore: style |= MB_ABORTRETRYIGNORE; break; - /* case choice::ok: */ default: style |= MB_OK; break; + switch (_choice) { + case choice::ok_cancel: + style |= MB_OKCANCEL; + break; + case choice::yes_no: + style |= MB_YESNO; + break; + case choice::yes_no_cancel: + style |= MB_YESNOCANCEL; + break; + case choice::retry_cancel: + style |= MB_RETRYCANCEL; + break; + case choice::abort_retry_ignore: + style |= MB_ABORTRETRYIGNORE; + break; + /* case choice::ok: */ default: + style |= MB_OK; + break; } m_mappings[IDCANCEL] = button::cancel; @@ -1628,8 +1508,7 @@ inline message::message(std::string const &title, m_mappings[IDRETRY] = button::retry; m_mappings[IDIGNORE] = button::ignore; - m_async->start_func([text, title, style](int* exit_code) -> std::string - { + m_async->start_func([text, title, style](int* exit_code) -> std::string { auto wtext = internal::str2wstr(text); auto wtitle = internal::str2wstr(title); // Apply new visual style (required for all Windows versions) @@ -1640,12 +1519,19 @@ inline message::message(std::string const &title, #elif __EMSCRIPTEN__ std::string full_message; - switch (_icon) - { - case icon::warning: full_message = "⚠️"; break; - case icon::error: full_message = "⛔"; break; - case icon::question: full_message = "❓"; break; - /* case icon::info: */ default: full_message = "ℹ"; break; + switch (_icon) { + case icon::warning: + full_message = "⚠️"; + break; + case icon::error: + full_message = "⛔"; + break; + case icon::question: + full_message = "❓"; + break; + /* case icon::info: */ default: + full_message = "ℹ"; + break; } full_message += ' ' + title + "\n\n" + text; @@ -1653,22 +1539,20 @@ inline message::message(std::string const &title, // This does not really start an async task; it just passes the // EM_ASM_INT return value to a fake start() function. m_async->start(EM_ASM_INT( - { - if ($1) - return window.confirm(UTF8ToString($0)) ? 0 : -1; - alert(UTF8ToString($0)); - return 0; - }, full_message.c_str(), _choice == choice::ok_cancel)); + { + if ($1) + return window.confirm(UTF8ToString($0)) ? 0 : -1; + alert(UTF8ToString($0)); + return 0; + }, + full_message.c_str(), _choice == choice::ok_cancel)); #else auto command = desktop_helper(); - if (is_osascript()) - { - std::string script = "display dialog " + osascript_quote(text) + - " with title " + osascript_quote(title); + if (is_osascript()) { + std::string script = "display dialog " + osascript_quote(text) + " with title " + osascript_quote(title); auto if_cancel = button::cancel; - switch (_choice) - { + switch (_choice) { case choice::ok_cancel: script += "buttons {\"OK\", \"Cancel\"}" " default button \"OK\"" @@ -1696,7 +1580,8 @@ inline message::message(std::string const &title, " cancel button \"Retry\""; if_cancel = button::retry; break; - case choice::ok: default: + case choice::ok: + default: script += "buttons {\"OK\"}" " default button \"OK\"" " cancel button \"OK\""; @@ -1706,65 +1591,82 @@ inline message::message(std::string const &title, m_mappings[1] = if_cancel; m_mappings[256] = if_cancel; // XXX: I think this was never correct script += " with icon "; - switch (_icon) - { - #define PFD_OSX_ICON(n) "alias ((path to library folder from system domain) as text " \ - "& \"CoreServices:CoreTypes.bundle:Contents:Resources:" n ".icns\")" - case icon::info: default: script += PFD_OSX_ICON("ToolBarInfo"); break; - case icon::warning: script += "caution"; break; - case icon::error: script += "stop"; break; - case icon::question: script += PFD_OSX_ICON("GenericQuestionMarkIcon"); break; - #undef PFD_OSX_ICON + switch (_icon) { +#define PFD_OSX_ICON(n) \ + "alias ((path to library folder from system domain) as text " \ + "& \"CoreServices:CoreTypes.bundle:Contents:Resources:" n ".icns\")" + case icon::info: + default: + script += PFD_OSX_ICON("ToolBarInfo"); + break; + case icon::warning: + script += "caution"; + break; + case icon::error: + script += "stop"; + break; + case icon::question: + script += PFD_OSX_ICON("GenericQuestionMarkIcon"); + break; +#undef PFD_OSX_ICON } command.push_back("-e"); command.push_back(script); - } - else if (is_zenity()) - { - switch (_choice) - { + } else if (is_zenity()) { + switch (_choice) { case choice::ok_cancel: - command.insert(command.end(), { "--question", "--cancel-label=Cancel", "--ok-label=OK" }); break; + command.insert(command.end(), { "--question", "--cancel-label=Cancel", "--ok-label=OK" }); + break; case choice::yes_no: // Do not use standard --question because it causes “No” to return -1, // which is inconsistent with the “Yes/No/Cancel” mode below. - command.insert(command.end(), { "--question", "--switch", "--extra-button=No", "--extra-button=Yes" }); break; + command.insert(command.end(), { "--question", "--switch", "--extra-button=No", "--extra-button=Yes" }); + break; case choice::yes_no_cancel: - command.insert(command.end(), { "--question", "--switch", "--extra-button=Cancel", "--extra-button=No", "--extra-button=Yes" }); break; + command.insert(command.end(), { "--question", "--switch", "--extra-button=Cancel", "--extra-button=No", + "--extra-button=Yes" }); + break; case choice::retry_cancel: - command.insert(command.end(), { "--question", "--switch", "--extra-button=Cancel", "--extra-button=Retry" }); break; + command.insert(command.end(), + { "--question", "--switch", "--extra-button=Cancel", "--extra-button=Retry" }); + break; case choice::abort_retry_ignore: - command.insert(command.end(), { "--question", "--switch", "--extra-button=Ignore", "--extra-button=Abort", "--extra-button=Retry" }); break; + command.insert(command.end(), { "--question", "--switch", "--extra-button=Ignore", + "--extra-button=Abort", "--extra-button=Retry" }); + break; case choice::ok: default: - switch (_icon) - { - case icon::error: command.push_back("--error"); break; - case icon::warning: command.push_back("--warning"); break; - default: command.push_back("--info"); break; + switch (_icon) { + case icon::error: + command.push_back("--error"); + break; + case icon::warning: + command.push_back("--warning"); + break; + default: + command.push_back("--info"); + break; } } - command.insert(command.end(), { "--title", title, - "--width=300", "--height=0", // sensible defaults + command.insert(command.end(), { "--title", title, "--width=300", "--height=0", // sensible defaults "--no-markup", // do not interpret text as Pango markup - "--text", text, - "--icon-name=dialog-" + get_icon_name(_icon) }); - } - else if (is_kdialog()) - { - if (_choice == choice::ok) - { - switch (_icon) - { - case icon::error: command.push_back("--error"); break; - case icon::warning: command.push_back("--sorry"); break; - default: command.push_back("--msgbox"); break; + "--text", text, "--icon-name=dialog-" + get_icon_name(_icon) }); + } else if (is_kdialog()) { + if (_choice == choice::ok) { + switch (_icon) { + case icon::error: + command.push_back("--error"); + break; + case icon::warning: + command.push_back("--sorry"); + break; + default: + command.push_back("--msgbox"); + break; } - } - else - { + } else { std::string flag = "--"; if (_icon == icon::warning || _icon == icon::error) flag += "warning"; @@ -1772,8 +1674,7 @@ inline message::message(std::string const &title, if (_choice == choice::yes_no_cancel) flag += "cancel"; command.push_back(flag); - if (_choice == choice::yes_no || _choice == choice::yes_no_cancel) - { + if (_choice == choice::yes_no || _choice == choice::yes_no_cancel) { m_mappings[0] = button::yes; m_mappings[256] = button::no; } @@ -1795,8 +1696,7 @@ inline message::message(std::string const &title, #endif } -inline button message::result() -{ +inline button message::result() { int exit_code; auto ret = m_async->result(&exit_code); // osascript will say "button returned:Cancel\n" @@ -1822,63 +1722,46 @@ inline button message::result() // open_file implementation -inline open_file::open_file(std::string const &title, - std::string const &default_path /* = "" */, - std::vector const &filters /* = { "All Files", "*" } */, +inline open_file::open_file(std::string const& title, std::string const& default_path /* = "" */, + std::vector const& filters /* = { "All Files", "*" } */, opt options /* = opt::none */) - : file_dialog(type::open, title, default_path, filters, options) -{ + : file_dialog(type::open, title, default_path, filters, options) { } -inline open_file::open_file(std::string const &title, - std::string const &default_path, - std::vector const &filters, - bool allow_multiselect) - : open_file(title, default_path, filters, - (allow_multiselect ? opt::multiselect : opt::none)) -{ +inline open_file::open_file(std::string const& title, std::string const& default_path, + std::vector const& filters, bool allow_multiselect) + : open_file(title, default_path, filters, (allow_multiselect ? opt::multiselect : opt::none)) { } -inline std::vector open_file::result() -{ +inline std::vector open_file::result() { return vector_result(); } // save_file implementation -inline save_file::save_file(std::string const &title, - std::string const &default_path /* = "" */, - std::vector const &filters /* = { "All Files", "*" } */, +inline save_file::save_file(std::string const& title, std::string const& default_path /* = "" */, + std::vector const& filters /* = { "All Files", "*" } */, opt options /* = opt::none */) - : file_dialog(type::save, title, default_path, filters, options) -{ + : file_dialog(type::save, title, default_path, filters, options) { } -inline save_file::save_file(std::string const &title, - std::string const &default_path, - std::vector const &filters, - bool confirm_overwrite) - : save_file(title, default_path, filters, - (confirm_overwrite ? opt::none : opt::force_overwrite)) -{ +inline save_file::save_file(std::string const& title, std::string const& default_path, + std::vector const& filters, bool confirm_overwrite) + : save_file(title, default_path, filters, (confirm_overwrite ? opt::none : opt::force_overwrite)) { } -inline std::string save_file::result() -{ +inline std::string save_file::result() { return string_result(); } // select_folder implementation -inline select_folder::select_folder(std::string const &title, - std::string const &default_path /* = "" */, +inline select_folder::select_folder(std::string const& title, std::string const& default_path /* = "" */, opt options /* = opt::none */) - : file_dialog(type::folder, title, default_path, {}, options) -{ + : file_dialog(type::folder, title, default_path, {}, options) { } -inline std::string select_folder::result() -{ +inline std::string select_folder::result() { return string_result(); } diff --git a/mm/2s2h/SaveManager/Migrations/1.cpp b/mm/2s2h/SaveManager/Migrations/1.cpp index 742c00232..5a3d63211 100644 --- a/mm/2s2h/SaveManager/Migrations/1.cpp +++ b/mm/2s2h/SaveManager/Migrations/1.cpp @@ -1,6 +1,7 @@ #include "2s2h/SaveManager/SaveManager.h" -// To better support future migrations, we always store the `Save` at the `save` key to be consistent across normal saves and owl saves +// To better support future migrations, we always store the `Save` at the `save` key to be consistent across normal +// saves and owl saves void SaveManager_Migration_1(nlohmann::json& j) { bool isOwlSave = j.contains("save"); diff --git a/mm/2s2h/SaveManager/SaveManager.cpp b/mm/2s2h/SaveManager/SaveManager.cpp index 285291cb9..8cefd9d02 100644 --- a/mm/2s2h/SaveManager/SaveManager.cpp +++ b/mm/2s2h/SaveManager/SaveManager.cpp @@ -5,7 +5,6 @@ #include #include - #include "macros.h" #include "BenJsonConversions.hpp" @@ -26,10 +25,9 @@ typedef enum FlashSlotFile { } FlashSlotFile; #define GET_NEWF(save, index) (save.saveInfo.playerData.newf[index]) -#define IS_VALID_FILE(save) \ - ((GET_NEWF(save, 0) == 'Z') && (GET_NEWF(save, 1) == 'E') && \ - (GET_NEWF(save, 2) == 'L') && (GET_NEWF(save, 3) == 'D') && \ - (GET_NEWF(save, 4) == 'A') && (GET_NEWF(save, 5) == '3')) +#define IS_VALID_FILE(save) \ + ((GET_NEWF(save, 0) == 'Z') && (GET_NEWF(save, 1) == 'E') && (GET_NEWF(save, 2) == 'L') && \ + (GET_NEWF(save, 3) == 'D') && (GET_NEWF(save, 4) == 'A') && (GET_NEWF(save, 5) == '3')) const std::filesystem::path savesFolderPath(Ship::Context::GetPathRelativeToAppDirectory("Save")); @@ -41,7 +39,8 @@ const std::filesystem::path savesFolderPath(Ship::Context::GetPathRelativeToAppD // To add a new migration: // - Increment CURRENT_SAVE_VERSION // - Create the migration file in the Migrations folder with the name `{CURRENT_SAVE_VERSION}.cpp` -// - Add the migration function definition below and add it to the `migrations` map with the key being the previous version +// - Add the migration function definition below and add it to the `migrations` map with the key being the previous +// version const uint32_t CURRENT_SAVE_VERSION = 3; void SaveManager_Migration_1(nlohmann::json& j); @@ -125,7 +124,8 @@ extern "C" void SaveManager_SysFlashrom_WriteData(u8* saveBuffer, u32 pageNum, u memcpy(&save, saveBuffer, sizeof(Save)); std::string fileName = "save_" + std::to_string(flashSlotFile) + ".sav"; - if (isBackup) fileName += ".bak"; + if (isBackup) + fileName += ".bak"; if (IS_VALID_FILE(save)) { nlohmann::json j; @@ -149,7 +149,8 @@ extern "C" void SaveManager_SysFlashrom_WriteData(u8* saveBuffer, u32 pageNum, u memcpy(&saveContext, saveBuffer, offsetof(SaveContext, fileNum)); std::string fileName = "save_" + std::to_string(flashSlotFile) + ".sav"; - if (isBackup) fileName += ".bak"; + if (isBackup) + fileName += ".bak"; if (IS_VALID_FILE(saveContext.save)) { nlohmann::json j = saveContext; @@ -196,11 +197,13 @@ extern "C" s32 SaveManager_SysFlashrom_ReadData(void* saveBuffer, u32 pageNum, u case FLASH_SLOT_FILE_1_NEW_CYCLE: case FLASH_SLOT_FILE_2_NEW_CYCLE: { std::string fileName = "save_" + std::to_string(flashSlotFile) + ".sav"; - if (isBackup) fileName += ".bak"; + if (isBackup) + fileName += ".bak"; nlohmann::json j; int result = SaveManager_ReadSaveFile(fileName, j); - if (result != 0) return result; + if (result != 0) + return result; SaveManager_MigrateSave(j); @@ -216,11 +219,13 @@ extern "C" s32 SaveManager_SysFlashrom_ReadData(void* saveBuffer, u32 pageNum, u case FLASH_SLOT_FILE_1_OWL_SAVE: case FLASH_SLOT_FILE_2_OWL_SAVE: { std::string fileName = "save_" + std::to_string(flashSlotFile) + ".sav"; - if (isBackup) fileName += ".bak"; + if (isBackup) + fileName += ".bak"; nlohmann::json j; int result = SaveManager_ReadSaveFile(fileName, j); - if (result != 0) return result; + if (result != 0) + return result; SaveManager_MigrateSave(j); @@ -235,7 +240,8 @@ extern "C" s32 SaveManager_SysFlashrom_ReadData(void* saveBuffer, u32 pageNum, u nlohmann::json j; int result = SaveManager_ReadSaveFile(fileName, j); - if (result != 0) return result; + if (result != 0) + return result; SaveOptions saveOptions = j; diff --git a/mm/2s2h/framebuffer_effects.c b/mm/2s2h/framebuffer_effects.c index f1d88f075..0d7ec9e2e 100644 --- a/mm/2s2h/framebuffer_effects.c +++ b/mm/2s2h/framebuffer_effects.c @@ -37,7 +37,8 @@ void FB_CreateFramebuffers(void) { * Setting oncePerFrame ensures that the copy will only happen once every game frame. This * is important for effects that could be affected by increased frame interpolation (like motion blur). * A pointer to a boolean is passed to the render for the render to set once the copy has been performed. - * This function uses opcodes from f3dex2 but may be called when s2dex is loaded, such as during shrink window. Make sure f3dex2 is loaded before this function is called. + * This function uses opcodes from f3dex2 but may be called when s2dex is loaded, such as during shrink window. Make + * sure f3dex2 is loaded before this function is called. */ void FB_CopyToFramebuffer(Gfx** gfxp, s32 fb_src, s32 fb_dest, u8 oncePerFrame, u8* hasCopied) { Gfx* gfx = *gfxp; @@ -118,8 +119,8 @@ void FB_DrawFromFramebuffer(Gfx** gfxp, s32 fb, u8 alpha) { gDPSetEnvColor(gfx++, 255, 255, 255, alpha); gDPSetOtherMode(gfx++, - G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | + G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); gSPClearGeometryMode(gfx++, G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); @@ -132,16 +133,16 @@ void FB_DrawFromFramebuffer(Gfx** gfxp, s32 fb, u8 alpha) { gDPSetTextureImageFB(gfx++, 0, 0, 0, fb); gDPImageRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0) << 2, 0 << 2, 0, 0, - OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2, SCREEN_HEIGHT << 2, - OTRGetGameRenderWidth(), OTRGetGameRenderHeight(), G_TX_RENDERTILE, - OTRGetGameRenderWidth(), OTRGetGameRenderHeight()); + OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2, SCREEN_HEIGHT << 2, OTRGetGameRenderWidth(), + OTRGetGameRenderHeight(), G_TX_RENDERTILE, OTRGetGameRenderWidth(), OTRGetGameRenderHeight()); *gfxp = gfx; } /** * Similar to FB_DrawFromFramebuffer, but scales the image relative to the center of the screen. - * This function uses opcodes from f3dex2 but may be called when s2dex is loaded, such as during shrink window. Make sure f3dex2 is loaded before this function is called. + * This function uses opcodes from f3dex2 but may be called when s2dex is loaded, such as during shrink window. Make + * sure f3dex2 is loaded before this function is called. */ void FB_DrawFromFramebufferScaled(Gfx** gfxp, s32 fb, u8 alpha, float scaleX, float scaleY) { Gfx* gfx = *gfxp; @@ -149,8 +150,8 @@ void FB_DrawFromFramebufferScaled(Gfx** gfxp, s32 fb, u8 alpha, float scaleX, fl gDPSetEnvColor(gfx++, 255, 255, 255, alpha); gDPSetOtherMode(gfx++, - G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | + G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); gDPSetCombineLERP(gfx++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, @@ -163,12 +164,10 @@ void FB_DrawFromFramebufferScaled(Gfx** gfxp, s32 fb, u8 alpha, float scaleX, fl float x0 = gScreenWidth * 0.5f * scaleX; float y0 = gScreenHeight * 0.5f * scaleY; - gDPImageRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(x0) << 2, - (int)(y0) << 2, 0, 0, + gDPImageRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(x0) << 2, (int)(y0) << 2, 0, 0, OTRGetRectDimensionFromRightEdge((float)(gScreenWidth - x0)) << 2, - (int)((float)(gScreenHeight - y0)) << 2, - OTRGetGameRenderWidth(), OTRGetGameRenderHeight(), G_TX_RENDERTILE, - OTRGetGameRenderWidth(), OTRGetGameRenderHeight()); + (int)((float)(gScreenHeight - y0)) << 2, OTRGetGameRenderWidth(), OTRGetGameRenderHeight(), + G_TX_RENDERTILE, OTRGetGameRenderWidth(), OTRGetGameRenderHeight()); *gfxp = gfx; } diff --git a/mm/2s2h/mixer.c b/mm/2s2h/mixer.c index 66dc8f179..2e6e45cc9 100644 --- a/mm/2s2h/mixer.c +++ b/mm/2s2h/mixer.c @@ -6,7 +6,7 @@ #include "mixer.h" #ifndef __clang__ -#pragma GCC optimize ("unroll-loops") +#pragma GCC optimize("unroll-loops") #endif #define ROUND_UP_64(v) (((v) + 63) & ~63) @@ -30,7 +30,7 @@ static struct { uint16_t vol_wet; uint16_t rate_wet; - ADPCM_STATE *adpcm_loop_state; + ADPCM_STATE* adpcm_loop_state; int16_t adpcm_table[8][2][8]; @@ -44,38 +44,28 @@ static struct { } rspa; static int16_t resample_table[64][4] = { - {0x0c39, 0x66ad, 0x0d46, 0xffdf}, {0x0b39, 0x6696, 0x0e5f, 0xffd8}, - {0x0a44, 0x6669, 0x0f83, 0xffd0}, {0x095a, 0x6626, 0x10b4, 0xffc8}, - {0x087d, 0x65cd, 0x11f0, 0xffbf}, {0x07ab, 0x655e, 0x1338, 0xffb6}, - {0x06e4, 0x64d9, 0x148c, 0xffac}, {0x0628, 0x643f, 0x15eb, 0xffa1}, - {0x0577, 0x638f, 0x1756, 0xff96}, {0x04d1, 0x62cb, 0x18cb, 0xff8a}, - {0x0435, 0x61f3, 0x1a4c, 0xff7e}, {0x03a4, 0x6106, 0x1bd7, 0xff71}, - {0x031c, 0x6007, 0x1d6c, 0xff64}, {0x029f, 0x5ef5, 0x1f0b, 0xff56}, - {0x022a, 0x5dd0, 0x20b3, 0xff48}, {0x01be, 0x5c9a, 0x2264, 0xff3a}, - {0x015b, 0x5b53, 0x241e, 0xff2c}, {0x0101, 0x59fc, 0x25e0, 0xff1e}, - {0x00ae, 0x5896, 0x27a9, 0xff10}, {0x0063, 0x5720, 0x297a, 0xff02}, - {0x001f, 0x559d, 0x2b50, 0xfef4}, {0xffe2, 0x540d, 0x2d2c, 0xfee8}, - {0xffac, 0x5270, 0x2f0d, 0xfedb}, {0xff7c, 0x50c7, 0x30f3, 0xfed0}, - {0xff53, 0x4f14, 0x32dc, 0xfec6}, {0xff2e, 0x4d57, 0x34c8, 0xfebd}, - {0xff0f, 0x4b91, 0x36b6, 0xfeb6}, {0xfef5, 0x49c2, 0x38a5, 0xfeb0}, - {0xfedf, 0x47ed, 0x3a95, 0xfeac}, {0xfece, 0x4611, 0x3c85, 0xfeab}, - {0xfec0, 0x4430, 0x3e74, 0xfeac}, {0xfeb6, 0x424a, 0x4060, 0xfeaf}, - {0xfeaf, 0x4060, 0x424a, 0xfeb6}, {0xfeac, 0x3e74, 0x4430, 0xfec0}, - {0xfeab, 0x3c85, 0x4611, 0xfece}, {0xfeac, 0x3a95, 0x47ed, 0xfedf}, - {0xfeb0, 0x38a5, 0x49c2, 0xfef5}, {0xfeb6, 0x36b6, 0x4b91, 0xff0f}, - {0xfebd, 0x34c8, 0x4d57, 0xff2e}, {0xfec6, 0x32dc, 0x4f14, 0xff53}, - {0xfed0, 0x30f3, 0x50c7, 0xff7c}, {0xfedb, 0x2f0d, 0x5270, 0xffac}, - {0xfee8, 0x2d2c, 0x540d, 0xffe2}, {0xfef4, 0x2b50, 0x559d, 0x001f}, - {0xff02, 0x297a, 0x5720, 0x0063}, {0xff10, 0x27a9, 0x5896, 0x00ae}, - {0xff1e, 0x25e0, 0x59fc, 0x0101}, {0xff2c, 0x241e, 0x5b53, 0x015b}, - {0xff3a, 0x2264, 0x5c9a, 0x01be}, {0xff48, 0x20b3, 0x5dd0, 0x022a}, - {0xff56, 0x1f0b, 0x5ef5, 0x029f}, {0xff64, 0x1d6c, 0x6007, 0x031c}, - {0xff71, 0x1bd7, 0x6106, 0x03a4}, {0xff7e, 0x1a4c, 0x61f3, 0x0435}, - {0xff8a, 0x18cb, 0x62cb, 0x04d1}, {0xff96, 0x1756, 0x638f, 0x0577}, - {0xffa1, 0x15eb, 0x643f, 0x0628}, {0xffac, 0x148c, 0x64d9, 0x06e4}, - {0xffb6, 0x1338, 0x655e, 0x07ab}, {0xffbf, 0x11f0, 0x65cd, 0x087d}, - {0xffc8, 0x10b4, 0x6626, 0x095a}, {0xffd0, 0x0f83, 0x6669, 0x0a44}, - {0xffd8, 0x0e5f, 0x6696, 0x0b39}, {0xffdf, 0x0d46, 0x66ad, 0x0c39} + { 0x0c39, 0x66ad, 0x0d46, 0xffdf }, { 0x0b39, 0x6696, 0x0e5f, 0xffd8 }, { 0x0a44, 0x6669, 0x0f83, 0xffd0 }, + { 0x095a, 0x6626, 0x10b4, 0xffc8 }, { 0x087d, 0x65cd, 0x11f0, 0xffbf }, { 0x07ab, 0x655e, 0x1338, 0xffb6 }, + { 0x06e4, 0x64d9, 0x148c, 0xffac }, { 0x0628, 0x643f, 0x15eb, 0xffa1 }, { 0x0577, 0x638f, 0x1756, 0xff96 }, + { 0x04d1, 0x62cb, 0x18cb, 0xff8a }, { 0x0435, 0x61f3, 0x1a4c, 0xff7e }, { 0x03a4, 0x6106, 0x1bd7, 0xff71 }, + { 0x031c, 0x6007, 0x1d6c, 0xff64 }, { 0x029f, 0x5ef5, 0x1f0b, 0xff56 }, { 0x022a, 0x5dd0, 0x20b3, 0xff48 }, + { 0x01be, 0x5c9a, 0x2264, 0xff3a }, { 0x015b, 0x5b53, 0x241e, 0xff2c }, { 0x0101, 0x59fc, 0x25e0, 0xff1e }, + { 0x00ae, 0x5896, 0x27a9, 0xff10 }, { 0x0063, 0x5720, 0x297a, 0xff02 }, { 0x001f, 0x559d, 0x2b50, 0xfef4 }, + { 0xffe2, 0x540d, 0x2d2c, 0xfee8 }, { 0xffac, 0x5270, 0x2f0d, 0xfedb }, { 0xff7c, 0x50c7, 0x30f3, 0xfed0 }, + { 0xff53, 0x4f14, 0x32dc, 0xfec6 }, { 0xff2e, 0x4d57, 0x34c8, 0xfebd }, { 0xff0f, 0x4b91, 0x36b6, 0xfeb6 }, + { 0xfef5, 0x49c2, 0x38a5, 0xfeb0 }, { 0xfedf, 0x47ed, 0x3a95, 0xfeac }, { 0xfece, 0x4611, 0x3c85, 0xfeab }, + { 0xfec0, 0x4430, 0x3e74, 0xfeac }, { 0xfeb6, 0x424a, 0x4060, 0xfeaf }, { 0xfeaf, 0x4060, 0x424a, 0xfeb6 }, + { 0xfeac, 0x3e74, 0x4430, 0xfec0 }, { 0xfeab, 0x3c85, 0x4611, 0xfece }, { 0xfeac, 0x3a95, 0x47ed, 0xfedf }, + { 0xfeb0, 0x38a5, 0x49c2, 0xfef5 }, { 0xfeb6, 0x36b6, 0x4b91, 0xff0f }, { 0xfebd, 0x34c8, 0x4d57, 0xff2e }, + { 0xfec6, 0x32dc, 0x4f14, 0xff53 }, { 0xfed0, 0x30f3, 0x50c7, 0xff7c }, { 0xfedb, 0x2f0d, 0x5270, 0xffac }, + { 0xfee8, 0x2d2c, 0x540d, 0xffe2 }, { 0xfef4, 0x2b50, 0x559d, 0x001f }, { 0xff02, 0x297a, 0x5720, 0x0063 }, + { 0xff10, 0x27a9, 0x5896, 0x00ae }, { 0xff1e, 0x25e0, 0x59fc, 0x0101 }, { 0xff2c, 0x241e, 0x5b53, 0x015b }, + { 0xff3a, 0x2264, 0x5c9a, 0x01be }, { 0xff48, 0x20b3, 0x5dd0, 0x022a }, { 0xff56, 0x1f0b, 0x5ef5, 0x029f }, + { 0xff64, 0x1d6c, 0x6007, 0x031c }, { 0xff71, 0x1bd7, 0x6106, 0x03a4 }, { 0xff7e, 0x1a4c, 0x61f3, 0x0435 }, + { 0xff8a, 0x18cb, 0x62cb, 0x04d1 }, { 0xff96, 0x1756, 0x638f, 0x0577 }, { 0xffa1, 0x15eb, 0x643f, 0x0628 }, + { 0xffac, 0x148c, 0x64d9, 0x06e4 }, { 0xffb6, 0x1338, 0x655e, 0x07ab }, { 0xffbf, 0x11f0, 0x65cd, 0x087d }, + { 0xffc8, 0x10b4, 0x6626, 0x095a }, { 0xffd0, 0x0f83, 0x6669, 0x0a44 }, { 0xffd8, 0x0e5f, 0x6696, 0x0b39 }, + { 0xffdf, 0x0d46, 0x66ad, 0x0c39 } }; static inline int16_t clamp16(int32_t v) { @@ -101,7 +91,7 @@ void aClearBufferImpl(uint16_t addr, int nbytes) { memset(BUF_U8(addr), 0, nbytes); } -void aLoadBufferImpl(const void *source_addr, uint16_t dest_addr, uint16_t nbytes) { +void aLoadBufferImpl(const void* source_addr, uint16_t dest_addr, uint16_t nbytes) { #if __SANITIZE_ADDRESS__ for (size_t i = 0; i < ROUND_DOWN_16(nbytes); i++) { BUF_U8(dest_addr)[i] = ((const unsigned char*)source_addr)[i]; @@ -111,11 +101,11 @@ void aLoadBufferImpl(const void *source_addr, uint16_t dest_addr, uint16_t nbyte #endif } -void aSaveBufferImpl(uint16_t source_addr, int16_t *dest_addr, uint16_t nbytes) { +void aSaveBufferImpl(uint16_t source_addr, int16_t* dest_addr, uint16_t nbytes) { memcpy(dest_addr, BUF_S16(source_addr), ROUND_DOWN_16(nbytes)); } -void aLoadADPCMImpl(int num_entries_times_16, const int16_t *book_source_addr) { +void aLoadADPCMImpl(int num_entries_times_16, const int16_t* book_source_addr) { memcpy(rspa.adpcm_table, book_source_addr, num_entries_times_16); } @@ -127,9 +117,9 @@ void aSetBufferImpl(uint8_t flags, uint16_t in, uint16_t out, uint16_t nbytes) { void aInterleaveImpl(uint16_t dest, uint16_t left, uint16_t right, uint16_t c) { int count = ROUND_UP_8(c) / sizeof(int16_t) / 4; - int16_t *l = BUF_S16(left); - int16_t *r = BUF_S16(right); - int16_t *d = BUF_S16(dest); + int16_t* l = BUF_S16(left); + int16_t* r = BUF_S16(right); + int16_t* d = BUF_S16(dest); while (count > 0) { int16_t l0 = *l++; int16_t l1 = *l++; @@ -156,13 +146,13 @@ void aDMEMMoveImpl(uint16_t in_addr, uint16_t out_addr, int nbytes) { memmove(BUF_U8(out_addr), BUF_U8(in_addr), nbytes); } -void aSetLoopImpl(ADPCM_STATE *adpcm_loop_state) { +void aSetLoopImpl(ADPCM_STATE* adpcm_loop_state) { rspa.adpcm_loop_state = adpcm_loop_state; } void aADPCMdecImpl(uint8_t flags, ADPCM_STATE state) { - uint8_t *in = BUF_U8(rspa.in); - int16_t *out = BUF_S16(rspa.out); + uint8_t* in = BUF_U8(rspa.in); + int16_t* out = BUF_S16(rspa.out); int nbytes = ROUND_UP_32(rspa.nbytes); if (flags & A_INIT) { memset(out, 0, 16 * sizeof(int16_t)); @@ -174,9 +164,9 @@ void aADPCMdecImpl(uint8_t flags, ADPCM_STATE state) { out += 16; while (nbytes > 0) { - int shift = *in >> 4; // should be in 0..12 or 0..14 + int shift = *in >> 4; // should be in 0..12 or 0..14 int table_index = *in++ & 0xf; // should be in 0..7 - int16_t (*tbl)[8] = rspa.adpcm_table[table_index]; + int16_t(*tbl)[8] = rspa.adpcm_table[table_index]; int i; for (i = 0; i < 2; i++) { @@ -184,19 +174,19 @@ void aADPCMdecImpl(uint8_t flags, ADPCM_STATE state) { int16_t prev1 = out[-1]; int16_t prev2 = out[-2]; int j, k; - if (flags & 4) { - for (j = 0; j < 2; j++) { - ins[j * 4] = (((*in >> 6) << 30) >> 30) << shift; - ins[j * 4 + 1] = ((((*in >> 4) & 0x3) << 30) >> 30) << shift; - ins[j * 4 + 2] = ((((*in >> 2) & 0x3) << 30) >> 30) << shift; - ins[j * 4 + 3] = (((*in++ & 0x3) << 30) >> 30) << shift; - } - } else { - for (j = 0; j < 4; j++) { - ins[j * 2] = (((*in >> 4) << 28) >> 28) << shift; - ins[j * 2 + 1] = (((*in++ & 0xf) << 28) >> 28) << shift; - } - } + if (flags & 4) { + for (j = 0; j < 2; j++) { + ins[j * 4] = (((*in >> 6) << 30) >> 30) << shift; + ins[j * 4 + 1] = ((((*in >> 4) & 0x3) << 30) >> 30) << shift; + ins[j * 4 + 2] = ((((*in >> 2) & 0x3) << 30) >> 30) << shift; + ins[j * 4 + 3] = (((*in++ & 0x3) << 30) >> 30) << shift; + } + } else { + for (j = 0; j < 4; j++) { + ins[j * 2] = (((*in >> 4) << 28) >> 28) << shift; + ins[j * 2 + 1] = (((*in++ & 0xf) << 28) >> 28) << shift; + } + } for (j = 0; j < 8; j++) { int32_t acc = tbl[0][j] * prev2 + tbl[1][j] * prev1 + (ins[j] << 11); for (k = 0; k < j; k++) { @@ -213,13 +203,13 @@ void aADPCMdecImpl(uint8_t flags, ADPCM_STATE state) { void aResampleImpl(uint8_t flags, uint16_t pitch, RESAMPLE_STATE state) { int16_t tmp[16]; - int16_t *in_initial = BUF_S16(rspa.in); - int16_t *in = in_initial; - int16_t *out = BUF_S16(rspa.out); + int16_t* in_initial = BUF_S16(rspa.in); + int16_t* in = in_initial; + int16_t* out = BUF_S16(rspa.out); int nbytes = ROUND_UP_16(rspa.nbytes); uint32_t pitch_accumulator; int i; - int16_t *tbl; + int16_t* tbl; int32_t sample; if (flags & A_INIT) { @@ -238,10 +228,8 @@ void aResampleImpl(uint8_t flags, uint16_t pitch, RESAMPLE_STATE state) { do { for (i = 0; i < 8; i++) { tbl = resample_table[pitch_accumulator * 64 >> 16]; - sample = ((in[0] * tbl[0] + 0x4000) >> 15) + - ((in[1] * tbl[1] + 0x4000) >> 15) + - ((in[2] * tbl[2] + 0x4000) >> 15) + - ((in[3] * tbl[3] + 0x4000) >> 15); + sample = ((in[0] * tbl[0] + 0x4000) >> 15) + ((in[1] * tbl[1] + 0x4000) >> 15) + + ((in[2] * tbl[2] + 0x4000) >> 15) + ((in[3] * tbl[3] + 0x4000) >> 15); *out++ = clamp16(sample); pitch_accumulator += (pitch << 1); @@ -274,32 +262,32 @@ void aEnvSetup2Impl(uint16_t initial_vol_left, uint16_t initial_vol_right) { rspa.vol[1] = initial_vol_right; } -void aEnvMixerImpl(uint16_t in_addr, uint16_t n_samples, bool swap_reverb, - bool neg_3, bool neg_2, - bool neg_left, bool neg_right, - int32_t wet_dry_addr, u32 unk) -{ - int16_t *in = BUF_S16(in_addr); - int16_t *dry[2] = {BUF_S16(((wet_dry_addr >> 24) & 0xFF) << 4), BUF_S16(((wet_dry_addr >> 16) & 0xFF) << 4)}; - int16_t *wet[2] = {BUF_S16(((wet_dry_addr >> 8) & 0xFF) << 4), BUF_S16(((wet_dry_addr) & 0xFF) << 4)}; - int16_t negs[4] = {neg_left ? -1 : 0, neg_right ? -1 : 0, neg_3 ? -4 : 0, neg_2 ? -2 : 0}; - int swapped[2] = {swap_reverb ? 1 : 0, swap_reverb ? 0 : 1}; +void aEnvMixerImpl(uint16_t in_addr, uint16_t n_samples, bool swap_reverb, bool neg_3, bool neg_2, bool neg_left, + bool neg_right, int32_t wet_dry_addr, u32 unk) { + int16_t* in = BUF_S16(in_addr); + int16_t* dry[2] = { BUF_S16(((wet_dry_addr >> 24) & 0xFF) << 4), BUF_S16(((wet_dry_addr >> 16) & 0xFF) << 4) }; + int16_t* wet[2] = { BUF_S16(((wet_dry_addr >> 8) & 0xFF) << 4), BUF_S16(((wet_dry_addr)&0xFF) << 4) }; + int16_t negs[4] = { neg_left ? -1 : 0, neg_right ? -1 : 0, neg_3 ? -4 : 0, neg_2 ? -2 : 0 }; + int swapped[2] = { swap_reverb ? 1 : 0, swap_reverb ? 0 : 1 }; int n = ROUND_UP_16(n_samples); - uint16_t vols[2] = {rspa.vol[0], rspa.vol[1]}; - uint16_t rates[2] = {rspa.rate[0], rspa.rate[1]}; + uint16_t vols[2] = { rspa.vol[0], rspa.vol[1] }; + uint16_t rates[2] = { rspa.rate[0], rspa.rate[1] }; uint16_t vol_wet = rspa.vol_wet; uint16_t rate_wet = rspa.rate_wet; do { for (int i = 0; i < 8; i++) { - int16_t samples[2] = {*in, *in}; in++; + int16_t samples[2] = { *in, *in }; + in++; for (int j = 0; j < 2; j++) { samples[j] = (samples[j] * vols[j] >> 16) ^ negs[j]; } - for (int j = 0; j < 2; j++) { - *dry[j] = clamp16(*dry[j] + samples[j]); dry[j]++; - *wet[j] = clamp16(*wet[j] + ((samples[swapped[j]] * vol_wet >> 16) ^ negs[2 + j])); wet[j]++; + for (int j = 0; j < 2; j++) { + *dry[j] = clamp16(*dry[j] + samples[j]); + dry[j]++; + *wet[j] = clamp16(*wet[j] + ((samples[swapped[j]] * vol_wet >> 16) ^ negs[2 + j])); + wet[j]++; } } vols[0] += rates[0]; @@ -312,8 +300,8 @@ void aEnvMixerImpl(uint16_t in_addr, uint16_t n_samples, bool swap_reverb, void aMixImpl(uint16_t count, int16_t gain, uint16_t in_addr, uint16_t out_addr) { int nbytes = ROUND_UP_32(ROUND_DOWN_16(count << 4)); - int16_t *in = BUF_S16(in_addr); - int16_t *out = BUF_S16(out_addr); + int16_t* in = BUF_S16(in_addr); + int16_t* out = BUF_S16(out_addr); int i; int32_t sample; @@ -338,8 +326,8 @@ void aMixImpl(uint16_t count, int16_t gain, uint16_t in_addr, uint16_t out_addr) } void aS8DecImpl(uint8_t flags, ADPCM_STATE state) { - uint8_t *in = BUF_U8(rspa.in); - int16_t *out = BUF_S16(rspa.out); + uint8_t* in = BUF_U8(rspa.in); + int16_t* out = BUF_S16(rspa.out); int nbytes = ROUND_UP_32(rspa.nbytes); if (flags & A_INIT) { memset(out, 0, 16 * sizeof(int16_t)); @@ -375,27 +363,43 @@ void aS8DecImpl(uint8_t flags, ADPCM_STATE state) { } void aAddMixerImpl(uint16_t count, uint16_t in_addr, uint16_t out_addr) { - int16_t *in = BUF_S16(in_addr); - int16_t *out = BUF_S16(out_addr); + int16_t* in = BUF_S16(in_addr); + int16_t* out = BUF_S16(out_addr); int nbytes = ROUND_UP_64(ROUND_DOWN_16(count)); do { - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; - *out = clamp16(*out + *in++); out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; + *out = clamp16(*out + *in++); + out++; nbytes -= 16 * sizeof(int16_t); } while (nbytes > 0); @@ -403,7 +407,7 @@ void aAddMixerImpl(uint16_t count, uint16_t in_addr, uint16_t out_addr) { void aDuplicateImpl(uint16_t count, uint16_t in_addr, uint16_t out_addr) { uint8_t* in = BUF_U8(in_addr); - uint8_t *out = BUF_U8(out_addr); + uint8_t* out = BUF_U8(out_addr); uint8_t tmp[128]; memcpy(tmp, in, 128); @@ -414,49 +418,61 @@ void aDuplicateImpl(uint16_t count, uint16_t in_addr, uint16_t out_addr) { } void aResampleZohImpl(uint16_t pitch, uint16_t start_fract) { - int16_t *in = BUF_S16(rspa.in); - int16_t *out = BUF_S16(rspa.out); + int16_t* in = BUF_S16(rspa.in); + int16_t* out = BUF_S16(rspa.out); int nbytes = ROUND_UP_8(rspa.nbytes); uint32_t pos = start_fract; uint32_t pitch_add = pitch << 2; do { - *out++ = in[pos >> 17]; pos += pitch_add; - *out++ = in[pos >> 17]; pos += pitch_add; - *out++ = in[pos >> 17]; pos += pitch_add; - *out++ = in[pos >> 17]; pos += pitch_add; + *out++ = in[pos >> 17]; + pos += pitch_add; + *out++ = in[pos >> 17]; + pos += pitch_add; + *out++ = in[pos >> 17]; + pos += pitch_add; + *out++ = in[pos >> 17]; + pos += pitch_add; nbytes -= 4 * sizeof(int16_t); } while (nbytes > 0); } void aInterlImpl(uint16_t in_addr, uint16_t out_addr, uint16_t n_samples) { - int16_t *in = BUF_S16(in_addr); - int16_t *out = BUF_S16(out_addr); + int16_t* in = BUF_S16(in_addr); + int16_t* out = BUF_S16(out_addr); int n = ROUND_UP_8(n_samples); do { - *out++ = *in++; in++; - *out++ = *in++; in++; - *out++ = *in++; in++; - *out++ = *in++; in++; - *out++ = *in++; in++; - *out++ = *in++; in++; - *out++ = *in++; in++; - *out++ = *in++; in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; + *out++ = *in++; + in++; n -= 8; } while (n > 0); } -void aFilterImpl(uint8_t flags, uint16_t count_or_buf, int16_t *state_or_filter) { +void aFilterImpl(uint8_t flags, uint16_t count_or_buf, int16_t* state_or_filter) { if (flags > A_INIT) { rspa.filter_count = ROUND_UP_16(count_or_buf); memcpy(rspa.filter, state_or_filter, sizeof(rspa.filter)); } else { int16_t tmp[16], tmp2[8]; int count = rspa.filter_count; - int16_t *buf = BUF_S16(count_or_buf); + int16_t* buf = BUF_S16(count_or_buf); if (flags == A_INIT) { #ifndef __clang__ @@ -498,18 +514,26 @@ void aFilterImpl(uint8_t flags, uint16_t count_or_buf, int16_t *state_or_filter) } void aHiLoGainImpl(uint8_t g, uint16_t count, uint16_t addr) { - int16_t *samples = BUF_S16(addr); + int16_t* samples = BUF_S16(addr); int nbytes = ROUND_UP_32(count); do { - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; - *samples = clamp16((*samples * g) >> 4); samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; + *samples = clamp16((*samples * g) >> 4); + samples++; nbytes -= 8; } while (nbytes > 0); @@ -520,8 +544,8 @@ void aUnkCmd3Impl(uint16_t a, uint16_t b, uint16_t c) { void aUnkCmd19Impl(uint8_t f, uint16_t count, uint16_t out_addr, uint16_t in_addr) { int nbytes = ROUND_UP_64(count); - int16_t *in = BUF_S16(in_addr + f); - int16_t *out = BUF_S16(out_addr); + int16_t* in = BUF_S16(in_addr + f); + int16_t* out = BUF_S16(out_addr); int16_t tbl[32]; memcpy(tbl, in, 32 * sizeof(int16_t)); diff --git a/mm/2s2h/resource/importer/AnimationFactory.cpp b/mm/2s2h/resource/importer/AnimationFactory.cpp index 3e384e0a0..c2fddcac6 100644 --- a/mm/2s2h/resource/importer/AnimationFactory.cpp +++ b/mm/2s2h/resource/importer/AnimationFactory.cpp @@ -5,8 +5,7 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { +std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } @@ -82,7 +81,8 @@ ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) // Read the segment pointer (always 32 bit, doesn't adjust for system pointer size) std::string path = reader->ReadString(); - const auto animData = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str())); + const auto animData = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str())); animation->animationData.linkAnimationHeader.segment = animData->GetPointer(); } else if (animType == AnimationType::Legacy) { diff --git a/mm/2s2h/resource/importer/AnimationFactory.h b/mm/2s2h/resource/importer/AnimationFactory.h index c475ae559..2a6b0dc7f 100644 --- a/mm/2s2h/resource/importer/AnimationFactory.h +++ b/mm/2s2h/resource/importer/AnimationFactory.h @@ -8,4 +8,4 @@ class ResourceFactoryBinaryAnimationV0 : public Ship::ResourceFactoryBinary { public: std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/AudioSampleFactory.cpp b/mm/2s2h/resource/importer/AudioSampleFactory.cpp index 2e57c7784..388436538 100644 --- a/mm/2s2h/resource/importer/AudioSampleFactory.cpp +++ b/mm/2s2h/resource/importer/AudioSampleFactory.cpp @@ -82,10 +82,8 @@ extern "C" SoundFontSample* ReadCustomSample(const char* path) { drwav_uint32 sampleRate; drwav_uint64 totalPcm; drmp3_int16* pcmData = - drwav_open_memory_and_read_pcm_frames_s16(strem2, sampleRaw->BufferSize, &channels, &sampleRate, &totalPcm, NULL); - sampleC->size = totalPcm; - sampleC->sampleAddr = (uint8_t*)pcmData; - sampleC->codec = CODEC_S16; + drwav_open_memory_and_read_pcm_frames_s16(strem2, sampleRaw->BufferSize, &channels, &sampleRate, &totalPcm, +NULL); sampleC->size = totalPcm; sampleC->sampleAddr = (uint8_t*)pcmData; sampleC->codec = CODEC_S16; sampleC->loop = new AdpcmLoop; sampleC->loop->start = 0; diff --git a/mm/2s2h/resource/importer/AudioSequenceFactory.cpp b/mm/2s2h/resource/importer/AudioSequenceFactory.cpp index 3461077b5..5b8899501 100644 --- a/mm/2s2h/resource/importer/AudioSequenceFactory.cpp +++ b/mm/2s2h/resource/importer/AudioSequenceFactory.cpp @@ -17,7 +17,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResou audioSequence->sequenceData.push_back(reader->ReadChar()); } audioSequence->sequence.seqData = audioSequence->sequenceData.data(); - + audioSequence->sequence.seqNumber = reader->ReadUByte(); audioSequence->sequence.medium = reader->ReadUByte(); audioSequence->sequence.cachePolicy = reader->ReadUByte(); diff --git a/mm/2s2h/resource/importer/AudioSoundFontFactory.cpp b/mm/2s2h/resource/importer/AudioSoundFontFactory.cpp index 971f6b9c8..39cc6f47f 100644 --- a/mm/2s2h/resource/importer/AudioSoundFontFactory.cpp +++ b/mm/2s2h/resource/importer/AudioSoundFontFactory.cpp @@ -15,7 +15,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadReso audioSoundFont->soundFont.fntIndex = reader->ReadInt32(); audioSoundFont->medium = reader->ReadInt8(); audioSoundFont->cachePolicy = reader->ReadInt8(); - + audioSoundFont->data1 = reader->ReadUInt16(); audioSoundFont->soundFont.sampleBankId1 = audioSoundFont->data1 >> 8; audioSoundFont->soundFont.sampleBankId2 = audioSoundFont->data1 & 0xFF; @@ -25,10 +25,10 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadReso uint32_t drumCount = reader->ReadUInt32(); audioSoundFont->soundFont.numDrums = drumCount; - + uint32_t instrumentCount = reader->ReadUInt32(); audioSoundFont->soundFont.numInstruments = instrumentCount; - + uint32_t soundEffectCount = reader->ReadUInt32(); audioSoundFont->soundFont.numSfx = soundEffectCount; @@ -48,7 +48,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadReso drumEnvelopes.reserve(audioSoundFont->drumEnvelopeCounts[i]); for (uint32_t j = 0; j < audioSoundFont->drumEnvelopeCounts.back(); j++) { AdsrEnvelope env; - + int16_t delay = reader->ReadInt16(); int16_t arg = reader->ReadInt16(); @@ -147,11 +147,8 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadReso instrument.highNotesSound.tuning = 0; } - audioSoundFont->instruments.push_back(instrument); - audioSoundFont->instrumentAddresses.push_back(isValidEntry ? - &audioSoundFont->instruments.back() : - nullptr); + audioSoundFont->instrumentAddresses.push_back(isValidEntry ? &audioSoundFont->instruments.back() : nullptr); } audioSoundFont->soundFont.instruments = audioSoundFont->instrumentAddresses.data(); @@ -168,7 +165,7 @@ std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadReso auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(sampleFileName.c_str()); soundEffect.sample = static_cast(res ? res->GetRawPointer() : nullptr); } - + audioSoundFont->soundEffects.push_back(soundEffect); } audioSoundFont->soundFont.soundEffects = audioSoundFont->soundEffects.data(); diff --git a/mm/2s2h/resource/importer/CollisionHeaderFactory.cpp b/mm/2s2h/resource/importer/CollisionHeaderFactory.cpp index d636e57c4..bc03cfde5 100644 --- a/mm/2s2h/resource/importer/CollisionHeaderFactory.cpp +++ b/mm/2s2h/resource/importer/CollisionHeaderFactory.cpp @@ -3,7 +3,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { +std::shared_ptr +ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } @@ -36,7 +37,7 @@ std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadRes CollisionPoly polygon; polygon.type = reader->ReadUInt16(); - + polygon.flags_vIA = reader->ReadUInt16(); polygon.flags_vIB = reader->ReadUInt16(); polygon.vIC = reader->ReadUInt16(); @@ -48,7 +49,6 @@ std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadRes polygon.dist = reader->ReadUInt16(); collisionHeader->polygons.push_back(polygon); - } collisionHeader->collisionHeaderData.polyList = collisionHeader->polygons.data(); @@ -72,7 +72,7 @@ std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadRes camDataEntry.cameraSType = reader->ReadUInt16(); camDataEntry.numCameras = reader->ReadInt16(); collisionHeader->camData.push_back(camDataEntry); - + int32_t camPosDataIdx = reader->ReadInt32(); collisionHeader->camPosDataIndices.push_back(camPosDataIdx); } @@ -91,7 +91,7 @@ std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadRes zero.x = 0; zero.y = 0; zero.z = 0; - collisionHeader->camPosDataZero = zero; + collisionHeader->camPosDataZero = zero; for (size_t i = 0; i < collisionHeader->camDataCount; i++) { int32_t idx = collisionHeader->camPosDataIndices[i]; @@ -159,7 +159,7 @@ std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResour CollisionPoly polygon; polygon.type = child->UnsignedAttribute("Type"); - + polygon.flags_vIA = child->UnsignedAttribute("VertexA"); polygon.flags_vIB = child->UnsignedAttribute("VertexB"); polygon.vIC = child->UnsignedAttribute("VertexC"); @@ -183,11 +183,11 @@ std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResour camDataEntry.cameraSType = child->UnsignedAttribute("SType"); camDataEntry.numCameras = child->IntAttribute("NumData"); collisionHeader->camData.push_back(camDataEntry); - + int32_t camPosDataIdx = child->IntAttribute("CameraPosDataSeg"); collisionHeader->camPosDataIndices.push_back(camPosDataIdx); } else if (childName == "CameraPositionData") { - //each camera position data is made up of 3 Vec3s + // each camera position data is made up of 3 Vec3s Vec3s pos; pos.x = child->IntAttribute("PosX"); pos.y = child->IntAttribute("PosY"); @@ -227,7 +227,7 @@ std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResour collisionHeader->camData[i].camPosData = &collisionHeader->camPosDataZero; } } - + collisionHeader->collisionHeaderData.numVertices = collisionHeader->vertices.size(); collisionHeader->collisionHeaderData.numPolygons = collisionHeader->polygons.size(); collisionHeader->surfaceTypesCount = collisionHeader->surfaceTypes.size(); diff --git a/mm/2s2h/resource/importer/CutsceneFactory.cpp b/mm/2s2h/resource/importer/CutsceneFactory.cpp index 83a81f3ab..944d64525 100644 --- a/mm/2s2h/resource/importer/CutsceneFactory.cpp +++ b/mm/2s2h/resource/importer/CutsceneFactory.cpp @@ -850,4 +850,4 @@ void Ship::CutsceneFactoryV0::ParseFileBinaryOoT(std::shared_ptr r } } #endif -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/CutsceneFactory.h b/mm/2s2h/resource/importer/CutsceneFactory.h index da5989eb9..70d29519a 100644 --- a/mm/2s2h/resource/importer/CutsceneFactory.h +++ b/mm/2s2h/resource/importer/CutsceneFactory.h @@ -3,10 +3,9 @@ #include "Resource.h" #include "ResourceFactoryBinary.h" - namespace SOH { class ResourceFactoryBinaryCutsceneV0 : public Ship::ResourceFactoryBinary { public: std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/KeyFrameFactory.h b/mm/2s2h/resource/importer/KeyFrameFactory.h index 6c28d6fe0..2d9596d68 100644 --- a/mm/2s2h/resource/importer/KeyFrameFactory.h +++ b/mm/2s2h/resource/importer/KeyFrameFactory.h @@ -14,4 +14,4 @@ class ResourceFactoryBinaryKeyFrameAnim : public Ship::ResourceFactoryBinary { std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/PlayerAnimationFactory.h b/mm/2s2h/resource/importer/PlayerAnimationFactory.h index ce356b835..ffcb64d67 100644 --- a/mm/2s2h/resource/importer/PlayerAnimationFactory.h +++ b/mm/2s2h/resource/importer/PlayerAnimationFactory.h @@ -8,4 +8,4 @@ class ResourceFactoryBinaryPlayerAnimationV0 : public Ship::ResourceFactoryBinar public: std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/SceneFactory.cpp b/mm/2s2h/resource/importer/SceneFactory.cpp index aec26e383..6db76fe23 100644 --- a/mm/2s2h/resource/importer/SceneFactory.cpp +++ b/mm/2s2h/resource/importer/SceneFactory.cpp @@ -58,7 +58,7 @@ ResourceFactoryBinarySceneV0::ResourceFactoryBinarySceneV0() { sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared(); // TODO should we use a different custom scene command like cutscenes? sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared(); - //sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared(); + // sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared(); sceneCommandFactories[SceneCommandID::SetCutscenesMM] = std::make_shared(); @@ -79,8 +79,8 @@ void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr sce } std::shared_ptr -ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, - uint32_t index) { +ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr scene, + std::shared_ptr reader, uint32_t index) { SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); reader->Seek(-sizeof(int32_t), Ship::SeekOffsetType::Current); diff --git a/mm/2s2h/resource/importer/SkeletonFactory.cpp b/mm/2s2h/resource/importer/SkeletonFactory.cpp index a9c5f9db0..a8057e781 100644 --- a/mm/2s2h/resource/importer/SkeletonFactory.cpp +++ b/mm/2s2h/resource/importer/SkeletonFactory.cpp @@ -27,18 +27,18 @@ std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(s } if (skeleton->type == SkeletonType::Curve) { - skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; - skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); + skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; + skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); } else if (skeleton->type == SkeletonType::Flex) { - skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; + skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; } if (skeleton->type == SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.limbCount = skeleton->limbCount; - skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); + skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.limbCount = skeleton->limbCount; - skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); + skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); } for (size_t i = 0; i < skeleton->limbTable.size(); i++) { @@ -101,7 +101,6 @@ std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std: } } - skel->limbCount = reader->IntAttribute("LimbCount"); skel->dListCount = reader->IntAttribute("DisplayListCount"); @@ -118,7 +117,7 @@ std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std: child = child->NextSiblingElement(); } - + skel->skeletonData.flexSkeletonHeader.sh.limbCount = skel->limbCount; skel->skeletonData.flexSkeletonHeader.sh.segment = (void**)skel->skeletonHeaderSegments.data(); skel->skeletonData.flexSkeletonHeader.dListCount = skel->dListCount; diff --git a/mm/2s2h/resource/importer/SkeletonFactory.h b/mm/2s2h/resource/importer/SkeletonFactory.h index 24f92720a..39feb8c29 100644 --- a/mm/2s2h/resource/importer/SkeletonFactory.h +++ b/mm/2s2h/resource/importer/SkeletonFactory.h @@ -12,6 +12,6 @@ class ResourceFactoryBinarySkeletonV0 : public Ship::ResourceFactoryBinary { class ResourceFactoryXMLSkeletonV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/SkeletonLimbFactory.cpp b/mm/2s2h/resource/importer/SkeletonLimbFactory.cpp index 86553fef4..181c8e40b 100644 --- a/mm/2s2h/resource/importer/SkeletonLimbFactory.cpp +++ b/mm/2s2h/resource/importer/SkeletonLimbFactory.cpp @@ -17,12 +17,12 @@ std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResour skeletonLimb->skinDList = reader->ReadString(); skeletonLimb->skinVtxCnt = reader->ReadUInt16(); - + skeletonLimb->skinLimbModifCount = reader->ReadUInt32(); skeletonLimb->skinLimbModifArray.reserve(skeletonLimb->skinLimbModifCount); skeletonLimb->skinLimbModifVertexArrays.reserve(skeletonLimb->skinLimbModifCount); skeletonLimb->skinLimbModifTransformationArrays.reserve(skeletonLimb->skinLimbModifCount); - for (size_t i = 0; i < skeletonLimb->skinLimbModifCount; i++) { + for (size_t i = 0; i < skeletonLimb->skinLimbModifCount; i++) { SkinLimbModif skinLimbModif; skinLimbModif.unk_4 = reader->ReadUInt16(); skeletonLimb->skinLimbModifArray.push_back(skinLimbModif); @@ -168,16 +168,20 @@ std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResour } for (size_t i = 0; i < skeletonLimb->skinLimbModifArray.size(); i++) { - skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = skeletonLimb->skinLimbModifVertexArrays[i].size(); - skeletonLimb->skinAnimLimbData.limbModifications[i].skinVertices = skeletonLimb->skinLimbModifVertexArrays[i].data(); - - skeletonLimb->skinAnimLimbData.limbModifications[i].transformCount = skeletonLimb->skinLimbModifTransformationArrays[i].size(); - skeletonLimb->skinAnimLimbData.limbModifications[i].limbTransformations = skeletonLimb->skinLimbModifTransformationArrays[i].data(); + skeletonLimb->skinAnimLimbData.limbModifications[i].vtxCount = + skeletonLimb->skinLimbModifVertexArrays[i].size(); + skeletonLimb->skinAnimLimbData.limbModifications[i].skinVertices = + skeletonLimb->skinLimbModifVertexArrays[i].data(); + + skeletonLimb->skinAnimLimbData.limbModifications[i].transformCount = + skeletonLimb->skinLimbModifTransformationArrays[i].size(); + skeletonLimb->skinAnimLimbData.limbModifications[i].limbTransformations = + skeletonLimb->skinLimbModifTransformationArrays[i].data(); skeletonLimb->skinAnimLimbData.limbModifications[i].unk_4 = skeletonLimb->skinLimbModifArray[i].unk_4; } - skeletonLimb->limbData.skinLimb.segment = &skeletonLimb->skinAnimLimbData; + skeletonLimb->limbData.skinLimb.segment = &skeletonLimb->skinAnimLimbData; } } diff --git a/mm/2s2h/resource/importer/SkeletonLimbFactory.h b/mm/2s2h/resource/importer/SkeletonLimbFactory.h index 222cefa2c..bacb2d127 100644 --- a/mm/2s2h/resource/importer/SkeletonLimbFactory.h +++ b/mm/2s2h/resource/importer/SkeletonLimbFactory.h @@ -12,6 +12,6 @@ class ResourceFactoryBinarySkeletonLimbV0 : public Ship::ResourceFactoryBinary { class ResourceFactoryXMLSkeletonLimbV0 : public Ship::ResourceFactoryXML { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/TextMMFactory.cpp b/mm/2s2h/resource/importer/TextMMFactory.cpp index 494feeafe..16da26f25 100644 --- a/mm/2s2h/resource/importer/TextMMFactory.cpp +++ b/mm/2s2h/resource/importer/TextMMFactory.cpp @@ -19,7 +19,8 @@ std::shared_ptr ResourceFactoryBinaryTextMMV0::ReadResource(std entry.id = reader->ReadUInt16(); entry.textboxType = reader->ReadUByte(); entry.textboxYPos = reader->ReadUByte(); - // BENTODO: the new ZAPD reads and exports this as an int16 for JP but nothing currently uses that and the game expects an int8. Use this for now. + // BENTODO: the new ZAPD reads and exports this as an int16 for JP but nothing currently uses that and the game + // expects an int8. Use this for now. entry.icon = (int8_t)reader->ReadUInt16(); entry.nextMessageID = reader->ReadUInt16(); entry.firstItemCost = reader->ReadUInt16(); @@ -65,4 +66,4 @@ std::shared_ptr ResourceFactoryXMLTextMMV0::ReadResource(std::s return text; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/TextMMFactory.h b/mm/2s2h/resource/importer/TextMMFactory.h index f82ff9142..e2a00ce5b 100644 --- a/mm/2s2h/resource/importer/TextMMFactory.h +++ b/mm/2s2h/resource/importer/TextMMFactory.h @@ -25,4 +25,4 @@ class TextMMFactory : public Ship::ResourceFactoryBinary ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; }; #endif -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/TextureAnimationFactory.cpp b/mm/2s2h/resource/importer/TextureAnimationFactory.cpp index ede0e9a4c..1e141816f 100644 --- a/mm/2s2h/resource/importer/TextureAnimationFactory.cpp +++ b/mm/2s2h/resource/importer/TextureAnimationFactory.cpp @@ -6,7 +6,8 @@ namespace SOH { -std::shared_ptr ResourceFactoryBinaryTextureAnimationV0::ReadResource(std::shared_ptr file) { +std::shared_ptr +ResourceFactoryBinaryTextureAnimationV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } @@ -144,4 +145,4 @@ std::shared_ptr ResourceFactoryBinaryTextureAnimationV0::ReadRe return tAnim; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/TextureAnimationFactory.h b/mm/2s2h/resource/importer/TextureAnimationFactory.h index bca2e3d84..4ff6bb4ff 100644 --- a/mm/2s2h/resource/importer/TextureAnimationFactory.h +++ b/mm/2s2h/resource/importer/TextureAnimationFactory.h @@ -7,7 +7,6 @@ namespace SOH { class ResourceFactoryBinaryTextureAnimationV0 : public Ship::ResourceFactoryBinary { public: std::shared_ptr ReadResource(std::shared_ptr file) override; - }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.cpp b/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.cpp index 30c943623..1787a920e 100644 --- a/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -3,8 +3,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -EndMarkerFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr EndMarkerFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto endMarker = std::make_shared(initData); ReadCommandId(endMarker, reader); diff --git a/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.h b/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.h index 7fb64a5b0..2e20fa46c 100644 --- a/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/EndMarkerFactory.h @@ -5,6 +5,7 @@ namespace SOH { class EndMarkerFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.cpp index a72fdbd06..d41e27da5 100644 --- a/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.cpp @@ -7,5 +7,4 @@ void SceneCommandFactoryBinaryV0::ReadCommandId(std::shared_ptr reader) { command->cmdId = (SceneCommandID)reader->ReadInt32(); } -} - \ No newline at end of file +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.h b/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.h index a2a6fecb4..2a487c408 100644 --- a/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SceneCommandFactory.h @@ -9,7 +9,7 @@ namespace SOH { class SceneCommandFactoryBinaryV0 { public: virtual std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) = 0; + std::shared_ptr reader) = 0; protected: void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); diff --git a/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.cpp index 28e73a7cc..01d10f95a 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.cpp @@ -3,8 +3,9 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetActorCutsceneListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetActorCutsceneListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setActorCsList = std::make_shared(initData); ReadCommandId(setActorCsList, reader); @@ -27,4 +28,4 @@ std::shared_ptr SetActorCutsceneListFactory::ReadResource(std:: } return setActorCsList; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.h index ca96462d5..13887991e 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetActorCutsceneListFactory.h @@ -5,6 +5,6 @@ namespace SOH { class SetActorCutsceneListFactory : public SceneCommandFactoryBinaryV0 { std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -} +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.cpp index 96593963c..39424847b 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetActorListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetActorListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setActorList = std::make_shared(initData); ReadCommandId(setActorList, reader); - + setActorList->numActors = reader->ReadUInt32(); setActorList->actorList.reserve(setActorList->numActors); for (uint32_t i = 0; i < setActorList->numActors; i++) { diff --git a/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.h index 9fff9af90..6a93e5a73 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetActorListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 62a518947..fba819f8a 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -3,18 +3,20 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setAlternateHeaders = std::make_shared(initData); ReadCommandId(setAlternateHeaders, reader); - + setAlternateHeaders->numHeaders = reader->ReadUInt32(); setAlternateHeaders->headers.reserve(setAlternateHeaders->numHeaders); for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { auto headerName = reader->ReadString(); if (!headerName.empty()) { - setAlternateHeaders->headers.push_back(std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + setAlternateHeaders->headers.push_back(std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); } else { setAlternateHeaders->headers.push_back(nullptr); } diff --git a/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.h index 2c8be6712..dd96fe1a3 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.cpp index de097d44f..2e673a67f 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.cpp @@ -5,10 +5,11 @@ namespace SOH { -std::shared_ptr SetAnimatedMaterialListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetAnimatedMaterialListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setAnimatedMat = std::make_shared(initData); - + ReadCommandId(setAnimatedMat, reader); std::string str = reader->ReadString(); @@ -17,7 +18,7 @@ std::shared_ptr SetAnimatedMaterialListFactory::ReadResource(st AnimatedMaterial* res = data->GetPointer(); setAnimatedMat->mat = res; - + return setAnimatedMat; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.h index 4c99cee23..cb54be868 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetAnimatedMaterialListFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetAnimatedMaterialListFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -} +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 75fc47cf6..c95f6fa2f 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -3,8 +3,9 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setCameraSettings = std::make_shared(initData); ReadCommandId(setCameraSettings, reader); diff --git a/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.h index d1cd6f6a7..19855f7d4 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index 13198efe4..3bf3272d9 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -4,14 +4,16 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setCollisionHeader = std::make_shared(initData); ReadCommandId(setCollisionHeader, reader); - + setCollisionHeader->fileName = reader->ReadString(); - setCollisionHeader->collisionHeader = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); + setCollisionHeader->collisionHeader = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); return setCollisionHeader; } diff --git a/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.h index ddb8d26ca..630959c5c 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp index 75048bfdd..043d3fc83 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -3,10 +3,10 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetCsCameraFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetCsCameraFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setCsCamera = std::make_shared(initData); - + ReadCommandId(setCsCamera, reader); size_t camSize = reader->ReadUInt32(); @@ -32,4 +32,4 @@ SetCsCameraFactory::ReadResource(std::shared_ptr initDat return setCsCamera; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.h b/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.h index 2d2555bf6..1187d434b 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetCsCameraFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.cpp index fc77a9bca..ee9050e88 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -5,7 +5,7 @@ namespace SOH { std::shared_ptr SetCutsceneFactoryMM::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto setCutscenes = std::make_shared(initData); ReadCommandId(setCutscenes, reader); @@ -20,7 +20,8 @@ std::shared_ptr SetCutsceneFactoryMM::ReadResource(std::shared_ entry.entrance = reader->ReadUByte(); entry.flag = reader->ReadUByte(); entry.data = std::static_pointer_cast( - Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str()))->GetPointer(); + Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path.c_str())) + ->GetPointer(); setCutscenes->entries.emplace_back(entry); } diff --git a/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.h b/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.h index f8d24a22d..5489f6d3c 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetCutscenesFactory.h @@ -6,7 +6,7 @@ namespace SOH { class SetCutsceneFactoryMM : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index 16a556725..9b8660f04 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setEchoSettings = std::make_shared(initData); ReadCommandId(setEchoSettings, reader); - + setEchoSettings->settings.echo = reader->ReadInt8(); return setEchoSettings; diff --git a/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.h index 89d3e1823..c552239d7 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.cpp index 05a4bc8b0..b541b4498 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -3,20 +3,20 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetEntranceListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetEntranceListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setEntranceList = std::make_shared(initData); ReadCommandId(setEntranceList, reader); - + setEntranceList->numEntrances = reader->ReadUInt32(); setEntranceList->entrances.reserve(setEntranceList->numEntrances); for (uint32_t i = 0; i < setEntranceList->numEntrances; i++) { - EntranceEntry entranceEntry; + EntranceEntry entranceEntry; + + entranceEntry.spawn = reader->ReadInt8(); + entranceEntry.room = reader->ReadInt8(); - entranceEntry.spawn = reader->ReadInt8(); - entranceEntry.room = reader->ReadInt8(); - setEntranceList->entrances.push_back(entranceEntry); } diff --git a/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.h index 7372c436c..09cb70ea8 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetEntranceListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.cpp index f5c6d2768..6e9335a40 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.cpp @@ -3,9 +3,8 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetExitListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr SetExitListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setExitList = std::make_shared(initData); ReadCommandId(setExitList, reader); @@ -17,4 +16,4 @@ SetExitListFactory::ReadResource(std::shared_ptr initDat } return setExitList; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.h index 079996c0c..8666bbed2 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetExitListFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetExitListFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.cpp index c8b3e6f16..7a82f1594 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.cpp @@ -3,20 +3,20 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetLightListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetLightListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setLightList = std::make_shared(initData); ReadCommandId(setLightList, reader); - + setLightList->numLights = reader->ReadUInt32(); setLightList->lightList.reserve(setLightList->numLights); for (uint32_t i = 0; i < setLightList->numLights; i++) { LightInfo light; light.type = reader->ReadUByte(); - - light.params.point.x = reader->ReadInt16(); + + light.params.point.x = reader->ReadInt16(); light.params.point.y = reader->ReadInt16(); light.params.point.z = reader->ReadInt16(); @@ -25,7 +25,7 @@ SetLightListFactory::ReadResource(std::shared_ptr initDa light.params.point.color[2] = reader->ReadUByte(); // b light.params.point.drawGlow = reader->ReadUByte(); - light.params.point.radius = reader->ReadInt16(); + light.params.point.radius = reader->ReadInt16(); setLightList->lightList.emplace_back(light); } diff --git a/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.h index e846e093a..5ea4f8794 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetLightListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetLightListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetLightingSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetLightingSettingsFactory.h index 9361bbb25..bd72a56e1 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetLightingSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetLightingSettingsFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp index 925f744bc..7ed059a63 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.cpp @@ -4,12 +4,12 @@ #include "libultraship/libultraship.h" namespace SOH { -std::shared_ptr -SetMeshFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetMeshFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setMesh = std::make_shared(initData); ReadCommandId(setMesh, reader); - + setMesh->data = reader->ReadInt8(); setMesh->meshHeader.base.type = reader->ReadInt8(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.h b/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.h index f7d87d9f0..0426c2b47 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetMeshFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetMeshFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.cpp index 21daeadad..90f543b9f 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.cpp @@ -5,7 +5,7 @@ namespace SOH { std::shared_ptr SetMinimapChestsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto chests = std::make_shared(initData); ReadCommandId(chests, reader); @@ -26,4 +26,4 @@ std::shared_ptr SetMinimapChestsFactory::ReadResource(std::shar return chests; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.h index 8e7bce9fb..673ce1ad2 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetMinimapChestsFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetMinimapChestsFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -} +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.cpp index 852a2ad07..a008dba67 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.cpp @@ -4,7 +4,7 @@ namespace SOH { std::shared_ptr SetMinimapListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto mapList = std::make_shared(initData); ReadCommandId(mapList, reader); @@ -26,6 +26,5 @@ std::shared_ptr SetMinimapListFactory::ReadResource(std::shared mapList->list.entry = mapList->entries.data(); return mapList; - } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.h index daa058fc3..65689ee80 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetMinimapListFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetMinimapListFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.cpp index 4081d9efd..7f265ba48 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetObjectListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetObjectListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setObjectList = std::make_shared(initData); ReadCommandId(setObjectList, reader); - + setObjectList->numObjects = reader->ReadUInt32(); setObjectList->objects.reserve(setObjectList->numObjects); for (uint32_t i = 0; i < setObjectList->numObjects; i++) { diff --git a/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.h index d8f8184d1..2bb877032 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetObjectListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetObjectListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.cpp index 651e20ef9..850e4cc59 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -5,9 +5,9 @@ namespace SOH { std::shared_ptr SetPathwaysMMFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto setPathways = std::make_shared(initData); - + ReadCommandId(setPathways, reader); setPathways->numPaths = reader->ReadUInt32(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.h b/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.h index c4efe8bff..d79cd12b1 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetPathwaysFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetPathwaysMMFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index 187d39c7c..8d16ddc00 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -3,8 +3,9 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetRoomBehaviorMMFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetRoomBehaviorMMFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setRoomBehavior = std::make_shared(initData); ReadCommandId(setRoomBehavior, reader); diff --git a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h index cb54d0b0f..8a7976ff0 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetRoomBehaviorMMFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; }; // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.cpp index 9afeef77c..4008a702e 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -3,12 +3,12 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr -SetRoomListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { +std::shared_ptr SetRoomListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setRoomList = std::make_shared(initData); ReadCommandId(setRoomList, reader); - + setRoomList->numRooms = reader->ReadInt32(); setRoomList->rooms.reserve(setRoomList->numRooms); for (uint32_t i = 0; i < setRoomList->numRooms; i++) { @@ -19,7 +19,7 @@ SetRoomListFactory::ReadResource(std::shared_ptr initDat room.fileName = (char*)setRoomList->fileNames.back().c_str(); room.vromStart = reader->ReadInt32(); room.vromEnd = reader->ReadInt32(); - + setRoomList->rooms.push_back(room); } diff --git a/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.h index 5959bc213..9f07d6f08 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetRoomListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetRoomListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index 1bb843815..4ef26acc2 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -3,12 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSkyboxModifier = std::make_shared(initData); - ReadCommandId(setSkyboxModifier, reader); - + ReadCommandId(setSkyboxModifier, reader); + setSkyboxModifier->modifier.skyboxDisabled = reader->ReadInt8(); setSkyboxModifier->modifier.sunMoonDisabled = reader->ReadInt8(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.h index e1a8f0fac..3a159daf6 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index 3e06bc980..eac85dd88 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -3,12 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSkyboxSettings = std::make_shared(initData); ReadCommandId(setSkyboxSettings, reader); - + setSkyboxSettings->settings.unk = reader->ReadInt8(); setSkyboxSettings->settings.skyboxId = reader->ReadInt8(); setSkyboxSettings->settings.weather = reader->ReadInt8(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 5b70d2fdf..7a501619c 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index 4d8428d89..877b64cd2 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -4,11 +4,11 @@ namespace SOH { std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto setSoundSettings = std::make_shared(initData); ReadCommandId(setSoundSettings, reader); - + setSoundSettings->settings.reverb = reader->ReadInt8(); setSoundSettings->settings.natureAmbienceId = reader->ReadInt8(); setSoundSettings->settings.seqId = reader->ReadInt8(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.h index 00d41daac..912fa6ea0 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index 411a4e5c8..af5af8f38 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -3,12 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setSpecialObjects = std::make_shared(initData); ReadCommandId(setSpecialObjects, reader); - + setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8(); setSpecialObjects->specialObjects.globalObject = reader->ReadInt16(); diff --git a/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.h index 2a0e32dfd..ef24aa740 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.cpp index e4a455335..3525d3b0d 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -3,12 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetStartPositionListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setStartPositionList = std::make_shared(initData); ReadCommandId(setStartPositionList, reader); - + setStartPositionList->numStartPositions = reader->ReadUInt32(); setStartPositionList->startPositions.reserve(setStartPositionList->numStartPositions); for (uint32_t i = 0; i < setStartPositionList->numStartPositions; i++) { diff --git a/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.h index 37ce5a21d..91b52089a 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetStartPositionListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index 3fd53d3ae..cc11d3c0a 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -4,7 +4,7 @@ namespace SOH { std::shared_ptr SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto setTimeSettings = std::make_shared(initData); ReadCommandId(setTimeSettings, reader); @@ -16,4 +16,4 @@ std::shared_ptr SetTimeSettingsFactory::ReadResource(std::share return setTimeSettings; } -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.h index 47111e3ec..673cc3692 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; -} // namespace LUS +} // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index 966adbf55..835594663 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -3,12 +3,13 @@ #include "spdlog/spdlog.h" namespace SOH { -std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { +std::shared_ptr +SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { auto setTransitionActorList = std::make_shared(initData); - + ReadCommandId(setTransitionActorList, reader); - + setTransitionActorList->numTransitionActors = reader->ReadUInt32(); setTransitionActorList->transitionActorList.reserve(setTransitionActorList->numTransitionActors); for (uint32_t i = 0; i < setTransitionActorList->numTransitionActors; i++) { diff --git a/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.h b/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.h index c9d460fc2..a4917e464 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetTransitionActorListFactory.h @@ -5,7 +5,7 @@ namespace SOH { class SetTransitionActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, + std::shared_ptr reader) override; }; } // namespace SOH diff --git a/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.cpp index 3a6fec805..60d4dda46 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -4,7 +4,7 @@ namespace SOH { std::shared_ptr SetWindSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { + std::shared_ptr reader) { auto setWind = std::make_shared(initData); ReadCommandId(setWind, reader); diff --git a/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.h b/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.h index bdb1686c7..5bab7e63a 100644 --- a/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/mm/2s2h/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -6,6 +6,6 @@ namespace SOH { class SetWindSettingsFactory : public SceneCommandFactoryBinaryV0 { public: std::shared_ptr ReadResource(std::shared_ptr initData, - std::shared_ptr reader) override; + std::shared_ptr reader) override; }; -}; // namespace LUS +}; // namespace SOH diff --git a/mm/2s2h/resource/type/2shResourceType.h b/mm/2s2h/resource/type/2shResourceType.h index f2124ab8b..4524ba88c 100644 --- a/mm/2s2h/resource/type/2shResourceType.h +++ b/mm/2s2h/resource/type/2shResourceType.h @@ -19,8 +19,8 @@ enum class ResourceType { SOH_SceneCommand = 0x4F52434D, // ORCM TSH_TextMM = 0x4F54584D, // OTXM - - TSH_TexAnim = 0x4F54414E, // OTAN + + TSH_TexAnim = 0x4F54414E, // OTAN TSH_CKeyFrameAnim = 0x4F4B4641, // OKFA TSH_CKeyFrameSkel = 0x4F4B4653 // OKFS }; diff --git a/mm/2s2h/resource/type/Animation.cpp b/mm/2s2h/resource/type/Animation.cpp index d11d05394..0547c79c2 100644 --- a/mm/2s2h/resource/type/Animation.cpp +++ b/mm/2s2h/resource/type/Animation.cpp @@ -6,11 +6,11 @@ AnimationData* Animation::GetPointer() { } size_t Animation::GetPointerSize() { - switch(type) { + switch (type) { case AnimationType::Normal: return sizeof(animationData.animationHeader); case AnimationType::Link: - return sizeof(animationData.linkAnimationHeader); + return sizeof(animationData.linkAnimationHeader); case AnimationType::Curve: return sizeof(animationData.transformUpdateIndex); case AnimationType::Legacy: diff --git a/mm/2s2h/resource/type/Animation.h b/mm/2s2h/resource/type/Animation.h index 87f93970c..e4ca4295f 100644 --- a/mm/2s2h/resource/type/Animation.h +++ b/mm/2s2h/resource/type/Animation.h @@ -4,85 +4,85 @@ #include namespace SOH { - enum class AnimationType { - Normal = 0, - Link = 1, - Curve = 2, - Legacy = 3, - }; - - struct RotationIndex { - uint16_t x, y, z; - - RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) { - } - }; - - typedef struct { - /* 0x0000 */ u16 unk_00; // appears to be flags - /* 0x0002 */ s16 unk_02; - /* 0x0004 */ s16 unk_04; - /* 0x0006 */ s16 unk_06; - /* 0x0008 */ f32 unk_08; - } TransformData; // size = 0xC - - typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk_0C; - /* 0x000E */ s16 unk_0E; - } TransformUpdateIndex; // size = 0x10 - - typedef struct { - /* 0x00 */ s16 frameCount; - } AnimationHeaderCommon; - - // Index into the frame data table. - typedef struct { - /* 0x00 */ u16 x; - /* 0x02 */ u16 y; - /* 0x04 */ u16 z; - } JointIndex; // size = 0x06 - - typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ s16* frameData; // "tbl" - /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" - /* 0x0C */ u16 staticIndexMax; - } AnimationHeader; // size = 0x10 - - typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ void* segment; - } LinkAnimationHeader; // size = 0x8 - - union AnimationData { +enum class AnimationType { + Normal = 0, + Link = 1, + Curve = 2, + Legacy = 3, +}; + +struct RotationIndex { + uint16_t x, y, z; + + RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) { + } +}; + +typedef struct { + /* 0x0000 */ u16 unk_00; // appears to be flags + /* 0x0002 */ s16 unk_02; + /* 0x0004 */ s16 unk_04; + /* 0x0006 */ s16 unk_06; + /* 0x0008 */ f32 unk_08; +} TransformData; // size = 0xC + +typedef struct { + /* 0x0000 */ u8* refIndex; + /* 0x0004 */ TransformData* transformData; + /* 0x0008 */ s16* copyValues; + /* 0x000C */ s16 unk_0C; + /* 0x000E */ s16 unk_0E; +} TransformUpdateIndex; // size = 0x10 + +typedef struct { + /* 0x00 */ s16 frameCount; +} AnimationHeaderCommon; + +// Index into the frame data table. +typedef struct { + /* 0x00 */ u16 x; + /* 0x02 */ u16 y; + /* 0x04 */ u16 z; +} JointIndex; // size = 0x06 + +typedef struct { + /* 0x00 */ AnimationHeaderCommon common; + /* 0x04 */ s16* frameData; // "tbl" + /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" + /* 0x0C */ u16 staticIndexMax; +} AnimationHeader; // size = 0x10 + +typedef struct { + /* 0x00 */ AnimationHeaderCommon common; + /* 0x04 */ void* segment; +} LinkAnimationHeader; // size = 0x8 + +union AnimationData { AnimationHeader animationHeader; LinkAnimationHeader linkAnimationHeader; TransformUpdateIndex transformUpdateIndex; - }; +}; - class Animation : public Ship::Resource { - public: - using Resource::Resource; +class Animation : public Ship::Resource { + public: + using Resource::Resource; - Animation() : Resource(std::shared_ptr()) { - } + Animation() : Resource(std::shared_ptr()) { + } - AnimationData* GetPointer(); - size_t GetPointerSize(); + AnimationData* GetPointer(); + size_t GetPointerSize(); - AnimationType type; - AnimationData animationData; + AnimationType type; + AnimationData animationData; - // NORMAL - std::vector rotationValues; - std::vector rotationIndices; + // NORMAL + std::vector rotationValues; + std::vector rotationIndices; - // CURVE - std::vector refIndexArr; - std::vector transformDataArr; - std::vector copyValuesArr; - }; + // CURVE + std::vector refIndexArr; + std::vector transformDataArr; + std::vector copyValuesArr; +}; }; // namespace SOH diff --git a/mm/2s2h/resource/type/AudioSample.h b/mm/2s2h/resource/type/AudioSample.h index 865f2177a..192b5a6f5 100644 --- a/mm/2s2h/resource/type/AudioSample.h +++ b/mm/2s2h/resource/type/AudioSample.h @@ -6,56 +6,57 @@ #include namespace SOH { - typedef struct { - /* 0x00 */ u32 start; - /* 0x04 */ u32 end; - /* 0x08 */ u32 count; - /* 0x0C */ char unk_0C[0x4]; - /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned - } AdpcmLoop; // size = 0x30 (or 0x10) - - typedef struct { - /* 0x00 */ s32 order; - /* 0x04 */ s32 npredictors; - /* 0x08 */ s16* book; // size 8 * order * npredictors. 8-byte aligned - } AdpcmBook; // s - - typedef struct { - union { - struct { - /* 0x00 */ u32 codec : 4; - /* 0x00 */ u32 medium : 2; - /* 0x00 */ u32 unk_bit26 : 1; - /* 0x00 */ u32 unk_bit25 : 1; // this has been named isRelocated in zret - /* 0x01 */ u32 size : 24; - }; - u32 asU32; +typedef struct { + /* 0x00 */ u32 start; + /* 0x04 */ u32 end; + /* 0x08 */ u32 count; + /* 0x0C */ char unk_0C[0x4]; + /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned +} AdpcmLoop; // size = 0x30 (or 0x10) + +typedef struct { + /* 0x00 */ s32 order; + /* 0x04 */ s32 npredictors; + /* 0x08 */ s16* book; // size 8 * order * npredictors. 8-byte aligned +} AdpcmBook; // s + +typedef struct { + union { + struct { + /* 0x00 */ u32 codec : 4; + /* 0x00 */ u32 medium : 2; + /* 0x00 */ u32 unk_bit26 : 1; + /* 0x00 */ u32 unk_bit25 : 1; // this has been named isRelocated in zret + /* 0x01 */ u32 size : 24; }; + u32 asU32; + }; - /* 0x04 */ u8* sampleAddr; - /* 0x08 */ AdpcmLoop* loop; - /* 0x0C */ AdpcmBook* book; - u32 sampleRateMagicValue; // For wav samples only... - s32 sampleRate; // For wav samples only... - } Sample; // size = 0x10 + /* 0x04 */ u8* sampleAddr; + /* 0x08 */ AdpcmLoop* loop; + /* 0x0C */ AdpcmBook* book; + u32 sampleRateMagicValue; // For wav samples only... + s32 sampleRate; // For wav samples only... +} Sample; // size = 0x10 - class AudioSample : public Ship::Resource { - public: - using Resource::Resource; +class AudioSample : public Ship::Resource { + public: + using Resource::Resource; - AudioSample() : Resource(std::shared_ptr()) {} + AudioSample() : Resource(std::shared_ptr()) { + } - Sample* GetPointer(); - size_t GetPointerSize(); + Sample* GetPointer(); + size_t GetPointerSize(); - Sample sample; - std::vector audioSampleData; + Sample sample; + std::vector audioSampleData; - AdpcmLoop loop; - uint32_t loopStateCount; + AdpcmLoop loop; + uint32_t loopStateCount; - AdpcmBook book; - uint32_t bookDataCount; - std::vector bookData; - }; + AdpcmBook book; + uint32_t bookDataCount; + std::vector bookData; +}; }; // namespace SOH diff --git a/mm/2s2h/resource/type/AudioSequence.h b/mm/2s2h/resource/type/AudioSequence.h index bd376815f..5ff4c9a35 100644 --- a/mm/2s2h/resource/type/AudioSequence.h +++ b/mm/2s2h/resource/type/AudioSequence.h @@ -18,10 +18,11 @@ typedef struct { } Sequence; class AudioSequence : public Ship::Resource { -public: + public: using Resource::Resource; - AudioSequence() : Resource(std::shared_ptr()) {} + AudioSequence() : Resource(std::shared_ptr()) { + } Sequence* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/AudioSoundFont.h b/mm/2s2h/resource/type/AudioSoundFont.h index dd5aab2a0..302c182d2 100644 --- a/mm/2s2h/resource/type/AudioSoundFont.h +++ b/mm/2s2h/resource/type/AudioSoundFont.h @@ -17,7 +17,7 @@ typedef struct { /* 0x00 */ Sample* sample; /* 0x04 */ union { u32 tuningAsU32; - f32 tuning;// frequency scale factor + f32 tuning; // frequency scale factor }; } SoundFontSound; // size = 0x8 @@ -53,10 +53,11 @@ typedef struct { } SoundFont; // size = 0x14 class AudioSoundFont : public Ship::Resource { -public: + public: using Resource::Resource; - AudioSoundFont() : Resource(std::shared_ptr()) {} + AudioSoundFont() : Resource(std::shared_ptr()) { + } SoundFont* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/Background.h b/mm/2s2h/resource/type/Background.h index b5e4c27d6..728e0207e 100644 --- a/mm/2s2h/resource/type/Background.h +++ b/mm/2s2h/resource/type/Background.h @@ -7,7 +7,8 @@ class Background : public Ship::Resource { public: using Resource::Resource; - Background() : Resource(std::shared_ptr()) {} + Background() : Resource(std::shared_ptr()) { + } uint8_t* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/CollisionHeader.h b/mm/2s2h/resource/type/CollisionHeader.h index 6f2a50e25..151437442 100644 --- a/mm/2s2h/resource/type/CollisionHeader.h +++ b/mm/2s2h/resource/type/CollisionHeader.h @@ -23,7 +23,7 @@ typedef struct { // Value ranges from -0x7FFF to 0x7FFF, representing -1.0 to 1.0; 0x8000 is invalid /* 0x0E */ s16 dist; // Plane distance from origin along the normal -} CollisionPoly; // size = 0x10 +} CollisionPoly; // size = 0x10 typedef struct { /* 0x00 */ s16 xMin; @@ -52,7 +52,6 @@ typedef struct { // 0x0800_0000 = wall damage } SurfaceType; - typedef struct { /* 0x00 */ Vec3s minBounds; // minimum coordinates of poly bounding box /* 0x06 */ Vec3s maxBounds; // maximum coordinates of poly bounding box @@ -65,13 +64,14 @@ typedef struct { /* 0x24 */ u16 numWaterBoxes; /* 0x28 */ WaterBox* waterBoxes; size_t cameraDataListLen; // OTRTODO: Added to allow for bounds checking the cameraDataList. -} CollisionHeaderData; // original name: BGDataInfo +} CollisionHeaderData; // original name: BGDataInfo class CollisionHeader : public Ship::Resource { -public: + public: using Resource::Resource; - CollisionHeader() : Resource(std::shared_ptr()) {} + CollisionHeader() : Resource(std::shared_ptr()) { + } CollisionHeaderData* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/Cutscene.cpp b/mm/2s2h/resource/type/Cutscene.cpp index 60440ceb2..fec43126c 100644 --- a/mm/2s2h/resource/type/Cutscene.cpp +++ b/mm/2s2h/resource/type/Cutscene.cpp @@ -7,6 +7,6 @@ uint32_t* Cutscene::GetPointer() { } size_t Cutscene::GetPointerSize() { - return commands.size() * sizeof(uint32_t); + return commands.size() * sizeof(uint32_t); } } // namespace SOH \ No newline at end of file diff --git a/mm/2s2h/resource/type/Cutscene.h b/mm/2s2h/resource/type/Cutscene.h index 664413d2d..e1f786ea5 100644 --- a/mm/2s2h/resource/type/Cutscene.h +++ b/mm/2s2h/resource/type/Cutscene.h @@ -45,7 +45,8 @@ class Cutscene : public Ship::Resource { public: using Resource::Resource; - Cutscene() : Resource(std::shared_ptr()) {} + Cutscene() : Resource(std::shared_ptr()) { + } uint32_t* GetPointer(); size_t GetPointerSize(); @@ -56,7 +57,6 @@ class Cutscene : public Ship::Resource { }; } // namespace SOH - ///////////// // class CutsceneCommand { diff --git a/mm/2s2h/resource/type/KeyFrame.cpp b/mm/2s2h/resource/type/KeyFrame.cpp index 06107fe7f..d5c7d844e 100644 --- a/mm/2s2h/resource/type/KeyFrame.cpp +++ b/mm/2s2h/resource/type/KeyFrame.cpp @@ -2,7 +2,7 @@ namespace SOH { -KeyFrameSkel::~KeyFrameSkel() { +KeyFrameSkel::~KeyFrameSkel() { delete[] skelData.limbsFlex; } @@ -14,7 +14,6 @@ size_t KeyFrameSkel::GetPointerSize() { return sizeof(skelData); } - KeyFrameAnim::~KeyFrameAnim() { delete[] animData.bitFlags; delete[] animData.keyFrames; @@ -30,4 +29,4 @@ size_t KeyFrameAnim::GetPointerSize() { return sizeof(animData); } -} \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/mm/2s2h/resource/type/KeyFrame.h b/mm/2s2h/resource/type/KeyFrame.h index 512f20673..154301a79 100644 --- a/mm/2s2h/resource/type/KeyFrame.h +++ b/mm/2s2h/resource/type/KeyFrame.h @@ -12,9 +12,9 @@ typedef struct Vec3s { } Vec3s; enum class KeyframeSkelType { - Normal, - Flex, - Error, + Normal, + Flex, + Error, }; // Keyframe limb? diff --git a/mm/2s2h/resource/type/Path.h b/mm/2s2h/resource/type/Path.h index 77316af29..016216873 100644 --- a/mm/2s2h/resource/type/Path.h +++ b/mm/2s2h/resource/type/Path.h @@ -12,7 +12,7 @@ typedef struct { /* 0x1 */ u8 additionalPathIndex; /* 0x2 */ s16 customValue; // Path specific to help distinguish different paths /* 0x4 */ Vec3s* points; // Segment Address to the array of points -} PathDataMM; // size = 0x8 +} PathDataMM; // size = 0x8 class PathMM : public Ship::Resource { public: diff --git a/mm/2s2h/resource/type/PlayerAnimation.cpp b/mm/2s2h/resource/type/PlayerAnimation.cpp index c9269061e..26092c621 100644 --- a/mm/2s2h/resource/type/PlayerAnimation.cpp +++ b/mm/2s2h/resource/type/PlayerAnimation.cpp @@ -7,6 +7,6 @@ int16_t* PlayerAnimation::GetPointer() { } size_t PlayerAnimation::GetPointerSize() { - return limbRotData.size() * sizeof(int16_t); + return limbRotData.size() * sizeof(int16_t); } } // namespace SOH \ No newline at end of file diff --git a/mm/2s2h/resource/type/PlayerAnimation.h b/mm/2s2h/resource/type/PlayerAnimation.h index 51032418f..e25aab039 100644 --- a/mm/2s2h/resource/type/PlayerAnimation.h +++ b/mm/2s2h/resource/type/PlayerAnimation.h @@ -10,7 +10,8 @@ class PlayerAnimation : public Ship::Resource { public: using Resource::Resource; - PlayerAnimation() : Resource(std::shared_ptr()) {} + PlayerAnimation() : Resource(std::shared_ptr()) { + } int16_t* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/Scene.cpp b/mm/2s2h/resource/type/Scene.cpp index 15829c40e..9b93e4aea 100644 --- a/mm/2s2h/resource/type/Scene.cpp +++ b/mm/2s2h/resource/type/Scene.cpp @@ -7,6 +7,6 @@ void* Scene::GetPointer() { } size_t Scene::GetPointerSize() { - return 0; + return 0; } } // namespace SOH diff --git a/mm/2s2h/resource/type/Scene.h b/mm/2s2h/resource/type/Scene.h index 5a3ff6ffa..2bd7f4584 100644 --- a/mm/2s2h/resource/type/Scene.h +++ b/mm/2s2h/resource/type/Scene.h @@ -9,10 +9,11 @@ namespace SOH { class Scene : public Ship::Resource { -public: - using Resource::Resource; + public: + using Resource::Resource; - Scene() : Resource(std::shared_ptr()) {} + Scene() : Resource(std::shared_ptr()) { + } void* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/Skeleton.cpp b/mm/2s2h/resource/type/Skeleton.cpp index 9ef28beaf..8eaaf0475 100644 --- a/mm/2s2h/resource/type/Skeleton.cpp +++ b/mm/2s2h/resource/type/Skeleton.cpp @@ -9,7 +9,7 @@ SkeletonData* Skeleton::GetPointer() { } size_t Skeleton::GetPointerSize() { - switch(type) { + switch (type) { case SkeletonType::Normal: return sizeof(skeletonData.skeletonHeader); case SkeletonType::Flex: @@ -23,7 +23,6 @@ size_t Skeleton::GetPointerSize() { std::vector SkeletonPatcher::skeletons; - void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) { SkeletonPatchInfo info; @@ -49,8 +48,7 @@ void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) void SkeletonPatcher::UnregisterSkeleton(SkelAnime* skelAnime) { // TODO: Should probably just use a dictionary here... - for (int i = 0; i < skeletons.size(); i++) - { + for (int i = 0; i < skeletons.size(); i++) { auto skel = skeletons[i]; if (skel.skelAnime == skelAnime) { @@ -59,8 +57,7 @@ void SkeletonPatcher::UnregisterSkeleton(SkelAnime* skelAnime) { } } } -void SkeletonPatcher::ClearSkeletons() -{ +void SkeletonPatcher::ClearSkeletons() { skeletons.clear(); } @@ -68,14 +65,16 @@ void SkeletonPatcher::UpdateSkeletons() { bool isHD = CVarGetInteger("gAltAssets", 0); for (auto skel : skeletons) { Skeleton* newSkel = - (Skeleton*)Ship::Context::GetInstance()->GetResourceManager() + (Skeleton*)Ship::Context::GetInstance() + ->GetResourceManager() ->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true) .get(); if (newSkel != nullptr) { skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment; uintptr_t skelPtr = (uintptr_t)newSkel->GetPointer(); - memcpy(&skel.skelAnime->skeleton, &skelPtr, sizeof(uintptr_t)); // Dumb thing that needs to be done because cast is not cooperating + memcpy(&skel.skelAnime->skeleton, &skelPtr, + sizeof(uintptr_t)); // Dumb thing that needs to be done because cast is not cooperating } } } diff --git a/mm/2s2h/resource/type/Skeleton.h b/mm/2s2h/resource/type/Skeleton.h index c0bdef5d1..d2b0516dd 100644 --- a/mm/2s2h/resource/type/Skeleton.h +++ b/mm/2s2h/resource/type/Skeleton.h @@ -24,7 +24,7 @@ enum class SkeletonType { typedef struct { /* 0x00 */ void** segment; /* 0x04 */ uint8_t limbCount; - uint8_t skeletonType; + uint8_t skeletonType; } SkeletonHeader; // size = 0x8 // Model has limbs with flexible meshes @@ -54,14 +54,15 @@ class Skeleton : public Ship::Resource { public: using Resource::Resource; - Skeleton() : Resource(std::shared_ptr()) {} + Skeleton() : Resource(std::shared_ptr()) { + } SkeletonData* GetPointer(); size_t GetPointerSize(); SkeletonType type; SkeletonData skeletonData; - + LimbType limbType; int limbCount; int dListCount; @@ -74,8 +75,7 @@ class Skeleton : public Ship::Resource { }; // TODO: CLEAN THIS UP LATER -struct SkeletonPatchInfo -{ +struct SkeletonPatchInfo { SkelAnime* skelAnime; std::string vanillaSkeletonPath; }; @@ -90,5 +90,4 @@ class SkeletonPatcher { static std::vector skeletons; }; - } // namespace SOH diff --git a/mm/2s2h/resource/type/SkeletonLimb.cpp b/mm/2s2h/resource/type/SkeletonLimb.cpp index eb599e641..ddc2e4d25 100644 --- a/mm/2s2h/resource/type/SkeletonLimb.cpp +++ b/mm/2s2h/resource/type/SkeletonLimb.cpp @@ -6,7 +6,7 @@ SkeletonLimbData* SkeletonLimb::GetPointer() { } size_t SkeletonLimb::GetPointerSize() { - switch(limbType) { + switch (limbType) { case LimbType::Standard: return sizeof(limbData.standardLimb); case LimbType::LOD: diff --git a/mm/2s2h/resource/type/SkeletonLimb.h b/mm/2s2h/resource/type/SkeletonLimb.h index 848c7b87f..65addf8af 100644 --- a/mm/2s2h/resource/type/SkeletonLimb.h +++ b/mm/2s2h/resource/type/SkeletonLimb.h @@ -14,12 +14,11 @@ enum class LimbType { Legacy, }; -enum class ZLimbSkinType -{ - SkinType_0, // Segment = 0 - SkinType_4 = 4, // Segment = segmented address // Struct_800A5E28 - SkinType_5 = 5, // Segment = 0 - SkinType_DList = 11, // Segment = DList address +enum class ZLimbSkinType { + SkinType_0, // Segment = 0 + SkinType_4 = 4, // Segment = segmented address // Struct_800A5E28 + SkinType_5 = 5, // Segment = 0 + SkinType_DList = 11, // Segment = DList address }; /** @@ -60,7 +59,7 @@ typedef struct { /* 0x06 */ u8 child; /* 0x07 */ u8 sibling; /* 0x08 */ Gfx* dLists[2]; // Near and far -} LodLimb; // size = 0x10 +} LodLimb; // size = 0x10 typedef struct { /* 0x00 */ Vec3s jointPos; // Root is position in model space, children are relative to parent @@ -80,8 +79,9 @@ typedef struct { /* 0x06 */ u8 child; /* 0x07 */ u8 sibling; /* 0x08 */ s32 segmentType; // Type of data contained in segment - /* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData* if segmentType is SKIN_LIMB_TYPE_ANIMATED, NULL otherwise -} SkinLimb; // size = 0x10 + /* 0x0C */ void* segment; // Gfx* if segmentType is SKIN_LIMB_TYPE_NORMAL, SkinAnimatedLimbData* if segmentType is + // SKIN_LIMB_TYPE_ANIMATED, NULL otherwise +} SkinLimb; // size = 0x10 typedef struct { /* 0x00 */ u16 totalVtxCount; // total vertex count for all modif entries @@ -91,18 +91,18 @@ typedef struct { } SkinAnimatedLimbData; // size = 0xC union SkeletonLimbData { - LodLimb lodLimb; - StandardLimb standardLimb; - SkelCurveLimb skelCurveLimb; - SkinLimb skinLimb; + LodLimb lodLimb; + StandardLimb standardLimb; + SkelCurveLimb skelCurveLimb; + SkinLimb skinLimb; }; class SkeletonLimb : public Ship::Resource { -public: - using Resource::Resource; + public: + using Resource::Resource; SkeletonLimb() : Resource(std::shared_ptr()) { - } + } SkeletonLimbData* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/TextMM.cpp b/mm/2s2h/resource/type/TextMM.cpp index 18f910044..1d10ecbb0 100644 --- a/mm/2s2h/resource/type/TextMM.cpp +++ b/mm/2s2h/resource/type/TextMM.cpp @@ -6,6 +6,6 @@ MessageEntryMM* TextMM::GetPointer() { } size_t TextMM::GetPointerSize() { - return messages.size() * sizeof(MessageEntryMM); + return messages.size() * sizeof(MessageEntryMM); } } // namespace SOH diff --git a/mm/2s2h/resource/type/TextMM.h b/mm/2s2h/resource/type/TextMM.h index cd76488e3..82f5f9ba0 100644 --- a/mm/2s2h/resource/type/TextMM.h +++ b/mm/2s2h/resource/type/TextMM.h @@ -23,11 +23,11 @@ class MessageEntryMM { }; class TextMM : public Ship::Resource { -public: - using Resource::Resource; + public: + using Resource::Resource; TextMM() : Resource(std::shared_ptr()) { - } + } MessageEntryMM* GetPointer(); size_t GetPointerSize(); diff --git a/mm/2s2h/resource/type/TextureAnimation.cpp b/mm/2s2h/resource/type/TextureAnimation.cpp index 9dc07d1be..69aab1007 100644 --- a/mm/2s2h/resource/type/TextureAnimation.cpp +++ b/mm/2s2h/resource/type/TextureAnimation.cpp @@ -14,15 +14,15 @@ TextureAnimation::~TextureAnimation() { case TextureAnimationParamsType::ColorChange: case TextureAnimationParamsType::ColorChangeLERP: case TextureAnimationParamsType::ColorChangeLagrange: - delete[] ((AnimatedMatColorParams*)a.params)->keyFrames; - delete[] ((AnimatedMatColorParams*)a.params)->primColors; - delete[] ((AnimatedMatColorParams*)a.params)->envColors; + delete[]((AnimatedMatColorParams*)a.params)->keyFrames; + delete[]((AnimatedMatColorParams*)a.params)->primColors; + delete[]((AnimatedMatColorParams*)a.params)->envColors; free(a.params); break; case TextureAnimationParamsType::TextureCycle: // BENTODO free the textures - delete[] ((AnimatedMatTexCycleParams*)a.params)->textureIndexList; - delete[] ((AnimatedMatTexCycleParams*)a.params)->textureList; + delete[]((AnimatedMatTexCycleParams*)a.params)->textureIndexList; + delete[]((AnimatedMatTexCycleParams*)a.params)->textureList; free(a.params); break; } diff --git a/mm/2s2h/resource/type/scenecommand/EndMarker.cpp b/mm/2s2h/resource/type/scenecommand/EndMarker.cpp index ba8898187..9b9fc0960 100644 --- a/mm/2s2h/resource/type/scenecommand/EndMarker.cpp +++ b/mm/2s2h/resource/type/scenecommand/EndMarker.cpp @@ -6,6 +6,6 @@ Marker* EndMarker::GetPointer() { } size_t EndMarker::GetPointerSize() { - return sizeof(Marker); + return sizeof(Marker); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/RomFile.h b/mm/2s2h/resource/type/scenecommand/RomFile.h index 19a5545e7..5262ce649 100644 --- a/mm/2s2h/resource/type/scenecommand/RomFile.h +++ b/mm/2s2h/resource/type/scenecommand/RomFile.h @@ -3,9 +3,9 @@ #include namespace SOH { - typedef struct { - /* 0x00 */ uintptr_t vromStart; - /* 0x04 */ uintptr_t vromEnd; - char* fileName; - } RomFile; // size = 0x8 -} \ No newline at end of file +typedef struct { + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; + char* fileName; +} RomFile; // size = 0x8 +} // namespace SOH \ No newline at end of file diff --git a/mm/2s2h/resource/type/scenecommand/SceneCommand.h b/mm/2s2h/resource/type/scenecommand/SceneCommand.h index cef85eed8..5e8c2d5cd 100644 --- a/mm/2s2h/resource/type/scenecommand/SceneCommand.h +++ b/mm/2s2h/resource/type/scenecommand/SceneCommand.h @@ -49,9 +49,10 @@ enum class SceneCommandID : uint8_t { }; class ISceneCommand : public Ship::IResource { -public: + public: using IResource::IResource; - ISceneCommand() : IResource(std::shared_ptr()) {} + ISceneCommand() : IResource(std::shared_ptr()) { + } SceneCommandID cmdId; }; diff --git a/mm/2s2h/resource/type/scenecommand/SetActorCutsceneList.h b/mm/2s2h/resource/type/scenecommand/SetActorCutsceneList.h index f9989bd53..4fe497a68 100644 --- a/mm/2s2h/resource/type/scenecommand/SetActorCutsceneList.h +++ b/mm/2s2h/resource/type/scenecommand/SetActorCutsceneList.h @@ -19,12 +19,12 @@ typedef struct CutsceneEntry { class SetActorCutsceneList : public SceneCommand { public: - using SceneCommand::SceneCommand; + using SceneCommand::SceneCommand; - CutsceneEntry* GetPointer(); - size_t GetPointerSize(); + CutsceneEntry* GetPointer(); + size_t GetPointerSize(); - std::vector entries; + std::vector entries; }; -} \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/mm/2s2h/resource/type/scenecommand/SetActorList.cpp b/mm/2s2h/resource/type/scenecommand/SetActorList.cpp index 5bb62e764..3f33afb72 100644 --- a/mm/2s2h/resource/type/scenecommand/SetActorList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetActorList.cpp @@ -6,6 +6,6 @@ ActorEntry* SetActorList::GetPointer() { } size_t SetActorList::GetPointerSize() { - return actorList.size() * sizeof(ActorEntry); + return actorList.size() * sizeof(ActorEntry); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetActorList.h b/mm/2s2h/resource/type/scenecommand/SetActorList.h index 5da281b7e..f01f5e844 100644 --- a/mm/2s2h/resource/type/scenecommand/SetActorList.h +++ b/mm/2s2h/resource/type/scenecommand/SetActorList.h @@ -8,10 +8,10 @@ namespace SOH { typedef struct { - /* 0x00 */ s16 id; + /* 0x00 */ s16 id; /* 0x02 */ Vec3s pos; /* 0x08 */ Vec3s rot; - /* 0x0E */ s16 params; + /* 0x0E */ s16 params; } ActorEntry; // size = 0x10 class SetActorList : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetAlternateHeaders.h b/mm/2s2h/resource/type/scenecommand/SetAlternateHeaders.h index 0e0b78747..67f2c5d1d 100644 --- a/mm/2s2h/resource/type/scenecommand/SetAlternateHeaders.h +++ b/mm/2s2h/resource/type/scenecommand/SetAlternateHeaders.h @@ -8,7 +8,6 @@ #include "RomFile.h" #include - namespace SOH { class SetAlternateHeaders : public SceneCommand { public: diff --git a/mm/2s2h/resource/type/scenecommand/SetCameraSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetCameraSettings.cpp index 5c41f1c8f..287a291ea 100644 --- a/mm/2s2h/resource/type/scenecommand/SetCameraSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetCameraSettings.cpp @@ -6,6 +6,6 @@ CameraSettings* SetCameraSettings::GetPointer() { } size_t SetCameraSettings::GetPointerSize() { - return sizeof(CameraSettings); + return sizeof(CameraSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetCameraSettings.h b/mm/2s2h/resource/type/scenecommand/SetCameraSettings.h index 6bce30a9b..ad674d306 100644 --- a/mm/2s2h/resource/type/scenecommand/SetCameraSettings.h +++ b/mm/2s2h/resource/type/scenecommand/SetCameraSettings.h @@ -9,8 +9,8 @@ namespace SOH { typedef struct { - int8_t cameraMovement; - int32_t worldMapArea; + int8_t cameraMovement; + int32_t worldMapArea; } CameraSettings; class SetCameraSettings : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetCollisionHeader.cpp b/mm/2s2h/resource/type/scenecommand/SetCollisionHeader.cpp index a1c22b9ea..a50fecee6 100644 --- a/mm/2s2h/resource/type/scenecommand/SetCollisionHeader.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetCollisionHeader.cpp @@ -12,6 +12,6 @@ size_t SetCollisionHeader::GetPointerSize() { if (collisionHeader == nullptr) { return 0; } - return collisionHeader->GetPointerSize(); + return collisionHeader->GetPointerSize(); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetCsCamera.h b/mm/2s2h/resource/type/scenecommand/SetCsCamera.h index 406b7fa93..66166c3b7 100644 --- a/mm/2s2h/resource/type/scenecommand/SetCsCamera.h +++ b/mm/2s2h/resource/type/scenecommand/SetCsCamera.h @@ -17,7 +17,7 @@ typedef struct { /* 0x0 */ s16 setting; // camera setting described by CameraSettingType enum /* 0x2 */ s16 count; /* 0x4 */ z64Vec3s* actorCsCamFuncData; // s16 data grouped in threes -} ActorCsCamInfoData; // size = 0x8 +} ActorCsCamInfoData; // size = 0x8 class SetCsCamera : public SceneCommand { public: diff --git a/mm/2s2h/resource/type/scenecommand/SetEchoSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetEchoSettings.cpp index d4b2b1e15..579f93aea 100644 --- a/mm/2s2h/resource/type/scenecommand/SetEchoSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetEchoSettings.cpp @@ -6,6 +6,6 @@ EchoSettings* SetEchoSettings::GetPointer() { } size_t SetEchoSettings::GetPointerSize() { - return sizeof(EchoSettings); + return sizeof(EchoSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetEchoSettings.h b/mm/2s2h/resource/type/scenecommand/SetEchoSettings.h index 12c2036c9..2d17a879e 100644 --- a/mm/2s2h/resource/type/scenecommand/SetEchoSettings.h +++ b/mm/2s2h/resource/type/scenecommand/SetEchoSettings.h @@ -9,7 +9,7 @@ namespace SOH { typedef struct { - int8_t echo; + int8_t echo; } EchoSettings; class SetEchoSettings : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetEntranceList.cpp b/mm/2s2h/resource/type/scenecommand/SetEntranceList.cpp index e82711da2..d23e39a03 100644 --- a/mm/2s2h/resource/type/scenecommand/SetEntranceList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetEntranceList.cpp @@ -6,6 +6,6 @@ EntranceEntry* SetEntranceList::GetPointer() { } size_t SetEntranceList::GetPointerSize() { - return entrances.size() * sizeof(EntranceEntry); + return entrances.size() * sizeof(EntranceEntry); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetExitList.cpp b/mm/2s2h/resource/type/scenecommand/SetExitList.cpp index 3de483b0e..6ed71368c 100644 --- a/mm/2s2h/resource/type/scenecommand/SetExitList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetExitList.cpp @@ -6,6 +6,6 @@ uint16_t* SetExitList::GetPointer() { } size_t SetExitList::GetPointerSize() { - return exits.size() * sizeof(int16_t); + return exits.size() * sizeof(int16_t); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetLightList.cpp b/mm/2s2h/resource/type/scenecommand/SetLightList.cpp index 459e957cb..5e12624ba 100644 --- a/mm/2s2h/resource/type/scenecommand/SetLightList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetLightList.cpp @@ -6,6 +6,6 @@ LightInfo* SetLightList::GetPointer() { } size_t SetLightList::GetPointerSize() { - return lightList.size() * sizeof(LightInfo); + return lightList.size() * sizeof(LightInfo); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetLightingSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetLightingSettings.cpp index 042062512..b660d5e1a 100644 --- a/mm/2s2h/resource/type/scenecommand/SetLightingSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetLightingSettings.cpp @@ -6,6 +6,6 @@ EnvLightSettings* SetLightingSettings::GetPointer() { } size_t SetLightingSettings::GetPointerSize() { - return settings.size() * sizeof(EnvLightSettings); + return settings.size() * sizeof(EnvLightSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetMesh.cpp b/mm/2s2h/resource/type/scenecommand/SetMesh.cpp index 1e2cd396c..eb286f7e0 100644 --- a/mm/2s2h/resource/type/scenecommand/SetMesh.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetMesh.cpp @@ -6,6 +6,6 @@ MeshHeader* SetMesh::GetPointer() { } size_t SetMesh::GetPointerSize() { - return sizeof(MeshHeader); + return sizeof(MeshHeader); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetMesh.h b/mm/2s2h/resource/type/scenecommand/SetMesh.h index 37684b7e1..da9067513 100644 --- a/mm/2s2h/resource/type/scenecommand/SetMesh.h +++ b/mm/2s2h/resource/type/scenecommand/SetMesh.h @@ -9,48 +9,48 @@ namespace SOH { typedef struct { - /* 0x00 */ u8 type; + /* 0x00 */ u8 type; } PolygonBase; typedef struct { /* 0x00 */ PolygonBase base; - /* 0x01 */ u8 num; // number of dlist entries + /* 0x01 */ u8 num; // number of dlist entries /* 0x04 */ void* start; /* 0x08 */ void* end; } PolygonType0; // size = 0xC typedef struct { - /* 0x00 */ u16 unk_00; - /* 0x02 */ u8 id; + /* 0x00 */ u16 unk_00; + /* 0x02 */ u8 id; /* 0x04 */ void* source; - /* 0x08 */ u32 unk_0C; - /* 0x0C */ u32 tlut; - /* 0x10 */ u16 width; - /* 0x12 */ u16 height; - /* 0x14 */ u8 fmt; - /* 0x15 */ u8 siz; - /* 0x16 */ u16 mode0; - /* 0x18 */ u16 tlutCount; + /* 0x08 */ u32 unk_0C; + /* 0x0C */ u32 tlut; + /* 0x10 */ u16 width; + /* 0x12 */ u16 height; + /* 0x14 */ u8 fmt; + /* 0x15 */ u8 siz; + /* 0x16 */ u16 mode0; + /* 0x18 */ u16 tlutCount; } BgImage; // size = 0x1C typedef struct { /* 0x00 */ PolygonBase base; - /* 0x01 */ u8 format; // 1 = single, 2 = multi - /* 0x04 */ Gfx* dlist; + /* 0x01 */ u8 format; // 1 = single, 2 = multi + /* 0x04 */ Gfx* dlist; union { struct { /* 0x08 */ void* source; - /* 0x0C */ u32 unk_0C; + /* 0x0C */ u32 unk_0C; /* 0x10 */ void* tlut; - /* 0x14 */ u16 width; - /* 0x16 */ u16 height; - /* 0x18 */ u8 fmt; - /* 0x19 */ u8 siz; - /* 0x1A */ u16 mode0; - /* 0x1C */ u16 tlutCount; + /* 0x14 */ u16 width; + /* 0x16 */ u16 height; + /* 0x18 */ u8 fmt; + /* 0x19 */ u8 siz; + /* 0x1A */ u16 mode0; + /* 0x1C */ u16 tlutCount; } single; struct { - /* 0x08 */ u8 count; + /* 0x08 */ u8 count; /* 0x0C */ BgImage* list; } multi; }; @@ -58,13 +58,13 @@ typedef struct { typedef struct { /* 0x00 */ PolygonBase base; - /* 0x01 */ u8 num; // number of dlist entries + /* 0x01 */ u8 num; // number of dlist entries /* 0x04 */ void* start; /* 0x08 */ void* end; } PolygonType2; // size = 0xC typedef union { - PolygonBase base; + PolygonBase base; PolygonType0 polygon0; PolygonType1 polygon1; PolygonType2 polygon2; @@ -72,9 +72,9 @@ typedef union { typedef struct { /* 0x00 */ Vec3s pos; - /* 0x06 */ s16 unk_06; - /* 0x08 */ Gfx* opa; - /* 0x0C */ Gfx* xlu; + /* 0x06 */ s16 unk_06; + /* 0x08 */ Gfx* opa; + /* 0x0C */ Gfx* xlu; } PolygonDlist2; // size = 0x8 typedef struct { diff --git a/mm/2s2h/resource/type/scenecommand/SetMinimapChests.h b/mm/2s2h/resource/type/scenecommand/SetMinimapChests.h index e99ef2634..81fdd8ce3 100644 --- a/mm/2s2h/resource/type/scenecommand/SetMinimapChests.h +++ b/mm/2s2h/resource/type/scenecommand/SetMinimapChests.h @@ -13,11 +13,11 @@ typedef struct { class SetMinimapChests : public SceneCommand { public: - using SceneCommand::SceneCommand; + using SceneCommand::SceneCommand; - MinimapChestData* GetPointer(); - size_t GetPointerSize(); - std::vector chests; + MinimapChestData* GetPointer(); + size_t GetPointerSize(); + std::vector chests; }; -} +} // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetMinimapList.h b/mm/2s2h/resource/type/scenecommand/SetMinimapList.h index 48eaa8902..881c361f4 100644 --- a/mm/2s2h/resource/type/scenecommand/SetMinimapList.h +++ b/mm/2s2h/resource/type/scenecommand/SetMinimapList.h @@ -11,14 +11,13 @@ typedef struct { /* 0x04 */ s16 unk4; /* 0x06 */ s16 unk6; /* 0x08 */ u16 unk8; // flags; 1 = mirror x? 2 = mirror y? -} MinimapEntryData; // size = 0xA +} MinimapEntryData; // size = 0xA typedef struct { /* 0x00 */ MinimapEntryData* entry; /* 0x04 */ s16 scale; } MinimapListData; // size = 0x8 - class SetMinimapList : public SceneCommand { public: using SceneCommand::SceneCommand; @@ -29,4 +28,4 @@ class SetMinimapList : public SceneCommand { std::vector entries; }; -} +} // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetObjectList.cpp b/mm/2s2h/resource/type/scenecommand/SetObjectList.cpp index 04aeb27d0..16399b38f 100644 --- a/mm/2s2h/resource/type/scenecommand/SetObjectList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetObjectList.cpp @@ -6,6 +6,6 @@ int16_t* SetObjectList::GetPointer() { } size_t SetObjectList::GetPointerSize() { - return objects.size() * sizeof(int16_t); + return objects.size() * sizeof(int16_t); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetRoomList.cpp b/mm/2s2h/resource/type/scenecommand/SetRoomList.cpp index c81d3645e..e7b8daf0b 100644 --- a/mm/2s2h/resource/type/scenecommand/SetRoomList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetRoomList.cpp @@ -6,6 +6,6 @@ RomFile* SetRoomList::GetPointer() { } size_t SetRoomList::GetPointerSize() { - return rooms.size() * sizeof(RomFile); + return rooms.size() * sizeof(RomFile); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.cpp b/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.cpp index 122d93d77..3066ead43 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.cpp @@ -6,6 +6,6 @@ SkyboxModifier* SetSkyboxModifier::GetPointer() { } size_t SetSkyboxModifier::GetPointerSize() { - return sizeof(SkyboxModifier); + return sizeof(SkyboxModifier); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.h b/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.h index 6cb1ab19b..7ed86ddc5 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.h +++ b/mm/2s2h/resource/type/scenecommand/SetSkyboxModifier.h @@ -9,8 +9,8 @@ namespace SOH { typedef struct { - uint8_t skyboxDisabled; - uint8_t sunMoonDisabled; + uint8_t skyboxDisabled; + uint8_t sunMoonDisabled; } SkyboxModifier; class SetSkyboxModifier : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.cpp index 527f0462c..031e15b8c 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.cpp @@ -6,6 +6,6 @@ SkyboxSettings* SetSkyboxSettings::GetPointer() { } size_t SetSkyboxSettings::GetPointerSize() { - return sizeof(SetSkyboxSettings); + return sizeof(SetSkyboxSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.h b/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.h index 30fef6b91..d3d7b5a4c 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.h +++ b/mm/2s2h/resource/type/scenecommand/SetSkyboxSettings.h @@ -9,10 +9,10 @@ namespace SOH { typedef struct { - uint8_t unk; - uint8_t skyboxId; - uint8_t weather; - uint8_t indoors; + uint8_t unk; + uint8_t skyboxId; + uint8_t weather; + uint8_t indoors; } SkyboxSettings; class SetSkyboxSettings : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetSoundSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetSoundSettings.cpp index c136d34db..2df7e325c 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSoundSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetSoundSettings.cpp @@ -6,6 +6,6 @@ SoundSettings* SetSoundSettings::GetPointer() { } size_t SetSoundSettings::GetPointerSize() { - return sizeof(SoundSettings); + return sizeof(SoundSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetSoundSettings.h b/mm/2s2h/resource/type/scenecommand/SetSoundSettings.h index 237261f6a..57e3beaae 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSoundSettings.h +++ b/mm/2s2h/resource/type/scenecommand/SetSoundSettings.h @@ -9,9 +9,9 @@ namespace SOH { typedef struct { - uint8_t seqId; - uint8_t natureAmbienceId; - uint8_t reverb; + uint8_t seqId; + uint8_t natureAmbienceId; + uint8_t reverb; } SoundSettings; class SetSoundSettings : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.cpp b/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.cpp index 304ab514c..dae2f1385 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.cpp @@ -6,6 +6,6 @@ SpecialObjects* SetSpecialObjects::GetPointer() { } size_t SetSpecialObjects::GetPointerSize() { - return sizeof(SpecialObjects); + return sizeof(SpecialObjects); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.h b/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.h index f0f643657..e225af809 100644 --- a/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.h +++ b/mm/2s2h/resource/type/scenecommand/SetSpecialObjects.h @@ -7,8 +7,8 @@ namespace SOH { typedef struct { - int8_t elfMessage; - int16_t globalObject; + int8_t elfMessage; + int16_t globalObject; } SpecialObjects; class SetSpecialObjects : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetStartPositionList.cpp b/mm/2s2h/resource/type/scenecommand/SetStartPositionList.cpp index 5fa17b2a0..2b8ab450b 100644 --- a/mm/2s2h/resource/type/scenecommand/SetStartPositionList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetStartPositionList.cpp @@ -6,6 +6,6 @@ ActorEntry* SetStartPositionList::GetPointer() { } size_t SetStartPositionList::GetPointerSize() { - return startPositions.size() * sizeof(ActorEntry); + return startPositions.size() * sizeof(ActorEntry); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetTimeSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetTimeSettings.cpp index c9380a0a0..8ff2525f3 100644 --- a/mm/2s2h/resource/type/scenecommand/SetTimeSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetTimeSettings.cpp @@ -6,6 +6,6 @@ TimeSettings* SetTimeSettings::GetPointer() { } size_t SetTimeSettings::GetPointerSize() { - return sizeof(TimeSettings); + return sizeof(TimeSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetTimeSettings.h b/mm/2s2h/resource/type/scenecommand/SetTimeSettings.h index 44146fe3d..ca95841e7 100644 --- a/mm/2s2h/resource/type/scenecommand/SetTimeSettings.h +++ b/mm/2s2h/resource/type/scenecommand/SetTimeSettings.h @@ -9,9 +9,9 @@ namespace SOH { typedef struct { - uint8_t hour; - uint8_t minute; - uint8_t timeIncrement; + uint8_t hour; + uint8_t minute; + uint8_t timeIncrement; } TimeSettings; class SetTimeSettings : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.cpp b/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.cpp index c944e99f2..961778e11 100644 --- a/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.cpp @@ -6,6 +6,6 @@ TransitionActorEntry* SetTransitionActorList::GetPointer() { } size_t SetTransitionActorList::GetPointerSize() { - return transitionActorList.size() * sizeof(TransitionActorEntry); + return transitionActorList.size() * sizeof(TransitionActorEntry); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.h b/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.h index ab142e5e8..3c37c676f 100644 --- a/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.h +++ b/mm/2s2h/resource/type/scenecommand/SetTransitionActorList.h @@ -9,13 +9,13 @@ namespace SOH { typedef struct { struct { - s8 room; // Room to switch to - s8 effects; // How the camera reacts during the transition + s8 room; // Room to switch to + s8 effects; // How the camera reacts during the transition } /* 0x00 */ sides[2]; // 0 = front, 1 = back - /* 0x04 */ s16 id; + /* 0x04 */ s16 id; /* 0x06 */ Vec3s pos; - /* 0x0C */ s16 rotY; - /* 0x0E */ s16 params; + /* 0x0C */ s16 rotY; + /* 0x0E */ s16 params; } TransitionActorEntry; // size = 0x10 class SetTransitionActorList : public SceneCommand { diff --git a/mm/2s2h/resource/type/scenecommand/SetWindSettings.cpp b/mm/2s2h/resource/type/scenecommand/SetWindSettings.cpp index 64bc8ecc8..e1ffb7004 100644 --- a/mm/2s2h/resource/type/scenecommand/SetWindSettings.cpp +++ b/mm/2s2h/resource/type/scenecommand/SetWindSettings.cpp @@ -6,6 +6,6 @@ WindSettings* SetWindSettings::GetPointer() { } size_t SetWindSettings::GetPointerSize() { - return sizeof(WindSettings); + return sizeof(WindSettings); } } // namespace SOH diff --git a/mm/2s2h/resource/type/scenecommand/SetWindSettings.h b/mm/2s2h/resource/type/scenecommand/SetWindSettings.h index 389f3f0d8..755ad0d0d 100644 --- a/mm/2s2h/resource/type/scenecommand/SetWindSettings.h +++ b/mm/2s2h/resource/type/scenecommand/SetWindSettings.h @@ -9,10 +9,10 @@ namespace SOH { typedef struct { - int8_t windWest; - int8_t windVertical; - int8_t windSouth; - uint8_t windSpeed; + int8_t windWest; + int8_t windVertical; + int8_t windSouth; + uint8_t windSpeed; } WindSettings; class SetWindSettings : public SceneCommand { diff --git a/mm/2s2h/z_message_OTR.cpp b/mm/2s2h/z_message_OTR.cpp index 5dfb85c4b..441e7ebe2 100644 --- a/mm/2s2h/z_message_OTR.cpp +++ b/mm/2s2h/z_message_OTR.cpp @@ -6,15 +6,16 @@ #include "2s2h/resource/type/TextMM.h" #include -//extern "C" MessageTableEntry* sNesMessageEntryTablePtr; -//extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; +// extern "C" MessageTableEntry* sNesMessageEntryTablePtr; +// extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { - auto file = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast( + Ship::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr; - + // Allocate room for an additional message // OTRTODO: Should not be malloc'ing here. It's fine for now since we check elsewhere that the message table is // already null. @@ -43,8 +44,8 @@ MessageTableEntry* OTRMessage_LoadTable(const char* filePath, bool isNES) { table[i].msgSize = file->messages[i].msg.size() + 11; - //if (isNES && file->messages[i].id == 0xFFFC) - //_message_0xFFFC_nes = (char*)file->messages[i].msg.c_str(); + // if (isNES && file->messages[i].id == 0xFFFC) + //_message_0xFFFC_nes = (char*)file->messages[i].msg.c_str(); } return table; @@ -54,24 +55,23 @@ extern "C" void OTRMessage_Init(PlayState* play) { // OTRTODO: Added a lot of null checks here so that we don't malloc the table multiple times causing a memory leak. // We really ought to fix the implementation such that we aren't malloc'ing new tables. // Once we fix the implementation, remove these NULL checks. - //if (play->msgCtx.messageEntryTableNes == NULL) { - play->msgCtx.messageEntryTableNes = OTRMessage_LoadTable("text/message_data_static/message_data_static", true); - play->msgCtx.messageEntryTable = play->msgCtx.messageEntryTableNes; + // if (play->msgCtx.messageEntryTableNes == NULL) { + play->msgCtx.messageEntryTableNes = OTRMessage_LoadTable("text/message_data_static/message_data_static", true); + play->msgCtx.messageEntryTable = play->msgCtx.messageEntryTableNes; //} - //if (play->msgCtx.messageTableStaff == NULL) { - auto file2 = - std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( - "text/staff_message_data_static/staff_message_data_static")); - // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. - play->msgCtx.messageTableStaff = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); + // if (play->msgCtx.messageTableStaff == NULL) { + auto file2 = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource( + "text/staff_message_data_static/staff_message_data_static")); + // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. + play->msgCtx.messageTableStaff = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); - for (size_t i = 0; i < file2->messages.size(); i++) { - play->msgCtx.messageTableStaff[i].textId = file2->messages[i].id; - play->msgCtx.messageTableStaff[i].typePos = - (file2->messages[i].textboxType << 4) | file2->messages[i].textboxYPos; - play->msgCtx.messageTableStaff[i].segment = file2->messages[i].msg.c_str(); - play->msgCtx.messageTableStaff[i].msgSize = file2->messages[i].msg.size(); - } + for (size_t i = 0; i < file2->messages.size(); i++) { + play->msgCtx.messageTableStaff[i].textId = file2->messages[i].id; + play->msgCtx.messageTableStaff[i].typePos = + (file2->messages[i].textboxType << 4) | file2->messages[i].textboxYPos; + play->msgCtx.messageTableStaff[i].segment = file2->messages[i].msg.c_str(); + play->msgCtx.messageTableStaff[i].msgSize = file2->messages[i].msg.size(); + } //} } diff --git a/mm/2s2h/z_play_2SH.cpp b/mm/2s2h/z_play_2SH.cpp index 6ab49eec0..3432ab9e3 100644 --- a/mm/2s2h/z_play_2SH.cpp +++ b/mm/2s2h/z_play_2SH.cpp @@ -43,7 +43,8 @@ extern "C" void OTRPlay_SpawnScene(PlayState* play, s32 sceneId, s32 spawn) { play->loadedScene = scene; play->sceneId = sceneId; play->sceneConfig = scene->drawConfig; - std::string scenePath = StringHelper::Sprintf("scenes/nonmq/%s/%s", scene->segment.fileName, scene->segment.fileName); + std::string scenePath = + StringHelper::Sprintf("scenes/nonmq/%s/%s", scene->segment.fileName, scene->segment.fileName); play->sceneSegment = OTRPlay_LoadFile(play, scenePath.c_str()); scene->unk_D = 0; gSegments[2] = (uintptr_t)play->sceneSegment; diff --git a/mm/2s2h/z_scene_2SH.cpp b/mm/2s2h/z_scene_2SH.cpp index acc7023fa..61ee7ed0d 100644 --- a/mm/2s2h/z_scene_2SH.cpp +++ b/mm/2s2h/z_scene_2SH.cpp @@ -41,7 +41,6 @@ s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); - void Scene_CommandSpawnList(PlayState* play, SOH::ISceneCommand* cmd) { SOH::SetStartPositionList* list = (SOH::SetStartPositionList*)cmd; ActorEntry* entries = (ActorEntry*)(list->GetRawPointer()); @@ -118,14 +117,16 @@ void Scene_CommandSpecialFiles(PlayState* play, SOH::ISceneCommand* cmd) { // }; if (specialObjList->specialObjects.globalObject != 0) { - play->objectCtx.subKeepSlot = Object_SpawnPersistent(&play->objectCtx, specialObjList->specialObjects.globalObject); + play->objectCtx.subKeepSlot = + Object_SpawnPersistent(&play->objectCtx, specialObjList->specialObjects.globalObject); // ZRET TODO: Segment number enum? // gSegments[0x05] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[play->objectCtx.subKeepSlot].segment); } // BENTODO: Figure out if the following section is needed for something // if (specialObjList->specialObjects.elfMessage != NAVI_QUEST_HINTS_NONE) { - // play->naviQuestHints = Play_LoadFile(play, &naviQuestHintFiles[specialObjList->specialObjects.elfMessage - 1]); + // play->naviQuestHints = Play_LoadFile(play, &naviQuestHintFiles[specialObjList->specialObjects.elfMessage - + // 1]); // } } @@ -138,12 +139,12 @@ void Scene_CommandRoomBehavior(PlayState* play, SOH::ISceneCommand* cmd) { play->msgCtx.unk12044 = behavior->roomBehavior.msgCtxUnk; play->roomCtx.curRoom.enablePosLights = behavior->roomBehavior.enablePointLights; play->envCtx.stormState = behavior->roomBehavior.kankyoContextUnkE2; - //play->roomCtx.curRoom.behaviorType1 = behavior->roomBehavior.gameplayFlags; - //play->roomCtx.curRoom.behaviorType2 = behavior->roomBehavior.gameplayFlags2 & 0xFF; - //play->roomCtx.curRoom.lensMode = (behavior->roomBehavior.gameplayFlags2 >> 8) & 1; - //play->msgCtx.unk12044 = (behavior->roomBehavior.gameplayFlags2 >> 0xA) & 1; - //play->roomCtx.curRoom.enablePosLights = (behavior->roomBehavior.gameplayFlags2 >> 0xB) & 1; - //play->envCtx.stormState = (behavior->roomBehavior.gameplayFlags2 >> 0xC) & 1; + // play->roomCtx.curRoom.behaviorType1 = behavior->roomBehavior.gameplayFlags; + // play->roomCtx.curRoom.behaviorType2 = behavior->roomBehavior.gameplayFlags2 & 0xFF; + // play->roomCtx.curRoom.lensMode = (behavior->roomBehavior.gameplayFlags2 >> 8) & 1; + // play->msgCtx.unk12044 = (behavior->roomBehavior.gameplayFlags2 >> 0xA) & 1; + // play->roomCtx.curRoom.enablePosLights = (behavior->roomBehavior.gameplayFlags2 >> 0xB) & 1; + // play->envCtx.stormState = (behavior->roomBehavior.gameplayFlags2 >> 0xC) & 1; } void Scene_Command09(PlayState* play, SOH::ISceneCommand* cmd) { @@ -195,7 +196,7 @@ void Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) { // ObjectEntry* invalidatedEntry; // s16* objectEntry; // void* nextPtr; - + // s16* objectEntry = (s16*)objList->GetRawPointer(); // k = 0; // i = play->objectCtx.numPersistentEntries; @@ -240,7 +241,7 @@ void Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) { void Scene_CommandLightList(PlayState* play, SOH::ISceneCommand* cmd) { SOH::SetLightList* lightList = (SOH::SetLightList*)cmd; - + for (unsigned int i = 0; i < lightList->numLights; i++) { LightContext_InsertLight(play, &play->lightCtx, (LightInfo*)&lightList->lightList[i]); } @@ -268,9 +269,10 @@ void Scene_CommandEnvLightSettings(PlayState* play, SOH::ISceneCommand* cmd) { void Scene_CommandTimeSettings(PlayState* play, SOH::ISceneCommand* cmd) { SOH::SetTimeSettings* settings = (SOH::SetTimeSettings*)cmd; - + if ((settings->settings.hour != 0xFF) && (settings->settings.minute != 0xFF)) { - gSaveContext.skyboxTime = gSaveContext.save.time = CLOCK_TIME_ALT2_F(settings->settings.hour, settings->settings.minute); + gSaveContext.skyboxTime = gSaveContext.save.time = + CLOCK_TIME_ALT2_F(settings->settings.hour, settings->settings.minute); } if (settings->settings.timeIncrement != 0xFF) { @@ -309,13 +311,13 @@ void Scene_CommandTimeSettings(PlayState* play, SOH::ISceneCommand* cmd) { void Scene_CommandSkyboxSettings(PlayState* play, SOH::ISceneCommand* cmd) { SOH::SetSkyboxSettings* settings = (SOH::SetSkyboxSettings*)cmd; - + play->skyboxId = settings->settings.skyboxId & 3; // BENTODO z_scene.c reads from skyboxSettings.skyboxConfig not weather // Settings uses names from OOT play->envCtx.skyboxConfig = play->envCtx.changeSkyboxNextConfig = settings->settings.weather; play->envCtx.lightMode = settings->settings.indoors; - //Scene_LoadAreaTextures(play, settings->settings.) + // Scene_LoadAreaTextures(play, settings->settings.) } void Scene_CommandSkyboxDisables(PlayState* play, SOH::ISceneCommand* cmd) { @@ -335,10 +337,11 @@ void Scene_CommandSoundSettings(PlayState* play, SOH::ISceneCommand* cmd) { play->sequenceCtx.seqId = settings->settings.seqId; play->sequenceCtx.ambienceId = settings->settings.natureAmbienceId; - if(gSaveContext.seqId == (u8)NA_BGM_DISABLED || AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { + if (gSaveContext.seqId == (u8)NA_BGM_DISABLED || + AudioSeq_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { Audio_SetSpec(settings->settings.reverb); // BENTODO Verify if this should be reverb } - } +} void Scene_CommandEchoSetting(PlayState* play, SOH::ISceneCommand* cmd) { SOH::SetEchoSettings* echo = (SOH::SetEchoSettings*)cmd; @@ -350,7 +353,6 @@ void Scene_CommandCutsceneScriptList(PlayState* play, SOH::ISceneCommand* cmd) { play->csCtx.scriptListCount = cs->entries.size(); // BENTODO do this the right way with get pointer play->csCtx.scriptList = (CutsceneScriptEntry*)cs->entries.data(); - } static bool shouldEndSceneCommands = false; @@ -372,7 +374,7 @@ void Scene_CommandAltHeaderList(PlayState* play, SOH::ISceneCommand* cmd) { } void Scene_CommandSetRegionVisitedFlag(PlayState* play, SOH::ISceneCommand* cmd) { - s16 j = 0; + s16 j = 0; s16 i = 0; while (true) { @@ -418,7 +420,6 @@ void Scene_CommandMiniMap(PlayState* play, SOH::ISceneCommand* cmd) { } void Scene_Command1D(PlayState* play, SOH::ISceneCommand* cmd) { - } void Scene_CommandMiniMapCompassInfo(PlayState* play, SOH::ISceneCommand* cmd) { @@ -469,11 +470,12 @@ s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene) { auto sceneCmd = scene->commands[i]; cmdId = sceneCmd->cmdId; - // 2S2H [Port] This opcode is not in the original game. Its a special command for OTRs, for supporting multiple games + // 2S2H [Port] This opcode is not in the original game. Its a special command for OTRs, for supporting multiple + // games if (cmdId == SOH::SceneCommandID::SetCutscenesMM) { cmdId = SOH::SceneCommandID::SetCutscenes; } - + // 2S2H [Port] shouldEndSceneCommands is set when an alternate header list is found if (cmdId == SOH::SceneCommandID::EndMarker || shouldEndSceneCommands) { shouldEndSceneCommands = false; @@ -487,9 +489,8 @@ s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene) { return 0; } - extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { - + u32 size; if (roomCtx->status == 0) { @@ -498,20 +499,20 @@ extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomN roomCtx->curRoom.segment = NULL; roomCtx->status = 1; - //assert(roomNum < play->numRooms); + // assert(roomNum < play->numRooms); if (roomNum >= play->numRooms) return 0; // UH OH size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; - //roomCtx->activeRoomVram = - // (void*)((uintptr_t)roomCtx->roomMemPages[roomCtx->activeMemPage] - ((size + 8) * roomCtx->activeMemPage + 7)); + // roomCtx->activeRoomVram = + // (void*)((uintptr_t)roomCtx->roomMemPages[roomCtx->activeMemPage] - ((size + 8) * roomCtx->activeMemPage + + // 7)); // DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, //&roomCtx->loadQueue, NULL, __FILE__, __LINE__); printf("File Name %s\n", play->roomList[roomNum].fileName); - auto roomData = - std::static_pointer_cast(ResourceLoad(play->roomList[roomNum].fileName)); + auto roomData = std::static_pointer_cast(ResourceLoad(play->roomList[roomNum].fileName)); roomCtx->status = 1; roomCtx->activeRoomVram = roomData.get(); diff --git a/mm/src/audio/lib/load.c b/mm/src/audio/lib/load.c index 4574fff17..e38e232a6 100644 --- a/mm/src/audio/lib/load.c +++ b/mm/src/audio/lib/load.c @@ -925,7 +925,7 @@ static void AudioLoad_RelocateFont(s32 fontId, SoundFontData* mem, SampleBankRel void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { OSMesgQueue* msgQueue = &gAudioCtx.syncDmaQueue; OSIoMesg* ioMesg = &gAudioCtx.syncDmaIoMesg; - //size = ALIGN16(size); + // size = ALIGN16(size); Audio_InvalDCache(ramAddr, size); diff --git a/mm/src/audio/lib/playback.c b/mm/src/audio/lib/playback.c index 97c3a6c59..33e1337ed 100644 --- a/mm/src/audio/lib/playback.c +++ b/mm/src/audio/lib/playback.c @@ -186,9 +186,9 @@ void AudioPlayback_ProcessNotes(void) { playbackState = ¬e->playbackState; if (playbackState->parentLayer != NO_LAYER) { - // OTRTODO: This skips playback if the pointer is below where memory on the N64 normally would be. - // This does not translate well to modern platforms and how they map memory. - // Considering that this check is not present in OoT/SoH, we may be able to remove this altogether. + // OTRTODO: This skips playback if the pointer is below where memory on the N64 normally would be. + // This does not translate well to modern platforms and how they map memory. + // Considering that this check is not present in OoT/SoH, we may be able to remove this altogether. if ((uintptr_t)playbackState->parentLayer < 0x7FFFFFFF) { continue; } diff --git a/mm/src/audio/lib/seqplayer.c b/mm/src/audio/lib/seqplayer.c index ca41d9b6f..be884ecfd 100644 --- a/mm/src/audio/lib/seqplayer.c +++ b/mm/src/audio/lib/seqplayer.c @@ -1421,7 +1421,7 @@ void AudioScript_SequenceChannelProcessScript(SequenceChannel* channel) { if (seqPlayer->defaultFont != 0xFF) { if (gAudioCtx.seqReplaced[seqPlayer->playerIndex]) { - seqPlayer->seqId = gAudioCtx.seqToPlay[seqPlayer->playerIndex]; + seqPlayer->seqId = gAudioCtx.seqToPlay[seqPlayer->playerIndex]; gAudioCtx.seqReplaced[seqPlayer->playerIndex] = 0; } u16 seqId = seqPlayer->seqId; // AudioEditor_GetReplacementSeq(seqPlayer->seqId); diff --git a/mm/src/audio/lib/synthesis.c b/mm/src/audio/lib/synthesis.c index aa68ad369..8cd0805be 100644 --- a/mm/src/audio/lib/synthesis.c +++ b/mm/src/audio/lib/synthesis.c @@ -356,8 +356,8 @@ void AudioSynth_Noop9(void) { void AudioSynth_DMemMove(Acmd* cmd, s32 dmemIn, s32 dmemOut, size_t size) { aDMEMMove(cmd, dmemIn, dmemOut, size); - //cmd->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(dmemIn, 0, 24); - //cmd->words.w1 = _SHIFTL(dmemOut, 16, 16) | _SHIFTL(size, 0, 16); + // cmd->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(dmemIn, 0, 24); + // cmd->words.w1 = _SHIFTL(dmemOut, 16, 16) | _SHIFTL(size, 0, 16); } void AudioSynth_Noop10(void) { @@ -1031,7 +1031,7 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note } numEntries = SAMPLES_PER_FRAME * sample->book->order * sample->book->numPredictors; - //ResourceCheckSample(sample->sampleAddr, sample->book->codeBook); + // ResourceCheckSample(sample->sampleAddr, sample->book->codeBook); aLoadADPCM(cmd++, numEntries, gAudioCtx.adpcmCodeBook); } } @@ -1189,7 +1189,7 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; // BEN: This will crash the asan. We can just ignore alignment since we don't have those strictures. - //if (sampleDataChunkSize + sampleAddrOffset > sample->size) { + // if (sampleDataChunkSize + sampleAddrOffset > sample->size) { // sampleDataChunkSize = sample->size - sampleAddrOffset; // sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; //} diff --git a/mm/src/audio/sequence.c b/mm/src/audio/sequence.c index a0cf65a10..3ad2266e3 100644 --- a/mm/src/audio/sequence.c +++ b/mm/src/audio/sequence.c @@ -116,9 +116,10 @@ void AudioSeq_ProcessSeqCmd(u32 cmd) { fadeTimer = (cmd & 0xFF0000) >> 13; if (!gActiveSeqs[seqPlayerIndex].isWaitingForFonts && !sStartSeqDisabled) { // BEN: The code block to later load a sequence doesn't exist in OOT. - // BEN: The thing preventing this code block from running is actually the fact that we killed the audio tables. - // BEN: This delayed loading method actually utilizes some functions that OOT is no longer utilizing. - // BEN: The short of it ends up being the short circuit here is fine since it works and the stuff is loaded anyway. + // BEN: The thing preventing this code block from running is actually the fact that we killed the audio + // tables. BEN: This delayed loading method actually utilizes some functions that OOT is no longer + // utilizing. BEN: The short of it ends up being the short circuit here is fine since it works and the + // stuff is loaded anyway. if (seqArgs < 0x80 || 1) { AudioSeq_StartSequence(seqPlayerIndex, seqId, seqArgs, fadeTimer); } else { diff --git a/mm/src/audio/voice_external.c b/mm/src/audio/voice_external.c index 95eca9cde..f8a942d17 100644 --- a/mm/src/audio/voice_external.c +++ b/mm/src/audio/voice_external.c @@ -36,7 +36,7 @@ void func_801A4EB0(void) { } void func_801A4EB8(void) { - #if 0 +#if 0 u8* new_var; OSMesgQueue* serialEventQueue; s32 index; @@ -66,7 +66,7 @@ void func_801A4EB8(void) { func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; } - #endif +#endif } // Used externally in code_8019AF00 @@ -91,7 +91,7 @@ void func_801A4FD8(void) { func_801A5080(VOICE_WORD_ID_HIYA); func_801A5080(VOICE_WORD_ID_CHEESE); } - #endif +#endif } void func_801A5080(u16 wordId) { diff --git a/mm/src/audio/voice_internal.c b/mm/src/audio/voice_internal.c index 1efd76153..4c607d69c 100644 --- a/mm/src/audio/voice_internal.c +++ b/mm/src/audio/voice_internal.c @@ -59,7 +59,7 @@ s32 func_801A51F0(s32 errorCode) { s32 func_801A5228(OSVoiceDictionary* dict) { return 0; - #if 0 +#if 0 OSMesgQueue* serialEventQueue; s32 errorCode; u8 numWords; @@ -97,7 +97,7 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } return errorCode; - #endif +#endif } OSVoiceData* func_801A5390(void) { @@ -114,7 +114,7 @@ OSVoiceData* func_801A5390(void) { PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); return voiceData; - #endif +#endif } // Unused @@ -133,7 +133,7 @@ void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 // Unused // Could have a return? or be void return? s32 func_801A541C(s32 analog, s32 digital) { - #if 0 +#if 0 s32 errorCode; OSMesgQueue* serialEventQueue; @@ -146,7 +146,7 @@ s32 func_801A541C(s32 analog, s32 digital) { func_801A51F0(errorCode); } } - #endif +#endif } // Unused @@ -161,7 +161,7 @@ s32 func_801A5488(u8* word) { PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); return errorCode; - #endif +#endif } u8* func_801A54C4(void) { @@ -211,12 +211,12 @@ s32 func_801A54D0(u16 wordId) { } return errorCode; - #endif +#endif } s32 func_801A5680(u16 wordId) { return 0; - #if 0 +#if 0 s32 errorCode; u8 phi_a3 = true; u8 numWords; @@ -257,12 +257,12 @@ s32 func_801A5680(u16 wordId) { } return errorCode; - #endif +#endif } s32 func_801A5808(void) { return 0; - #if 0 +#if 0 s32 errorCode = 0; s32 ret; OSMesgQueue* serialEventQueue; @@ -331,7 +331,7 @@ s32 func_801A5808(void) { ret = func_801A51F0(errorCode); return ret; - #endif +#endif } // Unused diff --git a/mm/src/boot/O2/__osMalloc.c b/mm/src/boot/O2/__osMalloc.c index dd94e8c0d..afd626252 100644 --- a/mm/src/boot/O2/__osMalloc.c +++ b/mm/src/boot/O2/__osMalloc.c @@ -27,11 +27,11 @@ void ArenaImpl_LockInit(Arena* arena) { } void ArenaImpl_Lock(Arena* arena) { - //osSendMesg(&arena->lock, NULL, OS_MESG_BLOCK); + // osSendMesg(&arena->lock, NULL, OS_MESG_BLOCK); } void ArenaImpl_Unlock(Arena* arena) { - //osRecvMesg(&arena->lock, NULL, OS_MESG_BLOCK); + // osRecvMesg(&arena->lock, NULL, OS_MESG_BLOCK); } ArenaNode* ArenaImpl_GetLastBlock(Arena* arena) { diff --git a/mm/src/boot/O2/debug.c b/mm/src/boot/O2/debug.c index b146000d2..c8929d9ed 100644 --- a/mm/src/boot/O2/debug.c +++ b/mm/src/boot/O2/debug.c @@ -2,7 +2,7 @@ #include "fault.h" void _dbg_hungup(const char* file, int lineNum) { - //osGetThreadId(NULL); + // osGetThreadId(NULL); Fault_AddHungupAndCrash(file, lineNum); } diff --git a/mm/src/boot/O2/loadfragment2.c b/mm/src/boot/O2/loadfragment2.c index 86c459f9c..cd7da84f2 100644 --- a/mm/src/boot/O2/loadfragment2.c +++ b/mm/src/boot/O2/loadfragment2.c @@ -133,7 +133,7 @@ void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlReloc size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* ramStart, void* ramEnd, void* allocatedRamAddr) { return 0; - #if 0 +#if 0 uintptr_t vramStart = (uintptr_t)ramStart; uintptr_t vramEnd = (uintptr_t)ramEnd; s32 size = vromEnd - vromStart; @@ -166,7 +166,7 @@ size_t Overlay_Load(uintptr_t vromStart, uintptr_t vromEnd, void* ramStart, void if (gOverlayLogSeverity >= 3) {} return size; - #endif +#endif } void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd) { diff --git a/mm/src/boot/O2/rcp_utils.c b/mm/src/boot/O2/rcp_utils.c index 4c16efb86..5233ecc8a 100644 --- a/mm/src/boot/O2/rcp_utils.c +++ b/mm/src/boot/O2/rcp_utils.c @@ -1,23 +1,23 @@ #include "ultra64.h" void RcpUtils_PrintRegisterStatus(void) { - //u32 spStatus = __osSpGetStatus(); - //u32 dpStatus = osDpGetStatus(); + // u32 spStatus = __osSpGetStatus(); + // u32 dpStatus = osDpGetStatus(); // - //if (spStatus) { - // // stubbed debug prints - //} + // if (spStatus) { + // // stubbed debug prints + // } // - //if (dpStatus) { - // // stubbed debug prints - //} + // if (dpStatus) { + // // stubbed debug prints + // } } void RcpUtils_Reset(void) { - //RcpUtils_PrintRegisterStatus(); + // RcpUtils_PrintRegisterStatus(); //// Flush the RDP pipeline and freeze clock counter - //osDpSetStatus(DPC_SET_FREEZE | DPC_SET_FLUSH); + // osDpSetStatus(DPC_SET_FREEZE | DPC_SET_FLUSH); //// Halt the RSP, disable interrupt on break and set "task done" signal //__osSpSetStatus(SP_SET_HALT | SP_SET_TASKDONE | SP_CLR_INTR_BREAK); - //RcpUtils_PrintRegisterStatus(); + // RcpUtils_PrintRegisterStatus(); } diff --git a/mm/src/boot/O2/sleep.c b/mm/src/boot/O2/sleep.c index baa2d3d83..a45d7e7dd 100644 --- a/mm/src/boot/O2/sleep.c +++ b/mm/src/boot/O2/sleep.c @@ -1,27 +1,27 @@ #include "global.h" void Sleep_Cycles(u64 time) { - //OSMesgQueue mq; - //OSMesg msg[1]; - //OSTimer timer; + // OSMesgQueue mq; + // OSMesg msg[1]; + // OSTimer timer; - //osCreateMesgQueue(&mq, msg, ARRAY_COUNT(msg)); - //osSetTimer(&timer, time, 0, &mq, NULL); - //osRecvMesg(&mq, NULL, OS_MESG_BLOCK); + // osCreateMesgQueue(&mq, msg, ARRAY_COUNT(msg)); + // osSetTimer(&timer, time, 0, &mq, NULL); + // osRecvMesg(&mq, NULL, OS_MESG_BLOCK); } void Sleep_Nsec(u32 nsec) { - //Sleep_Cycles(OS_NSEC_TO_CYCLES(nsec)); + // Sleep_Cycles(OS_NSEC_TO_CYCLES(nsec)); } void Sleep_Usec(u32 usec) { - //Sleep_Cycles(OS_USEC_TO_CYCLES(usec)); + // Sleep_Cycles(OS_USEC_TO_CYCLES(usec)); } void Sleep_Msec(u32 ms) { - //Sleep_Cycles((ms * OS_CPU_COUNTER) / 1000ULL); + // Sleep_Cycles((ms * OS_CPU_COUNTER) / 1000ULL); } void Sleep_Sec(u32 sec) { - //Sleep_Cycles(sec * OS_CPU_COUNTER); + // Sleep_Cycles(sec * OS_CPU_COUNTER); } diff --git a/mm/src/boot/fault.c b/mm/src/boot/fault.c index 5ca8f8391..46e140e0b 100644 --- a/mm/src/boot/fault.c +++ b/mm/src/boot/fault.c @@ -85,9 +85,9 @@ const char* sFpuExceptions[] = { #endif #include void Fault_SleepImpl(u32 duration) { - //OSTime value = (duration * OS_CPU_COUNTER) / 1000ULL; + // OSTime value = (duration * OS_CPU_COUNTER) / 1000ULL; - //Sleep_Cycles(value); + // Sleep_Cycles(value); } /** @@ -97,7 +97,7 @@ void Fault_SleepImpl(u32 duration) { * Arguments are passed on to the callback through `arg0` and `arg1`. */ void Fault_AddClient(FaultClient* client, FaultClientCallback callback, void* arg0, void* arg1) { - #if 0 +#if 0 OSIntMask mask; u32 alreadyExists = false; @@ -128,14 +128,14 @@ void Fault_AddClient(FaultClient* client, FaultClientCallback callback, void* ar if (alreadyExists) { osSyncPrintf(VT_COL(RED, WHITE) "fault_AddClient: %08x は既にリスト中にある\n" VT_RST, client); } - #endif +#endif } /** * Removes a fault client so that the page is no longer displayed if a crash occurs. */ void Fault_RemoveClient(FaultClient* client) { - #if 0 +#if 0 FaultClient* iter = sFaultInstance->clients; FaultClient* lastIter = NULL; OSIntMask mask; @@ -167,7 +167,7 @@ void Fault_RemoveClient(FaultClient* client) { if (listIsEmpty) { osSyncPrintf(VT_COL(RED, WHITE) "fault_RemoveClient: %08x リスト不整合です\n" VT_RST, client); } - #endif +#endif } /** @@ -181,7 +181,7 @@ void Fault_RemoveClient(FaultClient* client) { * The callback may return 0 if it could not convert the address */ void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvClientCallback callback, void* arg) { - #if 0 +#if 0 OSIntMask mask; s32 alreadyExists = false; @@ -210,11 +210,11 @@ void Fault_AddAddrConvClient(FaultAddrConvClient* client, FaultAddrConvClientCal if (alreadyExists) { osSyncPrintf(VT_COL(RED, WHITE) "fault_AddressConverterAddClient: %08x は既にリスト中にある\n" VT_RST, client); } - #endif +#endif } void Fault_RemoveAddrConvClient(FaultAddrConvClient* client) { - #if 0 +#if 0 FaultAddrConvClient* iter = sFaultInstance->addrConvClients; FaultAddrConvClient* lastIter = NULL; OSIntMask mask; @@ -247,7 +247,7 @@ void Fault_RemoveAddrConvClient(FaultAddrConvClient* client) { osSyncPrintf(VT_COL(RED, WHITE) "fault_AddressConverterRemoveClient: %08x は既にリスト中にある\n" VT_RST, client); } - #endif +#endif } /** @@ -255,7 +255,7 @@ void Fault_RemoveAddrConvClient(FaultAddrConvClient* client) { * address converter clients */ uintptr_t Fault_ConvertAddress(uintptr_t addr) { - #if 0 +#if 0 uintptr_t ret; FaultAddrConvClient* iter = sFaultInstance->addrConvClients; @@ -270,19 +270,19 @@ uintptr_t Fault_ConvertAddress(uintptr_t addr) { } return 0; - #endif +#endif } void Fault_Sleep(u32 msec) { - //Fault_SleepImpl(msec); + // Fault_SleepImpl(msec); } void Fault_PadCallback(Input* input) { - //PadMgr_GetInput2(input, false); + // PadMgr_GetInput2(input, false); } void Fault_UpdatePadImpl(void) { - //sFaultInstance->padCallback(sFaultInstance->inputs); + // sFaultInstance->padCallback(sFaultInstance->inputs); } /** @@ -295,7 +295,7 @@ void Fault_UpdatePadImpl(void) { * DPad-Left continues and returns false */ u32 Fault_WaitForInputImpl(void) { - #if 0 +#if 0 Input* input = &sFaultInstance->inputs[0]; s32 count = 600; u32 pressedBtn; @@ -332,37 +332,37 @@ u32 Fault_WaitForInputImpl(void) { } } } - #endif +#endif } void Fault_WaitForInput(void) { - //Fault_WaitForInputImpl(); + // Fault_WaitForInputImpl(); } void Fault_DrawRec(s32 x, s32 y, s32 w, s32 h, u16 color) { - //FaultDrawer_DrawRecImpl(x, y, x + w - 1, y + h - 1, color); + // FaultDrawer_DrawRecImpl(x, y, x + w - 1, y + h - 1, color); } void Fault_FillScreenBlack(void) { - //FaultDrawer_SetForeColor(GPACK_RGBA5551(255, 255, 255, 1)); - //FaultDrawer_SetBackColor(GPACK_RGBA5551(0, 0, 0, 1)); - //FaultDrawer_FillScreen(); - //FaultDrawer_SetBackColor(GPACK_RGBA5551(0, 0, 0, 0)); + // FaultDrawer_SetForeColor(GPACK_RGBA5551(255, 255, 255, 1)); + // FaultDrawer_SetBackColor(GPACK_RGBA5551(0, 0, 0, 1)); + // FaultDrawer_FillScreen(); + // FaultDrawer_SetBackColor(GPACK_RGBA5551(0, 0, 0, 0)); } void Fault_FillScreenRed(void) { - //FaultDrawer_SetForeColor(GPACK_RGBA5551(255, 255, 255, 1)); - //FaultDrawer_SetBackColor(GPACK_RGBA5551(240, 0, 0, 1)); - //FaultDrawer_FillScreen(); - //FaultDrawer_SetBackColor(GPACK_RGBA5551(0, 0, 0, 0)); + // FaultDrawer_SetForeColor(GPACK_RGBA5551(255, 255, 255, 1)); + // FaultDrawer_SetBackColor(GPACK_RGBA5551(240, 0, 0, 1)); + // FaultDrawer_FillScreen(); + // FaultDrawer_SetBackColor(GPACK_RGBA5551(0, 0, 0, 0)); } void Fault_DrawCornerRec(u16 color) { - //Fault_DrawRec(22, 16, 8, 1, color); + // Fault_DrawRec(22, 16, 8, 1, color); } void Fault_PrintFReg(s32 index, f32* value) { - #if 0 +#if 0 u32 raw = *(u32*)value; s32 v0 = ((raw & 0x7F800000) >> 0x17) - 0x7F; @@ -372,11 +372,11 @@ void Fault_PrintFReg(s32 index, f32* value) { // Print subnormal floats as their IEEE-754 hex representation FaultDrawer_Printf("F%02d: %08x(16) ", index, raw); } - #endif +#endif } void Fault_LogFReg(s32 idx, f32* value) { - #if 0 +#if 0 u32 raw = *(u32*)value; s32 v0 = ((raw & 0x7F800000) >> 0x17) - 0x7F; @@ -385,11 +385,11 @@ void Fault_LogFReg(s32 idx, f32* value) { } else { osSyncPrintf("F%02d: %08x(16) ", idx, *(u32*)value); } - #endif +#endif } void Fault_PrintFPCR(u32 value) { - #if 0 +#if 0 s32 i; u32 flag = 0x20000; @@ -405,11 +405,11 @@ void Fault_PrintFPCR(u32 value) { flag >>= 1; } FaultDrawer_Printf("\n"); - #endif +#endif } void Fault_LogFPCSR(u32 value) { - #if 0 +#if 0 s32 i; u32 flag = 0x20000; @@ -421,11 +421,11 @@ void Fault_LogFPCSR(u32 value) { } flag >>= 1; } - #endif +#endif } void Fault_PrintThreadContext(OSThread* thread) { - #if 0 +#if 0 __OSThreadContext* threadCtx; s16 causeStrIdx = _SHIFTR((u32)thread->context.cause, 2, 5); @@ -488,11 +488,11 @@ void Fault_PrintThreadContext(OSThread* thread) { if (sFaultTimeTotal != 0.0f) { FaultDrawer_DrawText(160, 216, "%5.2f sec\n", sFaultTimeTotal); } - #endif +#endif } void osSyncPrintfThreadContext(OSThread* thread) { - #if 0 +#if 0 __OSThreadContext* threadCtx; s16 causeStrIdx = _SHIFTR((u32)thread->context.cause, 2, 5); @@ -545,7 +545,7 @@ void osSyncPrintfThreadContext(OSThread* thread) { Fault_LogFReg(28, &threadCtx->fp28.f.f_even); Fault_LogFReg(30, &threadCtx->fp30.f.f_even); osSyncPrintf("\n"); - #endif +#endif } /** @@ -553,7 +553,7 @@ void osSyncPrintfThreadContext(OSThread* thread) { * the CPU break or Fault flag set. */ OSThread* Fault_FindFaultedThread(void) { - #if 0 +#if 0 OSThread* iter = __osGetActiveQueue(); while (iter->priority != OS_PRIORITY_THREADTAIL) { @@ -565,10 +565,10 @@ OSThread* Fault_FindFaultedThread(void) { } return NULL; - #endif +#endif } void Fault_Wait5Seconds(void) { - #if 0 +#if 0 s32 pad; OSTime start = osGetTime(); @@ -577,7 +577,7 @@ void Fault_Wait5Seconds(void) { } while ((osGetTime() - start) <= OS_SEC_TO_CYCLES(5)); sFaultInstance->autoScroll = true; - #endif +#endif } /** @@ -586,7 +586,7 @@ void Fault_Wait5Seconds(void) { * (DPad-Left & L & R & C-Right) & Start */ void Fault_WaitForButtonCombo(void) { - #if 0 +#if 0 Input* input = &sFaultInstance->inputs[0]; FaultDrawer_SetForeColor(GPACK_RGBA5551(255, 255, 255, 1)); @@ -598,11 +598,11 @@ void Fault_WaitForButtonCombo(void) { Fault_UpdatePadImpl(); } while (!CHECK_BTN_ALL(input->press.button, BTN_RESET)); } while (!CHECK_BTN_ALL(input->cur.button, BTN_DLEFT | BTN_L | BTN_R | BTN_CRIGHT)); - #endif +#endif } void Fault_DrawMemDumpContents(const char* title, uintptr_t addr, u32 param_3) { - #if 0 +#if 0 uintptr_t alignedAddr = addr; u32* writeAddr; s32 y; @@ -639,7 +639,7 @@ void Fault_DrawMemDumpContents(const char* title, uintptr_t addr, u32 param_3) { } FaultDrawer_SetCharPad(0, 0); - #endif +#endif } /** @@ -659,7 +659,7 @@ void Fault_DrawMemDumpContents(const char* title, uintptr_t addr, u32 param_3) { * @param cRightJump Unused parameter, pressing C-Right jumps to this address */ void Fault_DrawMemDump(uintptr_t pc, uintptr_t sp, uintptr_t cLeftJump, uintptr_t cRightJump) { - #if 0 +#if 0 s32 scrollCountdown; s32 off; Input* input = &sFaultInstance->inputs[0]; @@ -740,7 +740,7 @@ void Fault_DrawMemDump(uintptr_t pc, uintptr_t sp, uintptr_t cLeftJump, uintptr_ // Resume auto-scroll and move to next page sFaultInstance->autoScroll = true; - #endif +#endif } /** @@ -779,7 +779,7 @@ void Fault_DrawMemDump(uintptr_t pc, uintptr_t sp, uintptr_t cLeftJump, uintptr_ * and the backtrace may continue as normal. */ void Fault_WalkStack(uintptr_t* spPtr, uintptr_t* pcPtr, uintptr_t* raPtr) { - #if 0 +#if 0 uintptr_t sp = *spPtr; uintptr_t pc = *pcPtr; uintptr_t ra = *raPtr; @@ -842,14 +842,14 @@ void Fault_WalkStack(uintptr_t* spPtr, uintptr_t* pcPtr, uintptr_t* raPtr) { *spPtr = sp; *pcPtr = pc; *raPtr = ra; - #endif +#endif } /** * Draws the stack trace page contents for the specified thread */ void Fault_DrawStackTrace(OSThread* thread, u32 flags) { - #if 0 +#if 0 s32 line; uintptr_t sp = thread->context.sp; uintptr_t ra = thread->context.ra; @@ -876,11 +876,11 @@ void Fault_DrawStackTrace(OSThread* thread, u32 flags) { Fault_WalkStack(&sp, &pc, &ra); } - #endif +#endif } void Fault_LogStackTrace(OSThread* thread, u32 flags) { - #if 0 +#if 0 s32 line; uintptr_t sp = thread->context.sp; uintptr_t ra = thread->context.ra; @@ -906,11 +906,11 @@ void Fault_LogStackTrace(OSThread* thread, u32 flags) { Fault_WalkStack(&sp, &pc, &ra); } - #endif +#endif } void Fault_ResumeThread(OSThread* thread) { - #if 0 +#if 0 thread->context.cause = 0; thread->context.fpcsr = 0; thread->context.pc += sizeof(u32); @@ -918,11 +918,11 @@ void Fault_ResumeThread(OSThread* thread) { osWritebackDCache((void*)thread->context.pc, 4); osInvalICache((void*)thread->context.pc, 4); osStartThread(thread); - #endif +#endif } void Fault_DisplayFrameBuffer(void) { - #if 0 +#if 0 void* fb; osViSetYScale(1.0f); @@ -941,7 +941,7 @@ void Fault_DisplayFrameBuffer(void) { osViSwapBuffer(fb); FaultDrawer_SetDrawerFrameBuffer(fb, SCREEN_WIDTH, SCREEN_HEIGHT); - #endif +#endif } /** @@ -949,7 +949,7 @@ void Fault_DisplayFrameBuffer(void) { * on the crash screen. */ void Fault_ProcessClients(void) { - #if 0 +#if 0 FaultClient* client = sFaultInstance->clients; s32 idx = 0; @@ -966,11 +966,11 @@ void Fault_ProcessClients(void) { } client = client->next; } - #endif +#endif } void Fault_SetOptionsFromController3(void) { - #if 0 +#if 0 static u32 faultCustomOptions; Input* input3 = &sFaultInstance->inputs[3]; u32 pad; @@ -1003,12 +1003,12 @@ void Fault_SetOptionsFromController3(void) { FaultDrawer_DrawText(0x20, 0xD8, "GRAPH PC %08x RA %08x SP %08x", pc, ra, sp); } } - #endif +#endif } void Fault_UpdatePad(void) { - //Fault_UpdatePadImpl(); - //Fault_SetOptionsFromController3(); + // Fault_UpdatePadImpl(); + // Fault_SetOptionsFromController3(); } //#define FAULT_MSG_CPU_BREAK ((OSMesg)1) @@ -1016,7 +1016,7 @@ void Fault_UpdatePad(void) { //#define FAULT_MSG_UNK ((OSMesg)3) void Fault_ThreadEntry(void* arg) { - #if 0 +#if 0 OSMesg msg; u32 pad; OSThread* faultedThread; @@ -1115,20 +1115,20 @@ void Fault_ThreadEntry(void* arg) { Fault_ResumeThread(faultedThread); } - #endif +#endif } void Fault_SetFrameBuffer(void* fb, u16 w, u16 h) { - //sFaultInstance->fb = fb; - //FaultDrawer_SetDrawerFrameBuffer(fb, w, h); + // sFaultInstance->fb = fb; + // FaultDrawer_SetDrawerFrameBuffer(fb, w, h); } -//STACK(sFaultStack, 0x600); -//StackEntry sFaultStackInfo; -//FaultMgr gFaultMgr; +// STACK(sFaultStack, 0x600); +// StackEntry sFaultStackInfo; +// FaultMgr gFaultMgr; void Fault_Init(void) { - #if 0 +#if 0 sFaultInstance = &gFaultMgr; bzero(sFaultInstance, sizeof(FaultMgr)); FaultDrawer_Init(); @@ -1146,7 +1146,7 @@ void Fault_Init(void) { osCreateThread(&sFaultInstance->thread, Z_THREAD_ID_FAULT, Fault_ThreadEntry, NULL, STACK_TOP(sFaultStack), Z_PRIORITY_FAULT); osStartThread(&sFaultInstance->thread); - #endif +#endif } /** @@ -1154,14 +1154,14 @@ void Fault_Init(void) { * specified in arguments to `Fault_AddHungupAndCrashImpl`. */ void Fault_HangupFaultClient(const char* exp1, const char* exp2) { - #if 0 +#if 0 osSyncPrintf("HungUp on Thread %d\n", osGetThreadId(NULL)); osSyncPrintf("%s\n", exp1 != NULL ? exp1 : "(NULL)"); osSyncPrintf("%s\n", exp2 != NULL ? exp2 : "(NULL)"); FaultDrawer_Printf("HungUp on Thread %d\n", osGetThreadId(NULL)); FaultDrawer_Printf("%s\n", exp1 != NULL ? exp1 : "(NULL)"); FaultDrawer_Printf("%s\n", exp2 != NULL ? exp2 : "(NULL)"); - #endif +#endif } /** @@ -1171,10 +1171,10 @@ void Fault_HangupFaultClient(const char* exp1, const char* exp2) { */ void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) { assert(0); - //FaultClient client; - //s32 pad; + // FaultClient client; + // s32 pad; // - //Fault_AddClient(&client, (void*)Fault_HangupFaultClient, (void*)exp1, (void*)exp2); + // Fault_AddClient(&client, (void*)Fault_HangupFaultClient, (void*)exp1, (void*)exp2); //*(u32*)0x11111111 = 0; // trigger an exception via unaligned memory access } diff --git a/mm/src/boot/fault_drawer.c b/mm/src/boot/fault_drawer.c index ed653a09d..e86b8d7e1 100644 --- a/mm/src/boot/fault_drawer.c +++ b/mm/src/boot/fault_drawer.c @@ -81,11 +81,11 @@ FaultDrawer sFaultDrawerDefault = { //#pragma GLOBAL_ASM("asm/non_matchings/boot/fault_drawer/sFaultDrawerFont.s") void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) { - //sFaultDrawerInstance->osSyncPrintfEnabled = enabled; + // sFaultDrawerInstance->osSyncPrintfEnabled = enabled; } void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color) { - #if 0 +#if 0 u16* frameBuffer; s32 x; s32 y; @@ -113,11 +113,11 @@ void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 col osWritebackDCacheAll(); } - #endif +#endif } void FaultDrawer_DrawChar(char c) { - #if 0 +#if 0 s32 x; s32 y; u32 data; @@ -147,7 +147,7 @@ void FaultDrawer_DrawChar(char c) { dataPtr += 2; } } - #endif +#endif } s32 FaultDrawer_ColorToPrintColor(u16 color) { @@ -161,11 +161,11 @@ s32 FaultDrawer_ColorToPrintColor(u16 color) { } } return -1; - #endif +#endif } void FaultDrawer_UpdatePrintColor(void) { - #if 0 +#if 0 s32 index; if (sFaultDrawerInstance->osSyncPrintfEnabled) { @@ -181,51 +181,51 @@ void FaultDrawer_UpdatePrintColor(void) { osSyncPrintf(VT_SGR("4%d"), index); } } - #endif +#endif } void FaultDrawer_SetForeColor(u16 color) { - //sFaultDrawerInstance->foreColor = color; - //FaultDrawer_UpdatePrintColor(); + // sFaultDrawerInstance->foreColor = color; + // FaultDrawer_UpdatePrintColor(); } void FaultDrawer_SetBackColor(u16 color) { - //sFaultDrawerInstance->backColor = color; - //FaultDrawer_UpdatePrintColor(); + // sFaultDrawerInstance->backColor = color; + // FaultDrawer_UpdatePrintColor(); } void FaultDrawer_SetFontColor(u16 color) { - //FaultDrawer_SetForeColor(color | 1); // force alpha to be set + // FaultDrawer_SetForeColor(color | 1); // force alpha to be set } void FaultDrawer_SetCharPad(s8 padW, s8 padH) { - //sFaultDrawerInstance->charWPad = padW; - //sFaultDrawerInstance->charHPad = padH; + // sFaultDrawerInstance->charWPad = padW; + // sFaultDrawerInstance->charHPad = padH; } void FaultDrawer_SetCursor(s32 x, s32 y) { - //if (sFaultDrawerInstance->osSyncPrintfEnabled) { - // osSyncPrintf( - // VT_CUP("%d", "%d"), - // (y - sFaultDrawerInstance->yStart) / (sFaultDrawerInstance->charH + sFaultDrawerInstance->charHPad), - // (x - sFaultDrawerInstance->xStart) / (sFaultDrawerInstance->charW + sFaultDrawerInstance->charWPad)); - //} - //sFaultDrawerInstance->cursorX = x; - //sFaultDrawerInstance->cursorY = y; + // if (sFaultDrawerInstance->osSyncPrintfEnabled) { + // osSyncPrintf( + // VT_CUP("%d", "%d"), + // (y - sFaultDrawerInstance->yStart) / (sFaultDrawerInstance->charH + sFaultDrawerInstance->charHPad), + // (x - sFaultDrawerInstance->xStart) / (sFaultDrawerInstance->charW + sFaultDrawerInstance->charWPad)); + // } + // sFaultDrawerInstance->cursorX = x; + // sFaultDrawerInstance->cursorY = y; } void FaultDrawer_FillScreen() { - //if (sFaultDrawerInstance->osSyncPrintfEnabled) { - // osSyncPrintf(VT_CLS); - //} + // if (sFaultDrawerInstance->osSyncPrintfEnabled) { + // osSyncPrintf(VT_CLS); + // } // - //FaultDrawer_DrawRecImpl(sFaultDrawerInstance->xStart, sFaultDrawerInstance->yStart, sFaultDrawerInstance->xEnd, - // sFaultDrawerInstance->yEnd, sFaultDrawerInstance->backColor | 1); - //FaultDrawer_SetCursor(sFaultDrawerInstance->xStart, sFaultDrawerInstance->yStart); + // FaultDrawer_DrawRecImpl(sFaultDrawerInstance->xStart, sFaultDrawerInstance->yStart, sFaultDrawerInstance->xEnd, + // sFaultDrawerInstance->yEnd, sFaultDrawerInstance->backColor | 1); + // FaultDrawer_SetCursor(sFaultDrawerInstance->xStart, sFaultDrawerInstance->yStart); } void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count) { - #if 0 +#if 0 for (; count != 0; count--, str++) { if (sFaultDrawerInstance->escCode) { sFaultDrawerInstance->escCode = false; @@ -270,14 +270,14 @@ void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count) { } osWritebackDCacheAll(); - #endif +#endif return NULL; } -//const char D_80099080[] = "(null)"; +// const char D_80099080[] = "(null)"; s32 FaultDrawer_VPrintf(const char* fmt, va_list ap) { - //return _Printf(FaultDrawer_FormatStringFunc, sFaultDrawerInstance, fmt, ap); + // return _Printf(FaultDrawer_FormatStringFunc, sFaultDrawerInstance, fmt, ap); } s32 FaultDrawer_Printf(const char* fmt, ...) { @@ -293,31 +293,31 @@ s32 FaultDrawer_Printf(const char* fmt, ...) { va_end(args); return ret; - #endif +#endif } void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) { - //va_list args; - //va_start(args, fmt); + // va_list args; + // va_start(args, fmt); // - //FaultDrawer_SetCursor(x, y); - //FaultDrawer_VPrintf(fmt, args); + // FaultDrawer_SetCursor(x, y); + // FaultDrawer_VPrintf(fmt, args); // - //va_end(args); + // va_end(args); } void FaultDrawer_SetDrawerFrameBuffer(void* frameBuffer, u16 w, u16 h) { - //sFaultDrawerInstance->frameBuffer = frameBuffer; - //sFaultDrawerInstance->w = w; - //sFaultDrawerInstance->h = h; + // sFaultDrawerInstance->frameBuffer = frameBuffer; + // sFaultDrawerInstance->w = w; + // sFaultDrawerInstance->h = h; } void FaultDrawer_SetInputCallback(FaultDrawerCallback callback) { - //sFaultDrawerInstance->inputCallback = callback; + // sFaultDrawerInstance->inputCallback = callback; } void FaultDrawer_Init() { - //sFaultDrawerInstance = &sFaultDrawer; - //bcopy(&sFaultDrawerDefault, sFaultDrawerInstance, sizeof(FaultDrawer)); - //sFaultDrawerInstance->frameBuffer = (u16*)(PHYS_TO_K0(osMemSize) - SCREEN_HEIGHT * SCREEN_WIDTH * sizeof(u16)); + // sFaultDrawerInstance = &sFaultDrawer; + // bcopy(&sFaultDrawerDefault, sFaultDrawerInstance, sizeof(FaultDrawer)); + // sFaultDrawerInstance->frameBuffer = (u16*)(PHYS_TO_K0(osMemSize) - SCREEN_HEIGHT * SCREEN_WIDTH * sizeof(u16)); } diff --git a/mm/src/boot/idle.c b/mm/src/boot/idle.c index 7899885f0..12c5e11fd 100644 --- a/mm/src/boot/idle.c +++ b/mm/src/boot/idle.c @@ -29,36 +29,36 @@ f32 gViConfigXScale = 1.0f; f32 gViConfigYScale = 1.0f; void Main_ClearMemory(void* begin, void* end) { - //if (begin < end) { - // bzero(begin, (uintptr_t)end - (uintptr_t)begin); - //} + // if (begin < end) { + // bzero(begin, (uintptr_t)end - (uintptr_t)begin); + // } } void Main_InitFramebuffer(u32* framebuffer, size_t numBytes, u32 value) { - //for (; numBytes > 0; numBytes -= sizeof(u32)) { - // *framebuffer++ = value; - //} + // for (; numBytes > 0; numBytes -= sizeof(u32)) { + // *framebuffer++ = value; + // } } void Main_InitScreen(void) { - //Main_InitFramebuffer((u32*)gFramebuffer1, sizeof(gFramebuffer1), - // (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - //ViConfig_UpdateVi(false); - //osViSwapBuffer(gFramebuffer1); - //osViBlack(false); + // Main_InitFramebuffer((u32*)gFramebuffer1, sizeof(gFramebuffer1), + // (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); + // ViConfig_UpdateVi(false); + // osViSwapBuffer(gFramebuffer1); + // osViBlack(false); } void Main_InitMemory(void) { - //void* memStart = (void*)0x80000400; - //void* memEnd = OS_PHYSICAL_TO_K0(osMemSize); + // void* memStart = (void*)0x80000400; + // void* memEnd = OS_PHYSICAL_TO_K0(osMemSize); // - //Main_ClearMemory(memStart, gFramebuffer1); - //Main_ClearMemory(D_80025D00, bootproc); - //Main_ClearMemory(gGfxSPTaskYieldBuffer, memEnd); + // Main_ClearMemory(memStart, gFramebuffer1); + // Main_ClearMemory(D_80025D00, bootproc); + // Main_ClearMemory(gGfxSPTaskYieldBuffer, memEnd); } void Main_Init(void) { - #if 0 +#if 0 DmaRequest dmaReq; OSMesgQueue mq; OSMesg msg[1]; @@ -78,22 +78,22 @@ void Main_Init(void) { gDmaMgrDmaBuffSize = prevSize; Main_ClearMemory(SEGMENT_BSS_START(code), SEGMENT_BSS_END(code)); - #endif +#endif } void Main_ThreadEntry(void* arg) { - #if 0 +#if 0 StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, STACK_TOP(sIrqMgrStack), 0, 0x100, "irqmgr"); IrqMgr_Init(&gIrqMgr, STACK_TOP(sIrqMgrStack), Z_PRIORITY_IRQMGR, 1); DmaMgr_Start(); Main_Init(); Main(arg); DmaMgr_Stop(); - #endif +#endif } void Idle_InitVideo(void) { - #if 0 +#if 0 osCreateViManager(OS_PRIORITY_VIMGR); gViConfigFeatures = OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF; @@ -119,16 +119,16 @@ void Idle_InitVideo(void) { } D_80096B20 = 1; - #endif +#endif } void Idle_ThreadEntry(void* arg) { - //Idle_InitVideo(); - //osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQueue, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); - //StackCheck_Init(&sMainStackInfo, sMainStack, STACK_TOP(sMainStack), 0, 0x400, "main"); - //osCreateThread(&sMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, STACK_TOP(sMainStack), Z_PRIORITY_MAIN); - //osStartThread(&sMainThread); - //osSetThreadPri(NULL, OS_PRIORITY_IDLE); - - //for (;;) {} + // Idle_InitVideo(); + // osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQueue, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); + // StackCheck_Init(&sMainStackInfo, sMainStack, STACK_TOP(sMainStack), 0, 0x400, "main"); + // osCreateThread(&sMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, STACK_TOP(sMainStack), Z_PRIORITY_MAIN); + // osStartThread(&sMainThread); + // osSetThreadPri(NULL, OS_PRIORITY_IDLE); + + // for (;;) {} } diff --git a/mm/src/boot/irqmgr.c b/mm/src/boot/irqmgr.c index 4cdcd398d..3e95a8645 100644 --- a/mm/src/boot/irqmgr.c +++ b/mm/src/boot/irqmgr.c @@ -8,7 +8,7 @@ volatile OSTime gIrqMgrRetraceTime = 0; s32 sIrqMgrRetraceCount = 0; void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueue) { - #if 0 +#if 0 u32 saveMask; saveMask = osSetIntMask(1); @@ -25,11 +25,11 @@ void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueu if (irqmgr->prenmiStage > 1) { osSendMesg(client->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); } - #endif +#endif } void IrqMgr_RemoveClient(IrqMgr* irqmgr, IrqMgrClient* remove) { - #if 0 +#if 0 IrqMgrClient* iter; IrqMgrClient* last; u32 saveMask; @@ -53,22 +53,22 @@ void IrqMgr_RemoveClient(IrqMgr* irqmgr, IrqMgrClient* remove) { } osSetIntMask(saveMask); - #endif +#endif } void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg) { - #if 0 +#if 0 IrqMgrClient* iter = irqmgr->callbacks; while (iter != NULL) { osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK); iter = iter->next; } - #endif +#endif } void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg) { - #if 0 +#if 0 IrqMgrClient* iter = irqmgr->callbacks; while (iter != NULL) { @@ -77,11 +77,11 @@ void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg) { } iter = iter->next; } - #endif +#endif } void IrqMgr_HandlePreNMI(IrqMgr* irqmgr) { - #if 0 +#if 0 gIrqMgrResetStatus = 1; irqmgr->prenmiStage = 1; @@ -91,15 +91,15 @@ void IrqMgr_HandlePreNMI(IrqMgr* irqmgr) { osSetTimer(&irqmgr->prenmiTimer, OS_USEC_TO_CYCLES(450000), 0, &irqmgr->irqQueue, (OSMesg)0x29F); IrqMgr_JamMesgForClient(irqmgr, &irqmgr->prenmiMsg.type); - #endif +#endif } void IrqMgr_CheckStack(void) { - //StackCheck_Check(NULL); + // StackCheck_Check(NULL); } void IrqMgr_HandlePRENMI450(IrqMgr* irqmgr) { - #if 0 +#if 0 gIrqMgrResetStatus = 2; irqmgr->prenmiStage = 2; @@ -107,21 +107,21 @@ void IrqMgr_HandlePRENMI450(IrqMgr* irqmgr) { osSetTimer(&irqmgr->prenmiTimer, OS_USEC_TO_CYCLES(30000), 0, &irqmgr->irqQueue, (OSMesg)0x2A0); IrqMgr_SendMesgForClient(irqmgr, &irqmgr->nmiMsg.type); - #endif +#endif } void IrqMgr_HandlePRENMI480(IrqMgr* irqmgr) { // Wait .52 seconds. After this we will have waited an entire second - //osSetTimer(&irqmgr->prenmiTimer, OS_USEC_TO_CYCLES(520000), 0, &irqmgr->irqQueue, (OSMesg)0x2A1); + // osSetTimer(&irqmgr->prenmiTimer, OS_USEC_TO_CYCLES(520000), 0, &irqmgr->irqQueue, (OSMesg)0x2A1); - //osAfterPreNMI(); + // osAfterPreNMI(); } void IrqMgr_HandlePRENMI500(IrqMgr* irqmgr) { - //IrqMgr_CheckStack(); + // IrqMgr_CheckStack(); } void IrqMgr_HandleRetrace(IrqMgr* irqmgr) { - #if 0 +#if 0 if (gIrqMgrRetraceTime == 0) { if (irqmgr->lastFrameTime == 0) { irqmgr->lastFrameTime = osGetTime(); @@ -132,11 +132,11 @@ void IrqMgr_HandleRetrace(IrqMgr* irqmgr) { sIrqMgrRetraceCount += 1; IrqMgr_SendMesgForClient(irqmgr, irqmgr); - #endif +#endif } void IrqMgr_ThreadEntry(IrqMgr* irqmgr) { - #if 0 +#if 0 u32 interrupt; u32 stop; @@ -166,11 +166,11 @@ void IrqMgr_ThreadEntry(IrqMgr* irqmgr) { break; } } - #endif +#endif } void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount) { - #if 0 +#if 0 irqmgr->callbacks = NULL; irqmgr->verticalRetraceMesg.type = 1; irqmgr->prenmiMsg.type = 4; @@ -184,5 +184,5 @@ void IrqMgr_Init(IrqMgr* irqmgr, void* stack, OSPri pri, u8 retraceCount) { osCreateThread(&irqmgr->thread, Z_THREAD_ID_IRQMGR, IrqMgr_ThreadEntry, irqmgr, stack, pri); osStartThread(&irqmgr->thread); - #endif +#endif } diff --git a/mm/src/boot/viconfig.c b/mm/src/boot/viconfig.c index b3faf85d5..540bd3c6c 100644 --- a/mm/src/boot/viconfig.c +++ b/mm/src/boot/viconfig.c @@ -10,7 +10,7 @@ extern OSViMode osViModeMpalLan1; extern OSViMode osViModeFpalLan1; void ViConfig_UpdateVi(u32 black) { - #if 0 +#if 0 if (black) { switch (osTvType) { case OS_TV_MPAL: @@ -55,7 +55,7 @@ void ViConfig_UpdateVi(u32 black) { } gViConfigUseBlack = black; - #endif +#endif } void ViConfig_UpdateBlack(void) { diff --git a/mm/src/boot/yaz0.c b/mm/src/boot/yaz0.c index 719250220..9378d684b 100644 --- a/mm/src/boot/yaz0.c +++ b/mm/src/boot/yaz0.c @@ -14,7 +14,7 @@ void* gYaz0DecompressDstEnd; #endif void* Yaz0_FirstDMA() { - #if 0 +#if 0 u32 pad0; u32 dmaSize; u32 curSize; @@ -27,12 +27,12 @@ void* Yaz0_FirstDMA() { DmaMgr_DmaRomToRam(sYaz0CurRomStart, sYaz0DataBuffer, dmaSize); sYaz0CurRomStart += dmaSize; sYaz0CurSize -= dmaSize; - #endif +#endif return NULL; } void* Yaz0_NextDMA(void* curSrcPos) { - #if 0 +#if 0 u8* dst; u32 restSize; u32 dmaSize; @@ -63,7 +63,7 @@ void* Yaz0_NextDMA(void* curSrcPos) { } return dst; - #endif +#endif } typedef struct { @@ -76,7 +76,7 @@ typedef struct { #define YAZ0_MAGIC 0x59617A30 // "Yaz0" s32 Yaz0_DecompressImpl(u8* src, u8* dst) { - #if 0 +#if 0 u32 bitIdx = 0; u8* dstEnd; u32 chunkHeader = 0; @@ -131,7 +131,7 @@ s32 Yaz0_DecompressImpl(u8* src, u8* dst) { gYaz0DecompressDstEnd = dstEnd; return 0; - #endif +#endif } void Yaz0_Decompress(uintptr_t romStart, void* dst, size_t size) { @@ -160,5 +160,5 @@ void Yaz0_Decompress(uintptr_t romStart, void* dst, size_t size) { } sYaz0CurDataEnd = NULL; - #endif +#endif } diff --git a/mm/src/boot/z_std_dma.c b/mm/src/boot/z_std_dma.c index 26b870d03..a193fd0e3 100644 --- a/mm/src/boot/z_std_dma.c +++ b/mm/src/boot/z_std_dma.c @@ -8,15 +8,15 @@ size_t gDmaMgrDmaBuffSize = 0x2000; -//StackEntry sDmaMgrStackInfo; -//u16 sNumDmaEntries; -//OSMesgQueue sDmaMgrMsgQueue; -//OSMesg sDmaMgrMsgs[32]; -//OSThread sDmaMgrThread; -//STACK(sDmaMgrStack, 0x500); +// StackEntry sDmaMgrStackInfo; +// u16 sNumDmaEntries; +// OSMesgQueue sDmaMgrMsgQueue; +// OSMesg sDmaMgrMsgs[32]; +// OSThread sDmaMgrThread; +// STACK(sDmaMgrStack, 0x500); s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { - #if 0 +#if 0 OSIoMesg ioMsg; OSMesgQueue queue; OSMesg msg[1]; @@ -60,16 +60,16 @@ s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) { END: return ret; - #endif +#endif return 0; } s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { - //return osEPiStartDma(pihandle, mb, direction); + // return osEPiStartDma(pihandle, mb, direction); } DmaEntry* DmaMgr_FindDmaEntry(uintptr_t vrom) { - #if 0 +#if 0 DmaEntry* curr; for (curr = dmadata; curr->vromEnd != 0; curr++) { @@ -84,11 +84,11 @@ DmaEntry* DmaMgr_FindDmaEntry(uintptr_t vrom) { } return NULL; - #endif +#endif } u32 DmaMgr_TranslateVromToRom(uintptr_t vrom) { - #if 0 +#if 0 DmaEntry* entry = DmaMgr_FindDmaEntry(vrom); if (entry != NULL) { @@ -104,11 +104,11 @@ u32 DmaMgr_TranslateVromToRom(uintptr_t vrom) { } return -1; - #endif +#endif } s32 DmaMgr_FindDmaIndex(uintptr_t vrom) { - #if 0 +#if 0 DmaEntry* entry = DmaMgr_FindDmaEntry(vrom); if (entry != NULL) { @@ -116,7 +116,7 @@ s32 DmaMgr_FindDmaIndex(uintptr_t vrom) { } return -1; - #endif +#endif } const char* func_800809F4(uintptr_t a0) { @@ -124,7 +124,7 @@ const char* func_800809F4(uintptr_t a0) { } void DmaMgr_ProcessMsg(DmaRequest* req) { - #if 0 +#if 0 uintptr_t vrom; void* ram; size_t size; @@ -166,11 +166,11 @@ void DmaMgr_ProcessMsg(DmaRequest* req) { } else { Fault_AddHungupAndCrash("../z_std_dma.c", 558); } - #endif +#endif } void DmaMgr_ThreadEntry(void* a0) { - #if 0 +#if 0 OSMesg msg; DmaRequest* req; @@ -188,12 +188,12 @@ void DmaMgr_ThreadEntry(void* a0) { osSendMesg(req->notifyQueue, req->notifyMsg, OS_MESG_NOBLOCK); } } - #endif +#endif } s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* queue, OSMesg msg) { - #if 0 +#if 0 if (gIrqMgrResetStatus >= 2) { return -2; } @@ -206,12 +206,12 @@ s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromS request->notifyMsg = msg; osSendMesg(&sDmaMgrMsgQueue, OS_MESG_PTR(request), OS_MESG_BLOCK); - #endif +#endif return 0; } s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { - #if 0 +#if 0 DmaRequest req; OSMesgQueue queue; OSMesg msg[1]; @@ -226,12 +226,12 @@ s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size) { } else { osRecvMesg(&queue, NULL, OS_MESG_BLOCK); } - #endif +#endif return 0; } void DmaMgr_Start(void) { - #if 0 +#if 0 DmaMgr_DmaRomToRam(SEGMENT_ROM_START(dmadata), dmadata, SEGMENT_ROM_SIZE(dmadata)); { @@ -252,9 +252,9 @@ void DmaMgr_Start(void) { Z_PRIORITY_DMAMGR); osStartThread(&sDmaMgrThread); - #endif +#endif } void DmaMgr_Stop(void) { - //osSendMesg(&sDmaMgrMsgQueue, OS_MESG_PTR(NULL), OS_MESG_BLOCK); + // osSendMesg(&sDmaMgrMsgQueue, OS_MESG_PTR(NULL), OS_MESG_BLOCK); } diff --git a/mm/src/buffers/heaps.c b/mm/src/buffers/heaps.c index 5ee423c4b..7fdae8aca 100644 --- a/mm/src/buffers/heaps.c +++ b/mm/src/buffers/heaps.c @@ -5,7 +5,6 @@ #include #endif - u8* gAudioHeap; u8* gSystemHeap; diff --git a/mm/src/code/c_keyframe.c b/mm/src/code/c_keyframe.c index 6ae56e54d..e2eb41772 100644 --- a/mm/src/code/c_keyframe.c +++ b/mm/src/code/c_keyframe.c @@ -134,7 +134,7 @@ void Keyframe_InitFlex(KFSkelAnimeFlex* kfSkelAnime, KeyFrameSkeleton* skeleton, if (ResourceMgr_OTRSigCheck(anim)) { anim = (KeyFrameAnimation*)ResourceMgr_LoadKeyFrameAnimByName(animation); } - + kfSkelAnime->skeleton = skel; kfSkelAnime->animation = anim; kfSkelAnime->jointTable = jointTable; @@ -648,7 +648,7 @@ void Keyframe_StandardChangeAnimQuick(KFSkelAnime* kfSkelAnime, KeyFrameAnimatio if (ResourceMgr_OTRSigCheck(animation)) { animation = ResourceMgr_LoadKeyFrameAnimByName(animation); } - + kfSkelAnime->animation = animation; kfSkelAnime->frameCtrl.duration = kfSkelAnime->animation->duration; } diff --git a/mm/src/code/graph.c b/mm/src/code/graph.c index a0694784a..731a0ec0c 100644 --- a/mm/src/code/graph.c +++ b/mm/src/code/graph.c @@ -181,7 +181,7 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { task->ucode_boot = SysUcode_GetUCodeBoot(); task->ucode_boot_size = SysUcode_GetUCodeBootSize(); task->ucode = SysUcode_GetUCode(); - //task->ucode_data = SysUcode_GetUCodeData(); + // task->ucode_data = SysUcode_GetUCodeData(); task->ucode_size = SP_UCODE_SIZE; task->ucode_data_size = SP_UCODE_DATA_SIZE; task->dram_stack = (u64*)gGfxSPTaskStack; diff --git a/mm/src/code/object_table.c b/mm/src/code/object_table.c index 6d28be247..f342ef67f 100644 --- a/mm/src/code/object_table.c +++ b/mm/src/code/object_table.c @@ -11,7 +11,7 @@ s16 gPlayerFormObjectIds[PLAYER_FORM_MAX] = { ObjectId gObjectTableSize = OBJECT_ID_MAX; // Object Table definition -#define DEFINE_OBJECT(name, _1) { 0, 0, #name}, +#define DEFINE_OBJECT(name, _1) { 0, 0, #name }, #define DEFINE_OBJECT_NULL(name, _1) ROM_FILE(name), #define DEFINE_OBJECT_UNSET(_0) { 0, 0, "" }, #define DEFINE_OBJECT_SIZE_ZERO(name, x) DEFINE_OBJECT_UNSET(aa) diff --git a/mm/src/code/padmgr.c b/mm/src/code/padmgr.c index 61a94e206..1beb8bfea 100644 --- a/mm/src/code/padmgr.c +++ b/mm/src/code/padmgr.c @@ -37,7 +37,7 @@ #include "fault.h" #include #include -//extern FaultMgr gFaultMgr; +// extern FaultMgr gFaultMgr; #define PADMGR_RETRACE_MSG (1 << 0) #define PADMGR_PRE_NMI_MSG (1 << 1) @@ -356,10 +356,10 @@ void PadMgr_AdjustInput(Input* input) { // BENTODO: Do we need controller reset logic? if (/* CHECK_BTN_ANY(input->press.button, BTN_RESET) || */ (input->press.stick_x == 0)) { - input->press.stick_x = 61; - input->press.err_no = -61; - input->press.stick_y = 63; - input->rel.err_no = -63; + input->press.stick_x = 61; + input->press.err_no = -61; + input->press.stick_y = 63; + input->rel.err_no = -63; } pressX = input->press.stick_x; pressX2 = (s8)input->press.err_no; diff --git a/mm/src/code/sched.c b/mm/src/code/sched.c index 08cfb476e..3d4d15c55 100644 --- a/mm/src/code/sched.c +++ b/mm/src/code/sched.c @@ -133,7 +133,7 @@ void Sched_HandleAudioCancel(SchedContext* sched) { * an RDP_DONE_MSG back to itself. */ void Sched_HandleGfxCancel(SchedContext* sched) { - #if 0 +#if 0 s32 i; // GRAPH SP Cancel @@ -195,7 +195,7 @@ void Sched_HandleGfxCancel(SchedContext* sched) { osSendMesg(&sched->interruptQ, (OSMesg)RDP_DONE_MSG, OS_MESG_NOBLOCK); } } - #endif +#endif } /** @@ -370,7 +370,7 @@ void Sched_RunTask(SchedContext* sched, OSScTask* spTask, OSScTask* dpTask) { * Enqueues any tasks that have been sent to the scheduler down the command queue. */ void Sched_HandleEntry(SchedContext* sched) { - #if 0 +#if 0 OSScTask* spTask = NULL; OSScTask* dpTask = NULL; OSMesg msg = NULL; @@ -390,7 +390,7 @@ void Sched_HandleEntry(SchedContext* sched) { if (Sched_Schedule(sched, &spTask, &dpTask, state) != state) { Sched_RunTask(sched, spTask, dpTask); } - #endif +#endif } void Sched_HandleRetrace(SchedContext* sched) { @@ -562,7 +562,8 @@ void Sched_FaultClient(void* param1, void* param2) { * threads or the OS. */ void Sched_ThreadEntry(void* arg) { - OSMesg msg = OS_MESG_PTR(NULL);; + OSMesg msg = OS_MESG_PTR(NULL); + ; SchedContext* sched = (SchedContext*)arg; while (true) { diff --git a/mm/src/code/stubs.c b/mm/src/code/stubs.c index e2e894568..a40bb8e83 100644 --- a/mm/src/code/stubs.c +++ b/mm/src/code/stubs.c @@ -70,18 +70,18 @@ GfxMasterList D_0E000000; Mtx D_01000000; u16 D_0F000000[SCREEN_WIDTH * SCREEN_HEIGHT]; -//u64 gspS2DEX_fifoTextStart[1], gspS2DEX_fifoTextEnd[1]; -//u64 gspS2DEX_fifoDataStart[1], gspS2DEX_fifoDataEnd[1]; -//u64 gspS2DEX_fifo_dTextStart[1], gspS2DEX_fifo_dTextEnd[1]; -//u64 gspS2DEX_fifo_dDataStart[1], gspS2DEX_fifo_dDataEnd[1]; -//u64 gspS2DEX2_fifoTextStart[1], gspS2DEX2_fifoTextEnd[1]; -//u64 gspS2DEX2_fifoDataStart[1], gspS2DEX2_fifoDataEnd[1]; -//u64 gspS2DEX2_xbusTextStart[1], gspS2DEX2_xbusTextEnd[1]; -//u64 gspS2DEX2_xbusDataStart[1], gspS2DEX2_xbusDataEnd[1]; -//u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[1]; -//u64 gspF3DZEX2_NoN_PosLight_fifoTextEnd[1]; -//u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[1]; -//u64 gspF3DZEX2_NoN_PosLight_fifoDataEnd[1]; +// u64 gspS2DEX_fifoTextStart[1], gspS2DEX_fifoTextEnd[1]; +// u64 gspS2DEX_fifoDataStart[1], gspS2DEX_fifoDataEnd[1]; +// u64 gspS2DEX_fifo_dTextStart[1], gspS2DEX_fifo_dTextEnd[1]; +// u64 gspS2DEX_fifo_dDataStart[1], gspS2DEX_fifo_dDataEnd[1]; +// u64 gspS2DEX2_fifoTextStart[1], gspS2DEX2_fifoTextEnd[1]; +// u64 gspS2DEX2_fifoDataStart[1], gspS2DEX2_fifoDataEnd[1]; +// u64 gspS2DEX2_xbusTextStart[1], gspS2DEX2_xbusTextEnd[1]; +// u64 gspS2DEX2_xbusDataStart[1], gspS2DEX2_xbusDataEnd[1]; +// u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[1]; +// u64 gspF3DZEX2_NoN_PosLight_fifoTextEnd[1]; +// u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[1]; +// u64 gspF3DZEX2_NoN_PosLight_fifoDataEnd[1]; Vec3f gZeroVec3f; Vec3s gZeroVec3s; @@ -146,7 +146,6 @@ void osSetUpMempakWrite(s32 channel, OSPifRam* buf) { } void osUnmapTLBAll(void) { - } int ResourceMgr_OTRSigCheck(char* imgData); @@ -643,7 +642,7 @@ void guOrtho(Mtx* m, float l, float r, float b, float t, float n, float f, float FrameInterpolation_RecordOpenChild("ortho", 0); Matrix_MtxFToMtx((MtxF*)mf, m); FrameInterpolation_RecordCloseChild(); - //guMtxF2L(mf, m); + // guMtxF2L(mf, m); } #define GU_PI 3.1415926 @@ -687,8 +686,8 @@ void guPerspective(Mtx* m, u16* perspNorm, float fovy, float aspect, float near, guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale); Matrix_MtxFToMtx((MtxF*)mf, m); - //guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale); - //guMtxF2L(mf, m); + // guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale); + // guMtxF2L(mf, m); } #include "global.h" @@ -754,7 +753,7 @@ void guLookAt(Mtx* m, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); Matrix_MtxFToMtx((MtxF*)mf, m); - //guMtxF2L(mf, m); + // guMtxF2L(mf, m); } void guRotateF(float m[4][4], float a, float x, float y, float z) { static float D_80097F90 = M_PI / 180.0f; @@ -799,7 +798,6 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) { m[0][1] = ab + zs; } - void guRotate(Mtx* m, float a, float x, float y, float z) { float mf[4][4]; guRotateF(mf, a, x, y, z); diff --git a/mm/src/code/su_mtx.c b/mm/src/code/su_mtx.c index fe8525969..93587f943 100644 --- a/mm/src/code/su_mtx.c +++ b/mm/src/code/su_mtx.c @@ -78,12 +78,9 @@ void Mtx_SetTranslateScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, f32 translateZ) { // #region 2S2H [Port] For compatibility with modern systems this has been changed to use guMtxF2L - MtxF mtxf = { { - { scaleX, 0, 0, 0 }, - { 0, scaleY, 0, 0 }, - { 0, 0, scaleZ, 0 }, - { translateX, translateY, translateZ, 1 } - } }; + MtxF mtxf = { + { { scaleX, 0, 0, 0 }, { 0, scaleY, 0, 0 }, { 0, 0, scaleZ, 0 }, { translateX, translateY, translateZ, 1 } } + }; guMtxF2L(&mtxf, mtx); } diff --git a/mm/src/code/sys_cfb.c b/mm/src/code/sys_cfb.c index 067231034..0dc170cbd 100644 --- a/mm/src/code/sys_cfb.c +++ b/mm/src/code/sys_cfb.c @@ -60,7 +60,7 @@ void SysCfb_SetLoResMode(void) { gSysCfbHiResEnabled = false; gScreenWidth = gCfbWidth; gScreenHeight = gCfbHeight; - //gActiveViMode = &osViModeNtscLan1; + // gActiveViMode = &osViModeNtscLan1; // 2S2H [Port] Inform LUS on resolution changes GfxSetNativeDimensions((uint32_t)gScreenWidth, (uint32_t)gScreenHeight); diff --git a/mm/src/code/sys_cmpdma.c b/mm/src/code/sys_cmpdma.c index ee5e52616..e7f69ce8e 100644 --- a/mm/src/code/sys_cmpdma.c +++ b/mm/src/code/sys_cmpdma.c @@ -116,5 +116,5 @@ void CmpDma_LoadAllFiles(uintptr_t segmentVrom, void* dst, size_t size) { CmpDma_LoadFileImpl(rom, i, nextDst, 0); nextDst = gYaz0DecompressDstEnd; } - #endif +#endif } diff --git a/mm/src/code/sys_matrix.c b/mm/src/code/sys_matrix.c index a00e6c341..2a13f4125 100644 --- a/mm/src/code/sys_matrix.c +++ b/mm/src/code/sys_matrix.c @@ -1203,7 +1203,7 @@ Mtx* Matrix_ToMtx(Mtx* dest) { FrameInterpolation_RecordMatrixToMtx(dest, __FILE__, __LINE__); guMtxF2L(sCurrentMatrix, dest); return dest; - //return Matrix_MtxFToMtx(sCurrentMatrix, dest); + // return Matrix_MtxFToMtx(sCurrentMatrix, dest); } /** diff --git a/mm/src/code/sys_ucode.c b/mm/src/code/sys_ucode.c index 21c24f0bd..c00ffd897 100644 --- a/mm/src/code/sys_ucode.c +++ b/mm/src/code/sys_ucode.c @@ -6,7 +6,7 @@ #include "public/bridge/gfxbridge.h" UcodeHandlers initialgspUcodeText = ucode_f3dex2; -//u64* initialgspUcodeData = gspF3DZEX2_NoN_PosLight_fifoDataStart; +// u64* initialgspUcodeData = gspF3DZEX2_NoN_PosLight_fifoDataStart; u64* SysUcode_GetUCodeBoot(void) { return rspbootTextStart; @@ -20,6 +20,6 @@ UcodeHandlers SysUcode_GetUCode(void) { return initialgspUcodeText; } -//u64* SysUcode_GetUCodeData(void) { -// return initialgspUcodeData; -//} +// u64* SysUcode_GetUCodeData(void) { +// return initialgspUcodeData; +// } diff --git a/mm/src/code/z_actor.c b/mm/src/code/z_actor.c index 00e7b6758..330ae3b05 100644 --- a/mm/src/code/z_actor.c +++ b/mm/src/code/z_actor.c @@ -70,7 +70,7 @@ void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory) Actor* Actor_RemoveFromCategory(PlayState* play, ActorContext* actorCtx, Actor* actorToRemove); void Actor_PrintLists(ActorContext* actorCtx) { - #if 0 +#if 0 ActorListEntry* actorList = &actorCtx->actorLists[0]; Actor* actor; s32 i; @@ -87,7 +87,7 @@ void Actor_PrintLists(ActorContext* actorCtx) { actor = actor->next; } } - #endif +#endif } void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadowDraw, f32 shadowScale) { @@ -615,7 +615,6 @@ void Target_Draw(TargetContext* targetCtx, PlayState* play) { TatlColor* color = &sTatlColorList[actor->category]; FrameInterpolation_RecordOpenChild(actor, 0); - POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_7); Matrix_Translate(actor->focus.pos.x, actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, @@ -880,10 +879,11 @@ void Flags_SetCollectible(PlayState* play, s32 flag) { } } -// #region 2S2H Originally these flags were all set with macros, for the port we want them to be in functions so we can hook into them +// #region 2S2H Originally these flags were all set with macros, for the port we want them to be in functions so we can +// hook into them void Flags_SetWeekEventReg(s32 flag) { u8 previouslyOff = !CHECK_WEEKEVENTREG(flag); - WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) | ((flag) & 0xFF); + WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) | ((flag)&0xFF); if (previouslyOff) { GameInteractor_ExecuteOnFlagSet(FLAG_WEEK_EVENT_REG, flag); } @@ -891,7 +891,7 @@ void Flags_SetWeekEventReg(s32 flag) { void Flags_ClearWeekEventReg(s32 flag) { u8 previouslyOn = CHECK_WEEKEVENTREG(flag); - WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) & (u8)~((flag) & 0xFF); + WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) & (u8) ~((flag)&0xFF); if (previouslyOn) { GameInteractor_ExecuteOnFlagUnset(FLAG_WEEK_EVENT_REG, flag); } @@ -899,7 +899,7 @@ void Flags_ClearWeekEventReg(s32 flag) { void Flags_SetEventInf(s32 flag) { u8 previouslyOff = !CHECK_EVENTINF(flag); - gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF)); + gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag)&0xF)); if (previouslyOff) { GameInteractor_ExecuteOnFlagSet(FLAG_EVENT_INF, flag); } @@ -907,7 +907,7 @@ void Flags_SetEventInf(s32 flag) { void Flags_ClearEventInf(s32 flag) { u8 previouslyOn = CHECK_EVENTINF(flag); - gSaveContext.eventInf[(flag) >> 4] &= (u8)~(1 << ((flag) & 0xF)); + gSaveContext.eventInf[(flag) >> 4] &= (u8) ~(1 << ((flag)&0xF)); if (previouslyOn) { GameInteractor_ExecuteOnFlagUnset(FLAG_EVENT_INF, flag); } @@ -1951,17 +1951,17 @@ f32 Target_GetAdjustedDistSq(Actor* actor, Player* player, s16 playerShapeYaw) { { SQ(range), (f32)(range) / (leash) } TargetRangeParams gTargetRanges[TARGET_MODE_MAX] = { - TARGET_RANGE(70.0f, 140.0f), // TARGET_MODE_0 - TARGET_RANGE(170.0f, 255.0f), // TARGET_MODE_1 - TARGET_RANGE(280.0f, 5600.0f), // TARGET_MODE_2 - TARGET_RANGE(350.0f, 525.0f), // TARGET_MODE_3 - TARGET_RANGE(700.0f, 1050.0f), // TARGET_MODE_4 - TARGET_RANGE(1000.0f, 1500.0f), // TARGET_MODE_5 - TARGET_RANGE(100.0f, 105.36842f), // TARGET_MODE_6 - TARGET_RANGE(140.0f, 163.33333f), // TARGET_MODE_7 - TARGET_RANGE(240.0f, 576.0f), // TARGET_MODE_8 - TARGET_RANGE(280.0f, 280000.0f), // TARGET_MODE_9 - TARGET_RANGE(2500.0f, 3750.0f), // TARGET_MODE_10 + TARGET_RANGE(70.0f, 140.0f), // TARGET_MODE_0 + TARGET_RANGE(170.0f, 255.0f), // TARGET_MODE_1 + TARGET_RANGE(280.0f, 5600.0f), // TARGET_MODE_2 + TARGET_RANGE(350.0f, 525.0f), // TARGET_MODE_3 + TARGET_RANGE(700.0f, 1050.0f), // TARGET_MODE_4 + TARGET_RANGE(1000.0f, 1500.0f), // TARGET_MODE_5 + TARGET_RANGE(100.0f, 105.36842f), // TARGET_MODE_6 + TARGET_RANGE(140.0f, 163.33333f), // TARGET_MODE_7 + TARGET_RANGE(240.0f, 576.0f), // TARGET_MODE_8 + TARGET_RANGE(280.0f, 280000.0f), // TARGET_MODE_9 + TARGET_RANGE(2500.0f, 3750.0f), // TARGET_MODE_10 }; /** @@ -2517,7 +2517,7 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto Actor_SpawnEntry(actorCtx, actorEntry, play); Target_Init(&actorCtx->targetCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, play); Actor_InitHalfDaysBit(actorCtx); - //Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); + // Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL); Actor_SpawnHorse(play, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first); } @@ -2922,7 +2922,8 @@ void Actor_DrawLensActors(PlayState* play, s32 numLensActors, Actor** lensActors // Remnant of debug dbgVar1 = true; - // BENTODO: Disabling the framebufer effects temporarily for lens actors until we can restore framebuffer effects for real + // BENTODO: Disabling the framebufer effects temporarily for lens actors until we can restore framebuffer effects + // for real dbgVar2 = false; if (dbgVar1) { @@ -3244,7 +3245,7 @@ void Actor_KillAllOnHalfDayChange(PlayState* play, ActorContext* actorCtx) { void Actor_CleanupContext(ActorContext* actorCtx, PlayState* play) { s32 i; - //Fault_RemoveClient(&sActorFaultClient); + // Fault_RemoveClient(&sActorFaultClient); for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { if (i != ACTORCAT_PLAYER) { @@ -3442,7 +3443,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 // for static variable cleanup // if (overlayEntry->vramStart != NULL) { if (true) { - // #endregion + // #endregion overlayEntry->numLoaded++; } @@ -3599,7 +3600,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { // for static variable cleanup // if (overlayEntry->vramStart != NULL) { if (true) { - // #endregion + // #endregion overlayEntry->numLoaded--; Actor_FreeOverlay(overlayEntry); } @@ -4798,7 +4799,6 @@ void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist) { CLOSE_DISPS(play->state.gfxCtx); } - /** * Finds the first actor instance of a specified Id and category within a given range from * an actor if there is one. If the Id provided is -1, this will look for any actor of the diff --git a/mm/src/code/z_camera.c b/mm/src/code/z_camera.c index 2f65c3ea9..8d098c3b2 100644 --- a/mm/src/code/z_camera.c +++ b/mm/src/code/z_camera.c @@ -6058,9 +6058,9 @@ s32 Camera_Demo2(Camera* camera) { CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CDOWN) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CLEFT) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_CRIGHT) || - // #region 2S2H [Dpad] - CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) || - // #endregion + // #region 2S2H [Dpad] + CHECK_BTN_DPAD(CONTROLLER1(&camera->play->state)->press.button) || + // #endregion CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_Z) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_L) || CHECK_BTN_ALL(CONTROLLER1(&camera->play->state)->press.button, BTN_R)) && diff --git a/mm/src/code/z_collision_check.c b/mm/src/code/z_collision_check.c index 1dc4181f8..b3a2723af 100644 --- a/mm/src/code/z_collision_check.c +++ b/mm/src/code/z_collision_check.c @@ -2656,7 +2656,7 @@ void CollisionCheck_AC_SphereVsTris(PlayState* play, CollisionCheckContext* colC * AC overlap check. Calculates the center of each collider element and the point of contact. */ void CollisionCheck_AC_SphereVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) { - + ColliderSphere* at = (ColliderSphere*)colAT; Vec3f hitPos; ColliderQuad* ac = (ColliderQuad*)colAC; diff --git a/mm/src/code/z_demo.c b/mm/src/code/z_demo.c index e15b2f021..700b26a72 100644 --- a/mm/src/code/z_demo.c +++ b/mm/src/code/z_demo.c @@ -1561,7 +1561,8 @@ void Cutscene_HandleEntranceTriggers(PlayState* play) { if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) { scene = play->loadedScene; - if ((scene->titleTextId != 0) && GameInteractor_Should(GI_VB_SHOW_TITLE_CARD, gSaveContext.showTitleCard, NULL)) { + if ((scene->titleTextId != 0) && + GameInteractor_Should(GI_VB_SHOW_TITLE_CARD, gSaveContext.showTitleCard, NULL)) { if ((Entrance_GetTransitionFlags(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer)) & 0x4000) != 0) { @@ -1573,11 +1574,12 @@ void Cutscene_HandleEntranceTriggers(PlayState* play) { } } -// 2S2H [Enhancements] This is equivalent to Cutscene_HandleConditionalTriggers in OoT. It's unused normally, but we -// use it for VB. In VB changing *should to false has no effect, but you instead modify the entrance & cutsceneIndex to +// 2S2H [Enhancements] This is equivalent to Cutscene_HandleConditionalTriggers in OoT. It's unused normally, but we +// use it for VB. In VB changing *should to false has no effect, but you instead modify the entrance & cutsceneIndex to // override the behavior. void func_800EDDB0(PlayState* play) { - LUSLOG_INFO("Cutscene_HandleConditionalTriggers: entrance: %d, cutsceneIndex: 0x%X", gSaveContext.save.entrance, gSaveContext.save.cutsceneIndex); + LUSLOG_INFO("Cutscene_HandleConditionalTriggers: entrance: %d, cutsceneIndex: 0x%X", gSaveContext.save.entrance, + gSaveContext.save.cutsceneIndex); if (!GameInteractor_Should(GI_VB_PLAY_TRANSITION_CS, true, NULL)) { return; diff --git a/mm/src/code/z_eff_shield_particle.c b/mm/src/code/z_eff_shield_particle.c index 759faceb0..75bb03ceb 100644 --- a/mm/src/code/z_eff_shield_particle.c +++ b/mm/src/code/z_eff_shield_particle.c @@ -148,7 +148,7 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) { Color_RGBA8 envColor; FrameInterpolation_RecordOpenChild(this, 0); - + OPEN_DISPS(gfxCtx); if (this != NULL) { diff --git a/mm/src/code/z_fbdemo_circle.c b/mm/src/code/z_fbdemo_circle.c index 0f2168691..22dac2f59 100644 --- a/mm/src/code/z_fbdemo_circle.c +++ b/mm/src/code/z_fbdemo_circle.c @@ -122,7 +122,8 @@ void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, // #region 2S2H [Cosmetic] Adjust circle overlay to support widescreen // The first wide rectangle instruction renders the tile information on the extra space on the left edge // The second instruction renders the original overlay in the center and has it extend to the right edge - // gSPTextureRectangle(gfx++, 0, 0, xh << 2, yh << 2, G_TX_RENDERTILE, (s32)(s * (1 << 5)), (s32)(t * (1 << 5)), dsdx, + // gSPTextureRectangle(gfx++, 0, 0, xh << 2, yh << 2, G_TX_RENDERTILE, (s32)(s * (1 << 5)), (s32)(t * (1 << 5)), + // dsdx, // dtdy); s32 x = OTRGetRectDimensionFromLeftEdge(0) << 2; if (x < 0) { diff --git a/mm/src/code/z_jpeg.c b/mm/src/code/z_jpeg.c index 39c1e5d7f..572f1ee1d 100644 --- a/mm/src/code/z_jpeg.c +++ b/mm/src/code/z_jpeg.c @@ -23,7 +23,7 @@ extern u64 njpgdspMainDataStart[]; * Configures and schedules a JPEG decoder task and waits for it to finish. */ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { - #if 0 +#if 0 static OSTask_t sJpegTask = { M_NJPEGTASK, // type 0, // flags @@ -69,7 +69,7 @@ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { osSendMesg(&gSchedContext.cmdQ, (OSMesg*)&jpegCtx->scTask, OS_MESG_BLOCK); Sched_SendEntryMsg(&gSchedContext); // osScKickEntryMsg osRecvMesg(&jpegCtx->mq, NULL, OS_MESG_BLOCK); - #endif +#endif } /** diff --git a/mm/src/code/z_kaleido_manager.c b/mm/src/code/z_kaleido_manager.c index c36351850..237426242 100644 --- a/mm/src/code/z_kaleido_manager.c +++ b/mm/src/code/z_kaleido_manager.c @@ -88,7 +88,7 @@ void KaleidoManager_Destroy() { void* KaleidoManager_GetRamAddr(void* vram) { return vram; - #if 0 +#if 0 if (gKaleidoMgrCurOvl == NULL) { s32 pad[2]; KaleidoMgrOverlay* ovl = &gKaleidoMgrOverlayTable[0]; @@ -108,5 +108,5 @@ void* KaleidoManager_GetRamAddr(void* vram) { } return (void*)((uintptr_t)vram + gKaleidoMgrCurOvl->offset); - #endif +#endif } diff --git a/mm/src/code/z_kanfont.c b/mm/src/code/z_kanfont.c index a186c84b5..760ffc312 100644 --- a/mm/src/code/z_kanfont.c +++ b/mm/src/code/z_kanfont.c @@ -220,7 +220,8 @@ void Font_LoadOrderedFont(Font* font) { loadOffset = 0; } - // DmaMgr_SendRequest0(writeLocation, (uintptr_t)SEGMENT_ROM_START(nes_font_static) + loadOffset, FONT_CHAR_TEX_SIZE); + // DmaMgr_SendRequest0(writeLocation, (uintptr_t)SEGMENT_ROM_START(nes_font_static) + loadOffset, + // FONT_CHAR_TEX_SIZE); memcpy(writeLocation, fontTbl[loadOffset], strlen(fontTbl[loadOffset]) + 1); // #endregion diff --git a/mm/src/code/z_kankyo.c b/mm/src/code/z_kankyo.c index 9745d5217..f391ff095 100644 --- a/mm/src/code/z_kankyo.c +++ b/mm/src/code/z_kankyo.c @@ -1052,7 +1052,8 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon size = sNormalSkyFiles[skybox1Index].file.vromEnd - sNormalSkyFiles[skybox1Index].file.vromStart; osCreateMesgQueue(&envCtx->loadQueue, envCtx->loadMsg, ARRAY_COUNT(envCtx->loadMsg)); DmaMgr_SendRequestImpl(&envCtx->dmaRequest, skyboxCtx->staticSegments[0], - sNormalSkyFiles[skybox1Index].file.vromStart, size, 0, &envCtx->loadQueue, OS_MESG_PTR(NULL)); + sNormalSkyFiles[skybox1Index].file.vromStart, size, 0, &envCtx->loadQueue, + OS_MESG_PTR(NULL)); envCtx->skybox1Index = skybox1Index; } @@ -1061,7 +1062,8 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon size = sNormalSkyFiles[skybox2Index].file.vromEnd - sNormalSkyFiles[skybox2Index].file.vromStart; osCreateMesgQueue(&envCtx->loadQueue, envCtx->loadMsg, ARRAY_COUNT(envCtx->loadMsg)); DmaMgr_SendRequestImpl(&envCtx->dmaRequest, skyboxCtx->staticSegments[1], - sNormalSkyFiles[skybox2Index].file.vromStart, size, 0, &envCtx->loadQueue, OS_MESG_PTR(NULL)); + sNormalSkyFiles[skybox2Index].file.vromStart, size, 0, &envCtx->loadQueue, + OS_MESG_PTR(NULL)); envCtx->skybox2Index = skybox2Index; } @@ -1783,11 +1785,9 @@ void Environment_DrawSun(PlayState* play) { gSPMatrix(POLY_OPA_DISP++, D_01000000_TO_SEGMENTED, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gDPPipeSync(POLY_OPA_DISP++); gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gSun1Tex, G_IM_FMT_I, 64, 64, 0, G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, - 6, 6, G_TX_NOLOD, G_TX_NOLOD); + G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); gDPLoadMultiBlock_4b(POLY_OPA_DISP++, gSunEvening1Tex, 0x0100, 1, G_IM_FMT_I, 64, 64, 0, - G_TX_NOMIRROR | G_TX_CLAMP, - G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); gSPVertex(POLY_OPA_DISP++, vertices, 4, 0); gSP2Triangles(POLY_OPA_DISP++, 0, 1, 2, 0, 2, 1, 3, 0); // #endregion @@ -2925,17 +2925,15 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) { (u32)sp94 % 4096, 4095 - ((u32)sp92 % 4096), 256, 64)); gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); // #region 2S2H [Widescreen] Widescreen Sandstorm - //gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); // Original Dlist call + // gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); // Original Dlist call gDPPipeSync(POLY_XLU_DISP++); gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_CLD_SURF2); gDPSetCombineLERP(POLY_XLU_DISP++, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, ENVIRONMENT, TEXEL0, - PRIMITIVE, - ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0); + PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR); gDPLoadTextureBlock(POLY_XLU_DISP++, gFieldSandstorm1Tex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, - G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, 6, 5, 1, G_TX_NOLOD); + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 6, 5, 1, G_TX_NOLOD); gDPLoadMultiBlock(POLY_XLU_DISP++, gFieldSandstorm2Tex, 0x0100, 1, G_IM_FMT_IA, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 6, 5, 2, 1); gSPDisplayList(POLY_XLU_DISP++, 0x08000000 | 1); @@ -2943,7 +2941,7 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) { OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) << 2, SCREEN_HEIGHT << 2, G_TX_RENDERTILE, 0, 0, 0x008C, -0x008C); // #endregion - + CLOSE_DISPS(play->state.gfxCtx); } @@ -3167,7 +3165,8 @@ void Environment_DrawSkyboxStarsImpl(PlayState* play, Gfx** gfxP) { { 65, 164, 255, 255 }, { 131, 164, 230, 255 }, { 98, 205, 255, 255 }, { 82, 82, 255, 255 }, { 123, 164, 164, 255 }, { 98, 205, 255, 255 }, { 98, 164, 230, 255 }, { 255, 90, 0, 255 }, }; - // 2S2H [Port] This originally had `UNALIGNED` however we don't need that for PC and it was causing warnings in the header file + // 2S2H [Port] This originally had `UNALIGNED` however we don't need that for PC and it was causing warnings in the + // header file static const Color_RGBA8_u32 D_801DD900[] = { { 64, 80, 112, 255 }, { 96, 96, 128, 255 }, { 128, 112, 144, 255 }, { 160, 128, 160, 255 }, { 192, 144, 168, 255 }, { 224, 160, 176, 255 }, { 224, 160, 176, 255 }, { 104, 104, 136, 255 }, @@ -3305,8 +3304,9 @@ void Environment_DrawSkyboxStarsImpl(PlayState* play, Gfx** gfxP) { (f32)(OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) - (SCREEN_WIDTH / 2)) / (SCREEN_WIDTH / 2); } - if ((scale >= 1.0f) && (imgX > -adjustedXBounds) && (imgX < adjustedXBounds) && (imgY > -1.0f) && (imgY < 1.0f)) { - // #endregion + if ((scale >= 1.0f) && (imgX > -adjustedXBounds) && (imgX < adjustedXBounds) && (imgY > -1.0f) && + (imgY < 1.0f)) { + // #endregion imgX = (imgX * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2); imgY = (imgY * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2); diff --git a/mm/src/code/z_lifemeter.c b/mm/src/code/z_lifemeter.c index e2fd7e121..8f6de0c4a 100644 --- a/mm/src/code/z_lifemeter.c +++ b/mm/src/code/z_lifemeter.c @@ -365,7 +365,8 @@ void LifeMeter_Draw(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_HEARTS); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -380,15 +381,14 @@ void LifeMeter_Draw(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { gSPTextureRectangle(OVERLAY_DISP++, (s32)((posX - halfTexSize) * 4), (s32)((posY - halfTexSize) * 4), - (s32)((posX + halfTexSize) * 4), (s32)((posY + halfTexSize) * 4), G_TX_RENDERTILE, 0, 0, - (s32)temp_f4, (s32)temp_f4); + (s32)((posX + halfTexSize) * 4), (s32)((posY + halfTexSize) * 4), G_TX_RENDERTILE, + 0, 0, (s32)temp_f4, (s32)temp_f4); } } else { Mtx* mtx; @@ -414,7 +414,8 @@ void LifeMeter_Draw(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_HEARTS); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; Mtx_SetTranslateScaleMtx(mtx, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } else { @@ -429,7 +430,7 @@ void LifeMeter_Draw(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; Mtx_SetTranslateScaleMtx(mtx, size, size, size, transX, transY, 0.0f); } - // #endregion + // #endregion } else { Mtx_SetTranslateScaleMtx(mtx, 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), -130.0f + offsetX, 94.5f - offsetY, 0.0f); diff --git a/mm/src/code/z_map_disp.c b/mm/src/code/z_map_disp.c index 23b389221..e601e00a2 100644 --- a/mm/src/code/z_map_disp.c +++ b/mm/src/code/z_map_disp.c @@ -66,7 +66,7 @@ static const u32 sLoadTextureBlock_siz_LINE_BYTES[4] = { ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ }) -//static const UNK_TYPE4 D_801BEB30[2] = { 0, 0 }; +// static const UNK_TYPE4 D_801BEB30[2] = { 0, 0 }; static const u64 sWhiteSquareTex[] = { 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, @@ -89,7 +89,7 @@ static MapDataScene sMapDataScene = { static s32 sSceneNumRooms = 0; // current scene's no. of rooms -static s32 sNumChests = 0; // MinimapChest count +static s32 sNumChests = 0; // MinimapChest count static TransitionActorList sTransitionActorList = { 0, NULL }; @@ -163,7 +163,7 @@ void MapDisp_GetMapITexture(void* dst, s32 mapCompactId) { if (mapSize != 0) { void* data = ResourceMgr_LoadTexOrDListByName(sMapTextures[mapCompactId]); memcpy(dst, data, mapSize); - //CmpDma_LoadFile(SEGMENT_ROM_START(map_i_static), mapCompactId, dst, MapDisp_GetSizeOfMapITex(mapCompactId)); + // CmpDma_LoadFile(SEGMENT_ROM_START(map_i_static), mapCompactId, dst, MapDisp_GetSizeOfMapITex(mapCompactId)); } } @@ -423,7 +423,7 @@ void MapDisp_Minimap_DrawActorIcon(PlayState* play, Actor* actor) { s16 dtdy = 512; if (HudEditor_ShouldOverrideDraw()) { HudEditor_ModifyDrawValuesFromBase(sMapDisp.minimapCurX, sMapDisp.minimapCurY, &posX, &posY, &squareWidth, - &squareHeight, &dsdx, &dtdy); + &squareHeight, &dsdx, &dtdy); // Texture rectangles can't be smaller than 1 unit squareWidth = MAX(squareWidth, 1); squareHeight = MAX(squareHeight, 1); @@ -1142,23 +1142,23 @@ void MapDisp_SwapRooms(s16 nextRoom) { prevOffsetY *= elemScale; sMapDisp.minimapPrevX = TRUNCF_BINANG( - ((f32)offsetX + - (((f32)prevMapDataRoom->centerX - (f32)nextMapDataRoom->centerX) * (1.0f / scale) * elemScale)) - + ((f32)offsetX + (((f32)prevMapDataRoom->centerX - (f32)nextMapDataRoom->centerX) * + (1.0f / scale) * elemScale)) - (f32)prevOffsetX); sMapDisp.minimapPrevY = TRUNCF_BINANG( - ((f32)offsetY + - (((f32)prevMapDataRoom->centerZ - (f32)nextMapDataRoom->centerZ) * (1.0f / scale) * elemScale)) - + ((f32)offsetY + (((f32)prevMapDataRoom->centerZ - (f32)nextMapDataRoom->centerZ) * + (1.0f / scale) * elemScale)) - (f32)prevOffsetY); } else { // #endregion - sMapDisp.minimapPrevX = - TRUNCF_BINANG(((f32)offsetX + (((f32)prevMapDataRoom->centerX - (f32)nextMapDataRoom->centerX) * - (1.0f / scale))) - - (f32)prevOffsetX); - sMapDisp.minimapPrevY = - TRUNCF_BINANG(((f32)offsetY + (((f32)prevMapDataRoom->centerZ - (f32)nextMapDataRoom->centerZ) * - (1.0f / scale))) - - (f32)prevOffsetY); + sMapDisp.minimapPrevX = TRUNCF_BINANG( + ((f32)offsetX + + (((f32)prevMapDataRoom->centerX - (f32)nextMapDataRoom->centerX) * (1.0f / scale))) - + (f32)prevOffsetX); + sMapDisp.minimapPrevY = TRUNCF_BINANG( + ((f32)offsetY + + (((f32)prevMapDataRoom->centerZ - (f32)nextMapDataRoom->centerZ) * (1.0f / scale))) - + (f32)prevOffsetY); } sMapDisp.minimapCurX = minimapBaseX - sMapDisp.minimapPrevX; @@ -1187,9 +1187,10 @@ void MapDisp_SwapRooms(s16 nextRoom) { if (MapData_GetSizeOfMapGrandTex(nextMapDataRoom->mapId) != 0) { sMapDisp.minimapCurTex = ResourceMgr_LoadTexOrDListByName( sMapGrandTextures[MAPDATA_GET_MAP_GRAND_ID_FROM_MAP_ID(nextMapDataRoom->mapId)]); - //CmpDma_LoadFile(SEGMENT_ROM_START(map_grand_static), - // MAPDATA_GET_MAP_GRAND_ID_FROM_MAP_ID(nextMapDataRoom->mapId), - // sMapDisp.minimapCurTex, MapData_GetSizeOfMapGrandTex(nextMapDataRoom->mapId)); + // CmpDma_LoadFile(SEGMENT_ROM_START(map_grand_static), + // MAPDATA_GET_MAP_GRAND_ID_FROM_MAP_ID(nextMapDataRoom->mapId), + // sMapDisp.minimapCurTex, + // MapData_GetSizeOfMapGrandTex(nextMapDataRoom->mapId)); } break; diff --git a/mm/src/code/z_message.c b/mm/src/code/z_message.c index 0c2ed349a..d871049d0 100644 --- a/mm/src/code/z_message.c +++ b/mm/src/code/z_message.c @@ -44,28 +44,15 @@ const char* gBombersNotebookPhotos[] = { }; const char* gQuestIcons[] = { - gQuestIconGoldSkulltulaTex, - gQuestIconHeartContainerTex, - gQuestIconPieceOfHeartTex, - gQuestIconPieceOfHeart2Tex, - gQuestIconHeartContainer2Tex, - gQuestIconHeartContainer3Tex, - gQuestIconBossKeyTex, - gQuestIconCompassTex, - gQuestIconDungeonMapTex, - gQuestIconGoldSkulltula2Tex, - gQuestIconSmallKeyTex, - gQuestIconSmallMagicJarTex, - gQuestIconBigMagicJarTex, - gQuestIconLinkHumanFaceTex, + gQuestIconGoldSkulltulaTex, gQuestIconHeartContainerTex, gQuestIconPieceOfHeartTex, gQuestIconPieceOfHeart2Tex, + gQuestIconHeartContainer2Tex, gQuestIconHeartContainer3Tex, gQuestIconBossKeyTex, gQuestIconCompassTex, + gQuestIconDungeonMapTex, gQuestIconGoldSkulltula2Tex, gQuestIconSmallKeyTex, gQuestIconSmallMagicJarTex, + gQuestIconBigMagicJarTex, gQuestIconLinkHumanFaceTex, }; const char* gMessageBackgrounds[] = { - gMessageDefaultBackgroundTex, - gMessageSignBackgroundTex, - gMessageNoteStaffBackgroundTex, - gMessageFadingBackgroundTex, - gMessageNotebookBackgroundTex, + gMessageDefaultBackgroundTex, gMessageSignBackgroundTex, gMessageNoteStaffBackgroundTex, + gMessageFadingBackgroundTex, gMessageNotebookBackgroundTex, }; // This looks very similar to gItemIcons, but it's not the same! Make sure you're using the @@ -316,7 +303,8 @@ s32 Message_ShouldAdvance(PlayState* play) { Audio_PlaySfx(NA_SE_SY_MESSAGE_PASS); } return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || - // 2S2H [Enhancement] When fast text is on, we want to check if B is held instead of only if it was just pressed + // 2S2H [Enhancement] When fast text is on, we want to check if B is held instead of only if it was just + // pressed (CVarGetInteger("gEnhancements.Dialogue.FastText", 0) && CHECK_BTN_ALL(controller->cur.button, BTN_B)) || CHECK_BTN_ALL(controller->press.button, BTN_CUP); } @@ -330,7 +318,8 @@ s32 Message_ShouldAdvanceSilent(PlayState* play) { return CHECK_BTN_ALL(controller->press.button, BTN_A); } else { return CHECK_BTN_ALL(controller->press.button, BTN_A) || CHECK_BTN_ALL(controller->press.button, BTN_B) || - // 2S2H [Enhancement] When fast text is on, we want to check if B is held instead of only if it was just pressed + // 2S2H [Enhancement] When fast text is on, we want to check if B is held instead of only if it was just + // pressed (CVarGetInteger("gEnhancements.Dialogue.FastText", 0) && CHECK_BTN_ALL(controller->cur.button, BTN_B)) || CHECK_BTN_ALL(controller->press.button, BTN_CUP); } @@ -2031,14 +2020,16 @@ void Message_LoadItemIcon(PlayState* play, u16 itemId, s16 arg2) { msgCtx->unk12010 = (msgCtx->unk11FF8 - D_801CFF70[gSaveContext.options.language]); msgCtx->unk12012 = (arg2 + 8); msgCtx->unk12014 = 0x20; - // CmpDma_LoadFile(SEGMENT_ROM_START(schedule_dma_static_yar), ITEM_POTION_BLUE, msgCtx->textboxSegment + 0x1000, + // CmpDma_LoadFile(SEGMENT_ROM_START(schedule_dma_static_yar), ITEM_POTION_BLUE, msgCtx->textboxSegment + + // 0x1000, // 0x400); msgCtx->textboxSegment[TEXTBOX_SEG_ICON] = gBombersNotebookPhotos[ITEM_POTION_BLUE]; } else if (itemId >= ITEM_B8) { msgCtx->unk12010 = (msgCtx->unk11FF8 - D_801CFF70[gSaveContext.options.language]); msgCtx->unk12012 = (arg2 + 8); msgCtx->unk12014 = 0x20; - // CmpDma_LoadFile(SEGMENT_ROM_START(schedule_dma_static_yar), (itemId - ITEM_B8), msgCtx->textboxSegment + 0x1000, + // CmpDma_LoadFile(SEGMENT_ROM_START(schedule_dma_static_yar), (itemId - ITEM_B8), msgCtx->textboxSegment + + // 0x1000, // 0x800); msgCtx->textboxSegment[TEXTBOX_SEG_ICON] = gBombersNotebookPhotos[itemId - ITEM_B8]; } else if (itemId >= ITEM_SKULL_TOKEN) { @@ -2148,7 +2139,8 @@ void Message_SetupLoadItemIcon(PlayState* play) { msgCtx->msgBufPos += 2; } else { msgCtx->msgBufPos += 2; - if ((((u8)font->msgBuf.schar[msgCtx->msgBufPos]) < 0xC8) || (((u8)font->msgBuf.schar[msgCtx->msgBufPos]) >= 0xD8)) { + if ((((u8)font->msgBuf.schar[msgCtx->msgBufPos]) < 0xC8) || + (((u8)font->msgBuf.schar[msgCtx->msgBufPos]) >= 0xD8)) { msgCtx->itemId = D_801CFF94[(u8)font->msgBuf.schar[msgCtx->msgBufPos]]; } else { msgCtx->itemId = 0xFE; @@ -2357,7 +2349,7 @@ void Message_Decode(PlayState* play) { u16 curChar; u8 index2 = 0; - //BENTODO do this somewhere else + // BENTODO do this somewhere else gSaveContext.options.language = LANGUAGE_ENG; msgCtx->textDelayTimer = 0; @@ -2456,9 +2448,10 @@ void Message_Decode(PlayState* play) { spC0 += playerNameLen * (16.0f * msgCtx->textCharScale); } else if (curChar == 0x201) { // #region 2S2H [Port] - //DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1000, SEGMENT_ROM_START(message_texture_static), 0x900); - //DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1900, SEGMENT_ROM_START(message_texture_static) + 0x900, - // 0x900); + // DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1000, SEGMENT_ROM_START(message_texture_static), + // 0x900); DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1900, + // SEGMENT_ROM_START(message_texture_static) + 0x900, + // 0x900); msgCtx->textboxSegment[TEXTBOX_SEG_BG_1] = gMessageXLeftTex; msgCtx->textboxSegment[TEXTBOX_SEG_BG_2] = gMessageXRightTex; // #endregion @@ -3234,7 +3227,7 @@ void func_80150A84(PlayState* play) { if (D_801CFC78[textBoxType] != 14) { // #region 2S2H [Port] - //DmaMgr_SendRequest0(msgCtx->textboxSegment, + // DmaMgr_SendRequest0(msgCtx->textboxSegment, // SEGMENT_ROM_START(message_static) + D_801CFC78[textBoxType] * 0x1000, 0x1000); msgCtx->textboxSegment[TEXTBOX_SEG_TYPE] = gMessageBackgrounds[D_801CFC78[textBoxType]]; // #endregion @@ -3371,21 +3364,21 @@ void Message_OpenText(PlayState* play, u16 textId) { MessageTableEntry* msgEntry = (MessageTableEntry*)font->messageStart; msgCtx->msgLength = msgEntry->msgSize; memcpy(&font->msgBuf, msgEntry->segment, msgEntry->msgSize); - //DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(staff_message_data_static) + font->messageStart, - // font->messageEnd); + // DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(staff_message_data_static) + font->messageStart, + // font->messageEnd); } else if (gSaveContext.options.language == LANGUAGE_JPN) { Message_FindMessage(play, textId); msgCtx->msgLength = font->messageEnd; - //DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, - // font->messageEnd); + // DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, + // font->messageEnd); } else { Message_FindMessageNES(play, textId); MessageTableEntry* msgEntry = (MessageTableEntry*)font->messageStart; msgCtx->msgLength = msgEntry->msgSize; memcpy(&font->msgBuf, msgEntry->segment, msgEntry->msgSize); - //msgCtx->msgLength = font->messageEnd; - //DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, - // font->messageEnd); + // msgCtx->msgLength = font->messageEnd; + // DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, + // font->messageEnd); } msgCtx->choiceNum = 0; @@ -3476,17 +3469,17 @@ void func_801514B0(PlayState* play, u16 arg1, u8 arg2) { Message_FindMessage(play, arg1); msgCtx->msgLength = font->messageEnd; // BENTODO - //DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, + // DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, // font->messageEnd); } else { Message_FindMessageNES(play, arg1); MessageTableEntry* msgEntry = (MessageTableEntry*)font->messageStart; msgCtx->msgLength = msgEntry->msgSize; memcpy(&font->msgBuf, msgEntry->segment, msgEntry->msgSize); - //msgCtx->msgLength = font->messageEnd; - // BENTODO - //DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, - // font->messageEnd); + // msgCtx->msgLength = font->messageEnd; + // BENTODO + // DmaMgr_SendRequest0(&font->msgBuf, SEGMENT_ROM_START(message_data_static) + font->messageStart, + // font->messageEnd); } msgCtx->choiceNum = 0; msgCtx->textUnskippable = false; @@ -3501,7 +3494,7 @@ void func_801514B0(PlayState* play, u16 arg1, u8 arg2) { msgCtx->unk11F0C = msgCtx->unk11F08 & 0xF; msgCtx->textUnskippable = true; // #region 2S2H [Port] - //DmaMgr_SendRequest0(msgCtx->textboxSegment, SEGMENT_ROM_START(message_static) + (D_801CFC78[0] << 12), 0x1000); + // DmaMgr_SendRequest0(msgCtx->textboxSegment, SEGMENT_ROM_START(message_static) + (D_801CFC78[0] << 12), 0x1000); msgCtx->textboxSegment[TEXTBOX_SEG_TYPE] = gMessageBackgrounds[D_801CFC78[0]]; // #endregion msgCtx->textboxColorRed = 0; @@ -3908,8 +3901,9 @@ void Message_DrawTextBox(PlayState* play, Gfx** gfxP) { if (((u32)msgCtx->textBoxType == TEXTBOX_TYPE_0) || (msgCtx->textBoxType == TEXTBOX_TYPE_2) || (msgCtx->textBoxType == TEXTBOX_TYPE_6) || (msgCtx->textBoxType == TEXTBOX_TYPE_8) || (msgCtx->textBoxType == TEXTBOX_TYPE_9) || (msgCtx->textBoxType == TEXTBOX_TYPE_A)) { - gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment[TEXTBOX_SEG_TYPE], G_IM_FMT_I, 128, 64, 0, G_TX_MIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, 7, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment[TEXTBOX_SEG_TYPE], G_IM_FMT_I, 128, 64, 0, + G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 7, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); } else { gDPPipeSync(gfx++); @@ -3920,8 +3914,9 @@ void Message_DrawTextBox(PlayState* play, Gfx** gfxP) { } else { gDPSetEnvColor(gfx++, 50, 20, 0, 255); } - gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment[TEXTBOX_SEG_TYPE], G_IM_FMT_IA, 128, 64, 0, G_TX_MIRROR | G_TX_WRAP, - G_TX_MIRROR | G_TX_WRAP, 7, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment[TEXTBOX_SEG_TYPE], G_IM_FMT_IA, 128, 64, 0, + G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, 7, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); } if (msgCtx->textBoxType == TEXTBOX_TYPE_A) { @@ -4298,7 +4293,9 @@ void Message_DrawSceneTitleCard(PlayState* play, Gfx** gfxP) { // gSPTextureRectangle(gfx++, 0, XREG(77) << 2, 320 << 2, (XREG(77) + XREG(76)) << 2, G_TX_RENDERTILE, 0, 0, 204, // 1 << 10); f32 tileOffset = 204.0f / ((320.0f + (OTRGetDimensionFromRightEdge(0) * 2.0f)) / 320.0f); - gSPWideTextureRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0) << 2, XREG(77) << 2, OTRGetRectDimensionFromRightEdge(320) << 2, (XREG(77) + XREG(76)) << 2, G_TX_RENDERTILE, 8, 0, (u32)tileOffset - 1, 1 << 10); + gSPWideTextureRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0) << 2, XREG(77) << 2, + OTRGetRectDimensionFromRightEdge(320) << 2, (XREG(77) + XREG(76)) << 2, G_TX_RENDERTILE, 8, + 0, (u32)tileOffset - 1, 1 << 10); // #endregion gDPPipeSync(gfx++); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); @@ -4593,7 +4590,8 @@ void Message_DrawMain(PlayState* play, Gfx** gfxP) { AudioOcarina_SetOcarinaDisableTimer(0, 20); Message_CloseTextbox(play); play->msgCtx.ocarinaMode = OCARINA_MODE_PLAYED_FULL_EVAN_SONG; - } else if (GameInteractor_Should(GI_VB_SONG_AVAILABLE_TO_PLAY, vanillaOwnedSongCheck, &msgCtx->ocarinaStaff->state)) { + } else if (GameInteractor_Should(GI_VB_SONG_AVAILABLE_TO_PLAY, vanillaOwnedSongCheck, + &msgCtx->ocarinaStaff->state)) { sLastPlayedSong = msgCtx->ocarinaStaff->state; msgCtx->lastPlayedSong = msgCtx->ocarinaStaff->state; msgCtx->songPlayed = msgCtx->ocarinaStaff->state; @@ -5060,7 +5058,7 @@ void Message_DrawMain(PlayState* play, Gfx** gfxP) { msgCtx->msgMode = MSGMODE_SCARECROW_SPAWN_RECORDING_DONE; Audio_PlaySfx(NA_SE_SY_TRE_BOX_APPEAR); memcpy(gSaveContext.save.saveInfo.scarecrowSpawnSong, gScarecrowSpawnSongPtr, - sizeof(gSaveContext.save.saveInfo.scarecrowSpawnSong)); + sizeof(gSaveContext.save.saveInfo.scarecrowSpawnSong)); for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.scarecrowSpawnSong); i++) { // osSyncPrintf("%d, ", gSaveContext.scarecrowSpawnSong[i]); } @@ -5641,11 +5639,12 @@ void Message_Update(PlayState* play) { case MSGMODE_TEXT_DISPLAYING: if (msgCtx->textBoxType != TEXTBOX_TYPE_4) { - if (( - CHECK_BTN_ALL(input->press.button, BTN_B) || - // 2S2H [Enhancement] When fast text is on, we want to check if B is held instead of only if it was just pressed - (CVarGetInteger("gEnhancements.Dialogue.FastText", 0) && CHECK_BTN_ALL(input->cur.button, BTN_B)) - ) && !msgCtx->textUnskippable) { + if ((CHECK_BTN_ALL(input->press.button, BTN_B) || + // 2S2H [Enhancement] When fast text is on, we want to check if B is held instead of only if it was + // just pressed + (CVarGetInteger("gEnhancements.Dialogue.FastText", 0) && + CHECK_BTN_ALL(input->cur.button, BTN_B))) && + !msgCtx->textUnskippable) { msgCtx->textboxSkipped = true; msgCtx->textDrawPos = msgCtx->decodedTextLen; } else if (CHECK_BTN_ALL(input->press.button, BTN_A) && !msgCtx->textUnskippable) { @@ -6217,8 +6216,8 @@ void Message_Update(PlayState* play) { } void Message_SetTables(PlayState* play) { - //play->msgCtx.messageEntryTableNes = D_801C6B98; - //play->msgCtx.messageTableStaff = D_801CFB08; + // play->msgCtx.messageEntryTableNes = D_801C6B98; + // play->msgCtx.messageTableStaff = D_801CFB08; OTRMessage_Init(play); } diff --git a/mm/src/code/z_message_nes.c b/mm/src/code/z_message_nes.c index d1cc054e2..7e6b43852 100644 --- a/mm/src/code/z_message_nes.c +++ b/mm/src/code/z_message_nes.c @@ -35,7 +35,7 @@ void Message_FindMessageNES(PlayState* play, u16 textId) { foundSegment = msgEntry->segment; msgEntry++; nextSegment = msgEntry->segment; - + font->messageStart = foundSegment - segment; font->messageEnd = nextSegment - foundSegment; return; @@ -47,7 +47,7 @@ void Message_FindMessageNES(PlayState* play, u16 textId) { foundSegment = msgEntry->segment; msgEntry++; nextSegment = msgEntry->segment; - // #region 2S2H [Port] This seems to be a fallback if the message isn't found it just + // #region 2S2H [Port] This seems to be a fallback if the message isn't found it just // returns the first message, we still don't need to change the messageStart and messageEnd // font->messageStart = foundSegment - segment; // font->messageEnd = nextSegment - foundSegment; @@ -1102,8 +1102,8 @@ void Message_DecodeNES(PlayState* play) { decodedBufPos--; } else if (curChar == 0xC1) { // #region 2S2H [Port] - //DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1000, SEGMENT_ROM_START(message_texture_static), 0x900); - //DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1900, SEGMENT_ROM_START(message_texture_static) + 0x900, + // DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1000, SEGMENT_ROM_START(message_texture_static), 0x900); + // DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1900, SEGMENT_ROM_START(message_texture_static) + 0x900, // 0x900); msgCtx->textboxSegment[TEXTBOX_SEG_BG_1] = gMessageXLeftTex; msgCtx->textboxSegment[TEXTBOX_SEG_BG_2] = gMessageXRightTex; diff --git a/mm/src/code/z_overlay.c b/mm/src/code/z_overlay.c index b24a807fd..b77b98ff3 100644 --- a/mm/src/code/z_overlay.c +++ b/mm/src/code/z_overlay.c @@ -36,7 +36,7 @@ s32 TransitionOverlay_Load(TransitionOverlay* overlayEntry) { s32 count; void* loadedRamAddr; return 3; - #if 0 +#if 0 if (overlayEntry->vromStart == 0) { return 3; } @@ -64,7 +64,7 @@ s32 TransitionOverlay_Load(TransitionOverlay* overlayEntry) { } return 2; } - #endif +#endif } s32 TransitionOverlay_Free(TransitionOverlay* overlayEntry) { diff --git a/mm/src/code/z_parameter.c b/mm/src/code/z_parameter.c index b2a4f6fd4..1020d0b9c 100644 --- a/mm/src/code/z_parameter.c +++ b/mm/src/code/z_parameter.c @@ -21,7 +21,8 @@ #include "2s2h_assets.h" #include "Enhancements/GameInteractor/GameInteractor.h" -// 2S2H [Port] This was originally static but needs to be global so it can be accessed in z_kaleido_collect, z_kaleido_debug, and z_kaleido_draw. +// 2S2H [Port] This was originally static but needs to be global so it can be accessed in z_kaleido_collect, +// z_kaleido_debug, and z_kaleido_draw. const char* sCounterTextures[] = { gCounterDigit0Tex, gCounterDigit1Tex, gCounterDigit2Tex, gCounterDigit3Tex, gCounterDigit4Tex, gCounterDigit5Tex, gCounterDigit6Tex, gCounterDigit7Tex, gCounterDigit8Tex, gCounterDigit9Tex, gCounterColonTex, @@ -52,15 +53,37 @@ static const char* doActionTbl[] = { }; static const char* emptyCButtonArrows[] = { - gEmptyCLeftArrowTex, gEmptyCDownArrowTex, gEmptyCRightArrowTex, + gEmptyCLeftArrowTex, + gEmptyCDownArrowTex, + gEmptyCRightArrowTex, }; u8 gPlayerFormItemRestrictions[PLAYER_FORM_MAX][114] = { - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, - { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, + { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, + 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, // {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, extra bytes at the end of data.s? }; // #endregion @@ -129,7 +152,8 @@ Input sPostmanTimerInput[MAXCONTROLLERS]; #define RESTRICTIONS_NO_DOUBLE_TIME RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0) // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, _humanName) \ +#define DEFINE_SCENE(_name, enumValue, _textId, _drawConfig, restrictionFlags, _persistentCycleFlags, \ + _entranceSceneId, _betterMapSelectIndex, _humanName) \ { enumValue, restrictionFlags }, #define DEFINE_SCENE_UNSET(enumValue) { enumValue, RESTRICTIONS_NONE }, @@ -302,7 +326,8 @@ Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 text // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -320,16 +345,16 @@ Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 text // #endregion // 2S2H [Cosmetic] Changed to Wide variant to support widescreen - gSPWideTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + gSPWideTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); return gfx; } // #region 2S2H [Dpad] Gfx* Gfx_DrawTexRectIA16_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, - s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, s16 r, s16 g, s16 b, - s16 a) { + s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, s16 r, s16 g, s16 b, + s16 a) { s16 dropShadowAlpha = a; if (a > 100) { @@ -345,7 +370,8 @@ Gfx* Gfx_DrawTexRectIA16_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWid // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -358,13 +384,13 @@ Gfx* Gfx_DrawTexRectIA16_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWid // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); gDPPipeSync(gfx++); gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); return gfx; } @@ -407,7 +433,8 @@ Gfx* Gfx_DrawTexRectIA8_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWidt // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -420,13 +447,13 @@ Gfx* Gfx_DrawTexRectIA8_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWidt // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); gDPPipeSync(gfx++); gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); return gfx; } @@ -457,7 +484,8 @@ Gfx* Gfx_DrawRect_DropShadow(Gfx* gfx, s16 rectLeft, s16 rectTop, s16 rectWidth, // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -472,13 +500,13 @@ Gfx* Gfx_DrawRect_DropShadow(Gfx* gfx, s16 rectLeft, s16 rectTop, s16 rectWidth, gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); gDPPipeSync(gfx++); gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); return gfx; } @@ -521,7 +549,8 @@ Gfx* Gfx_DrawTexRectIA8_DropShadowOffset(Gfx* gfx, TexturePtr texture, s16 textu // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -534,14 +563,14 @@ Gfx* Gfx_DrawTexRectIA8_DropShadowOffset(Gfx* gfx, TexturePtr texture, s16 textu // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, - (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, rects, 0, dsdx, dtdy); + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, rects, 0, dsdx, dtdy); gDPPipeSync(gfx++); gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); // 2S2H [Cosmetic] Changed to Wide variant to support widescreen gSPWideTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, - G_TX_RENDERTILE, rects, 0, dsdx, dtdy); + G_TX_RENDERTILE, rects, 0, dsdx, dtdy); return gfx; } @@ -569,7 +598,8 @@ Gfx* Gfx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textu // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -587,8 +617,8 @@ Gfx* Gfx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textu // #endregion // 2S2H [Cosmetic] Changed to Wide variant to support widescreen - gSPWideTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + gSPWideTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); return gfx; } @@ -619,7 +649,8 @@ Gfx* Gfx_DrawTexRect4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, // #region 2S2H [Cosmetic] Hud Editor if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; return gfx; } @@ -637,8 +668,8 @@ Gfx* Gfx_DrawTexRect4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, // #endregion // 2S2H [Cosmetic] Changed to Wide variant to support widescreen - gSPWideTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, rects, 0, dsdx, dtdy); + gSPWideTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, rects, 0, dsdx, dtdy); return gfx; } @@ -1276,19 +1307,23 @@ void Interface_UpdateButtonAlphas(PlayState* play, s16 dimmingAlpha, s16 risingA } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1329,19 +1364,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1405,19 +1444,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1529,19 +1572,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1578,19 +1625,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1635,19 +1686,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1699,19 +1754,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1925,19 +1984,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -1982,19 +2045,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -2031,19 +2098,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -2084,19 +2155,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -2141,19 +2216,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -2186,19 +2265,23 @@ void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { } // #region 2S2H [Dpad] - if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dRightAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dRightAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dRightAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dLeftAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dLeftAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dLeftAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dDownAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dDownAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dDownAlpha = dimmingAlpha; } - if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { + if ((interfaceCtx->shipInterface.dpad.dUpAlpha != 0) && + (interfaceCtx->shipInterface.dpad.dUpAlpha > dimmingAlpha)) { interfaceCtx->shipInterface.dpad.dUpAlpha = dimmingAlpha; } // #endregion @@ -2322,7 +2405,8 @@ void Interface_UpdateButtonsPart2(PlayState* play) { // #region 2S2H [Dpad] for (s16 j = EQUIP_SLOT_D_RIGHT; j <= EQUIP_SLOT_D_UP; j++) { if ((DPAD_GET_CUR_FORM_BTN_ITEM(j) == ITEM_MASK_FIERCE_DEITY) || - ((DPAD_GET_CUR_FORM_BTN_ITEM(j) >= ITEM_BOTTLE) && (DPAD_GET_CUR_FORM_BTN_ITEM(j) <= ITEM_OBABA_DRINK))) { + ((DPAD_GET_CUR_FORM_BTN_ITEM(j) >= ITEM_BOTTLE) && + (DPAD_GET_CUR_FORM_BTN_ITEM(j) <= ITEM_OBABA_DRINK))) { if (gSaveContext.shipSaveContext.dpad.status[j] == BTN_DISABLED) { restoreHudVisibility = true; gSaveContext.shipSaveContext.dpad.status[j] = BTN_ENABLED; @@ -2351,7 +2435,8 @@ void Interface_UpdateButtonsPart2(PlayState* play) { } // #region 2S2H [Dpad] for (s16 j = EQUIP_SLOT_D_RIGHT; j <= EQUIP_SLOT_D_UP; j++) { - if ((DPAD_GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MASK_DEKU) && (DPAD_GET_CUR_FORM_BTN_ITEM(j) <= ITEM_MASK_ZORA)) { + if ((DPAD_GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MASK_DEKU) && + (DPAD_GET_CUR_FORM_BTN_ITEM(j) <= ITEM_MASK_ZORA)) { if (gSaveContext.shipSaveContext.dpad.status[j] != BTN_DISABLED) { restoreHudVisibility = true; } @@ -2715,11 +2800,9 @@ void Interface_UpdateButtonsPart2(PlayState* play) { } } else if (GET_CUR_FORM_BTN_ITEM(i) == ITEM_MASK_FIERCE_DEITY) { // Fierce Deity's Mask is equipped - u8 vanillaSceneConditionResult = - (play->sceneId != SCENE_MITURIN_BS) && - (play->sceneId != SCENE_HAKUGIN_BS) && - (play->sceneId != SCENE_SEA_BS) && - (play->sceneId != SCENE_INISIE_BS) && + u8 vanillaSceneConditionResult = + (play->sceneId != SCENE_MITURIN_BS) && (play->sceneId != SCENE_HAKUGIN_BS) && + (play->sceneId != SCENE_SEA_BS) && (play->sceneId != SCENE_INISIE_BS) && (play->sceneId != SCENE_LAST_BS); if (GameInteractor_Should(GI_VB_DISABLE_FD_MASK, vanillaSceneConditionResult, NULL)) { if (gSaveContext.buttonStatus[i] != BTN_DISABLED) { @@ -2862,11 +2945,9 @@ void Interface_UpdateButtonsPart2(PlayState* play) { } } else if (DPAD_GET_CUR_FORM_BTN_ITEM(j) == ITEM_MASK_FIERCE_DEITY) { // Fierce Deity's Mask is equipped - u8 vanillaSceneConditionResult = - (play->sceneId != SCENE_MITURIN_BS) && - (play->sceneId != SCENE_HAKUGIN_BS) && - (play->sceneId != SCENE_SEA_BS) && - (play->sceneId != SCENE_INISIE_BS) && + u8 vanillaSceneConditionResult = + (play->sceneId != SCENE_MITURIN_BS) && (play->sceneId != SCENE_HAKUGIN_BS) && + (play->sceneId != SCENE_SEA_BS) && (play->sceneId != SCENE_INISIE_BS) && (play->sceneId != SCENE_LAST_BS); if (GameInteractor_Should(GI_VB_DISABLE_FD_MASK, vanillaSceneConditionResult, NULL)) { if (gSaveContext.shipSaveContext.dpad.status[j] != BTN_DISABLED) { @@ -3352,7 +3433,7 @@ void Interface_Dpad_LoadItemIconImpl(PlayState* play, u8 btn) { void Interface_LoadItemIconImpl(PlayState* play, u8 btn) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - + // #region 2S2H [Port] // CmpDma_LoadFile(SEGMENT_ROM_START(icon_item_static_yar), GET_CUR_FORM_BTN_ITEM(btn), // &interfaceCtx->iconItemSegment[(u32)btn * 0x1000], 0x1000); @@ -4106,7 +4187,7 @@ s32 Inventory_ReplaceItem(PlayState* play, u8 oldItem, u8 newItem) { Interface_Dpad_LoadItemIconImpl(play, j); break; } - } + } // #endregion return true; } @@ -4366,7 +4447,7 @@ void Interface_SetTatlCall(PlayState* play, u16 tatlCallState) { void Interface_LoadBButtonDoActionLabel(PlayState* play, s16 bButtonDoAction) { InterfaceContext* interfaceCtx = &play->interfaceCtx; - + interfaceCtx->unk_224 = bButtonDoAction; // #region 2S2H [Port] @@ -4788,12 +4869,12 @@ void Magic_Update(PlayState* play) { ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) != ITEM_LENS_OF_TRUTH) && (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) != ITEM_LENS_OF_TRUTH) && (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) != ITEM_LENS_OF_TRUTH) && - // #region 2S2H [Dpad] - (!CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) || + // #region 2S2H [Dpad] + (!CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) || (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) != ITEM_LENS_OF_TRUTH) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) != ITEM_LENS_OF_TRUTH) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) != ITEM_LENS_OF_TRUTH) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) != ITEM_LENS_OF_TRUTH))) || + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) != ITEM_LENS_OF_TRUTH) && + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) != ITEM_LENS_OF_TRUTH) && + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) != ITEM_LENS_OF_TRUTH))) || // #endregion !play->actorCtx.lensActive) { // Deactivate Lens of Truth and set magic state to idle @@ -4922,7 +5003,8 @@ void Magic_DrawMeter(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_MAGIC_METER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -4937,12 +5019,11 @@ void Magic_DrawMeter(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } } else { - // #endregion + // #endregion gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, (((void)0, gSaveContext.save.saveInfo.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); @@ -4961,7 +5042,8 @@ void Magic_DrawMeter(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_MAGIC_METER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -4976,16 +5058,15 @@ void Magic_DrawMeter(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } } else { - // #endregion + // #endregion gSPTextureRectangle( OVERLAY_DISP++, 104, (magicBarY + 3) << 2, - ((((void)0, gSaveContext.save.saveInfo.playerData.magic) - ((void)0, gSaveContext.magicToConsume)) + 26) - << 2, + ((((void)0, gSaveContext.save.saveInfo.playerData.magic) - ((void)0, gSaveContext.magicToConsume)) + + 26) << 2, (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } } else { @@ -5004,7 +5085,8 @@ void Magic_DrawMeter(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_MAGIC_METER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -5019,11 +5101,10 @@ void Magic_DrawMeter(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, (((void)0, gSaveContext.save.saveInfo.playerData.magic) + 26) << 2, @@ -5051,14 +5132,16 @@ void Interface_SetPerspectiveView(PlayState* play, s32 topY, s32 bottomY, s32 le interfaceCtx->viewport.topY = topY; interfaceCtx->viewport.bottomY = bottomY; - // 2S2H [Cosmetic] These are originally relative to screen size, but by default we want them to instead be relative to the 4:3 HUD size, to match the rest of the HUD + // 2S2H [Cosmetic] These are originally relative to screen size, but by default we want them to instead be relative + // to the 4:3 HUD size, to match the rest of the HUD interfaceCtx->viewport.leftX = OTRConvertHUDXToScreenX(leftX); interfaceCtx->viewport.rightX = OTRConvertHUDXToScreenX(rightX); // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_A); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { interfaceCtx->viewport.leftX = 0; interfaceCtx->viewport.rightX = 0; hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; @@ -5134,10 +5217,13 @@ void Interface_DrawItemButtons(PlayState* play) { // #region 2S2H [Dpad] if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { - s16 dpadAlpha = MAX(MAX(MAX(interfaceCtx->shipInterface.dpad.dRightAlpha, interfaceCtx->shipInterface.dpad.dLeftAlpha), interfaceCtx->shipInterface.dpad.dDownAlpha), - interfaceCtx->shipInterface.dpad.dUpAlpha); + s16 dpadAlpha = + MAX(MAX(MAX(interfaceCtx->shipInterface.dpad.dRightAlpha, interfaceCtx->shipInterface.dpad.dLeftAlpha), + interfaceCtx->shipInterface.dpad.dDownAlpha), + interfaceCtx->shipInterface.dpad.dUpAlpha); HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_D_PAD); - OVERLAY_DISP = Gfx_DrawTexRectIA16_DropShadow(OVERLAY_DISP, gDPadTex, 32, 32, 271, 55, 32, 32, 1024, 1024, 255, 255, 255, dpadAlpha); + OVERLAY_DISP = Gfx_DrawTexRectIA16_DropShadow(OVERLAY_DISP, gDPadTex, 32, 32, 271, 55, 32, 32, 1024, 1024, 255, + 255, 255, dpadAlpha); gDPPipeSync(OVERLAY_DISP++); } // #endregion @@ -5186,7 +5272,8 @@ void Interface_DrawItemButtons(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_START); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -5201,13 +5288,13 @@ void Interface_DrawItemButtons(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { - gSPTextureRectangle(OVERLAY_DISP++, 0x01F8, 0x0054, 0x02D4, 0x009C, G_TX_RENDERTILE, 0, 0, 0x04A6, 0x04A6); + gSPTextureRectangle(OVERLAY_DISP++, 0x01F8, 0x0054, 0x02D4, 0x009C, G_TX_RENDERTILE, 0, 0, 0x04A6, + 0x04A6); } } } @@ -5246,7 +5333,8 @@ void Interface_DrawItemButtons(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_C_UP); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -5291,9 +5379,9 @@ void Interface_DrawItemButtons(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 240, 0, interfaceCtx->cRightAlpha); } HudEditor_SetActiveElement(temp); - OVERLAY_DISP = - Gfx_DrawTexRectIA8(OVERLAY_DISP, emptyCButtonArrows[temp - 1], 0x20, 0x20, D_801BF9D4[temp], D_801BF9DC[temp], - D_801BFAF4[temp], D_801BFAF4[temp], D_801BF9E4[temp] * 2, D_801BF9E4[temp] * 2); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, emptyCButtonArrows[temp - 1], 0x20, 0x20, D_801BF9D4[temp], + D_801BF9DC[temp], D_801BFAF4[temp], D_801BFAF4[temp], + D_801BF9E4[temp] * 2, D_801BF9E4[temp] * 2); } } @@ -5308,10 +5396,10 @@ s16 sDpadItemIconDD[] = { 1024, // EQUIP_SLOT_D_UP }; s16 sDpadItemIconLeft[] = { - 295, // EQUIP_SLOT_D_RIGHT - 263, // EQUIP_SLOT_D_LEFT - 279, // EQUIP_SLOT_D_DOWN - 279, // EQUIP_SLOT_D_UP + 295, // EQUIP_SLOT_D_RIGHT + 263, // EQUIP_SLOT_D_LEFT + 279, // EQUIP_SLOT_D_DOWN + 279, // EQUIP_SLOT_D_UP }; s16 sDpadItemIconTop[] = { 63, // EQUIP_SLOT_D_RIGHT @@ -5330,7 +5418,8 @@ void Interface_Dpad_DrawItemIconTexture(PlayState* play, TexturePtr texture, s16 HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_D_PAD); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { s16 rectLeft = sDpadItemIconLeft[button]; @@ -5344,14 +5433,14 @@ void Interface_Dpad_DrawItemIconTexture(PlayState* play, TexturePtr texture, s16 hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } } else { gSPTextureRectangle(OVERLAY_DISP++, sDpadItemIconLeft[button] << 2, sDpadItemIconTop[button] << 2, - (sDpadItemIconLeft[button] + sDpadItemIconWidth[button]) << 2, (sDpadItemIconTop[button] + sDpadItemIconWidth[button]) << 2, - G_TX_RENDERTILE, 0, 0, sDpadItemIconDD[button] << 1, sDpadItemIconDD[button] << 1); + (sDpadItemIconLeft[button] + sDpadItemIconWidth[button]) << 2, + (sDpadItemIconTop[button] + sDpadItemIconWidth[button]) << 2, G_TX_RENDERTILE, 0, 0, + sDpadItemIconDD[button] << 1, sDpadItemIconDD[button] << 1); } CLOSE_DISPS(play->state.gfxCtx); @@ -5364,7 +5453,7 @@ s16 sDpadItemAmmoX[] = { 279, // EQUIP_SLOT_D_UP }; -s16 sDpadItemAmmoY[] = { +s16 sDpadItemAmmoY[] = { 63 + 11, // EQUIP_SLOT_D_RIGHT 63 + 11, // EQUIP_SLOT_D_LEFT 79 + 11, // EQUIP_SLOT_D_DOWN @@ -5399,12 +5488,12 @@ void Interface_Dpad_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { gDPPipeSync(OVERLAY_DISP++); if (((i == ITEM_BOW) && (AMMO(i) == CUR_CAPACITY(UPG_QUIVER))) || - ((i == ITEM_BOMB) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || - ((i == ITEM_DEKU_STICK) && (AMMO(i) == CUR_CAPACITY(UPG_DEKU_STICKS))) || - ((i == ITEM_DEKU_NUT) && (AMMO(i) == CUR_CAPACITY(UPG_DEKU_NUTS))) || - ((i == ITEM_BOMBCHU) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || - ((i == ITEM_POWDER_KEG) && (ammo == 1)) || ((i == ITEM_PICTOGRAPH_BOX) && (ammo == 1)) || - ((i == ITEM_MAGIC_BEANS) && (ammo == 20))) { + ((i == ITEM_BOMB) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((i == ITEM_DEKU_STICK) && (AMMO(i) == CUR_CAPACITY(UPG_DEKU_STICKS))) || + ((i == ITEM_DEKU_NUT) && (AMMO(i) == CUR_CAPACITY(UPG_DEKU_NUTS))) || + ((i == ITEM_BOMBCHU) && (AMMO(i) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((i == ITEM_POWDER_KEG) && (ammo == 1)) || ((i == ITEM_PICTOGRAPH_BOX) && (ammo == 1)) || + ((i == ITEM_MAGIC_BEANS) && (ammo == 20))) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, alpha); } @@ -5419,14 +5508,14 @@ void Interface_Dpad_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { // Draw upper digit (tens) if ((u32)i != 0) { HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_D_PAD); - OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[i], 8, 8, - sDpadItemAmmoX[button], sDpadItemAmmoY[button], 8, 8, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[i], 8, 8, sDpadItemAmmoX[button], + sDpadItemAmmoY[button], 8, 8, 1 << 10, 1 << 10); } // Draw lower digit (ones) HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_D_PAD); - OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[ammo], 8, 8, - sDpadItemAmmoX[button] + 6, sDpadItemAmmoY[button], 8, 8, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[ammo], 8, 8, sDpadItemAmmoX[button] + 6, + sDpadItemAmmoY[button], 8, 8, 1 << 10, 1 << 10); } CLOSE_DISPS(play->state.gfxCtx); @@ -5444,7 +5533,8 @@ void Interface_DrawItemIconTexture(PlayState* play, TexturePtr texture, s16 butt // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(button); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -5459,15 +5549,15 @@ void Interface_DrawItemIconTexture(PlayState* play, TexturePtr texture, s16 butt hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { gSPTextureRectangle(OVERLAY_DISP++, D_801BF9D4[button] << 2, D_801BF9DC[button] << 2, - (D_801BF9D4[button] + D_801BFAFC[button]) << 2, (D_801BF9DC[button] + D_801BFAFC[button]) << 2, - G_TX_RENDERTILE, 0, 0, D_801BF9BC[button] << 1, D_801BF9BC[button] << 1); + (D_801BF9D4[button] + D_801BFAFC[button]) << 2, + (D_801BF9DC[button] + D_801BFAFC[button]) << 2, G_TX_RENDERTILE, 0, 0, + D_801BF9BC[button] << 1, D_801BF9BC[button] << 1); } CLOSE_DISPS(play->state.gfxCtx); @@ -5536,14 +5626,14 @@ void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { // Draw upper digit (tens) if ((u32)i != 0) { HudEditor_SetActiveElement(button); - OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[i], 8, 8, - D_801BFB04[button], D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[i], 8, 8, D_801BFB04[button], + D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10); } // Draw lower digit (ones) HudEditor_SetActiveElement(button); - OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[ammo], 8, 8, - D_801BFB04[button] + 6, D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gAmmoDigitTextures[ammo], 8, 8, D_801BFB04[button] + 6, + D_801BFB0C[button], 8, 8, 1 << 10, 1 << 10); } CLOSE_DISPS(play->state.gfxCtx); @@ -5608,7 +5698,8 @@ void Interface_DrawBButtonIcons(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_B); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -5623,16 +5714,16 @@ void Interface_DrawBButtonIcons(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { - gSPTextureRectangle( - OVERLAY_DISP++, (D_801BF9C4[gSaveContext.options.language] * 4), - (D_801BF9C8[gSaveContext.options.language] * 4), ((D_801BF9C4[gSaveContext.options.language] + 0x30) << 2), - ((D_801BF9C8[gSaveContext.options.language] + 0x10) << 2), G_TX_RENDERTILE, 0, 0, D_801BF9B0, D_801BF9B0); + gSPTextureRectangle(OVERLAY_DISP++, (D_801BF9C4[gSaveContext.options.language] * 4), + (D_801BF9C8[gSaveContext.options.language] * 4), + ((D_801BF9C4[gSaveContext.options.language] + 0x30) << 2), + ((D_801BF9C8[gSaveContext.options.language] + 0x10) << 2), G_TX_RENDERTILE, 0, 0, + D_801BF9B0, D_801BF9B0); } } else if (interfaceCtx->bButtonDoAction != DO_ACTION_NONE) { gDPPipeSync(OVERLAY_DISP++); @@ -5648,7 +5739,8 @@ void Interface_DrawBButtonIcons(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_B); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == + HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -5663,16 +5755,16 @@ void Interface_DrawBButtonIcons(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { - gSPTextureRectangle( - OVERLAY_DISP++, (D_801BF9C4[gSaveContext.options.language] * 4), - (D_801BF9C8[gSaveContext.options.language] * 4), ((D_801BF9C4[gSaveContext.options.language] + 0x30) << 2), - ((D_801BF9C8[gSaveContext.options.language] + 0x10) << 2), G_TX_RENDERTILE, 0, 0, D_801BF9B0, D_801BF9B0); + gSPTextureRectangle(OVERLAY_DISP++, (D_801BF9C4[gSaveContext.options.language] * 4), + (D_801BF9C8[gSaveContext.options.language] * 4), + ((D_801BF9C4[gSaveContext.options.language] + 0x30) << 2), + ((D_801BF9C8[gSaveContext.options.language] + 0x10) << 2), G_TX_RENDERTILE, 0, 0, + D_801BF9B0, D_801BF9B0); } } @@ -5741,20 +5833,22 @@ void Interface_DrawDButtonIcons(PlayState* play) { if (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) < ITEM_F0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, dpadInterfaceCtx->dRightAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_RIGHT + EQUIP_SLOT_MAX], EQUIP_SLOT_D_RIGHT); + Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_RIGHT + EQUIP_SLOT_MAX], + EQUIP_SLOT_D_RIGHT); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); Interface_Dpad_DrawAmmoCount(play, EQUIP_SLOT_D_RIGHT, dpadInterfaceCtx->dRightAlpha); } - gDPPipeSync(OVERLAY_DISP++); + gDPPipeSync(OVERLAY_DISP++); // D-Left Button Icon & Ammo Count if (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) < ITEM_F0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, dpadInterfaceCtx->dLeftAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_LEFT + EQUIP_SLOT_MAX], EQUIP_SLOT_D_LEFT); + Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_LEFT + EQUIP_SLOT_MAX], + EQUIP_SLOT_D_LEFT); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -5767,7 +5861,8 @@ void Interface_DrawDButtonIcons(PlayState* play) { if (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) < ITEM_F0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, dpadInterfaceCtx->dDownAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_DOWN + EQUIP_SLOT_MAX], EQUIP_SLOT_D_DOWN); + Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_DOWN + EQUIP_SLOT_MAX], + EQUIP_SLOT_D_DOWN); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -5780,7 +5875,8 @@ void Interface_DrawDButtonIcons(PlayState* play) { if (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) < ITEM_F0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, dpadInterfaceCtx->dUpAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_UP + EQUIP_SLOT_MAX], EQUIP_SLOT_D_UP); + Interface_Dpad_DrawItemIconTexture(play, interfaceCtx->iconItemSegment[EQUIP_SLOT_D_UP + EQUIP_SLOT_MAX], + EQUIP_SLOT_D_UP); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -5916,8 +6012,8 @@ void Interface_DrawPauseMenuEquippingIcons(PlayState* play) { gSPVertex(OVERLAY_DISP++, &pauseCtx->cursorVtx[16], 4, 0); gDPLoadTextureBlock(OVERLAY_DISP++, gMagicArrowEquipEffectTex, G_IM_FMT_IA, G_IM_SIZ_8b, 32, 32, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, - G_TX_NOLOD, G_TX_NOLOD); + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); } gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); @@ -5948,17 +6044,19 @@ void Interface_DrawClock(PlayState* play) { gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, - gEmptyTexture, gEmptyTexture, // 2S2H [Port] To account for the vanilla bug detailed later on in this function + gEmptyTexture, gEmptyTexture, // 2S2H [Port] To account for the vanilla bug detailed later on in this + // function }; - // 2S2H Region [Enhancements] 24 Hours Clock - static TexturePtr sThreeDayClockHourTwentyFourHoursTextures[] = { - gThreeDayClockHour24Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, - gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, - gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, - gThreeDayClockHour12Tex, gThreeDayClockHour13Tex, gThreeDayClockHour14Tex, gThreeDayClockHour15Tex, - gThreeDayClockHour16Tex, gThreeDayClockHour17Tex, gThreeDayClockHour18Tex, gThreeDayClockHour19Tex, - gThreeDayClockHour20Tex, gThreeDayClockHour21Tex, gThreeDayClockHour22Tex, gThreeDayClockHour23Tex, - gEmptyTexture, gEmptyTexture, // 2S2H [Port] To account for the vanilla bug detailed later on in this function + // 2S2H Region [Enhancements] 24 Hours Clock + static TexturePtr sThreeDayClockHourTwentyFourHoursTextures[] = { + gThreeDayClockHour24Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, + gThreeDayClockHour12Tex, gThreeDayClockHour13Tex, gThreeDayClockHour14Tex, gThreeDayClockHour15Tex, + gThreeDayClockHour16Tex, gThreeDayClockHour17Tex, gThreeDayClockHour18Tex, gThreeDayClockHour19Tex, + gThreeDayClockHour20Tex, gThreeDayClockHour21Tex, gThreeDayClockHour22Tex, gThreeDayClockHour23Tex, + gEmptyTexture, gEmptyTexture, // 2S2H [Port] To account for the vanilla bug detailed later on in this + // function // #endregison }; static s16 sClockInvDiamondPrimRed = 0; @@ -6084,8 +6182,8 @@ void Interface_DrawClock(PlayState* play) { //! covered by the diamond. However, it can be seen by the final-hours clock. // 2S2H [Port] We are opting to fix this here because our garbage data will not // be consistent with the garbage rendered on hardware, and potentially dangerous. - OVERLAY_DISP = Gfx_DrawTexRect4b(OVERLAY_DISP, gThreeDayClockBorderTex, 4, 64, /*50*/ 48, 96, 168, 128, 50, 1, 6, - 0, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRect4b(OVERLAY_DISP, gThreeDayClockBorderTex, 4, 64, /*50*/ 48, 96, 168, 128, 50, + 1, 6, 0, 1 << 10, 1 << 10); if (((CURRENT_DAY >= 4) || ((CURRENT_DAY == 3) && (((void)0, gSaveContext.save.time) >= (CLOCK_TIME(0, 0) + 5)) && @@ -6191,8 +6289,9 @@ void Interface_DrawClock(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 155, sThreeDayClockAlpha); HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_CLOCK); - OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, interfaceCtx->doActionSegment[DO_ACTION_SEG_CLOCK].mainTex, 48, - 27, 137, 192, 48, 27, 1 << 10, 1 << 10); + OVERLAY_DISP = + Gfx_DrawTexRectIA8(OVERLAY_DISP, interfaceCtx->doActionSegment[DO_ACTION_SEG_CLOCK].mainTex, 48, 27, + 137, 192, 48, 27, 1 << 10, 1 << 10); /** * Section: Draw Three-Day Clock's Star (for the Minute Tracker) @@ -6399,7 +6498,6 @@ void Interface_DrawClock(PlayState* play) { rectWidth = MIN(rectLeft + rectWidth, OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH)) - rectLeft; rectHeight = MIN(rectTop + rectHeight, SCREEN_HEIGHT) - rectTop; - gDPSetScissor(OVERLAY_DISP++, G_SC_NON_INTERLACE, OTRConvertHUDXToScreenX(rectLeft), rectTop, OTRConvertHUDXToScreenX(rectLeft + rectWidth), rectTop + rectHeight); } else { @@ -6441,9 +6539,10 @@ void Interface_DrawClock(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, sThreeDayClockAlpha); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[24], 8, 0); - OVERLAY_DISP = CVarGetInteger("gEnhancements.Graphics.24HoursClock", 0) ? - Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTwentyFourHoursTextures[sp1C6], 4, 16, 11, 0) : - Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTextures[sp1C6], 4, 16, 11, 0); + OVERLAY_DISP = + CVarGetInteger("gEnhancements.Graphics.24HoursClock", 0) + ? Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTwentyFourHoursTextures[sp1C6], 4, 16, 11, 0) + : Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTextures[sp1C6], 4, 16, 11, 0); // Colours the Three-Day Clocks's Hour Digit Above the Sun gDPPipeSync(OVERLAY_DISP++); @@ -6482,10 +6581,10 @@ void Interface_DrawClock(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, sThreeDayClockAlpha); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[32], 8, 0); - OVERLAY_DISP = CVarGetInteger("gEnhancements.Graphics.24HoursClock", 0) ? - Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTwentyFourHoursTextures[sp1C6], 4, 16, 11, 0) : - Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTextures[sp1C6], 4, 16, 11, 0); - + OVERLAY_DISP = + CVarGetInteger("gEnhancements.Graphics.24HoursClock", 0) + ? Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTwentyFourHoursTextures[sp1C6], 4, 16, 11, 0) + : Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTextures[sp1C6], 4, 16, 11, 0); // Colours the Three-Day Clocks's Hour Digit Above the Moon gDPPipeSync(OVERLAY_DISP++); @@ -7944,7 +8043,8 @@ void Interface_DrawMinigameIcons(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_MINIGAME_COUNTER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { s16 newRectX = rectX; @@ -8162,8 +8262,8 @@ void Interface_Draw(PlayState* play) { gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); - OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[2]], 8, 16, 43, 191, - 8, 16, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[2]], 8, 16, 43, + 191, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); @@ -8186,7 +8286,8 @@ void Interface_Draw(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_KEY_COUNTER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -8221,14 +8322,16 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); - gDPLoadTextureBlock(OVERLAY_DISP++, gGoldSkulltulaCounterIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 24, // 2S2H [Port] This last 24 was 18 in the minibuild, not sure why + gDPLoadTextureBlock(OVERLAY_DISP++, gGoldSkulltulaCounterIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, + 24, // 2S2H [Port] This last 24 was 18 in the minibuild, not sure why 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -8272,15 +8375,16 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER); - OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[2]], 8, 16, 43, 191, 8, - 16, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[2]], 8, 16, 43, 191, + 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -8301,7 +8405,8 @@ void Interface_Draw(PlayState* play) { } // #endregion } else { - gSPTextureRectangle(OVERLAY_DISP++, 168, 760, 200, 824, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, 168, 760, 200, 824, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); } sp2CA += 8; @@ -8311,8 +8416,8 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER); - OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[3]], 8, 16, sp2CA + 1, 191, - 8, 16, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[3]], 8, 16, sp2CA + 1, + 191, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); @@ -8320,7 +8425,8 @@ void Interface_Draw(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_SKULLTULA_COUNTER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -8341,8 +8447,8 @@ void Interface_Draw(PlayState* play) { } // #endregion } else { - gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 760, (sp2CA * 4) + 0x20, 824, G_TX_RENDERTILE, 0, - 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 760, (sp2CA * 4) + 0x20, 824, G_TX_RENDERTILE, 0, 0, + 1 << 10, 1 << 10); } break; @@ -8385,8 +8491,8 @@ void Interface_Draw(PlayState* play) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, magicAlpha); HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_RUPEE_COUNTER); - OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[sp2CC]], 8, 16, sp2CA + 1, 207, - 8, 16, 1 << 10, 1 << 10); + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, sCounterTextures[counterDigits[sp2CC]], 8, 16, sp2CA + 1, + 207, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(OVERLAY_DISP++); @@ -8401,7 +8507,8 @@ void Interface_Draw(PlayState* play) { // #region 2S2H [Cosmetic] Hud Editor HudEditor_SetActiveElement(HUD_EDITOR_ELEMENT_RUPEE_COUNTER); if (HudEditor_ShouldOverrideDraw()) { - if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { + if (CVarGetInteger(hudEditorElements[hudEditorActiveElement].modeCvar, + HUD_EDITOR_ELEMENT_MODE_VANILLA) == HUD_EDITOR_ELEMENT_MODE_HIDDEN) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; } else { // All of this information was derived from the original call to gSPTextureRectangle below @@ -8416,14 +8523,13 @@ void Interface_Draw(PlayState* play) { hudEditorActiveElement = HUD_EDITOR_ELEMENT_NONE; - gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, - (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, - G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); + gSPWideTextureRectangle(OVERLAY_DISP++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, + (rectTop + rectHeight) << 2, G_TX_RENDERTILE, 0, 0, dsdx << 1, dtdy << 1); } - // #endregion + // #endregion } else { - gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 824, (sp2CA * 4) + 0x20, 888, G_TX_RENDERTILE, 0, 0, 1 << 10, - 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 824, (sp2CA * 4) + 0x20, 888, G_TX_RENDERTILE, 0, 0, + 1 << 10, 1 << 10); } } @@ -8629,7 +8735,7 @@ void Interface_LoadStory(PlayState* play, s32 osMesgFlag) { case STORY_DMA_LOADING: // if (osRecvMesg(&interfaceCtx->storyMsgQueue, NULL, osMesgFlag) == 0) { if (true) { - // #endregion + // #endregion interfaceCtx->storyDmaStatus = STORY_DMA_DONE; } break; @@ -9160,7 +9266,8 @@ void Interface_Init(PlayState* play) { parameterStaticSize = SEGMENT_ROM_SIZE(parameter_static); // #region 2S2H [Port] interfaceCtx->parameterSegment = THA_AllocTailAlign16(&play->state.tha, parameterStaticSize); - // DmaMgr_SendRequest0(interfaceCtx->parameterSegment, SEGMENT_ROM_START(parameter_static), parameterStaticSize); // 2S2H [Port] TODO + // DmaMgr_SendRequest0(interfaceCtx->parameterSegment, SEGMENT_ROM_START(parameter_static), parameterStaticSize); // + // 2S2H [Port] TODO interfaceCtx->doActionSegment = THA_AllocTailAlign16(&play->state.tha, sizeof(ActionLabel) * DO_ACTION_SEG_MAX); for (size_t id = 0; id < DO_ACTION_SEG_MAX; id++) { @@ -9176,7 +9283,8 @@ void Interface_Init(PlayState* play) { Interface_NewDay(play, CURRENT_DAY); // #region 2S2H [Dpad] Increase Size of iconItemSegment for dpad - interfaceCtx->iconItemSegment = THA_AllocTailAlign16(&play->state.tha, sizeof(char*) * (EQUIP_SLOT_MAX + EQUIP_SLOT_D_MAX)); + interfaceCtx->iconItemSegment = + THA_AllocTailAlign16(&play->state.tha, sizeof(char*) * (EQUIP_SLOT_MAX + EQUIP_SLOT_D_MAX)); for (size_t id = 0; id < (EQUIP_SLOT_MAX + EQUIP_SLOT_D_MAX); id++) { interfaceCtx->iconItemSegment[id] = gEmptyTexture; } diff --git a/mm/src/code/z_pause.c b/mm/src/code/z_pause.c index 7e094cfc1..e61e71d1e 100644 --- a/mm/src/code/z_pause.c +++ b/mm/src/code/z_pause.c @@ -41,9 +41,9 @@ s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) { } if (!frameAdvCtx->enabled || CVarGetInteger("gDeveloperTools.FrameAdvanceTick", 0) || - (CHECK_BTN_ALL(input->cur.button, BTN_Z) && - (CHECK_BTN_ALL(input->press.button, BTN_R) || - (CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) { + (CHECK_BTN_ALL(input->cur.button, BTN_Z) && + (CHECK_BTN_ALL(input->press.button, BTN_R) || + (CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) { CVarClear("gDeveloperTools.FrameAdvanceTick"); frameAdvCtx->timer = 0; return true; diff --git a/mm/src/code/z_play.c b/mm/src/code/z_play.c index faf0e4279..0d7dab16d 100644 --- a/mm/src/code/z_play.c +++ b/mm/src/code/z_play.c @@ -1659,7 +1659,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn); void Play_InitScene(PlayState* this, s32 spawn) { OTRPlay_InitScene(this, spawn); - #if 0 +#if 0 this->curSpawn = spawn; this->linkActorEntry = NULL; this->actorCsCamList = NULL; @@ -1677,7 +1677,7 @@ void Play_InitScene(PlayState* this, s32 spawn) { gSaveContext.worldMapArea = 0; Scene_ExecuteCommands(this, this->sceneSegment); Play_InitEnvironment(this, this->skyboxId); - #endif +#endif } void OTRPlay_SpawnScene(PlayState* play, s32 sceneId, s32 spawn); @@ -2338,7 +2338,8 @@ void Play_Init(GameState* thisx) { sceneLayer = gSaveContext.sceneLayer; - s32 sceneIdAbsolute = Entrance_GetSceneIdAbsolute(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer)); + s32 sceneIdAbsolute = + Entrance_GetSceneIdAbsolute(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer)); s32 spawnNum = Entrance_GetSpawnNum(((void)0, gSaveContext.save.entrance) + ((void)0, gSaveContext.sceneLayer)); Play_SpawnScene(this, sceneIdAbsolute, spawnNum); diff --git a/mm/src/code/z_play_hireso.c b/mm/src/code/z_play_hireso.c index a115b3f85..0fcb6b086 100644 --- a/mm/src/code/z_play_hireso.c +++ b/mm/src/code/z_play_hireso.c @@ -1070,8 +1070,8 @@ void BombersNotebook_Draw(BombersNotebook* this, GraphicsContext* gfxCtx) { gfx = POLY_OPA_DISP; if (this->loadState == BOMBERS_NOTEBOOK_LOAD_STATE_DONE) { - //gSPSegment(gfx++, 0x07, this->scheduleDmaSegment); - //gSPSegment(gfx++, 0x08, this->scheduleSegment); + // gSPSegment(gfx++, 0x07, this->scheduleDmaSegment); + // gSPSegment(gfx++, 0x08, this->scheduleSegment); gfx = Gfx_SetupDL39(gfx); gDPSetCombineLERP(gfx++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -1115,9 +1115,9 @@ void BombersNotebook_Draw(BombersNotebook* this, GraphicsContext* gfxCtx) { void BombersNotebook_LoadFiles(BombersNotebook* this, s32 flag) { switch (this->loadState) { case BOMBERS_NOTEBOOK_LOAD_STATE_NONE: - // #region 2S2H [Port] Same as the comment in the update function. We don't need to use the built in DMA - // engine. We use the resource manager. - #if 0 +// #region 2S2H [Port] Same as the comment in the update function. We don't need to use the built in DMA +// engine. We use the resource manager. +#if 0 if (this->scheduleDmaSegment == NULL) { break; } @@ -1125,12 +1125,12 @@ void BombersNotebook_LoadFiles(BombersNotebook* this, s32 flag) { osCreateMesgQueue(&this->loadQueue, this->loadMsg, ARRAY_COUNT(this->loadMsg)); DmaMgr_SendRequestImpl(&this->dmaRequest, this->scheduleSegment, this->scheduleSegmentStart, this->scheduleSegmentSize, 0, &this->loadQueue, OS_MESG_PTR(NULL)); - #endif +#endif this->loadState = BOMBERS_NOTEBOOK_LOAD_STATE_STARTED; // fallthrough case BOMBERS_NOTEBOOK_LOAD_STATE_STARTED: - //if (osRecvMesg(&this->loadQueue, NULL, flag) == 0) { - this->loadState = BOMBERS_NOTEBOOK_LOAD_STATE_DONE; + // if (osRecvMesg(&this->loadQueue, NULL, flag) == 0) { + this->loadState = BOMBERS_NOTEBOOK_LOAD_STATE_DONE; //} break; @@ -1159,9 +1159,9 @@ void BombersNotebook_Update(PlayState* play, BombersNotebook* this, Input* input s32 stickAdjY = input->rel.stick_y; s32 cursorEntryScan; - // #region 2S2H [Port] We don't need to allocate anything because we don't use these segments. - // We also want to avoid using malloc here because using a size of zero still allocates some data. - #if 0 +// #region 2S2H [Port] We don't need to allocate anything because we don't use these segments. +// We also want to avoid using malloc here because using a size of zero still allocates some data. +#if 0 this->scheduleDmaSegmentStart = SEGMENT_ROM_START(schedule_dma_static_yar); this->scheduleDmaSegmentSize = SEGMENT_ROM_SIZE(schedule_dma_static_syms); this->scheduleSegmentStart = SEGMENT_ROM_START(schedule_static); @@ -1174,7 +1174,7 @@ void BombersNotebook_Update(PlayState* play, BombersNotebook* this, Input* input if (this->scheduleSegment == NULL) { this->scheduleSegment = ZeldaArena_Malloc(this->scheduleSegmentSize); } - #endif +#endif BombersNotebook_LoadFiles(this, OS_MESG_NOBLOCK); @@ -1355,12 +1355,12 @@ void BombersNotebook_Destroy(BombersNotebook* this) { if (this->loadState == BOMBERS_NOTEBOOK_LOAD_STATE_STARTED) { BombersNotebook_LoadFiles(this, OS_MESG_BLOCK); } - #if 0 +#if 0 if (this->scheduleDmaSegment != NULL) { ZeldaArena_Free(this->scheduleDmaSegment); this->scheduleDmaSegment = NULL; } - #endif +#endif //! @bug: Does not free malloc'd memory for schedule segment // 2S2H [Port] "Fix" the bug by not allocating anything } diff --git a/mm/src/code/z_player_lib.c b/mm/src/code/z_player_lib.c index 7941fb883..44581b9b8 100644 --- a/mm/src/code/z_player_lib.c +++ b/mm/src/code/z_player_lib.c @@ -210,7 +210,7 @@ void func_801229FC(Player* player) { } else if (player->maskObjectLoadState == 2) { // if (osRecvMesg(&player->maskObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0) { if (true) { - // #endregion + // #endregion player->maskObjectLoadState = 0; if (player->currentMask == PLAYER_MASK_GREAT_FAIRY) { @@ -1082,7 +1082,8 @@ Gfx* sPlayerFirstPersonRightShoulderDLs[PLAYER_FORM_MAX] = { Gfx* sPlayerFirstPersonRightHandDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityRightHandDL, //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist - // 2S2H [Port] Put the DList that makes the most sense here. In reality nothing makes sense since goron has no first person items, but we need something here to prevent a crash. + // 2S2H [Port] Put the DList that makes the most sense here. In reality nothing makes sense since goron has no first + // person items, but we need something here to prevent a crash. gLinkGoronRightHandOpenDL, gLinkZoraRightHandOpenDL, gLinkDekuRightHandDL, @@ -1092,7 +1093,8 @@ Gfx* sPlayerFirstPersonRightHandDLs[PLAYER_FORM_MAX] = { Gfx* sPlayerFirstPersonRightHandHookshotDLs[PLAYER_FORM_MAX] = { gLinkFierceDeityRightHandDL, //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist - // 2S2H [Port] Put the DList that makes the most sense here. In reality nothing makes sense since goron has no first person items, but we need something here to prevent a crash. + // 2S2H [Port] Put the DList that makes the most sense here. In reality nothing makes sense since goron has no first + // person items, but we need something here to prevent a crash. gLinkGoronRightHandOpenDL, gLinkZoraRightHandOpenDL, gLinkDekuRightHandDL, @@ -2261,8 +2263,9 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** ? D_801C0608 : ((BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_pg_wait)) ? D_801C0628 - : ((BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_pg_punchC)) ? D_801C07C0 - : D_801C0460)); + : ((BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_pg_punchC)) + ? D_801C07C0 + : D_801C0460)); func_80124618(phi_a0, player->skelAnime.curFrame, player->unk_AF0); } else { @@ -3394,7 +3397,8 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dlist) { f32 temp_f0; if (temp_v1 || - ((player->currentMask != PLAYER_MASK_NONE) && (BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_cl_setmask)) && + ((player->currentMask != PLAYER_MASK_NONE) && + (BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_cl_setmask)) && (temp_f0 = player->skelAnime.curFrame - 8.0f, (temp_f0 >= 0.0f)) && (temp_f0 < 4.0f)) || (player->stateFlags2 & PLAYER_STATE2_1000000)) { s32 mask; @@ -3652,8 +3656,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G } else if (CVarGetInteger("gEnhancements.Graphics.BowReticle", 0) && ((player->heldItemAction == PLAYER_IA_BOW_FIRE) || (player->heldItemAction == PLAYER_IA_BOW_ICE) || - (player->heldItemAction == PLAYER_IA_BOW_LIGHT) || - (player->heldItemAction == PLAYER_IA_BOW))) { + (player->heldItemAction == PLAYER_IA_BOW_LIGHT) || (player->heldItemAction == PLAYER_IA_BOW))) { if (heldActor != NULL) { MtxF sp44; @@ -3662,7 +3665,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G if (func_800B7128(player) != 0) { Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY); - Player_DrawHookshotReticle(play, player, 776000.0f); + Player_DrawHookshotReticle(play, player, 776000.0f); } } } else if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) { @@ -3752,7 +3755,8 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G //! FAKE if (((*dList1 != NULL) && ((((void)0, player->currentMask)) != (((void)0, PLAYER_MASK_NONE)))) && (((player->transformation == PLAYER_FORM_HUMAN) && - ((!BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_cl_setmask)) || (player->skelAnime.curFrame >= 12.0f))) || + ((!BEN_ANIM_EQUAL(player->skelAnime.animation, gPlayerAnim_cl_setmask)) || + (player->skelAnime.curFrame >= 12.0f))) || ((((player->transformation != PLAYER_FORM_HUMAN) && (player->currentMask >= PLAYER_MASK_FIERCE_DEITY)) && ((player->transformation + PLAYER_MASK_FIERCE_DEITY) != player->currentMask)) && (player->skelAnime.curFrame >= 10.0f)))) { diff --git a/mm/src/code/z_rcp.c b/mm/src/code/z_rcp.c index 5c2aee50b..3adec7b98 100644 --- a/mm/src/code/z_rcp.c +++ b/mm/src/code/z_rcp.c @@ -1517,7 +1517,8 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g // WideRectangle consumes two instructions and requires ++ for the macro to work // Remove `- 1` on the sizes so the rectangle fills the whole screen like `fillRect` Gfx* tmpGfx = masterGfx; - gDPFillWideRectangle(tmpGfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gCfbWidth), gCfbHeight); + gDPFillWideRectangle(tmpGfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gCfbWidth), + gCfbHeight); gDPPipeSync(&masterGfx[2]); gSPEndDisplayList(&masterGfx[3]); // #endregion @@ -1529,7 +1530,8 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 // WideRectangle consumes two instructions and requires ++ for the macro to work tmpGfx = masterGfx; - gDPFillWideRectangle(tmpGfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gCfbWidth), gCfbHeight); + gDPFillWideRectangle(tmpGfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gCfbWidth), + gCfbHeight); gDPPipeSync(&masterGfx[2]); gSPEndDisplayList(&masterGfx[3]); // #endregion diff --git a/mm/src/code/z_room.c b/mm/src/code/z_room.c index 8ad5f1f15..bdf86c328 100644 --- a/mm/src/code/z_room.c +++ b/mm/src/code/z_room.c @@ -4,7 +4,6 @@ #include "public/bridge/gfxbridge.h" - void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3) { } @@ -549,12 +548,11 @@ size_t Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx) { return maxRoomSize; } - s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum); s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { return OTRfunc_8009728C(play, roomCtx, index); - #if 0 +#if 0 if (roomCtx->status == 0) { size_t size; @@ -576,7 +574,7 @@ s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) { } return 0; - #endif +#endif } void OTRPlay_InitScene(PlayState* play, s32 spawn); @@ -609,7 +607,7 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) { } return 1; - #endif +#endif } RoomDrawHandler sRoomDrawHandlers[] = { diff --git a/mm/src/code/z_scene_table.c b/mm/src/code/z_scene_table.c index 0c7ba11e0..bbfe736b6 100644 --- a/mm/src/code/z_scene_table.c +++ b/mm/src/code/z_scene_table.c @@ -13,7 +13,8 @@ #endif // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(name, _enumValue, textId, drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, _humanName) \ +#define DEFINE_SCENE(name, _enumValue, textId, drawConfig, _restrictionFlags, _persistentCycleFlags, _entranceSceneId, \ + _betterMapSelectIndex, _humanName) \ { { 0, 0, #name }, textId, 0, drawConfig, 0, 0 }, #define DEFINE_SCENE_UNSET(_enumValue) { 0 }, diff --git a/mm/src/code/z_shrink_window.c b/mm/src/code/z_shrink_window.c index 16b7fa25a..a1e651d01 100644 --- a/mm/src/code/z_shrink_window.c +++ b/mm/src/code/z_shrink_window.c @@ -89,15 +89,19 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), letterboxSize - 1); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, + OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), letterboxSize - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize, + OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth), letterboxSize + 1); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize - 1, OTRGetRectDimensionFromRightEdge(gScreenWidth), gScreenHeight - letterboxSize); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), letterboxSize, + OTRGetRectDimensionFromRightEdge(gScreenWidth), letterboxSize + 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize - 1, + OTRGetRectDimensionFromRightEdge(gScreenWidth), gScreenHeight - letterboxSize); // #endregion gDPPipeSync(gfx++); @@ -117,16 +121,20 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(pillarboxSize - 1), gScreenHeight - 1); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(gScreenWidth - pillarboxSize), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, + OTRGetRectDimensionFromRightEdge(pillarboxSize - 1), gScreenHeight - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(gScreenWidth - pillarboxSize), 0, + OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(pillarboxSize), 0, pillarboxSize + 2, gScreenHeight); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(gScreenWidth - pillarboxSize - 2), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - pillarboxSize), gScreenHeight); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(pillarboxSize), 0, pillarboxSize + 2, + gScreenHeight); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(gScreenWidth - pillarboxSize - 2), 0, + OTRGetRectDimensionFromRightEdge(gScreenWidth - pillarboxSize), gScreenHeight); // #endregion gDPPipeSync(gfx++); diff --git a/mm/src/code/z_skelanime.c b/mm/src/code/z_skelanime.c index c04d9b9dc..2af58e492 100644 --- a/mm/src/code/z_skelanime.c +++ b/mm/src/code/z_skelanime.c @@ -1113,7 +1113,7 @@ void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* ske void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data) { AnimEntryLoadFrame* entry = &data->load; - //osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); + // osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); } /** diff --git a/mm/src/code/z_sram_NES.c b/mm/src/code/z_sram_NES.c index 94e8c73bc..86bf9e945 100644 --- a/mm/src/code/z_sram_NES.c +++ b/mm/src/code/z_sram_NES.c @@ -26,7 +26,8 @@ typedef struct PersistentCycleSceneFlags { #define PERSISTENT_CYCLE_FLAGS_NONE PERSISTENT_CYCLE_FLAGS_SET(0, 0, 0, 0) // 2S2H Added columns to scene table: entranceSceneId, betterMapSelectIndex, humanName -#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, persistentCycleFlags, _entranceSceneId, _betterMapSelectIndex, _humanName) \ +#define DEFINE_SCENE(_name, _enumValue, _textId, _drawConfig, _restrictionFlags, persistentCycleFlags, \ + _entranceSceneId, _betterMapSelectIndex, _humanName) \ persistentCycleFlags #define DEFINE_SCENE_UNSET(_enumValue) PERSISTENT_CYCLE_FLAGS_NONE @@ -561,7 +562,7 @@ void Sram_SaveEndOfCycle(PlayState* play) { DPAD_SET_CUR_FORM_BTN_ITEM(k, ITEM_BOTTLE); Interface_Dpad_LoadItemIconImpl(play, k); } - } + } // #endregion gSaveContext.save.saveInfo.inventory.items[i] = ITEM_BOTTLE; } @@ -633,11 +634,12 @@ void Sram_SaveEndOfCycle(PlayState* play) { } // #region 2S2H [Dpad] for (s32 k = EQUIP_SLOT_D_RIGHT; k <= EQUIP_SLOT_D_UP; k++) { - if ((DPAD_GET_CUR_FORM_BTN_ITEM(k) >= ITEM_MOONS_TEAR) && (DPAD_GET_CUR_FORM_BTN_ITEM(k) <= ITEM_PENDANT_OF_MEMORIES)) { + if ((DPAD_GET_CUR_FORM_BTN_ITEM(k) >= ITEM_MOONS_TEAR) && + (DPAD_GET_CUR_FORM_BTN_ITEM(k) <= ITEM_PENDANT_OF_MEMORIES)) { DPAD_SET_CUR_FORM_BTN_ITEM(k, ITEM_NONE); Interface_Dpad_LoadItemIconImpl(play, k); } - } + } // #endregion gSaveContext.save.saveInfo.skullTokenCount &= ~0xFFFF0000; @@ -971,8 +973,7 @@ void Sram_InitNewSave(void) { memcpy(&gSaveContext.save.saveInfo.playerData, &sSaveDefaultPlayerData, sizeof(SavePlayerData)); memcpy(&gSaveContext.save.saveInfo.equips, &sSaveDefaultItemEquips, sizeof(ItemEquips)); memcpy(&gSaveContext.save.saveInfo.inventory, &sSaveDefaultInventory, sizeof(Inventory)); - memcpy(&gSaveContext.save.saveInfo.checksum, &sSaveDefaultChecksum, - sizeof(gSaveContext.save.saveInfo.checksum)); + memcpy(&gSaveContext.save.saveInfo.checksum, &sSaveDefaultChecksum, sizeof(gSaveContext.save.saveInfo.checksum)); gSaveContext.save.saveInfo.horseData.sceneId = SCENE_F01; gSaveContext.save.saveInfo.horseData.pos.x = -1420; @@ -1368,7 +1369,7 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { if (gSaveContext.save.saveInfo.scarecrowSpawnSongSet) { memcpy(gScarecrowSpawnSongPtr, gSaveContext.save.saveInfo.scarecrowSpawnSong, - sizeof(gSaveContext.save.saveInfo.scarecrowSpawnSong)); + sizeof(gSaveContext.save.saveInfo.scarecrowSpawnSong)); for (i = 0; i != ARRAY_COUNT(gSaveContext.save.saveInfo.scarecrowSpawnSong); i++) {} } @@ -1994,7 +1995,10 @@ void Sram_UpdateWriteToFlashDefault(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->startWriteOsTime) >= SECONDS_TO_TIMER(CVarGetInteger("gEnhancements.Save.SaveDelay", 0))) { // 2S2H [Port] Some tricks require a save delay so we can't just force it to zero + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->startWriteOsTime) >= + SECONDS_TO_TIMER(CVarGetInteger( + "gEnhancements.Save.SaveDelay", + 0))) { // 2S2H [Port] Some tricks require a save delay so we can't just force it to zero // Finished status is hardcoded to 2 seconds instead of when the task finishes sramCtx->status = 0; } @@ -2032,7 +2036,10 @@ void Sram_UpdateWriteToFlashOwlSave(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->startWriteOsTime) >= SECONDS_TO_TIMER(CVarGetInteger("gEnhancements.Save.SaveDelay", 0))) { // 2S2H [Port] Some tricks require a save delay so we can't just force it to zero + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->startWriteOsTime) >= + SECONDS_TO_TIMER(CVarGetInteger( + "gEnhancements.Save.SaveDelay", + 0))) { // 2S2H [Port] Some tricks require a save delay so we can't just force it to zero // Finished status is hardcoded to 2 seconds instead of when the task finishes sramCtx->status = 0; memset(sramCtx->saveBuf, 0, SAVE_BUFFER_SIZE); diff --git a/mm/src/code/z_sub_s.c b/mm/src/code/z_sub_s.c index 44191455b..f2c5666cd 100644 --- a/mm/src/code/z_sub_s.c +++ b/mm/src/code/z_sub_s.c @@ -554,8 +554,8 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animationI if (animationInfo->playSpeed < 0.0f) { SWAP(s32, endFrame, startFrame); } - Animation_Change(skelAnime, ogAnim, animationInfo->playSpeed, startFrame, endFrame, - animationInfo->mode, animationInfo->morphFrames); + Animation_Change(skelAnime, ogAnim, animationInfo->playSpeed, startFrame, endFrame, animationInfo->mode, + animationInfo->morphFrames); return true; } @@ -1413,8 +1413,7 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a startFrame = Animation_GetLastFrame(&anim->common); endFrame = 0.0f; } - Animation_Change(skelAnime, ogAnim, animation->playSpeed, startFrame, endFrame, animation->mode, - morphFrames); + Animation_Change(skelAnime, ogAnim, animation->playSpeed, startFrame, endFrame, animation->mode, morphFrames); *curAnimIndex = nextAnimIndex; } diff --git a/mm/src/code/z_view.c b/mm/src/code/z_view.c index dcc6ce7de..352e3c975 100644 --- a/mm/src/code/z_view.c +++ b/mm/src/code/z_view.c @@ -386,8 +386,8 @@ s32 View_ApplyPerspective(View* view) { float eye_dist = sqrtf(sqr(view->eye.x - old_view.eye.x) + sqr(view->eye.y - old_view.eye.y) + sqr(view->eye.z - old_view.eye.z)); - float look_dist = sqrtf(sqr(view->at.x - old_view.at.x) + sqr(view->at.y - old_view.at.y) + - sqr(view->at.z - old_view.at.z)); + float look_dist = + sqrtf(sqr(view->at.x - old_view.at.x) + sqr(view->at.y - old_view.at.y) + sqr(view->at.z - old_view.at.z)); float up_dist = sqrtf(sqr(view->up.x - old_view.up.x) + sqr(view->up.y - old_view.up.y) + sqr(view->up.z - old_view.up.z)); float d_dist = sqrtf(sqr(dirx - odirx) + sqr(diry - odiry) + sqr(dirz - odirz)); diff --git a/mm/src/code/z_vimode.c b/mm/src/code/z_vimode.c index 5ab22dc1e..e0096f15b 100644 --- a/mm/src/code/z_vimode.c +++ b/mm/src/code/z_vimode.c @@ -206,7 +206,7 @@ extern OSViMode osViModeMpalLan1; extern OSViMode osViModeFpalLan1; void ViMode_Save(ViMode* viMode) { - #if 0 +#if 0 R_VI_MODE_EDIT_STATE = viMode->editState; R_VI_MODE_EDIT_WIDTH = viMode->viWidth; R_VI_MODE_EDIT_HEIGHT = viMode->viHeight; @@ -231,7 +231,7 @@ void ViMode_Save(ViMode* viMode) { break; } } - #endif +#endif } void ViMode_Load(ViMode* viMode) { @@ -271,7 +271,7 @@ void ViMode_Destroy(ViMode* viMode) { } void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures) { - #if 0 +#if 0 u32 ctrl = viMode->customViMode.comRegs.ctrl; if (viFeatures & OS_VI_GAMMA_ON) { @@ -293,7 +293,7 @@ void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures) { ctrl &= ~OS_VI_DIVOT; } viMode->customViMode.comRegs.ctrl = ctrl; - #endif +#endif } /** @@ -301,7 +301,7 @@ void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures) { * (through R_VI_MODE_EDIT_* entries) */ void ViMode_Update(ViMode* viMode, Input* input) { - #if 0 +#if 0 ViMode_Load(viMode); if ((viMode->editState == VI_MODE_EDIT_STATE_ACTIVE) || (viMode->editState == VI_MODE_EDIT_STATE_2) || @@ -407,5 +407,5 @@ void ViMode_Update(ViMode* viMode, Input* input) { } ViMode_Save(viMode); - #endif +#endif } diff --git a/mm/src/code/z_visfbuf.c b/mm/src/code/z_visfbuf.c index f3f553797..e17c8fa2f 100644 --- a/mm/src/code/z_visfbuf.c +++ b/mm/src/code/z_visfbuf.c @@ -173,7 +173,8 @@ void VisFbuf_ApplyEffects(VisFbuf* this, Gfx** gfxP, void* source, void* img, s3 G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - // The function FB_CopyToFramebuffer uses f3dex2 opcodes, clear and set geometry ode. We need to load f3dex2, call the function, and then reload s2dex. + // The function FB_CopyToFramebuffer uses f3dex2 opcodes, clear and set geometry ode. We need to load f3dex2, call + // the function, and then reload s2dex. gSPLoadUcode(gfx++, ucode_f3dex2); FB_CopyToFramebuffer(&gfx, 0, gReusableFrameBuffer, false, NULL); gSPLoadUcode(gfx++, ucode_s2dex); @@ -192,9 +193,10 @@ void VisFbuf_ApplyEffects(VisFbuf* this, Gfx** gfxP, void* source, void* img, s3 //! @bug VisFbuf_SetBgSimple() sets the current color image back to the frame's default framebuffer at the end, //! so this will always fill in the default framebuffer, whatever are used as `source` and `img`. This does not //! arise in-game since this function is always used with `source = D_0F000000`. - + gSPLoadUcode(gfx++, ucode_f3dex2); - gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(width - 1), height - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(width - 1), + height - 1); gSPLoadUcode(gfx++, ucode_s2dex); gDPPipeSync(gfx++); @@ -233,8 +235,8 @@ void VisFbuf_ApplyEffects(VisFbuf* this, Gfx** gfxP, void* source, void* img, s3 // 2S2H [Port][Widescreen] // Draw shrunk window using an adjusted horizontal scale accounting for different aspect ratios - // The function FB_DrawFromFramebufferScaled uses f3dex2 opcodes. We need to load f3dex2, call the function, and then - // reload s2dex. + // The function FB_DrawFromFramebufferScaled uses f3dex2 opcodes. We need to load f3dex2, call the function, and + // then reload s2dex. gSPLoadUcode(gfx++, ucode_f3dex2); FB_DrawFromFramebufferScaled(&gfx, gReusableFrameBuffer, 255, diff --git a/mm/src/code/z_vr_box.c b/mm/src/code/z_vr_box.c index 01d1f2e18..fba172026 100644 --- a/mm/src/code/z_vr_box.c +++ b/mm/src/code/z_vr_box.c @@ -29,7 +29,8 @@ const char* sD2CloudStaticTex[] = { gCloudySkybox1Tex, gCloudySkybox2Tex, gCloudySkybox3Tex, gCloudySkybox4Tex, gCloudySkybox5Tex, }; -SkyboxFiles skyboxFiles[] = { // 2S2H [Port] Renamed from files because of conflcit +SkyboxFiles skyboxFiles[] = { + // 2S2H [Port] Renamed from files because of conflcit { sD2FineStaticTex, gClearSkyboxTlue }, { sD2CloudStaticTex, gClearSkyboxTlue }, }; diff --git a/mm/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/mm/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 87728b6c6..bceca1c3d 100644 --- a/mm/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/mm/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -265,8 +265,9 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { CollisionCheck_SpawnShieldParticlesMetal(play, &this->actor.world.pos); Audio_PlaySfx_AtPos(&this->actor.projectedPos, NA_SE_IT_HOOKSHOT_REFLECT); } - } else if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, - BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN | BTN_DPAD_EQUIP)) { + } else if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | + BTN_CRIGHT | BTN_CDOWN | + BTN_DPAD_EQUIP)) { s32 pad; this->timer = 1; diff --git a/mm/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c b/mm/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c index 2e6f2b887..674304e10 100644 --- a/mm/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c +++ b/mm/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.c @@ -156,7 +156,6 @@ void func_80BD4720(BgIkanaBombwall* this, PlayState* play) { scale = D_80BD52C8[i & (ARRAY_COUNT(D_80BD52C8) - 1)]; - if (scale >= 16) { gravity = -550; } else { diff --git a/mm/src/overlays/actors/ovl_Boss_05/z_boss_05.c b/mm/src/overlays/actors/ovl_Boss_05/z_boss_05.c index 3390ed58b..6419384dd 100644 --- a/mm/src/overlays/actors/ovl_Boss_05/z_boss_05.c +++ b/mm/src/overlays/actors/ovl_Boss_05/z_boss_05.c @@ -283,10 +283,10 @@ void Boss05_Init(Actor* thisx, PlayState* play) { this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); func_809EEDD0(this, play); - SkelAnime_InitFlex(play, &this->skelAnime10, &gBioDekuBabaLilyPadSkel, &gBioDekuBabaLilyPadIdleAnim, this->jointTable10, this->morphTable10, - 10); - SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, this->jointTable20, this->morphTable20, - 20); + SkelAnime_InitFlex(play, &this->skelAnime10, &gBioDekuBabaLilyPadSkel, &gBioDekuBabaLilyPadIdleAnim, + this->jointTable10, this->morphTable10, 10); + SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, + this->jointTable20, this->morphTable20, 20); this->lastAnimFrame = Animation_GetLastFrame(&gBioDekuBabaHeadChompAnim); Collider_InitAndSetJntSph(play, &this->collider2, &this->dyna.actor, &D_809F1B74, this->colliderElements2); @@ -304,18 +304,18 @@ void Boss05_Init(Actor* thisx, PlayState* play) { CollisionHeader_GetVirtual(&sBioBabaLilypadCol, &colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); - SkelAnime_InitFlex(play, &this->skelAnime10, &gBioDekuBabaLilyPadSkel, &gBioDekuBabaLilyPadIdleAnim, this->jointTable10, this->morphTable10, - 10); + SkelAnime_InitFlex(play, &this->skelAnime10, &gBioDekuBabaLilyPadSkel, &gBioDekuBabaLilyPadIdleAnim, + this->jointTable10, this->morphTable10, 10); this->dyna.actor.flags &= ~ACTOR_FLAG_TARGETABLE; func_800BC154(play, &play->actorCtx, &this->dyna.actor, ACTORCAT_BG); } else if (this->dyna.actor.params == BIO_DEKU_BABA_TYPE_3) { this->actionFunc = func_809EFAB4; this->unk198 = 1.0f; - SkelAnime_InitFlex(play, &this->skelAnime10, &gBioDekuBabaLilyPadSkel, &gBioDekuBabaLilyPadIdleAnim, this->jointTable10, this->morphTable10, - 10); - SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, this->jointTable20, this->morphTable20, - 20); + SkelAnime_InitFlex(play, &this->skelAnime10, &gBioDekuBabaLilyPadSkel, &gBioDekuBabaLilyPadIdleAnim, + this->jointTable10, this->morphTable10, 10); + SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, + this->jointTable20, this->morphTable20, 20); this->lastAnimFrame = Animation_GetLastFrame(&gBioDekuBabaHeadChompAnim); Collider_InitAndSetJntSph(play, &this->collider2, &this->dyna.actor, &D_809F1B74, this->colliderElements2); @@ -327,8 +327,8 @@ void Boss05_Init(Actor* thisx, PlayState* play) { func_809F00CC(this, play); this->dyna.actor.colChkInfo.mass = 90; - SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, this->jointTable20, this->morphTable20, - 20); + SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, + this->jointTable20, this->morphTable20, 20); Collider_InitAndSetJntSph(play, &this->collider1, &this->dyna.actor, &D_809F1BDC, this->colliderElements1); @@ -336,8 +336,8 @@ void Boss05_Init(Actor* thisx, PlayState* play) { this->dyna.actor.colChkInfo.damageTable = &D_809F1C20; this->dyna.actor.flags |= ACTOR_FLAG_10 | ACTOR_FLAG_20; } else if (this->dyna.actor.params >= BIO_DEKU_BABA_TYPE_10) { - SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, this->jointTable20, this->morphTable20, - 20); + SkelAnime_InitFlex(play, &this->skelAnime20, &gBioDekuBabaHeadSkel, &gBioDekuBabaHeadChompAnim, + this->jointTable20, this->morphTable20, 20); this->dyna.actor.gravity = 0.0f; this->dyna.actor.world.rot.y = (s32)Rand_ZeroFloat(0x8000); diff --git a/mm/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/mm/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 45babf636..912ff71a6 100644 --- a/mm/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/mm/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -529,7 +529,8 @@ void Boss06_Draw(Actor* thisx, PlayState* play2) { if (this->unk_144 & 2) { temp_s0 = Math_SinS(D_809F4970->unk_144) * 1000.0f; temp_f10 = (Math_CosS(D_809F4970->unk_144) * -2000.0f) - 2000.0f; - // #region 2S2H fix a crash caused by modifying what would be a string. Load the verticies here so the correct thing is modified. + // #region 2S2H fix a crash caused by modifying what would be a string. Load the verticies here so the correct + // thing is modified. temp_v0_2 = ResourceMgr_LoadVtxByName(object_knight_Vtx_018BD0); // #endregion temp_v0_2[0].v.ob[1] = (s16)this->unk_1A0 + 0xE92; diff --git a/mm/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c b/mm/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c index 79e779366..fb0d2a612 100644 --- a/mm/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/mm/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -46,9 +46,8 @@ void DemoMoonend_Init(Actor* thisx, PlayState* play) { this->actionFunc = func_80C17B60; } else { Actor_SetScale(&this->actor, 0.095f); - Keyframe_InitFlex(&this->skeletonInfo, gMoonendKFSkel_B5A0, gMoonendKFAnim_1214, - this->jointTable, - this->morphTable, NULL); + Keyframe_InitFlex(&this->skeletonInfo, gMoonendKFSkel_B5A0, gMoonendKFAnim_1214, this->jointTable, + this->morphTable, NULL); Keyframe_FlexPlayOnce(&this->skeletonInfo, gMoonendKFAnim_1214); this->cueType = CS_CMD_ACTOR_CUE_560; this->actionFunc = func_80C17C48; diff --git a/mm/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/mm/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index 021a8174e..e8e553d37 100644 --- a/mm/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/mm/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -73,9 +73,8 @@ void DemoSyoten_Init(Actor* thisx, PlayState* play) { switch (DEMOSYOTEN_GET_F(&this->actor)) { case DEMOSYOTEN_F_0: - Keyframe_InitFlex(&this->unk_144, gSyotenKFSkel_1328, gSyotenKFAnim_023C, - this->unk_174, - this->unk_2A6, NULL); + Keyframe_InitFlex(&this->unk_144, gSyotenKFSkel_1328, gSyotenKFAnim_023C, this->unk_174, this->unk_2A6, + NULL); Keyframe_FlexPlayLoop(&this->unk_144, gSyotenKFAnim_023C); this->actor.draw = NULL; this->actionFunc = func_80C16A74; diff --git a/mm/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/mm/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index 496dddea7..2e0c7b134 100644 --- a/mm/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/mm/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -52,7 +52,7 @@ void EffChange_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.075f); this->primColors[3] = 0; Keyframe_InitFlex(&this->skeletonInfo, gGameplayKeepKFSkel_2900C, gGameplayKeepKFAnim_281DC, this->jointTable, - this->morphTable, NULL); + this->morphTable, NULL); Keyframe_FlexPlayOnce(&this->skeletonInfo, gGameplayKeepKFAnim_281DC); this->step = 0; this->actor.shape.rot.y = 0; diff --git a/mm/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c b/mm/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c index 6be333215..479ac0b11 100644 --- a/mm/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/mm/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -105,11 +105,14 @@ void func_80A2CF7C(ElfMsg3* this, PlayState* play) { Player* player = GET_PLAYER(play); EnElf* tatl = (EnElf*)player->tatlActor; - if (GameInteractor_Should(GI_VB_TATL_INTERUPT_MSG3, (((((player->tatlActor != NULL) && - (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x))) && - (this->actor.world.pos.y <= player->actor.world.pos.y)) && - ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) && - (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))), this)) { + if (GameInteractor_Should( + GI_VB_TATL_INTERUPT_MSG3, + (((((player->tatlActor != NULL) && + (fabsf(player->actor.world.pos.x - this->actor.world.pos.x) < (100.0f * this->actor.scale.x))) && + (this->actor.world.pos.y <= player->actor.world.pos.y)) && + ((player->actor.world.pos.y - this->actor.world.pos.y) < (100.0f * this->actor.scale.y))) && + (fabsf(player->actor.world.pos.z - this->actor.world.pos.z) < (100.0f * this->actor.scale.z))), + this)) { player->tatlTextId = func_80A2CF50(this); CutsceneManager_Queue(CS_ID_GLOBAL_TALK); tatl->elfMsg = &this->actor; diff --git a/mm/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c b/mm/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c index f5f36eeab..20af2ff5f 100644 --- a/mm/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/mm/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -237,8 +237,11 @@ void ElfMsg6_Destroy(Actor* thisx, PlayState* play) { } s32 func_80BA1C00(ElfMsg6* this) { - return GameInteractor_Should(GI_VB_TATL_INTERUPT_MSG6, ((this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && - ((this->actor.playerHeightRel >= 0.0f) && (this->actor.playerHeightRel < (100.0f * this->actor.scale.y)))), this); + return GameInteractor_Should( + GI_VB_TATL_INTERUPT_MSG6, + ((this->actor.xzDistToPlayer < (100.0f * this->actor.scale.x)) && + ((this->actor.playerHeightRel >= 0.0f) && (this->actor.playerHeightRel < (100.0f * this->actor.scale.y)))), + this); } void func_80BA1C88(ElfMsg6* this, PlayState* play, s16 arg2) { diff --git a/mm/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c b/mm/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c index 2a4620d86..7996b4e43 100644 --- a/mm/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c +++ b/mm/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c @@ -1013,7 +1013,6 @@ void EnBigslime_CallMinislime(EnBigslime* this, PlayState* play) { } } - void EnBigslime_SetupMoveOnCeiling(EnBigslime* this) { Animation_PlayLoop(&this->skelAnime, &gGekkoSwimForwardAnim); this->actor.gravity = 0.0f; @@ -1765,7 +1764,6 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, PlayState* play) { } } - void EnBigslime_SetupSetDynamicVtxThrowPlayer(EnBigslime* this, PlayState* play) { this->grabPlayerTimer = 10; EnBigslime_SetTargetVtxToWideCone(this); diff --git a/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 0be682708..3a8fc6d52 100644 --- a/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -787,7 +787,6 @@ void func_808726DC(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 a Math_Vec3f_Copy(arg1, &fuseSegmentPtr->pos); } - // 2S2H [Port] See comment in the draw function. #define dgPowderKegFuseTexLarger "__OTR__overlays/ovl_En_Bom/gPowderKegFuseTexLarger" static const ALIGN_ASSET(2) char gPowderKegFuseTexLarger[] = dgPowderKegFuseTexLarger; @@ -806,10 +805,9 @@ void EnBom_DrawKeg(PlayState* play, s32 timer) { gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - // 2S2H [Port] This was originally a static DL in the OTR file. The normal texture is too small to be rendered by Fast3D - // and causes a crash. - // This adds a custom texture in the OTR file and changes the DList to use the new size. At some point this should be - // done in the GFX patcher. + // 2S2H [Port] This was originally a static DL in the OTR file. The normal texture is too small to be rendered by + // Fast3D and causes a crash. This adds a custom texture in the OTR file and changes the DList to use the new size. + // At some point this should be done in the GFX patcher. gDPPipeSync(POLY_OPA_DISP++); gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); gSPClearGeometryMode(POLY_OPA_DISP++, G_CULL_BOTH); @@ -818,10 +816,10 @@ void EnBom_DrawKeg(PlayState* play, s32 timer) { gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); gSPTexture(POLY_OPA_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gDPLoadTextureBlock(POLY_OPA_DISP++, gPowderKegFuseTexLarger, G_IM_FMT_I, G_IM_SIZ_8b, 8, 8, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 1, G_TX_NOLOD, G_TX_NOLOD); + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 1, G_TX_NOLOD, G_TX_NOLOD); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 200, 0, 255); gSPVertex(POLY_OPA_DISP++, gPowderKegFuseVtx, 4, 0); - + temp_s5 = (timer / 240) + 1; fuseSegmentPtr2 = &sPowderKegFuseSegments[1]; // Bentodo the fuse is not visible enough to see if this is broken. Verify once the long timer crash is fixed. diff --git a/mm/src/overlays/actors/ovl_En_Death/z_en_death.c b/mm/src/overlays/actors/ovl_En_Death/z_en_death.c index ed234f3b0..447e080d6 100644 --- a/mm/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/mm/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -1567,8 +1567,7 @@ void EnDeath_DrawFlames(EnDeath* this, PlayState* play2) { gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 165, 255, 215, alpha); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - ((play->gameplayFrames + ((j + i) * 10)) * -20) & 511, 32, - 128)); + ((play->gameplayFrames + ((j + i) * 10)) * -20) & 511, 32, 128)); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); diff --git a/mm/src/overlays/actors/ovl_En_Dt/z_en_dt.c b/mm/src/overlays/actors/ovl_En_Dt/z_en_dt.c index 70fc957b1..387b7d79c 100644 --- a/mm/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/mm/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -87,8 +87,8 @@ static u8 D_80BEB2E0[] = { 0, 0, 2, 0, 0, 2 }; static s32 D_80BEB2E8[] = { 0, 1, 3, 1, 0, 2, 3, 1, 0, 3, 3, 1, 0, 3, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0 }; -static TexturePtr D_80BEB348[] = { gDotourEyeShockTex, gDotourEyeOpenTex, gDotourEyeClosedTex, - gDotourEyeLookDownTex, gDotourEyeSquintTex }; +static TexturePtr D_80BEB348[] = { gDotourEyeShockTex, gDotourEyeOpenTex, gDotourEyeClosedTex, gDotourEyeLookDownTex, + gDotourEyeSquintTex }; static TexturePtr D_80BEB35C[] = { &gDotourEyebrowHighTex, &gDotourEyebrowMidTex, &gDotourEyebrowLowTex }; diff --git a/mm/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/mm/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 7aa963fc4..bd80a27eb 100644 --- a/mm/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/mm/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -1671,7 +1671,7 @@ void EnEgol_DrawEffects(EnEgol* this, PlayState* play) { default: break; - FrameInterpolation_RecordCloseChild(); + FrameInterpolation_RecordCloseChild(); } Matrix_Pop(); } diff --git a/mm/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/mm/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index db2f5df8e..4d10f82bd 100644 --- a/mm/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/mm/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -36,9 +36,7 @@ void EnFall2_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 1.0f); this->actionFunc = EnFall2_DoNothing; - Keyframe_InitFlex(&this->skeletonInfo, gFall2KFSkel_8898, gFall2FKAnim_5EF4, - this->unk174, this->unk228, - NULL); + Keyframe_InitFlex(&this->skeletonInfo, gFall2KFSkel_8898, gFall2FKAnim_5EF4, this->unk174, this->unk228, NULL); Keyframe_FlexPlayLoop(&this->skeletonInfo, (void*)gFall2FKAnim_5EF4); this->unk2DC = Lib_SegmentedToVirtual((void*)object_fall2_Matanimheader_008840); Actor_SetScale(&this->actor, 0.02f); diff --git a/mm/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c b/mm/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c index 9cf9271bb..5cd3ce2a6 100644 --- a/mm/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c +++ b/mm/src/overlays/actors/ovl_En_Fsn/z_en_fsn.c @@ -1481,8 +1481,9 @@ void EnFsn_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - // #region 2S2H [Port] ENFSN_LIMB_MAX originally had a +1 because the game incorrectly thought the skel had 18 limbs when it - // only has 17. We also need to patch the count in skelAnime because it is reading the wrong number from the skeleton header. + // #region 2S2H [Port] ENFSN_LIMB_MAX originally had a +1 because the game incorrectly thought the skel had 18 limbs + // when it only has 17. We also need to patch the count in skelAnime because it is reading the wrong number from the + // skeleton header. SkelAnime_InitFlex(play, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, ENFSN_LIMB_MAX); this->skelAnime.limbCount = ENFSN_LIMB_MAX; diff --git a/mm/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/mm/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index e9754f333..abf909450 100644 --- a/mm/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/mm/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -104,8 +104,8 @@ void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { EnHiddenNuts* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_Init(play, &this->skelAnime, &object_hintnuts_Skel_0023B8, &object_hintnuts_Anim_0024CC, - this->jointTable, this->morphTable, OBJECT_HINTNUTS_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &object_hintnuts_Skel_0023B8, &object_hintnuts_Anim_0024CC, this->jointTable, + this->morphTable, OBJECT_HINTNUTS_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; diff --git a/mm/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/mm/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index 670a419ab..41a55bff2 100644 --- a/mm/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/mm/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -56,8 +56,9 @@ ActorInit En_Kbt_InitVars = { static JointIndex* origIndicies_004274; -// #region 2S2H [Port] This data originally stopped at the the entry { 0x000A, 0x000B, 0x000C }. -// The next 3 entries are set to zero because using the data the original game would have read would also have caused an OOB read +// #region 2S2H [Port] This data originally stopped at the the entry { 0x000A, 0x000B, 0x000C }. +// The next 3 entries are set to zero because using the data the original game would have read would also have caused an +// OOB read static JointIndex object_kbt_Anim_004274JointIndicesFixed[] = { { 0x0000, 0x000D, 0x0002 }, { 0x0003, 0x002B, 0x0003 }, { 0x0049, 0x0067, 0x0085 }, { 0x0000, 0x0000, 0x00A3 }, { 0x0000, 0x0000, 0x00C1 }, { 0x00DF, 0x00FD, 0x011B }, { 0x0000, 0x0000, 0x0139 }, { 0x0000, 0x0000, 0x0157 }, @@ -71,15 +72,15 @@ void EnKbt_Init(Actor* thisx, PlayState* play) { EnKbt* this = THIS; Actor_SetScale(&this->actor, 0.01f); - // #region 2S2H [Port] The animation object_kbt_Anim_004274 has the wrong number of joint indicies. It should have 20 but only has 17. - // We need to do the following steps to correct this. - // First we must tell the animation system to not load the animation when it initializes the skeleton. - // Then we must manually load the animation and change the joint index data see the static JointIndex data above for what we used for the data. - // Finally we manually set the animation - - SkelAnime_InitFlex(play, &this->skelAnime, &object_kbt_Skel_00DEE8, NULL, this->jointTable, - this->morphTable, OBJECT_KBT_LIMB_MAX); - + // #region 2S2H [Port] The animation object_kbt_Anim_004274 has the wrong number of joint indicies. It should have + // 20 but only has 17. We need to do the following steps to correct this. First we must tell the animation system to + // not load the animation when it initializes the skeleton. Then we must manually load the animation and change the + // joint index data see the static JointIndex data above for what we used for the data. Finally we manually set the + // animation + + SkelAnime_InitFlex(play, &this->skelAnime, &object_kbt_Skel_00DEE8, NULL, this->jointTable, this->morphTable, + OBJECT_KBT_LIMB_MAX); + AnimationHeader* anim = (AnimationHeader*)ResourceMgr_LoadAnimByName(object_kbt_Anim_004274); origIndicies_004274 = anim->jointIndices; @@ -87,7 +88,6 @@ void EnKbt_Init(Actor* thisx, PlayState* play) { Animation_PlayLoop(&this->skelAnime, object_kbt_Anim_004274); // #endregion - this->unk_27C = 0; this->actor.home.rot.z = 0; this->unk_27E = 4; diff --git a/mm/src/overlays/actors/ovl_En_Knight/z_en_knight.c b/mm/src/overlays/actors/ovl_En_Knight/z_en_knight.c index e0768627f..62f4b3c64 100644 --- a/mm/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/mm/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -473,7 +473,8 @@ void EnKnight_Init(Actor* thisx, PlayState* play) { if (this->actor.params == 0x64) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 12.0f); - SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_0201A8, &object_knight_Anim_003008, this->unk2C4, this->unk372, 29); + SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_0201A8, &object_knight_Anim_003008, this->unk2C4, + this->unk372, 29); Actor_SetScale(&this->actor, KREG(12) * 0.001f + 0.017f); func_809BA058(this, play); Collider_InitAndSetCylinder(play, &this->unk488, &this->actor, &D_809BDC38); @@ -485,10 +486,12 @@ void EnKnight_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~1; if (1) {} if (this->actor.params == 0xC8) { - SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_020374, &object_knight_Anim_0040E0, this->unk2C4, this->unk372, 0x1D); + SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_020374, &object_knight_Anim_0040E0, + this->unk2C4, this->unk372, 0x1D); Actor_SetScale(&this->actor, KREG(13) * 0.001f + 0.013f); } else { - SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_0201A8, &object_knight_Anim_0040E0, this->unk2C4, this->unk372, 0x1D); + SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_0201A8, &object_knight_Anim_0040E0, + this->unk2C4, this->unk372, 0x1D); Actor_SetScale(&this->actor, KREG(13) * 0.001f + 0.017f); } if (this->actor.params == 0xCA) { @@ -503,12 +506,14 @@ void EnKnight_Init(Actor* thisx, PlayState* play) { Collider_InitAndSetJntSph(play, &this->unk594, &this->actor, &D_809BDC28, this->unk5B4); if (this->actor.params == 0x23) { Collider_InitAndSetJntSph(play, &this->unk4D4, &this->actor, &D_809BDB8C, this->unk4F4); - SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_020374, &object_knight_Anim_0040E0, this->unk2C4, this->unk372, 0x1D); + SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_020374, &object_knight_Anim_0040E0, + this->unk2C4, this->unk372, 0x1D); this->actor.colChkInfo.health = 6 - BREG(40); Actor_SetScale(&this->actor, KREG(13) * 0.001f + 0.013f); } else { Collider_InitAndSetJntSph(play, &this->unk4D4, &this->actor, &D_809BDB9C, this->unk4F4); - SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_0201A8, &object_knight_Anim_0040E0, this->unk2C4, this->unk372, 0x1D); + SkelAnime_InitFlex(play, &this->unk194, &object_knight_Skel_0201A8, &object_knight_Anim_0040E0, + this->unk2C4, this->unk372, 0x1D); this->actor.colChkInfo.health = 14 - BREG(41); Actor_SetScale(&this->actor, KREG(12) * 0.001f + 0.017f); this->unk290 = Rand_ZeroFloat(1.9999f); diff --git a/mm/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/mm/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 31e90189b..f70cf1d9c 100644 --- a/mm/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/mm/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -550,8 +550,8 @@ void EnMag_DrawImageRGBA32HDSupport(Gfx** gfxp, s16 centerX, s16 centerY, Textur gDPLoadSync(gfx++); gDPLoadTile(gfx++, G_TX_LOADTILE, 0, 0, (width - 1) << 2, (height - 1) << 2); - gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + (s32)width) << 2, - (rectTop + height) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + (s32)width) << 2, (rectTop + height) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); *gfxp = gfx; } @@ -875,13 +875,12 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxp) { uint32_t gameVersion = ResourceMgr_GetGameVersion(0); if (gameVersion == MM_NTSC_US_GC) { - EnMag_DrawTextureIA8(&gfx, gTitleScreenCopyright2000NintendoTex, COPYRIGHT_TEX_WIDTH_GC, COPYRIGHT_TEX_HEIGHT, - COPYRIGHT_TEX_LEFT_GC, COPYRIGHT_TEX_TOP); + EnMag_DrawTextureIA8(&gfx, gTitleScreenCopyright2000NintendoTex, COPYRIGHT_TEX_WIDTH_GC, + COPYRIGHT_TEX_HEIGHT, COPYRIGHT_TEX_LEFT_GC, COPYRIGHT_TEX_TOP); } else { // Default: MM_NTSC_US_10 EnMag_DrawTextureIA8(&gfx, gTitleScreenCopyright2000NintendoTex, COPYRIGHT_TEX_WIDTH, COPYRIGHT_TEX_HEIGHT, - COPYRIGHT_TEX_LEFT, COPYRIGHT_TEX_TOP); + COPYRIGHT_TEX_LEFT, COPYRIGHT_TEX_TOP); } - } if (gSaveContext.fileNum == 0xFEDC) { diff --git a/mm/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c b/mm/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c index e3abe62d8..26109268d 100644 --- a/mm/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c +++ b/mm/src/overlays/actors/ovl_En_Neo_Reeba/z_en_neo_reeba.c @@ -412,7 +412,9 @@ void EnNeoReeba_SetupDamageAnim(EnNeoReeba* this) { this->actionFunc = EnNeoReeba_DamageAnim; } -static f32 sDamageAnimXZScales[] = { 0.04f, 0.04f, 0.039f, 0.042f, 0.045f, 0.043f, 0.04f, 0.035f, 0.03f, 0.033f, 0.04f }; +static f32 sDamageAnimXZScales[] = { + 0.04f, 0.04f, 0.039f, 0.042f, 0.045f, 0.043f, 0.04f, 0.035f, 0.03f, 0.033f, 0.04f +}; static f32 sDamageAnimYScales[] = { 0.04f, 0.04f, 0.041f, 0.038f, 0.035f, 0.037f, 0.04f, 0.045f, 0.05f, 0.047f, 0.04f }; void EnNeoReeba_DamageAnim(EnNeoReeba* this, PlayState* play) { diff --git a/mm/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/mm/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 65bc39cf1..dd24fbe43 100644 --- a/mm/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/mm/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -1392,7 +1392,8 @@ void EnOssan_CuriosityShopMan_Init(EnOssan* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gFsnSkel, &gFsnIdleAnim, this->jointTable, this->morphTable, ENOSSAN_LIMB_MAX); - // #region 2S2H [Port] We need to manually patch this skeleton because OBJECT_FSN lists the wrong amount. Same as in en_fsn + // #region 2S2H [Port] We need to manually patch this skeleton because OBJECT_FSN lists the wrong amount. Same as in + // en_fsn this->skelAnime.limbCount = ENOSSAN_LIMB_MAX; this->actor.draw = EnOssan_CuriosityShopMan_Draw; } diff --git a/mm/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/mm/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index 00295d5de..0c45c0e1a 100644 --- a/mm/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/mm/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -278,9 +278,9 @@ void EnPoComposer_SetupStartedCutscene(EnPoComposer* this) { this->actionFunc = EnPoComposer_StartedCutscene; } -// #region 2S2H [Port] There is an issue with MSVC where this function is removed in release mode and the check in EnPoComposer_UpdateAction fails. -// We need to do something in this function that has a side effect which will cause MSVC to not remove it. -// This modification seemed cleaner than `volatile int a = 5`. __declspec(noinlne) did not work. +// #region 2S2H [Port] There is an issue with MSVC where this function is removed in release mode and the check in +// EnPoComposer_UpdateAction fails. We need to do something in this function that has a side effect which will cause +// MSVC to not remove it. This modification seemed cleaner than `volatile int a = 5`. __declspec(noinlne) did not work. void EnPoComposer_StartedCutscene(EnPoComposer* this, PlayState* play) { sPlayerIsPlayingOcarina = false; } diff --git a/mm/src/overlays/actors/ovl_En_Raf/z_en_raf.c b/mm/src/overlays/actors/ovl_En_Raf/z_en_raf.c index b64dd5fd7..6619564e7 100644 --- a/mm/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/mm/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -186,9 +186,8 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; - -// #region 2S2H [Port] The original game set the texture pixel to zero to make it transparent. -// We need to set a mask to 1 to tell the shader to mask that part of the texture. +// #region 2S2H [Port] The original game set the texture pixel to zero to make it transparent. +// We need to set a mask to 1 to tell the shader to mask that part of the texture. // This applies to both functions. /** @@ -267,7 +266,6 @@ void EnRaf_Init(Actor* thisx, PlayState* play) { Gfx_RegisterBlendedTexture(gCarnivorousLilyPadTrapPetalTex, sCurPetalMask, NULL); Gfx_RegisterBlendedTexture(gCarnivorousLilyPadTrapTeethTex, sCurTeethMask, NULL); - } void EnRaf_Destroy(Actor* thisx, PlayState* play) { @@ -626,8 +624,10 @@ void EnRaf_Dissolve(EnRaf* this, PlayState* play) { for (i = 0; i < (BREG(4) + 5); i++) { //#region 2S2H [Port] Instead of directly zeroing the texture pixels, set a texture mask. // Applies to both loops. - EnRaf_ClearPixelPetal(sCurPetalMask, sPetalClearPixelTableFirstPass, this->petalClearPixelFirstPassIndex); - EnRaf_ClearPixelTeeth(sCurTeethMask, sTeethClearPixelTableFirstPass, this->teethClearPixelFirstPassIndex); + EnRaf_ClearPixelPetal(sCurPetalMask, sPetalClearPixelTableFirstPass, + this->petalClearPixelFirstPassIndex); + EnRaf_ClearPixelTeeth(sCurTeethMask, sTeethClearPixelTableFirstPass, + this->teethClearPixelFirstPassIndex); if (this->petalClearPixelFirstPassIndex < (16 * 32)) { this->petalClearPixelFirstPassIndex++; } @@ -890,7 +890,7 @@ void EnRaf_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL25_Opa(play->state.gfxCtx); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - + OPEN_DISPS(play->state.gfxCtx); // #2S2H [Port] Invalidate the blend masks when they are set in the cutscene @@ -903,7 +903,6 @@ void EnRaf_Draw(Actor* thisx, PlayState* play) { SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, EnRaf_TransformLimbDraw, &this->dyna.actor); - if (this->action == EN_RAF_ACTION_EXPLODE) { EnRaf_DrawEffects(this, play); diff --git a/mm/src/overlays/actors/ovl_En_Test/z_en_test.c b/mm/src/overlays/actors/ovl_En_Test/z_en_test.c index cda1901c1..b6048deaa 100644 --- a/mm/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/mm/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -186,9 +186,8 @@ void EnTest_Init(Actor* thisx, PlayState* play2) { this->surfaceMaterial = SurfaceType_GetMaterial(&play->colCtx, thisx->floorPoly, bgId); } - Keyframe_InitFlex(&this->skeletonInfo, gGameplayKeepKFSkel_6EB70, gGameplayKeepKFAnim_6BB0C, - this->unk_178, - this->unk_1C0, NULL); + Keyframe_InitFlex(&this->skeletonInfo, gGameplayKeepKFSkel_6EB70, gGameplayKeepKFAnim_6BB0C, this->unk_178, + this->unk_1C0, NULL); Keyframe_FlexPlayOnce(&this->skeletonInfo, gGameplayKeepKFAnim_6BB0C); this->skeletonInfo.frameCtrl.curTime = 9.0f; func_80862B70(this->unk_20C); @@ -196,7 +195,7 @@ void EnTest_Init(Actor* thisx, PlayState* play2) { void EnTest_Destroy(Actor* thisx, PlayState* play) { EnTest* this = THIS; - + Keyframe_DestroyFlex(&this->skeletonInfo); } diff --git a/mm/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/mm/src/overlays/actors/ovl_En_Test7/z_en_test7.c index da43f0c83..a9416eb7c 100644 --- a/mm/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/mm/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -398,7 +398,7 @@ void EnTest7_Init(Actor* thisx, PlayState* play2) { this->unk_1E94 = player->actor.scale.z; Keyframe_InitFlex(&this->unk_18CC, gGameplayKeepKFSkel_85640, gGameplayKeepKFAnim_83534, this->unk_18FC, - this->unk_1BA8, NULL); + this->unk_1BA8, NULL); Keyframe_FlexPlayOnce(&this->unk_18CC, gGameplayKeepKFAnim_83534); func_80AF0838(this->unk_15C); func_80AF1730(&this->unk_148); diff --git a/mm/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/mm/src/overlays/actors/ovl_En_Toto/z_en_toto.c index f68596cc8..2e234b5e8 100644 --- a/mm/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/mm/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -93,56 +93,21 @@ static InitChainEntry sInitChain[] = { }; static EnTotoText D_80BA502C[] = { - { 0, 0, 0x2B21 }, - { 3, 2, 0 }, - { 0, 0, 0x2B23 }, - { 2, 1, 0x2B24 }, - { 4, 0, 0x2B25 }, - { 3, 2, 0 }, - { 4, 0, 0x2B25 }, - { 16, 0, 0x2A94 }, - { 0, 0, 0x2A95 }, - { 4, 0, 0x2A96 }, - { 4, 0, 0x2A97 }, - { 0, 0, 0x2A98 }, - { 0, 0, 0x2A99 }, - { 4, 0, 0x2A9A }, - { 4, 0, 0x2A9B }, - { 0, 0, 0x2AE1 }, - { 0, 0, 0x2AE2 }, - { 4, 0, 0x2AE3 }, - { 4, 0, 0x2AE4 }, + { 0, 0, 0x2B21 }, { 3, 2, 0 }, { 0, 0, 0x2B23 }, { 2, 1, 0x2B24 }, { 4, 0, 0x2B25 }, + { 3, 2, 0 }, { 4, 0, 0x2B25 }, { 16, 0, 0x2A94 }, { 0, 0, 0x2A95 }, { 4, 0, 0x2A96 }, + { 4, 0, 0x2A97 }, { 0, 0, 0x2A98 }, { 0, 0, 0x2A99 }, { 4, 0, 0x2A9A }, { 4, 0, 0x2A9B }, + { 0, 0, 0x2AE1 }, { 0, 0, 0x2AE2 }, { 4, 0, 0x2AE3 }, { 4, 0, 0x2AE4 }, }; - static AnimationHeader* D_80BA5078[] = { &object_zm_Anim_0028B8, &object_zm_Anim_00B894, &object_zm_Anim_002F20, &object_zm_Anim_00BC08 }; static EnTotoText D_80BA5088[] = { - { 5, 0, 0 }, - { 6, 20, 0 }, - { 7, 0, 0 }, - { 8, 9, 0 }, - { 9, 10, 0 }, - { 1, 0, 0 }, - { 10, 0, 0 }, - { 11, 0, 0 }, - { 12, 0, 0 }, - { 13, 0, 0 }, - { 15, 0, 0 }, - { 17, 1, 0 }, - { 17, 0, 0 }, - { 5, 0, 0 }, - { 6, 20, 0 }, - { 8, 5, 0 }, - { 12, 0, 0 }, - { 13, 0, 0 }, - { 14, 20, 0x2B22 }, - { 1, 0, 0 }, - { 17, 0, 0 }, + { 5, 0, 0 }, { 6, 20, 0 }, { 7, 0, 0 }, { 8, 9, 0 }, { 9, 10, 0 }, { 1, 0, 0 }, { 10, 0, 0 }, + { 11, 0, 0 }, { 12, 0, 0 }, { 13, 0, 0 }, { 15, 0, 0 }, { 17, 1, 0 }, { 17, 0, 0 }, { 5, 0, 0 }, + { 6, 20, 0 }, { 8, 5, 0 }, { 12, 0, 0 }, { 13, 0, 0 }, { 14, 20, 0x2B22 }, { 1, 0, 0 }, { 17, 0, 0 }, }; - static EnTotoUnkStruct2 D_80BA50DC[] = { { 0x2B2F, 0x2B30, 0x2B31, { 0xFF96, 0x0016, 0xFE16 } }, { 0x2B26, 0x2B27, 0x2B28, { 0x0072, 0x0016, 0xFE3C } }, diff --git a/mm/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/mm/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 51f7b5897..5a2f7aee4 100644 --- a/mm/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/mm/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -1026,8 +1026,8 @@ void func_809924EC(EnWf* this, PlayState* play) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; - Animation_Change(&this->skelAnime, &gWolfosBackflipAnim, -1.0f, Animation_GetLastFrame(&gWolfosBackflipAnim), - 0.0f, ANIMMODE_ONCE, -3.0f); + Animation_Change(&this->skelAnime, &gWolfosBackflipAnim, -1.0f, Animation_GetLastFrame(&gWolfosBackflipAnim), 0.0f, + ANIMMODE_ONCE, -3.0f); this->unk_2A0 = 0; this->actor.speed = 6.5f; this->actor.velocity.y = 15.0f; diff --git a/mm/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/mm/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index fded9d6b6..951419e06 100644 --- a/mm/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/mm/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -553,8 +553,7 @@ void func_808DD3C8(Actor* thisx, PlayState* play2) { } // #pragma endregion - if ((screenPos.x >= xMin) && (screenPos.x < xMax) && (screenPos.y >= 0.0f) && - (screenPos.y < SCREEN_HEIGHT)) { + if ((screenPos.x >= xMin) && (screenPos.x < xMax) && (screenPos.y >= 0.0f) && (screenPos.y < SCREEN_HEIGHT)) { if (!spB4) { spB4 = true; @@ -637,8 +636,7 @@ void func_808DD970(Actor* thisx, PlayState* play2) { } // #pragma endregion - if ((screenPos.x >= xMin) && (screenPos.x < xMax) && (screenPos.y >= 0.0f) && - (screenPos.y < SCREEN_HEIGHT)) { + if ((screenPos.x >= xMin) && (screenPos.x < xMax) && (screenPos.y >= 0.0f) && (screenPos.y < SCREEN_HEIGHT)) { Matrix_Translate(worldPos.x, worldPos.y, worldPos.z, MTXMODE_NEW); Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); temp_f0 = Math_Vec3f_DistXYZ(&worldPos, &play->view.eye); diff --git a/mm/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/mm/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index b769f0e86..caaeab0cc 100644 --- a/mm/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/mm/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -200,7 +200,8 @@ void OceffStorm_Draw2(Actor* thisx, PlayState* play) { void OceffStorm_Draw(Actor* thisx, PlayState* play) { u32 scroll = play->state.frames & 0xFFF; OceffStorm* this = (OceffStorm*)thisx; - // #region 2S2H [Port] Originally this was just a pointer to the vertices, now it's the OTR path so we need to grab it's actual address + // #region 2S2H [Port] Originally this was just a pointer to the vertices, now it's the OTR path so we need to grab + // it's actual address Vtx* vtxPtr = ResourceMgr_LoadVtxByName(sSongOfStormsCylinderVtx); // #endregion diff --git a/mm/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/mm/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 65b4c9d06..91cd9bdda 100644 --- a/mm/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/mm/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -105,8 +105,8 @@ void OceffWipe_Draw(Actor* thisx, PlayState* play) { alphaTable[2] = 255; } - // 2S2H [Port] Originally this was just a pointer to the vertices, now it's the OTR path so we need to grab it's actual address - // and move out of loop as we don't need to load the resource each iteration + // 2S2H [Port] Originally this was just a pointer to the vertices, now it's the OTR path so we need to grab it's + // actual address and move out of loop as we don't need to load the resource each iteration vtxPtr = ResourceMgr_LoadVtxByName(sSongOfTimeFrustumVtx); for (i = 0; i < 20; i++) { diff --git a/mm/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c b/mm/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c index e30a6f764..d1825686d 100644 --- a/mm/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/mm/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -60,7 +60,6 @@ void OceffWipe5_Update(Actor* thisx, PlayState* play) { } } - static u8 sPrimColors[] = { 255, 255, 200, 255, 255, 200, 200, 255, 255, 255, 255, 200, 255, 200, 255, }; diff --git a/mm/src/overlays/actors/ovl_player_actor/z_player.c b/mm/src/overlays/actors/ovl_player_actor/z_player.c index 0bea7c470..7685e7dff 100644 --- a/mm/src/overlays/actors/ovl_player_actor/z_player.c +++ b/mm/src/overlays/actors/ovl_player_actor/z_player.c @@ -3707,7 +3707,7 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { if (btn <= EQUIP_SLOT_NONE) { DpadEquipSlot dpadBtn = func_Dpad_8082FD0C(this, maskItemAction); - + if (dpadBtn > EQUIP_SLOT_D_NONE) { btn = DPAD_TO_HELD_ITEM(dpadBtn); } @@ -3724,8 +3724,7 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { maskItem = GET_CUR_FORM_BTN_ITEM(this->unk_154); } - s32 maskIdMinusOne = - GET_MASK_FROM_IA(Player_ItemToItemAction(this, maskItem)) - 1; + s32 maskIdMinusOne = GET_MASK_FROM_IA(Player_ItemToItemAction(this, maskItem)) - 1; // #endregion if ((maskIdMinusOne < PLAYER_MASK_TRUTH - 1) || (maskIdMinusOne >= PLAYER_MASK_MAX - 1)) { @@ -3746,13 +3745,13 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { if (((this->actor.id == ACTOR_PLAYER) && (this->itemAction >= PLAYER_IA_FISHING_ROD)) && !(((Player_GetHeldBButtonSword(this) == PLAYER_B_SWORD_NONE) || (gSaveContext.jinxTimer == 0)) && (Player_ItemIsInUse(this, (IREG(1) != 0) ? ITEM_FISHING_ROD : Inventory_GetBtnBItem(play)) || - // #region 2S2H [Dpad] - (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) && - (Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_RIGHT)) || - Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_LEFT)) || - Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_DOWN)) || - Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_UP)))) || - // #end region + // #region 2S2H [Dpad] + (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0) && + (Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_RIGHT)) || + Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_LEFT)) || + Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_DOWN)) || + Player_ItemIsInUse(this, DPAD_BTN_ITEM(EQUIP_SLOT_D_UP)))) || + // #end region Player_ItemIsInUse(this, C_BTN_ITEM(EQUIP_SLOT_C_LEFT)) || Player_ItemIsInUse(this, C_BTN_ITEM(EQUIP_SLOT_C_DOWN)) || Player_ItemIsInUse(this, C_BTN_ITEM(EQUIP_SLOT_C_RIGHT))))) { @@ -7805,7 +7804,9 @@ s32 Player_ActionChange_4(Player* this, PlayState* play) { if (var_a1 != NULL) { if (!var_t1) { this->stateFlags2 |= PLAYER_STATE2_200000; - // This code is the same as the OoT code, except for the !CutsceneManager_IsNext(CS_ID_GLOBAL_TALK), which is what prevented Tatl ISG from working + // This code is the same as the OoT code, except for the + // !CutsceneManager_IsNext(CS_ID_GLOBAL_TALK), which is what prevented Tatl ISG from + // working bool vanillaCondition = !CutsceneManager_IsNext(CS_ID_GLOBAL_TALK); if (GameInteractor_Should(GI_VB_TATL_CONVERSATION_AVAILABLE, vanillaCondition, NULL) || !CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_CUP)) { @@ -9294,7 +9295,8 @@ s32 func_8083D738(Player* this, Actor* heldActor) { s32 Player_ActionChange_9(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_800) { if ((this->heldActor != NULL) && - CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A | BTN_DPAD_EQUIP)) { + CHECK_BTN_ANY(sPlayerControlInput->press.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A | BTN_DPAD_EQUIP)) { if (!func_808313A8(play, this, this->heldActor)) { if (!func_8083D738(this, this->heldActor)) { Player_SetAction(play, this, Player_Action_41, 1); @@ -9787,7 +9789,8 @@ void Player_ChooseIdleAnim(PlayState* play, Player* this) { } endFrame = Animation_GetLastFrame(anim); - if ((BEN_ANIM_EQUAL(this->skelAnime.animation, anim)) || (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_pz_attackAend)) || + if ((BEN_ANIM_EQUAL(this->skelAnime.animation, anim)) || + (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_pz_attackAend)) || (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_pz_attackBend)) || (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_pz_attackCend))) { morphFrames = 0.0f; @@ -12501,7 +12504,8 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) { if ((CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_L | BTN_R | BTN_A) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) || - (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_DRIGHT))) { + (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_L) && + CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_DRIGHT))) { sNoclipEnabled ^= 1; @@ -12519,7 +12523,7 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) { speed = 20.0f; } - //DebugCamera_ScreenText(3, 2, "DEBUG MODE"); + // DebugCamera_ScreenText(3, 2, "DEBUG MODE"); if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_L)) { if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { @@ -12552,9 +12556,10 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) { this->actor.gravity = 0.0f; this->actor.velocity.x = this->actor.velocity.y = this->actor.velocity.z = 0.0f; - //if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_DLEFT)) { - // Flags_SetTempClear(play, play->roomCtx.curRoom.num); - //} + // if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_L) && CHECK_BTN_ALL(sPlayerControlInput->press.button, + // BTN_DLEFT)) { + // Flags_SetTempClear(play, play->roomCtx.curRoom.num); + // } Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); @@ -12564,8 +12569,6 @@ s32 Player_UpdateNoclip(Player* this, PlayState* play) { return true; } - - void Player_Update(Actor* thisx, PlayState* play) { static Vec3f sDogSpawnPos; Player* this = (Player*)thisx; @@ -12574,15 +12577,14 @@ void Player_Update(Actor* thisx, PlayState* play) { Input input; s32 pad2; - // 2S2H [port] bring over SoH's noclip - //Could be an if else. I think this looks nicer. + // Could be an if else. I think this looks nicer. if (!Player_UpdateNoclip(this, play)) { goto skipUpdate; } this->stateFlags3 &= ~PLAYER_STATE3_10; - + // This block is a leftover dog-following mechanic from OoT if (gSaveContext.dogParams < 0) { if (Object_GetSlot(&play->objectCtx, OBJECT_DOG) < 0) { @@ -12629,7 +12631,7 @@ void Player_Update(Actor* thisx, PlayState* play) { GameInteractor_ExecuteOnPassPlayerInputs(&input); Player_UpdateCommon(this, play, &input); - skipUpdate: +skipUpdate: play->actorCtx.unk268 = 0; memset(&play->actorCtx.unk_26C, 0, sizeof(Input)); @@ -14068,8 +14070,10 @@ void Player_Action_4(Player* this, PlayState* play) { } if (animFinished || - ((this->currentMask == PLAYER_MASK_SCENTS) && (!BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_msbowait))) || - ((this->currentMask != PLAYER_MASK_SCENTS) && (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_msbowait)))) { + ((this->currentMask == PLAYER_MASK_SCENTS) && + (!BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_msbowait))) || + ((this->currentMask != PLAYER_MASK_SCENTS) && + (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_msbowait)))) { if (this->av2.actionVar2 != 0) { if (DECR(this->av2.actionVar2) == 0) { this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; @@ -14843,7 +14847,8 @@ void Player_Action_25(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_800) { heldActor = this->heldActor; if (!func_808313A8(play, this, heldActor) && (heldActor->id == ACTOR_EN_NIW) && - CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A | BTN_DPAD_EQUIP)) { + CHECK_BTN_ANY(sPlayerControlInput->press.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A | BTN_DPAD_EQUIP)) { func_808409A8(play, this, this->linearVelocity + 2.0f, this->actor.velocity.y + 2.0f); } } @@ -15289,7 +15294,8 @@ void Player_Action_33(Player* this, PlayState* play) { Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_CLIMB_END); } - if ((BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_link_normal_100step_up)) || (this->skelAnime.curFrame > 5.0f)) { + if ((BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_link_normal_100step_up)) || + (this->skelAnime.curFrame > 5.0f)) { if (this->av2.actionVar2 == 0) { Player_AnimSfx_PlayFloorJump(this); this->av2.actionVar2 = 1; @@ -15574,7 +15580,8 @@ void Player_Action_38(Player* this, PlayState* play) { } else if (PlayerAnimation_OnFrame(&this->skelAnime, 25.0f)) { Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_L); } - } else if (CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A | BTN_DPAD_EQUIP)) { + } else if (CHECK_BTN_ANY(sPlayerControlInput->press.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A | BTN_DPAD_EQUIP)) { Player_SetAction(play, this, Player_Action_39, 1); Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_silver_throw); } @@ -17052,9 +17059,10 @@ void func_808525C4(PlayState* play, Player* this) { } void Player_Action_63(Player* this, PlayState* play) { - if ((this->unk_AA5 != PLAYER_UNKAA5_4) && ((PlayerAnimation_Update(play, &this->skelAnime) && - (BEN_ANIM_EQUAL(this->skelAnime.animation, D_8085D17C[this->transformation]))) || - ((this->skelAnime.mode == 0) && (this->av2.actionVar2 == 0)))) { + if ((this->unk_AA5 != PLAYER_UNKAA5_4) && + ((PlayerAnimation_Update(play, &this->skelAnime) && + (BEN_ANIM_EQUAL(this->skelAnime.animation, D_8085D17C[this->transformation]))) || + ((this->skelAnime.mode == 0) && (this->av2.actionVar2 == 0)))) { func_808525C4(play, this); if (!(this->actor.flags & ACTOR_FLAG_20000000) || (this->unk_A90->id == ACTOR_EN_ZOT)) { Message_DisplayOcarinaStaff(play, OCARINA_ACTION_FREE_PLAY); @@ -17483,7 +17491,8 @@ void Player_Action_68(Player* this, PlayState* play) { } // #region 2S2H [Dpad] else if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { - if (Player_Dpad_GetItemOnButton(play, this, HELD_ITEM_TO_DPAD(this->heldItemButton)) == ITEM_BOTTLE) { + if (Player_Dpad_GetItemOnButton(play, this, HELD_ITEM_TO_DPAD(this->heldItemButton)) == + ITEM_BOTTLE) { Actor* interactRangeActor = this->interactRangeActor; if (interactRangeActor != NULL) { @@ -17492,8 +17501,8 @@ void Player_Action_68(Player* this, PlayState* play) { for (i = 0; i < ARRAY_COUNT(D_8085D798); i++) { if (((interactRangeActor->id == entry->actorId) && - ((entry->actorParams <= BOTTLE_CATCH_PARAMS_ANY) || - (interactRangeActor->params == entry->actorParams)))) { + ((entry->actorParams <= BOTTLE_CATCH_PARAMS_ANY) || + (interactRangeActor->params == entry->actorParams)))) { break; } entry++; @@ -17877,7 +17886,7 @@ void Player_Action_80(Player* this, PlayState* play) { if ((play->sceneId == SCENE_20SICHITAI) && (Player_Dpad_GetItemOnButton(play, this, func_Dpad_8082FDC4()) == ITEM_PICTOGRAPH_BOX)) { play->actorCtx.flags |= ACTORCTX_FLAG_PICTO_BOX_ON; - } + } } // #endregion } @@ -18197,7 +18206,8 @@ AnimSfxEntry D_8085D904[] = { }; void func_80855218(PlayState* play, Player* this, struct_8085D910** arg2) { - if (PlayerAnimation_Update(play, &this->skelAnime) && (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_setmask))) { + if (PlayerAnimation_Update(play, &this->skelAnime) && + (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_setmask))) { func_8082DB60(play, this, &gPlayerAnim_cl_setmaskend); } else if ((BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_setmask)) || (BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_cl_setmaskend))) { @@ -18249,7 +18259,8 @@ void Player_Action_86(Player* this, PlayState* play) { struct_8085D910* sp4C = D_8085D910; s32 sp48 = false; - if (GameInteractor_Should(GI_VB_PREVENT_MASK_TRANSFORMATION_CS, false, NULL)) return; + if (GameInteractor_Should(GI_VB_PREVENT_MASK_TRANSFORMATION_CS, false, NULL)) + return; func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_MASK_TRANSFORMATION]); sPlayerControlInput = play->state.input; @@ -18482,7 +18493,8 @@ void Player_Action_92(Player* this, PlayState* play) { this->stateFlags2 &= ~PLAYER_STATE2_400; this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; this->stateFlags3 |= PLAYER_STATE3_10000; - } else if ((!BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_link_hook_fly_start)) || (this->skelAnime.curFrame >= 4.0f)) { + } else if ((!BEN_ANIM_EQUAL(this->skelAnime.animation, gPlayerAnim_link_hook_fly_start)) || + (this->skelAnime.curFrame >= 4.0f)) { this->actor.gravity = 0.0f; Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 0x800); Player_RequestRumble(play, this, 100, 2, 100, SQ(0)); diff --git a/mm/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c b/mm/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c index 8db81594d..87ad1424b 100644 --- a/mm/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c +++ b/mm/src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c @@ -1327,12 +1327,8 @@ TexturePtr sFileSelRemainsTextures[] = { // day 4. TexturePtr sFileSelDayENGTextures[] = { - gFileSelFirstDayENGTex, - gFileSelFirstDayENGTex, - gFileSelSecondDayENGTex, - gFileSelFinalDayENGTex, - gFileSelFourthDayTex, - gFileSelCheatingDayTex, + gFileSelFirstDayENGTex, gFileSelFirstDayENGTex, gFileSelSecondDayENGTex, + gFileSelFinalDayENGTex, gFileSelFourthDayTex, gFileSelCheatingDayTex, }; TexturePtr sFileSelHeartPieceTextures[] = { @@ -1582,7 +1578,8 @@ void FileSelect_DrawFileInfo(GameState* thisx, s16 fileIndex) { gSPVertex(POLY_OPA_DISP++, &this->windowContentVtx[D_80814654[fileIndex] + 0xDC], 8, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 0, 0, 0, this->fileInfoAlpha[fileIndex]); - // 2S2H [Port] When making an owl save on day 4 the texture was currupt. We also decided to add a texture for going past day 4. + // 2S2H [Port] When making an owl save on day 4 the texture was currupt. We also decided to add a texture for + // going past day 4. uint32_t dayIndex = CLAMP_MAX(this->day[sp20C], 5); gDPLoadTextureBlock_4b(POLY_OPA_DISP++, sFileSelDayENGTextures[dayIndex], G_IM_FMT_I, 48, 24, 0, diff --git a/mm/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c b/mm/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c index 902f3ae32..e5b1d3a07 100644 --- a/mm/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c +++ b/mm/src/overlays/gamestates/ovl_file_choose/z_file_nameset_NES.c @@ -37,17 +37,11 @@ s16 D_80814280[] = { 1, 1, 1, 2, 2, 2, 2, 2, 3, 2, 2, 4, 3, 2, 4, 1, 2, 2, 1, 1, 2, 2, 3, 2, 2, 0, 2, 2, 2, 0, 3, 1, 0, }; -s16 D_80814304[] = { - 1, 2, 0, 1, 1, 2, 1, 1, 4, 2, 2, 2, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, - 2, 2, 4, 3, 2, 4, 1, 2, 2, 1, 1, 2, 2, 3, 2, 2, 0, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, - 0 -}; +s16 D_80814304[] = { 1, 2, 0, 1, 1, 2, 1, 1, 4, 2, 2, 2, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 2, + 2, 4, 3, 2, 4, 1, 2, 2, 1, 1, 2, 2, 3, 2, 2, 0, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 0 }; -s16 D_80814384[] = { - 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0 -}; +s16 D_80814384[] = { 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }; s16 D_80814404[] = { -94, -96, -48, 0, 32, 64, @@ -973,18 +967,18 @@ void FileSelect_DrawOptionsImpl_NES_GC(GameState* thisx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, this->titleAlpha[FS_TITLE_CUR]); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); } - + gDPLoadTextureBlock(POLY_OPA_DISP++, gOptionsMenuHeaders[i].texture, G_IM_FMT_IA, G_IM_SIZ_8b, - gOptionsMenuHeaders[i].width, gOptionsMenuHeaders[i].height, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gOptionsMenuHeaders[i].width, gOptionsMenuHeaders[i].height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); } else { gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gOptionsMenuHeaders[i].texture, G_IM_FMT_IA, - gOptionsMenuHeaders[i].width, gOptionsMenuHeaders[i].height, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + gOptionsMenuHeaders[i].width, gOptionsMenuHeaders[i].height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); } gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); - } gDPPipeSync(POLY_OPA_DISP++); @@ -1012,8 +1006,9 @@ void FileSelect_DrawOptionsImpl_NES_GC(GameState* thisx) { } gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gOptionsMenuSettings[i].texture, G_IM_FMT_IA, - gOptionsMenuSettings[i].width, gOptionsMenuSettings[i].height, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gOptionsMenuSettings[i].width, gOptionsMenuSettings[i].height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); } @@ -1035,8 +1030,9 @@ void FileSelect_DrawOptionsImpl_NES_GC(GameState* thisx) { } gDPLoadTextureBlock_4b(POLY_OPA_DISP++, gOptionsMenuSettings[i].texture, G_IM_FMT_IA, - gOptionsMenuSettings[i].width, gOptionsMenuSettings[i].height, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gOptionsMenuSettings[i].width, gOptionsMenuSettings[i].height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); } @@ -1049,7 +1045,7 @@ void FileSelect_DrawOptionsImpl_NES_GC(GameState* thisx) { G_TX_NOLOD); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 55, 55, 55, this->titleAlpha[FS_TITLE_CUR]); gDPSetEnvColor(POLY_OPA_DISP++, 40, 40, 40, 255); - gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); + gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); vtx += 4; diff --git a/mm/src/overlays/gamestates/ovl_title/z_title.c b/mm/src/overlays/gamestates/ovl_title/z_title.c index 3357d1928..6cf5bdf59 100644 --- a/mm/src/overlays/gamestates/ovl_title/z_title.c +++ b/mm/src/overlays/gamestates/ovl_title/z_title.c @@ -161,11 +161,10 @@ void ConsoleLogo_Draw(GameState* thisx) { for (idx = 0, y = 94; idx < 16; idx++, y += 2) { // #region 2S2H [Port] Use LoadMultiTile so we can pass the resource path and control which bytes are loaded - gDPLoadMultiTile(POLY_OPA_DISP++, logoText, 0, G_TX_RENDERTILE, G_IM_FMT_I, G_IM_SIZ_8b, 192, 32, - 0, idx * 2, 192 - 1, (idx + 1) * 2 - 1, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gDPSetTileSize(POLY_OPA_DISP++, 0, 0, 0, (192 - 1) << G_TEXTURE_IMAGE_FRAC, - (2 - 1) << G_TEXTURE_IMAGE_FRAC); + gDPLoadMultiTile(POLY_OPA_DISP++, logoText, 0, G_TX_RENDERTILE, G_IM_FMT_I, G_IM_SIZ_8b, 192, 32, 0, idx * 2, + 192 - 1, (idx + 1) * 2 - 1, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileSize(POLY_OPA_DISP++, 0, 0, 0, (192 - 1) << G_TEXTURE_IMAGE_FRAC, (2 - 1) << G_TEXTURE_IMAGE_FRAC); // #endregion gDPSetTileSize(POLY_OPA_DISP++, 1, this->uls, (this->ult & 0x7F) - idx * 4, 0, 0); diff --git a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c index 3ebded15e..da4c9476a 100644 --- a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c +++ b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_collect.c @@ -540,9 +540,9 @@ void KaleidoScope_DrawQuestStatus(PlayState* play) { for (j = 0; j < 3; j++, i += 4) { if ((j >= 2) || (skullTokenDigits[j] != 0) || isDigitDrawn) { // 2S2H [Port] Don't do pointer math and access the texture directly. - gDPLoadTextureBlock(POLY_OPA_DISP++, sCounterTextures[skullTokenDigits[j]], - G_IM_FMT_I, G_IM_SIZ_8b, 8, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_OPA_DISP++, sCounterTextures[skullTokenDigits[j]], G_IM_FMT_I, G_IM_SIZ_8b, + 8, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, i, i + 2, i + 3, i + 1, 0); diff --git a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c index 81b14976f..2f4d4a0b9 100644 --- a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c +++ b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.c @@ -228,14 +228,13 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, // Draw upper digit if (ammoUpperDigit != 0) { POLY_OPA_DISP = - Gfx_DrawTexRectIA8(POLY_OPA_DISP,gAmmoDigitTextures[ammoUpperDigit], 8, 8, - sAmmoRectLeft[ammoIndex], sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + Gfx_DrawTexRectIA8(POLY_OPA_DISP, gAmmoDigitTextures[ammoUpperDigit], 8, 8, sAmmoRectLeft[ammoIndex], + sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); } // Draw lower digit - POLY_OPA_DISP = - Gfx_DrawTexRectIA8(POLY_OPA_DISP, gAmmoDigitTextures[ammo], 8, 8, sAmmoRectLeft[ammoIndex] + 6, - sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + POLY_OPA_DISP = Gfx_DrawTexRectIA8(POLY_OPA_DISP, gAmmoDigitTextures[ammo], 8, 8, sAmmoRectLeft[ammoIndex] + 6, + sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); CLOSE_DISPS(gfxCtx); } @@ -322,8 +321,8 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { pauseCtx->itemVtx[j + 0].v.ob[1] - 32; } } - // #region 2S2H [Port] Originally this was done in KaleidoScope_Update, but now we are using gSPGrayscale on the fly - // It reads odd here to assign a u8 to a u16, then cast it to s32 for gPlayerFormItemRestrictions + // #region 2S2H [Port] Originally this was done in KaleidoScope_Update, but now we are using gSPGrayscale on + // the fly It reads odd here to assign a u8 to a u16, then cast it to s32 for gPlayerFormItemRestrictions // but this matches the behavior of the original code u16 itemId = gSaveContext.save.saveInfo.inventory.items[i]; if (!gPlayerFormItemRestrictions[GET_PLAYER_FORM][(s32)itemId]) { @@ -626,7 +625,8 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // Equip item to the C buttons if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && (pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && - CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT | BTN_DPAD_EQUIP)) { + CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, + BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT | BTN_DPAD_EQUIP)) { // Ensure that a transformation mask can not be unequipped while being used if (GET_PLAYER_FORM != PLAYER_FORM_HUMAN) { @@ -650,7 +650,8 @@ void KaleidoScope_UpdateItemCursor(PlayState* play) { // #region 2S2H [Dpad] else if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_DRIGHT)) { - if (sPlayerFormItems[GET_PLAYER_FORM] == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT)) { + if (sPlayerFormItems[GET_PLAYER_FORM] == + DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT)) { Audio_PlaySfx(NA_SE_SY_ERROR); return; } @@ -805,8 +806,8 @@ void KaleidoScope_SwapDpadItemToCItem(PlayState* play, EquipSlot cEquipSlot) { if ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) == ITEM_BOW) || - (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && - ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -822,8 +823,8 @@ void KaleidoScope_SwapDpadItemToCItem(PlayState* play, EquipSlot cEquipSlot) { if ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) == ITEM_BOW) || - (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && - ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -839,8 +840,8 @@ void KaleidoScope_SwapDpadItemToCItem(PlayState* play, EquipSlot cEquipSlot) { if ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) == ITEM_BOW) || - (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && - ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -856,8 +857,8 @@ void KaleidoScope_SwapDpadItemToCItem(PlayState* play, EquipSlot cEquipSlot) { if ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) == ITEM_BOW) || - (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && - ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) >= ITEM_BOW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, cEquipSlot) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -881,8 +882,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -898,8 +899,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -915,8 +916,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -932,8 +933,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -949,8 +950,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -966,8 +967,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -981,12 +982,11 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { } } - // Special case for magic arrows if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) == ITEM_BOW) || ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT))) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } @@ -996,23 +996,23 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT); Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT); Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT); Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_LEFT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_DOWN); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_UP); } @@ -1028,8 +1028,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1045,8 +1045,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1062,8 +1062,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1079,8 +1079,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1096,8 +1096,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1113,8 +1113,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1128,12 +1128,11 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { } } - // Special case for magic arrows if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) == ITEM_BOW) || ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT))) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } @@ -1143,23 +1142,23 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT); Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT); Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT); Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_DOWN); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_UP); } @@ -1175,8 +1174,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1192,8 +1191,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1209,8 +1208,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1226,8 +1225,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1243,8 +1242,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1260,8 +1259,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1275,12 +1274,11 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { } } - // Special case for magic arrows if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) == ITEM_BOW) || ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT))) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } @@ -1290,23 +1288,23 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN); Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN); Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN); Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_LEFT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_UP); } @@ -1322,8 +1320,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1339,8 +1337,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1356,8 +1354,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1373,8 +1371,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1390,8 +1388,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1407,8 +1405,8 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) != ITEM_NONE) { if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) == ITEM_BOW) || - (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && - ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { + (((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) >= ITEM_BOW_FIRE) && + ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) & 0xFF) <= ITEM_BOW_LIGHT)))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } else { @@ -1422,12 +1420,11 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { } } - // Special case for magic arrows if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) == ITEM_BOW) || ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT))) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT))) { pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_FIRE; pauseCtx->equipTargetSlot = SLOT_BOW; } @@ -1437,23 +1434,23 @@ void KaleidoScope_UpdateDpadItemEquip(PlayState* play) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP); Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP); Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_FIRE) && - (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_LIGHT)) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP); Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_LEFT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) = DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_DOWN); } @@ -1659,22 +1656,22 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { // #region 2S2H [Dpad] // Note Only C-Left has the swap of 'slot equips' here if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); DPAD_SLOT_EQUIP(0, EQUIP_SLOT_D_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); DPAD_SLOT_EQUIP(0, EQUIP_SLOT_D_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_LEFT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); DPAD_SLOT_EQUIP(0, EQUIP_SLOT_D_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_DOWN); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); DPAD_SLOT_EQUIP(0, EQUIP_SLOT_D_UP) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_UP); @@ -1748,19 +1745,19 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { // #region 2S2H [Dpad] // Note Only C-Left has the swap of 'slot equips' here if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_LEFT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_DOWN); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_UP); } @@ -1771,7 +1768,8 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); - } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) { // #Region 2S2H [Dpad] Added condition here to allow for other cases + } else if (pauseCtx->equipTargetCBtn == + PAUSE_EQUIP_C_RIGHT) { // #Region 2S2H [Dpad] Added condition here to allow for other cases // Swap if item is already equipped on CLeft or CDown. if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { @@ -1833,19 +1831,19 @@ void KaleidoScope_UpdateItemEquip(PlayState* play) { // #region 2S2H [Dpad] // Note Only C-Left has the swap of 'slot equips' here if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_RIGHT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_LEFT); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_DOWN); } else if ((DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) >= ITEM_BOW_FIRE) && - (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { + (DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) <= ITEM_BOW_LIGHT)) { DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); Interface_Dpad_LoadItemIcon(play, EQUIP_SLOT_D_UP); } diff --git a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c index e6fdb3bb3..d0e23c839 100644 --- a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c +++ b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_map.c @@ -33,8 +33,8 @@ void KaleidoScope_DrawDungeonStrayFairyCount(PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 255); - POLY_OPA_DISP = Gfx_DrawTexRectI8(POLY_OPA_DISP, sCounterTextures[counterDigits[digitIndex]], - 8, 16, rectLeft + 1, 146, 8, 16, 1 << 10, 1 << 10); + POLY_OPA_DISP = Gfx_DrawTexRectI8(POLY_OPA_DISP, sCounterTextures[counterDigits[digitIndex]], 8, 16, + rectLeft + 1, 146, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); @@ -66,8 +66,8 @@ void KaleidoScope_DrawDungeonStrayFairyCount(PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 255); - POLY_OPA_DISP = Gfx_DrawTexRectI8(POLY_OPA_DISP, sCounterTextures[counterDigits[digitIndex]], - 8, 16, rectLeft + 1, 146, 8, 16, 1 << 10, 1 << 10); + POLY_OPA_DISP = Gfx_DrawTexRectI8(POLY_OPA_DISP, sCounterTextures[counterDigits[digitIndex]], 8, 16, + rectLeft + 1, 146, 8, 16, 1 << 10, 1 << 10); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); @@ -572,9 +572,9 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Process the 128 rows of pixels for gWorldMapImageTex, 8 rows at a time over 16 iterations // Loop over yPos (t), textureIndex (j) for (t = 62, j = 0; j < 16; j++, t += 8) { - gDPLoadTextureBlock(POLY_OPA_DISP++, &tex[j * (WORLD_MAP_IMAGE_WIDTH * 8)], G_IM_FMT_CI, - G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_OPA_DISP++, &tex[j * (WORLD_MAP_IMAGE_WIDTH * 8)], G_IM_FMT_CI, G_IM_SIZ_8b, + WORLD_MAP_IMAGE_WIDTH, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); rectLeft = 51 << 2; rectRight = rectLeft + (WORLD_MAP_IMAGE_WIDTH << 2); @@ -608,12 +608,12 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Process the first 72 rows of pixels for gWorldMapImageTex, 9 rows at a time over 8 iterations // Loop over quadIndex of this loop (i), quadIndex of the entire texture (k), vtxIndex (j) - char* tex = ResourceMgr_LoadTexOrDListByName(gWorldMapImageTex); + char* tex = ResourceMgr_LoadTexOrDListByName(gWorldMapImageTex); for (i = 0, k = 0, j = 0; i < 8; i++, k++, j += 4) { - gDPLoadTextureBlock( - POLY_OPA_DISP++, &tex[k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT)], - G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_FRAG_HEIGHT, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_OPA_DISP++, &tex[k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT)], + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_FRAG_HEIGHT, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); } @@ -626,19 +626,19 @@ void KaleidoScope_DrawWorldMap(PlayState* play) { // Loop over quadIndex of this loop (i), quadIndex of the entire texture (k), vtxIndex (j) for (i = 0, j = 0; i < 6; i++, k++, j += 4) { gDPLoadTextureBlock(POLY_OPA_DISP++, &tex[k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT)], - G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_FRAG_HEIGHT, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_FRAG_HEIGHT, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); } // Process the last 2 rows of pixels for gWorldMapImageTex - gDPLoadTextureBlock( - POLY_OPA_DISP++, &tex[k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT)], - G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, WORLD_MAP_IMAGE_HEIGHT % WORLD_MAP_IMAGE_FRAG_HEIGHT, 0, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(POLY_OPA_DISP++, &tex[k * (WORLD_MAP_IMAGE_WIDTH * WORLD_MAP_IMAGE_FRAG_HEIGHT)], + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_WIDTH, + WORLD_MAP_IMAGE_HEIGHT % WORLD_MAP_IMAGE_FRAG_HEIGHT, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); - } Gfx_SetupDL42_Opa(play->state.gfxCtx); diff --git a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c index 2df28e871..5b85511cc 100644 --- a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c +++ b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_mask.c @@ -586,33 +586,37 @@ void KaleidoScope_UpdateMaskCursor(PlayState* play) { else if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) { if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && - (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT))) || + (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT))) || ((sMaskPlayerFormItems[GET_PLAYER_FORM] != ITEM_NONE) && - (sMaskPlayerFormItems[GET_PLAYER_FORM] == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT)))) { + (sMaskPlayerFormItems[GET_PLAYER_FORM] == + DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_RIGHT)))) { Audio_PlaySfx(NA_SE_SY_ERROR); return; } } else if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) { if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && - (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT))) || + (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT))) || ((sMaskPlayerFormItems[GET_PLAYER_FORM] != ITEM_NONE) && - (sMaskPlayerFormItems[GET_PLAYER_FORM] == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT)))) { + (sMaskPlayerFormItems[GET_PLAYER_FORM] == + DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_LEFT)))) { Audio_PlaySfx(NA_SE_SY_ERROR); return; } } else if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && - (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN))) || + (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN))) || ((sMaskPlayerFormItems[GET_PLAYER_FORM] != ITEM_NONE) && - (sMaskPlayerFormItems[GET_PLAYER_FORM] == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN)))) { + (sMaskPlayerFormItems[GET_PLAYER_FORM] == + DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_DOWN)))) { Audio_PlaySfx(NA_SE_SY_ERROR); return; } } else if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) { if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && - (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP))) || + (Player_GetCurMaskItemId(play) == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP))) || ((sMaskPlayerFormItems[GET_PLAYER_FORM] != ITEM_NONE) && - (sMaskPlayerFormItems[GET_PLAYER_FORM] == DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP)))) { + (sMaskPlayerFormItems[GET_PLAYER_FORM] == + DPAD_BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_D_UP)))) { Audio_PlaySfx(NA_SE_SY_ERROR); return; } @@ -1185,7 +1189,8 @@ void KaleidoScope_UpdateMaskEquip(PlayState* play) { BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); - } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) { // #region 2S2H [Dpad] Added condition here to allow for other cases + } else if (pauseCtx->equipTargetCBtn == + PAUSE_EQUIP_C_RIGHT) { // #region 2S2H [Dpad] Added condition here to allow for other cases // Swap if mask is already equipped on CLeft or CDown. if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { @@ -1215,7 +1220,7 @@ void KaleidoScope_UpdateMaskEquip(PlayState* play) { C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); } - // #region 2S2H [Dpad] + // #region 2S2H [Dpad] else if (CVarGetInteger("gEnhancements.Dpad.DpadEquips", 0)) { KaleidoScope_UpdateDpadMaskEquip(play); } diff --git a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c index 6828f3840..169d880f8 100644 --- a/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c +++ b/mm/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope_NES.c @@ -263,7 +263,7 @@ void Kaleido_LoadMapNameStatic(void* segment, u32 texIndex) { }; void* tex = ResourceMgr_LoadTexOrDListByName(gMapNameStatics[texIndex]); memcpy(segment, tex, 0x400); - //CmpDma_LoadFile(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0x400); + // CmpDma_LoadFile(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0x400); } //! note: nothing from `map_name_static` is of size `0xA00` in US 1.0 @@ -396,7 +396,7 @@ void Kaleido_LoadItemNameStatic(void* segment, u32 texIndex) { }; void* tex = ResourceMgr_LoadTexOrDListByName(gItemNameStatics[texIndex]); memcpy(segment, tex, 0x400); - //CmpDma_LoadFile(SEGMENT_ROM_START(item_name_static), texIndex, segment, 0x400); + // CmpDma_LoadFile(SEGMENT_ROM_START(item_name_static), texIndex, segment, 0x400); } void KaleidoScope_MoveCursorToSpecialPos(PlayState* play, s16 cursorSpecialPos) { @@ -439,9 +439,12 @@ void KaleidoScope_MoveCursorFromSpecialPos(PlayState* play) { gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; // #region 2S2H [Dpad] - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_RIGHT] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_LEFT] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_DOWN] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_RIGHT] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_LEFT] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_DOWN] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_UP] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + 1][1]; // #endregion gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; @@ -612,9 +615,9 @@ static TexturePtr sSaveTexs[] = { }; static TexturePtr sGameOverTexs[] = { - gPauseSave00Tex, gPauseSave01Tex, gPauseSave02Tex, gPauseSave03Tex, gPauseSave04Tex, + gPauseSave00Tex, gPauseSave01Tex, gPauseSave02Tex, gPauseSave03Tex, gPauseSave04Tex, gPauseGameOver10Tex, gPauseSave11Tex, gPauseSave12Tex, gPauseSave13Tex, gPauseSave14Tex, - gPauseSave20Tex, gPauseSave21Tex, gPauseSave22Tex, gPauseSave23Tex, gPauseSave24Tex, + gPauseSave20Tex, gPauseSave21Tex, gPauseSave22Tex, gPauseSave23Tex, gPauseSave24Tex, }; void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { @@ -914,7 +917,8 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { if ((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) || IS_PAUSE_STATE_GAMEOVER) { KaleidoScope_UpdatePrompt(play); gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0); + gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, SHADE, 0, TEXEL0, 0, PRIMITIVE, 0, + TEXEL0, 0, SHADE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 180, 180, 120, 255); switch (pauseCtx->pageIndex) { @@ -957,13 +961,17 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { gSPVertex(POLY_OPA_DISP++, &pauseCtx->promptPageVtx[60], 32, 0); - if (((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && ((pauseCtx->savePromptState <= PAUSE_SAVEPROMPT_STATE_4) || (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_6))) || (pauseCtx->state == PAUSE_STATE_GAMEOVER_SAVE_PROMPT)) { + if (((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && + ((pauseCtx->savePromptState <= PAUSE_SAVEPROMPT_STATE_4) || + (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_6))) || + (pauseCtx->state == PAUSE_STATE_GAMEOVER_SAVE_PROMPT)) { gDPPipeSync(POLY_OPA_DISP++); gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gPauseSavePromptENGTex, 152, 16, 0); gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0); + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, + TEXEL0, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 255, pauseCtx->promptAlpha); if (pauseCtx->promptChoice == PAUSE_PROMPT_YES) { gSPDisplayList(POLY_OPA_DISP++, gPromptCursorLeftDL); @@ -977,12 +985,16 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gPauseNoENGTex, 48, 16, 16); - } else if (((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && (pauseCtx->savePromptState >= PAUSE_SAVEPROMPT_STATE_5)) || (pauseCtx->state == PAUSE_STATE_GAMEOVER_8)) { + } else if (((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && + (pauseCtx->savePromptState >= PAUSE_SAVEPROMPT_STATE_5)) || + (pauseCtx->state == PAUSE_STATE_GAMEOVER_8)) { POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gPauseSaveConfirmationENGTex, 152, 16, 0); - } else if ((pauseCtx->state == PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT) || (pauseCtx->state == PAUSE_STATE_GAMEOVER_10)) { + } else if ((pauseCtx->state == PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT) || + (pauseCtx->state == PAUSE_STATE_GAMEOVER_10)) { POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gContinuePlayingENGTex, 152, 16, 0); gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0); + gDPSetCombineLERP(POLY_OPA_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, + TEXEL0, 0, PRIMITIVE, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 255, pauseCtx->promptAlpha); if (pauseCtx->promptChoice == PAUSE_PROMPT_YES) { gSPDisplayList(POLY_OPA_DISP++, gPromptCursorLeftDL); @@ -998,9 +1010,11 @@ void KaleidoScope_DrawPages(PlayState* play, GraphicsContext* gfxCtx) { } gDPPipeSync(POLY_OPA_DISP++); - gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - if ((pauseCtx->state != PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT) && (pauseCtx->state != PAUSE_STATE_GAMEOVER_10)) { + if ((pauseCtx->state != PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT) && + (pauseCtx->state != PAUSE_STATE_GAMEOVER_10)) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 0, pauseCtx->alpha); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); } @@ -1332,7 +1346,6 @@ void KaleidoScope_DrawInfoPanel(PlayState* play) { gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); - POLY_OPA_DISP = Gfx_DrawTexQuad4b(POLY_OPA_DISP, gPauseToEquipENGTex, G_IM_FMT_IA, 64, 16, 4); } else if ((pauseCtx->pageIndex == PAUSE_MAP) && sInDungeonScene) { // No code in this case @@ -1409,7 +1422,7 @@ void KaleidoScope_UpdateNamePanel(PlayState* play) { pauseCtx->namedItem = pauseCtx->cursorItem[pauseCtx->pageIndex]; namedItem = pauseCtx->namedItem; - //osCreateMesgQueue(&pauseCtx->loadQueue, &pauseCtx->loadMsg, 1); + // osCreateMesgQueue(&pauseCtx->loadQueue, &pauseCtx->loadMsg, 1); if (pauseCtx->namedItem != PAUSE_ITEM_NONE) { if ((pauseCtx->pageIndex == PAUSE_MAP) && !sInDungeonScene) { @@ -1695,7 +1708,7 @@ void KaleidoScope_UpdateOwlWarpNamePanel(PlayState* play) { pauseCtx->namedItem = pauseCtx->cursorItem[pauseCtx->pageIndex]; texIndex = pauseCtx->namedItem; - //osCreateMesgQueue(&pauseCtx->loadQueue, &pauseCtx->loadMsg, 1); + // osCreateMesgQueue(&pauseCtx->loadQueue, &pauseCtx->loadMsg, 1); if (pauseCtx->namedItem != PAUSE_ITEM_NONE) { if ((pauseCtx->pageIndex == PAUSE_MAP) && !sInDungeonScene) { @@ -3178,10 +3191,14 @@ void KaleidoScope_UpdateOpening(PlayState* play) { gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; // #region 2S2H [Dpad] - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_RIGHT] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_LEFT] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_DOWN] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; - gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_UP] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_RIGHT] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_LEFT] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_DOWN] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; + gSaveContext.shipSaveContext.dpad.status[EQUIP_SLOT_D_UP] = + gPageSwitchNextButtonStatus[pauseCtx->pageIndex][1]; // #endregion gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; } else { @@ -3503,18 +3520,21 @@ void KaleidoScope_Update(PlayState* play) { Play_SaveCycleSceneFlags(&play->state); gSaveContext.save.saveInfo.playerData.savedSceneId = play->sceneId; func_8014546C(sramCtx); - if (!gSaveContext.flashSaveAvailable || gSaveContext.fileNum == 255) { // 2S2H [Enhancement] Don't let them save if they are in debug save + if (!gSaveContext.flashSaveAvailable || + gSaveContext.fileNum == + 255) { // 2S2H [Enhancement] Don't let them save if they are in debug save pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_5; } else { if (CVarGetInteger("gEnhancements.Kaleido.PauseSave", 0)) { - Sram_SetFlashPagesOwlSave(sramCtx, gFlashOwlSaveStartPages[gSaveContext.fileNum * 2], - gFlashOwlSaveNumPages[gSaveContext.fileNum * 2]); + Sram_SetFlashPagesOwlSave(sramCtx, + gFlashOwlSaveStartPages[gSaveContext.fileNum * 2], + gFlashOwlSaveNumPages[gSaveContext.fileNum * 2]); Sram_StartWriteToFlashOwlSave(sramCtx); gSaveContext.save.isOwlSave = false; gSaveContext.save.shipSaveInfo.pauseSaveEntrance = -1; } else { Sram_SetFlashPagesDefault(sramCtx, gFlashSaveStartPages[gSaveContext.fileNum], - gFlashSaveNumPages[gSaveContext.fileNum]); + gFlashSaveNumPages[gSaveContext.fileNum]); Sram_StartWriteToFlashDefault(sramCtx); } pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_4; diff --git a/mm/windows/resource.h b/mm/windows/resource.h index 8a193b3e8..771a9af38 100644 --- a/mm/windows/resource.h +++ b/mm/windows/resource.h @@ -2,15 +2,15 @@ // Microsoft Visual C++ generated include file. // Used by Resource.rc // -#define IDI_ICON1 111 +#define IDI_ICON1 111 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 113 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 113 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif