SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit bce4bfba61f169b6b320b5b33aef838ef284badc parent 5b2eec214ba7018a50482b95434395868fc5649e Author: Lior Halphon <LIJI32@gmail.com> Date: Thu, 6 Aug 2020 19:33:33 +0300 Fix major battery save regressions introduced by the last release, fixes #282 Diffstat:
| M | Core/memory.c | 11 | ++++++++--- |
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Core/memory.c b/Core/memory.c @@ -205,7 +205,7 @@ static uint8_t read_mbc_ram(GB_gameboy_t *gb, uint16_t 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; } @@ -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; - if (gb->is_mbc30) { + if (gb->cartridge_type->mbc_type == GB_MBC3 && !gb->is_mbc30) { effective_bank &= 0x3; } uint8_t ret = gb->mbc_ram[((addr & 0x1FFF) + effective_bank * 0x2000) & (gb->mbc_ram_size - 1)]; @@ -708,8 +708,13 @@ static void write_mbc_ram(GB_gameboy_t *gb, uint16_t addr, uint8_t value) if (!gb->mbc_ram || !gb->mbc_ram_size) { return; } + + 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) + gb->mbc_ram_bank * 0x2000) & (gb->mbc_ram_size - 1)] = value; + 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)
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.