From 696d419e5b2feaf559f4918b9b3c3401983b2662 Mon Sep 17 00:00:00 2001 From: Emmet Young Date: Tue, 2 Feb 2016 19:44:18 +1100 Subject: [PATCH] Improve behaviour of MBC3 if statements. --- .../Project64-core/N64System/Mips/GBCart.cpp | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/GBCart.cpp b/Source/Project64-core/N64System/Mips/GBCart.cpp index 7a54d66df..6cc377fa5 100644 --- a/Source/Project64-core/N64System/Mips/GBCart.cpp +++ b/Source/Project64-core/N64System/Mips/GBCart.cpp @@ -332,7 +332,15 @@ static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t { if (gb_cart->ram != NULL) { - if (gb_cart->has_rtc && (gb_cart->ram_bank >= 0x08 && gb_cart->ram_bank <= 0x0c)) + if (gb_cart->ram_bank >= 0x00 && gb_cart->ram_bank <= 0x03) + { + offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); + if (offset < gb_cart->ram_size) + { + memcpy(data, &gb_cart->ram[offset], 0x20); + } + } + else if (gb_cart->has_rtc) { switch (gb_cart->ram_bank) { @@ -353,14 +361,6 @@ static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t break; } } - else - { - offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); - if (offset < gb_cart->ram_size) - { - memcpy(data, &gb_cart->ram[offset], 0x20); - } - } } } } @@ -413,7 +413,15 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const { if (gb_cart->ram != NULL) { - if (gb_cart->has_rtc && (gb_cart->ram_bank >= 0x8 && gb_cart->ram_bank <= 0xC)) + if (gb_cart->ram_bank >= 0x00 && gb_cart->ram_bank <= 0x03) + { + offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); + if (offset < gb_cart->ram_size) + { + memcpy(&gb_cart->ram[offset], data, 0x20); + } + } + else if (gb_cart->has_rtc) { bank = data[0]; @@ -444,14 +452,6 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const break; } } - else - { - offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); - if (offset < gb_cart->ram_size) - { - memcpy(&gb_cart->ram[offset], data, 0x20); - } - } } } }