aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorJesse Talavera <jesse@jesse.tg>2024-01-03 07:32:17 -0500
committerGitHub <noreply@github.com>2024-01-03 13:32:17 +0100
commitd1cbc41115e65e9441ce6cb98d94af2923f42d79 (patch)
tree6e1d8dc36083a767184d38a635814d0c62ee4436 /src/frontend
parent8bfc6df8de216eff0be4be1dbe37b19a741bed51 (diff)
Slight fixups with `FATStorage` (#1934)
* Reload the SD card for `CartSD` and all subclasses * Make `ROMManager::LoadDLDISDCard` delegate to `GetDLDISDCardArgs` * Add a method overload for `CartSD::SetSDCard` * Initialize new SD card images with the correct size * Sync the old card to the host (if applicable) when move-assigning a new one * Only sync the old card to the host if it's not read-only * Remove static state in `FATStorage` - Replace `FF_ReadStorage` and `FF_WriteStorage` with lambda functions - Keep open and use the single `File` handle throughout the `FATStorage`'s life
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/qt_sdl/EmuThread.cpp7
-rw-r--r--src/frontend/qt_sdl/ROMManager.cpp14
2 files changed, 10 insertions, 11 deletions
diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp
index 4a75387..01431a1 100644
--- a/src/frontend/qt_sdl/EmuThread.cpp
+++ b/src/frontend/qt_sdl/EmuThread.cpp
@@ -196,12 +196,11 @@ bool EmuThread::UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAAr
ndsargs = {};
}
- if (nextndscart && nextndscart->Type() == NDSCart::Homebrew)
+ if (auto* cartsd = dynamic_cast<NDSCart::CartSD*>(nextndscart.get()))
{
- // Load DLDISDCard will return nullopt if the SD card is disabled;
+ // LoadDLDISDCard will return nullopt if the SD card is disabled;
// SetSDCard will accept nullopt, which means no SD card
- auto& homebrew = static_cast<NDSCart::CartHomebrew&>(*nextndscart);
- homebrew.SetSDCard(ROMManager::LoadDLDISDCard());
+ cartsd->SetSDCard(ROMManager::GetDLDISDCardArgs());
}
std::unique_ptr<GBACart::CartCommon> nextgbacart;
diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp
index a20af20..15a9ebf 100644
--- a/src/frontend/qt_sdl/ROMManager.cpp
+++ b/src/frontend/qt_sdl/ROMManager.cpp
@@ -759,7 +759,12 @@ std::optional<DSi_NAND::NANDImage> LoadNAND(const std::array<u8, DSiBIOSSize>& a
return nandImage;
}
-constexpr u64 imgsizes[] = {0, 256, 512, 1024, 2048, 4096};
+constexpr u64 MB(u64 i)
+{
+ return i * 1024 * 1024;
+}
+
+constexpr u64 imgsizes[] = {0, MB(256), MB(512), MB(1024), MB(2048), MB(4096)};
std::optional<FATStorageArgs> GetDSiSDCardArgs() noexcept
{
if (!Config::DSiSDEnable)
@@ -804,12 +809,7 @@ std::optional<FATStorage> LoadDLDISDCard() noexcept
if (!Config::DLDIEnable)
return std::nullopt;
- return FATStorage(
- Config::DLDISDPath,
- imgsizes[Config::DLDISize],
- Config::DLDIReadOnly,
- Config::DLDIFolderSync ? std::make_optional(Config::DLDIFolderPath) : std::nullopt
- );
+ return FATStorage(*GetDLDISDCardArgs());
}
void EnableCheats(NDS& nds, bool enable)