aboutsummaryrefslogtreecommitdiff
path: root/src/FATStorage.h
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/FATStorage.h
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/FATStorage.h')
-rw-r--r--src/FATStorage.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/FATStorage.h b/src/FATStorage.h
index 48a411b..0062846 100644
--- a/src/FATStorage.h
+++ b/src/FATStorage.h
@@ -28,6 +28,7 @@
#include "Platform.h"
#include "types.h"
#include "fatfs/ff.h"
+#include "FATIO.h"
namespace melonDS
{
@@ -39,6 +40,8 @@ namespace melonDS
struct FATStorageArgs
{
std::string Filename;
+
+ /// Size of the desired SD card in bytes, or 0 for auto-detect.
u64 Size;
bool ReadOnly;
std::optional<std::string> SourceDir;
@@ -74,10 +77,8 @@ private:
Platform::FileHandle* File;
u64 FileSize;
- static Platform::FileHandle* FF_File;
- static u64 FF_FileSize;
- static UINT FF_ReadStorage(BYTE* buf, LBA_t sector, UINT num);
- static UINT FF_WriteStorage(const BYTE* buf, LBA_t sector, UINT num);
+ [[nodiscard]] ff_disk_read_cb FF_ReadStorage() const noexcept;
+ [[nodiscard]] ff_disk_write_cb FF_WriteStorage() const noexcept;
static u32 ReadSectorsInternal(Platform::FileHandle* file, u64 filelen, u32 start, u32 num, u8* data);
static u32 WriteSectorsInternal(Platform::FileHandle* file, u64 filelen, u32 start, u32 num, const u8* data);