mirror of https://github.com/mgba-emu/mgba.git
GB MBC: Fix MBC6 bank switching
This commit is contained in:
parent
84b79b1ba8
commit
f23f221d49
|
@ -531,7 +531,7 @@ void _GBMBC5(struct GB* gb, uint16_t address, uint8_t value) {
|
||||||
|
|
||||||
void _GBMBC6(struct GB* gb, uint16_t address, uint8_t value) {
|
void _GBMBC6(struct GB* gb, uint16_t address, uint8_t value) {
|
||||||
struct GBMemory* memory = &gb->memory;
|
struct GBMemory* memory = &gb->memory;
|
||||||
int bank = value & 0x7F;
|
int bank = value;
|
||||||
switch (address >> 10) {
|
switch (address >> 10) {
|
||||||
case 0:
|
case 0:
|
||||||
switch (value) {
|
switch (value) {
|
||||||
|
@ -548,9 +548,11 @@ void _GBMBC6(struct GB* gb, uint16_t address, uint8_t value) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 0x8:
|
||||||
case 0x9:
|
case 0x9:
|
||||||
GBMBCSwitchHalfBank(gb, 0, bank);
|
GBMBCSwitchHalfBank(gb, 0, bank);
|
||||||
break;
|
break;
|
||||||
|
case 0xC:
|
||||||
case 0xD:
|
case 0xD:
|
||||||
GBMBCSwitchHalfBank(gb, 1, bank);
|
GBMBCSwitchHalfBank(gb, 1, bank);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -73,9 +73,20 @@ static void GBSetActiveRegion(struct LR35902Core* cpu, uint16_t address) {
|
||||||
case GB_REGION_CART_BANK1 + 2:
|
case GB_REGION_CART_BANK1 + 2:
|
||||||
case GB_REGION_CART_BANK1 + 3:
|
case GB_REGION_CART_BANK1 + 3:
|
||||||
cpu->memory.cpuLoad8 = GBFastLoad8;
|
cpu->memory.cpuLoad8 = GBFastLoad8;
|
||||||
cpu->memory.activeRegion = memory->romBank;
|
if (gb->memory.mbcType != GB_MBC6) {
|
||||||
cpu->memory.activeRegionEnd = GB_BASE_VRAM;
|
cpu->memory.activeRegion = memory->romBank;
|
||||||
cpu->memory.activeMask = GB_SIZE_CART_BANK0 - 1;
|
cpu->memory.activeRegionEnd = GB_BASE_VRAM;
|
||||||
|
cpu->memory.activeMask = GB_SIZE_CART_BANK0 - 1;
|
||||||
|
} else {
|
||||||
|
cpu->memory.activeMask = GB_SIZE_CART_HALFBANK - 1;
|
||||||
|
if (address & 0x2000) {
|
||||||
|
cpu->memory.activeRegion = memory->mbcState.mbc6.romBank1;
|
||||||
|
cpu->memory.activeRegionEnd = GB_BASE_VRAM;
|
||||||
|
} else {
|
||||||
|
cpu->memory.activeRegion = memory->romBank;
|
||||||
|
cpu->memory.activeRegionEnd = GB_BASE_CART_BANK1 + 0x2000;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cpu->memory.cpuLoad8 = GBLoad8;
|
cpu->memory.cpuLoad8 = GBLoad8;
|
||||||
|
@ -169,6 +180,10 @@ void GBMemoryReset(struct GB* gb) {
|
||||||
case GB_MBC1:
|
case GB_MBC1:
|
||||||
gb->memory.mbcState.mbc1.mode = 0;
|
gb->memory.mbcState.mbc1.mode = 0;
|
||||||
break;
|
break;
|
||||||
|
case GB_MBC6:
|
||||||
|
GBMBCSwitchHalfBank(gb, 0, 2);
|
||||||
|
GBMBCSwitchHalfBank(gb, 1, 3);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
memset(&gb->memory.mbcState, 0, sizeof(gb->memory.mbcState));
|
memset(&gb->memory.mbcState, 0, sizeof(gb->memory.mbcState));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue