From c96c27c52141e2c3c1d02ffeca95141012fd6e55 Mon Sep 17 00:00:00 2001 From: sanni Date: Fri, 9 Aug 2024 13:44:20 +0200 Subject: [PATCH] Update FLASH.ino --- Cart_Reader/FLASH.ino | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Cart_Reader/FLASH.ino b/Cart_Reader/FLASH.ino index 08c0d27..81d90e8 100644 --- a/Cart_Reader/FLASH.ino +++ b/Cart_Reader/FLASH.ino @@ -2868,8 +2868,11 @@ void adjustFileSizeOffset(byte currChip, byte totalChips, boolean reversed) { // 2*2MB or 2*4MB else if ((currChip == 1) && (totalChips == 2)) { if (reversed) { - fileSize = fileSize - flashSize / 2; - myFile.seekSet(4194304); + if (fileSize > 4194304) { + fileSize = fileSize - flashSize / 2; + myFile.seekSet(4194304); + } else + fileSize = 0; } else if (fileSize > flashSize / 2) fileSize = flashSize / 2; @@ -2885,9 +2888,13 @@ void adjustFileSizeOffset(byte currChip, byte totalChips, boolean reversed) { // 4*2MB else if ((currChip == 1) && (totalChips == 4)) { - if (reversed) - myFile.seekSet(4194304); - if (fileSize > 2097152) + if (reversed) { + if (fileSize > 4194304) { + myFile.seekSet(4194304); + fileSize = 2097152; + } else + fileSize = 0; + } else if (fileSize > 2097152) fileSize = 2097152; } else if ((currChip == 2) && (totalChips == 4)) { @@ -2919,8 +2926,11 @@ void adjustFileSizeOffset(byte currChip, byte totalChips, boolean reversed) { } else if ((currChip == 4) && (totalChips == 4)) { if (reversed) { - myFile.seekSet(2097152); - fileSize = 2097152; + if (fileSize > 2097152) { + myFile.seekSet(2097152); + fileSize = 2097152; + } else + fileSize = 0; } else { if (fileSize > 6291456) { myFile.seekSet(6291456);