From 1128720bdd72d8ed9b51227675a8699bda124187 Mon Sep 17 00:00:00 2001 From: Modman <55462393+Modman@users.noreply.github.com> Date: Tue, 17 Sep 2019 13:01:05 -0700 Subject: [PATCH] Update N64.ino Included new strcmp function to ignore case when comparing checksums. --- Cart_Reader/N64.ino | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Cart_Reader/N64.ino b/Cart_Reader/N64.ino index 6dce10e..af91d4e 100644 --- a/Cart_Reader/N64.ino +++ b/Cart_Reader/N64.ino @@ -1188,6 +1188,16 @@ static const uint32_t crc_32_tab[] PROGMEM = { /* CRC polynomial 0xedb88320 */ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; +// improved strcmp function that ignores case to prevent checksum comparison issues +int strcicmp(char const *a, char const *b) +{ + for (;; a++, b++) { + int d = tolower((unsigned char)*a) - tolower((unsigned char)*b); + if (d != 0 || !*a) + return d; + } +} + // look-up the calculated crc in the file n64.txt on sd card boolean searchCRC(char crcStr[9]) { boolean result = 0; @@ -1209,7 +1219,7 @@ boolean searchCRC(char crcStr[9]) { } // Check if string is a match - if (strcmp(tempStr1, crcStr) == 0) { + if (strcicmp(tempStr1, crcStr) == 0) { // Skip the , in the file myFile.seekSet(myFile.curPosition() + 1);