From f2fa52f26ceb1f385d58e57ab26ca7d5349978d2 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Fri, 11 Sep 2020 03:08:06 +0200 Subject: add functionality to import savefiles --- src/NDSCart.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/NDSCart.cpp') diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index 6abfc7c..5710213 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -1034,6 +1034,12 @@ void RelocateSave(const char* path, bool write) NDSCart_SRAM::RelocateSave(path, write); } +int ImportSRAM(const u8* data, u32 length) +{ + memcpy(NDSCart_SRAM::SRAM, data, std::min(length, NDSCart_SRAM::SRAMLength)); + return length - NDSCart_SRAM::SRAMLength; +} + void ResetCart() { // CHECKME: what if there is a transfer in progress? -- cgit v1.2.3 From ef4215e172d2a83f39cb90a804e3f20d290ad52d Mon Sep 17 00:00:00 2001 From: RSDuck Date: Tue, 6 Oct 2020 00:48:35 +0200 Subject: flush to file after importing SRAM --- src/NDSCart.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/NDSCart.cpp') diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index 5710213..077bf48 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -1037,6 +1037,13 @@ void RelocateSave(const char* path, bool write) int ImportSRAM(const u8* data, u32 length) { memcpy(NDSCart_SRAM::SRAM, data, std::min(length, NDSCart_SRAM::SRAMLength)); + FILE* f = Platform::OpenFile(NDSCart_SRAM::SRAMPath, "wb"); + if (f) + { + fwrite(NDSCart_SRAM::SRAM, NDSCart_SRAM::SRAMLength, 1, f); + fclose(f); + } + return length - NDSCart_SRAM::SRAMLength; } -- cgit v1.2.3