diff --git a/.gitignore b/.gitignore index d5266a91..32ce0889 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,6 @@ code/ !/sound/**/*custom*/**/*.aiff !/assets/**/*custom*.bin !/assets/**/*custom*/**/*.bin - # Torch hash torch.hash.yml +merge/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index aaaccdf7..b2e72ca4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ add_compile_definitions( VERSION_US=1 ENABLE_RUMBLE=1 F3D_OLD=1 + F3D_GBI=1 GBI_FLOATS=1 _LANGUAGE_C _USE_MATH_DEFINES @@ -379,6 +380,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces + -Wno-int-conversion $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types diff --git a/Torch b/Torch index 76e90b4d..7e4c4bca 160000 --- a/Torch +++ b/Torch @@ -1 +1 @@ -Subproject commit 76e90b4ddc9c215132c39ebf8433d5f88813b368 +Subproject commit 7e4c4bca087490960bbd67ecc102a3884adc6788 diff --git a/include/macros.h b/include/macros.h index 68acf04d..db4cbcbf 100644 --- a/include/macros.h +++ b/include/macros.h @@ -52,4 +52,77 @@ #define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr)) #define VIRTUAL_TO_PHYSICAL2(addr) ((void *)(addr)) +#define G_CC_PRIMITIVE 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE +#define G_CC_SHADE 0, 0, 0, SHADE, 0, 0, 0, SHADE + +#define G_CC_MODULATEI TEXEL0, 0, SHADE, 0, 0, 0, 0, SHADE +#define G_CC_MODULATEIDECALA TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0 +#define G_CC_MODULATEIFADE TEXEL0, 0, SHADE, 0, 0, 0, 0, ENVIRONMENT + +#define G_CC_MODULATERGB G_CC_MODULATEI +#define G_CC_MODULATERGBDECALA G_CC_MODULATEIDECALA +#define G_CC_MODULATERGBFADE G_CC_MODULATEIFADE + +#define G_CC_MODULATEIA TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0 +#define G_CC_MODULATEIFADEA TEXEL0, 0, SHADE, 0, TEXEL0, 0, ENVIRONMENT, 0 + +#define G_CC_MODULATEFADE TEXEL0, 0, SHADE, 0, ENVIRONMENT, 0, TEXEL0, 0 + +#define G_CC_MODULATERGBA G_CC_MODULATEIA +#define G_CC_MODULATERGBFADEA G_CC_MODULATEIFADEA + +#define G_CC_MODULATEI_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE +#define G_CC_MODULATEIA_PRIM TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0 +#define G_CC_MODULATEIDECALA_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0 + +#define G_CC_MODULATERGB_PRIM G_CC_MODULATEI_PRIM +#define G_CC_MODULATERGBA_PRIM G_CC_MODULATEIA_PRIM +#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIDECALA_PRIM + +#define G_CC_FADE SHADE, 0, ENVIRONMENT, 0, SHADE, 0, ENVIRONMENT, 0 +#define G_CC_FADEA TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0 + +#define G_CC_DECALRGB 0, 0, 0, TEXEL0, 0, 0, 0, SHADE +#define G_CC_DECALRGBA 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 +#define G_CC_DECALFADE 0, 0, 0, TEXEL0, 0, 0, 0, ENVIRONMENT + +#define G_CC_DECALFADEA 0, 0, 0, TEXEL0, TEXEL0, 0, ENVIRONMENT, 0 + +#define G_CC_BLENDI ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_BLENDIA ENVIRONMENT, SHADE, TEXEL0, SHADE, TEXEL0, 0, SHADE, 0 +#define G_CC_BLENDIDECALA ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 + +#define G_CC_BLENDRGBA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, SHADE +#define G_CC_BLENDRGBDECALA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_BLENDRGBFADEA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, ENVIRONMENT + +#define G_CC_ADDRGB TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_ADDRGBDECALA TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_ADDRGBFADE TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, ENVIRONMENT + +#define G_CC_REFLECTRGB ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_REFLECTRGBDECALA ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 + +#define G_CC_HILITERGB PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE +#define G_CC_HILITERGBA PRIMITIVE, SHADE, TEXEL0, SHADE, PRIMITIVE, SHADE, TEXEL0, SHADE +#define G_CC_HILITERGBDECALA PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 + +#define G_CC_SHADEDECALA 0, 0, 0, SHADE, 0, 0, 0, TEXEL0 +#define G_CC_SHADEFADEA 0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT + +#define G_CC_BLENDPE PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0 +#define G_CC_BLENDPEDECALA PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL0 + +#define RM_AA_ZB_XLU_SURF(clk) \ + AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ + FORCE_BL | ZMODE_XLU | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +/* Custom version of RM_AA_ZB_XLU_SURF with Z_UPD */ +#define RM_CUSTOM_AA_ZB_XLU_SURF(clk) \ + RM_AA_ZB_XLU_SURF(clk) | Z_UPD + +#define G_RM_CUSTOM_AA_ZB_XLU_SURF RM_CUSTOM_AA_ZB_XLU_SURF(1) +#define G_RM_CUSTOM_AA_ZB_XLU_SURF2 RM_CUSTOM_AA_ZB_XLU_SURF(2) + #endif // MACROS_H diff --git a/include/types.h b/include/types.h index 4592c7f9..b1c32573 100644 --- a/include/types.h +++ b/include/types.h @@ -5,10 +5,10 @@ // have an appropriate header. #include +#include #include "macros.h" #include "config.h" - // Certain functions are marked as having return values, but do not // actually return a value. This causes undefined behavior, which we'd rather // avoid on modern GCC. This only impacts -O2 and can matter for both the function diff --git a/lib/src/guMtxF2L.c b/lib/src/guMtxF2L.c index 2b9d9359..14056e75 100644 --- a/lib/src/guMtxF2L.c +++ b/lib/src/guMtxF2L.c @@ -65,6 +65,6 @@ void guMtxIdent(Mtx *m) { guMtxIdentF(mf); guMtxF2L(mf, m); #else - guMtxIdentF(m->m); + guMtxIdentF(m->mf); #endif } diff --git a/lib/src/osAi.h b/lib/src/osAi.h index 276fa071..41de8524 100644 --- a/lib/src/osAi.h +++ b/lib/src/osAi.h @@ -1,7 +1,7 @@ #ifndef _OSAI_H_ #define _OSAI_H_ -s32 osAiSetFrequency(u32); -s32 osAiSetNextBuffer(void *, u32); -u32 osAiGetLength(void); +// s32 osAiSetFrequency(u32); +// s32 osAiSetNextBuffer(void *, u32); +// u32 osAiGetLength(void); #endif diff --git a/libultraship b/libultraship index 39b5d3f1..4b1df828 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 39b5d3f1acfa53d3a2d0723a9831411005401562 +Subproject commit 4b1df828f57d4219a74734c3880d9909e580f0c7 diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index ed366fa2..54c1a5e3 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -342,7 +342,7 @@ static void geo_process_perspective(struct GraphNodePerspective *node) { static void geo_process_level_of_detail(struct GraphNodeLevelOfDetail *node) { #ifdef GBI_FLOATS Mtx *mtx = gMatStackFixed[gMatStackIndex]; - s16 distanceFromCam = (s32) -mtx->m[3][2]; // z-component of the translation column + s16 distanceFromCam = (s32) -mtx->mf[3][2]; // z-component of the translation column #else // The fixed point Mtx type is defined as 16 longs, but it's actually 16 // shorts for the integer parts followed by 16 shorts for the fraction parts diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index e1286bea..7b96a425 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -8,7 +8,6 @@ #include "port/importer/DictionaryFactory.h" #include "port/importer/ResourceType.h" #include "audio/GameAudio.h" -#include "ZAPDUtils/Utils/StringHelper.h" #include "texts_table.h" #include "port/Enhancements/game-interactor/GameInteractor.h" #include "port/Enhancements/mods.h" @@ -18,6 +17,15 @@ #include +#include "ArrayFactory.h" +#include "BlobFactory.h" +#include "DisplayListFactory.h" +#include "MatrixFactory.h" +#include "StringHelper.h" +#include "TextureFactory.h" +#include "VertexFactory.h" +#include "Fast3D/Fast3dWindow.h" + extern "C" { #include "sm64.h" #include "audio/external.h" @@ -31,13 +39,13 @@ GameInteractor* GameInteractor::Instance; GameEngine::GameEngine(): dictionary(nullptr) { std::vector OTRFiles; - if (const std::string cube_path = LUS::Context::GetPathRelativeToAppDirectory("smcube.otr"); std::filesystem::exists(cube_path)) { + if (const std::string cube_path = Ship::Context::GetPathRelativeToAppDirectory("smcube.otr"); std::filesystem::exists(cube_path)) { OTRFiles.push_back(cube_path); } - if (const std::string sm64_otr_path = LUS::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) { + if (const std::string sm64_otr_path = Ship::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) { OTRFiles.push_back(sm64_otr_path); } - if (const std::string patches_path = LUS::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { + if (const std::string patches_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { if (std::filesystem::is_directory(patches_path)) { for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) { if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { @@ -46,10 +54,14 @@ GameEngine::GameEngine(): dictionary(nullptr) { } } } - this->context = LUS::Context::CreateInstance("Ghostship", "sm64", "ghostship.cfg.json", OTRFiles, + this->context = Ship::Context::CreateInstance("Ghostship", "sm64", "ghostship.cfg.json", OTRFiles, {0xFF2B5A63, 0xE3DAA4E}, 3); - this->context->GetWindow()->SetTargetFps(60); - this->context->GetWindow()->SetMaximumFrameLatency(1); + + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + wnd->SetTargetFps(60); + wnd->SetMaximumFrameLatency(1); + wnd->SetRendererUCode(ucode_f3d); + auto loader = context->GetResourceManager()->GetResourceLoader(); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SM64::ResourceType::Anim), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioBank", static_cast(SM64::ResourceType::Bank), 0); @@ -57,6 +69,13 @@ GameEngine::GameEngine(): dictionary(nullptr) { loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast(SM64::ResourceType::Sequence), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Dialog", static_cast(SM64::ResourceType::SDialog), 0); loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Dictionary", static_cast(SM64::ResourceType::Dictionary), 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, "Vertex", static_cast(LUS::ResourceType::Vertex), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast(LUS::ResourceType::DisplayList), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast(LUS::ResourceType::Matrix), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Array", static_cast(LUS::ResourceType::Array), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Blob", static_cast(LUS::ResourceType::Blob), 0); } void GameEngine::Create(){ @@ -75,7 +94,7 @@ void GameEngine::Destroy(){ bool ShouldClearTextureCacheAtEndOfFrame = false; void GameEngine::StartFrame() const{ - using LUS::KbScancode; + using Ship::KbScancode; const int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); this->context->GetWindow()->SetLastScancode(-1); @@ -91,20 +110,16 @@ void GameEngine::StartFrame() const{ this->context->GetWindow()->StartFrame(); } -void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const { - this->context->GetWindow()->MainLoop(run_one_game_iter); -} - uint32_t GameEngine::GetInterpolationFPS() { - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { return CVarGetInteger("gInterpolationFPS", 30); } if (CVarGetInteger("gMatchRefreshRate", 0)) { - return LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } - return std::min(LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 30)); + return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 30)); } // Audio @@ -157,7 +172,7 @@ void GameEngine::EndAudioFrame(){ } void GameEngine::AudioInit() { - const auto resourceMgr = LUS::Context::GetInstance()->GetResourceManager(); + const auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager(); resourceMgr->LoadDirectory("sound"); const auto banksFiles = resourceMgr->GetArchiveManager()->ListFiles("sound/banks/*"); const auto sequences_files = resourceMgr->GetArchiveManager()->ListFiles("sound/sequences/*"); @@ -204,11 +219,11 @@ uint8_t GameEngine::GetBankIdByName(const std::string& name) { } uint32_t GameEngine::GetGameVersion() { - return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0]; + return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0]; } -void GameEngine::RunCommands(Gfx* Commands) { - gfx_run(Commands, {}); +void GameEngine::RunCommands(F3DGfx* Commands) { + gfx_run(reinterpret_cast(Commands), {}); gfx_end_frame(); if (ShouldClearTextureCacheAtEndOfFrame) { @@ -228,7 +243,9 @@ void GameEngine::PatchInterpolations() { patch_interpolated_snow_particles(); } -void GameEngine::ProcessGfxCommands(Gfx* commands) { +void GameEngine::ProcessGfxCommands(F3DGfx* commands) { + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + int target_fps = GetInterpolationFPS(); static int last_fps; static int time; @@ -255,10 +272,10 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) { time -= fps; - Instance->context->GetWindow()->SetTargetFps(fps); + wnd->SetTargetFps(fps); int threshold = CVarGetInteger("gExtraLatencyThreshold", 80); - Instance->context->GetWindow()->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); + wnd->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); last_fps = fps; } @@ -268,7 +285,7 @@ extern "C" uint32_t GameEngine_GetInterpolatedFPS() { } extern "C" uint32_t GameEngine_GetSampleRate() { - auto player = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer(); + auto player = Ship::Context::GetInstance()->GetAudio()->GetAudioPlayer(); if (player == nullptr) { return 0; } @@ -355,7 +372,7 @@ extern "C" void GameEngine_UnloadSequence(uint8_t seqId) { } extern "C" uint32_t GameEngine_GetGameVersion() { - return LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0]; + return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions()[0]; } extern "C" uint8_t* GameEngine_LoadActName(uint32_t actId){ @@ -382,5 +399,5 @@ extern "C" uint8_t* GameEngine_LoadTranslation(const char* key) { } extern "C" int GameEngine_OTRSigCheck(const char* data) { - return LUS::Context::GetInstance()->GetResourceManager()->OtrSignatureCheck(data); + return Ship::Context::GetInstance()->GetResourceManager()->OtrSignatureCheck(data); } \ No newline at end of file diff --git a/src/port/Engine.h b/src/port/Engine.h index 19f22509..f9c65030 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -19,7 +19,7 @@ class GameEngine { public: static GameEngine* Instance; - std::shared_ptr context; + std::shared_ptr context; std::unordered_map banks; std::unordered_map sequences; std::unordered_map bankMapTable; @@ -30,15 +30,14 @@ class GameEngine { static void Create(); void AudioInit(); void StartFrame() const; - static void RunCommands(Gfx* Commands); - void ProcessFrame(void (*run_one_game_iter)()) const; + static void RunCommands(F3DGfx* Commands); static uint32_t GetInterpolationFPS(); static void HandleAudioThread(); static void StartAudioFrame(); static void EndAudioFrame(); static void AudioExit(); static void PatchInterpolations(); - static void ProcessGfxCommands(Gfx* commands); + static void ProcessGfxCommands(F3DGfx* commands); static uint8_t GetBankIdByName(const std::string& name); void LoadDictionary(); uint32_t GetGameVersion(); diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp index a4411541..ca7504e5 100644 --- a/src/port/GBIMiddleware.cpp +++ b/src/port/GBIMiddleware.cpp @@ -10,7 +10,7 @@ extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { char* imgData = (char*)dl; if (GameEngine_OTRSigCheck(imgData) == 1) { - auto resource = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); + auto resource = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); auto res = std::static_pointer_cast(resource); dl = &res->Instructions[0]; } @@ -31,7 +31,7 @@ extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { char* imgData = (char*)texAddr; if (texAddr != 0 && GameEngine_OTRSigCheck(imgData)) { - auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); + auto res = Ship::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); if (res->GetInitData()->Type == (uint32_t) LUS::ResourceType::DisplayList) texAddr = (uintptr_t)&((std::static_pointer_cast(res))->Instructions[0]); diff --git a/src/port/Game.cpp b/src/port/Game.cpp index b53d2ae9..44e3ae47 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -28,7 +28,7 @@ void patch_interpolations() { extern "C" void exec_display_list(SPTask *spTask) { - GameEngine::ProcessGfxCommands((Gfx *) spTask->task.t.data_ptr); + GameEngine::ProcessGfxCommands((F3DGfx *) spTask->task.t.data_ptr); } void push_frame() { @@ -48,7 +48,9 @@ int main(){ audio_init(); sound_init(); thread5_game_loop(); - GameEngine::Instance->ProcessFrame(push_frame); + while (WindowIsRunning()) { + push_frame(); + } GameEngine::Instance->Destroy(); return 0; } \ No newline at end of file diff --git a/src/port/game/GeoLayoutParser.cpp b/src/port/game/GeoLayoutParser.cpp index ee46ccfc..46862f46 100644 --- a/src/port/game/GeoLayoutParser.cpp +++ b/src/port/game/GeoLayoutParser.cpp @@ -12,8 +12,8 @@ extern "C" { // Function Table #include "menu/intro_geo.h" } -LUS::BinaryReader* GeoLayoutParser::mReader; -LUS::BinaryReader* GeoLayoutParser::mLoadedReader; +Ship::BinaryReader* GeoLayoutParser::mReader; +Ship::BinaryReader* GeoLayoutParser::mLoadedReader; typedef void (*GeoCommandFunction)(); #undef cur_geo_cmd_ptr @@ -73,7 +73,7 @@ void process_cmd_branch_and_link() { const auto data = static_cast(ResourceGetDataByCrc(crc)); const auto size = ResourceGetSizeByCrc(crc); - GeoLayoutParser::mReader = new LUS::BinaryReader(data, size); + GeoLayoutParser::mReader = new Ship::BinaryReader(data, size); gGeoLayoutStack[gGeoLayoutStackIndex++] = reinterpret_cast(GeoLayoutParser::mLoadedReader); gGeoLayoutStack[gGeoLayoutStackIndex++] = (gCurGraphNodeIndex << 16) + gGeoLayoutReturnIndex; @@ -84,7 +84,7 @@ void process_cmd_end() { gGeoLayoutStackIndex = gGeoLayoutReturnIndex; gGeoLayoutReturnIndex = gGeoLayoutStack[--gGeoLayoutStackIndex] & 0xFFFF; gCurGraphNodeIndex = gGeoLayoutStack[gGeoLayoutStackIndex] >> 16; - GeoLayoutParser::mReader = reinterpret_cast(gGeoLayoutStack[--gGeoLayoutStackIndex]); + GeoLayoutParser::mReader = reinterpret_cast(gGeoLayoutStack[--gGeoLayoutStackIndex]); } void process_cmd_branch() { @@ -96,15 +96,15 @@ void process_cmd_branch() { if (param == 1) { gGeoLayoutStack[gGeoLayoutStackIndex++] = reinterpret_cast(GeoLayoutParser::mLoadedReader); - GeoLayoutParser::mReader = new LUS::BinaryReader(data, size); + GeoLayoutParser::mReader = new Ship::BinaryReader(data, size); } else { - GeoLayoutParser::mLoadedReader = new LUS::BinaryReader(data, size); + GeoLayoutParser::mLoadedReader = new Ship::BinaryReader(data, size); GeoLayoutParser::mReader = GeoLayoutParser::mLoadedReader; } } void process_cmd_return() { - GeoLayoutParser::mReader = reinterpret_cast(gGeoLayoutStack[--gGeoLayoutStackIndex]); + GeoLayoutParser::mReader = reinterpret_cast(gGeoLayoutStack[--gGeoLayoutStackIndex]); } void process_cmd_open_node() { @@ -233,7 +233,7 @@ void process_cmd_node_camera() { Vec3f pos, focus; const auto type = GeoLayoutParser::mReader->ReadUInt16(); - + ReadVec3f(pos); ReadVec3f(focus); @@ -515,7 +515,7 @@ void GeoLayoutParser::execute(const char* path) { const auto data = static_cast(ResourceGetDataByName(path)); const auto size = ResourceGetSizeByName(path); - mLoadedReader = new LUS::BinaryReader(data, size); + mLoadedReader = new Ship::BinaryReader(data, size); mReader = mLoadedReader; while (mReader != nullptr) { diff --git a/src/port/game/GeoLayoutParser.h b/src/port/game/GeoLayoutParser.h index 53aac64a..662ca386 100644 --- a/src/port/game/GeoLayoutParser.h +++ b/src/port/game/GeoLayoutParser.h @@ -6,8 +6,8 @@ class GeoLayoutParser { public: - static LUS::BinaryReader* mLoadedReader; - static LUS::BinaryReader* mReader; + static Ship::BinaryReader* mLoadedReader; + static Ship::BinaryReader* mReader; static void execute(const char* path); }; #else diff --git a/src/port/importer/AnimationFactory.cpp b/src/port/importer/AnimationFactory.cpp index 32d7e932..164288a2 100644 --- a/src/port/importer/AnimationFactory.cpp +++ b/src/port/importer/AnimationFactory.cpp @@ -2,13 +2,13 @@ #include "port/importer/types/Animation.h" #include "spdlog/spdlog.h" -std::shared_ptr SM64::AnimationFactoryV0::ReadResource(std::shared_ptr file) { +std::shared_ptr SM64::AnimationFactoryV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } std::shared_ptr animation = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); animation->mData.flags = reader->ReadInt16(); animation->mData.animYTransDivisor = reader->ReadInt16(); diff --git a/src/port/importer/AnimationFactory.h b/src/port/importer/AnimationFactory.h index b3cf6b69..06a5561f 100644 --- a/src/port/importer/AnimationFactory.h +++ b/src/port/importer/AnimationFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SM64 { -class AnimationFactoryV0 : public LUS::ResourceFactoryBinary { +class AnimationFactoryV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } diff --git a/src/port/importer/AudioBankFactory.cpp b/src/port/importer/AudioBankFactory.cpp index 60af6cfc..3f78c71d 100644 --- a/src/port/importer/AudioBankFactory.cpp +++ b/src/port/importer/AudioBankFactory.cpp @@ -4,13 +4,13 @@ #include "resourcebridge.h" #include "ResourceUtil.h" -std::shared_ptr SM64::AudioBankFactoryV0::ReadResource(std::shared_ptr file) { +std::shared_ptr SM64::AudioBankFactoryV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } std::shared_ptr bank = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); uint8_t bankId = reader->ReadUInt32(); uint32_t instrumentCount = reader->ReadUInt32(); diff --git a/src/port/importer/AudioBankFactory.h b/src/port/importer/AudioBankFactory.h index 8179be92..f76e2d83 100644 --- a/src/port/importer/AudioBankFactory.h +++ b/src/port/importer/AudioBankFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SM64 { -class AudioBankFactoryV0 : public LUS::ResourceFactoryBinary { +class AudioBankFactoryV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } diff --git a/src/port/importer/AudioSampleFactory.cpp b/src/port/importer/AudioSampleFactory.cpp index 987a9f26..79aa23d2 100644 --- a/src/port/importer/AudioSampleFactory.cpp +++ b/src/port/importer/AudioSampleFactory.cpp @@ -3,13 +3,13 @@ #include "port/importer/types/AudioSample.h" #include "spdlog/spdlog.h" -std::shared_ptr SM64::AudioSampleFactoryV0::ReadResource(std::shared_ptr file) { +std::shared_ptr SM64::AudioSampleFactoryV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } std::shared_ptr bank = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); bank->loop.start = reader->ReadUInt32(); bank->loop.end = reader->ReadUInt32(); diff --git a/src/port/importer/AudioSampleFactory.h b/src/port/importer/AudioSampleFactory.h index e91c6f94..cf640bd5 100644 --- a/src/port/importer/AudioSampleFactory.h +++ b/src/port/importer/AudioSampleFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SM64 { -class AudioSampleFactoryV0 : public LUS::ResourceFactoryBinary { +class AudioSampleFactoryV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } diff --git a/src/port/importer/AudioSequenceFactory.cpp b/src/port/importer/AudioSequenceFactory.cpp index 43d3f422..55f86922 100644 --- a/src/port/importer/AudioSequenceFactory.cpp +++ b/src/port/importer/AudioSequenceFactory.cpp @@ -4,13 +4,13 @@ #include "port/Engine.h" #include "port/importer/types/AudioBank.h" -std::shared_ptr SM64::AudioSequenceFactoryV0::ReadResource(std::shared_ptr file) { +std::shared_ptr SM64::AudioSequenceFactoryV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } std::shared_ptr bank = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); uint8_t id = reader->ReadUInt32(); size_t bankCount = reader->ReadUInt32(); diff --git a/src/port/importer/AudioSequenceFactory.h b/src/port/importer/AudioSequenceFactory.h index 7920494a..722d999b 100644 --- a/src/port/importer/AudioSequenceFactory.h +++ b/src/port/importer/AudioSequenceFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SM64 { -class AudioSequenceFactoryV0 : public LUS::ResourceFactoryBinary { +class AudioSequenceFactoryV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } diff --git a/src/port/importer/DialogFactory.cpp b/src/port/importer/DialogFactory.cpp index c2e3531d..257ed7b0 100644 --- a/src/port/importer/DialogFactory.cpp +++ b/src/port/importer/DialogFactory.cpp @@ -2,13 +2,13 @@ #include "port/importer/types/Dialog.h" #include "spdlog/spdlog.h" -std::shared_ptr SM64::DialogFactoryV0::ReadResource(std::shared_ptr file) { +std::shared_ptr SM64::DialogFactoryV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } std::shared_ptr dialog = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); dialog->mData.unused = reader->ReadUInt32(); dialog->mData.linesPerBox = reader->ReadInt8(); diff --git a/src/port/importer/DialogFactory.h b/src/port/importer/DialogFactory.h index 55d2aa58..0442f3bf 100644 --- a/src/port/importer/DialogFactory.h +++ b/src/port/importer/DialogFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SM64 { -class DialogFactoryV0 : public LUS::ResourceFactoryBinary { +class DialogFactoryV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } diff --git a/src/port/importer/DictionaryFactory.cpp b/src/port/importer/DictionaryFactory.cpp index b338b7c7..c415ceb4 100644 --- a/src/port/importer/DictionaryFactory.cpp +++ b/src/port/importer/DictionaryFactory.cpp @@ -3,13 +3,13 @@ #include "spdlog/spdlog.h" -std::shared_ptr SM64::DictionaryFactoryV0::ReadResource(std::shared_ptr file) { +std::shared_ptr SM64::DictionaryFactoryV0::ReadResource(std::shared_ptr file) { if (!FileHasValidFormatAndReader(file)) { return nullptr; } std::shared_ptr dictionary = std::make_shared(file->InitData); - auto reader = std::get>(file->Reader); + auto reader = std::get>(file->Reader); size_t numEntries = reader->ReadUInt32(); for(size_t i = 0; i < numEntries; i++){ diff --git a/src/port/importer/DictionaryFactory.h b/src/port/importer/DictionaryFactory.h index 7bdb7150..37611331 100644 --- a/src/port/importer/DictionaryFactory.h +++ b/src/port/importer/DictionaryFactory.h @@ -4,8 +4,8 @@ #include "ResourceFactoryBinary.h" namespace SM64 { -class DictionaryFactoryV0 : public LUS::ResourceFactoryBinary { +class DictionaryFactoryV0 : public Ship::ResourceFactoryBinary { public: - std::shared_ptr ReadResource(std::shared_ptr file) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; } diff --git a/src/port/importer/ResourceUtil.h b/src/port/importer/ResourceUtil.h index 57d29400..69d03a7d 100644 --- a/src/port/importer/ResourceUtil.h +++ b/src/port/importer/ResourceUtil.h @@ -9,14 +9,14 @@ template T LoadChild(uint64_t crc) { if (path == nullptr) { return nullptr; } - auto asset = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); + auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); return asset ? static_cast(asset->GetRawPointer()) : nullptr; } template T LoadChild(const char* path) { if (path == nullptr) { return nullptr; } - auto asset = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); + auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); return asset ? static_cast(asset->GetRawPointer()) : nullptr; } } diff --git a/src/port/importer/types/Animation.h b/src/port/importer/types/Animation.h index 5d4a48ed..eaaddee0 100644 --- a/src/port/importer/types/Animation.h +++ b/src/port/importer/types/Animation.h @@ -18,11 +18,11 @@ struct AnimationData { /*0x14*/ uint64_t length; // only used with Mario animations to determine how much to load. 0 otherwise. }; -class Animation : public LUS::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(); diff --git a/src/port/importer/types/AudioBank.h b/src/port/importer/types/AudioBank.h index fcce8d26..0f0e71a9 100644 --- a/src/port/importer/types/AudioBank.h +++ b/src/port/importer/types/AudioBank.h @@ -45,11 +45,11 @@ struct CtlEntry { namespace SM64 { -class AudioBank : public LUS::Resource { +class AudioBank : public Ship::Resource { public: using Resource::Resource; - AudioBank() : Resource(std::shared_ptr()) {} + AudioBank() : Resource(std::shared_ptr()) {} CtlEntry* GetPointer(); size_t GetPointerSize(); diff --git a/src/port/importer/types/AudioSample.h b/src/port/importer/types/AudioSample.h index 9c118c2b..d6115304 100644 --- a/src/port/importer/types/AudioSample.h +++ b/src/port/importer/types/AudioSample.h @@ -30,11 +30,11 @@ struct AudioBankSample { namespace SM64 { -class AudioSample : public LUS::Resource { +class AudioSample : public Ship::Resource { public: using Resource::Resource; - AudioSample() : Resource(std::shared_ptr()) {} + AudioSample() : Resource(std::shared_ptr()) {} AudioBankSample* GetPointer(); size_t GetPointerSize(); diff --git a/src/port/importer/types/AudioSequence.h b/src/port/importer/types/AudioSequence.h index 965d6d7a..01e37920 100644 --- a/src/port/importer/types/AudioSequence.h +++ b/src/port/importer/types/AudioSequence.h @@ -12,11 +12,11 @@ struct AudioSequenceData { namespace SM64 { -class AudioSequence : public LUS::Resource { +class AudioSequence : public Ship::Resource { public: using Resource::Resource; - AudioSequence() : Resource(std::shared_ptr()) {} + AudioSequence() : Resource(std::shared_ptr()) {} AudioSequenceData* GetPointer(); size_t GetPointerSize(); diff --git a/src/port/importer/types/Dialog.h b/src/port/importer/types/Dialog.h index 9958e184..27814da6 100644 --- a/src/port/importer/types/Dialog.h +++ b/src/port/importer/types/Dialog.h @@ -14,11 +14,11 @@ struct DialogEntry { namespace SM64 { -class Dialog : public LUS::Resource { +class Dialog : public Ship::Resource { public: using Resource::Resource; - Dialog() : Resource(std::shared_ptr()) {} + Dialog() : Resource(std::shared_ptr()) {} DialogEntry* GetPointer(); size_t GetPointerSize(); diff --git a/src/port/importer/types/Dictionary.h b/src/port/importer/types/Dictionary.h index 1c1ad807..7d82551c 100644 --- a/src/port/importer/types/Dictionary.h +++ b/src/port/importer/types/Dictionary.h @@ -8,11 +8,11 @@ namespace SM64 { typedef std::unordered_map> GameDictionary; -class Dictionary : public LUS::Resource { +class Dictionary : public Ship::Resource { public: using Resource::Resource; - Dictionary() : Resource(std::shared_ptr()) {} + Dictionary() : Resource(std::shared_ptr()) {} GameDictionary* GetPointer(); size_t GetPointerSize(); diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 3d85aa63..774c1d79 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -4,9 +4,9 @@ #include "SaveEditor.h" #include -#include +#include #define IMGUI_DEFINE_MATH_OPERATORS -#include +#include #include #include #include "port/Engine.h" @@ -16,15 +16,15 @@ extern "C" { namespace GameUI { std::shared_ptr mGameMenuBar; -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 mAdvancedResolutionSettingsWindow; void SetupGuiElements() { - auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); auto& style = ImGui::GetStyle(); style.FramePadding = ImVec2(4.0f, 6.0f); @@ -114,27 +114,27 @@ void DrawSettingsMenu(){ audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f)); } - static std::unordered_map audioBackendNames = { - { LUS::AudioBackend::WASAPI, "Windows Audio Session API" }, - { LUS::AudioBackend::SDL, "SDL" }, + static std::unordered_map audioBackendNames = { + { Ship::AudioBackend::WASAPI, "Windows Audio Session API" }, + { Ship::AudioBackend::SDL, "SDL" }, }; ImGui::Text("Audio API (Needs reload)"); - auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend(); + auto currentAudioBackend = Ship::Context::GetInstance()->GetAudio()->GetAudioBackend(); - if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) { - for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { - auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; + for (uint8_t i = 0; i < Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { + auto backend = Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) { - LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); + Ship::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); } } ImGui::EndCombo(); } - if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { UIWidgets::ReEnableComponent(""); } @@ -176,23 +176,23 @@ void DrawSettingsMenu(){ UIWidgets::Spacer(0); // Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste? - // LUS::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"); #ifndef __WIIU__ if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, { .tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel" })) { - LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); } #endif { // FPS Slider const int minFps = 30; static int maxFps; - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { maxFps = 360; } else { - maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } int currentFps = fmax(fmin(GameEngine::GetInterpolationFPS(), maxFps), minFps); #ifdef __WIIU__ @@ -254,15 +254,15 @@ void DrawSettingsMenu(){ currentFps = 60; } CVarSetInteger("gInterpolationFPS", currentFps); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); #else bool matchingRefreshRate = - CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11; + CVarGetInteger("gMatchRefreshRate", 0) && Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() != Ship::WindowBackend::DX11; UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, { .disabled = matchingRefreshRate }); #endif - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + 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" @@ -276,13 +276,13 @@ void DrawSettingsMenu(){ } } // END FPS Slider - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::Spacer(0); if (ImGui::Button("Match Refresh Rate")) { - int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); if (hz >= 30 && hz <= 360) { CVarSetInteger("gInterpolationFPS", hz); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } } else { @@ -291,7 +291,7 @@ void DrawSettingsMenu(){ UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); - if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::DX11) { UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); @@ -300,51 +300,51 @@ void DrawSettingsMenu(){ UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); - static std::unordered_map windowBackendNames = { - { LUS::WindowBackend::DX11, "DirectX" }, - { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, - { LUS::WindowBackend::SDL_METAL, "Metal" }, - { LUS::WindowBackend::GX2, "GX2"} + static std::unordered_map windowBackendNames = { + { Ship::WindowBackend::DX11, "DirectX" }, + { Ship::WindowBackend::SDL_OPENGL, "OpenGL"}, + { Ship::WindowBackend::SDL_METAL, "Metal" }, + { Ship::WindowBackend::GX2, "GX2"} }; ImGui::Text("Renderer API (Needs reload)"); - LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); - LUS::WindowBackend configWindowBackend; - int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); - if (configWindowBackendId != -1 && configWindowBackendId < static_cast(LUS::WindowBackend::BACKEND_COUNT)) { - configWindowBackend = static_cast(configWindowBackendId); + Ship::WindowBackend runningWindowBackend = Ship::Context::GetInstance()->GetWindow()->GetWindowBackend(); + Ship::WindowBackend configWindowBackend; + int configWindowBackendId = Ship::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (configWindowBackendId != -1 && configWindowBackendId < static_cast(Ship::WindowBackend::BACKEND_COUNT)) { + configWindowBackend = static_cast(configWindowBackendId); } else { configWindowBackend = runningWindowBackend; } - if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); } if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { - for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { - auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; + for (size_t i = 0; i < Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { + auto backend = Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { - LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); - LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", + Ship::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); + Ship::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", windowBackendNames[backend]); - LUS::Context::GetInstance()->GetConfig()->Save(); + Ship::Context::GetInstance()->GetConfig()->Save(); } } ImGui::EndCombo(); } - if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + if (Ship::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { UIWidgets::ReEnableComponent(""); } - if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { + if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); } - if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { + if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); } - if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { + if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); } @@ -356,7 +356,7 @@ void DrawSettingsMenu(){ UIWidgets::Spacer(0); - LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); ImGui::EndMenu(); } @@ -365,11 +365,11 @@ void DrawSettingsMenu(){ void DrawMenuBarIcon() { static bool gameIconLoaded = false; if (!gameIconLoaded) { - // LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("Game_Icon", "textures/icons/gIcon.png", ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); + // Ship::Context::GetInstance()->GetWindow()->GetGui()->LoadGuiTexture("Game_Icon", "textures/icons/gIcon.png", ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // gameIconLoaded = true; } - if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { + if (Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { #ifdef __SWITCH__ ImVec2 iconSize = ImVec2(20.0f, 20.0f); float posScale = 1.0f; @@ -381,7 +381,7 @@ void DrawMenuBarIcon() { float posScale = 1.5f; #endif ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale); - ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); + ImGui::Image(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); ImGui::SameLine(); ImGui::SetCursorPos(ImVec2(25, 0) * posScale); } @@ -396,16 +396,16 @@ void DrawGameMenu() { "Ctrl+R" #endif )) { - std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); + std::reinterpret_pointer_cast(Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); } #if !defined(__SWITCH__) && !defined(__WIIU__) if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) { - LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen(); + Ship::Context::GetInstance()->GetWindow()->ToggleFullscreen(); } if (UIWidgets::MenuItem("Quit")) { - LUS::Context::GetInstance()->GetWindow()->Close(); + Ship::Context::GetInstance()->GetWindow()->Close(); } #endif ImGui::EndMenu(); diff --git a/src/port/ui/ImguiUI.h b/src/port/ui/ImguiUI.h index 2d233f4c..e3fa9a66 100644 --- a/src/port/ui/ImguiUI.h +++ b/src/port/ui/ImguiUI.h @@ -6,9 +6,9 @@ namespace GameUI { void Destroy(); } -class GameMenuBar : public LUS::GuiMenuBar { +class GameMenuBar : public Ship::GuiMenuBar { public: - using LUS::GuiMenuBar::GuiMenuBar; + using Ship::GuiMenuBar::GuiMenuBar; protected: void DrawElement() override; void InitElement() override {}; diff --git a/src/port/ui/ResolutionEditor.cpp b/src/port/ui/ResolutionEditor.cpp index 3d5293d4..afd687fa 100644 --- a/src/port/ui/ResolutionEditor.cpp +++ b/src/port/ui/ResolutionEditor.cpp @@ -1,7 +1,7 @@ #include "ResolutionEditor.h" #include "UIWidgets.h" -#include +#include #include #include @@ -39,7 +39,7 @@ namespace AdvancedResolutionSettings { const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 }; const int default_pixelCount = 0; // Default combo list option - const uint32_t minVerticalPixelCount = 240; // see: LUS::AdvancedResolution() + const uint32_t minVerticalPixelCount = 240; // see: Ship::AdvancedResolution() const uint32_t maxVerticalPixelCount = 4320; const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. @@ -103,7 +103,7 @@ namespace AdvancedResolutionSettings { (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && CVarGetInteger("gAdvancedResolution.Enabled", 0)) || CVarGetInteger("gLowResMode", 0))) { - LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); } UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective " "form of anti-aliasing"); // Description pulled from SohMenuBar.cpp diff --git a/src/port/ui/ResolutionEditor.h b/src/port/ui/ResolutionEditor.h index 38af5607..90b10f5b 100644 --- a/src/port/ui/ResolutionEditor.h +++ b/src/port/ui/ResolutionEditor.h @@ -2,7 +2,7 @@ #include namespace AdvancedResolutionSettings { - class AdvancedResolutionSettingsWindow : public LUS::GuiWindow { + class AdvancedResolutionSettingsWindow : public Ship::GuiWindow { private: bool IsDroppingFrames(); @@ -10,7 +10,7 @@ namespace AdvancedResolutionSettings { bool IsBoolArrayTrue(bool*); public: - using LUS::GuiWindow::GuiWindow; + using Ship::GuiWindow::GuiWindow; void InitElement() override; void DrawElement() override; diff --git a/src/port/ui/SaveEditor.cpp b/src/port/ui/SaveEditor.cpp index 7ef7477d..1e747698 100644 --- a/src/port/ui/SaveEditor.cpp +++ b/src/port/ui/SaveEditor.cpp @@ -2,7 +2,7 @@ #include "UIWidgets.h" #include -#include +#include #include extern "C" { diff --git a/src/port/ui/SaveEditor.h b/src/port/ui/SaveEditor.h index 6e384cf9..7f4d2683 100644 --- a/src/port/ui/SaveEditor.h +++ b/src/port/ui/SaveEditor.h @@ -84,9 +84,9 @@ const std::vector flagTables = { } }, }; -class SaveEditorWindow : public LUS::GuiWindow { +class SaveEditorWindow : public Ship::GuiWindow { public: - using LUS::GuiWindow::GuiWindow; + using Ship::GuiWindow::GuiWindow; void InitElement() override; void DrawElement() override; diff --git a/src/port/ui/UIWidgets.cpp b/src/port/ui/UIWidgets.cpp index cef68266..c30790be 100644 --- a/src/port/ui/UIWidgets.cpp +++ b/src/port/ui/UIWidgets.cpp @@ -8,7 +8,7 @@ #include "UIWidgets.h" #define IMGUI_DEFINE_MATH_OPERATORS -#include +#include #include #include @@ -203,7 +203,7 @@ namespace UIWidgets { bool val = (bool)CVarGetInteger(cvarName, defaultValue); if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { CVarSetInteger(cvarName, val); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } @@ -243,7 +243,7 @@ namespace UIWidgets { CVarSetInteger(cvarName, i); selected = i; changed = true; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } } @@ -256,7 +256,7 @@ namespace UIWidgets { if (disabledValue >= 0 && selected != disabledValue) { CVarSetInteger(cvarName, disabledValue); changed = true; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } } @@ -345,7 +345,7 @@ namespace UIWidgets { if (changed) { CVarSetInteger(cvarName, val); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } return changed; @@ -421,7 +421,7 @@ namespace UIWidgets { if (changed) { CVarSetFloat(cvarName, val); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } return changed; @@ -468,7 +468,7 @@ namespace UIWidgets { int val = CVarGetInteger(cvarName, 0); if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { CVarSetInteger(cvarName, id); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); ret = true; } ImGui::SameLine(); @@ -495,7 +495,7 @@ namespace UIWidgets { CVarSetColor(cvarName, colorsRGBA); CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); changed = true; } Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); @@ -671,7 +671,7 @@ namespace UIWidgets { return dirty; } - bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options) { + 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; @@ -761,7 +761,7 @@ namespace UIWidgets { bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); if (Checkbox(label, &value, options)) { CVarSetInteger(cvarName, value); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } return dirty; @@ -865,7 +865,7 @@ namespace UIWidgets { uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex); if (Combobox(label, &value, comboArray, options)) { CVarSetInteger(cvarName, value); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } return dirty; @@ -912,7 +912,7 @@ namespace UIWidgets { if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { *value -= options.step; if (*value < min) *value = min; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } ImGui::SameLine(0, 3.0f); @@ -921,7 +921,7 @@ namespace UIWidgets { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); } if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } if (options.showButtons) { @@ -930,7 +930,7 @@ namespace UIWidgets { if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { *value += options.step; if (*value > max) *value = max; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } } @@ -951,7 +951,7 @@ namespace UIWidgets { int32_t value = CVarGetInteger(cvarName, defaultValue); if (SliderInt(label, &value, min, max, options)) { CVarSetInteger(cvarName, value); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } return dirty; @@ -983,7 +983,7 @@ namespace UIWidgets { if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { *value -= options.step; if (*value < min) *value = min; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } ImGui::SameLine(0, 3.0f); @@ -993,7 +993,7 @@ namespace UIWidgets { } if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) { *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } if (options.showButtons) { @@ -1002,7 +1002,7 @@ namespace UIWidgets { if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { *value += options.step; if (*value > max) *value = max; - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } } @@ -1023,7 +1023,7 @@ namespace UIWidgets { float value = CVarGetFloat(cvarName, defaultValue); if (SliderFloat(label, &value, min, max, options)) { CVarSetFloat(cvarName, value); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); dirty = true; } return dirty; diff --git a/src/port/ui/UIWidgets.h b/src/port/ui/UIWidgets.h index 2d398f61..8f3d1402 100644 --- a/src/port/ui/UIWidgets.h +++ b/src/port/ui/UIWidgets.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include namespace UIWidgets { @@ -24,7 +24,7 @@ namespace UIWidgets { } return 1; } - + }; // MARK: - Enums @@ -64,17 +64,17 @@ namespace UIWidgets { bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); - + bool EnhancementCombobox(const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); - + void PaddedText(const char* text, bool padTop = true, bool padBottom = true); - + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); - + bool EnhancementRadioButton(const char* text, const char* cvarName, int id); bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha); @@ -140,7 +140,7 @@ namespace UIWidgets { void PushStyleButton(const ImVec4& color = Colors::Gray); void PopStyleButton(); bool Button(const char* label, const ButtonOptions& options = {}); - bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options = {}); + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options = {}); struct CheckboxOptions { const ImVec4 color = Colors::Indigo;