From ec5eb3c1b91514687f1086da9263fb094ba15557 Mon Sep 17 00:00:00 2001 From: MegaMech <7255464+MegaMech@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:29:06 -0700 Subject: [PATCH] Update lus --- libultraship | 2 +- src/port/Engine.cpp | 60 ++++++++++++++++++++++++-------------- src/port/Engine.h | 8 ++--- src/port/GBIMiddleware.cpp | 8 ++--- 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/libultraship b/libultraship index 80c2c5e9c..3e46fe77a 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 80c2c5e9c6a5681428f759100c2428c5e41f333c +Subproject commit 3e46fe77a4581a84f9c0edfab9c3a69a5320fe01 diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 6c43b48bb..23c5dbdbe 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -62,10 +62,26 @@ GameEngine::GameEngine() { } } - this->context = Ship::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3, - { 26800, 512, 1100 }); + this->context = + Ship::Context::CreateUninitializedInstance("Spaghetti Kart", "spaghettify", "spaghettify.cfg.json"); + + this->context->InitConfiguration(); // without this line InitConsoleVariables fails at Config::Reload() + this->context->InitConsoleVariables(); // without this line the controldeck constructor failes in ShipDeviceIndexMappingManager::UpdateControllerNamesFromConfig() + + auto controlDeck = std::make_shared(); + + this->context->InitResourceManager(OTRFiles, {}, 3); // without this line InitWindow fails in Gui::Init() + this->context->InitConsole(); // without this line the GuiWindow constructor fails in ConsoleWindow::InitElement() + + auto wnd = std::make_shared(std::vector>({})); + //auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + + this->context->Init(OTRFiles, {}, 3, { 26800, 512, 1100 }, wnd, controlDeck); + + + // this->context = Ship::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3, + // { 26800, 512, 1100 }); - auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); wnd->SetRendererUCode(ucode_f3dex); this->context->InitGfxDebugger(); @@ -84,27 +100,27 @@ GameEngine::GameEngine() { loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "GenericArray", static_cast(SF64::ResourceType::GenericArray), 0); - 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, + "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(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, + "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(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, + "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(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, - "Lights1", static_cast(LUS::ResourceType::Light), 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, + "Lights1", static_cast(Fast::ResourceType::Light), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(MK64::ResourceType::MK_Array), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, @@ -233,7 +249,7 @@ void GameEngine::EndAudioFrame() { void GameEngine::AudioInit() { const auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager(); - resourceMgr->LoadDirectory("sound"); + resourceMgr->LoadResources("sound"); const auto banksFiles = resourceMgr->GetArchiveManager()->ListFiles("sound/banks/*"); const auto sequences_files = resourceMgr->GetArchiveManager()->ListFiles("sound/sequences/*"); diff --git a/src/port/Engine.h b/src/port/Engine.h index 94f0e4d33..25e61d5c4 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -55,11 +55,7 @@ class GameEngine { uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center); uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center); }; -#endif - -#ifdef __cplusplus -extern "C" { -#endif +#else void GameEngine_ProcessGfxCommands(Gfx* commands); uint32_t GameEngine_GetSampleRate(); uint32_t GameEngine_GetSamplesPerFrame(); @@ -81,4 +77,4 @@ uint32_t OTRGetGameRenderWidth(void); uint32_t OTRGetGameRenderHeight(void); uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center); uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center); -#endif +#endif // __cplusplus diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp index 9b3f1e71d..3881453d1 100644 --- a/src/port/GBIMiddleware.cpp +++ b/src/port/GBIMiddleware.cpp @@ -13,7 +13,7 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { if (GameEngine_OTRSigCheck(imgData)) { auto resource = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); - auto res = std::static_pointer_cast(resource); + auto res = std::static_pointer_cast(resource); dl = &res->Instructions[0]; } @@ -34,10 +34,10 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { if (texAddr != 0 && GameEngine_OTRSigCheck(data)) { const auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(data); - const auto type = static_cast(res->GetInitData()->Type); + const auto type = static_cast(res->GetInitData()->Type); - if (res->GetInitData()->Type == static_cast(LUS::ResourceType::DisplayList)) { - texAddr = reinterpret_cast(&std::static_pointer_cast(res)->Instructions[0]); + if (res->GetInitData()->Type == static_cast(Fast::ResourceType::DisplayList)) { + texAddr = reinterpret_cast(&std::static_pointer_cast(res)->Instructions[0]); } else if (res->GetInitData()->Type == static_cast(MK64::ResourceType::MK_Array)) { texAddr = reinterpret_cast(std::static_pointer_cast(res)->Vertices.data()); } else {