Fix major battery save regressions introduced by the last release, fixes #282
This commit is contained in:
parent
5b2eec214b
commit
bce4bfba61
@ -205,7 +205,7 @@ static uint8_t read_mbc_ram(GB_gameboy_t *gb, uint16_t addr)
|
|||||||
return GB_camera_read_register(gb, addr);
|
return GB_camera_read_register(gb, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gb->mbc_ram || gb->mbc_ram_size) {
|
if (!gb->mbc_ram || !gb->mbc_ram_size) {
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ static uint8_t read_mbc_ram(GB_gameboy_t *gb, uint16_t addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t effective_bank = gb->mbc_ram_bank;
|
uint8_t effective_bank = gb->mbc_ram_bank;
|
||||||
if (gb->is_mbc30) {
|
if (gb->cartridge_type->mbc_type == GB_MBC3 && !gb->is_mbc30) {
|
||||||
effective_bank &= 0x3;
|
effective_bank &= 0x3;
|
||||||
}
|
}
|
||||||
uint8_t ret = gb->mbc_ram[((addr & 0x1FFF) + effective_bank * 0x2000) & (gb->mbc_ram_size - 1)];
|
uint8_t ret = gb->mbc_ram[((addr & 0x1FFF) + effective_bank * 0x2000) & (gb->mbc_ram_size - 1)];
|
||||||
@ -709,7 +709,12 @@ static void write_mbc_ram(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gb->mbc_ram[((addr & 0x1FFF) + gb->mbc_ram_bank * 0x2000) & (gb->mbc_ram_size - 1)] = value;
|
uint8_t effective_bank = gb->mbc_ram_bank;
|
||||||
|
if (gb->cartridge_type->mbc_type == GB_MBC3 && !gb->is_mbc30) {
|
||||||
|
effective_bank &= 0x3;
|
||||||
|
}
|
||||||
|
|
||||||
|
gb->mbc_ram[((addr & 0x1FFF) + effective_bank * 0x2000) & (gb->mbc_ram_size - 1)] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_ram(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
|
static void write_ram(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
|
||||||
|
Loading…
Reference in New Issue
Block a user