diff --git a/CHANGES.md b/CHANGES.md index 4beb487..6eec381 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,7 @@ # Release notes +### v3.17 (released 2022-08-01) +- Improved MBC1 ROM banking based on the [Game Boy: Complete Technical Reference](https://github.com/Gekkio/gb-ctr) by gekkio (fixes games such as Super Chinese Fighter GB) + ### v3.16/v3.16.1 (released 2022-07-26) - Added support for 256M29EWH (no PCB text) *(thanks Diddy_Kong)* - Added support for a new insideGadgets 4 MB flash cartridge *(thanks AlexiG)* diff --git a/FlashGBX/Mapper.py b/FlashGBX/Mapper.py index bcdb23a..80d6589 100644 --- a/FlashGBX/Mapper.py +++ b/FlashGBX/Mapper.py @@ -207,11 +207,12 @@ class DMG_MBC1(DMG_MBC): def SelectBankROM(self, index): dprint(self.GetName(), "|", index, hex(index >> 5), hex(index & 0x1F)) commands = [ - [ 0x6000, 0 ], + [ 0x6000, 1 ], + [ 0x2000, index ], [ 0x4000, index >> 5 ], - [ 0x2000, index & 0x1F ], ] - start_address = 0 if index == 0 else 0x4000 + start_address = 0x4000 if index & 0x1F else 0 + self.CartWrite(commands) return (start_address, self.ROM_BANK_SIZE) @@ -544,18 +545,12 @@ class DMG_MBC1M(DMG_MBC1): def SelectBankROM(self, index): dprint(self.GetName(), "|", index) - if index < 10: - commands = [ - [ 0x4000, index >> 4 ], - [ 0x2000, index & 0x1F ], - ] - else: - commands = [ - [ 0x4000, index >> 4 ], - [ 0x2000, 0x10 | (index & 0x1F) ], - ] - - start_address = 0 if index == 0 else 0x4000 + commands = [ + [ 0x6000, 1 ], + [ 0x2000, index ], + [ 0x4000, index >> 4 ], + ] + start_address = 0x4000 if index & 0x0F else 0 self.CartWrite(commands) return (start_address, self.ROM_BANK_SIZE) diff --git a/FlashGBX/Util.py b/FlashGBX/Util.py index 6756a0d..5e816e6 100644 --- a/FlashGBX/Util.py +++ b/FlashGBX/Util.py @@ -7,7 +7,7 @@ from enum import Enum # Common constants APPNAME = "FlashGBX" -VERSION_PEP440 = "3.16.1" +VERSION_PEP440 = "3.17" VERSION = "v{:s}".format(VERSION_PEP440) DEBUG = False @@ -632,8 +632,10 @@ def GenerateFileName(mode, header, settings): path_revision = str(header["version"]) path_extension = "bin" path = "%TITLE%" + fe_sgb = "enabled" if settings is not None: path = settings.value(key="FileNameFormatDMG", default=path) + fe_sgb = settings.value(key="AutoFileExtensionSGB", default="enabled") if header["cgb"] == 0xC0 or header["cgb"] == 0x80: if len(header["game_title_raw"].rstrip("\x00")) == 15: if path_title[-4:][0] in ("A", "B", "H", "K", "V") and path_title[-4:][3] in ("A", "B", "D", "E", "F", "I", "J", "K", "P", "S", "U", "X", "Y"): @@ -643,7 +645,7 @@ def GenerateFileName(mode, header, settings): if settings is not None: path = settings.value(key="FileNameFormatCGB", default=path) path_extension = "gbc" - elif header["old_lic"] == 0x33 and header["sgb"] == 0x03: + elif header["old_lic"] == 0x33 and header["sgb"] == 0x03 and fe_sgb.lower() == "enabled": path_extension = "sgb" else: path_extension = "gb" diff --git a/FlashGBX/hw_GBxCartRW_ofw.py b/FlashGBX/hw_GBxCartRW_ofw.py index 8459ead..0d05047 100644 --- a/FlashGBX/hw_GBxCartRW_ofw.py +++ b/FlashGBX/hw_GBxCartRW_ofw.py @@ -190,7 +190,7 @@ class GbxDevice: dev.close() self.DEVICE = None return False - elif (self.FW[1] == 100 and self.FW[0] < 26): + elif (self.FW[1] == 100 and self.FW[0] < 26 and self.FW[0] != 20): self.FW_UPDATE_REQ = True elif (self.FW[1] in (2, 4, 90) and self.FW[0] < self.DEVICE_MAX_FW) or (self.FW[0] < self.DEVICE_MIN_FW): self.FW_UPDATE_REQ = True @@ -703,9 +703,12 @@ class GbxDevice: if mbc in (0x01, 0x02, 0x03): # MBC1 dprint("└[MBC1] 0x6000=0x00, 0x4000=0x{:X}, 0x2000=0x{:X}".format(bank >> 5, bank & 0x1F)) - self.cart_write(0x6000, 0) + #self.cart_write(0x6000, 0) + #self.cart_write(0x4000, bank >> 5) + #self.cart_write(0x2000, bank & 0x1F) + self.cart_write(0x6000, 1) + self.cart_write(0x2000, bank) self.cart_write(0x4000, bank >> 5) - self.cart_write(0x2000, bank & 0x1F) elif mbc in (0x101, 0x103): # MBC1M self.cart_write(0x4000, bank >> 4) if (bank < 10): @@ -1386,7 +1389,14 @@ class GbxDevice: elif mbc == 0x104: # M161 startAddr = 0 endAddr = 0x8000 - + elif mbc in (0x01, 0x02, 0x03): # MBC1 + if bank & 0x1F: + startAddr = 0x4000 + endAddr = 0x8000 + else: + startAddr = 0 + endAddr = 0x4000 + self.SetBankROM(bank, mbc) for currAddr in range(startAddr, endAddr, buffer_len): diff --git a/FlashGBX/res/config.zip b/FlashGBX/res/config.zip index a8af507..066a810 100644 Binary files a/FlashGBX/res/config.zip and b/FlashGBX/res/config.zip differ diff --git a/README.md b/README.md index 2abc7e2..fab67d2 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,7 @@ The author would like to thank the following very kind people for their help and - FerrantePescara (flash chip info) - frarees (bug reports) - Frost Clock (flash chip info) +- gekkio (bug reports, technical information) - Godan (flash chip info) - Grender (testing) - HDR (testing) diff --git a/setup.py b/setup.py index dd04698..2e09acd 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read( setuptools.setup( name="FlashGBX", - version="3.16.1", + version="3.17", author="Lesserkuma", description="Reads and writes Game Boy and Game Boy Advance cartridge data. Supported hardware: GBxCart RW v1.3 and v1.4 by insideGadgets.", url="https://github.com/lesserkuma/FlashGBX",