mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-10 23:15:08 +01:00
Add CRC32 and filenames to SNES database
This commit is contained in:
parent
311822f3c7
commit
44d853e1bb
@ -4,7 +4,7 @@
|
||||
This project represents a community-driven effort to provide
|
||||
an easy to build and easy to modify cartridge dumper.
|
||||
|
||||
Date: 20.06.2022
|
||||
Date: 21.06.2022
|
||||
Version: 8.5 BETA
|
||||
|
||||
SD lib: https://github.com/greiman/SdFat
|
||||
@ -370,6 +370,9 @@ inline uint32_t updateCRC(uint8_t ch, uint32_t crc) {
|
||||
|
||||
// Calculate rom's CRC32 from SD
|
||||
uint32_t calculateCRC(char* fileName, char* folder) {
|
||||
// Open folder
|
||||
sd.chdir(folder);
|
||||
// Open file
|
||||
if (myFile.open(fileName, O_READ)) {
|
||||
uint32_t oldcrc32 = 0xFFFFFFFF;
|
||||
|
||||
@ -384,7 +387,12 @@ uint32_t calculateCRC(char* fileName, char* folder) {
|
||||
return ~oldcrc32;
|
||||
}
|
||||
else {
|
||||
print_Error(F("File not found"), true);
|
||||
display_Clear();
|
||||
print_Msg(F("File "));
|
||||
//print_Msg(folder);
|
||||
//print_Msg(F("/"));
|
||||
//print_Msg(fileName);
|
||||
print_Error(F(" not found"), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,7 +452,11 @@ boolean compareCRC(char* database, char* crcString) {
|
||||
#ifdef no-intro
|
||||
char crcStr[9];
|
||||
if (crcString == 0) {
|
||||
//go to root
|
||||
sd.chdir();
|
||||
// Calculate CRC32
|
||||
print_Msg(F("CRC32... "));
|
||||
display_Update();
|
||||
sprintf(crcStr, "%08lX", calculateCRC(fileName, folder));
|
||||
}
|
||||
else {
|
||||
@ -452,7 +464,6 @@ boolean compareCRC(char* database, char* crcString) {
|
||||
strcpy(crcStr, crcString);
|
||||
}
|
||||
// Print checksum
|
||||
print_Msg(F("CRC32: "));
|
||||
print_Msg(crcStr);
|
||||
display_Update();
|
||||
|
||||
|
@ -925,9 +925,6 @@ unsigned int calc_checksum_GB (char* fileName, char* folder) {
|
||||
|
||||
// Compare checksum
|
||||
void compare_checksums_GB() {
|
||||
println_Msg(F("Calculating Checksum..."));
|
||||
display_Update();
|
||||
|
||||
strcpy(fileName, romName);
|
||||
strcat(fileName, ".GB");
|
||||
|
||||
|
@ -130,8 +130,6 @@ void gbaMenu() {
|
||||
// Internal Checksum
|
||||
compare_checksum_GBA();
|
||||
// CRC32
|
||||
println_Msg(F("Calculating CRC checksum..."));
|
||||
display_Update();
|
||||
compareCRC("gba.txt", 0);
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
@ -501,7 +499,7 @@ void setup_GBA() {
|
||||
|
||||
// Get cart info
|
||||
display_Clear();
|
||||
println_Msg(F("Seaching database..."));
|
||||
println_Msg(F("Searching database..."));
|
||||
display_Update();
|
||||
getCartInfo_GBA();
|
||||
display_Clear();
|
||||
|
@ -1293,9 +1293,6 @@ void readROM_MD() {
|
||||
//println_Msg(F("s"));
|
||||
//display_Update();
|
||||
|
||||
println_Msg(F("Calculating checksum..."));
|
||||
display_Update();
|
||||
|
||||
// Calculate and compare CRC32 with no-intro
|
||||
compareCRC("md.txt", 0);
|
||||
|
||||
|
@ -3434,9 +3434,6 @@ redumpsamefolder:
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
|
||||
// Calculate Checksum and convert to string
|
||||
println_Msg(F("Calculating CRC.."));
|
||||
display_Update();
|
||||
if (compareCRC("n64.txt", 0)) {
|
||||
#else
|
||||
// dumping rom fast
|
||||
|
@ -215,12 +215,10 @@ void snesMenu() {
|
||||
unsigned long startTime = millis();
|
||||
// start reading from cart
|
||||
readROM_SNES();
|
||||
// Internal Checksum
|
||||
compare_checksum();
|
||||
|
||||
// print elapsed time
|
||||
print_Msg(F("Time elapsed: "));
|
||||
print_Msg((millis() - startTime) / 1000);
|
||||
println_Msg(F("s"));
|
||||
// CRC32
|
||||
compareCRC("snes.txt", 0);
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
@ -337,7 +335,7 @@ void snesMenu() {
|
||||
resetArduino();
|
||||
break;
|
||||
}
|
||||
println_Msg(F(""));
|
||||
//println_Msg(F(""));
|
||||
println_Msg(F("Press Button..."));
|
||||
display_Update();
|
||||
wait();
|
||||
@ -818,7 +816,18 @@ void checkAltConf() {
|
||||
altconf = 0;
|
||||
|
||||
if (myFile.open("snes.txt", O_READ)) {
|
||||
// Get cart info
|
||||
display_Clear();
|
||||
println_Msg(F("Searching database..."));
|
||||
display_Update();
|
||||
|
||||
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
|
||||
sprintf(tempStr1, "%c", myFile.read());
|
||||
strcpy(tempStr2, tempStr1);
|
||||
@ -836,24 +845,31 @@ void checkAltConf() {
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
|
||||
// Read file size
|
||||
romSize = (myFile.read() - 48) * 10 + (myFile.read() - 48);
|
||||
byte romSize2 = (myFile.read() - 48) * 10 + (myFile.read() - 48);
|
||||
|
||||
// Skip the , in the file
|
||||
myFile.seekSet(myFile.curPosition() + 1);
|
||||
|
||||
// Read number of banks
|
||||
numBanks = (myFile.read() - 48) * 100 + (myFile.read() - 48) * 10 + (myFile.read() - 48);
|
||||
byte numBanks2 = (myFile.read() - 48) * 100 + (myFile.read() - 48) * 10 + (myFile.read() - 48);
|
||||
|
||||
altconf = 1;
|
||||
if ((romSize != romSize2) || (numBanks != numBanks2)) {
|
||||
romSize = romSize2;
|
||||
numBanks = numBanks2;
|
||||
altconf = 1;
|
||||
}
|
||||
}
|
||||
// If no match empty string advance by 9 and try again
|
||||
else {
|
||||
myFile.seekSet(myFile.curPosition() + 9);
|
||||
// skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 7);
|
||||
// skip third empty line
|
||||
skip_line(&myFile);
|
||||
}
|
||||
}
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
}
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
}
|
||||
|
||||
// Read header
|
||||
@ -1163,8 +1179,7 @@ unsigned int calc_checksum (char* fileName, char* folder) {
|
||||
}
|
||||
|
||||
boolean compare_checksum() {
|
||||
|
||||
println_Msg(F("Calculating Checksum"));
|
||||
print_Msg(F("Internal Checksum..."));
|
||||
display_Update();
|
||||
|
||||
strcpy(fileName, romName);
|
||||
@ -1178,8 +1193,8 @@ boolean compare_checksum() {
|
||||
sprintf(calcsumStr, "%04X", calc_checksum(fileName, folder));
|
||||
|
||||
if (strcmp(calcsumStr, checksumStr) == 0) {
|
||||
print_Msg(F("Checksum OK: "));
|
||||
println_Msg(calcsumStr);
|
||||
println_Msg(F("OK"));
|
||||
//println_Msg(calcsumStr);
|
||||
display_Update();
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user