mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Make GBA RTC dumping optional (#218)
This commit is contained in:
parent
d588ac07a4
commit
a67d157bc1
@ -34,8 +34,10 @@ enum DumpOption {
|
|||||||
save = 4,
|
save = 4,
|
||||||
metadata = 8,
|
metadata = 8,
|
||||||
ndsSave = 16,
|
ndsSave = 16,
|
||||||
|
saveNoRtc = 32,
|
||||||
all = rom | save | metadata,
|
all = rom | save | metadata,
|
||||||
allTrimmed = romTrimmed | save | metadata
|
allTrimmed = romTrimmed | save | metadata,
|
||||||
|
allNoRtc = rom | saveNoRtc | metadata
|
||||||
};
|
};
|
||||||
|
|
||||||
DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName) {
|
DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName) {
|
||||||
@ -65,6 +67,9 @@ DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName
|
|||||||
case DumpOption::allTrimmed:
|
case DumpOption::allTrimmed:
|
||||||
font->print(optionsCol, row++, false, STR_DUMP_ALL_TRIMMED, alignStart);
|
font->print(optionsCol, row++, false, STR_DUMP_ALL_TRIMMED, alignStart);
|
||||||
break;
|
break;
|
||||||
|
case DumpOption::allNoRtc:
|
||||||
|
font->print(optionsCol, row++, false, STR_DUMP_ALL_NO_RTC, alignStart);
|
||||||
|
break;
|
||||||
case DumpOption::rom:
|
case DumpOption::rom:
|
||||||
font->print(optionsCol, row++, false, STR_DUMP_ROM, alignStart);
|
font->print(optionsCol, row++, false, STR_DUMP_ROM, alignStart);
|
||||||
break;
|
break;
|
||||||
@ -77,6 +82,9 @@ DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName
|
|||||||
case DumpOption::ndsSave:
|
case DumpOption::ndsSave:
|
||||||
font->print(optionsCol, row++, false, STR_DUMP_DS_SAVE, alignStart);
|
font->print(optionsCol, row++, false, STR_DUMP_DS_SAVE, alignStart);
|
||||||
break;
|
break;
|
||||||
|
case DumpOption::saveNoRtc:
|
||||||
|
font->print(optionsCol, row++, false, STR_DUMP_SAVE_NO_RTC, alignStart);
|
||||||
|
break;
|
||||||
case DumpOption::metadata:
|
case DumpOption::metadata:
|
||||||
font->print(optionsCol, row++, false, STR_DUMP_METADATA, alignStart);
|
font->print(optionsCol, row++, false, STR_DUMP_METADATA, alignStart);
|
||||||
break;
|
break;
|
||||||
@ -961,7 +969,7 @@ void ndsCardDump(void) {
|
|||||||
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gbaCartSaveDump(const char *filename) {
|
void gbaCartSaveDump(const char *filename, bool includeRtc) {
|
||||||
font->clear(false);
|
font->clear(false);
|
||||||
font->print(firstCol, 0, false, STR_DUMPING_SAVE, alignStart);
|
font->print(firstCol, 0, false, STR_DUMPING_SAVE, alignStart);
|
||||||
font->print(firstCol, 1, false, STR_DO_NOT_REMOVE_CART, alignStart);
|
font->print(firstCol, 1, false, STR_DO_NOT_REMOVE_CART, alignStart);
|
||||||
@ -978,11 +986,13 @@ void gbaCartSaveDump(const char *filename) {
|
|||||||
FILE *destinationFile = fopen(filename, "wb");
|
FILE *destinationFile = fopen(filename, "wb");
|
||||||
fwrite(buffer, 1, size, destinationFile);
|
fwrite(buffer, 1, size, destinationFile);
|
||||||
|
|
||||||
u8 cartRtc[RTC_SIZE];
|
if(includeRtc) {
|
||||||
if (gbaGetRtc(cartRtc)) {
|
u8 cartRtc[RTC_SIZE];
|
||||||
fwrite(cartRtc, 1, RTC_SIZE, destinationFile);
|
if (gbaGetRtc(cartRtc)) {
|
||||||
u64 systime = time(nullptr);
|
fwrite(cartRtc, 1, RTC_SIZE, destinationFile);
|
||||||
fwrite(&systime, 1, 8, destinationFile);
|
u64 systime = time(nullptr);
|
||||||
|
fwrite(&systime, 1, 8, destinationFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(destinationFile);
|
fclose(destinationFile);
|
||||||
@ -1068,16 +1078,26 @@ void gbaCartDump(void) {
|
|||||||
font->print(firstCol, 0, false, STR_LOADING, alignStart);
|
font->print(firstCol, 0, false, STR_LOADING, alignStart);
|
||||||
font->update(false);
|
font->update(false);
|
||||||
|
|
||||||
std::vector allowedOptions = {DumpOption::all, DumpOption::rom};
|
std::vector allowedOptions = {DumpOption::all};
|
||||||
u8 allowedBitfield = DumpOption::rom | DumpOption::metadata;
|
u8 allowedBitfield = DumpOption::rom | DumpOption::metadata;
|
||||||
char gameTitle[13] = {0};
|
char gameTitle[13] = {0};
|
||||||
char gameCode[7] = {0};
|
char gameCode[7] = {0};
|
||||||
char fileName[32] = {0};
|
char fileName[32] = {0};
|
||||||
saveTypeGBA saveType = gbaGetSaveType();
|
saveTypeGBA saveType = gbaGetSaveType();
|
||||||
|
|
||||||
|
u8 cartRtc[RTC_SIZE];
|
||||||
|
bool hasRtc = gbaGetRtc(cartRtc);
|
||||||
|
|
||||||
if(saveType != saveTypeGBA::SAVE_GBA_NONE) {
|
if(saveType != saveTypeGBA::SAVE_GBA_NONE) {
|
||||||
|
if(hasRtc)
|
||||||
|
allowedOptions.push_back(DumpOption::allNoRtc);
|
||||||
|
allowedOptions.push_back(DumpOption::rom);
|
||||||
allowedOptions.push_back(DumpOption::save);
|
allowedOptions.push_back(DumpOption::save);
|
||||||
allowedBitfield |= DumpOption::save;
|
allowedBitfield |= DumpOption::save;
|
||||||
|
if(hasRtc) {
|
||||||
|
allowedOptions.push_back(DumpOption::saveNoRtc);
|
||||||
|
allowedBitfield |= DumpOption::saveNoRtc;
|
||||||
|
}
|
||||||
|
|
||||||
u32 size = gbaGetSaveSize(saveType);
|
u32 size = gbaGetSaveSize(saveType);
|
||||||
u8 *buffer = new u8[size];
|
u8 *buffer = new u8[size];
|
||||||
@ -1087,7 +1107,10 @@ void gbaCartDump(void) {
|
|||||||
allowedBitfield |= DumpOption::ndsSave;
|
allowedBitfield |= DumpOption::ndsSave;
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
} else {
|
||||||
|
allowedOptions.push_back(DumpOption::rom);
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedOptions.push_back(DumpOption::metadata);
|
allowedOptions.push_back(DumpOption::metadata);
|
||||||
|
|
||||||
// Get name
|
// Get name
|
||||||
@ -1235,10 +1258,10 @@ void gbaCartDump(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dump save
|
// Dump save
|
||||||
if((dumpOption & allowedBitfield) & DumpOption::save) {
|
if((dumpOption & allowedBitfield) & (DumpOption::save | DumpOption::saveNoRtc)) {
|
||||||
char destPath[256];
|
char destPath[256];
|
||||||
sprintf(destPath, "fat:/gm9i/out/%s.sav", fileName);
|
sprintf(destPath, "fat:/gm9i/out/%s.sav", fileName);
|
||||||
gbaCartSaveDump(destPath);
|
gbaCartSaveDump(destPath, (dumpOption & allowedBitfield) & DumpOption::save);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump NDS save previously saved to this cart
|
// Dump NDS save previously saved to this cart
|
||||||
|
|||||||
@ -139,10 +139,12 @@ STRING(DUMP_TO, "Dump \"%s\" to\n\"%s:/gm9i/out\"?")
|
|||||||
STRING(DUMP_TO_GBA, "Dump \"%s\" to GBA cart?")
|
STRING(DUMP_TO_GBA, "Dump \"%s\" to GBA cart?")
|
||||||
STRING(DUMP_ALL, "All")
|
STRING(DUMP_ALL, "All")
|
||||||
STRING(DUMP_ALL_TRIMMED, "All (Trimmed ROM)")
|
STRING(DUMP_ALL_TRIMMED, "All (Trimmed ROM)")
|
||||||
|
STRING(DUMP_ALL_NO_RTC, "All (No RTC)")
|
||||||
STRING(DUMP_ROM, "ROM")
|
STRING(DUMP_ROM, "ROM")
|
||||||
STRING(DUMP_ROM_TRIMMED, "ROM (Trimmed)")
|
STRING(DUMP_ROM_TRIMMED, "ROM (Trimmed)")
|
||||||
STRING(DUMP_SAVE, "Save")
|
STRING(DUMP_SAVE, "Save")
|
||||||
STRING(DUMP_DS_SAVE, "DS save")
|
STRING(DUMP_DS_SAVE, "DS save")
|
||||||
|
STRING(DUMP_SAVE_NO_RTC, "Save (No RTC)")
|
||||||
STRING(DUMP_PUBLIC_SAVE, "Public save")
|
STRING(DUMP_PUBLIC_SAVE, "Public save")
|
||||||
STRING(DUMP_PRIVATE_SAVE, "Private save")
|
STRING(DUMP_PRIVATE_SAVE, "Private save")
|
||||||
STRING(DUMP_BANNER_SAVE, "Banner save")
|
STRING(DUMP_BANNER_SAVE, "Banner save")
|
||||||
|
|||||||
@ -134,10 +134,12 @@ DUMP_TO=Dump "%s" to\n"%s:/gm9i/out"?
|
|||||||
DUMP_TO_GBA=Dump "%s" to GBA cart?
|
DUMP_TO_GBA=Dump "%s" to GBA cart?
|
||||||
DUMP_ALL=All
|
DUMP_ALL=All
|
||||||
DUMP_ALL_TRIMMED=All (Trimmed ROM)
|
DUMP_ALL_TRIMMED=All (Trimmed ROM)
|
||||||
|
DUMP_ALL_NO_RTC=All (No RTC)
|
||||||
DUMP_ROM=ROM
|
DUMP_ROM=ROM
|
||||||
DUMP_ROM_TRIMMED=ROM (Trimmed)
|
DUMP_ROM_TRIMMED=ROM (Trimmed)
|
||||||
DUMP_SAVE=Save
|
DUMP_SAVE=Save
|
||||||
DUMP_DS_SAVE=DS save
|
DUMP_DS_SAVE=DS save
|
||||||
|
DUMP_SAVE_NO_RTC=Save (No RTC)
|
||||||
DUMP_PUBLIC_SAVE=Public save
|
DUMP_PUBLIC_SAVE=Public save
|
||||||
DUMP_PRIVATE_SAVE=Private save
|
DUMP_PRIVATE_SAVE=Private save
|
||||||
DUMP_BANNER_SAVE=Banner save
|
DUMP_BANNER_SAVE=Banner save
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user