Skip to content

Commit

Permalink
Fix verifyFlash()
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni committed Jun 27, 2024
1 parent fefd959 commit ce4e26c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
37 changes: 27 additions & 10 deletions Cart_Reader/FLASH.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1793,17 +1793,26 @@ void blankcheck_Flash() {
}

void verifyFlash() {
verifyFlash(0, 0);
verifyFlash(0);
}

void verifyFlash(unsigned long verifyStart, unsigned long verifyEnd) {
void verifyFlash(byte romChips) {
if (openVerifyFlashFile()) {
blank = 0;

if (verifyStart != 0)
myFile.seekCur(verifyStart);
if (verifyEnd != 0)
fileSize = verifyEnd;
if (romChips == 1) {
myFile.seekCur(0);
// Truncate file to size of 1st flash chip
if (fileSize > flashSize / 2) {
fileSize = flashSize / 2;
}
} else if (romChips == 2) {
if (fileSize > flashSize / 2) {
myFile.seekCur(flashSize / 2);
fileSize = fileSize - (flashSize / 2);
} else
fileSize = 0;
}

for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
//fill sdBuffer
Expand Down Expand Up @@ -2608,17 +2617,25 @@ void writeCFI_Flash(byte romChips) {
// If we have two ROM chips only write half the ROM file here and skip to second half of file on second write
if (romChips == 0) {
println_Msg(F(""));
} else if (romChips == 1) {
}

else if (romChips == 1) {
println_Msg(F(" 1/2"));
myFile.seekCur(0);
// Truncate file to size of 1st flash chip
if (fileSize > flashSize / 2) {
fileSize = flashSize / 2;
}
} else if (romChips == 2) {
}

else if (romChips == 2) {
println_Msg(F(" 2/2"));
myFile.seekCur(flashSize / 2);
fileSize = fileSize - flashSize / 2;
if (fileSize > flashSize / 2) {
myFile.seekCur(flashSize / 2);
fileSize = fileSize - (flashSize / 2);
} else {
fileSize = 0;
}
}
display_Update();

Expand Down
4 changes: 2 additions & 2 deletions Cart_Reader/SNES.ino
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void reproCFIMenu() {
flashSize = 4194304;
// Write first rom chip
writeCFI_Flash(1);
verifyFlash(0, 2097152);
verifyFlash(1);
delay(300);

// Switch to second ROM chip, see flash.ino low level functions line 811
Expand All @@ -121,7 +121,7 @@ void reproCFIMenu() {
// Write second rom chip
display_Clear();
writeCFI_Flash(2);
verifyFlash(2097152, 2097152);
verifyFlash(2);
break;

case 2:
Expand Down

0 comments on commit ce4e26c

Please sign in to comment.