mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Bug fixes
This commit is contained in:
parent
5b3b31f743
commit
9b4876a8e4
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
extern PrintConsole topConsole, bottomConsole;
|
extern PrintConsole topConsole, bottomConsole;
|
||||||
|
|
||||||
|
static sNDSHeaderExt ndsCardHeader;
|
||||||
|
|
||||||
void ndsCardSaveDump(const char* filename) {
|
void ndsCardSaveDump(const char* filename) {
|
||||||
std::ofstream output(filename, std::ofstream::binary);
|
std::ofstream output(filename, std::ofstream::binary);
|
||||||
if(output.is_open()) {
|
if(output.is_open()) {
|
||||||
@ -88,9 +90,7 @@ void ndsCardDump(void) {
|
|||||||
mkdir(folderPath[1], 0777);
|
mkdir(folderPath[1], 0777);
|
||||||
}
|
}
|
||||||
consoleClear();
|
consoleClear();
|
||||||
// Read header
|
if (cardInit(&ndsCardHeader) == 0) {
|
||||||
sNDSHeaderExt* ndsCardHeader = (sNDSHeaderExt*)malloc(0x1000);
|
|
||||||
if (cardInit (ndsCardHeader) == 0) {
|
|
||||||
printf("Dumping...\n");
|
printf("Dumping...\n");
|
||||||
printf("Do not remove the NDS card.\n");
|
printf("Do not remove the NDS card.\n");
|
||||||
} else {
|
} else {
|
||||||
@ -98,25 +98,24 @@ void ndsCardDump(void) {
|
|||||||
for (int i = 0; i < 60*2; i++) {
|
for (int i = 0; i < 60*2; i++) {
|
||||||
swiWaitForVBlank();
|
swiWaitForVBlank();
|
||||||
}
|
}
|
||||||
free(ndsCardHeader);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char gameTitle[13] = {0};
|
char gameTitle[13] = {0};
|
||||||
tonccpy(gameTitle, ndsCardHeader->gameTitle, 12);
|
tonccpy(gameTitle, ndsCardHeader.gameTitle, 12);
|
||||||
char gameCode[7] = {0};
|
char gameCode[7] = {0};
|
||||||
tonccpy(gameCode, ndsCardHeader->gameCode, 6);
|
tonccpy(gameCode, ndsCardHeader.gameCode, 6);
|
||||||
bool trimRom = (pressed & KEY_Y);
|
bool trimRom = (pressed & KEY_Y);
|
||||||
char romBuffer[0x200];
|
char romBuffer[0x200];
|
||||||
char destPath[256];
|
char destPath[256];
|
||||||
sprintf(destPath, "%s:/gm9i/out/%s_%s_%x%s.nds", (sdMounted ? "sd" : "fat"), gameTitle, gameCode, ndsCardHeader->romversion, (trimRom ? "_trim" : ""));
|
sprintf(destPath, "%s:/gm9i/out/%s_%s_%x%s.nds", (sdMounted ? "sd" : "fat"), gameTitle, gameCode, ndsCardHeader.romversion, (trimRom ? "_trim" : ""));
|
||||||
char destSavPath[256];
|
char destSavPath[256];
|
||||||
sprintf(destSavPath, "%s:/gm9i/out/%s_%s_%x%s.sav", (sdMounted ? "sd" : "fat"), gameTitle, gameCode, ndsCardHeader->romversion, (trimRom ? "_trim" : ""));
|
sprintf(destSavPath, "%s:/gm9i/out/%s_%s_%x%s.sav", (sdMounted ? "sd" : "fat"), gameTitle, gameCode, ndsCardHeader.romversion, (trimRom ? "_trim" : ""));
|
||||||
// Determine ROM size
|
// Determine ROM size
|
||||||
u32 romSize = 0;
|
u32 romSize = 0;
|
||||||
if (trimRom) {
|
if (trimRom) {
|
||||||
romSize = ((ndsCardHeader->unitCode != 0) && (ndsCardHeader->twlRomSize > 0))
|
romSize = ((ndsCardHeader.unitCode != 0) && (ndsCardHeader.twlRomSize > 0))
|
||||||
? ndsCardHeader->twlRomSize : ndsCardHeader->romSize;
|
? ndsCardHeader.twlRomSize : ndsCardHeader.romSize;
|
||||||
} else switch (ndsCardHeader->deviceSize) {
|
} else switch (ndsCardHeader.deviceSize) {
|
||||||
case 0x00:
|
case 0x00:
|
||||||
romSize = 0x20000;
|
romSize = 0x20000;
|
||||||
break;
|
break;
|
||||||
@ -168,6 +167,8 @@ void ndsCardDump(void) {
|
|||||||
// Print time
|
// Print time
|
||||||
printf ("_%s" ,RetTime().c_str());
|
printf ("_%s" ,RetTime().c_str());
|
||||||
|
|
||||||
|
consoleSelect(&bottomConsole);
|
||||||
|
printf ("\x1B[47m"); // Print foreground white color
|
||||||
printf ("\x1b[8;0H");
|
printf ("\x1b[8;0H");
|
||||||
printf ("Progress:\n");
|
printf ("Progress:\n");
|
||||||
printf ("%i/%i Bytes ", (int)src, (int)romSize);
|
printf ("%i/%i Bytes ", (int)src, (int)romSize);
|
||||||
@ -176,7 +177,6 @@ void ndsCardDump(void) {
|
|||||||
}
|
}
|
||||||
fclose(destinationFile);
|
fclose(destinationFile);
|
||||||
ndsCardSaveDump(destSavPath);
|
ndsCardSaveDump(destSavPath);
|
||||||
free(ndsCardHeader);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -590,6 +590,9 @@ string browseForFile (void) {
|
|||||||
|
|
||||||
// Rename file/folder
|
// Rename file/folder
|
||||||
if ((held & KEY_R) && (pressed & KEY_X) && (strcmp (entry->name.c_str(), "..") != 0) && (strncmp (path, "nitro:/", 7) != 0)) {
|
if ((held & KEY_R) && (pressed & KEY_X) && (strcmp (entry->name.c_str(), "..") != 0) && (strncmp (path, "nitro:/", 7) != 0)) {
|
||||||
|
printf ("\x1b[0;27H");
|
||||||
|
printf ("\x1B[42m"); // Print green color
|
||||||
|
printf ("_____"); // Clear time
|
||||||
pressed = 0;
|
pressed = 0;
|
||||||
consoleDemoInit();
|
consoleDemoInit();
|
||||||
Keyboard *kbd = keyboardDemoInit();
|
Keyboard *kbd = keyboardDemoInit();
|
||||||
@ -698,6 +701,9 @@ string browseForFile (void) {
|
|||||||
|
|
||||||
// Create new folder
|
// Create new folder
|
||||||
if ((held & KEY_R) && (pressed & KEY_Y) && (strncmp (path, "nitro:/", 7) != 0)) {
|
if ((held & KEY_R) && (pressed & KEY_Y) && (strncmp (path, "nitro:/", 7) != 0)) {
|
||||||
|
printf ("\x1b[0;27H");
|
||||||
|
printf ("\x1B[42m"); // Print green color
|
||||||
|
printf ("_____"); // Clear time
|
||||||
pressed = 0;
|
pressed = 0;
|
||||||
consoleDemoInit();
|
consoleDemoInit();
|
||||||
Keyboard *kbd = keyboardDemoInit();
|
Keyboard *kbd = keyboardDemoInit();
|
||||||
|
|||||||
@ -291,6 +291,8 @@ int cardInit (sNDSHeaderExt* ndsHeader)
|
|||||||
NULL, 0);
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toncset(headerData, 0, 0x1000);
|
||||||
|
|
||||||
u32 iCardId=cardReadID(CARD_CLK_SLOW);
|
u32 iCardId=cardReadID(CARD_CLK_SLOW);
|
||||||
while(REG_ROMCTRL & CARD_BUSY);
|
while(REG_ROMCTRL & CARD_BUSY);
|
||||||
//u32 iCheapCard=iCardId&0x80000000;
|
//u32 iCheapCard=iCardId&0x80000000;
|
||||||
@ -298,19 +300,22 @@ int cardInit (sNDSHeaderExt* ndsHeader)
|
|||||||
// Read the header
|
// Read the header
|
||||||
cardParamCommand (CARD_CMD_HEADER_READ, 0,
|
cardParamCommand (CARD_CMD_HEADER_READ, 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),
|
||||||
(void*)ndsHeader, 0x200/sizeof(u32));
|
(void*)headerData, 0x200/sizeof(u32));
|
||||||
|
|
||||||
|
tonccpy(ndsHeader, headerData, 0x200);
|
||||||
|
|
||||||
if ((ndsHeader->unitCode != 0) || (ndsHeader->dsi_flags != 0))
|
if ((ndsHeader->unitCode != 0) || (ndsHeader->dsi_flags != 0))
|
||||||
{
|
{
|
||||||
// Extended header found
|
// Extended header found
|
||||||
cardParamCommand (CARD_CMD_HEADER_READ, 0,
|
cardParamCommand (CARD_CMD_HEADER_READ, 0,
|
||||||
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(4) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
|
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(4) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
|
||||||
(void*)ndsHeader, 0x1000/sizeof(u32));
|
(void*)headerData, 0x1000/sizeof(u32));
|
||||||
if (ndsHeader->dsi1[0]==0xFFFFFFFF && ndsHeader->dsi1[1]==0xFFFFFFFF
|
if (ndsHeader->dsi1[0]==0xFFFFFFFF && ndsHeader->dsi1[1]==0xFFFFFFFF
|
||||||
&& ndsHeader->dsi1[2]==0xFFFFFFFF && ndsHeader->dsi1[3]==0xFFFFFFFF)
|
&& ndsHeader->dsi1[2]==0xFFFFFFFF && ndsHeader->dsi1[3]==0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
toncset((u8*)ndsHeader+0x200, 0, 0xE00);
|
toncset((u8*)headerData+0x200, 0, 0xE00); // Clear out FFs
|
||||||
}
|
}
|
||||||
|
tonccpy(ndsHeader, headerData, sizeof(sNDSHeaderExt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check header CRC
|
// Check header CRC
|
||||||
@ -318,8 +323,6 @@ int cardInit (sNDSHeaderExt* ndsHeader)
|
|||||||
return ERR_HEAD_CRC;
|
return ERR_HEAD_CRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
tonccpy(headerData, ndsHeader, 0x1000);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Check logo CRC
|
// Check logo CRC
|
||||||
if (ndsHeader->logoCRC16 != 0xCF56) {
|
if (ndsHeader->logoCRC16 != 0xCF56) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user