Make sure cart is inserted correctly before mounting flashcard

This commit is contained in:
RocketRobz 2018-10-16 15:43:46 -06:00
parent 7721df24c4
commit 1c99a3a613
3 changed files with 25 additions and 4 deletions

View File

@ -11,6 +11,8 @@ static sNDSHeader nds;
u8 stored_SCFG_MC = 0;
static bool slot1Enabled = true;
bool sdMounted = false;
bool sdMountedDone = false; // true if SD mount is successful once
bool flashcardMounted = false;
@ -137,10 +139,23 @@ TWL_CODE bool twl_flashcardMount(void) {
sysSetCardOwner (BUS_OWNER_ARM9);
// Reset Slot-1 to allow reading title name and ID
disableSlot1();
for(int i = 0; i < 25; i++) { swiWaitForVBlank(); }
enableSlot1();
for(int i = 0; i < 15; i++) { swiWaitForVBlank(); }
if (slot1Enabled) {
disableSlot1();
for(int i = 0; i < 25; i++) { swiWaitForVBlank(); }
slot1Enabled = false;
}
if (appInited) {
for(int i = 0; i < 35; i++) { swiWaitForVBlank(); } // Make sure cart is inserted correctly
}
if (REG_SCFG_MC == 0x11) {
sysSetCardOwner (BUS_OWNER_ARM7);
return false;
}
if (!slot1Enabled) {
enableSlot1();
for(int i = 0; i < 15; i++) { swiWaitForVBlank(); }
slot1Enabled = true;
}
nds.gameCode[0] = 0;
nds.gameTitle[0] = 0;

View File

@ -40,6 +40,8 @@ char titleName[32] = {" "};
int screenMode = 0;
bool appInited = false;
bool arm7SCFGLocked = false;
bool isRegularDS = true;
bool is3DS = true;
@ -150,6 +152,8 @@ int main(int argc, char **argv) {
keysSetRepeat(25,5);
appInited = true;
while(1) {
if (screenMode == 0) {

View File

@ -8,6 +8,8 @@ extern char titleName[32];
extern int screenMode;
extern bool appInited;
extern bool arm7SCFGLocked;
extern bool isRegularDS;
extern bool is3DS;