mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Check if .nds (or .gba) file is created before dumping
This commit is contained in:
parent
ada2974435
commit
edd514aad5
@ -282,6 +282,12 @@ void ndsCardDump(void) {
|
|||||||
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);
|
||||||
|
if (gameTitle[0] == 0 || gameTitle[0] == 0x2E || gameTitle[0] == 0xFF) {
|
||||||
|
sprintf(gameTitle, "NO-TITLE");
|
||||||
|
}
|
||||||
|
if (gameCode[0] == 0 || gameCode[0] == 0x23 || gameCode[0] == 0xFF) {
|
||||||
|
sprintf(gameCode, "NONE00");
|
||||||
|
}
|
||||||
bool trimRom = (pressed & KEY_Y);
|
bool trimRom = (pressed & KEY_Y);
|
||||||
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" : ""));
|
||||||
@ -441,6 +447,7 @@ void ndsCardDump(void) {
|
|||||||
remove(destPath);
|
remove(destPath);
|
||||||
u32 currentSize = romSize;
|
u32 currentSize = romSize;
|
||||||
FILE* destinationFile = fopen(destPath, "wb");
|
FILE* destinationFile = fopen(destPath, "wb");
|
||||||
|
if (destinationFile) {
|
||||||
for (u32 src = 0; src < romSize; src += 0x8000) {
|
for (u32 src = 0; src < romSize; src += 0x8000) {
|
||||||
consoleSelect(&topConsole);
|
consoleSelect(&topConsole);
|
||||||
printf ("\x1B[30m"); // Print black color
|
printf ("\x1B[30m"); // Print black color
|
||||||
@ -461,6 +468,7 @@ void ndsCardDump(void) {
|
|||||||
currentSize -= 0x8000;
|
currentSize -= 0x8000;
|
||||||
}
|
}
|
||||||
fclose(destinationFile);
|
fclose(destinationFile);
|
||||||
|
}
|
||||||
ndsCardSaveDump(destSavPath);
|
ndsCardSaveDump(destSavPath);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@ -576,6 +584,7 @@ void gbaCartDump(void) {
|
|||||||
};
|
};
|
||||||
writeChange(rstCmd);
|
writeChange(rstCmd);
|
||||||
FILE* destinationFile = fopen(destPath, "wb");
|
FILE* destinationFile = fopen(destPath, "wb");
|
||||||
|
if (destinationFile) {
|
||||||
fwrite(GBAROM, 1, romSize, destinationFile);
|
fwrite(GBAROM, 1, romSize, destinationFile);
|
||||||
// Check for 64MB GBA Video ROM
|
// Check for 64MB GBA Video ROM
|
||||||
if (strncmp((char*)0x080000AC, "MSAE", 4)==0 // Shark Tale
|
if (strncmp((char*)0x080000AC, "MSAE", 4)==0 // Shark Tale
|
||||||
@ -600,6 +609,7 @@ void gbaCartDump(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(destinationFile);
|
fclose(destinationFile);
|
||||||
|
}
|
||||||
// Save file
|
// Save file
|
||||||
remove(destSavPath);
|
remove(destSavPath);
|
||||||
destinationFile = fopen(destSavPath, "wb");
|
destinationFile = fopen(destSavPath, "wb");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user