diff --git a/OTRExporter b/OTRExporter index c872b1ff1..8f7167290 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit c872b1ff18b793a97385ccf1c864c3fc04051cc7 +Subproject commit 8f71672901987bc3dbf6256e64e228db36a686f5 diff --git a/libultraship b/libultraship index 60868949e..bd307e8ed 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 60868949e62a4c4c863eb5daf883bae18387f372 +Subproject commit bd307e8edc3ec4424c284484fce6233c2c618eae diff --git a/soh/include/z64.h b/soh/include/z64.h index cd66089a8..bac56cd87 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -46,6 +46,8 @@ namespace LUS { class IResource; class Scene; +}; +namespace Fast { class DisplayList; }; #include diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 6abaed446..0a4f83b0f 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -170,7 +170,7 @@ void InputViewer::DrawElement() { ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); - OSContPad* pads = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* pads = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp index 72ec3806b..83f1ac412 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.cpp @@ -1304,7 +1304,7 @@ void SohInputEditorWindow::DrawButtonDeviceIcons(uint8_t portIndex, std::set allLusDeviceIndices; allLusDeviceIndices.insert(Ship::ShipDeviceIndex::Keyboard); for (auto [lusIndex, mapping] : Ship::Context::GetInstance() @@ -1317,7 +1317,7 @@ void SohInputEditorWindow::DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::S std::vector> lusDeviceIndiciesWithMappings; for (auto lusIndex : allLusDeviceIndices) { auto controllerStick = - stick == Ship::Stick::LEFT_STICK + stickIndex == Ship::StickIndex::LEFT_STICK ? Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetLeftStick() : Ship::Context::GetInstance()->GetControlDeck()->GetControllerByPort(portIndex)->GetRightStick(); if (controllerStick->HasMappingsForShipDeviceIndex(lusIndex)) { diff --git a/soh/soh/Enhancements/controls/SohInputEditorWindow.h b/soh/soh/Enhancements/controls/SohInputEditorWindow.h index 1b38e8f28..ee0942902 100644 --- a/soh/soh/Enhancements/controls/SohInputEditorWindow.h +++ b/soh/soh/Enhancements/controls/SohInputEditorWindow.h @@ -96,7 +96,7 @@ class SohInputEditorWindow : public Ship::GuiWindow { std::set mModifierButtonsBitmasks; std::set mCustomOcarinaButtonsBitmasks; void DrawButtonDeviceIcons(uint8_t portIndex, std::set bitmasks); - void DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::Stick stick); + void DrawAnalogStickDeviceIcons(uint8_t portIndex, Ship::StickIndex stickIndex); void DrawRumbleDeviceIcons(uint8_t portIndex); void DrawGyroDeviceIcons(uint8_t portIndex); void DrawLEDDeviceIcons(uint8_t portIndex); diff --git a/soh/soh/Enhancements/debugger/dlViewer.cpp b/soh/soh/Enhancements/debugger/dlViewer.cpp index 42b005a8c..fdfc8be1c 100644 --- a/soh/soh/Enhancements/debugger/dlViewer.cpp +++ b/soh/soh/Enhancements/debugger/dlViewer.cpp @@ -120,9 +120,9 @@ void DLViewerWindow::DrawElement() { } try { - auto res = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList)); + auto res = std::static_pointer_cast(Ship::Context::GetInstance()->GetResourceManager()->LoadResource(activeDisplayList)); - if (res->GetInitData()->Type != static_cast(LUS::ResourceType::DisplayList)) { + if (res->GetInitData()->Type != static_cast(Fast::ResourceType::DisplayList)) { ImGui::Text("Resource type is not a Display List. Please choose another."); return; } diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index fff1bc134..846fc7026 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -822,7 +822,7 @@ void CheckTrackerWindow::DrawElement() { if (CVarGetInteger(CVAR_TRACKER_CHECK("DisplayType"), TRACKER_DISPLAY_ALWAYS) == TRACKER_DISPLAY_COMBO_BUTTON) { int comboButton1Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton1"), TRACKER_COMBO_BUTTON_L)]; int comboButton2Mask = buttons[CVarGetInteger(CVAR_TRACKER_CHECK("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; - OSContPad* trackerButtonsPressed = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* trackerButtonsPressed = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); bool comboButtonsHeld = trackerButtonsPressed != nullptr && trackerButtonsPressed[0].button & comboButton1Mask && trackerButtonsPressed[0].button & comboButton2Mask; diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 7f80edfeb..b0e2c2438 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -1224,7 +1224,7 @@ void ItemTrackerWindow::DrawElement() { int iconSpacing = CVarGetInteger(CVAR_TRACKER_ITEM("IconSpacing"), 12); int comboButton1Mask = buttonMap[CVarGetInteger(CVAR_TRACKER_ITEM("ComboButton1"), TRACKER_COMBO_BUTTON_L)]; int comboButton2Mask = buttonMap[CVarGetInteger(CVAR_TRACKER_ITEM("ComboButton2"), TRACKER_COMBO_BUTTON_R)]; - OSContPad* buttonsPressed = Ship::Context::GetInstance()->GetControlDeck()->GetPads(); + OSContPad* buttonsPressed = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetControlDeck())->GetPads(); bool comboButtonsHeld = buttonsPressed != nullptr && buttonsPressed[0].button & comboButton1Mask && buttonsPressed[0].button & comboButton2Mask; bool isPaused = CVarGetInteger(CVAR_TRACKER_ITEM("ShowOnlyPaused"), 0) == 0 || gPlayState != nullptr && gPlayState->pauseCtx.state > 0; diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index 4797c27a3..24294ea8f 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -1,6 +1,6 @@ #include "savestates.h" -#include +#include #include // std::sprintf diff --git a/soh/soh/GameVersions.h b/soh/soh/GameVersions.h new file mode 100644 index 000000000..ce532d2eb --- /dev/null +++ b/soh/soh/GameVersions.h @@ -0,0 +1,28 @@ +#ifndef GAME_VERSION_H +#define GAME_VERSION_H + +#pragma once + +#define OOT_NTSC_US_10 0xEC7011B7 +#define OOT_NTSC_US_11 0xD43DA81F +#define OOT_NTSC_US_12 0x693BA2AE +// #define OOT_NTSC_JP_10 ? +// #define OOT_NTSC_JP_11 ? +// #define OOT_NTSC_JP_12 ? +#define OOT_PAL_10 0xB044B569 +#define OOT_PAL_11 0xB2055FBD +#define OOT_NTSC_JP_GC_CE 0xF7F52DB8 +#define OOT_NTSC_JP_GC 0xF611F4BA +#define OOT_NTSC_US_GC 0xF3DD35BA +#define OOT_PAL_GC 0x09465AC3 +#define OOT_NTSC_JP_MQ 0xF43B45BA +#define OOT_NTSC_US_MQ 0xF034001A +#define OOT_PAL_MQ 0x1D4136F3 +#define OOT_PAL_GC_DBG1 0x871E1C92 // 03-21-2002 build +#define OOT_PAL_GC_DBG2 0x87121EFE // 03-13-2002 build +#define OOT_PAL_GC_MQ_DBG 0x917D18F6 +#define OOT_IQUE_TW 0x3D81FB3E +#define OOT_IQUE_CN 0xB1E1E07B +#define UNKNOWN_GAME_VERSION 0xFFFFFFFF + +#endif diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index b5627db36..9189da7e5 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "Enhancements/gameconsole.h" #ifdef _WIN32 @@ -327,7 +327,7 @@ OTRGlobals::OTRGlobals() { prevAltAssets = CVarGetInteger(CVAR_ENHANCEMENT("AltAssets"), 0); context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets); - context->InitControlDeck({ + auto controlDeck = std::make_shared(std::vector({ BTN_CUSTOM_MODIFIER1, BTN_CUSTOM_MODIFIER2, BTN_CUSTOM_OCARINA_NOTE_D4, @@ -338,14 +338,16 @@ OTRGlobals::OTRGlobals() { BTN_CUSTOM_OCARINA_DISABLE_SONGS, BTN_CUSTOM_OCARINA_PITCH_UP, BTN_CUSTOM_OCARINA_PITCH_DOWN, - }); + })); + context->InitControlDeck(controlDeck); context->GetControlDeck()->SetSinglePlayerMappingMode(true); context->InitCrashHandler(); context->InitConsole(); auto sohInputEditorWindow = std::make_shared(CVAR_WINDOW("ControllerConfiguration"), "Controller Configuration"); - context->InitWindow({ sohInputEditorWindow }); + auto sohFast3dWindow = std::make_shared(std::vector>({sohInputEditorWindow})); + context->InitWindow(sohFast3dWindow); auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", 12.0f, "fonts/PressStart2P-Regular.ttf"); @@ -357,14 +359,14 @@ OTRGlobals::OTRGlobals() { SPDLOG_INFO("Starting Ship of Harkinian version {} (Branch: {} | Commit: {})", (char*)gBuildVersion, (char*)gGitBranch, (char*)gGitCommitHash); auto loader = context->GetResourceManager()->GetResourceLoader(); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(LUS::ResourceType::Texture), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(LUS::ResourceType::Texture), 1); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast(LUS::ResourceType::Vertex), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Vertex", static_cast(LUS::ResourceType::Vertex), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast(LUS::ResourceType::Matrix), 0); - loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Blob", static_cast(LUS::ResourceType::Blob), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(Fast::ResourceType::Texture), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Texture", static_cast(Fast::ResourceType::Texture), 1); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast(Fast::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Vertex", static_cast(Fast::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast(Fast::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "DisplayList", static_cast(Fast::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast(Fast::ResourceType::Matrix), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Blob", static_cast(Ship::ResourceType::Blob), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(SOH::ResourceType::SOH_Array), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SOH::ResourceType::SOH_Animation), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "PlayerAnimation", static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); diff --git a/soh/soh/ResourceManagerHelpers.cpp b/soh/soh/ResourceManagerHelpers.cpp index 45ed269f7..2f87f4551 100644 --- a/soh/soh/ResourceManagerHelpers.cpp +++ b/soh/soh/ResourceManagerHelpers.cpp @@ -6,7 +6,7 @@ #include "Enhancements/enhancementTypes.h" #include "Enhancements/randomizer/dungeon.h" #include -#include +#include #include "resource/type/SohResourceType.h" #include "resource/type/Array.h" #include "resource/type/Skeleton.h" @@ -205,7 +205,7 @@ extern "C" char* ResourceMgr_GetResourceDataByNameHandlingMQ(const char* path) { } extern "C" uint8_t ResourceMgr_TexIsRaw(const char* texPath) { - auto res = std::static_pointer_cast(ResourceMgr_GetResourceByNameHandlingMQ(texPath)); + auto res = std::static_pointer_cast(ResourceMgr_GetResourceByNameHandlingMQ(texPath)); return res->Flags & TEX_FLAG_LOAD_AS_RAW; } @@ -253,8 +253,8 @@ extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) { extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { auto res = ResourceMgr_GetResourceByNameHandlingMQ(filePath); - if (res->GetInitData()->Type == static_cast(LUS::ResourceType::DisplayList)) { - return (char*)&((std::static_pointer_cast(res))->Instructions[0]); + if (res->GetInitData()->Type == static_cast(Fast::ResourceType::DisplayList)) { + return (char*)&((std::static_pointer_cast(res))->Instructions[0]); } if (res->GetInitData()->Type == static_cast(SOH::ResourceType::SOH_Array)) { @@ -267,8 +267,8 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { extern "C" char* ResourceMgr_LoadIfDListByName(const char* filePath) { auto res = ResourceMgr_GetResourceByNameHandlingMQ(filePath); - if (res->GetInitData()->Type == static_cast(LUS::ResourceType::DisplayList)) { - return (char*)&((std::static_pointer_cast(res))->Instructions[0]); + if (res->GetInitData()->Type == static_cast(Fast::ResourceType::DisplayList)) { + return (char*)&((std::static_pointer_cast(res))->Instructions[0]); } return nullptr; @@ -290,12 +290,12 @@ extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) { // OTRTODO: If Alt loading over original cache is fixed, this line can most likely be removed ResourceMgr_UnloadOriginalWhenAltExists(path); - auto res = std::static_pointer_cast(ResourceMgr_GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(ResourceMgr_GetResourceByNameHandlingMQ(path)); return (Gfx*)&res->Instructions[0]; } extern "C" uint8_t ResourceMgr_FileIsCustomByName(const char* path) { - auto res = std::static_pointer_cast(ResourceMgr_GetResourceByNameHandlingMQ(path)); + auto res = std::static_pointer_cast(ResourceMgr_GetResourceByNameHandlingMQ(path)); return res->GetInitData()->IsCustom; } @@ -309,7 +309,7 @@ std::unordered_map> origi // Attention! This is primarily for cosmetics & bug fixes. For things like mods and model replacement you should be using OTRs // instead (When that is available). Index can be found using the commented out section below. extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction) { - auto res = std::static_pointer_cast( + auto res = std::static_pointer_cast( Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Leaving this here for people attempting to find the correct Dlist index to patch @@ -348,7 +348,7 @@ extern "C" void ResourceMgr_PatchGfxByName(const char* path, const char* patchNa } extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex) { - auto res = std::static_pointer_cast( + auto res = std::static_pointer_cast( Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); // Do not patch custom assets as they most likely do not have the same instructions as authentic assets @@ -371,7 +371,7 @@ extern "C" void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const ch extern "C" void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName) { if (originalGfx.contains(path) && originalGfx[path].contains(patchName)) { - auto res = std::static_pointer_cast( + auto res = std::static_pointer_cast( Ship::Context::GetInstance()->GetResourceManager()->LoadResource(path)); Gfx* gfx = (Gfx*)&res->Instructions[originalGfx[path][patchName].index]; diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 4e05cd7a8..022aeee37 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -107,7 +107,7 @@ bool Scene_CommandSpecialFiles(PlayState* play, SOH::ISceneCommand* cmd) { if (specialCmd->specialObjects.elfMessage != 0) { auto res = - (LUS::Blob*)OTRPlay_LoadFile(play, sNaviMsgFiles[specialCmd->specialObjects.elfMessage - 1].fileName); + (Ship::Blob*)OTRPlay_LoadFile(play, sNaviMsgFiles[specialCmd->specialObjects.elfMessage - 1].fileName); play->cUpElfMsgs = (ElfMessage*)res->Data.data(); } diff --git a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 77773e92a..48710d4a3 100644 --- a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -6,7 +6,7 @@ #include "z_en_mag.h" #include "objects/object_mag/object_mag.h" -#include +#include #include "soh/ResourceManagerHelpers.h" #define FLAGS (ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED) diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index b093a746c..53901821b 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -11,7 +11,7 @@ #include #include "textures/message_static/message_static.h" #include "soh/frame_interpolation.h" -#include +#include #include "objects/object_mag/object_mag.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "soh_assets.h" diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index 23243a84c..f8561166f 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -11,7 +11,7 @@ #include "textures/nintendo_rogo_static/nintendo_rogo_static.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" #include -#include +#include #include #include "soh/ResourceManagerHelpers.h" #include