diff --git a/Cart_Reader/GBM.ino b/Cart_Reader/GBM.ino index f376706..0790539 100644 --- a/Cart_Reader/GBM.ino +++ b/Cart_Reader/GBM.ino @@ -403,13 +403,13 @@ void send_GBM(byte myCommand) { break; case 0x04: - //CMD_04h -> Map entire flashrom (MBC4 mode) + //CMD_04h -> Disable mapping; makes the entire flash and SRAM accessible writeByte_GBM(0x0120, 0x04); writeByte_GBM(0x013F, 0xA5); break; case 0x05: - //CMD_05h -> Map menu (MBC5 mode) + //CMD_05h -> Enable mapping; re-enables the mapping that was previously selected by 0xCn writeByte_GBM(0x0120, 0x05); writeByte_GBM(0x013F, 0xA5); break; @@ -479,8 +479,14 @@ void switchGame_GBM(byte myData) { // Enable ports 0x0120 (F2) send_GBM(0x09); + // Enable mapping. Mapping must be enabled before the C0 cmd, otherwise switching has no effect. + send_GBM(0x05); + //CMD_C0h -> map selected game without reset - writeByte_GBM(0x0120, 0xC0 & myData); + // C0 is the menu or a single 1MB sized game + // C1 is the first game entry + // C2 is the second game entry... + writeByte_GBM(0x0120, 0xC0 | myData); writeByte_GBM(0x013F, 0xA5); } @@ -918,4 +924,4 @@ void writeMapping_GBM() { //****************************************** // End of File -//****************************************** \ No newline at end of file +//******************************************