Add CRC32 and filenames to GBA database

This commit is contained in:
sanni 2022-06-20 22:36:53 +02:00
parent 386a940528
commit fe5264b8ba
3 changed files with 25 additions and 5 deletions

View File

@ -4,7 +4,7 @@
This project represents a community-driven effort to provide This project represents a community-driven effort to provide
an easy to build and easy to modify cartridge dumper. an easy to build and easy to modify cartridge dumper.
Date: 18.06.2022 Date: 20.06.2022
Version: 8.5 BETA Version: 8.5 BETA
SD lib: https://github.com/greiman/SdFat SD lib: https://github.com/greiman/SdFat

View File

@ -127,7 +127,12 @@ void gbaMenu() {
sd.chdir("/"); sd.chdir("/");
readROM_GBA(); readROM_GBA();
sd.chdir("/"); sd.chdir("/");
// Internal Checksum
compare_checksum_GBA(); compare_checksum_GBA();
// CRC32
println_Msg(F("Calculating CRC checksum..."));
display_Update();
compareCRC("gba.txt", 0);
#ifdef global_log #ifdef global_log
save_log(); save_log();
#endif #endif
@ -495,10 +500,14 @@ void gbaMenu() {
void setup_GBA() { void setup_GBA() {
setROM_GBA(); setROM_GBA();
// Print start page // Get cart info
display_Clear();
println_Msg(F("Seaching database..."));
display_Update();
getCartInfo_GBA(); getCartInfo_GBA();
display_Clear(); display_Clear();
// Print start page
print_Msg(F("Name: ")); print_Msg(F("Name: "));
println_Msg(romName); println_Msg(romName);
print_Msg(F("Cart ID: ")); print_Msg(F("Cart ID: "));
@ -544,6 +553,7 @@ void setup_GBA() {
println_Msg(romVersion); println_Msg(romVersion);
// Wait for user input // Wait for user input
println_Msg("");
println_Msg(F("Press Button...")); println_Msg(F("Press Button..."));
display_Update(); display_Update();
wait(); wait();
@ -788,6 +798,12 @@ void getCartInfo_GBA() {
if (myFile.open("gba.txt", O_READ)) { if (myFile.open("gba.txt", O_READ)) {
// Loop through file // Loop through file
while (myFile.available()) { while (myFile.available()) {
// Skip first line with name
skip_line(&myFile);
// Skip over the CRC checksum
myFile.seekSet(myFile.curPosition() + 9);
// Read 4 bytes into String, do it one at a time so byte order doesn't get mixed up // Read 4 bytes into String, do it one at a time so byte order doesn't get mixed up
sprintf(tempStr, "%c", myFile.read()); sprintf(tempStr, "%c", myFile.read());
for (byte i = 0; i < 3; i++) { for (byte i = 0; i < 3; i++) {
@ -818,7 +834,10 @@ void getCartInfo_GBA() {
} }
// If no match, empty string, advance by 7 and try again // If no match, empty string, advance by 7 and try again
else { else {
// skip rest of line
myFile.seekSet(myFile.curPosition() + 7); myFile.seekSet(myFile.curPosition() + 7);
// skip third empty line
skip_line(&myFile);
} }
} }
// Close the file: // Close the file:
@ -917,7 +936,7 @@ void readROM_GBA() {
// Calculate the checksum of the dumped rom // Calculate the checksum of the dumped rom
boolean compare_checksum_GBA () { boolean compare_checksum_GBA () {
println_Msg(F("Calculating Checksum")); print_Msg(F("Internal Checksum..."));
display_Update(); display_Update();
strcpy(fileName, romName); strcpy(fileName, romName);
@ -945,11 +964,12 @@ boolean compare_checksum_GBA () {
sprintf(calcChecksumStr, "%02X", calcChecksum); sprintf(calcChecksumStr, "%02X", calcChecksum);
if (strcmp(calcChecksumStr, checksumStr) == 0) { if (strcmp(calcChecksumStr, checksumStr) == 0) {
println_Msg(F("Checksum matches")); println_Msg(F("OK"));
display_Update(); display_Update();
return 1; return 1;
} }
else { else {
println_Msg("");
print_Msg(F("Result: ")); print_Msg(F("Result: "));
println_Msg(calcChecksumStr); println_Msg(calcChecksumStr);
print_Error(F("Checksum Error"), false); print_Error(F("Checksum Error"), false);