mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-27 00:00:07 -06:00
keep only one handle of the NAND file around
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user