Adds romBanks <= flashBanks check

This commit is contained in:
Dakkaron 2021-07-21 23:02:45 +02:00
parent 12b3c7ebe0
commit 78d6e9dde3

View File

@ -946,6 +946,7 @@ void identifyFlash_GB() {
// Write 29F032 flashrom
// A0-A13 directly connected to cart edge -> 16384(0x0-0x3FFF) bytes per bank -> 256(0x0-0xFF) banks
// A14-A21 connected to MBC5
// identifyFlash_GB() needs to be run before this!
bool writeFlash_GB() {
// Create filepath
sprintf(filePath, "%s/%s", filePath, fileName);
@ -965,6 +966,27 @@ bool writeFlash_GB() {
romBanks = 2 << romSize;
}
if (romBanks<=flashBanks) {
print_Msg(F("Using "));
print_Msg(romBanks);
print_Msg(F("/"));
print_Msg(flashBanks);
println_Msg(F(" Banks"));
display_Update();
} else {
println_Msg(F("Error: Flash has too few banks!"));
print_Msg(F("Has "));
print_Msg(flashBanks);
println_Msg(F(" banks,")
print_Msg(F("but needs "));
print_Msg(romBanks);
println_Msg(F("."));
println_Msg(F("Press button..."));
display_Update();
wait();
resetArduino();
}
// Set data pins to output
dataOut();
@ -1037,7 +1059,7 @@ bool writeFlash_GB() {
}
}
println_Msg(F("Writing flash MBC3/MBC5"));
println_Msg(F("Writing flash MBC3/5"));
display_Update();
// Write flash