GB Memory: Initial MBC2 support

This commit is contained in:
Jeffrey Pfau 2016-02-27 01:21:43 -08:00
parent 93a839f52a
commit 53e70a5460
1 changed files with 28 additions and 2 deletions

View File

@ -520,8 +520,34 @@ void _GBMBC1(struct GBMemory* memory, uint16_t address, uint8_t value) {
}
void _GBMBC2(struct GBMemory* memory, uint16_t address, uint8_t value) {
mLOG(GB_MBC, STUB, "MBC2 unimplemented");
}
int bank = value & 0xF;
switch (address >> 13) {
case 0x0:
switch (value) {
case 0:
memory->sramAccess = false;
break;
case 0xA:
memory->sramAccess = true;
_switchSramBank(memory, memory->sramCurrentBank);
break;
default:
// TODO
mLOG(GB_MBC, STUB, "MBC1 unknown value %02X", value);
break;
}
break;
case 0x1:
if (!bank) {
++bank;
}
_switchBank(memory, bank);
break;
default:
// TODO
mLOG(GB_MBC, STUB, "MBC2 unknown address: %04X:%02X", address, value);
break;
}}
void _GBMBC3(struct GBMemory* memory, uint16_t address, uint8_t value) {
int bank = value & 0x7F;