diff --git a/Runtime/CMemoryCardSys.cpp b/Runtime/CMemoryCardSys.cpp index 47e12ef08..3b5fcbc84 100644 --- a/Runtime/CMemoryCardSys.cpp +++ b/Runtime/CMemoryCardSys.cpp @@ -6,15 +6,19 @@ #include "Runtime/GameGlobalObjects.hpp" #include "Runtime/Graphics/CTexture.hpp" #include "Runtime/GuiSys/CStringTable.hpp" +#include +#include namespace urde { - +namespace { using ECardResult = kabufuda::ECardResult; static kabufuda::SystemString g_CardImagePaths[2] = {}; static kabufuda::Card g_CardStates[2] = {kabufuda::Card{"GM8E", "01"}, kabufuda::Card{"GM8E", "01"}}; // static kabufuda::ECardResult g_OpResults[2] = {}; - +hecl::CVar* mc_dolphinAPath = nullptr; +hecl::CVar* mc_dolphinBPath = nullptr; +} // namespace CSaveWorldIntermediate::CSaveWorldIntermediate(CAssetId mlvl, CAssetId savw) : x0_mlvlId(mlvl), x8_savwId(savw) { if (!savw.IsValid()) x2c_dummyWorld = std::make_unique(mlvl, false); @@ -67,6 +71,12 @@ const CSaveWorldMemory& CMemoryCardSys::GetSaveWorldMemory(CAssetId wldId) const } CMemoryCardSys::CMemoryCardSys() { + mc_dolphinAPath = hecl::CVarManager::instance()->findOrMakeCVar( + "memcard.PathA"sv, "Path to the memory card image for SlotA"sv, ""sv, + (hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::System | hecl::CVar::EFlags::ModifyRestart)); + mc_dolphinBPath = hecl::CVarManager::instance()->findOrMakeCVar( + "memcard.PathB"sv, "Path to the memory card image for SlotB"sv, ""sv, + (hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::System | hecl::CVar::EFlags::ModifyRestart)); x0_hints = g_SimplePool->GetObj("HINT_Hints"); xc_memoryWorlds.reserve(16); x1c_worldInter.emplace(); @@ -139,9 +149,8 @@ bool CMemoryCardSys::InitializePump() { } if (done) { - std::sort(x20_scanStates.begin(), x20_scanStates.end(), [&](const auto& a, const auto& b) { - return a.first < b.first; - }); + std::sort(x20_scanStates.begin(), x20_scanStates.end(), + [&](const auto& a, const auto& b) { return a.first < b.first; }); x1c_worldInter = std::nullopt; } @@ -149,15 +158,15 @@ bool CMemoryCardSys::InitializePump() { } std::pair CMemoryCardSys::GetAreaAndWorldIdForSaveId(s32 saveId) const { - for (const auto& [mlvl, saveWorld] : xc_memoryWorlds) { - for (TAreaId areaId = 0; areaId < saveWorld.xc_areaIds.size(); ++areaId) { - if (saveWorld.xc_areaIds[areaId] == saveId) { - return {mlvl, areaId}; - } - } + for (const auto& [mlvl, saveWorld] : xc_memoryWorlds) { + for (TAreaId areaId = 0; areaId < saveWorld.xc_areaIds.size(); ++areaId) { + if (saveWorld.xc_areaIds[areaId] == saveId) { + return {mlvl, areaId}; + } } + } - return {{}, kInvalidAreaId}; + return {{}, kInvalidAreaId}; } void CMemoryCardSys::CCardFileInfo::LockBannerToken(CAssetId bannerTxtr, CSimplePool& sp) { @@ -327,9 +336,25 @@ ECardResult CMemoryCardSys::CCardFileInfo::WriteFile() { ECardResult CMemoryCardSys::CCardFileInfo::CloseFile() { return CMemoryCardSys::CloseFile(m_handle); } +void CMemoryCardSys::_ResolveDolphinCardPath(const hecl::CVar* cv, kabufuda::ECardSlot slot) { +#if CARD_UCS2 + if (cv != nullptr && cv->toWideLiteral().empty()) { + g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot); + } else if (cv != nullptr) { + g_CardImagePaths[int(slot)] = cv->toWideLiteral(); + } +#else + if (cv != nullptr && cv->toLiteral().empty()) { + g_CardImagePaths[int(slot)] = ResolveDolphinCardPath(slot); + } else if (cv != nullptr) { + g_CardImagePaths[int(slot)] = cv->toLiteral(); + } +#endif +} + kabufuda::ProbeResults CMemoryCardSys::CardProbe(kabufuda::ECardSlot port) { - g_CardImagePaths[0] = ResolveDolphinCardPath(kabufuda::ECardSlot::SlotA); - g_CardImagePaths[1] = ResolveDolphinCardPath(kabufuda::ECardSlot::SlotB); + _ResolveDolphinCardPath(mc_dolphinAPath, kabufuda::ECardSlot::SlotA); + _ResolveDolphinCardPath(mc_dolphinBPath, kabufuda::ECardSlot::SlotB); kabufuda::ProbeResults res = kabufuda::Card::probeCardFile(g_CardImagePaths[int(port)]); // g_OpResults[int(port)] = res.x0_error; diff --git a/Runtime/CMemoryCardSys.hpp b/Runtime/CMemoryCardSys.hpp index ce4c8387a..8d491bd26 100644 --- a/Runtime/CMemoryCardSys.hpp +++ b/Runtime/CMemoryCardSys.hpp @@ -67,6 +67,7 @@ class CMemoryCardSys { rstl::reserved_vector x30_scanCategoryCounts; public: + static void _ResolveDolphinCardPath(const hecl::CVar* cv, kabufuda::ECardSlot slot); static kabufuda::SystemString ResolveDolphinCardPath(kabufuda::ECardSlot slot); static kabufuda::SystemString CreateDolphinCard(kabufuda::ECardSlot slot); static kabufuda::SystemString _CreateDolphinCard(kabufuda::ECardSlot slot); diff --git a/hecl b/hecl index 1ca04a490..ec30cc090 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 1ca04a490ef755f2f976769c5bf78ea7386452bd +Subproject commit ec30cc090a2fcb14acb79f745a16d1bbb5b913f5 diff --git a/hecl-gui b/hecl-gui index b0969a4b7..ce8dc3ddc 160000 --- a/hecl-gui +++ b/hecl-gui @@ -1 +1 @@ -Subproject commit b0969a4b72d8e7b7183a6e54e6c3bd934d9f93e3 +Subproject commit ce8dc3ddc55d00051c834d2971cb3f24417076b9 diff --git a/specter b/specter index e061a0ef2..c1aa98247 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit e061a0ef216523ee76783e4b0d6c1dfc70944037 +Subproject commit c1aa9824749f15a729166dc8b93ff5ee0eae2a29