mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Mount flashcard, if supported one is inserted
This commit is contained in:
parent
0a3d3b5e13
commit
8e07f18eea
@ -35,17 +35,17 @@ using namespace std;
|
||||
|
||||
static bool dmTextPrinted = false;
|
||||
static int dmCursorPosition = 0;
|
||||
static bool sdMounted = false;
|
||||
static u8 dm_SCFG_MC = 0;
|
||||
|
||||
void driveMenu (void) {
|
||||
int pressed = 0;
|
||||
int held = 0;
|
||||
|
||||
if (isDSiMode()) {
|
||||
sdMounted = sdFound();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
if (isDSiMode() && !pressed) {
|
||||
flashcardMounted = flashcardMount(); // Try to mount flashcard
|
||||
}
|
||||
|
||||
if (!dmTextPrinted) {
|
||||
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
|
||||
if (dmCursorPosition == 0 && isDSiMode()) {
|
||||
@ -95,6 +95,8 @@ void driveMenu (void) {
|
||||
|
||||
dmTextPrinted = true;
|
||||
}
|
||||
|
||||
dm_SCFG_MC = REG_SCFG_MC;
|
||||
|
||||
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||
do {
|
||||
@ -107,6 +109,10 @@ void driveMenu (void) {
|
||||
pressed = keysDownRepeat();
|
||||
held = keysHeld();
|
||||
swiWaitForVBlank();
|
||||
|
||||
if (REG_SCFG_MC != dm_SCFG_MC) {
|
||||
break;
|
||||
}
|
||||
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_A) && !(held & KEY_R));
|
||||
|
||||
if ((pressed & KEY_UP) && isDSiMode()) {
|
||||
@ -130,10 +136,7 @@ void driveMenu (void) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (isDSiMode()) {
|
||||
flashcardMount();
|
||||
}
|
||||
if (flashcardFound()) {
|
||||
if (flashcardMounted) {
|
||||
dmTextPrinted = false;
|
||||
chdir("fat:/");
|
||||
screenMode = 1;
|
||||
@ -144,12 +147,10 @@ void driveMenu (void) {
|
||||
|
||||
// Unmount/Remount SD card
|
||||
if ((held & KEY_R) && (pressed & KEY_B) && isDSiMode()) {
|
||||
dmTextPrinted = false;
|
||||
if (sdMounted) {
|
||||
dmTextPrinted = false;
|
||||
sdUnmount();
|
||||
sdMounted = false;
|
||||
} else {
|
||||
dmTextPrinted = false;
|
||||
sdMounted = sdMount();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
|
||||
static sNDSHeader nds;
|
||||
|
||||
bool sdMounted = false;
|
||||
bool flashcardMounted = false;
|
||||
|
||||
bool sdFound(void) {
|
||||
if (access("sd:/", F_OK) == 0) {
|
||||
return true;
|
||||
@ -39,6 +42,7 @@ bool sdMount(void) {
|
||||
|
||||
void sdUnmount(void) {
|
||||
fatUnmount("sd");
|
||||
sdMounted = false;
|
||||
}
|
||||
|
||||
DLDI_INTERFACE* dldiLoadFromBin (const u8 dldiAddr[]) {
|
||||
@ -100,8 +104,10 @@ void ShowGameInfo(const char gameid[], const char gamename[]) {
|
||||
iprintf("Game id: %s\nName: %s", gameid, gamename);
|
||||
}
|
||||
|
||||
void flashcardMount(void) {
|
||||
if (!flashcardFound() && REG_SCFG_MC != 0x11) {
|
||||
bool flashcardMount(void) {
|
||||
if (flashcardFound()) {
|
||||
return true;
|
||||
} else if (REG_SCFG_MC != 0x11) {
|
||||
// Reset Slot-1 to allow reading title name and ID
|
||||
sysSetCardOwner (BUS_OWNER_ARM9);
|
||||
disableSlot1();
|
||||
@ -136,10 +142,16 @@ void flashcardMount(void) {
|
||||
// Read a DLDI driver specific to the cart
|
||||
if (!memcmp(gamename, "R4DSULTRA", 9)) {
|
||||
io_dldi_data = dldiLoadFromBin(r4idsn_sd_bin);
|
||||
fatMountSimple("fat", &io_dldi_data->ioInterface);
|
||||
return fatMountSimple("fat", &io_dldi_data->ioInterface);
|
||||
} else if (!memcmp(gameid, "YCEP", 4) || !memcmp(gameid, "AHZH", 4)) {
|
||||
io_dldi_data = dldiLoadFromBin(ak2_sd_bin);
|
||||
fatMountSimple("fat", &io_dldi_data->ioInterface);
|
||||
return fatMountSimple("fat", &io_dldi_data->ioInterface);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void flashcardUnmount(void) {
|
||||
fatUnmount("fat");
|
||||
flashcardMounted = false;
|
||||
}
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
#ifndef FLASHCARD_H
|
||||
#define FLASHCARD_H
|
||||
|
||||
bool sdFound(void);
|
||||
bool flashcardFound(void);
|
||||
bool bothSDandFlashcard(void);
|
||||
bool sdMount(void);
|
||||
void sdUnmount(void);
|
||||
void flashcardMount(void);
|
||||
extern bool sdMounted;
|
||||
extern bool flashcardMounted;
|
||||
|
||||
extern bool sdFound(void);
|
||||
extern bool flashcardFound(void);
|
||||
extern bool bothSDandFlashcard(void);
|
||||
extern bool sdMount(void);
|
||||
extern void sdUnmount(void);
|
||||
extern bool flashcardMount(void);
|
||||
extern void flashcardUnmount(void);
|
||||
|
||||
#endif //FLASHCARD_H
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include "nds_loader_arm9.h"
|
||||
#include "driveMenu.h"
|
||||
#include "driveOperations.h"
|
||||
#include "file_browse.h"
|
||||
|
||||
#include "gm9i_logo.h"
|
||||
@ -108,7 +109,10 @@ int main(int argc, char **argv) {
|
||||
stop();
|
||||
}*/
|
||||
|
||||
fatInitDefault();
|
||||
if (isDSiMode()) {
|
||||
sdMounted = sdMount();
|
||||
}
|
||||
flashcardMounted = flashcardMount();
|
||||
|
||||
// Top screen as a console
|
||||
videoSetMode(MODE_0_2D);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user