mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Add unused DS mode ROM dumping code
This commit is contained in:
parent
065674a19f
commit
ef4b474fd6
@ -52,6 +52,8 @@ static int dmMaxCursors = -1;
|
|||||||
|
|
||||||
static u8 gbaFixedValue = 0;
|
static u8 gbaFixedValue = 0;
|
||||||
|
|
||||||
|
extern bool expansionPakFound;
|
||||||
|
|
||||||
extern PrintConsole topConsole, bottomConsole;
|
extern PrintConsole topConsole, bottomConsole;
|
||||||
|
|
||||||
extern void printBorderTop(void);
|
extern void printBorderTop(void);
|
||||||
@ -228,7 +230,9 @@ void driveMenu (void) {
|
|||||||
dmMaxCursors++;
|
dmMaxCursors++;
|
||||||
dmAssignedOp[dmMaxCursors] = 6;
|
dmAssignedOp[dmMaxCursors] = 6;
|
||||||
}
|
}
|
||||||
if ((io_dldi_data->ioInterface.features & FEATURE_SLOT_GBA) || (isDSiMode() && !(REG_SCFG_MC & BIT(0)))) {
|
if (expansionPakFound
|
||||||
|
|| (io_dldi_data->ioInterface.features & FEATURE_SLOT_GBA)
|
||||||
|
|| (isDSiMode() && !(REG_SCFG_MC & BIT(0)))) {
|
||||||
dmMaxCursors++;
|
dmMaxCursors++;
|
||||||
dmAssignedOp[dmMaxCursors] = 4;
|
dmAssignedOp[dmMaxCursors] = 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -287,7 +287,7 @@ TWL_CODE bool twl_flashcardMount(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool flashcardMount(void) {
|
bool flashcardMount(void) {
|
||||||
if ((!isDSiMode()) || (arm7SCFGLocked && !sdMountedDone)) {
|
if (!isDSiMode() || (arm7SCFGLocked && !sdMountedDone)) {
|
||||||
fatInitDefault();
|
fatInitDefault();
|
||||||
if (flashcardFound()) {
|
if (flashcardFound()) {
|
||||||
fatGetVolumeLabel("fat", fatLabel);
|
fatGetVolumeLabel("fat", fatLabel);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include <nds.h>
|
#include <nds.h>
|
||||||
|
#include <nds/arm9/dldi.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -12,6 +13,8 @@
|
|||||||
#include "read_card.h"
|
#include "read_card.h"
|
||||||
#include "tonccpy.h"
|
#include "tonccpy.h"
|
||||||
|
|
||||||
|
extern bool expansionPakFound;
|
||||||
|
|
||||||
extern PrintConsole topConsole, bottomConsole;
|
extern PrintConsole topConsole, bottomConsole;
|
||||||
|
|
||||||
static sNDSHeaderExt ndsCardHeader;
|
static sNDSHeaderExt ndsCardHeader;
|
||||||
@ -50,6 +53,7 @@ void ndsCardSaveDump(const char* filename) {
|
|||||||
|
|
||||||
void ndsCardDump(void) {
|
void ndsCardDump(void) {
|
||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
|
bool showGameCardMsgAgain = false;
|
||||||
|
|
||||||
consoleSelect(&bottomConsole);
|
consoleSelect(&bottomConsole);
|
||||||
consoleClear();
|
consoleClear();
|
||||||
@ -89,6 +93,29 @@ void ndsCardDump(void) {
|
|||||||
printf("Creating directory...");
|
printf("Creating directory...");
|
||||||
mkdir(folderPath[1], 0777);
|
mkdir(folderPath[1], 0777);
|
||||||
}
|
}
|
||||||
|
if (expansionPakFound) {
|
||||||
|
consoleClear();
|
||||||
|
printf("Please switch to the\ngame card, then press A.\n");
|
||||||
|
//flashcardUnmount();
|
||||||
|
io_dldi_data->ioInterface.shutdown();
|
||||||
|
|
||||||
|
consoleSelect(&topConsole);
|
||||||
|
printf ("\x1B[30m"); // Print black color
|
||||||
|
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||||
|
do {
|
||||||
|
// Move to right side of screen
|
||||||
|
printf ("\x1b[0;26H");
|
||||||
|
// Print time
|
||||||
|
printf (" %s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
scanKeys();
|
||||||
|
pressed = keysDownRepeat();
|
||||||
|
swiWaitForVBlank();
|
||||||
|
} while (!(pressed & KEY_A));
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1B[47m"); // Print foreground white color
|
||||||
|
}
|
||||||
consoleClear();
|
consoleClear();
|
||||||
if (cardInit(&ndsCardHeader) == 0) {
|
if (cardInit(&ndsCardHeader) == 0) {
|
||||||
printf("Dumping...\n");
|
printf("Dumping...\n");
|
||||||
@ -157,26 +184,131 @@ void ndsCardDump(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Dump!
|
// Dump!
|
||||||
remove(destPath);
|
if (expansionPakFound) {
|
||||||
FILE* destinationFile = fopen(destPath, "wb");
|
u32 currentSize = ((expansionPakFound && romSize > 0x800000) ? 0x800000 : romSize);
|
||||||
for (u32 src = 0; src < romSize; src += 0x200) {
|
u32 src = 0;
|
||||||
consoleSelect(&topConsole);
|
u32 writeSrc = 0;
|
||||||
printf ("\x1B[30m"); // Print black color
|
FILE* destinationFile;
|
||||||
// Move to right side of screen
|
bool destinationFileOpened = false;
|
||||||
printf ("\x1b[0;26H");
|
while (currentSize > 0) {
|
||||||
// Print time
|
if (showGameCardMsgAgain) {
|
||||||
printf (" %s" ,RetTime().c_str());
|
printf ("\x1b[8;0H");
|
||||||
|
printf (" \n");
|
||||||
|
|
||||||
consoleSelect(&bottomConsole);
|
printf ("\x1b[15;0H");
|
||||||
printf ("\x1B[47m"); // Print foreground white color
|
printf("Please switch to the\ngame card, then press A.\n");
|
||||||
printf ("\x1b[8;0H");
|
//flashcardUnmount();
|
||||||
printf ("Progress:\n");
|
io_dldi_data->ioInterface.shutdown();
|
||||||
printf ("%i/%i Bytes ", (int)src, (int)romSize);
|
|
||||||
cardRead (src, romBuffer);
|
consoleSelect(&topConsole);
|
||||||
fwrite(romBuffer, 1, 0x200, destinationFile);
|
printf ("\x1B[30m"); // Print black color
|
||||||
|
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||||
|
do {
|
||||||
|
// Move to right side of screen
|
||||||
|
printf ("\x1b[0;26H");
|
||||||
|
// Print time
|
||||||
|
printf (" %s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
scanKeys();
|
||||||
|
pressed = keysDownRepeat();
|
||||||
|
swiWaitForVBlank();
|
||||||
|
} while (!(pressed & KEY_A));
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1b[15;0H");
|
||||||
|
printf(" \n \n");
|
||||||
|
cardInit(&ndsCardHeader);
|
||||||
|
}
|
||||||
|
showGameCardMsgAgain = true;
|
||||||
|
|
||||||
|
// Read from game card
|
||||||
|
for (src = src; src < currentSize; src += 0x200) {
|
||||||
|
consoleSelect(&topConsole);
|
||||||
|
printf ("\x1B[30m"); // Print black color
|
||||||
|
// Move to right side of screen
|
||||||
|
printf ("\x1b[0;26H");
|
||||||
|
// Print time
|
||||||
|
printf (" %s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1B[47m"); // Print foreground white color
|
||||||
|
printf ("\x1b[8;0H");
|
||||||
|
printf ("Read:\n");
|
||||||
|
printf ("%i/%i Bytes ", (int)src, (int)romSize);
|
||||||
|
cardRead (src, (void*)0x09000000+(src % 0x800000));
|
||||||
|
}
|
||||||
|
printf ("\x1b[15;0H");
|
||||||
|
printf("Please switch to the\nflashcard, then press A.\n");
|
||||||
|
consoleSelect(&topConsole);
|
||||||
|
printf ("\x1B[30m"); // Print black color
|
||||||
|
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
|
||||||
|
do {
|
||||||
|
// Move to right side of screen
|
||||||
|
printf ("\x1b[0;26H");
|
||||||
|
// Print time
|
||||||
|
printf (" %s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
scanKeys();
|
||||||
|
pressed = keysDownRepeat();
|
||||||
|
swiWaitForVBlank();
|
||||||
|
} while (!(pressed & KEY_A));
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1b[15;0H");
|
||||||
|
printf(" \n \n");
|
||||||
|
|
||||||
|
printf ("\x1B[47m"); // Print foreground white color
|
||||||
|
printf ("\x1b[11;0H");
|
||||||
|
printf ("Written:\n");
|
||||||
|
|
||||||
|
// Write back to flashcard
|
||||||
|
cardInit(&ndsCardHeader);
|
||||||
|
io_dldi_data->ioInterface.startup();
|
||||||
|
//flashcardMounted = flashcardMount();
|
||||||
|
if (!destinationFileOpened) {
|
||||||
|
destinationFile = fopen(destPath, "wb");
|
||||||
|
destinationFileOpened = true;
|
||||||
|
}
|
||||||
|
for (writeSrc = writeSrc; writeSrc < currentSize; writeSrc += 0x200) {
|
||||||
|
consoleSelect(&topConsole);
|
||||||
|
printf ("\x1B[30m"); // Print black color
|
||||||
|
// Move to right side of screen
|
||||||
|
printf ("\x1b[0;26H");
|
||||||
|
// Print time
|
||||||
|
printf (" %s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1B[47m"); // Print foreground white color
|
||||||
|
printf ("\x1b[12;0H");
|
||||||
|
printf ("%i/%i Bytes ", (int)writeSrc, (int)romSize);
|
||||||
|
fwrite((void*)0x09000000+(writeSrc % 0x800000), 1, currentSize, destinationFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSize -= 0x800000;
|
||||||
|
}
|
||||||
|
fclose(destinationFile);
|
||||||
|
} else {
|
||||||
|
remove(destPath);
|
||||||
|
FILE* destinationFile = fopen(destPath, "wb");
|
||||||
|
for (u32 src = 0; src < romSize; src += 0x200) {
|
||||||
|
consoleSelect(&topConsole);
|
||||||
|
printf ("\x1B[30m"); // Print black color
|
||||||
|
// Move to right side of screen
|
||||||
|
printf ("\x1b[0;26H");
|
||||||
|
// Print time
|
||||||
|
printf (" %s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1B[47m"); // Print foreground white color
|
||||||
|
printf ("\x1b[8;0H");
|
||||||
|
printf ("Progress:\n");
|
||||||
|
printf ("%i/%i Bytes", (int)src, (int)romSize);
|
||||||
|
cardRead (src, romBuffer);
|
||||||
|
fwrite(romBuffer, 1, 0x200, destinationFile);
|
||||||
|
}
|
||||||
|
fclose(destinationFile);
|
||||||
|
ndsCardSaveDump(destSavPath);
|
||||||
}
|
}
|
||||||
fclose(destinationFile);
|
|
||||||
ndsCardSaveDump(destSavPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,19 +358,25 @@ void gbaCartDump(void) {
|
|||||||
char gbaHeaderGameTitle[13] = "\0";
|
char gbaHeaderGameTitle[13] = "\0";
|
||||||
char gbaHeaderGameCode[5] = "\0";
|
char gbaHeaderGameCode[5] = "\0";
|
||||||
char gbaHeaderMakerCode[3] = "\0";
|
char gbaHeaderMakerCode[3] = "\0";
|
||||||
for (int i = 0; i < 12; i++) {
|
if (*(u8*)(0x080000A0) == 0 || *(u8*)(0x080000A0) == 0xFF) {
|
||||||
|
sprintf(gbaHeaderGameTitle, "NO-TITLE");
|
||||||
|
} else for (int i = 0; i < 12; i++) {
|
||||||
gbaHeaderGameTitle[i] = *(char*)(0x080000A0+i);
|
gbaHeaderGameTitle[i] = *(char*)(0x080000A0+i);
|
||||||
if (*(u8*)(0x080000A0+i) == 0) {
|
if (*(u8*)(0x080000A0+i) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++) {
|
if (*(u8*)(0x080000AC) == 0 || *(u8*)(0x080000AC) == 0xFF) {
|
||||||
|
sprintf(gbaHeaderGameCode, "NONE");
|
||||||
|
} else for (int i = 0; i < 4; i++) {
|
||||||
gbaHeaderGameCode[i] = *(char*)(0x080000AC+i);
|
gbaHeaderGameCode[i] = *(char*)(0x080000AC+i);
|
||||||
if (*(u8*)(0x080000AC+i) == 0) {
|
if (*(u8*)(0x080000AC+i) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 2; i++) {
|
if (*(u8*)(0x080000B0) == 0 || *(u8*)(0x080000B0) == 0xFF) {
|
||||||
|
sprintf(gbaHeaderMakerCode, "00");
|
||||||
|
} else for (int i = 0; i < 2; i++) {
|
||||||
gbaHeaderMakerCode[i] = *(char*)(0x080000B0+i);
|
gbaHeaderMakerCode[i] = *(char*)(0x080000B0+i);
|
||||||
}
|
}
|
||||||
u8 gbaHeaderSoftwareVersion = *(u8*)(0x080000BC);
|
u8 gbaHeaderSoftwareVersion = *(u8*)(0x080000BC);
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
------------------------------------------------------------------*/
|
------------------------------------------------------------------*/
|
||||||
#include <nds.h>
|
#include <nds.h>
|
||||||
|
#include <nds/arm9/dldi.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -44,6 +45,7 @@ bool appInited = false;
|
|||||||
|
|
||||||
bool arm7SCFGLocked = false;
|
bool arm7SCFGLocked = false;
|
||||||
bool isRegularDS = true;
|
bool isRegularDS = true;
|
||||||
|
bool expansionPakFound = false;
|
||||||
bool is3DS = false;
|
bool is3DS = false;
|
||||||
|
|
||||||
bool applaunch = false;
|
bool applaunch = false;
|
||||||
@ -204,7 +206,10 @@ int main(int argc, char **argv) {
|
|||||||
ramdrive2Mount();
|
ramdrive2Mount();
|
||||||
}
|
}
|
||||||
is3DS = ((access("sd:/Nintendo 3DS", F_OK) == 0) && (*(vu32*)(0x0DFFFE0C) == 0x474D3969));
|
is3DS = ((access("sd:/Nintendo 3DS", F_OK) == 0) && (*(vu32*)(0x0DFFFE0C) == 0x474D3969));
|
||||||
}
|
} /*else if (isRegularDS) {
|
||||||
|
*(vu32*)(0x08240000) = 1;
|
||||||
|
expansionPakFound = ((*(vu32*)(0x08240000) == 1) && (io_dldi_data->ioInterface.features & FEATURE_SLOT_NDS));
|
||||||
|
}*/
|
||||||
if (!isDSiMode() || !yHeld) {
|
if (!isDSiMode() || !yHeld) {
|
||||||
flashcardMounted = flashcardMount();
|
flashcardMounted = flashcardMount();
|
||||||
flashcardMountSkipped = false;
|
flashcardMountSkipped = false;
|
||||||
|
|||||||
@ -175,8 +175,15 @@ static void switchToTwlBlowfish(sNDSHeaderExt* ndsHeader) {
|
|||||||
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
|
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
|
REG_ROMCTRL=0;
|
||||||
|
REG_AUXSPICNT=0;
|
||||||
|
//ioDelay2(167550);
|
||||||
|
for(i = 0; i < 25; i++) { swiWaitForVBlank(); }
|
||||||
|
REG_AUXSPICNT=CARD_CR1_ENABLE|CARD_CR1_IRQ;
|
||||||
|
REG_ROMCTRL=CARD_nRESET|CARD_SEC_SEED;
|
||||||
|
while(REG_ROMCTRL&CARD_BUSY) ;
|
||||||
cardReset();
|
cardReset();
|
||||||
while(REG_ROMCTRL & CARD_BUSY);
|
while(REG_ROMCTRL&CARD_BUSY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//int iCardDevice = 1;
|
//int iCardDevice = 1;
|
||||||
@ -289,6 +296,16 @@ int cardInit (sNDSHeaderExt* ndsHeader)
|
|||||||
cardParamCommand (CARD_CMD_DUMMY, 0,
|
cardParamCommand (CARD_CMD_DUMMY, 0,
|
||||||
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
|
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
} else {
|
||||||
|
REG_ROMCTRL=0;
|
||||||
|
REG_AUXSPICNT=0;
|
||||||
|
//ioDelay2(167550);
|
||||||
|
for(i = 0; i < 25; i++) { swiWaitForVBlank(); }
|
||||||
|
REG_AUXSPICNT=CARD_CR1_ENABLE|CARD_CR1_IRQ;
|
||||||
|
REG_ROMCTRL=CARD_nRESET|CARD_SEC_SEED;
|
||||||
|
while(REG_ROMCTRL&CARD_BUSY) ;
|
||||||
|
cardReset();
|
||||||
|
while(REG_ROMCTRL&CARD_BUSY) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
toncset(headerData, 0, 0x1000);
|
toncset(headerData, 0, 0x1000);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user