This commit is contained in:
parent
68b8d4bb1e
commit
b0d118f246
@ -438,7 +438,7 @@ struct GB_gameboy_internal_s {
|
|||||||
bool rumble_state;
|
bool rumble_state;
|
||||||
bool cart_ir;
|
bool cart_ir;
|
||||||
|
|
||||||
// TODO: move to huc3 struct when breaking save compat
|
// TODO: move to huc3/mbc3 struct when breaking save compat
|
||||||
uint8_t huc3_mode;
|
uint8_t huc3_mode;
|
||||||
uint8_t huc3_access_index;
|
uint8_t huc3_access_index;
|
||||||
uint16_t huc3_minutes, huc3_days;
|
uint16_t huc3_minutes, huc3_days;
|
||||||
@ -446,6 +446,7 @@ struct GB_gameboy_internal_s {
|
|||||||
bool huc3_alarm_enabled;
|
bool huc3_alarm_enabled;
|
||||||
uint8_t huc3_read;
|
uint8_t huc3_read;
|
||||||
uint8_t huc3_access_flags;
|
uint8_t huc3_access_flags;
|
||||||
|
bool mbc3_rtc_mapped;
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,10 +195,10 @@ static uint8_t read_mbc_ram(GB_gameboy_t *gb, uint16_t addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gb->cartridge_type->has_rtc && gb->cartridge_type->mbc_type != GB_HUC3 &&
|
if (gb->cartridge_type->has_rtc && gb->cartridge_type->mbc_type != GB_HUC3 &&
|
||||||
gb->mbc_ram_bank >= 8 && gb->mbc_ram_bank <= 0xC) {
|
gb->mbc3_rtc_mapped && gb->mbc_ram_bank <= 4) {
|
||||||
/* RTC read */
|
/* RTC read */
|
||||||
gb->rtc_latched.high |= ~0xC1; /* Not all bytes in RTC high are used. */
|
gb->rtc_latched.high |= ~0xC1; /* Not all bytes in RTC high are used. */
|
||||||
return gb->rtc_latched.data[gb->mbc_ram_bank - 8];
|
return gb->rtc_latched.data[gb->mbc_ram_bank];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gb->camera_registers_mapped) {
|
if (gb->camera_registers_mapped) {
|
||||||
@ -509,7 +509,10 @@ static void write_mbc(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
|
|||||||
switch (addr & 0xF000) {
|
switch (addr & 0xF000) {
|
||||||
case 0x0000: case 0x1000: gb->mbc_ram_enable = (value & 0xF) == 0xA; break;
|
case 0x0000: case 0x1000: gb->mbc_ram_enable = (value & 0xF) == 0xA; break;
|
||||||
case 0x2000: case 0x3000: gb->mbc3.rom_bank = value; break;
|
case 0x2000: case 0x3000: gb->mbc3.rom_bank = value; break;
|
||||||
case 0x4000: case 0x5000: gb->mbc3.ram_bank = value; break;
|
case 0x4000: case 0x5000:
|
||||||
|
gb->mbc3.ram_bank = value;
|
||||||
|
gb->mbc3_rtc_mapped = value & 8;
|
||||||
|
break;
|
||||||
case 0x6000: case 0x7000:
|
case 0x6000: case 0x7000:
|
||||||
if (!gb->rtc_latch && (value & 1)) { /* Todo: verify condition is correct */
|
if (!gb->rtc_latch && (value & 1)) { /* Todo: verify condition is correct */
|
||||||
memcpy(&gb->rtc_latched, &gb->rtc_real, sizeof(gb->rtc_real));
|
memcpy(&gb->rtc_latched, &gb->rtc_real, sizeof(gb->rtc_real));
|
||||||
@ -693,8 +696,8 @@ static void write_mbc_ram(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gb->cartridge_type->has_rtc && gb->mbc_ram_bank >= 8 && gb->mbc_ram_bank <= 0xC) {
|
if (gb->cartridge_type->has_rtc && gb->mbc3_rtc_mapped && gb->mbc_ram_bank <= 4) {
|
||||||
gb->rtc_latched.data[gb->mbc_ram_bank - 8] = gb->rtc_real.data[gb->mbc_ram_bank - 8] = value;
|
gb->rtc_latched.data[gb->mbc_ram_bank] = gb->rtc_real.data[gb->mbc_ram_bank] = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user