mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-14 08:55:06 +01:00
Improve stability when dumping N64 with fastcrc option
This commit is contained in:
parent
e9d9617ad8
commit
6959c055e6
@ -5,7 +5,7 @@
|
|||||||
an easy to build and easy to modify cartridge dumper.
|
an easy to build and easy to modify cartridge dumper.
|
||||||
|
|
||||||
Date: 10.02.2023
|
Date: 10.02.2023
|
||||||
Version: 12.2
|
Version: 12.3
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
LCD lib: https://github.com/olikraus/u8g2
|
LCD lib: https://github.com/olikraus/u8g2
|
||||||
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
|
|
||||||
char ver[5] = "12.2";
|
char ver[5] = "12.3";
|
||||||
|
|
||||||
//******************************************
|
//******************************************
|
||||||
// !!! CHOOSE HARDWARE VERSION !!!
|
// !!! CHOOSE HARDWARE VERSION !!!
|
||||||
@ -157,7 +157,7 @@ char ver[5] = "12.2";
|
|||||||
#define enable_rotary
|
#define enable_rotary
|
||||||
// #define rotate_counter_clockwise
|
// #define rotate_counter_clockwise
|
||||||
#define clockgen_installed
|
#define clockgen_installed
|
||||||
// #define fastcrc
|
#define fastcrc
|
||||||
#define ws_adapter_v2
|
#define ws_adapter_v2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -769,20 +769,20 @@ void rewind_line(FsFile& readfile, byte count = 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate CRC32 if needed and compare it to CRC read from database
|
// Calculate CRC32 if needed and compare it to CRC read from database
|
||||||
boolean compareCRC(const char* database, char* crcString, boolean renamerom, int offset) {
|
boolean compareCRC(const char* database, uint32_t crc32sum, boolean renamerom, int offset) {
|
||||||
#ifdef nointro
|
#ifdef nointro
|
||||||
char crcStr[9];
|
char crcStr[9];
|
||||||
if (crcString == 0) {
|
print_Msg(F("CRC32... "));
|
||||||
|
display_Update();
|
||||||
|
|
||||||
|
if (crc32sum == 0) {
|
||||||
//go to root
|
//go to root
|
||||||
sd.chdir();
|
sd.chdir();
|
||||||
// Calculate CRC32
|
// Calculate CRC32
|
||||||
print_Msg(F("CRC32... "));
|
|
||||||
display_Update();
|
|
||||||
sprintf(crcStr, "%08lX", calculateCRC(fileName, folder, offset));
|
sprintf(crcStr, "%08lX", calculateCRC(fileName, folder, offset));
|
||||||
} else {
|
} else {
|
||||||
// Use precalculated crc
|
// Convert precalculated crc to string
|
||||||
print_Msg(F("CRC32... "));
|
sprintf(crcStr, "%08lX", ~crc32sum);
|
||||||
strcpy(crcStr, crcString);
|
|
||||||
}
|
}
|
||||||
// Print checksum
|
// Print checksum
|
||||||
print_Msg(crcStr);
|
print_Msg(crcStr);
|
||||||
@ -804,6 +804,7 @@ boolean compareCRC(const char* database, char* crcString, boolean renamerom, int
|
|||||||
|
|
||||||
//if checksum search successful, rename the file and end search
|
//if checksum search successful, rename the file and end search
|
||||||
if (strcmp(crc_search, crcStr) == 0) {
|
if (strcmp(crc_search, crcStr) == 0) {
|
||||||
|
|
||||||
#ifdef enable_NES
|
#ifdef enable_NES
|
||||||
if ((mode == mode_NES) && (offset != 0)) {
|
if ((mode == mode_NES) && (offset != 0)) {
|
||||||
// Rewind to iNES Header
|
// Rewind to iNES Header
|
||||||
|
@ -239,15 +239,20 @@ void n64CartMenu() {
|
|||||||
case 0:
|
case 0:
|
||||||
display_Clear();
|
display_Clear();
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
readRom_N64();
|
|
||||||
#ifndef fastcrc
|
#ifndef fastcrc
|
||||||
|
// Dumping ROM slow
|
||||||
|
readRom_N64();
|
||||||
sd.chdir("/");
|
sd.chdir("/");
|
||||||
// CRC32
|
|
||||||
compareCRC("n64.txt", 0, 1, 0);
|
compareCRC("n64.txt", 0, 1, 0);
|
||||||
|
#else
|
||||||
|
// Dumping ROM fast
|
||||||
|
compareCRC("n64.txt", readRom_N64(), 1, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef global_log
|
#ifdef global_log
|
||||||
save_log();
|
save_log();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prints string out of the common strings array either with or without newline
|
// Prints string out of the common strings array either with or without newline
|
||||||
print_STR(press_button_STR, 1);
|
print_STR(press_button_STR, 1);
|
||||||
display_Update();
|
display_Update();
|
||||||
@ -2780,6 +2785,8 @@ void getFramType() {
|
|||||||
Rom functions
|
Rom functions
|
||||||
*****************************************/
|
*****************************************/
|
||||||
// Read rom and save to the SD card
|
// Read rom and save to the SD card
|
||||||
|
#ifndef fastcrc
|
||||||
|
// dumping rom slow
|
||||||
void readRom_N64() {
|
void readRom_N64() {
|
||||||
// Get name, add extension and convert to char array for sd lib
|
// Get name, add extension and convert to char array for sd lib
|
||||||
strcpy(fileName, romName);
|
strcpy(fileName, romName);
|
||||||
@ -2807,9 +2814,6 @@ void readRom_N64() {
|
|||||||
print_FatalError(create_file_STR);
|
print_FatalError(create_file_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef fastcrc
|
|
||||||
// dumping rom slow
|
|
||||||
|
|
||||||
//Initialize progress bar
|
//Initialize progress bar
|
||||||
uint32_t processedProgressBar = 0;
|
uint32_t processedProgressBar = 0;
|
||||||
uint32_t totalProgressBar = (uint32_t)(cartSize)*1024 * 1024;
|
uint32_t totalProgressBar = (uint32_t)(cartSize)*1024 * 1024;
|
||||||
@ -2835,8 +2839,36 @@ void readRom_N64() {
|
|||||||
}
|
}
|
||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// dumping rom fast
|
// dumping rom fast
|
||||||
|
uint32_t readRom_N64() {
|
||||||
|
// Get name, add extension and convert to char array for sd lib
|
||||||
|
strcpy(fileName, romName);
|
||||||
|
strcat(fileName, ".Z64");
|
||||||
|
|
||||||
|
// create a new folder
|
||||||
|
EEPROM_readAnything(0, foldern);
|
||||||
|
sprintf(folder, "N64/ROM/%s/%d", romName, foldern);
|
||||||
|
sd.mkdir(folder, true);
|
||||||
|
sd.chdir(folder);
|
||||||
|
|
||||||
|
// clear the screen
|
||||||
|
// display_Clear();
|
||||||
|
print_STR(saving_to_STR, 0);
|
||||||
|
print_Msg(folder);
|
||||||
|
println_Msg(F("/..."));
|
||||||
|
display_Update();
|
||||||
|
|
||||||
|
// write new folder number back to eeprom
|
||||||
|
foldern = foldern + 1;
|
||||||
|
EEPROM_writeAnything(0, foldern);
|
||||||
|
|
||||||
|
// Open file on sd card
|
||||||
|
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||||
|
print_FatalError(create_file_STR);
|
||||||
|
}
|
||||||
|
|
||||||
byte buffer[1024];
|
byte buffer[1024];
|
||||||
|
|
||||||
//Initialize progress bar
|
//Initialize progress bar
|
||||||
@ -2917,14 +2949,10 @@ void readRom_N64() {
|
|||||||
// Close the file:
|
// Close the file:
|
||||||
myFile.close();
|
myFile.close();
|
||||||
|
|
||||||
// convert checksum to string
|
// Return checksum
|
||||||
char crcStr[9];
|
return oldcrc32;
|
||||||
sprintf(crcStr, "%08lX", ~oldcrc32);
|
|
||||||
|
|
||||||
// Search n64.txt for crc
|
|
||||||
compareCRC("n64.txt", crcStr, 1, 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef savesummarytotxt
|
#ifdef savesummarytotxt
|
||||||
// Save an info.txt with information on the dumped rom to the SD card
|
// Save an info.txt with information on the dumped rom to the SD card
|
||||||
|
Loading…
Reference in New Issue
Block a user