From 8b78b2943eb3d9a6813ee4730c8f1f3c698f1bf5 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 19 Aug 2021 16:09:58 -0500 Subject: [PATCH] fix(cartridge): specify intentional overflow in MBC5 --- src/cartridge.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cartridge.rs b/src/cartridge.rs index b178d92..4d09a75 100644 --- a/src/cartridge.rs +++ b/src/cartridge.rs @@ -372,7 +372,9 @@ impl MBCIo for MBC5 { match addr { 0x0000..=0x3FFF => Address(addr as usize), - 0x4000..=0x7FFF => Address(0x4000 * self.rom_bank as usize + (addr as usize - 0x4000)), + 0x4000..=0x7FFF => { + Address(0x4000u16.wrapping_mul(self.rom_bank) as usize + (addr as usize - 0x4000)) + } 0xA000..=0xBFFF if self.mem_enabled => { Value(self.memory[0x2000 * self.ram_bank as usize + (addr as usize - 0xA000)]) }