Forgot to amend the last commit, it was broken.
This commit is contained in:
parent
aefca34b39
commit
efbc385417
@ -279,7 +279,8 @@ struct GB_gameboy_internal_s {
|
|||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uint8_t bank_low:5;
|
uint8_t bank_low:5;
|
||||||
uint8_t bank_high:3;
|
uint8_t bank_high:2;
|
||||||
|
uint8_t padding:1; // Save state compatibility with 0.9
|
||||||
uint8_t mode:1;
|
uint8_t mode:1;
|
||||||
} mbc1;
|
} mbc1;
|
||||||
|
|
||||||
|
53
Core/mbc.c
53
Core/mbc.c
@ -46,41 +46,49 @@ void GB_update_mbc_mappings(GB_gameboy_t *gb)
|
|||||||
switch (gb->cartridge_type->mbc_type) {
|
switch (gb->cartridge_type->mbc_type) {
|
||||||
case GB_NO_MBC: return;
|
case GB_NO_MBC: return;
|
||||||
case GB_MBC1:
|
case GB_MBC1:
|
||||||
if (gb->mbc1.mode == 0) {
|
switch (gb->mbc1_wiring) {
|
||||||
switch (gb->mbc1_wiring) {
|
case GB_STANDARD_MBC1_WIRING:
|
||||||
case GB_STANDARD_MBC1_WIRING:
|
gb->mbc_rom_bank = gb->mbc1.bank_low | (gb->mbc1.bank_high << 5);
|
||||||
gb->mbc_rom_bank = gb->mbc1.bank_low | (gb->mbc1.bank_high << 5);
|
if (gb->mbc1.mode == 0) {
|
||||||
gb->mbc_ram_bank = 0;
|
gb->mbc_ram_bank = 0;
|
||||||
gb->mbc_rom0_bank = 0;
|
gb->mbc_rom0_bank = 0;
|
||||||
break;
|
}
|
||||||
|
else {
|
||||||
case GB_MBC1M_WIRING:
|
|
||||||
gb->mbc_rom_bank = (gb->mbc1.bank_low & 0xF) | (gb->mbc1.bank_high << 4);
|
|
||||||
gb->mbc_ram_bank = 0;
|
|
||||||
gb->mbc_rom0_bank = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
switch (gb->mbc1_wiring) {
|
|
||||||
case GB_STANDARD_MBC1_WIRING:
|
|
||||||
gb->mbc_rom_bank = gb->mbc1.bank_low | (gb->mbc1.bank_high << 5);
|
|
||||||
gb->mbc_ram_bank = gb->mbc1.bank_high;
|
gb->mbc_ram_bank = gb->mbc1.bank_high;
|
||||||
gb->mbc_rom0_bank = gb->mbc1.bank_high << 5;
|
gb->mbc_rom0_bank = gb->mbc1.bank_high << 5;
|
||||||
break;
|
}
|
||||||
|
if ((gb->mbc_rom_bank & 0x1F) == 0) {
|
||||||
case GB_MBC1M_WIRING:
|
gb->mbc_rom_bank++;
|
||||||
gb->mbc_rom_bank = (gb->mbc1.bank_low & 0xF) | (gb->mbc1.bank_high << 4);
|
}
|
||||||
|
break;
|
||||||
|
case GB_MBC1M_WIRING:
|
||||||
|
gb->mbc_rom_bank = (gb->mbc1.bank_low & 0xF) | (gb->mbc1.bank_high << 4);
|
||||||
|
if (gb->mbc1.mode == 0) {
|
||||||
|
gb->mbc_ram_bank = 0;
|
||||||
|
gb->mbc_rom0_bank = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
gb->mbc_rom0_bank = gb->mbc1.bank_high << 4;
|
gb->mbc_rom0_bank = gb->mbc1.bank_high << 4;
|
||||||
gb->mbc_ram_bank = 0;
|
gb->mbc_ram_bank = 0;
|
||||||
}
|
}
|
||||||
|
if ((gb->mbc1.bank_low & 0x1F) == 0) {
|
||||||
|
gb->mbc_rom_bank++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GB_MBC2:
|
case GB_MBC2:
|
||||||
gb->mbc_rom_bank = gb->mbc2.rom_bank;
|
gb->mbc_rom_bank = gb->mbc2.rom_bank;
|
||||||
|
if ((gb->mbc_rom_bank & 0xF) == 0) {
|
||||||
|
gb->mbc_rom_bank = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GB_MBC3:
|
case GB_MBC3:
|
||||||
gb->mbc_rom_bank = gb->mbc3.rom_bank;
|
gb->mbc_rom_bank = gb->mbc3.rom_bank;
|
||||||
gb->mbc_ram_bank = gb->mbc3.ram_bank;
|
gb->mbc_ram_bank = gb->mbc3.ram_bank;
|
||||||
|
if (gb->mbc_rom_bank == 0) {
|
||||||
|
gb->mbc_rom_bank = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GB_MBC5:
|
case GB_MBC5:
|
||||||
gb->mbc_rom_bank = gb->mbc5.rom_bank_low | (gb->mbc5.rom_bank_high << 8);
|
gb->mbc_rom_bank = gb->mbc5.rom_bank_low | (gb->mbc5.rom_bank_high << 8);
|
||||||
@ -101,9 +109,6 @@ void GB_update_mbc_mappings(GB_gameboy_t *gb)
|
|||||||
gb->mbc_ram_bank = gb->huc3.ram_bank;
|
gb->mbc_ram_bank = gb->huc3.ram_bank;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((gb->mbc_rom_bank & 0x1F) == 0 && gb->cartridge_type->mbc_type != GB_MBC5 && gb->cartridge_type->mbc_type != GB_HUC3) {
|
|
||||||
gb->mbc_rom_bank++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GB_configure_cart(GB_gameboy_t *gb)
|
void GB_configure_cart(GB_gameboy_t *gb)
|
||||||
|
Loading…
Reference in New Issue
Block a user