mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Try to load DLDI driver from arm9 binary
This commit is contained in:
parent
ffd8a4d661
commit
10ca991150
2
Makefile
2
Makefile
@ -27,7 +27,7 @@ TARGET := GodMode9i
|
|||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := source
|
SOURCES := source
|
||||||
INCLUDES := include source
|
INCLUDES := include source
|
||||||
DATA := data
|
DATA := data dldi
|
||||||
GRAPHICS := gfx
|
GRAPHICS := gfx
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
|
#include "driveOperations.h"
|
||||||
|
|
||||||
#define SCREEN_COLS 32
|
#define SCREEN_COLS 32
|
||||||
#define ENTRIES_PER_SCREEN 22
|
#define ENTRIES_PER_SCREEN 22
|
||||||
@ -86,8 +87,20 @@ void driveMenu (void) {
|
|||||||
if (dmCursorPosition > 1) dmCursorPosition = 0; // Wrap around to top of list
|
if (dmCursorPosition > 1) dmCursorPosition = 0; // Wrap around to top of list
|
||||||
|
|
||||||
if (pressed & KEY_A) {
|
if (pressed & KEY_A) {
|
||||||
|
if (dmCursorPosition == 0 && isDSiMode()) {
|
||||||
|
chdir("sd:/");
|
||||||
|
screenMode = 1;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (isDSiMode()) {
|
||||||
|
flashcardMount();
|
||||||
|
}
|
||||||
|
if (flashcardFound()) {
|
||||||
|
chdir("fat:/");
|
||||||
screenMode = 1;
|
screenMode = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
119
arm9/source/driveOperations.cpp
Normal file
119
arm9/source/driveOperations.cpp
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
#include <nds.h>
|
||||||
|
#include <nds/arm9/dldi.h>
|
||||||
|
#include <fat.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "r4idsn_sd_bin.h"
|
||||||
|
#include "ak2_sd_bin.h"
|
||||||
|
|
||||||
|
static sNDSHeader nds;
|
||||||
|
|
||||||
|
bool sdFound(void) {
|
||||||
|
if (access("sd:/", F_OK) == 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool flashcardFound(void) {
|
||||||
|
if (access("fat:/", F_OK) == 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bothSDandFlashcard(void) {
|
||||||
|
if ((access("sd:/", F_OK) == 0) && (access("fat:/", F_OK) == 0)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DLDI_INTERFACE* dldiLoadFromBin (void* dldiAddr, u16 size) {
|
||||||
|
DLDI_INTERFACE* device;
|
||||||
|
|
||||||
|
if ((device = (DLDI_INTERFACE*)malloc (sizeof(DLDI_INTERFACE))) == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load entire DLDI
|
||||||
|
memcpy(device, dldiAddr, size);
|
||||||
|
|
||||||
|
// Check that it is a valid DLDI
|
||||||
|
if (!dldiIsValid (device)) {
|
||||||
|
free (device);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dldiFixDriverAddresses (device);
|
||||||
|
|
||||||
|
if (device->ioInterface.features & FEATURE_SLOT_GBA) {
|
||||||
|
sysSetCartOwner(BUS_OWNER_ARM9);
|
||||||
|
}
|
||||||
|
if (device->ioInterface.features & FEATURE_SLOT_NDS) {
|
||||||
|
sysSetCardOwner(BUS_OWNER_ARM9);
|
||||||
|
}
|
||||||
|
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UpdateCardInfo(sNDSHeader* nds, char* gameid, char* gamename) {
|
||||||
|
cardReadHeader((uint8*)nds);
|
||||||
|
memcpy(gameid, nds->gameCode, 4);
|
||||||
|
gameid[4] = 0x00;
|
||||||
|
memcpy(gamename, nds->gameTitle, 12);
|
||||||
|
gamename[12] = 0x00;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
// Reset Slot-1 to allow reading title name and ID
|
||||||
|
sysSetCardOwner (BUS_OWNER_ARM9);
|
||||||
|
disableSlot1();
|
||||||
|
for(int i = 0; i < 25; i++) { swiWaitForVBlank(); }
|
||||||
|
enableSlot1();
|
||||||
|
for(int i = 0; i < 15; i++) { swiWaitForVBlank(); }
|
||||||
|
|
||||||
|
nds.gameCode[0] = 0;
|
||||||
|
nds.gameTitle[0] = 0;
|
||||||
|
char gamename[13];
|
||||||
|
char gameid[5];
|
||||||
|
|
||||||
|
/*fifoSendValue32(FIFO_USER_04, 1);
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
swiWaitForVBlank();
|
||||||
|
}
|
||||||
|
memcpy(&nds, (void*)0x02000000, sizeof(nds));*/
|
||||||
|
UpdateCardInfo(&nds, &gameid[0], &gamename[0]);
|
||||||
|
|
||||||
|
/*SetBrightness(0, 0);
|
||||||
|
SetBrightness(1, 0);
|
||||||
|
consoleDemoInit();
|
||||||
|
iprintf("REG_SCFG_MC: %x\n", REG_SCFG_MC);
|
||||||
|
ShowGameInfo(gameid, gamename);
|
||||||
|
|
||||||
|
for (int i = 0; i < 60*5; i++) {
|
||||||
|
swiWaitForVBlank();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
sysSetCardOwner (BUS_OWNER_ARM7); // 3DS fix
|
||||||
|
|
||||||
|
// Read a DLDI driver specific to the cart
|
||||||
|
if (!memcmp(gamename, "R4DSULTRA", 9)) {
|
||||||
|
io_dldi_data = dldiLoadFromBin((void*)r4idsn_sd_bin, r4idsn_sd_bin_size);
|
||||||
|
fatMountSimple("fat", &io_dldi_data->ioInterface);
|
||||||
|
} else if (!memcmp(gameid, "YCEP", 4) || !memcmp(gameid, "AHZH", 4)) {
|
||||||
|
io_dldi_data = dldiLoadFromBin((void*)ak2_sd_bin, ak2_sd_bin_size);
|
||||||
|
fatMountSimple("fat", &io_dldi_data->ioInterface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
arm9/source/driveOperations.h
Normal file
9
arm9/source/driveOperations.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef FLASHCARD_H
|
||||||
|
#define FLASHCARD_H
|
||||||
|
|
||||||
|
bool sdFound(void);
|
||||||
|
bool flashcardFound(void);
|
||||||
|
bool bothSDandFlashcard(void);
|
||||||
|
void flashcardMount(void);
|
||||||
|
|
||||||
|
#endif //FLASHCARD_H
|
||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
//#include "iconTitle.h"
|
//#include "iconTitle.h"
|
||||||
|
|
||||||
char titleName[32];
|
char titleName[32] = {" "};
|
||||||
|
|
||||||
int screenMode = 0;
|
int screenMode = 0;
|
||||||
|
|
||||||
|
|||||||
BIN
dldi/ak2_sd.bin
Normal file
BIN
dldi/ak2_sd.bin
Normal file
Binary file not shown.
BIN
dldi/r4idsn_sd.bin
Normal file
BIN
dldi/r4idsn_sd.bin
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user