mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-24 03:51:54 +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
|
||||
an easy to build and easy to modify cartridge dumper.
|
||||
|
||||
Date: 16.06.2022
|
||||
Date: 18.06.2022
|
||||
Version: 8.5 BETA
|
||||
|
||||
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
|
||||
// Calculate CRC32
|
||||
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_Msg(F("CRC32: "));
|
||||
print_Msg(crcStr);
|
||||
display_Update();
|
||||
|
||||
//Search for CRC32 in file
|
||||
char gamename[100];
|
||||
@ -430,16 +486,19 @@ void compareCRC(char* database) {
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strcmp(crc_search, crcStr) != 0)
|
||||
{
|
||||
println_Msg(F(" -> Not found"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
println_Msg(F(" -> database file not found"));
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
println_Msg("");
|
||||
|
@ -952,7 +952,7 @@ void compare_checksums_GB() {
|
||||
println_Msg(calcsumStr);
|
||||
print_Error(F("Checksum Error"), false);
|
||||
}
|
||||
compareCRC("gb.txt");
|
||||
compareCRC("gb.txt", 0);
|
||||
display_Update();
|
||||
//go to root
|
||||
sd.chdir();
|
||||
|
@ -1297,7 +1297,7 @@ void readROM_MD() {
|
||||
display_Update();
|
||||
|
||||
// Calculate and compare CRC32 with no-intro
|
||||
compareCRC("md.txt");
|
||||
compareCRC("md.txt", 0);
|
||||
|
||||
// Calculate internal checksum
|
||||
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
|
||||
boolean searchCRC(char crcStr[9]) {
|
||||
/* look-up the calculated crc in the file n64.txt on sd card
|
||||
boolean searchCRC(char crcStr[9]) {
|
||||
boolean result = 0;
|
||||
char tempStr2[2];
|
||||
char tempStr1[9];
|
||||
@ -2276,7 +2276,7 @@ boolean searchCRC(char crcStr[9]) {
|
||||
else {
|
||||
print_Error(F("n64.txt missing"), true);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// look-up cart id in file n64.txt on sd card
|
||||
void getCartInfo_N64() {
|
||||
@ -2291,10 +2291,14 @@ void getCartInfo_N64() {
|
||||
idCart();
|
||||
|
||||
if (myFile.open("n64.txt", O_READ)) {
|
||||
// Skip over the first crc
|
||||
myFile.seekSet(myFile.curPosition() + 9);
|
||||
// Loop through file
|
||||
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(tempStr, "%c", myFile.read());
|
||||
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
|
||||
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 {
|
||||
myFile.seekSet(myFile.curPosition() + 16);
|
||||
// skip rest of line
|
||||
myFile.seekSet(myFile.curPosition() + 7);
|
||||
// skip third empty line
|
||||
skip_line(&myFile);
|
||||
}
|
||||
}
|
||||
// Close the file:
|
||||
@ -3427,14 +3437,7 @@ redumpsamefolder:
|
||||
// Calculate Checksum and convert to string
|
||||
println_Msg(F("Calculating CRC.."));
|
||||
display_Update();
|
||||
char crcStr[9];
|
||||
sprintf(crcStr, "%08lx", calculateCRC(fileName, folder));
|
||||
// Print checksum
|
||||
println_Msg(crcStr);
|
||||
display_Update();
|
||||
|
||||
// end time
|
||||
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
|
||||
if (compareCRC("n64.txt", 0)) {
|
||||
#else
|
||||
// dumping rom fast
|
||||
byte buffer[1024] = { 0 };
|
||||
@ -3522,21 +3525,14 @@ redumpsamefolder:
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
|
||||
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
|
||||
|
||||
print_Msg(F("CRC: "));
|
||||
// convert checksum to string
|
||||
char crcStr[9];
|
||||
sprintf(crcStr, "%08lx", ~oldcrc32);
|
||||
// Print checksum
|
||||
println_Msg(crcStr);
|
||||
display_Update();
|
||||
#endif
|
||||
sprintf(crcStr, "%08lX", ~oldcrc32);
|
||||
|
||||
// Search n64.txt for crc
|
||||
if (searchCRC(crcStr)) {
|
||||
// Dump was a known good rom
|
||||
println_Msg(F("Checksum matches"));
|
||||
if (compareCRC("n64.txt", crcStr)) {
|
||||
#endif
|
||||
unsigned long timeElapsed = (millis() - startTime) / 1000; // seconds
|
||||
print_Msg(F("Done ("));
|
||||
print_Msg(timeElapsed); // include elapsed time
|
||||
println_Msg(F("s)"));
|
||||
@ -3556,8 +3552,6 @@ redumpsamefolder:
|
||||
// Dump was bad or unknown
|
||||
errorLvl = 1;
|
||||
setColor_RGB(255, 0, 0);
|
||||
println_Msg(F("Checksum not found"));
|
||||
println_Msg(F("in N64.txt"));
|
||||
println_Msg(F(""));
|
||||
println_Msg(F("Press Button..."));
|
||||
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)
|
||||
{
|
||||
int i, j;
|
||||
|
@ -68,7 +68,7 @@ void _smsMenu() {
|
||||
// Change working dir to root
|
||||
sd.chdir("/");
|
||||
readROM_SMS();
|
||||
compareCRC("sms.txt");
|
||||
compareCRC("sms.txt", 0);
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
|
@ -12,8 +12,9 @@
|
||||
#if !(defined(HW1) || defined(HW2) || defined(HW3) || defined(HW4) || defined(HW5) || defined(SERIAL_MONITOR))
|
||||
# error !!! PLEASE CHOOSE HARDWARE VERSION IN OPTIONS.H !!!
|
||||
#endif
|
||||
|
||||
//******************************************
|
||||
//
|
||||
// Advanced Options
|
||||
//******************************************
|
||||
|
||||
//******************************************
|
||||
@ -43,6 +44,8 @@
|
||||
|
||||
#if defined(SERIAL_MONITOR)
|
||||
#define enable_serial
|
||||
#define clockgen_installed
|
||||
#define fastcrc
|
||||
#endif
|
||||
|
||||
//******************************************
|
||||
@ -69,9 +72,9 @@
|
||||
// #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
|
||||
|
||||
//******************************************
|
||||
|
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