mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-23 21:19:16 +01:00
Add filenames to N64 database
This commit is contained in:
parent
8db79a434c
commit
196050257b
@ -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: 16.06.2022
|
Date: 18.06.2022
|
||||||
Version: 8.5 BETA
|
Version: 8.5 BETA
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
@ -389,16 +389,72 @@ uint32_t calculateCRC(char* fileName, char* folder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// no-intro database
|
// Functions for CRC32 database
|
||||||
//******************************************
|
//******************************************
|
||||||
void compareCRC(char* database) {
|
//Skip line
|
||||||
|
void skip_line(FsFile* readfile)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
char str_buf;
|
||||||
|
|
||||||
|
while (readfile->available())
|
||||||
|
{
|
||||||
|
//Read 1 byte from file
|
||||||
|
str_buf = readfile->read();
|
||||||
|
|
||||||
|
//if end of file or newline found, execute command
|
||||||
|
if (str_buf == '\r')
|
||||||
|
{
|
||||||
|
readfile->read(); //dispose \n because \r\n
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}//End while
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get line from file
|
||||||
|
void get_line(char* str_buf, FsFile* readfile, uint8_t maxi)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (readfile->available())
|
||||||
|
{
|
||||||
|
//If line size is more than maximum array, limit it.
|
||||||
|
if (i >= maxi)
|
||||||
|
{
|
||||||
|
i = maxi - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Read 1 byte from file
|
||||||
|
str_buf[i] = readfile->read();
|
||||||
|
|
||||||
|
//if end of file or newline found, execute command
|
||||||
|
if (str_buf[i] == '\r')
|
||||||
|
{
|
||||||
|
str_buf[i] = '\0';
|
||||||
|
readfile->read(); //dispose \n because \r\n
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}//End while
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate CRC32 if needed and compare it to CRC read from database
|
||||||
|
boolean compareCRC(char* database, char* crcString) {
|
||||||
#ifdef no-intro
|
#ifdef no-intro
|
||||||
// Calculate CRC32
|
|
||||||
char crcStr[9];
|
char crcStr[9];
|
||||||
sprintf(crcStr, "%08lX", calculateCRC(fileName, folder));
|
if (crcString == 0) {
|
||||||
|
// Calculate CRC32
|
||||||
|
sprintf(crcStr, "%08lX", calculateCRC(fileName, folder));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Use precalculated crc
|
||||||
|
strcpy(crcStr, crcString);
|
||||||
|
}
|
||||||
// Print checksum
|
// Print checksum
|
||||||
print_Msg(F("CRC32: "));
|
print_Msg(F("CRC32: "));
|
||||||
print_Msg(crcStr);
|
print_Msg(crcStr);
|
||||||
|
display_Update();
|
||||||
|
|
||||||
//Search for CRC32 in file
|
//Search for CRC32 in file
|
||||||
char gamename[100];
|
char gamename[100];
|
||||||
@ -430,16 +486,19 @@ void compareCRC(char* database) {
|
|||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strcmp(crc_search, crcStr) != 0)
|
if (strcmp(crc_search, crcStr) != 0)
|
||||||
{
|
{
|
||||||
println_Msg(F(" -> Not found"));
|
println_Msg(F(" -> Not found"));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println_Msg(F(" -> database file not found"));
|
println_Msg(F(" -> database file not found"));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
println_Msg("");
|
println_Msg("");
|
||||||
|
@ -952,7 +952,7 @@ void compare_checksums_GB() {
|
|||||||
println_Msg(calcsumStr);
|
println_Msg(calcsumStr);
|
||||||
print_Error(F("Checksum Error"), false);
|
print_Error(F("Checksum Error"), false);
|
||||||
}
|
}
|
||||||
compareCRC("gb.txt");
|
compareCRC("gb.txt", 0);
|
||||||
display_Update();
|
display_Update();
|
||||||
//go to root
|
//go to root
|
||||||
sd.chdir();
|
sd.chdir();
|
||||||
|
@ -1297,7 +1297,7 @@ void readROM_MD() {
|
|||||||
display_Update();
|
display_Update();
|
||||||
|
|
||||||
// Calculate and compare CRC32 with no-intro
|
// Calculate and compare CRC32 with no-intro
|
||||||
compareCRC("md.txt");
|
compareCRC("md.txt", 0);
|
||||||
|
|
||||||
// Calculate internal checksum
|
// Calculate internal checksum
|
||||||
if (chksum == calcCKS) {
|
if (chksum == calcCKS) {
|
||||||
|
@ -2223,8 +2223,8 @@ int strcicmp(char const * a, char const * b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// look-up the calculated crc in the file n64.txt on sd card
|
/* look-up the calculated crc in the file n64.txt on sd card
|
||||||
boolean searchCRC(char crcStr[9]) {
|
boolean searchCRC(char crcStr[9]) {
|
||||||
boolean result = 0;
|
boolean result = 0;
|
||||||
char tempStr2[2];
|
char tempStr2[2];
|
||||||
char tempStr1[9];
|
char tempStr1[9];
|
||||||
@ -2276,7 +2276,7 @@ boolean searchCRC(char crcStr[9]) {
|
|||||||
else {
|
else {
|
||||||
print_Error(F("n64.txt missing"), true);
|
print_Error(F("n64.txt missing"), true);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// look-up cart id in file n64.txt on sd card
|
// look-up cart id in file n64.txt on sd card
|
||||||
void getCartInfo_N64() {
|
void getCartInfo_N64() {
|
||||||
@ -2291,10 +2291,14 @@ void getCartInfo_N64() {
|
|||||||
idCart();
|
idCart();
|
||||||
|
|
||||||
if (myFile.open("n64.txt", O_READ)) {
|
if (myFile.open("n64.txt", O_READ)) {
|
||||||
// Skip over the first crc
|
|
||||||
myFile.seekSet(myFile.curPosition() + 9);
|
|
||||||
// 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++) {
|
||||||
@ -2322,10 +2326,16 @@ void getCartInfo_N64() {
|
|||||||
|
|
||||||
// Read the next ascii character and subtract 48 to convert to decimal
|
// Read the next ascii character and subtract 48 to convert to decimal
|
||||||
saveType = myFile.read() - 48;
|
saveType = myFile.read() - 48;
|
||||||
|
|
||||||
|
// End loop
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// If no match, empty string, advance by 16 and try again
|
// If no match skip to next entry
|
||||||
else {
|
else {
|
||||||
myFile.seekSet(myFile.curPosition() + 16);
|
// skip rest of line
|
||||||
|
myFile.seekSet(myFile.curPosition() + 7);
|
||||||
|
// skip third empty line
|
||||||
|
skip_line(&myFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
@ -3427,14 +3437,7 @@ redumpsamefolder:
|
|||||||
// Calculate Checksum and convert to string
|
// Calculate Checksum and convert to string
|
||||||
println_Msg(F("Calculating CRC.."));
|
println_Msg(F("Calculating CRC.."));
|
||||||
display_Update();
|
display_Update();
|
||||||
char crcStr[9];
|
if (compareCRC("n64.txt", 0)) {
|
||||||
sprintf(crcStr, "%08lx", calculateCRC(fileName, folder));
|
|
||||||
// Print checksum
|
|
||||||
println_Msg(crcStr);
|
|
||||||
display_Update();
|
|
||||||
|
|
||||||
// end time
|
|
||||||
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
|
|
||||||
#else
|
#else
|
||||||
// dumping rom fast
|
// dumping rom fast
|
||||||
byte buffer[1024] = { 0 };
|
byte buffer[1024] = { 0 };
|
||||||
@ -3522,21 +3525,14 @@ redumpsamefolder:
|
|||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
|
|
||||||
|
|
||||||
print_Msg(F("CRC: "));
|
|
||||||
// convert checksum to string
|
// convert checksum to string
|
||||||
char crcStr[9];
|
char crcStr[9];
|
||||||
sprintf(crcStr, "%08lx", ~oldcrc32);
|
sprintf(crcStr, "%08lX", ~oldcrc32);
|
||||||
// Print checksum
|
|
||||||
println_Msg(crcStr);
|
|
||||||
display_Update();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Search n64.txt for crc
|
// Search n64.txt for crc
|
||||||
if (searchCRC(crcStr)) {
|
if (compareCRC("n64.txt", crcStr)) {
|
||||||
// Dump was a known good rom
|
#endif
|
||||||
println_Msg(F("Checksum matches"));
|
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
|
||||||
print_Msg(F("Done ("));
|
print_Msg(F("Done ("));
|
||||||
print_Msg(timeElapsed); // include elapsed time
|
print_Msg(timeElapsed); // include elapsed time
|
||||||
println_Msg(F("s)"));
|
println_Msg(F("s)"));
|
||||||
@ -3556,8 +3552,6 @@ redumpsamefolder:
|
|||||||
// Dump was bad or unknown
|
// Dump was bad or unknown
|
||||||
errorLvl = 1;
|
errorLvl = 1;
|
||||||
setColor_RGB(255, 0, 0);
|
setColor_RGB(255, 0, 0);
|
||||||
println_Msg(F("Checksum not found"));
|
|
||||||
println_Msg(F("in N64.txt"));
|
|
||||||
println_Msg(F(""));
|
println_Msg(F(""));
|
||||||
println_Msg(F("Press Button..."));
|
println_Msg(F("Press Button..."));
|
||||||
display_Update();
|
display_Update();
|
||||||
|
@ -424,54 +424,6 @@ void read_bank_PCE_RAM(uint32_t address_start, int block_index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get line from file and convert upper case to lower case
|
|
||||||
void skip_line(FsFile* readfile)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
char str_buf;
|
|
||||||
|
|
||||||
while (readfile->available())
|
|
||||||
{
|
|
||||||
//Read 1 byte from file
|
|
||||||
str_buf = readfile->read();
|
|
||||||
|
|
||||||
//if end of file or newline found, execute command
|
|
||||||
if (str_buf == '\r')
|
|
||||||
{
|
|
||||||
readfile->read(); //dispose \n because \r\n
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}//End while
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get line from file and convert upper case to lower case
|
|
||||||
void get_line(char* str_buf, FsFile* readfile, uint8_t maxi)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
while (readfile->available())
|
|
||||||
{
|
|
||||||
//If line size is more than maximum array, limit it.
|
|
||||||
if (i >= maxi)
|
|
||||||
{
|
|
||||||
i = maxi - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Read 1 byte from file
|
|
||||||
str_buf[i] = readfile->read();
|
|
||||||
|
|
||||||
//if end of file or newline found, execute command
|
|
||||||
if (str_buf[i] == '\r')
|
|
||||||
{
|
|
||||||
str_buf[i] = '\0';
|
|
||||||
readfile->read(); //dispose \n because \r\n
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}//End while
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t calculate_crc32(int n, unsigned char c[], uint32_t r)
|
uint32_t calculate_crc32(int n, unsigned char c[], uint32_t r)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -68,7 +68,7 @@ void _smsMenu() {
|
|||||||
// Change working dir to root
|
// Change working dir to root
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
readROM_SMS();
|
readROM_SMS();
|
||||||
compareCRC("sms.txt");
|
compareCRC("sms.txt", 0);
|
||||||
#ifdef global_log
|
#ifdef global_log
|
||||||
save_log();
|
save_log();
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
#if !(defined(HW1) || defined(HW2) || defined(HW3) || defined(HW4) || defined(HW5) || defined(SERIAL_MONITOR))
|
#if !(defined(HW1) || defined(HW2) || defined(HW3) || defined(HW4) || defined(HW5) || defined(SERIAL_MONITOR))
|
||||||
# error !!! PLEASE CHOOSE HARDWARE VERSION IN OPTIONS.H !!!
|
# error !!! PLEASE CHOOSE HARDWARE VERSION IN OPTIONS.H !!!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
//
|
// Advanced Options
|
||||||
//******************************************
|
//******************************************
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
@ -43,6 +44,8 @@
|
|||||||
|
|
||||||
#if defined(SERIAL_MONITOR)
|
#if defined(SERIAL_MONITOR)
|
||||||
#define enable_serial
|
#define enable_serial
|
||||||
|
#define clockgen_installed
|
||||||
|
#define fastcrc
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
@ -69,9 +72,9 @@
|
|||||||
// #define clockgen_installed
|
// #define clockgen_installed
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// GB, SMS, MD database lookup
|
// GB, SMS, MD, N64 database lookup
|
||||||
//******************************************
|
//******************************************
|
||||||
// Renames ROM if found in database (slow)
|
// Renames ROM if found in database
|
||||||
#define no-intro
|
#define no-intro
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
|
3882
sd/n64.txt
3882
sd/n64.txt
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user