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);
|
||||
char gameCode[7] = {0};
|
||||
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);
|
||||
char destPath[256];
|
||||
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);
|
||||
u32 currentSize = romSize;
|
||||
FILE* destinationFile = fopen(destPath, "wb");
|
||||
if (destinationFile) {
|
||||
for (u32 src = 0; src < romSize; src += 0x8000) {
|
||||
consoleSelect(&topConsole);
|
||||
printf ("\x1B[30m"); // Print black color
|
||||
@ -461,6 +468,7 @@ void ndsCardDump(void) {
|
||||
currentSize -= 0x8000;
|
||||
}
|
||||
fclose(destinationFile);
|
||||
}
|
||||
ndsCardSaveDump(destSavPath);
|
||||
//}
|
||||
}
|
||||
@ -576,6 +584,7 @@ void gbaCartDump(void) {
|
||||
};
|
||||
writeChange(rstCmd);
|
||||
FILE* destinationFile = fopen(destPath, "wb");
|
||||
if (destinationFile) {
|
||||
fwrite(GBAROM, 1, romSize, destinationFile);
|
||||
// Check for 64MB GBA Video ROM
|
||||
if (strncmp((char*)0x080000AC, "MSAE", 4)==0 // Shark Tale
|
||||
@ -600,6 +609,7 @@ void gbaCartDump(void) {
|
||||
}
|
||||
}
|
||||
fclose(destinationFile);
|
||||
}
|
||||
// Save file
|
||||
remove(destSavPath);
|
||||
destinationFile = fopen(destSavPath, "wb");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user