diff options
author | sanni <[email protected]> | 2022-08-06 14:50:40 +0200 |
---|---|---|
committer | sanni <[email protected]> | 2022-08-06 14:50:40 +0200 |
commit | 511902eb5613d057605eba1cff0697d4c6fb0b1d (patch) | |
tree | 70205d2377f74d1f477b08393d49be3672890641 /Cart_Reader/COLV.ino | |
parent | 92f76b324cb9e3d912a35aa7d388c0c0e677c6f6 (diff) | |
download | cartreader-511902eb5613d057605eba1cff0697d4c6fb0b1d.tar.gz cartreader-511902eb5613d057605eba1cff0697d4c6fb0b1d.zip |
9.4: Add selecting mapping from database list for NES
Diffstat (limited to 'Cart_Reader/COLV.ino')
-rw-r--r-- | Cart_Reader/COLV.ino | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/Cart_Reader/COLV.ino b/Cart_Reader/COLV.ino index c17e60f..3fcb0dd 100644 --- a/Cart_Reader/COLV.ino +++ b/Cart_Reader/COLV.ino @@ -372,7 +372,6 @@ void checkStatus_COL() // CART SELECT CODE //****************************************** void setCart_COL() { - //Search for CRC32 in file char gamename[100]; char tempStr2[2]; char crc_search[9]; @@ -380,8 +379,46 @@ void setCart_COL() { //go to root sd.chdir(); + // Select starting letter + byte myLetter = starting_letter(); + // Open database if (myFile.open("colv.txt", O_READ)) { + // Skip ahead to selected starting letter + if ((myLetter > 0) && (myLetter <= 26)) { + while (myFile.available()) { + // Read current name + get_line(gamename, &myFile, 96); + + // Compare selected letter with first letter of current name until match + while (gamename[0] != 64 + myLetter) { + skip_line(&myFile); + skip_line(&myFile); + get_line(gamename, &myFile, 96); + } + break; + } + + // Rewind one line + for (byte count_newline = 0; count_newline < 2; count_newline++) { + while (1) { + if (myFile.curPosition() == 0) { + break; + } + else if (myFile.peek() == '\n') { + myFile.seekSet(myFile.curPosition() - 1); + break; + } + else { + myFile.seekSet(myFile.curPosition() - 1); + } + } + } + if (myFile.curPosition() != 0) + myFile.seekSet(myFile.curPosition() + 2); + } + + // Display database while (myFile.available()) { display_Clear(); @@ -520,8 +557,7 @@ void setCart_COL() { } } else { - println_Msg(F("Database file not found")); - return 0; + print_Error(F("Database file not found"), true); } } #endif |