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