Fix Progressbar and Erase while flashing GB cart

This commit is contained in:
sanni 2022-04-11 14:12:12 +02:00
parent a46358954f
commit ca70b9febd

View File

@ -743,7 +743,7 @@ void readROM_GB() {
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(romBanks - 2);
uint32_t totalProgressBar = (uint32_t)(romBanks) * 16384;
draw_progressbar(0, totalProgressBar);
for (word currBank = 1; currBank < romBanks; currBank++) {
@ -776,11 +776,10 @@ void readROM_GB() {
}
myFile.write(sdBuffer, 512);
romAddress += 512;
}
processedProgressBar += 1;
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
// Close the file:
myFile.close();
@ -1176,17 +1175,14 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
// Set data pins to input
dataIn_GB();
// Set OE/RD(PH6) LOW
PORTH &= ~(1 << 6);
// Read the status register
byte statusReg = readByte_GB(0);
// After a completed erase D7 will output 1
while ((PINC & 0x80) != 0x80) {
while ((statusReg & 0x80) != 0x80) {
// Update Status
statusReg = readByte_GB(0);
}
// Switch OE/RD(PH6) to HIGH
PORTH |= (1 << 6);
// Blankcheck
println_Msg(F("Blankcheck"));
display_Update();
@ -1228,7 +1224,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(romBanks - 2);
uint32_t totalProgressBar = (uint32_t)(romBanks) * 16384;
draw_progressbar(0, totalProgressBar);
for (int currBank = 0; currBank < romBanks; currBank++) {
@ -1271,11 +1267,11 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
dataOut();
}
currAddr += 512;
}
processedProgressBar += 1;
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
}
else if (MBC == 5) {
println_Msg(F("Writing flash MBC5"));
@ -1286,7 +1282,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
//Initialize progress bar
uint32_t processedProgressBar = 0;
uint32_t totalProgressBar = (uint32_t)(romBanks - 2);
uint32_t totalProgressBar = (uint32_t)(romBanks) * 16384;
draw_progressbar(0, totalProgressBar);
for (int currBank = 0; currBank < romBanks; currBank++) {
@ -1325,11 +1321,11 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
// Set data pins to output
dataOut();
}
}
processedProgressBar += 1;
processedProgressBar += 512;
draw_progressbar(processedProgressBar, totalProgressBar);
}
}
}
// Set data pins to input again
dataIn_GB();