mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-30 16:34:14 +01:00
Copy latest log to dump dir
This commit is contained in:
parent
f0639e20ad
commit
fac6f8eab2
@ -4,7 +4,7 @@
|
||||
This project represents a community-driven effort to provide
|
||||
an easy to build and easy to modify cartridge dumper.
|
||||
|
||||
Date: 14.06.2022
|
||||
Date: 16.06.2022
|
||||
Version: 8.5 BETA
|
||||
|
||||
SD lib: https://github.com/greiman/SdFat
|
||||
@ -907,6 +907,86 @@ void wait() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef global_log
|
||||
// Copies the last part of the current log file to the dump folder
|
||||
void save_log() {
|
||||
// Last found position
|
||||
uint64_t lastPosition = 0;
|
||||
|
||||
// Go to first line of log
|
||||
myLog.rewind();
|
||||
|
||||
// Find location of OSCR string to determine start of current log
|
||||
char tempStr[5];
|
||||
while (myLog.available()) {
|
||||
// Read first 4 chars of line
|
||||
tempStr[0] = myLog.read();
|
||||
|
||||
// Check if it's an empty line
|
||||
if (tempStr[0] == '\r') {
|
||||
// skip \n
|
||||
myLog.read();
|
||||
}
|
||||
else {
|
||||
// Read more lines
|
||||
tempStr[1] = myLog.read();
|
||||
tempStr[2] = myLog.read();
|
||||
tempStr[3] = myLog.read();
|
||||
tempStr[4] = '\0';
|
||||
char str_buf;
|
||||
|
||||
// Skip rest of line
|
||||
while (myLog.available()) {
|
||||
str_buf = myLog.read();
|
||||
|
||||
//break out of loop if CRLF is found
|
||||
if (str_buf == '\r')
|
||||
{
|
||||
myLog.read(); //dispose \n because \r\n
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If string is OSCR remember position in file and test if it's the lastest log entry
|
||||
if (strncmp(tempStr, "OSCR", 4) == 0) {
|
||||
// Check if current position is newer as old position
|
||||
if (myLog.position() > lastPosition) {
|
||||
lastPosition = myLog.position();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Go to position of last log entry
|
||||
myLog.seek(lastPosition - 16);
|
||||
|
||||
// Copy log from there to dump dir
|
||||
sd.chdir(folder);
|
||||
strcpy(fileName, romName);
|
||||
strcat(fileName, ".txt");
|
||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||
print_Error(F("SD Error"), true);
|
||||
}
|
||||
|
||||
while (myLog.available()) {
|
||||
if (myLog.available() >= 512) {
|
||||
for (word i = 0; i < 512; i++) {
|
||||
sdBuffer[i] = myLog.read();
|
||||
}
|
||||
myFile.write(sdBuffer, 512);
|
||||
}
|
||||
else {
|
||||
word i = 0;
|
||||
for (i = 0; i < myLog.available(); i++) {
|
||||
sdBuffer[i] = myLog.read();
|
||||
}
|
||||
myFile.write(sdBuffer, i);
|
||||
}
|
||||
}
|
||||
// Close the file:
|
||||
myFile.close();
|
||||
}
|
||||
#endif
|
||||
|
||||
void print_Msg(const __FlashStringHelper * string) {
|
||||
#ifdef enable_LCD
|
||||
display.print(string);
|
||||
|
@ -300,6 +300,9 @@ void gbMenu() {
|
||||
sd.chdir("/");
|
||||
readROM_GB();
|
||||
compare_checksums_GB();
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@ -997,7 +1000,7 @@ void compare_checksums_GB() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
println_Msg("gb.txt not found");
|
||||
println_Msg(" -> gb.txt not found");
|
||||
}
|
||||
#else
|
||||
println_Msg("");
|
||||
|
@ -128,6 +128,9 @@ void gbaMenu() {
|
||||
readROM_GBA();
|
||||
sd.chdir("/");
|
||||
compare_checksum_GBA();
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
println_Msg(F(""));
|
||||
println_Msg(F("Press Button..."));
|
||||
display_Update();
|
||||
|
@ -311,6 +311,9 @@ void mdCartMenu() {
|
||||
else
|
||||
readROM_MD();
|
||||
//compare_checksum_MD();
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
print_Error(F("Cart has no ROM"), false);
|
||||
|
@ -3575,6 +3575,9 @@ redumpsamefolder:
|
||||
// This saves a tt file with rom info next to the dumped rom
|
||||
#ifdef savesummarytotxt
|
||||
savesummary_N64(1, crcStr, timeElapsed);
|
||||
#endif
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
wait();
|
||||
}
|
||||
|
@ -246,6 +246,9 @@ void nesMenu() {
|
||||
delay(2000);
|
||||
resetROM();
|
||||
CartFinish();
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
break;
|
||||
|
||||
// Read single chip
|
||||
|
@ -68,6 +68,9 @@ void _smsMenu() {
|
||||
// Change working dir to root
|
||||
sd.chdir("/");
|
||||
readROM_SMS();
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
@ -216,10 +216,14 @@ void snesMenu() {
|
||||
// start reading from cart
|
||||
readROM_SNES();
|
||||
compare_checksum();
|
||||
|
||||
// print elapsed time
|
||||
print_Msg(F("Time elapsed: "));
|
||||
print_Msg((millis() - startTime) / 1000);
|
||||
println_Msg(F("s"));
|
||||
#ifdef global_log
|
||||
save_log();
|
||||
#endif
|
||||
display_Update();
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user