diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index da5f963..b0bbfed 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -4,8 +4,8 @@ This project represents a community-driven effort to provide an easy to build and easy to modify cartridge dumper. - Date: 31.10.2022 - Version: 11.1 + Date: 01.11.2022 + Version: 11.2 SD lib: https://github.com/greiman/SdFat LCD lib: https://github.com/olikraus/u8g2 @@ -57,7 +57,7 @@ **********************************************************************************/ -char ver[5] = "11.1"; +char ver[5] = "11.2"; //****************************************** // !!! CHOOSE HARDWARE VERSION !!! @@ -677,14 +677,14 @@ void rewind_line(FsFile& readfile, byte count = 1) { uint32_t position = readfile.curPosition(); count++; for (byte count_newline = 0; count_newline < count; count_newline++) { - while (position--) { + while (1) { + if (readfile.curPosition() == 0) + break; readfile.seekCur(-1); if (readfile.peek() == '\n') break; } } - if (position) - readfile.seekCur(1); } // Calculate CRC32 if needed and compare it to CRC read from database @@ -2730,8 +2730,11 @@ void wait_serial() { // Read button state int checkButton() { #ifdef enable_Button2 - if (checkButton2() != 0) + byte eventButton2 = checkButton2(); + if ((eventButton2 > 0) && (eventButton2 < 2)) return 3; + else if (eventButton2 > 2) + return 4; else return (checkButton1()); #else @@ -2803,7 +2806,7 @@ int checkButton1() { int checkButton2() { int event = 0; - // Read the state of the button (PD7) + // Read the state of the button (PG2) buttonVal2 = (PING & (1 << 2)); // Button pressed down if (buttonVal2 == LOW && buttonLast2 == HIGH && (millis() - upTime2) > debounce) { @@ -2928,15 +2931,18 @@ int checkButton() { if (buttonState == 0) { unsigned long pushTime = millis(); // Wait until button was let go again - while ((PING & (1 << PING2)) >> PING2 == 0) - ; + while ((PING & (1 << PING2)) >> PING2 == 0) { + // Signal long press delay reached + if ((millis() - pushTime) > 2000) + rgbLed(green_color); + } lastButtonState = reading; - // If the hold time was over 10 seconds, super long press for resetting eeprom in about screen - if (millis() - pushTime > 10000) { + // 2 second long press + if ((millis() - pushTime) > 2000) { return 4; } - // long press + // normal press else { return 3; } diff --git a/Cart_Reader/NES.ino b/Cart_Reader/NES.ino index 50da269..0a94957 100644 --- a/Cart_Reader/NES.ino +++ b/Cart_Reader/NES.ino @@ -529,7 +529,6 @@ void getMapping() { // Filter out all 0xFF checksums at 0x8000 and 0xE000 if (oldcrc32 == 0xBD7BC39F && oldcrc32MMC3 == 0xBD7BC39F) { - println_Msg(F("")); println_Msg(F("No data found.")); println_Msg(F("Using manual selection")); display_Update(); @@ -577,6 +576,7 @@ void getMapping() { selectMapping(database); } } + byte fastScrolling = 1; // Display database while (database.available()) { @@ -647,17 +647,25 @@ void getMapping() { #ifdef global_log // Disable log to prevent unnecessary logging - println_Log(F("Get Mapping from List")); + //println_Log(F("Get Mapping from List")); dont_log = true; #endif println_Msg(entry.filename); printNESSettings(); #if defined(enable_OLED) - print_STR(press_to_change_STR, 1); - print_STR(right_to_select_STR, 1); + print_STR(press_to_change_STR, 0); + if (fastScrolling > 1) + println_Msg(F(" (fast)")); + else + println_Msg(""); + println_Msg(F("Hold to select")); #elif defined(enable_LCD) - print_STR(rotate_to_change_STR, 1); - print_STR(press_to_select_STR, 1); + print_STR(rotate_to_change_STR, 0); + if (fastScrolling > 1) + println_Msg(F(" (fast)")); + else + println_Msg(""); + println_Msg(F("Hold to Select")); #elif defined(SERIAL_MONITOR) println_Msg(F("U/D to Change")); println_Msg(F("Space to Select")); @@ -673,12 +681,29 @@ void getMapping() { b = checkButton(); } while (b == 0); - if (b == 1) + if (b == 1) { // 1: Next record + if (fastScrolling > 1) { + for (byte skipped = 0; skipped < fastScrolling * 3; skipped++) { + skip_line(&database); + } + } continue; + } if (b == 2) { // 2: Previous record - rewind_line(database, 6); + if (fastScrolling > 1) + rewind_line(database, fastScrolling * 3 + 3); + else + rewind_line(database, 6); + continue; + } + if (b == 3) { + // 3: Toggle Fast Scrolling + if (fastScrolling == 1) + fastScrolling = 30; + else + fastScrolling = 1; continue; } // anything else: select current record