mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-15 01:15:06 +01:00
Update FLASH.ino
This commit is contained in:
parent
dae03f8810
commit
e19633536c
@ -2066,35 +2066,8 @@ void verifyFlash(byte currChip, byte totalChips, boolean reversed) {
|
||||
if (openVerifyFlashFile()) {
|
||||
blank = 0;
|
||||
|
||||
if ((currChip == 1) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 2) && (totalChips == 4) && (fileSize > 6291456)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(6291456);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 3) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(0);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 4) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(2097152);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 1) && (totalChips == 2)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
fileSize = 4194304;
|
||||
} else if ((currChip == 2) && (totalChips == 2)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(0);
|
||||
fileSize = 4194304;
|
||||
} else if ((currChip == 1) && (totalChips == 1)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
} else
|
||||
fileSize = 0; // skip write
|
||||
// Adjust filesize to fit flashchip
|
||||
adjustFileSize(currChip, totalChips, reversed);
|
||||
|
||||
//Initialize progress bar
|
||||
uint32_t processedProgressBar = 0;
|
||||
@ -2884,6 +2857,72 @@ void identifyCFI_Flash() {
|
||||
display_Update();
|
||||
}
|
||||
|
||||
// Adjust file size to fit flash chip
|
||||
void adjustFileSize(byte currChip, byte totalChips, boolean reversed) {
|
||||
// 1 flash chip
|
||||
if ((currChip == 1) && (totalChips == 1) && reversed) {
|
||||
myFile.seekSet(4194304);
|
||||
}
|
||||
// 2 flash chips
|
||||
else if ((currChip == 1) && (totalChips == 2)) {
|
||||
if (fileSize > flashSize / 2)
|
||||
fileSize = flashSize / 2;
|
||||
} else if ((currChip == 2) && (totalChips == 2) && (fileSize > flashSize / 2)) {
|
||||
fileSize = fileSize - flashSize / 2;
|
||||
myFile.seekSet(flashSize / 2);
|
||||
}
|
||||
|
||||
// 4*2MB
|
||||
else if ((currChip == 1) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
if (fileSize > 2097152)
|
||||
fileSize = 2097152;
|
||||
|
||||
} else if ((currChip == 2) && (totalChips == 4)) {
|
||||
if (reversed) {
|
||||
if (fileSize > 6291456) {
|
||||
myFile.seekSet(6291456);
|
||||
fileSize = 2097152;
|
||||
} else
|
||||
fileSize = 0;
|
||||
} else {
|
||||
if (fileSize > 2097152) {
|
||||
myFile.seekSet(2097152);
|
||||
fileSize = 2097152;
|
||||
} else
|
||||
fileSize = 0;
|
||||
}
|
||||
|
||||
} else if ((currChip == 3) && (totalChips == 4)) {
|
||||
if (reversed) {
|
||||
myFile.seekSet(0);
|
||||
fileSize = 2097152;
|
||||
} else {
|
||||
if (fileSize > 4194304) {
|
||||
myFile.seekSet(4194304);
|
||||
fileSize = 2097152;
|
||||
} else
|
||||
fileSize = 0;
|
||||
}
|
||||
|
||||
} else if ((currChip == 4) && (totalChips == 4)) {
|
||||
if (reversed) {
|
||||
myFile.seekSet(2097152);
|
||||
fileSize = 2097152;
|
||||
} else {
|
||||
if (fileSize > 6291456) {
|
||||
myFile.seekSet(6291456);
|
||||
fileSize = 2097152;
|
||||
} else
|
||||
fileSize = 0;
|
||||
}
|
||||
}
|
||||
// skip write
|
||||
else
|
||||
fileSize = 0;
|
||||
}
|
||||
|
||||
// Write flashrom
|
||||
void writeCFI_Flash(byte currChip, byte totalChips, boolean reversed) {
|
||||
if (openFileOnSD()) {
|
||||
@ -2931,37 +2970,8 @@ void writeCFI_Flash(byte currChip, byte totalChips, boolean reversed) {
|
||||
print_Msg(currChip);
|
||||
print_Msg(F("/"));
|
||||
println_Msg(totalChips);
|
||||
|
||||
if ((currChip == 1) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 2) && (totalChips == 4) && (fileSize > 6291456)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(6291456);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 3) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(0);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 4) && (totalChips == 4)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(2097152);
|
||||
fileSize = 2097152;
|
||||
} else if ((currChip == 1) && (totalChips == 2)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
fileSize = 4194304;
|
||||
} else if ((currChip == 2) && (totalChips == 2)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(0);
|
||||
fileSize = 4194304;
|
||||
} else if ((currChip == 1) && (totalChips == 1)) {
|
||||
if (reversed)
|
||||
myFile.seekSet(4194304);
|
||||
} else
|
||||
fileSize = 0; // skip write
|
||||
|
||||
// Adjust filesize to fit flashchip
|
||||
adjustFileSize(currChip, totalChips, reversed);
|
||||
display_Update();
|
||||
|
||||
//Initialize progress bar
|
||||
|
@ -71,9 +71,9 @@ static const char reproCFIItem5[] PROGMEM = "4x 2MB";
|
||||
static const char reproCFIItem6[] PROGMEM = "1x 8MB";
|
||||
static const char* const menuOptionsReproCFI[] PROGMEM = { reproCFIItem1, reproCFIItem2, reproCFIItem3, reproCFIItem4, reproCFIItem5, reproCFIItem6, FSTRING_RESET };
|
||||
|
||||
// EX ROM config
|
||||
static const char reproEXItem1[] PROGMEM = "standard (CDAB)";
|
||||
static const char reproEXItem2[] PROGMEM = "in-order (ABCD)";
|
||||
// ROM file order
|
||||
static const char reproEXItem1[] PROGMEM = "ExROM (CDAB)";
|
||||
static const char reproEXItem2[] PROGMEM = "standard (ABCD)";
|
||||
static const char* const menuOptionsReproEX[] PROGMEM = { reproEXItem1, reproEXItem2, FSTRING_RESET };
|
||||
|
||||
void setupCFI() {
|
||||
@ -98,7 +98,7 @@ boolean reproEXMenu() {
|
||||
unsigned char snsReproEX;
|
||||
// Copy menuOptions out of progmem
|
||||
convertPgm(menuOptionsReproEX, 3);
|
||||
snsReproEX = question_box(F("ExROM file order"), menuOptions, 3, 0);
|
||||
snsReproEX = question_box(F("ROM file order"), menuOptions, 3, 0);
|
||||
|
||||
// wait for user choice to come back from the question box menu
|
||||
switch (snsReproEX) {
|
||||
|
Loading…
Reference in New Issue
Block a user