aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/Util_ROM.cpp
diff options
context:
space:
mode:
authorRSDuck <rsduck@users.noreply.github.com>2021-01-17 19:56:02 +0100
committerRSDuck <rsduck@users.noreply.github.com>2021-01-17 19:56:02 +0100
commit1d6cc3c6ef8cf724883d3f12fa5a06fe25bf5839 (patch)
tree2f4a5da504de4f4f45cd60198a0686db7d85ab36 /src/frontend/Util_ROM.cpp
parent53d5def9192d1217e8d0e0cc3ce90f7060ba74db (diff)
keep only one handle of the NAND file around
Diffstat (limited to 'src/frontend/Util_ROM.cpp')
-rw-r--r--src/frontend/Util_ROM.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/frontend/Util_ROM.cpp b/src/frontend/Util_ROM.cpp
index 9f22f5f..065b319 100644
--- a/src/frontend/Util_ROM.cpp
+++ b/src/frontend/Util_ROM.cpp
@@ -25,6 +25,7 @@
#include "Platform.h"
#include "NDS.h"
+#include "DSi.h"
#include "GBACart.h"
#include "AREngine.h"
@@ -199,18 +200,27 @@ int VerifyDSiFirmware()
return Load_OK;
}
-int VerifyDSiNAND()
+int SetupDSiNAND()
{
FILE* f;
long len;
- f = Platform::OpenLocalFile(Config::DSiNANDPath, "rb");
+ f = Platform::OpenLocalFile(Config::DSiNANDPath, "r+b");
if (!f) return Load_DSiNANDMissing;
// TODO: some basic checks
// check that it has the nocash footer, and all
- fclose(f);
+ DSi::SDMMCFile = f;
+
+ if (Config::DSiSDEnable)
+ {
+ f = Platform::OpenLocalFile(Config::DSiSDPath, "r+b");
+ if (f)
+ DSi::SDIOFile = f;
+ else
+ DSi::SDIOFile = Platform::OpenLocalFile(Config::DSiSDPath, "w+b");
+ }
return Load_OK;
}
@@ -243,6 +253,8 @@ void LoadCheats()
int LoadBIOS()
{
+ DSi::CloseDSiNAND();
+
int res;
res = VerifyDSBIOS();
@@ -256,7 +268,7 @@ int LoadBIOS()
res = VerifyDSiFirmware();
if (res != Load_OK) return res;
- res = VerifyDSiNAND();
+ res = SetupDSiNAND();
if (res != Load_OK) return res;
}
else
@@ -285,6 +297,8 @@ int LoadBIOS()
int LoadROM(const char* file, int slot)
{
+ DSi::CloseDSiNAND();
+
int res;
bool directboot = Config::DirectBoot != 0;
@@ -305,7 +319,7 @@ int LoadROM(const char* file, int slot)
res = VerifyDSiFirmware();
if (res != Load_OK) return res;
- res = VerifyDSiNAND();
+ res = SetupDSiNAND();
if (res != Load_OK) return res;
GBACart::Eject();
@@ -376,10 +390,14 @@ void UnloadROM(int slot)
}
ROMPath[slot][0] = '\0';
+
+ DSi::CloseDSiNAND();
}
int Reset()
{
+ DSi::CloseDSiNAND();
+
int res;
bool directboot = Config::DirectBoot != 0;
@@ -394,7 +412,7 @@ int Reset()
res = VerifyDSiFirmware();
if (res != Load_OK) return res;
- res = VerifyDSiNAND();
+ res = SetupDSiNAND();
if (res != Load_OK) return res;
GBACart::Eject();