From c738072aa97fd11b56560bd7b911ea5384a086b6 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 21 Feb 2022 11:56:55 +0800 Subject: [PATCH 01/45] Sync libretro changes --- Core/BandaiFcg.h | 11 +++++-- Libretro/Makefile | 71 ++++++++++++++++++++++++++++++---------- Libretro/Makefile.common | 6 ++-- Libretro/libretro.h | 2 +- 4 files changed, 65 insertions(+), 25 deletions(-) diff --git a/Core/BandaiFcg.h b/Core/BandaiFcg.h index 2cea19014..49c6f7704 100644 --- a/Core/BandaiFcg.h +++ b/Core/BandaiFcg.h @@ -87,6 +87,9 @@ class BandaiFcg : public BaseMapper } //Last bank + if( _romInfo.MapperID != 153 && GetPRGPageCount() >= 0x20 ) + SelectPRGPage(1, 0x1F); + else SelectPRGPage(1, 0x0F); } @@ -156,7 +159,7 @@ class BandaiFcg : public BaseMapper switch(addr & 0x000F) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: _chrRegs[addr & 0x07] = value; - if(_romInfo.MapperID == 153 || GetPRGPageCount() >= 0x20) { + if(_romInfo.MapperID == 153) { _prgBankSelect = 0; for(int i = 0; i < 8; i++) { _prgBankSelect |= (_chrRegs[i] & 0x01) << 4; @@ -173,7 +176,11 @@ class BandaiFcg : public BaseMapper break; case 0x08: + if( _romInfo.MapperID != 153 && GetPRGPageCount() >= 0x20 ) + _prgPage = value & 0x1F; + else _prgPage = value & 0x0F; + SelectPRGPage(0, _prgPage | _prgBankSelect); break; @@ -232,4 +239,4 @@ class BandaiFcg : public BaseMapper break; } } -}; \ No newline at end of file +}; diff --git a/Libretro/Makefile b/Libretro/Makefile index e224e18e7..e6063d529 100644 --- a/Libretro/Makefile +++ b/Libretro/Makefile @@ -32,6 +32,9 @@ else ifneq ($(findstring Darwin,$(shell uname -a)),) ifeq ($(shell uname -p),powerpc) arch = ppc endif +ifeq ($(shell uname -p),arm) + arch = arm +endif else ifneq ($(findstring MINGW,$(shell uname -a)),) system_platform = win endif @@ -46,20 +49,15 @@ TARGET_NAME := mesen LIBM = -lm ifeq ($(ARCHFLAGS),) -ifeq ($(archs),ppc) +ifeq ($(arch),ppc) ARCHFLAGS = -arch ppc -arch ppc64 +else ifeq ($(arch),arm) + ARCHFLAGS = -arch arm64 else ARCHFLAGS = -arch i386 -arch x86_64 endif endif -ifeq ($(platform), osx) -ifndef ($(NOUNIVERSAL)) - CXXFLAGS += $(ARCHFLAGS) - LFLAGS += $(ARCHFLAGS) -endif -endif - ifeq ($(STATIC_LINKING), 1) EXT := a endif @@ -67,7 +65,11 @@ endif ifneq (,$(findstring unix,$(platform))) EXT ?= so TARGET := $(TARGET_NAME)_libretro.$(EXT) - fpic := -fPIC -pthread + ifneq ($(findstring Haiku,$(shell uname -s)),) + fpic := -fPIC -lroot + else + fpic := -fPIC -pthread + endif SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined else ifeq ($(platform), linux-portable) @@ -112,32 +114,62 @@ else ifeq ($(platform), classic_armv7_a7) endif ####################################### +########################### +# Raspberry Pi 4 in 64 mode +else ifneq (,$(findstring rpi4_64,$(platform))) + EXT ?= so + TARGET := $(TARGET_NAME)_libretro.$(EXT) + fpic := -fPIC -pthread + SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined + CFLAGS += -march=armv8-a+crc+simd -mtune=cortex-a72 + CXXFLAGS += $(CFLAGS) + CPPFLAGS += $(CFLAGS) + ASFLAGS += $(CFLAGS) +########################### + else ifneq (,$(findstring osx,$(platform))) TARGET := $(TARGET_NAME)_libretro.dylib fpic := -fPIC SHARED := -dynamiclib +ifeq ($(CROSS_COMPILE),1) + TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) + CFLAGS += $(TARGET_RULE) + CXXFLAGS += $(TARGET_RULE) + LDFLAGS += $(TARGET_RULE) + ARCHFLAGS = +endif +ifeq ($(platform), osx) +ifndef ($(NOUNIVERSAL)) + CFLAGS += $(ARCHFLAGS) + CXXFLAGS += $(ARCHFLAGS) + LFLAGS += $(ARCHFLAGS) +endif +endif + else ifneq (,$(findstring ios,$(platform))) TARGET := $(TARGET_NAME)_libretro_ios.dylib fpic := -fPIC SHARED := -dynamiclib + DEFINES := -DIOS + MINVERSION= ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) endif - - DEFINES := -DIOS ifeq ($(platform), ios-arm64) - CC = cc -arch arm64 -isysroot $(IOSSDK) -stdlib=libc++ + CC = clang -arch arm64 -isysroot $(IOSSDK) -stdlib=libc++ + CXX = clang++ -arch arm64 -isysroot $(IOSSDK) -stdlib=libc++ else - CC = cc -arch armv7 -isysroot $(IOSSDK) + CC = clang -arch armv7 -isysroot $(IOSSDK) + CXX = clang++ -arch armv7 -isysroot $(IOSSDK) endif ifeq ($(platform),$(filter $(platform),ios9 ios-arm64)) -CC += -miphoneos-version-min=8.0 -CXXFLAGS += -miphoneos-version-min=8.0 + MINVERSION = -miphoneos-version-min=9.0 else -CC += -miphoneos-version-min=5.0 -CXXFLAGS += -miphoneos-version-min=5.0 + MINVERSION = -miphoneos-version-min=5.0 endif + CFLAGS += $(MINVERSION) + CXXFLAGS += $(MINVERSION) else ifeq ($(platform), tvos-arm64) TARGET := $(TARGET_NAME)_libretro_tvos.dylib @@ -148,6 +180,8 @@ else ifeq ($(platform), tvos-arm64) ifeq ($(IOSSDK),) IOSSDK := $(shell xcodebuild -version -sdk appletvos Path) endif + CC = cc -arch arm64 -isysroot $(IOSSDK) + CXX = c++ -arch arm64 -isysroot $(IOSSDK) else ifneq (,$(findstring qnx,$(platform))) TARGET := $(TARGET_NAME)_libretro_qnx.so @@ -158,8 +192,9 @@ else ifeq ($(platform), emscripten) fpic := -fPIC SHARED := -shared -Wl,--version-script=$(LIBRETRO_DIR)/link.T -Wl,--no-undefined else ifeq ($(platform), vita) - TARGET := $(TARGET_NAME)_vita.a + TARGET := $(TARGET_NAME)_libretro_vita.a CC = arm-vita-eabi-gcc + CXX = arm-vita-eabi-g++ AR = arm-vita-eabi-ar CXXFLAGS += -Wl,-q -Wall -O3 STATIC_LINKING = 1 diff --git a/Libretro/Makefile.common b/Libretro/Makefile.common index da8a27985..8a9babda5 100644 --- a/Libretro/Makefile.common +++ b/Libretro/Makefile.common @@ -23,11 +23,10 @@ SOURCES_CXX := $(LIBRETRO_DIR)/libretro.cpp \ $(CORE_DIR)/APU.cpp \ $(CORE_DIR)/Assembler.cpp \ $(CORE_DIR)/AutomaticRomTest.cpp \ - $(CORE_DIR)/AutoSaveManager.cpp \ + $(CORE_DIR)/AutoSaveManager.cpp \ $(CORE_DIR)/BaseControlDevice.cpp \ $(CORE_DIR)/BaseExpansionAudio.cpp \ $(CORE_DIR)/BaseMapper.cpp \ - $(CORE_DIR)/BaseRenderer.cpp \ $(CORE_DIR)/BaseVideoFilter.cpp \ $(CORE_DIR)/BatteryManager.cpp \ $(CORE_DIR)/BisqwitNtscFilter.cpp \ @@ -91,7 +90,6 @@ SOURCES_CXX := $(LIBRETRO_DIR)/libretro.cpp \ $(CORE_DIR)/PerformanceTracker.cpp \ $(CORE_DIR)/PgoUtilities.cpp \ $(CORE_DIR)/Profiler.cpp \ - $(CORE_DIR)/RecordedRomTest.cpp \ $(CORE_DIR)/ReverbFilter.cpp \ $(CORE_DIR)/RewindData.cpp \ $(CORE_DIR)/RewindManager.cpp \ @@ -163,4 +161,4 @@ SOURCES_CXX := $(LIBRETRO_DIR)/libretro.cpp \ #LUAOBJ=$(patsubst Lua/%.c,Lua/$(OBJFOLDER)/%.o,$(wildcard Lua/*.c)) #COREOBJ=$(patsubst Core/%.cpp,Core/$(OBJFOLDER)/%.o,$(wildcard Core/*.cpp)) -#UTILOBJ=$(patsubst Utilities/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/*.cpp)) $(patsubst Utilities/HQX/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/HQX/*.cpp)) $(patsubst Utilities/xBRZ/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/xBRZ/*.cpp)) $(patsubst Utilities/KreedSaiEagle/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/KreedSaiEagle/*.cpp)) $(patsubst Utilities/Scale2x/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/Scale2x/*.cpp)) \ No newline at end of file +#UTILOBJ=$(patsubst Utilities/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/*.cpp)) $(patsubst Utilities/HQX/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/HQX/*.cpp)) $(patsubst Utilities/xBRZ/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/xBRZ/*.cpp)) $(patsubst Utilities/KreedSaiEagle/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/KreedSaiEagle/*.cpp)) $(patsubst Utilities/Scale2x/%.cpp,Utilities/$(OBJFOLDER)/%.o,$(wildcard Utilities/Scale2x/*.cpp)) diff --git a/Libretro/libretro.h b/Libretro/libretro.h index 352a8d1c0..32aa15f05 100644 --- a/Libretro/libretro.h +++ b/Libretro/libretro.h @@ -69,7 +69,7 @@ extern "C" { # endif # endif # else -# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__CELLOS_LV2__) +# if defined(__GNUC__) && __GNUC__ >= 4 # define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default"))) # else # define RETRO_API RETRO_CALLCONV From 247e23232b355a57b475a79aff4735ac14f4acf3 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 21 Feb 2022 13:57:00 +0800 Subject: [PATCH 02/45] Mapper 15: Fix CHR write protect for some subor/waixing boards --- Core/Mapper15.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Mapper15.h b/Core/Mapper15.h index 5cf481ddf..26753d9ca 100644 --- a/Core/Mapper15.h +++ b/Core/Mapper15.h @@ -26,8 +26,9 @@ class Mapper15 : public BaseMapper uint8_t bank = (value & 0x7F) << 1; uint8_t mode = addr & 0x03; - SetPpuMemoryMapping(0, 0x1FFF, 0, ChrMemoryType::Default, (mode == 0 || mode == 3) ? MemoryAccessType::Read : MemoryAccessType::ReadWrite); - + /* Protecting CHR writes only for mode 3 fixes some subor/waixing carts */ + SetPpuMemoryMapping(0, 0x1FFF, 0, ChrMemoryType::Default, (mode == 3) ? MemoryAccessType::Read : MemoryAccessType::ReadWrite); + switch(mode) { case 0: SelectPRGPage(0, bank ^ subBank); From 1eb28560e5b512e6f1df0eaca1b88183761f7b5a Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 26 Feb 2022 19:45:12 +0800 Subject: [PATCH 03/45] JY Company: Fixed PRG outer banking --- Core/JyCompany.h | 86 +++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/Core/JyCompany.h b/Core/JyCompany.h index 78a924ee5..93a9a9abb 100644 --- a/Core/JyCompany.h +++ b/Core/JyCompany.h @@ -23,7 +23,7 @@ class JyCompany : public BaseMapper uint8_t _prgMode; bool _enablePrgAt6000; uint8_t _prgBlock; - + uint8_t _chrMode; bool _chrBlockMode; uint8_t _chrBlock; @@ -71,6 +71,7 @@ class JyCompany : public BaseMapper memset(_chrHighRegs, 0, sizeof(_chrHighRegs)); _prgMode = 0; + _prgBlock = 0; _enablePrgAt6000 = false; _prgBlock = 0; @@ -117,7 +118,8 @@ class JyCompany : public BaseMapper Stream(_chrLatch[0], _chrLatch[1], _prgMode, _enablePrgAt6000, _prgBlock, _chrMode, _chrBlockMode, _chrBlock, _mirrorChr, _mirroringReg, _advancedNtControl, _disableNtRam, _ntRamSelectBit, _irqEnabled, _irqSource, _lastPpuAddr, _irqCountDirection, _irqFunkyMode, _irqFunkyModeReg, _irqSmallPrescaler, - _irqPrescaler, _irqCounter, _irqXorReg, _multiplyValue1, _multiplyValue2, _regRamValue, prgRegs, chrLowRegs, chrHighRegs, ntLowRegs, ntHighRegs); + _irqPrescaler, _irqCounter, _irqXorReg, _multiplyValue1, _multiplyValue2, _regRamValue, prgRegs, chrLowRegs, chrHighRegs, ntLowRegs, ntHighRegs, + _prgBlock); if(!saving) { UpdateState(); @@ -143,33 +145,32 @@ class JyCompany : public BaseMapper void UpdatePrgState() { bool invertBits = (_prgMode & 0x03) == 0x03; - int prgRegs[4] = { InvertPrgBits(_prgRegs[0], invertBits), InvertPrgBits(_prgRegs[1], invertBits), - InvertPrgBits(_prgRegs[2], invertBits), InvertPrgBits(_prgRegs[3], invertBits) }; + uint8_t lastBank = (_prgMode & 0x04) ? _prgRegs[3] : 0x3F; switch(_prgMode & 0x03) { case 0: - SelectPrgPage4x(0, (_prgMode & 0x04) ? prgRegs[3] : 0x3C); + SelectPrgPage4x(0, ((lastBank & 0x0F) | (_prgBlock << 4)) << 2); if(_enablePrgAt6000) { - SetCpuMemoryMapping(0x6000, 0x7FFF, prgRegs[3] * 4 + 3, PrgMemoryType::PrgRom); + SetCpuMemoryMapping(0x6000, 0x7FFF, ((_prgRegs[3] * 4 + 3) & 0x3F) | (_prgBlock << 6), PrgMemoryType::PrgRom); } break; case 1: - SelectPrgPage2x(0, prgRegs[1] << 1); - SelectPrgPage2x(1, (_prgMode & 0x04) ? prgRegs[3] : 0x3E); + SelectPrgPage2x(0, ((_prgRegs[1] & 0x1F) | (_prgBlock << 5)) << 1); + SelectPrgPage2x(1, ((lastBank & 0x1F) | (_prgBlock << 5)) << 1); if(_enablePrgAt6000) { - SetCpuMemoryMapping(0x6000, 0x7FFF, prgRegs[3] * 2 + 1, PrgMemoryType::PrgRom); + SetCpuMemoryMapping(0x6000, 0x7FFF, ((_prgRegs[3] * 2 + 1) & 0x3F) | (_prgBlock << 6), PrgMemoryType::PrgRom); } break; case 2: case 3: - SelectPRGPage(0, prgRegs[0] | (_prgBlock << 5)); - SelectPRGPage(1, prgRegs[1] | (_prgBlock << 5)); - SelectPRGPage(2, prgRegs[2] | (_prgBlock << 5)); - SelectPRGPage(3, (_prgMode & 0x04) ? prgRegs[3] | (_prgBlock << 5) : 0x3F); + SelectPRGPage(0, (InvertPrgBits(_prgRegs[0], invertBits) & 0x3F) | (_prgBlock << 6)); + SelectPRGPage(1, (InvertPrgBits(_prgRegs[1], invertBits) & 0x3F) | (_prgBlock << 6)); + SelectPRGPage(2, (InvertPrgBits(_prgRegs[2], invertBits) & 0x3F) | (_prgBlock << 6)); + SelectPRGPage(3, (InvertPrgBits(lastBank, invertBits) & 0x3F) | (_prgBlock << 6)); if(_enablePrgAt6000) { - SetCpuMemoryMapping(0x6000, 0x7FFF, prgRegs[3], PrgMemoryType::PrgRom); + SetCpuMemoryMapping(0x6000, 0x7FFF, (_prgRegs[3] & 0x3F) | (_prgBlock << 6), PrgMemoryType::PrgRom); } break; } @@ -267,31 +268,8 @@ class JyCompany : public BaseMapper case 0x5801: _multiplyValue2 = value; break; case 0x5803: _regRamValue = value; break; } - } else { + } else if((addr >= 0xC000) && (addr < 0xD000)) { switch(addr & 0xF007) { - case 0x8000: case 0x8001: case 0x8002: case 0x8003: - case 0x8004: case 0x8005: case 0x8006: case 0x8007: - _prgRegs[addr & 0x03] = value & 0x7F; - break; - - case 0x9000: case 0x9001: case 0x9002: case 0x9003: - case 0x9004: case 0x9005: case 0x9006: case 0x9007: - _chrLowRegs[addr & 0x07] = value; - break; - - case 0xA000: case 0xA001: case 0xA002: case 0xA003: - case 0xA004: case 0xA005: case 0xA006: case 0xA007: - _chrHighRegs[addr & 0x07] = value; - break; - - case 0xB000: case 0xB001: case 0xB002: case 0xB003: - _ntLowRegs[addr & 0x03] = value; - break; - - case 0xB004: case 0xB005: case 0xB006: case 0xB007: - _ntHighRegs[addr & 0x03] = value; - break; - case 0xC000: if(value & 0x01) { _irqEnabled = true; @@ -318,6 +296,30 @@ class JyCompany : public BaseMapper case 0xC005: _irqCounter = value ^ _irqXorReg; break; case 0xC006: _irqXorReg = value; break; case 0xC007: _irqFunkyModeReg = value; break; + } + } else { + switch(addr & 0xF807) { + case 0x8000: case 0x8001: case 0x8002: case 0x8003: + _prgRegs[addr & 0x03] = value & 0x7F; + break; + + case 0x9000: case 0x9001: case 0x9002: case 0x9003: + case 0x9004: case 0x9005: case 0x9006: case 0x9007: + _chrLowRegs[addr & 0x07] = value; + break; + + case 0xA000: case 0xA001: case 0xA002: case 0xA003: + case 0xA004: case 0xA005: case 0xA006: case 0xA007: + _chrHighRegs[addr & 0x07] = value; + break; + + case 0xB000: case 0xB001: case 0xB002: case 0xB003: + _ntLowRegs[addr & 0x03] = value; + break; + + case 0xB004: case 0xB005: case 0xB006: case 0xB007: + _ntHighRegs[addr & 0x03] = value; + break; case 0xD000: _prgMode = value & 0x07; @@ -334,11 +336,7 @@ class JyCompany : public BaseMapper _mirrorChr = (value & 0x80) == 0x80; _chrBlockMode = (value & 0x20) == 0x00; _chrBlock = ((value & 0x18) >> 2) | (value & 0x01); - - if (_romInfo.MapperID == 35 || _romInfo.MapperID == 90 || _romInfo.MapperID == 209 || _romInfo.MapperID == 211) { - _prgBlock = value & 0x06; - } - + _prgBlock = (value & 0x06) >> 1; break; } @@ -429,4 +427,4 @@ class JyCompany : public BaseMapper } } } -}; \ No newline at end of file +}; From 5a3d4bd269a9e2dd0a5ae9faf5c59f7c8672fa5a Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 28 Feb 2022 12:26:44 +0800 Subject: [PATCH 04/45] Mapper 319 (Eh8813): Fixed latch write registers --- Core/Eh8813A.h | 55 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/Core/Eh8813A.h b/Core/Eh8813A.h index ab4d1f205..ff8c31617 100644 --- a/Core/Eh8813A.h +++ b/Core/Eh8813A.h @@ -5,7 +5,12 @@ class Eh8813A : public BaseMapper { private: + uint8_t _prgBank; + uint8_t _chrBank; bool _alterReadAddress; + bool _lock; + bool _horizontalMirorring; + bool _nrom128; protected: uint32_t GetDipSwitchCount() override { return 4; } @@ -15,19 +20,43 @@ class Eh8813A : public BaseMapper void InitMapper() override { - SetMirroringType(MirroringType::Vertical); + _lock = 0; + _nrom128 = 0; + _prgBank = 0; + _chrBank = 0; + _alterReadAddress = 0; + _horizontalMirorring = 0; + UpdateState(); } void Reset(bool softReset) override { - WriteRegister(0x8000, 0); - _alterReadAddress = false; + _lock = 0; + _nrom128 = 0; + _prgBank = 0; + _chrBank = 0; + _alterReadAddress = 0; + _horizontalMirorring = 0; + UpdateState(); } void StreamState(bool saving) override { BaseMapper::StreamState(saving); - Stream(_alterReadAddress); + Stream(_alterReadAddress, _prgBank, _chrBank, _lock, _horizontalMirorring, _nrom128); + } + + void UpdateState() + { + if (_nrom128) { + SelectPRGPage(0, _prgBank); + SelectPRGPage(1, _prgBank); + } else { + SelectPrgPage2x(0, _prgBank & 0x1E); + } + + SelectCHRPage(0, _chrBank); + SetMirroringType(_horizontalMirorring ? MirroringType::Horizontal : MirroringType::Vertical); } uint8_t ReadRegister(uint16_t addr) override @@ -40,17 +69,15 @@ class Eh8813A : public BaseMapper void WriteRegister(uint16_t addr, uint8_t value) override { - if((addr & 0x0100) == 0) { + if (_lock == false) { + _prgBank = addr & 0x3F; _alterReadAddress = (addr & 0x40) == 0x40; - - if(addr & 0x80) { - SelectPRGPage(0, addr & 0x07); - SelectPRGPage(1, addr & 0x07); - } else { - SelectPrgPage2x(0, addr & 0x06); - } - - SelectCHRPage(0, value & 0x0F); + _nrom128 = (addr & 0x80) == 0x80; + _lock = (addr & 0x100) == 0x100; + _chrBank = value & 0x7F; + _horizontalMirorring = (value & 0x80) == 0x80; } + _chrBank = (_chrBank & 0xFC) | (value & 0x03); + UpdateState(); } }; \ No newline at end of file From 48f08e016495fb0e7d59531c6551cc4d9a513dff Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 28 Feb 2022 15:16:18 +0800 Subject: [PATCH 05/45] UNIF: Assign some boards to existing ines mappers, Set UNL-8237 as 215.1, Replace Mapper 27 with UNIF CC-21 --- Core/MapperFactory.cpp | 7 +++++-- Core/UnifLoader.cpp | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 752258e5c..c7fefa0f7 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -336,7 +336,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 24: return new VRC6(VRCVariant::VRC6a); case 25: return new VRC2_4(); case 26: return new VRC6(VRCVariant::VRC6b); - case 27: return new VRC2_4(); + case 27: return new Cc21(); case 28: return new Action53(); case 29: return new SealieComputing(); case 30: return new UnRom512(); @@ -509,7 +509,10 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 212: return new Mapper212(); case 213: return new Mapper213(); case 214: return new Mapper214(); - case 215: return new MMC3_215(); + case 215: + if (romData.Info.SubMapperID == 1) + return new Unl8237A(); + return new MMC3_215(); case 216: return new Mapper216(); case 217: return new MMC3_217(); case 218: return new Mapper218(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index eb0196c67..bcdedc6ba 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -169,4 +169,8 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "DRIPGAME", 284 }, { "60311C", 289 }, { "CHINA_ER_SAN2", 19 }, //Appears to be a mapper 19 hack specific for VirtuaNES (which adds chinese text on top of the PPU's output), unknown if a board actually exists + { "STREETFIGTER-GAME4IN1", 49 }, + { "HP2018-A", 260 }, + { "JC-016-2", 205 }, + { "NEWSTAR-GRM070-8IN1", 333 }, }; \ No newline at end of file From 62ddfcbef38975f1ca3de3745977698cd0d2f8dd Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 28 Feb 2022 16:27:41 +0800 Subject: [PATCH 06/45] UNIF: Added support for BMC-S-2009 board (Mapper 434) --- Core/BmcS2009.h | 51 +++++++++++++++++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 3 +++ Core/UnifLoader.cpp | 1 + 5 files changed, 59 insertions(+) create mode 100644 Core/BmcS2009.h diff --git a/Core/BmcS2009.h b/Core/BmcS2009.h new file mode 100644 index 000000000..e0728f7b6 --- /dev/null +++ b/Core/BmcS2009.h @@ -0,0 +1,51 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class BmcS2009 : public BaseMapper +{ +private: + uint8_t _prgBank; + uint8_t _outerBank; + + +protected: + uint16_t GetPRGPageSize() override { return 0x4000; } + uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); + UpdateState(); + } + + void Reset(bool softReset) override + { + _prgBank = 0; + _outerBank = 0; + UpdateState(); + } + + void UpdateState() + { + SelectPRGPage(0, (_outerBank << 3) | (_prgBank & 0x07)); + SelectPRGPage(1, (_outerBank << 3) | 0x07); + SelectCHRPage(0, 0); + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_prgBank, _outerBank); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + _outerBank = value; + } else { + _prgBank = value; + } + UpdateState(); + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index aacba3127..989a0d481 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -549,6 +549,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 48f65df04..ef70cc887 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -766,6 +766,9 @@ Nes\Mappers + + Nes\Mappers + Nes\Mappers diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index c7fefa0f7..b6051f392 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -40,6 +40,7 @@ #include "BmcHpxx.h" #include "BmcK3046.h" #include "BmcNtd03.h" +#include "BmcS2009.h" #include "BnRom.h" #include "Bs5.h" #include "Caltron41.h" @@ -631,6 +632,8 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 366: return new BmcGn45(); + case 434: return new BmcS2009(); + case 513: return new Sachen9602(); //514-517 case 518: return new Dance2000(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index bcdedc6ba..ad72412e9 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -173,4 +173,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "HP2018-A", 260 }, { "JC-016-2", 205 }, { "NEWSTAR-GRM070-8IN1", 333 }, + { "S-2009", 434 }, }; \ No newline at end of file From 1f56bcd51b35ed6560235aa6efe11e67c1099ab3 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 28 Feb 2022 21:09:52 +0800 Subject: [PATCH 07/45] UNIF: Add BMC-10-24-C-A1 board (Mapper 327) --- Core/Bmc1024CA1.h | 65 ++++++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 2 +- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 Core/Bmc1024CA1.h diff --git a/Core/Bmc1024CA1.h b/Core/Bmc1024CA1.h new file mode 100644 index 000000000..2728c420a --- /dev/null +++ b/Core/Bmc1024CA1.h @@ -0,0 +1,65 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class Bmc1024CA1 : public MMC3 +{ +private: + uint8_t _exReg; + +protected: + uint16_t GetChrRamPageSize() override { return 0x400; } + uint32_t GetChrRamSize() override { return 0x2000; } + uint32_t GetWorkRamSize() override { return 0x2000; } + uint32_t GetWorkRamPageSize() override { return 0x2000; } + bool ForceWorkRamSize() override { return true; } + + void InitMapper() override + { + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); + _exReg = 0; + MMC3::InitMapper(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exReg); + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override + { + if (_exReg & 0x10) { + MMC3::SelectCHRPage(slot, page, ChrMemoryType::ChrRam); + } else if (_exReg & 0x20) { + MMC3::SelectCHRPage(slot, ((_exReg & 0x07) << 7) | (page & 0xFF)); + } else { + MMC3::SelectCHRPage(slot, ((_exReg & 0x07) << 7) | (page & 0x7F)); + } + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + if(_exReg & 0x08) { + MMC3::SelectPRGPage(slot, ((_exReg & 0x07) << 4) | (page & 0x1F)); + } else { + MMC3::SelectPRGPage(slot, ((_exReg & 0x07) << 4) | (page & 0x0F)); + } + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr <= 0x7FFF) { + if(CanWriteToWorkRam()) { + _workRam[addr - 0x6000] = value; + if ((_exReg & 0x07) == 0) { + _exReg = addr & 0x3F; + UpdatePrgMapping(); + UpdateChrMapping(); + } + } + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index b6051f392..5b6949b18 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -26,6 +26,7 @@ #include "Bmc64in1NoRepeat.h" #include "Bmc70in1.h" #include "Bmc190in1.h" +#include "Bmc1024CA1.h" #include "Bmc235.h" #include "Bmc255.h" #include "Bmc60311C.h" @@ -605,7 +606,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 323: return new FaridSlrom(); case 324: return new FaridUnrom(); case 325: return new MMC3_MaliSB(); - case 327: break; //10-24-C-A1 + case 327: return new Bmc1024CA1(); case 328: return new Rt01(); case 329: return new Edu2000(); //330 diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index ad72412e9..831adeedf 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -31,7 +31,6 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "CC-21", UnifBoards::Cc21 }, { "CITYFIGHT", 266 }, { "COOLBOY", 268 }, - { "10-24-C-A1", UnifBoards::UnknownBoard }, { "CNROM", 3 }, { "CPROM", 13 }, { "D1038", 59 }, @@ -174,4 +173,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "JC-016-2", 205 }, { "NEWSTAR-GRM070-8IN1", 333 }, { "S-2009", 434 }, + { "10-24-C-A1", 327 }, }; \ No newline at end of file From 134de5d984629ba77d71b9f0cf40931519933843 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Mon, 28 Feb 2022 23:08:45 +0800 Subject: [PATCH 08/45] UNIF: Add BMC-830134C board (Mapper 315) --- Core/Bmc830134C.h | 59 +++++++++++++++++++++++++++++++++++++++ Core/Core.vcxproj | 2 ++ Core/Core.vcxproj.filters | 6 ++++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 1 + 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 Core/Bmc830134C.h diff --git a/Core/Bmc830134C.h b/Core/Bmc830134C.h new file mode 100644 index 000000000..495843241 --- /dev/null +++ b/Core/Bmc830134C.h @@ -0,0 +1,59 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class Bmc830134C : public MMC3 +{ +private: + uint8_t _exReg; + +protected: + void InitMapper() override + { + _exReg = 0; + MMC3::InitMapper(); + AddRegisterRange(0x6800, 0x68FF, MemoryOperation::Write); + } + + void Reset(bool softReset) override + { + _exReg = 0; + MMC3::Reset(softReset); + UpdateState(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exReg); + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override + { + MMC3::SelectCHRPage(slot, ((_exReg & 0x01) << 8) | ((_exReg & 0x02) << 6) | ((_exReg & 0x08) << 3) | (page & 0xFF)); + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + if((_exReg & 0x06) == 0x06) { + if(slot == 0) { + MMC3::SelectPRGPage(0, ((_exReg & 0x06) << 3) | (page & 0x0F)); + MMC3::SelectPRGPage(2, 0x32 | (page & 0x0F)); + } else if (slot == 1) { + MMC3::SelectPRGPage(1, ((_exReg & 0x06) << 3) | (page & 0x0F)); + MMC3::SelectPRGPage(3, 0x32 | (page & 0x0F)); + } + } else + MMC3::SelectPRGPage(slot, ((_exReg & 0x06) << 3) | (page & 0x0F)); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + _exReg = value; + UpdateState(); + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 989a0d481..a7c9717a8 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -540,6 +540,8 @@ + + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index ef70cc887..ea45e723d 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -757,6 +757,12 @@ Nes\Mappers + + Nes\Mappers + + + Nes\Mappers + Nes\Mappers diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 5b6949b18..6eb7617d5 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -34,6 +34,7 @@ #include "Bmc80013B.h" #include "Bmc810544CA1.h" #include "Bmc830118C.h" +#include "Bmc830134C.h" #include "Bmc830425C4391T.h" #include "Bmc8in1.h" #include "BmcG146.h" @@ -597,7 +598,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 312: return new Kaiser7013B(); case 313: return new ResetTxrom(); case 314: return new Bmc64in1NoRepeat(); - case 315: break; //830134C + case 315: return new Bmc830134C(); //316-318 case 319: return new Hp898f(); case 320: return new Bmc830425C4391T(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 831adeedf..ed17e900e 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -174,4 +174,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "NEWSTAR-GRM070-8IN1", 333 }, { "S-2009", 434 }, { "10-24-C-A1", 327 }, + { "830134C", 315 }, }; \ No newline at end of file From 04ab01c81e2d0f9f6705cb5eb7530ad1971b7be8 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Tue, 1 Mar 2022 13:36:15 +0800 Subject: [PATCH 09/45] UNIF: Add BMC-CTC-09 board (Mapper 335) --- Core/BmcCtc09.h | 31 +++++++++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 3 ++- Core/UnifLoader.cpp | 1 + 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Core/BmcCtc09.h diff --git a/Core/BmcCtc09.h b/Core/BmcCtc09.h new file mode 100644 index 000000000..1f292e7a7 --- /dev/null +++ b/Core/BmcCtc09.h @@ -0,0 +1,31 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class BmcCtc09 : public BaseMapper +{ +protected: + uint16_t GetPRGPageSize() override { return 0x4000; } + uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + WriteRegister(0x8000, 0); + WriteRegister(0xC000, 0); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr >= 0xC000) { + if (value & 0x10) { + SelectPRGPage(0, ((value << 1) & 0x0E) | ((value >> 3) & 0x01)); + SelectPRGPage(1, ((value << 1) & 0x0E) | ((value >> 3) & 0x01)); + } else { + SelectPrgPage2x(0, (value & 0x07) << 1); + } + SetMirroringType(((value & 0x40) == 0x40) ? MirroringType::Horizontal : MirroringType::Vertical); + } else { + SelectCHRPage(0, value & 0x0F); + } + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index a7c9717a8..b96d4f0bc 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -552,6 +552,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index ea45e723d..9dcce3b2c 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -775,6 +775,9 @@ Nes\Mappers + + Nes\Mappers + Nes\Mappers diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 6eb7617d5..6e88a2b1d 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -43,6 +43,7 @@ #include "BmcK3046.h" #include "BmcNtd03.h" #include "BmcS2009.h" +#include "BmcCtc09.h" #include "BnRom.h" #include "Bs5.h" #include "Caltron41.h" @@ -615,7 +616,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 332: return new Super40in1Ws(); case 333: return new Bmc8in1(); // + NEWSTAR-GRM070-8IN1 //334 - case 335: break; //CTC-09 + case 335: return new BmcCtc09(); case 336: return new BmcK3046(); case 337: break; //CTC-12IN1 case 338: break; //SA005-A diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index ed17e900e..cb844cad9 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -175,4 +175,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "S-2009", 434 }, { "10-24-C-A1", 327 }, { "830134C", 315 }, + { "CTC-09", 335 }, }; \ No newline at end of file From 629243a4fa5ad658fb396e8b42c93bb4e80ff1ab Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 08:29:59 +0800 Subject: [PATCH 10/45] UNIF: Add BMC-GN-26 board (Mapper 344) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 ++ Core/MMC3_BmcGn26.h | 64 +++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 1 + 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Core/MMC3_BmcGn26.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index b96d4f0bc..7be0c3d69 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -812,6 +812,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 9dcce3b2c..26714f7cd 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1054,6 +1054,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MMC3_BmcGn26.h b/Core/MMC3_BmcGn26.h new file mode 100644 index 000000000..938efc322 --- /dev/null +++ b/Core/MMC3_BmcGn26.h @@ -0,0 +1,64 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class MMC3_BmcGn26 : public MMC3 +{ +private: + uint8_t _exReg; + +protected: + void InitMapper() override + { + _exReg = 0; + MMC3::InitMapper(); + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); + } + + void Reset(bool softreset) override + { + _exReg = 0; + UpdateState(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exReg); + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override + { + uint8_t mask = (_exReg & 0x04) ? 0xFF : 0x7F; + page &= mask; + page |= ((_exReg << 7) & ~mask); + MMC3::SelectCHRPage(slot, page, memoryType); + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + if (_exReg & 0x04) { + if (slot == 0) { + page >>= 2; + page |= (_exReg << 2); + SelectPrgPage4x(0, page << 2); + } + } else { + page &= 0x0F; + page |= (_exReg << 4); + MMC3::SelectPRGPage(slot, page); + } + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr <= 0x7FFF) { + if (CanWriteToWorkRam()) { + _exReg = (uint8_t)addr; + UpdateState(); + } + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 6e88a2b1d..370199e8f 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -191,6 +191,7 @@ #include "MMC3_254.h" #include "MMC3_Bmc411120C.h" #include "MMC3_BmcF15.h" +#include "MMC3_BmcGn26.h" #include "MMC3_ChrRam.h" #include "MMC3_Coolboy.h" #include "MMC3_Kof97.h" @@ -625,7 +626,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 341: break; //TJ-03 case 342: break; //COOLGIRL //343 - case 344: break; //GN26 + case 344: return new MMC3_BmcGn26(); case 345: break; //L6IN1 case 346: return new Kaiser7012(); //347 diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index cb844cad9..d927aac5e 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -176,4 +176,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "10-24-C-A1", 327 }, { "830134C", 315 }, { "CTC-09", 335 }, + { "GN-26", 344 }, }; \ No newline at end of file From 70d1cbd84d264ce1b53e25e294519e5cb0c6fbe1 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 10:39:09 +0800 Subject: [PATCH 11/45] Mapper 283: Handle both GS-2013/GS-2004 roms in the same mapper --- Core/Core.vcxproj | 3 +-- Core/Core.vcxproj.filters | 5 +---- Core/{Gs2004.h => Gs2004_Gs2013.h} | 8 ++++---- Core/Gs2013.h | 26 -------------------------- Core/MapperFactory.cpp | 6 ++---- Core/UnifLoader.cpp | 2 +- 6 files changed, 9 insertions(+), 41 deletions(-) rename Core/{Gs2004.h => Gs2004_Gs2013.h} (64%) delete mode 100644 Core/Gs2013.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 7be0c3d69..ac9919391 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -708,8 +708,7 @@ - - + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 26714f7cd..b841c109e 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -973,10 +973,7 @@ Nes\Mappers\Unif - - Nes\Mappers\Unif - - + Nes\Mappers\Unif diff --git a/Core/Gs2004.h b/Core/Gs2004_Gs2013.h similarity index 64% rename from Core/Gs2004.h rename to Core/Gs2004_Gs2013.h index e8be57ee4..f1fc0306a 100644 --- a/Core/Gs2004.h +++ b/Core/Gs2004_Gs2013.h @@ -2,7 +2,7 @@ #include "stdafx.h" #include "BaseMapper.h" -class Gs2004 : public BaseMapper +class Gs2004_Gs2013 : public BaseMapper { protected: uint16_t GetPRGPageSize() override { return 0x2000; } @@ -15,12 +15,12 @@ class Gs2004 : public BaseMapper void Reset(bool softReset) override { - SetCpuMemoryMapping(0x6000, 0x7FFF, 0x20, PrgMemoryType::PrgRom); - SelectPrgPage4x(0, 0x07 << 2); + SetCpuMemoryMapping(0x6000, 0x7FFF, (_prgSize & 0x6000) ? 0x20 : 0x1F, PrgMemoryType::PrgRom); + SelectPrgPage4x(0, 0); } void WriteRegister(uint16_t addr, uint8_t value) override { - SelectPrgPage4x(0, (value & 0x07) << 2); + SelectPrgPage4x(0, value << 2); } }; \ No newline at end of file diff --git a/Core/Gs2013.h b/Core/Gs2013.h deleted file mode 100644 index 646e59e48..000000000 --- a/Core/Gs2013.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "stdafx.h" -#include "BaseMapper.h" - -class Gs2013 : public BaseMapper -{ -protected: - uint16_t GetPRGPageSize() override { return 0x2000; } - uint16_t GetCHRPageSize() override { return 0x2000; } - - void InitMapper() override - { - SelectCHRPage(0, 0); - } - - void Reset(bool softReset) override - { - SetCpuMemoryMapping(0x6000, 0x7FFF, 0x1F, PrgMemoryType::PrgRom); - SelectPrgPage4x(0, 0x0F << 2); - } - - void WriteRegister(uint16_t addr, uint8_t value) override - { - SelectPrgPage4x(0, (value & 0x0F) << 2); - } -}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 370199e8f..107361d0e 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -69,8 +69,7 @@ #include "Ghostbusters63in1.h" #include "Gkcx1.h" #include "GoldenFive.h" -#include "Gs2004.h" -#include "Gs2013.h" +#include "Gs2004_Gs2013.h" #include "GxRom.h" #include "Henggedianzi177.h" #include "Henggedianzi179.h" @@ -571,7 +570,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) //272-273 case 274: return new Bmc80013B(); //275-282 - case 283: return new Gs2004(); + case 283: return new Gs2004_Gs2013(); case 284: return new UnlDripGame(); case 285: return new A65AS(); case 286: return new Bs5(); @@ -657,7 +656,6 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case UnifBoards::Ac08: return new Ac08(); //mapper 42? case UnifBoards::Cc21: return new Cc21(); case UnifBoards::Ghostbusters63in1: return new Ghostbusters63in1(); //mapper 226? - case UnifBoards::Gs2013: return new Gs2013(); case UnifBoards::Malee: return new Malee(); //mapper 42? case UnifBoards::SssNrom256: return new FamicomBox(); case UnifBoards::Unl255in1: return new Unl255in1(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index d927aac5e..74f048fcd 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -50,7 +50,7 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "G-146", 349 }, { "GK-192", 58 }, { "GS-2004", 283 }, - { "GS-2013", UnifBoards::Gs2013 }, + { "GS-2013", 283 }, { "Ghostbusters63in1", UnifBoards::Ghostbusters63in1 }, { "H2288", 123 }, { "HKROM", 4 }, From 899f14f7f25636747fd51fc39ac75bb9d5a5d522 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 12:36:17 +0800 Subject: [PATCH 12/45] UNIF: Add BMC-K-3006 board (Mapper 339) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 ++ Core/MMC3_BmcK3006.h | 63 +++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 1 + 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 Core/MMC3_BmcK3006.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index ac9919391..e9c087bb0 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -812,6 +812,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index b841c109e..a05be00e6 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1054,6 +1054,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MMC3_BmcK3006.h b/Core/MMC3_BmcK3006.h new file mode 100644 index 000000000..64df27acc --- /dev/null +++ b/Core/MMC3_BmcK3006.h @@ -0,0 +1,63 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class MMC3_BmcK3006 : public MMC3 +{ +private: + uint8_t _exReg; + +protected: + void InitMapper() override + { + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); + _exReg = 0; + + MMC3::InitMapper(); + } + + void Reset(bool softreset) override + { + _exReg = 0; + UpdateState(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exReg); + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override + { + MMC3::SelectCHRPage(slot, (page & 0x7F) | ((_exReg << 4) & ~0x7F)); + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + if (_exReg & 0x20) { // MMC3 mode + MMC3::SelectPRGPage(slot, (page & 0x0F) | ((_exReg << 1) & ~0x0F)); + } else { + uint8_t bank = (_exReg & 0x1F); + if ((_exReg & 0x07) == 0x06) { // NROM-256 + SelectPrgPage4x(0, (bank & 0xFE) << 1); + } else { // NROM-128 + SelectPrgPage2x(0, bank << 1); + SelectPrgPage2x(1, bank << 1); + } + } + + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + if(CanWriteToWorkRam()) { + _exReg = (uint8_t)addr; + UpdateState(); + } + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 107361d0e..bb3cc0f60 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -191,6 +191,7 @@ #include "MMC3_Bmc411120C.h" #include "MMC3_BmcF15.h" #include "MMC3_BmcGn26.h" +#include "MMC3_BmcK3006.h" #include "MMC3_ChrRam.h" #include "MMC3_Coolboy.h" #include "MMC3_Kof97.h" @@ -620,7 +621,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 336: return new BmcK3046(); case 337: break; //CTC-12IN1 case 338: break; //SA005-A - case 339: break; //K-3006 + case 339: return new MMC3_BmcK3006(); case 340: break; //K-3036 case 341: break; //TJ-03 case 342: break; //COOLGIRL diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 74f048fcd..ff7716380 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -177,4 +177,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "830134C", 315 }, { "CTC-09", 335 }, { "GN-26", 344 }, + { "K-3006", 339 }, }; \ No newline at end of file From 0a57fe2213de50b3e46d968e9974b344cd029d3e Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 13:37:30 +0800 Subject: [PATCH 13/45] UNIF: Add BMC-K-3033 board (Mapper 322) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 ++ Core/MMC3_BmcK3033.h | 76 +++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 1 + 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 Core/MMC3_BmcK3033.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index e9c087bb0..32dbceeb7 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -813,6 +813,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index a05be00e6..f0672b848 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1057,6 +1057,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MMC3_BmcK3033.h b/Core/MMC3_BmcK3033.h new file mode 100644 index 000000000..5aa257801 --- /dev/null +++ b/Core/MMC3_BmcK3033.h @@ -0,0 +1,76 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class MMC3_BmcK3033 : public MMC3 +{ +private: + uint8_t _exReg; + +protected: + void InitMapper() override + { + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); + _exReg = 0; + + MMC3::InitMapper(); + } + + void Reset(bool softreset) override + { + _exReg = 0; + UpdateState(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exReg); + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override + { + uint8_t outerBank = ((_exReg & 0x18) >> 3) | ((_exReg & 0x40) >> 4); + if(_exReg & 0x20) { + if(_exReg & 0x80) { // MMC3 256 KiB + MMC3::SelectCHRPage(slot, (page & 0xFF) | (outerBank << 8)); + } else { // MMC3 128 KiB + MMC3::SelectCHRPage(slot, (page & 0x7F) | (outerBank << 7)); + } + } else { // NROM mode + MMC3::SelectCHRPage(slot, (page & 0x7F)); + } + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + uint8_t outerBank = ((_exReg & 0x18) >> 3) | ((_exReg & 0x40) >> 4); + if(_exReg & 0x20) { + if (_exReg & 0x80) { // MMC3 256 KiB + MMC3::SelectPRGPage(slot, (page & 0x1F) | (outerBank << 5)); + } else { // MMC3 128 KiB + MMC3::SelectPRGPage(slot, (page & 0x0F) | (outerBank << 4)); + } + } else { + uint8_t innerBank = _exReg & 7; + if(innerBank & 3) { // NROM-256 + SelectPrgPage4x(0, (((outerBank << 3) | innerBank) & 0xFE) << 1); + } else { // NROM-128 + SelectPrgPage2x(0, ((outerBank << 3) | innerBank) << 1); + SelectPrgPage2x(1, ((outerBank << 3) | innerBank) << 1); + } + } + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + if(CanWriteToWorkRam()) { + _exReg = (uint8_t)addr; + UpdateState(); + } + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index bb3cc0f60..4dcfa4c23 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -192,6 +192,7 @@ #include "MMC3_BmcF15.h" #include "MMC3_BmcGn26.h" #include "MMC3_BmcK3006.h" +#include "MMC3_BmcK3033.h" #include "MMC3_ChrRam.h" #include "MMC3_Coolboy.h" #include "MMC3_Kof97.h" @@ -605,7 +606,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 319: return new Hp898f(); case 320: return new Bmc830425C4391T(); //321 - case 322: break; //K-3033 + case 322: return new MMC3_BmcK3033(); case 323: return new FaridSlrom(); case 324: return new FaridUnrom(); case 325: return new MMC3_MaliSB(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index ff7716380..3a77afe9c 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -178,4 +178,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "CTC-09", 335 }, { "GN-26", 344 }, { "K-3006", 339 }, + { "K-3033", 322 }, }; \ No newline at end of file From 63ae113d5fbc42117f530785ac04c82fdaebb03d Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 14:04:04 +0800 Subject: [PATCH 14/45] UNIF: Add BMC-K-3036 board (Mapper 340) --- Core/BmcK3036.h | 34 ++++++++++++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 3 ++- Core/UnifLoader.cpp | 1 + 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Core/BmcK3036.h diff --git a/Core/BmcK3036.h b/Core/BmcK3036.h new file mode 100644 index 000000000..00f659a6c --- /dev/null +++ b/Core/BmcK3036.h @@ -0,0 +1,34 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class BmcK3036 : public BaseMapper +{ +protected: + virtual uint16_t GetPRGPageSize() override { return 0x4000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + WriteRegister(0x8000, 0); + } + + void Reset(bool softReset) override + { + BaseMapper::Reset(softReset); + WriteRegister(0x8000, 0); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if (addr & 0x20) { // NROM-128 + SelectPRGPage(0, addr & 0x1F); + SelectPRGPage(1, addr & 0x1F); + } else { // UNROM + SelectPRGPage(0, (addr & 0x1F) | (value & 0x07)); + SelectPRGPage(1, (addr & 0x1F) | 0x07); + } + SelectCHRPage(0, 0, ChrMemoryType::ChrRam); + SetMirroringType(((addr & 0x25) == 0x25) ? MirroringType::Horizontal : MirroringType::Vertical); + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 32dbceeb7..0e11be8cb 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -548,6 +548,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index f0672b848..90f1ed2e6 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -778,6 +778,9 @@ Nes\Mappers + + Nes\Mappers + Nes\Mappers diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 4dcfa4c23..12ba5aed1 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -37,6 +37,7 @@ #include "Bmc830134C.h" #include "Bmc830425C4391T.h" #include "Bmc8in1.h" +#include "BmcK3036.h" #include "BmcG146.h" #include "BmcGn45.h" #include "BmcHpxx.h" @@ -623,7 +624,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 337: break; //CTC-12IN1 case 338: break; //SA005-A case 339: return new MMC3_BmcK3006(); - case 340: break; //K-3036 + case 340: return new BmcK3036(); case 341: break; //TJ-03 case 342: break; //COOLGIRL //343 diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 3a77afe9c..e70f41bbd 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -179,4 +179,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "GN-26", 344 }, { "K-3006", 339 }, { "K-3033", 322 }, + { "K-3036", 340 }, }; \ No newline at end of file From f945a19bde5de8bc23ae53acc2a5bf050cb1dcaa Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 17:45:48 +0800 Subject: [PATCH 15/45] UNIF: Add BMC-L6IN1 board (Mapper 345) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 ++ Core/MMC3_BmcL6in1.h | 62 +++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 1 + 5 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Core/MMC3_BmcL6in1.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 0e11be8cb..155c8fe5f 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -815,6 +815,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 90f1ed2e6..bd9602f34 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1063,6 +1063,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MMC3_BmcL6in1.h b/Core/MMC3_BmcL6in1.h new file mode 100644 index 000000000..ad5ee36f8 --- /dev/null +++ b/Core/MMC3_BmcL6in1.h @@ -0,0 +1,62 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class MMC3_BmcL6in1 : public MMC3 +{ +private: + uint8_t _exReg; + +protected: + void InitMapper() override + { + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); + _exReg = 0; + + MMC3::InitMapper(); + } + + void Reset(bool softreset) override + { + _exReg = 0; + UpdateState(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exReg); + } + + void UpdateMirroring() override + { + if(_exReg & 0x20) { + SetMirroringType((_exReg & 0x10) ? MirroringType::ScreenBOnly : MirroringType::ScreenAOnly); + } else { + MMC3::UpdateMirroring(); + } + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + if(_exReg & 0x0C) { + MMC3::SelectPRGPage(slot, (page & 0x0F) | (_exReg & 0xC0) >> 2); + } else { + uint8_t bank = ((_exReg & 0xC0) >> 4) | (_exReg & 0x03); + SelectPrgPage4x(0, bank << 2); + } + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + if(CanWriteToWorkRam()) { + _exReg = value; + UpdatePrgMapping(); + UpdateMirroring(); + } + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 12ba5aed1..375e9c0e2 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -194,6 +194,7 @@ #include "MMC3_BmcGn26.h" #include "MMC3_BmcK3006.h" #include "MMC3_BmcK3033.h" +#include "MMC3_BmcL6in1.h" #include "MMC3_ChrRam.h" #include "MMC3_Coolboy.h" #include "MMC3_Kof97.h" @@ -629,7 +630,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 342: break; //COOLGIRL //343 case 344: return new MMC3_BmcGn26(); - case 345: break; //L6IN1 + case 345: return new MMC3_BmcL6in1(); case 346: return new Kaiser7012(); //347 case 348: return new Bmc830118C(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index e70f41bbd..a7ad52dc4 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -180,4 +180,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "K-3006", 339 }, { "K-3033", 322 }, { "K-3036", 340 }, + { "L6IN1", 345 }, }; \ No newline at end of file From d3fa903da9dba1384628692b843283ca3cfffd8f Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 18:38:35 +0800 Subject: [PATCH 16/45] UNIF: Add BMC-SA005-A board (Mapper 338) --- Core/BmcSa005A.h | 29 +++++++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 3 ++- Core/UnifLoader.cpp | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Core/BmcSa005A.h diff --git a/Core/BmcSa005A.h b/Core/BmcSa005A.h new file mode 100644 index 000000000..3cfd21c44 --- /dev/null +++ b/Core/BmcSa005A.h @@ -0,0 +1,29 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +// INES Mapper 200 is similar but with the mirroring bit's meaning flipped, and the mirroring bit being also used as a fourth bank bit. + +class BmcSa005A : public BaseMapper +{ +protected: + virtual uint16_t GetPRGPageSize() override { return 0x4000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + SelectPRGPage(0, 0); + SelectPRGPage(1, 0); + SelectCHRPage(0, 0); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + uint8_t bank = addr & 0x0F; + SelectPRGPage(0, bank); + SelectPRGPage(1, bank); + SelectCHRPage(0, bank); + + SetMirroringType(addr & 0x08 ? MirroringType::Vertical : MirroringType::Horizontal); + } +}; diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 155c8fe5f..d4f1b84d7 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -553,6 +553,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index bd9602f34..a5a1a14ca 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1003,6 +1003,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 375e9c0e2..cfc834ab0 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -44,6 +44,7 @@ #include "BmcK3046.h" #include "BmcNtd03.h" #include "BmcS2009.h" +#include "BmcSa005A.h" #include "BmcCtc09.h" #include "BnRom.h" #include "Bs5.h" @@ -623,7 +624,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 335: return new BmcCtc09(); case 336: return new BmcK3046(); case 337: break; //CTC-12IN1 - case 338: break; //SA005-A + case 338: return new BmcSa005A(); case 339: return new MMC3_BmcK3006(); case 340: return new BmcK3036(); case 341: break; //TJ-03 diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index a7ad52dc4..b35ac2f15 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -181,4 +181,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "K-3033", 322 }, { "K-3036", 340 }, { "L6IN1", 345 }, + { "SA005-A", 338 }, }; \ No newline at end of file From a4b4d49ac4b6eb064590697b6470272f91d62408 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 18:59:26 +0800 Subject: [PATCH 17/45] Mapper 200: Fixed mirroring --- Core/Mapper200.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Mapper200.h b/Core/Mapper200.h index aa6ec7c47..dca15ee5e 100644 --- a/Core/Mapper200.h +++ b/Core/Mapper200.h @@ -22,6 +22,6 @@ class Mapper200 : public BaseMapper SelectPRGPage(1, bank); SelectCHRPage(0, bank); - SetMirroringType(addr & 0x08 ? MirroringType::Vertical : MirroringType::Horizontal); + SetMirroringType(addr & 0x08 ? MirroringType::Horizontal : MirroringType::Vertical); } }; From 61aad865ec55d2f2e588f9e42bbf36e624a7613a Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 19:24:48 +0800 Subject: [PATCH 18/45] UNIF: Add BMC-TJ-03 board (Mapper 341) --- Core/BmcTj03.h | 25 +++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 3 ++- Core/UnifLoader.cpp | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Core/BmcTj03.h diff --git a/Core/BmcTj03.h b/Core/BmcTj03.h new file mode 100644 index 000000000..5459b7ec0 --- /dev/null +++ b/Core/BmcTj03.h @@ -0,0 +1,25 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class BmcTj03 : public BaseMapper +{ +protected: + virtual uint16_t GetPRGPageSize() override { return 0x8000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + SelectPRGPage(0, 0); + SelectCHRPage(0, 0); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + uint8_t bank = (addr >> 8) & 0x07; + SelectPRGPage(0, bank); + SelectCHRPage(0, bank); + + SetMirroringType(addr & 0x200 ? MirroringType::Horizontal : MirroringType::Vertical); + } +}; diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index d4f1b84d7..77b6dd448 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -554,6 +554,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index a5a1a14ca..fb4dd3e68 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1006,6 +1006,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index cfc834ab0..7a940d134 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -45,6 +45,7 @@ #include "BmcNtd03.h" #include "BmcS2009.h" #include "BmcSa005A.h" +#include "BmcTj03.h" #include "BmcCtc09.h" #include "BnRom.h" #include "Bs5.h" @@ -627,7 +628,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 338: return new BmcSa005A(); case 339: return new MMC3_BmcK3006(); case 340: return new BmcK3036(); - case 341: break; //TJ-03 + case 341: return new BmcTj03(); case 342: break; //COOLGIRL //343 case 344: return new MMC3_BmcGn26(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index b35ac2f15..7d3e4c77d 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -182,4 +182,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "K-3036", 340 }, { "L6IN1", 345 }, { "SA005-A", 338 }, + { "TJ-03", 341 }, }; \ No newline at end of file From ffa913430c2cc167ad3343a16ed28533a00a81bf Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 2 Mar 2022 21:41:56 +0800 Subject: [PATCH 19/45] UNIF: Add BMC-TH2131-1 board (Mapper 308) --- Core/MapperFactory.cpp | 2 +- Core/UnifLoader.cpp | 1 + Core/VRC2_4.h | 33 +++++++++++++++++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 7a940d134..a7abca32a 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -599,7 +599,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 305: return new Kaiser7031(); case 306: return new Kaiser7016(); case 307: return new Kaiser7037(); - case 308: break; //TH2131-1 + case 308: return new VRC2_4(); case 309: return new Lh51(); //310-311 case 312: return new Kaiser7013B(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 7d3e4c77d..8e17d77c6 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -183,4 +183,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "L6IN1", 345 }, { "SA005-A", 338 }, { "TJ-03", 341 }, + { "TH2131-1", 308 }, }; \ No newline at end of file diff --git a/Core/VRC2_4.h b/Core/VRC2_4.h index 39b809198..606c08b6b 100644 --- a/Core/VRC2_4.h +++ b/Core/VRC2_4.h @@ -7,6 +7,7 @@ enum class VRCVariant { VRC2a, //Mapper 22 VRC2b, //23 + VRC2b_308, //308 VRC2c, //25 VRC4a, //21 VRC4b, //25 @@ -34,6 +35,11 @@ class VRC2_4 : public BaseMapper uint8_t _latch = 0; + // Mapper 308 IRQ + uint16_t _irqCounter; + uint8_t _irqCounterHigh; + bool _irqEnabled; + void DetectVariant() { switch(_romInfo.MapperID) { @@ -72,9 +78,10 @@ class VRC2_4 : public BaseMapper break; case 27: _variant = VRCVariant::VRC4_27; break; //Untested + case 308: _variant = VRCVariant::VRC2b_308; break; } - _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27; + _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308; } protected: @@ -109,7 +116,15 @@ class VRC2_4 : public BaseMapper void ProcessCpuClock() override { - if((_useHeuristics && _romInfo.MapperID != 22) || _variant >= VRCVariant::VRC4a) { + if(_variant == VRCVariant::VRC2b_308) { + if(_irqEnabled) { + _irqCounter++; + if((_irqCounter & 0x0FFF) == 2048) + _irqCounterHigh--; + if(!_irqCounterHigh && (_irqCounter & 0x0FFF) < 2048) + _console->GetCpu()->SetIrqSource(IRQSource::External); + } + } else if((_useHeuristics && _romInfo.MapperID != 22) || _variant >= VRCVariant::VRC4a) { //Only VRC4 supports IRQs _irq->ProcessCpuClock(); } @@ -184,6 +199,16 @@ class VRC2_4 : public BaseMapper //One reg contains the high 5 bits _hiCHRRegs[regNumber] = value & 0x1F; } + } else if(_variant == VRCVariant::VRC2b_308) { + if(addr == 0xF000) { + _irqEnabled = false; + _irqCounter = 0; + _console->GetCpu()->ClearIrqSource(IRQSource::External); + } else if(addr == 0xF001) { + _irqEnabled = true; + } else if(addr == 0xF003) { + _irqCounterHigh = value >> 4; + } } else if(addr == 0xF000) { _irq->SetReloadValueNibble(value, false); } else if(addr == 0xF001) { @@ -197,7 +222,7 @@ class VRC2_4 : public BaseMapper UpdateState(); } - public: + public: uint16_t TranslateAddress(uint16_t addr) { uint32_t A0, A1; @@ -284,6 +309,7 @@ class VRC2_4 : public BaseMapper break; case VRCVariant::VRC2b: + case VRCVariant::VRC2b_308: //Mapper 23 A0 = addr & 0x01; A1 = (addr >> 1) & 0x01; @@ -299,7 +325,6 @@ class VRC2_4 : public BaseMapper throw std::runtime_error("not supported"); break; } - } return (addr & 0xFF00) | (A1 << 1) | A0; From 09ec7f8833c024fdb53f8d026d7320098ff18cd4 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 10:15:27 +0800 Subject: [PATCH 20/45] UNIF: Add BTL-900218 board (Mapper 524) --- Core/MapperFactory.cpp | 2 +- Core/UnifLoader.cpp | 1 + Core/VRC2_4.h | 54 +++++++++++++++++++++++++++++++----------- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index a7abca32a..dfb3fa84c 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -651,7 +651,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 521: return new DreamTech01(); case 522: return new Lh10(); //523 - case 524: break; //900218 + case 524: return new VRC2_4(); case 525: break; //KS7021A case 526: break; //BJ56 case 527: break; //AX40G diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 8e17d77c6..6515ae0e8 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -184,4 +184,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "SA005-A", 338 }, { "TJ-03", 341 }, { "TH2131-1", 308 }, + { "900218", 524 }, }; \ No newline at end of file diff --git a/Core/VRC2_4.h b/Core/VRC2_4.h index 606c08b6b..145e8cd72 100644 --- a/Core/VRC2_4.h +++ b/Core/VRC2_4.h @@ -5,9 +5,10 @@ enum class VRCVariant { + VRC2_308, //308 + VRC2_524, //308 VRC2a, //Mapper 22 VRC2b, //23 - VRC2b_308, //308 VRC2c, //25 VRC4a, //21 VRC4b, //25 @@ -78,10 +79,11 @@ class VRC2_4 : public BaseMapper break; case 27: _variant = VRCVariant::VRC4_27; break; //Untested - case 308: _variant = VRCVariant::VRC2b_308; break; + case 308: _variant = VRCVariant::VRC2_308; break; + case 524: _variant = VRCVariant::VRC2_524; break; } - _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308; + _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308 && _romInfo.MapperID != 524; } protected: @@ -116,7 +118,7 @@ class VRC2_4 : public BaseMapper void ProcessCpuClock() override { - if(_variant == VRCVariant::VRC2b_308) { + if(_variant == VRCVariant::VRC2_308) { if(_irqEnabled) { _irqCounter++; if((_irqCounter & 0x0FFF) == 2048) @@ -124,6 +126,12 @@ class VRC2_4 : public BaseMapper if(!_irqCounterHigh && (_irqCounter & 0x0FFF) < 2048) _console->GetCpu()->SetIrqSource(IRQSource::External); } + } else if(_variant == VRCVariant::VRC2_524) { + if(_irqEnabled) { + _irqCounter++; + if(_irqCounter & 1024) + _console->GetCpu()->SetIrqSource(IRQSource::External); + } } else if((_useHeuristics && _romInfo.MapperID != 22) || _variant >= VRCVariant::VRC4a) { //Only VRC4 supports IRQs _irq->ProcessCpuClock(); @@ -199,7 +207,7 @@ class VRC2_4 : public BaseMapper //One reg contains the high 5 bits _hiCHRRegs[regNumber] = value & 0x1F; } - } else if(_variant == VRCVariant::VRC2b_308) { + } else if(_variant == VRCVariant::VRC2_308) { if(addr == 0xF000) { _irqEnabled = false; _irqCounter = 0; @@ -209,14 +217,24 @@ class VRC2_4 : public BaseMapper } else if(addr == 0xF003) { _irqCounterHigh = value >> 4; } - } else if(addr == 0xF000) { - _irq->SetReloadValueNibble(value, false); - } else if(addr == 0xF001) { - _irq->SetReloadValueNibble(value, true); - } else if(addr == 0xF002) { - _irq->SetControlValue(value); - } else if(addr == 0xF003) { - _irq->AcknowledgeIrq(); + } else if(_variant == VRCVariant::VRC2_524) { + if(addr == 0xF002) { + _irqEnabled = true; + } else if(addr == 0xF003) { + _irqEnabled = false; + _irqCounter = 0; + _console->GetCpu()->ClearIrqSource(IRQSource::External); + } + } else { + if(addr == 0xF000) { + _irq->SetReloadValueNibble(value, false); + } else if(addr == 0xF001) { + _irq->SetReloadValueNibble(value, true); + } else if(addr == 0xF002) { + _irq->SetControlValue(value); + } else if(addr == 0xF003) { + _irq->AcknowledgeIrq(); + } } UpdateState(); @@ -278,10 +296,19 @@ class VRC2_4 : public BaseMapper break; case VRCVariant::VRC4_27: + case VRCVariant::VRC2_308: //Mapper 27 A0 = addr & 0x01; A1 = (addr >> 1) & 0x01; break; + + case VRCVariant::VRC2_524: + //Mapper 524 + A0 = addr & 0x01; + A1 = (addr >> 1) & 0x01; + A0 |= (addr >> 2) & 0x01; + A1 |= (addr >> 3) & 0x01; + break; case VRCVariant::VRC2c: case VRCVariant::VRC4b: @@ -309,7 +336,6 @@ class VRC2_4 : public BaseMapper break; case VRCVariant::VRC2b: - case VRCVariant::VRC2b_308: //Mapper 23 A0 = addr & 0x01; A1 = (addr >> 1) & 0x01; From de2dee6cc1c11a96d454dc0062c0bfddf00558f0 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 12:10:22 +0800 Subject: [PATCH 21/45] Add missing save state variables --- Core/VRC2_4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/VRC2_4.h b/Core/VRC2_4.h index 145e8cd72..82f542288 100644 --- a/Core/VRC2_4.h +++ b/Core/VRC2_4.h @@ -362,6 +362,6 @@ class VRC2_4 : public BaseMapper ArrayInfo loChrRegs = { _loCHRRegs, 8 }; ArrayInfo hiChrRegs = { _hiCHRRegs, 8 }; SnapshotInfo irq{ _irq.get() }; - Stream(_prgReg0, _prgReg1, _prgMode, loChrRegs, hiChrRegs, _latch, irq); + Stream(_prgReg0, _prgReg1, _prgMode, loChrRegs, hiChrRegs, _latch, irq, _irqCounter, _irqCounterHigh, _irqEnabled); } }; \ No newline at end of file From 6564cb7cd14affdd36641f70051aa2e77e724e88 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 16:35:00 +0800 Subject: [PATCH 22/45] UNIF: Add BTL-831128C board (Mapper 528) --- Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 1 + Core/Unl831128C.h | 79 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 Core/Unl831128C.h diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index dfb3fa84c..890dbaa53 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -261,6 +261,7 @@ #include "Unl158B.h" #include "Unl255in1.h" #include "Unl8237A.h" +#include "Unl831128C.h" #include "UnlD1038.h" #include "UnlDripGame.h" #include "UnlPci556.h" @@ -655,7 +656,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 525: break; //KS7021A case 526: break; //BJ56 case 527: break; //AX40G - case 528: break; //831128C + case 528: return new Unl831128C(); case 529: return new T230(); case 530: return new Ax5705(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 6515ae0e8..937876b9d 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -185,4 +185,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "TJ-03", 341 }, { "TH2131-1", 308 }, { "900218", 524 }, + { "831128C", 528 }, }; \ No newline at end of file diff --git a/Core/Unl831128C.h b/Core/Unl831128C.h new file mode 100644 index 000000000..6d359cd9f --- /dev/null +++ b/Core/Unl831128C.h @@ -0,0 +1,79 @@ +#pragma once +#include "stdafx.h" +#include "VrcIrq.h" + +class Unl831128C : public BaseMapper +{ +private: + unique_ptr _irq; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x2000; } + virtual uint16_t GetCHRPageSize() override { return 0x400; } + virtual uint32_t GetWorkRamSize() override { return 0x8000; } + virtual uint32_t GetWorkRamPageSize() override { return 0x2000; } + + void InitMapper() override + { + _irq.reset(new VrcIrq(_console)); + + SelectPRGPage(2, -2); + SelectPRGPage(3, -1); + + RemoveRegisterRange(0x8000, 0x9FFF, MemoryOperation::Write); + RemoveRegisterRange(0xD000, 0xFFFF, MemoryOperation::Write); + } + + void ProcessCpuClock() override + { + _irq->ProcessCpuClock(); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + uint8_t gameReg = (addr >> 10) & 0x10; + uint8_t prgMask = 0x0F | gameReg; + + switch(addr & 0xF) { + case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: + SelectCHRPage(addr & 0x07, value + (gameReg << 4)); + break; + + case 8: + if (value == 1) { + SetCpuMemoryMapping(0x6000, 0x7FFF, 0, PrgMemoryType::WorkRam, MemoryAccessType::ReadWrite); + } else { + SetCpuMemoryMapping(0x6000, 0x7FFF, (value & prgMask) + gameReg, PrgMemoryType::PrgRom); + } + break; + + case 9: case 0xA: + SelectPRGPage((addr >> 1) & 0x01, (value & prgMask) + gameReg); + break; + + case 0xC: + switch(value & 0x03) { + case 0: SetMirroringType(MirroringType::Vertical); break; + case 1: SetMirroringType(MirroringType::Horizontal); break; + case 2: SetMirroringType(MirroringType::ScreenAOnly); break; + case 3: SetMirroringType(MirroringType::ScreenBOnly); break; + } + break; + + case 0xD: + _irq->SetControlValue(value); + break; + + case 0xE: + _irq->AcknowledgeIrq(); + break; + + case 0xF: + _irq->SetReloadValue(value); + break; + } + + SelectPRGPage(2, (-2 & prgMask) + gameReg); + SelectPRGPage(3, (-1 & prgMask) + gameReg); + } +}; \ No newline at end of file From 2cfe2b98c504dbdeb9fca96a10a5f7290900d389 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 18:57:29 +0800 Subject: [PATCH 23/45] UNIF: Add BTL-AX-40G board (Mapper 527) --- Core/MapperFactory.cpp | 2 +- Core/UnifLoader.cpp | 1 + Core/VRC2_4.h | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 890dbaa53..8e7a6b5c2 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -655,7 +655,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 524: return new VRC2_4(); case 525: break; //KS7021A case 526: break; //BJ56 - case 527: break; //AX40G + case 527: return new VRC2_4(); case 528: return new Unl831128C(); case 529: return new T230(); case 530: return new Ax5705(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 937876b9d..ae4745ce8 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -186,4 +186,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "TH2131-1", 308 }, { "900218", 524 }, { "831128C", 528 }, + { "AX-40G", 527 }, }; \ No newline at end of file diff --git a/Core/VRC2_4.h b/Core/VRC2_4.h index 82f542288..46fdae6f9 100644 --- a/Core/VRC2_4.h +++ b/Core/VRC2_4.h @@ -6,7 +6,8 @@ enum class VRCVariant { VRC2_308, //308 - VRC2_524, //308 + VRC2_524, //524 + VRC2_527, //527 VRC2a, //Mapper 22 VRC2b, //23 VRC2c, //25 @@ -81,9 +82,10 @@ class VRC2_4 : public BaseMapper case 27: _variant = VRCVariant::VRC4_27; break; //Untested case 308: _variant = VRCVariant::VRC2_308; break; case 524: _variant = VRCVariant::VRC2_524; break; + case 527: _variant = VRCVariant::VRC2_527; break; } - _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308 && _romInfo.MapperID != 524; + _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308 && _romInfo.MapperID != 524 && _romInfo.MapperID != 527; } protected: @@ -149,6 +151,13 @@ class VRC2_4 : public BaseMapper SelectCHRPage(i, page); } + if(_variant == VRCVariant::VRC2_527) { + SetNametable(0, (_hiCHRRegs[0] >> 3) & 0x01); + SetNametable(1, (_hiCHRRegs[0] >> 3) & 0x01); + SetNametable(2, (_hiCHRRegs[1] >> 3) & 0x01); + SetNametable(3, (_hiCHRRegs[1] >> 3) & 0x01); + } + if(_prgMode == 0) { SelectPRGPage(0, _prgReg0); SelectPRGPage(1, _prgReg1); @@ -297,6 +306,7 @@ class VRC2_4 : public BaseMapper case VRCVariant::VRC4_27: case VRCVariant::VRC2_308: + case VRCVariant::VRC2_527: //Mapper 27 A0 = addr & 0x01; A1 = (addr >> 1) & 0x01; From ecda16283f0367783da6158ffe990a1a0a6fcccd Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 20:13:07 +0800 Subject: [PATCH 24/45] UNIF: Add UNL-BJ-56 board (Mapper 526) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 ++ Core/MapperFactory.cpp | 3 +- Core/UnifLoader.cpp | 2 +- Core/UnlBj56.h | 60 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 Core/UnlBj56.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 77b6dd448..39ba9d3ab 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -960,6 +960,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index fb4dd3e68..a58ff36f8 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1144,6 +1144,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + Nes\Mappers diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 8e7a6b5c2..59534ac1f 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -262,6 +262,7 @@ #include "Unl255in1.h" #include "Unl8237A.h" #include "Unl831128C.h" +#include "UnlBj56.h" #include "UnlD1038.h" #include "UnlDripGame.h" #include "UnlPci556.h" @@ -654,7 +655,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) //523 case 524: return new VRC2_4(); case 525: break; //KS7021A - case 526: break; //BJ56 + case 526: return new UnlBj56(); case 527: return new VRC2_4(); case 528: return new Unl831128C(); case 529: return new T230(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index ae4745ce8..56bbe07f9 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -186,5 +186,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "TH2131-1", 308 }, { "900218", 524 }, { "831128C", 528 }, - { "AX-40G", 527 }, + { "BJ-56", 526 }, }; \ No newline at end of file diff --git a/Core/UnlBj56.h b/Core/UnlBj56.h new file mode 100644 index 000000000..bbb551665 --- /dev/null +++ b/Core/UnlBj56.h @@ -0,0 +1,60 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class UnlBj56 : public BaseMapper +{ +private: + uint16_t _irqCounter; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x2000; } + virtual uint16_t GetCHRPageSize() override { return 0x400; } + + void InitMapper() override + { + _irqCounter = 0; + + SelectPRGPage(0, -4); + SelectPRGPage(1, -3); + SelectPRGPage(2, -2); + SelectPRGPage(3, -1); + + SetMirroringType(MirroringType::Vertical); + + RemoveRegisterRange(0x9000, 0xFFFF, MemoryOperation::Write); + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_irqCounter); + } + + void ProcessCpuClock() override + { + _irqCounter++; + if(_irqCounter & 4096) { + _console->GetCpu()->SetIrqSource(IRQSource::External); + } + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + switch(addr & 0xF) { + case 0: case 1: case 2: case 3: + case 4: case 5: case 6: case 7: + SelectCHRPage(addr & 0x07, value); + break; + + case 8: case 9: case 0xA: case 0xB: + SelectPRGPage(addr & 0x03, value); + break; + + case 0xD: case 0xF: + _irqCounter = 0; + _console->GetCpu()->ClearIrqSource(IRQSource::External); + break; + } + } +}; \ No newline at end of file From 03b835cf367019ecd0e42d9edf6a92e28e8b6a0d Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 21:29:13 +0800 Subject: [PATCH 25/45] UNIF: Add BTL_KS7021A board (Mapper 525) --- Core/MapperFactory.cpp | 2 +- Core/UnifLoader.cpp | 1 + Core/VRC2_4.h | 31 +++++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 59534ac1f..db01f3d35 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -654,7 +654,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 522: return new Lh10(); //523 case 524: return new VRC2_4(); - case 525: break; //KS7021A + case 525: return new VRC2_4(); case 526: return new UnlBj56(); case 527: return new VRC2_4(); case 528: return new Unl831128C(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 56bbe07f9..b4134ef3f 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -187,4 +187,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "900218", 524 }, { "831128C", 528 }, { "BJ-56", 526 }, + { "KS7021A", 525 }, }; \ No newline at end of file diff --git a/Core/VRC2_4.h b/Core/VRC2_4.h index 46fdae6f9..0a8dfcc8a 100644 --- a/Core/VRC2_4.h +++ b/Core/VRC2_4.h @@ -7,6 +7,7 @@ enum class VRCVariant { VRC2_308, //308 VRC2_524, //524 + VRC2_525, //525 VRC2_527, //527 VRC2a, //Mapper 22 VRC2b, //23 @@ -82,10 +83,11 @@ class VRC2_4 : public BaseMapper case 27: _variant = VRCVariant::VRC4_27; break; //Untested case 308: _variant = VRCVariant::VRC2_308; break; case 524: _variant = VRCVariant::VRC2_524; break; + case 525: _variant = VRCVariant::VRC2_525; break; case 527: _variant = VRCVariant::VRC2_527; break; } - _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308 && _romInfo.MapperID != 524 && _romInfo.MapperID != 527; + _useHeuristics = (_romInfo.SubMapperID == 0) && _romInfo.MapperID != 22 && _romInfo.MapperID != 27 && _romInfo.MapperID != 308 && _romInfo.MapperID != 524 && _romInfo.MapperID != 527 && _romInfo.MapperID != 525; } protected: @@ -93,7 +95,7 @@ class VRC2_4 : public BaseMapper uint16_t GetCHRPageSize() override { return 0x0400; } bool AllowRegisterRead() override { return true; } - void InitMapper() override + void InitMapper() override { _irq.reset(new VrcIrq(_console)); DetectVariant(); @@ -117,7 +119,7 @@ class VRC2_4 : public BaseMapper AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Any); } } - + void ProcessCpuClock() override { if(_variant == VRCVariant::VRC2_308) { @@ -158,7 +160,12 @@ class VRC2_4 : public BaseMapper SetNametable(3, (_hiCHRRegs[1] >> 3) & 0x01); } - if(_prgMode == 0) { + if(_variant == VRCVariant::VRC2_525) { + SelectPRGPage(0, _prgReg0 + 0); + SelectPRGPage(1, _prgReg0 + 1); + SelectPRGPage(2, -2); + SelectPRGPage(3, -1); + } else if(_prgMode == 0) { SelectPRGPage(0, _prgReg0); SelectPRGPage(1, _prgReg1); SelectPRGPage(2, -2); @@ -207,15 +214,22 @@ class VRC2_4 : public BaseMapper } else if(addr >= 0xA000 && addr <= 0xA006) { _prgReg1 = value & 0x1F; } else if(addr >= 0xB000 && addr <= 0xE006) { + if(_variant == VRCVariant::VRC2_525) { + if(addr <= 0xB007) { + _loCHRRegs[addr & 0x07] = value; + _hiCHRRegs[addr & 0x07] = 0; + } + } else { uint8_t regNumber = ((((addr >> 12) & 0x07) - 3) << 1) + ((addr >> 1) & 0x01); bool lowBits = (addr & 0x01) == 0x00; if(lowBits) { //The other reg contains the low 4 bits _loCHRRegs[regNumber] = value & 0x0F; } else { - //One reg contains the high 5 bits + //One reg contains the high 5 bits _hiCHRRegs[regNumber] = value & 0x1F; } + } } else if(_variant == VRCVariant::VRC2_308) { if(addr == 0xF000) { _irqEnabled = false; @@ -311,7 +325,12 @@ class VRC2_4 : public BaseMapper A0 = addr & 0x01; A1 = (addr >> 1) & 0x01; break; - + + case VRCVariant::VRC2_525: + A0 = addr & 0x01; + A1 = (addr >> 1) & 0x03; + break; + case VRCVariant::VRC2_524: //Mapper 524 A0 = addr & 0x01; From d7ca59b03b0e8e0cca3426d656f8e36f544698f2 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Fri, 4 Mar 2022 23:51:03 +0800 Subject: [PATCH 26/45] UNIF: Add MINDKIDS (Mapper 268.1/COOLBOY) --- Core/MapperFactory.cpp | 6 +++++- Core/RomData.h | 1 + Core/UnifLoader.cpp | 1 + Core/UnifLoader.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index db01f3d35..c483243f8 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -572,7 +572,11 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 265: return new T262(); case 266: return new CityFighter(); //267 - case 268: return new MMC3_Coolboy(); + case 268: + if(romData.Info.BoardName.compare("MINDKIDS") == 0) { + romData.Info.SubMapperID = 1; + } + return new MMC3_Coolboy(); //269-270 case 271: break; //22026 //272-273 diff --git a/Core/RomData.h b/Core/RomData.h index a36e9cebc..3a91e6d1a 100644 --- a/Core/RomData.h +++ b/Core/RomData.h @@ -71,6 +71,7 @@ struct RomInfo uint32_t FilePrgOffset = 0; + string BoardName; uint16_t MapperID = 0; uint8_t SubMapperID = 0; diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index b4134ef3f..5c547ef51 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -188,4 +188,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "831128C", 528 }, { "BJ-56", 526 }, { "KS7021A", 525 }, + { "MINDKIDS", 268 }, }; \ No newline at end of file diff --git a/Core/UnifLoader.h b/Core/UnifLoader.h index 9ca744053..50febe3d9 100644 --- a/Core/UnifLoader.h +++ b/Core/UnifLoader.h @@ -87,6 +87,7 @@ class UnifLoader : public BaseLoader if(fourCC.compare("MAPR") == 0) { _mapperName = ReadString(data, chunkEnd); if(_mapperName.size() > 0) { + romData.Info.BoardName = _mapperName; romData.Info.MapperID = GetMapperID(_mapperName); if(romData.Info.MapperID == UnifBoards::UnknownBoard) { Log("[UNIF] Error: Unknown board"); From d1049b14f14f73a0e4549a689d89b0d50f756288 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 5 Mar 2022 15:04:26 +0800 Subject: [PATCH 27/45] Update Bmc-10-24-C-A1 Use WritePrgRam() instead of writing directly to _workRam[] --- Core/Bmc1024CA1.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Bmc1024CA1.h b/Core/Bmc1024CA1.h index 2728c420a..b3bfe2a71 100644 --- a/Core/Bmc1024CA1.h +++ b/Core/Bmc1024CA1.h @@ -51,7 +51,7 @@ class Bmc1024CA1 : public MMC3 { if(addr <= 0x7FFF) { if(CanWriteToWorkRam()) { - _workRam[addr - 0x6000] = value; + WritePrgRam(addr, value); if ((_exReg & 0x07) == 0) { _exReg = addr & 0x3F; UpdatePrgMapping(); From edf18dc3845981b296291f32b11ca8ea7768ed40 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 5 Mar 2022 21:18:04 +0800 Subject: [PATCH 28/45] UNIF: Add BMC-RESETNRON-X1N1 and UNL-KS106C boards --- Core/BmcResetNromX1n1.h | 45 +++++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 6 +++++- Core/UnifBoards.h | 2 ++ Core/UnifLoader.cpp | 2 ++ Core/UnlKs106C.h | 38 ++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 Core/BmcResetNromX1n1.h create mode 100644 Core/UnlKs106C.h diff --git a/Core/BmcResetNromX1n1.h b/Core/BmcResetNromX1n1.h new file mode 100644 index 000000000..1b7cb2ba7 --- /dev/null +++ b/Core/BmcResetNromX1n1.h @@ -0,0 +1,45 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +// BMC-RESETNROM-XIN1 +// - Sheng Tian 2-in-1(Unl,ResetBase)[p1] - Kung Fu (Spartan X), Super Mario Bros (alt) +// - Sheng Tian 2-in-1(Unl,ResetBase)[p2] - B-Wings, Twin-beeSMB1 (wrong mirroring) + +class BmcResetNromX1n1 : public BaseMapper +{ +private: + uint8_t _game; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x8000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + _game = 0; + + RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Write); + } + + void Reset(bool softReset) override + { + if(softReset == true) { + _game++; + _game &= (GetPRGPageCount() - 1); + } else { + _game = 0; + } + + SelectPRGPage(0, _game); + SelectCHRPage(0, _game); + + if(_romInfo.Hash.PrgChrCrc32 == 0x3470F395) { + // Sheng Tian 2-in-1(Unl,ResetBase)[p1].unf + SetMirroringType(MirroringType::Vertical); + } else { + // Sheng Tian 2-in-1(Unl,ResetBase)[p2].unf + SetMirroringType(MirroringType::Horizontal); + } + } +}; diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index c483243f8..8831e6d4f 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -47,6 +47,8 @@ #include "BmcSa005A.h" #include "BmcTj03.h" #include "BmcCtc09.h" +#include "UnlKs106C.h" +#include "BmcResetNromX1n1.h" #include "BnRom.h" #include "Bs5.h" #include "Caltron41.h" @@ -644,7 +646,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 348: return new Bmc830118C(); case 349: return new BmcG146(); case 350: break; //891227 - + //352: case 366: return new BmcGn45(); case 434: return new BmcS2009(); @@ -673,6 +675,8 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case UnifBoards::Unl255in1: return new Unl255in1(); case UnifBoards::Unl8237A: return new Unl8237A(); //mapper 215.1 case UnifBoards::UnlPuzzle: return new UnlPuzzle(); + case UnifBoards::Ks106C: return new UnlKs106C(); //mapper 352, sub 1 + case UnifBoards::ResetNromX1n1: return new BmcResetNromX1n1(); //352 case MapperFactory::StudyBoxMapperID: return new StudyBox(); case MapperFactory::NsfMapperID: return new NsfMapper(); diff --git a/Core/UnifBoards.h b/Core/UnifBoards.h index 02488f291..2d1636db7 100644 --- a/Core/UnifBoards.h +++ b/Core/UnifBoards.h @@ -18,5 +18,7 @@ namespace UnifBoards { UnlVrc7, Unl8237A, SssNrom256, + Ks106C, + ResetNromX1n1, }; } \ No newline at end of file diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 5c547ef51..bcc0318f4 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -189,4 +189,6 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "BJ-56", 526 }, { "KS7021A", 525 }, { "MINDKIDS", 268 }, + { "KS106C", UnifBoards::Ks106C }, + { "RESETNROM-XIN1", UnifBoards::ResetNromX1n1 }, }; \ No newline at end of file diff --git a/Core/UnlKs106C.h b/Core/UnlKs106C.h new file mode 100644 index 000000000..b2fe4fba8 --- /dev/null +++ b/Core/UnlKs106C.h @@ -0,0 +1,38 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +// UNL-KS106C +// - Kaiser 4-in-1(Unl,KS106C)[p1] - B-Wings, Kung Fu, 1942, SMB1 (wrong mirroring) + +class UnlKs106C : public BaseMapper +{ +private: + uint8_t _game; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x8000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + _game = 0; + + RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Write); + } + + void Reset(bool softReset) override + { + if(softReset == true) { + _game++; + _game &= (GetPRGPageCount() - 1); + } else { + _game = 0; + } + + SelectPRGPage(0, _game); + SelectCHRPage(0, _game); + + SetMirroringType((_game & 0x01) ? MirroringType::Vertical : MirroringType::Horizontal); + } +}; From dcf7115c4f73b702a3ea47c696e710339eb2adf9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 6 Mar 2022 13:29:04 +0800 Subject: [PATCH 29/45] UNIF: T4A54A/WX-KB4K/BS-5652 boards Basically, updates Mapper 134 --- Core/MMC3_134.h | 61 +++++++++++++++++++++++++++++++++++++++------ Core/UnifLoader.cpp | 3 +++ 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Core/MMC3_134.h b/Core/MMC3_134.h index fa5e814e6..15710053b 100644 --- a/Core/MMC3_134.h +++ b/Core/MMC3_134.h @@ -3,26 +3,52 @@ #include "stdafx.h" #include "MMC3.h" +// T4A54A, WX-KB4K, or BS-5652 + class MMC3_134 : public MMC3 { private: - uint8_t _exReg; + uint8_t _mode; + uint8_t _outerBank; + uint8_t _cnrom; void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override { - BaseMapper::SelectCHRPage(slot, (page & 0xFF) | ((_exReg & 0x20) << 3), memoryType); + uint16_t mask = (_outerBank & 0x40) ? 0x7F: 0xFF; + uint16_t outerBank = ((_outerBank << 3) & 0x180); + + if(_mode & 0x08) { + page = ((outerBank & ~mask) >> 3) | (_cnrom & (mask >> 3)); + BaseMapper::SelectChrPage8x(0, page << 3, memoryType); + } else { + BaseMapper::SelectCHRPage(slot, (outerBank & ~mask) | (page & mask), memoryType); + } } void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override { - BaseMapper::SelectPRGPage(slot, (page & 0x1F) | ((_exReg & 0x02) << 4), memoryType); + uint16_t mask = (_outerBank & 0x04) ? 0x0F: 0x1F; + uint16_t outerBank = (_outerBank << 4) & 0x30; + + if(_outerBank & 0x80) { // NROM + page = (outerBank & ~mask) | (MMC3::_registers[6] & mask); + page >>= 1; + if(_outerBank & 0x08) { // NROM-128 + BaseMapper::SelectPrgPage2x(0, page << 1, memoryType); + BaseMapper::SelectPrgPage2x(1, page << 1, memoryType); + } else { // NROM-256 + BaseMapper::SelectPrgPage4x(0, (page & 0xFE) << 1, memoryType); + } + } else { + BaseMapper::SelectPRGPage(slot, (outerBank & ~mask) | (page & mask)); + } } void InitMapper() override { MMC3::InitMapper(); - AddRegisterRange(0x6001, 0x6001, MemoryOperation::Write); + AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); } void Reset(bool softReset) override @@ -30,7 +56,9 @@ class MMC3_134 : public MMC3 BaseMapper::Reset(softReset); if(softReset) { - _exReg = 0; + _mode = 0; + _outerBank = 0; + _cnrom = 0; MMC3::UpdateState(); } } @@ -38,13 +66,30 @@ class MMC3_134 : public MMC3 void StreamState(bool saving) override { MMC3::StreamState(saving); - Stream(_exReg); + Stream(_mode, _outerBank, _cnrom); } void WriteRegister(uint16_t addr, uint8_t value) override { - if(addr == 0x6001) { - _exReg = value; + if(addr < 0x8000) { + if((_mode & 0x80) == 0) { + switch (addr & 0x03) { + case 0: + _mode = value; + break; + + case 1: + _outerBank = value; + break; + + case 2: + _cnrom = value; + break; + } + } else if((addr & 0x03) == 2) { + _cnrom &= ~0x03; + _cnrom |= value & 0x03; + } MMC3::UpdateState(); } else { MMC3::WriteRegister(addr, value); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index bcc0318f4..47d099469 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -191,4 +191,7 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "MINDKIDS", 268 }, { "KS106C", UnifBoards::Ks106C }, { "RESETNROM-XIN1", UnifBoards::ResetNromX1n1 }, + { "T4A54A", 134 }, + { "WX-KB4K", 134 }, + { "BS-5652", 134 }, }; \ No newline at end of file From f981a8d7933ea25a07a7dfb5fd081d92deba31ea Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 6 Mar 2022 16:35:31 +0800 Subject: [PATCH 30/45] UNL-SMB2J: Update --- Core/Smb2j.h | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/Core/Smb2j.h b/Core/Smb2j.h index 354afecfe..4c83af451 100644 --- a/Core/Smb2j.h +++ b/Core/Smb2j.h @@ -6,58 +6,51 @@ class Smb2j : public BaseMapper { private: - uint16_t _irqCounter; bool _irqEnabled; protected: - uint16_t GetPRGPageSize() override { return 0x1000; } + uint16_t GetPRGPageSize() override { return 0x2000; } uint16_t GetCHRPageSize() override { return 0x2000; } - uint16_t RegisterStartAddress() override { return 0x4122; } - uint16_t RegisterEndAddress() override { return 0x4122; } + bool AllowRegisterRead() override { return true; } void InitMapper() override { SelectPrgPage4x(0, 0); - SelectPrgPage4x(1, 4); SelectCHRPage(0, 0); + SetCpuMemoryMapping(0x6000, 0x7FFF, 4, PrgMemoryType::PrgRom); - if(_prgSize >= 0x10000) { - AddRegisterRange(0x4022, 0x4022, MemoryOperation::Write); - } - - SetCpuMemoryMapping(0x5000, 0x5FFF, GetPRGPageCount() - 3, PrgMemoryType::PrgRom); - SetCpuMemoryMapping(0x6000, 0x6FFF, GetPRGPageCount() - 2, PrgMemoryType::PrgRom); - SetCpuMemoryMapping(0x7000, 0x7FFF, GetPRGPageCount() - 1, PrgMemoryType::PrgRom); - - _irqCounter = 0; _irqEnabled = false; + + AddRegisterRange(0x4042, 0x4055, MemoryOperation::Read); + AddRegisterRange(0x4027, 0x4027, MemoryOperation::Write); + AddRegisterRange(0x4068, 0x4068, MemoryOperation::Write); + RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Any); } void StreamState(bool saving) override { BaseMapper::StreamState(saving); - Stream(_irqCounter, _irqEnabled); + Stream(_irqEnabled); } void ProcessCpuClock() override { if(_irqEnabled) { - _irqCounter = (_irqCounter + 1) & 0xFFF; - if(_irqCounter == 0) { - _irqEnabled = false; - _console->GetCpu()->SetIrqSource(IRQSource::External); - } + _console->GetCpu()->SetIrqSource(IRQSource::External); } } + uint8_t ReadRegister(uint16_t addr) override + { + return 0xFF; + } + void WriteRegister(uint16_t addr, uint8_t value) override { - if(addr == 0x4022) { - SelectPrgPage4x(0, (value & 0x01) << 2); - SelectPrgPage4x(1, ((value & 0x01) << 2) + 4); - } else if(addr == 0x4122) { - _irqEnabled = (value & 0x03) != 0; - _irqCounter = 0; + if((addr & 0x4027) == 0x4027) { + SetCpuMemoryMapping(0x6000, 0x7FFF, 0x04 | (value & 0x01), PrgMemoryType::PrgRom); + } else if((addr & 0x4068) == 0x4068) { + _irqEnabled = (value & 0x01) == 1; _console->GetCpu()->ClearIrqSource(IRQSource::External); } } From 8ea418fd3b3c72e962dd1ee3ca304c702819c780 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 6 Mar 2022 20:37:48 +0800 Subject: [PATCH 31/45] Mapper 314: Fixed PRG/CHR banking issues --- Core/Bmc64in1NoRepeat.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Core/Bmc64in1NoRepeat.h b/Core/Bmc64in1NoRepeat.h index 2aa178f36..85ddbff4c 100644 --- a/Core/Bmc64in1NoRepeat.h +++ b/Core/Bmc64in1NoRepeat.h @@ -13,7 +13,7 @@ class Bmc64in1NoRepeat : public BaseMapper void InitMapper() override { - AddRegisterRange(0x5000, 0x5003, MemoryOperation::Write); + AddRegisterRange(0x5000, 0x5FFF, MemoryOperation::Write); } void Reset(bool softReset) override @@ -37,14 +37,15 @@ class Bmc64in1NoRepeat : public BaseMapper { if(_regs[0] & 0x80) { if(_regs[1] & 0x80) { - SelectPrgPage2x(0, (_regs[1] & 0x1F) << 1); + SelectPrgPage2x(0, (_regs[1] & 0x3F) << 1); } else { - int bank = ((_regs[1] & 0x1F) << 1) | ((_regs[1] >> 6) & 0x01); + int bank = ((_regs[1] & 0x3F) << 1) | ((_regs[1] >> 6) & 0x01); SelectPRGPage(0, bank); SelectPRGPage(1, bank); } } else { - SelectPRGPage(1, ((_regs[1] & 0x1F) << 1) | ((_regs[1] >> 6) & 0x01)); + SelectPRGPage(0, ((_regs[1] & 0x3F) << 1) | (_regs[3] & 0x07)); + SelectPRGPage(1, ((_regs[1] & 0x3F) << 1) | 0x07); } SetMirroringType(_regs[0] & 0x20 ? MirroringType::Horizontal : MirroringType::Vertical); SelectCHRPage(0, (_regs[2] << 2) | ((_regs[0] >> 1) & 0x03)); @@ -53,7 +54,11 @@ class Bmc64in1NoRepeat : public BaseMapper void WriteRegister(uint16_t addr, uint8_t value) override { if(addr < 0x8000) { - _regs[addr & 0x03] = value; + if(HasChrRom() == false) { + _regs[addr & 0x01] = value; + } else { + _regs[addr & 0x03] = value; + } } else { _regs[3] = value; } From 1c5a0d25eefd090b14b3308cf795c6709fb2d53e Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sun, 6 Mar 2022 21:05:31 +0800 Subject: [PATCH 32/45] RESET-TXROM: Use submappers to denote sizes of individual games --- Core/ResetTxrom.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Core/ResetTxrom.h b/Core/ResetTxrom.h index c231790a5..d42fa6664 100644 --- a/Core/ResetTxrom.h +++ b/Core/ResetTxrom.h @@ -27,13 +27,36 @@ class ResetTxrom : public MMC3 void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override { - page = (_resetCounter << 7) | (page & 0x7F); + switch (_romInfo.SubMapperID) { + default: + case 0: page = (_resetCounter << 7) | (page & 0x7F); break; + case 1: page = (_resetCounter << 7) | (page & 0x7F); break; + case 2: page = (_resetCounter << 8) | (page & 0xFF); break; + case 3: page = (_resetCounter << 8) | (page & 0xFF); break; + case 4: page = (_resetCounter << 7) | (page & 0x7F); break; + } + MMC3::SelectCHRPage(slot, page, memoryType); } void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType) override { - page = (_resetCounter << 4) | (page & 0x0F); + switch (_romInfo.SubMapperID) { + default: + case 0: page = (_resetCounter << 4) | (page & 0x0F); break; + case 1: page = (_resetCounter << 5) | (page & 0x1F); break; + case 2: page = (_resetCounter << 4) | (page & 0x0F); break; + case 3: page = (_resetCounter << 5) | (page & 0x1F); break; + case 4: + if (_resetCounter == 0) { + page &= 0x1F; + } else { + page &= 0x0F; + } + page |= (_resetCounter + 1) << 4; + break; + } + MMC3::SelectPRGPage(slot, page, memoryType); } }; \ No newline at end of file From 8dd79611c9fcf798b1420649b337b90018df92f0 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Tue, 8 Mar 2022 20:29:13 +0800 Subject: [PATCH 33/45] UNIF: Add BMC-891227, BMC-CTC-12in1 Mappers 350 and 337 respectively. --- Core/Bmc891227.h | 67 ++++++++++++++++++++++++++++++++++++++ Core/BmcCtc12in1.h | 68 +++++++++++++++++++++++++++++++++++++++ Core/Core.vcxproj | 2 ++ Core/Core.vcxproj.filters | 6 ++++ Core/MapperFactory.cpp | 6 ++-- Core/UnifLoader.cpp | 2 ++ 6 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 Core/Bmc891227.h create mode 100644 Core/BmcCtc12in1.h diff --git a/Core/Bmc891227.h b/Core/Bmc891227.h new file mode 100644 index 000000000..a1d4d070f --- /dev/null +++ b/Core/Bmc891227.h @@ -0,0 +1,67 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class Bmc891227 : public BaseMapper +{ +private: + uint8_t _reg; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x4000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + SelectCHRPage(0, 0); + } + + void Reset(bool softReset) override + { + if(!softReset) { + _reg = 0; + } + UpdateState(); + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_reg); + } + + void UpdateState() { + uint8_t prgPage = _reg & 0x1F; + + SetCpuMemoryMapping(0x6000, 0x7FFF, PrgMemoryType::PrgRom, 0x2000, MemoryAccessType::Read); + + switch((_reg & 0x60) >> 5) { + case 0: // NROM-128 + SelectPRGPage(0, _reg & 0x1F); + SelectPRGPage(1, _reg & 0x1F); + break; + + case 1: // NROM-256 + SelectPrgPage2x(0, _reg & 0x1E); + break; + + default: // UNROM + SelectPRGPage(0, _reg & 0x3F); + SelectPRGPage(1, (_reg & 0x3F) | 7); + break; + } + SetMirroringType(_reg & 0x80 ? MirroringType::Horizontal : MirroringType::Vertical); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0xC000) { + _reg &= 0x07; + _reg |= value & ~0x07; + } else { + _reg &= _reg & ~0x07; + _reg |= value & 0x07; + } + UpdateState(); + } +}; \ No newline at end of file diff --git a/Core/BmcCtc12in1.h b/Core/BmcCtc12in1.h new file mode 100644 index 000000000..660cc428d --- /dev/null +++ b/Core/BmcCtc12in1.h @@ -0,0 +1,68 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class BmcCtc12in1 : public BaseMapper +{ +private: + uint8_t _reg; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x4000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + SelectCHRPage(0, 0); + } + + void Reset(bool softReset) override + { + if(!softReset) { + _reg = 0; + } + UpdateState(); + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_reg); + } + + void UpdateState() { + uint8_t prgPage = _reg & 0x1F; + + SetCpuMemoryMapping(0x6000, 0x7FFF, PrgMemoryType::PrgRom, 0x2000, MemoryAccessType::Read); + SetPpuMemoryMapping(0, 0x1FFF, 0, ChrMemoryType::Default, (_reg & 0x80) ? MemoryAccessType::ReadWrite : MemoryAccessType::Read); + + switch((_reg & 0xC0) >> 6) { + case 0: // NROM-128 + SelectPRGPage(0, _reg & 0x1F); + SelectPRGPage(1, _reg & 0x1F); + break; + + case 1: // NROM-256 + SelectPrgPage2x(0, _reg & 0x1E); + break; + + default: // UNROM + SelectPRGPage(0, _reg & 0x3F); + SelectPRGPage(1, (_reg & 0x3F) | 7); + break; + } + SetMirroringType(_reg & 0x20 ? MirroringType::Horizontal : MirroringType::Vertical); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0xC000) { + _reg &= 0x07; + _reg |= value & ~0x07; + } else { + _reg &= _reg & ~0x07; + _reg |= value & 0x07; + } + UpdateState(); + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 39ba9d3ab..b0aa8bba2 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -556,6 +556,8 @@ + + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index a58ff36f8..feab295f7 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1009,6 +1009,12 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + + + Nes\Mappers\Unif + Nes\Mappers\Unif diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 8831e6d4f..de7d8b92a 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -36,6 +36,7 @@ #include "Bmc830118C.h" #include "Bmc830134C.h" #include "Bmc830425C4391T.h" +#include "Bmc891227.h" #include "Bmc8in1.h" #include "BmcK3036.h" #include "BmcG146.h" @@ -47,6 +48,7 @@ #include "BmcSa005A.h" #include "BmcTj03.h" #include "BmcCtc09.h" +#include "BmcCtc12in1.h" #include "UnlKs106C.h" #include "BmcResetNromX1n1.h" #include "BnRom.h" @@ -632,7 +634,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) //334 case 335: return new BmcCtc09(); case 336: return new BmcK3046(); - case 337: break; //CTC-12IN1 + case 337: return new BmcCtc12in1(); case 338: return new BmcSa005A(); case 339: return new MMC3_BmcK3006(); case 340: return new BmcK3036(); @@ -645,7 +647,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) //347 case 348: return new Bmc830118C(); case 349: return new BmcG146(); - case 350: break; //891227 + case 350: return new Bmc891227(); //352: case 366: return new BmcGn45(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 47d099469..f0f2ed6aa 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -194,4 +194,6 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "T4A54A", 134 }, { "WX-KB4K", 134 }, { "BS-5652", 134 }, + { "891227", 350 }, + { "CTC-12IN1", 337 }, }; \ No newline at end of file From 0b0b64159872c58bcfb450ea52b211600f7da142 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 10 Mar 2022 09:18:32 +0800 Subject: [PATCH 34/45] Mapper 348: Fixed crash on softreset --- Core/Bmc830118C.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/Bmc830118C.h b/Core/Bmc830118C.h index 92bef11be..23058d633 100644 --- a/Core/Bmc830118C.h +++ b/Core/Bmc830118C.h @@ -19,6 +19,7 @@ class Bmc830118C : public MMC3 { _reg = 0; MMC3::Reset(softReset); + UpdateState(); } void StreamState(bool saving) override From 27afd47fdae62105877498387c053de852ee7c12 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 10 Mar 2022 15:26:05 +0800 Subject: [PATCH 35/45] Mapper 332: Update --- Core/Super40in1Ws.h | 56 +++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/Core/Super40in1Ws.h b/Core/Super40in1Ws.h index dbd19c95f..88c3561db 100644 --- a/Core/Super40in1Ws.h +++ b/Core/Super40in1Ws.h @@ -5,38 +5,66 @@ class Super40in1Ws : public BaseMapper { private: - bool _regLock; + uint8_t _reg[2]; + uint8_t _latch; protected: + uint32_t GetDipSwitchCount() override { return 2; } uint16_t GetPRGPageSize() override { return 0x4000; } uint16_t GetCHRPageSize() override { return 0x2000; } uint16_t RegisterStartAddress() override { return 0x6000; } - uint16_t RegisterEndAddress() override { return 0x6FFF; } + uint16_t RegisterEndAddress() override { return 0xFFFF; } + bool AllowRegisterRead() override { return true; } void InitMapper() override { - _regLock = false; - WriteRegister(0x6000, 0); + _reg[0] = _reg[1] = _latch = 0; + UpdateState(); + + RemoveRegisterRange(0x6000, 0x7FFF, MemoryOperation::Read); } void StreamState(bool saving) override { BaseMapper::StreamState(saving); - Stream(_regLock); + Stream(_reg[0], _reg[1], _latch); + } + + void UpdateState() + { + uint8_t prgPage = ((_reg[0] >> 3) & 0x08) | (_reg[0] & 0x07); + uint8_t chrPage = ((_reg[0] >> 3) & 0x08) | (_reg[1] & 0x07); + + if(_reg[1] & 0x10) { + SelectCHRPage(0, chrPage); + } else { + uint8_t chrMask = ((~_reg[1] >> 4) & 0x02) | 0x01; + SelectCHRPage(0, (chrPage & ~chrMask) | (_latch & chrMask)); + } + + SelectPRGPage(0, prgPage & ~(~_reg[0] >> 3 & 0x01)); + SelectPRGPage(1, prgPage | (~_reg[0] >> 3 & 0x01)); + + SetMirroringType((_reg[0] & 0x10) ? MirroringType::Horizontal : MirroringType::Vertical); + } + + uint8_t ReadRegister(uint16_t addr) override + { + // There is no DPSW 3 setting, doing so causes rom to freeze + bool openbus = GetDipSwitches() != 0x03 && ((_reg[1] & 0xC0) & (GetDipSwitches() << 6)); + return openbus ? _console->GetMemoryManager()->GetOpenBus() : InternalReadRam(addr); } void WriteRegister(uint16_t addr, uint8_t value) override { - if(!_regLock) { - if(addr & 0x01) { - SelectCHRPage(0, value); - } else { - _regLock = (value & 0x20) == 0x20; - - SelectPRGPage(0, value & ~(~value >> 3 & 0x01)); - SelectPRGPage(1, value | (~value >> 3 & 0x01)); - SetMirroringType((value & 0x10) ? MirroringType::Horizontal : MirroringType::Vertical); + if(addr < 0x8000) { + if(!(_reg[0] & 0x20)) { + _reg[addr & 0x01] = value; + UpdateState(); } + } else { + _latch = value; + UpdateState(); } } }; \ No newline at end of file From bcc63b7eb18a61dd83d41566cd8ea8efeebad773 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Thu, 10 Mar 2022 16:33:20 +0800 Subject: [PATCH 36/45] Mapper 287: Fixed PRG/CHR outer banking issue --- Core/MMC3_Bmc411120C.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/MMC3_Bmc411120C.h b/Core/MMC3_Bmc411120C.h index 5bb69a1b6..fba91ffe9 100644 --- a/Core/MMC3_Bmc411120C.h +++ b/Core/MMC3_Bmc411120C.h @@ -26,7 +26,7 @@ class MMC3_Bmc411120C : public MMC3 void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override { - MMC3::SelectCHRPage(slot, page | ((_exReg & 0x03) << 7), memoryType); + MMC3::SelectCHRPage(slot, page | ((_exReg & 0x07) << 7), memoryType); } void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override @@ -34,7 +34,7 @@ class MMC3_Bmc411120C : public MMC3 if(_exReg & (0x08 | (GetDipSwitches() << 2))) { MMC3::SelectPrgPage4x(0, (((_exReg >> 4) & 0x03) | 0x0C) << 2); } else { - MMC3::SelectPRGPage(slot, (page & 0x0F) | ((_exReg & 0x03) << 4)); + MMC3::SelectPRGPage(slot, (page & 0x0F) | ((_exReg & 0x07) << 4)); } } From cf548dbd51c496efa2c7ec2fc945539067a72aaf Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 12 Mar 2022 15:03:10 +0800 Subject: [PATCH 37/45] Mapper 215: Fixed PRG mask in NROM mode --- Core/MMC3_215.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/MMC3_215.h b/Core/MMC3_215.h index ea99e8874..1110ff6d3 100644 --- a/Core/MMC3_215.h +++ b/Core/MMC3_215.h @@ -80,6 +80,7 @@ class MMC3_215 : public MMC3 if(_exRegs[0] & 0x80) { bank <<= 1; if(_exRegs[0] & 0x20) { + bank &= 0xFC; MMC3::SelectPRGPage(0, bank); MMC3::SelectPRGPage(1, bank + 1); MMC3::SelectPRGPage(2, bank + 2); From 4fa8391930d0427899cc0e8b9350d92b9c99fcb9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Sat, 12 Mar 2022 15:16:02 +0800 Subject: [PATCH 38/45] Mapper 215: Add correct write address mask Fixes crash in UNL-8327A's Lion King (game still is unable to complete level 1 though) --- Core/MMC3_215.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/MMC3_215.h b/Core/MMC3_215.h index 1110ff6d3..5c47a8d6c 100644 --- a/Core/MMC3_215.h +++ b/Core/MMC3_215.h @@ -99,7 +99,7 @@ class MMC3_215 : public MMC3 void WriteRegister(uint16_t addr, uint8_t value) override { if(addr < 0x8000) { - switch(addr) { + switch(addr & 0xF007) { case 0x5000: _exRegs[0] = value; UpdateState(); break; case 0x5001: _exRegs[1] = value; UpdateState(); break; case 0x5007: _exRegs[2] = value; break; From 54db67885013ae403389e3d859a95b5e487dce09 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 12:52:15 +0800 Subject: [PATCH 39/45] Mappers 126/422/534 updated/added --- Core/Core.vcxproj | 2 + Core/Core.vcxproj.filters | 6 ++ Core/MMC3_126.h | 86 ++----------------------- Core/MMC3_422.h | 130 ++++++++++++++++++++++++++++++++++++++ Core/MMC3_534.h | 21 ++++++ Core/MapperFactory.cpp | 4 ++ 6 files changed, 169 insertions(+), 80 deletions(-) create mode 100644 Core/MMC3_422.h create mode 100644 Core/MMC3_534.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index b0aa8bba2..6d339f8fa 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -797,6 +797,8 @@ + + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index feab295f7..557ba2d57 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -787,6 +787,12 @@ Nes\Mappers\MMC + + Nes\Mappers\MMC + + + Nes\Mappers\MMC + Nes\Mappers\Waixing diff --git a/Core/MMC3_126.h b/Core/MMC3_126.h index da8517dc1..8f441a841 100644 --- a/Core/MMC3_126.h +++ b/Core/MMC3_126.h @@ -1,88 +1,14 @@ #pragma once #include "stdafx.h" -#include "MMC3.h" +#include "MMC3_422.h" -class MMC3_126 : public MMC3 +class MMC3_126 : public MMC3_422 { private: - uint8_t _exRegs[4]; - - void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override - { - uint16_t reg = _exRegs[0]; - page &= ((~reg >> 2) & 0x10) | 0x0F; - page |= (reg & (0x06 | (reg & 0x40) >> 6)) << 4 | (reg & 0x10) << 3; - - if(!(_exRegs[3] & 0x03)) { - MMC3::SelectPRGPage(slot, page, memoryType); - } else if((_prgMode << 1) == slot) { - if((_exRegs[3] & 0x03) == 0x03) { - MMC3::SelectPRGPage(0, page, memoryType); - MMC3::SelectPRGPage(1, page + 1, memoryType); - MMC3::SelectPRGPage(2, page + 2, memoryType); - MMC3::SelectPRGPage(3, page + 3, memoryType); - } else { - MMC3::SelectPRGPage(0, page, memoryType); - MMC3::SelectPRGPage(1, page + 1, memoryType); - MMC3::SelectPRGPage(2, page, memoryType); - MMC3::SelectPRGPage(3, page + 1, memoryType); - } - } - } - - void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override - { - if(!(_exRegs[3] & 0x10)) { - MMC3::SelectCHRPage(slot, GetChrOuterBank() | (page & ((_exRegs[0] & 0x80) - 1))); - } - } - - uint16_t GetChrOuterBank() - { - uint16_t reg = _exRegs[0]; - return - (~reg << 0 & 0x0080 & _exRegs[2]) | - (reg << 4 & 0x0080 & reg) | - (reg << 3 & 0x0100) | - (reg << 5 & 0x0200); - } - - void InitMapper() override - { - MMC3::InitMapper(); - memset(_exRegs, 0, sizeof(_exRegs)); - AddRegisterRange(0x6000, 0x8000, MemoryOperation::Write); - } - - void StreamState(bool saving) override - { - MMC3::StreamState(saving); - Stream(_exRegs[0], _exRegs[1], _exRegs[2], _exRegs[3]); - } - - void WriteRegister(uint16_t addr, uint8_t value) override + uint16_t GetChrOuterBank() override { - if(addr < 0x8000) { - addr &= 0x03; - - if(addr == 0x01 || addr == 0x02 || ((addr == 0x00 || addr == 0x03) && !(_exRegs[3] & 0x80))) { - if(_exRegs[addr] != value) { - _exRegs[addr] = value; - - if(_exRegs[3] & 0x10) { - uint16_t page = GetChrOuterBank() | ((_exRegs[2] & 0x0F) << 3); - for(int i = 0; i < 8; i++) { - MMC3::SelectCHRPage(i, page + i); - } - } else { - MMC3::UpdateChrMapping(); - } - - MMC3::UpdatePrgMapping(); - } - } - } else { - MMC3::WriteRegister(addr, value); - } + return ((_exRegs[0] << 4) & 0x080) | + ((_exRegs[0] << 3) & 0x100) | + ((_exRegs[0] << 5) & 0x200); } }; \ No newline at end of file diff --git a/Core/MMC3_422.h b/Core/MMC3_422.h new file mode 100644 index 000000000..2378a063f --- /dev/null +++ b/Core/MMC3_422.h @@ -0,0 +1,130 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +// Mapper 126 CHR A18/A19 reversed +// Mapper 422 +// Mapper 534 $C000 value inverted + +class MMC3_422 : public MMC3 +{ +protected: + uint8_t _exRegs[4]; + + virtual uint16_t GetChrOuterBank() + { + return ((_exRegs[0] << 4) & 0x380); + } + + virtual void WriteMMC3(uint16_t addr, uint8_t value) + { + MMC3::WriteRegister(addr, value); + } + +private: + uint8_t _solderPad; + + uint32_t GetDipSwitchCount() override { return 2; } + uint16_t RegisterStartAddress() override { return 0x6000; } + uint16_t RegisterEndAddress() override { return 0xFFFF; } + bool AllowRegisterRead() override { return true; } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + uint8_t mask = (_exRegs[0] & 0x40) ? 0x0F: 0x1F; + uint8_t outerBank = (((_exRegs[0] << 3) & 0x180) & ~mask) | ((_exRegs[0] << 4) & 0x70); + + if(!(_exRegs[3] & 0x03)) { // MMC3 + MMC3::SelectPRGPage(slot, outerBank | (page & mask)); + } else { + page = (outerBank & ~mask) | (MMC3::_registers[6] & mask); + if((_exRegs[3] & 0x03) == 0x03) { // NROM-256 + page &= 0xFE; + MMC3::SelectPRGPage(0, page); + MMC3::SelectPRGPage(1, page + 1); + MMC3::SelectPRGPage(2, page + 2); + MMC3::SelectPRGPage(3, page + 3); + } else { // NROM-128 + MMC3::SelectPRGPage(0, page); + MMC3::SelectPRGPage(1, page + 1); + MMC3::SelectPRGPage(2, page); + MMC3::SelectPRGPage(3, page + 1); + } + } + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override + { + uint8_t mask = (_exRegs[0] & 0x80) ? 0x7F: 0xFF; + + if(!(_exRegs[3] & 0x10)) { + MMC3::SelectCHRPage(slot, (GetChrOuterBank() & ~mask) | (page & mask)); + } + } + + void UpdateChrCnrom() { + uint8_t mask = (_exRegs[0] & 0x80) ? 0x7F: 0xFF; + uint16_t page = ((GetChrOuterBank() & ~mask) >> 3) | (_exRegs[2] & (mask >> 3)); + + for(int i = 0; i < 8; i++) { + MMC3::SelectCHRPage(i, (page << 3) + i); + } + } + + void InitMapper() override + { + MMC3::InitMapper(); + memset(_exRegs, 0, sizeof(_exRegs)); + + RemoveRegisterRange(0x6000, 0x7FFF, MemoryOperation::Read); + } + + void Reset(bool softreset) override + { + _solderPad = GetDipSwitches(); + memset(_exRegs, 0, sizeof(_exRegs)); + MMC3::ResetMmc3(); + UpdateState(); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exRegs[0], _exRegs[1], _exRegs[2], _exRegs[3]); + } + + uint8_t ReadRegister(uint16_t addr) override + { + uint8_t value = InternalReadRam(addr); + if(_exRegs[1] & 0x01) { + value &= ~0x03; + value |= _solderPad & 0x03; + } + return value; + } + + virtual void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + WritePrgRam(addr, value); + if(!(_exRegs[3] & 0x80)) { + _exRegs[addr & 0x03] = value; + if(_exRegs[3] & 0x10) { + UpdateChrCnrom(); + } else { + MMC3::UpdateChrMapping(); + } + MMC3::UpdatePrgMapping(); + } else { + if((addr & 0x03) == 0x02) { + uint8_t mask = ((~_exRegs[2] >> 3) & 0x02) | 0x01; + _exRegs[2] &= ~mask; + _exRegs[2] |= value & mask; + UpdateChrCnrom(); + } + } + } else { + WriteMMC3(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MMC3_534.h b/Core/MMC3_534.h new file mode 100644 index 000000000..e4eddf0bc --- /dev/null +++ b/Core/MMC3_534.h @@ -0,0 +1,21 @@ +#pragma once +#include "stdafx.h" +#include "MMC3_126.h" + +class MMC3_534 : public MMC3_126 +{ +private: + uint16_t GetChrOuterBank() override + { + return ((_exRegs[0] << 4) & 0x380); + } + + void WriteMMC3(uint16_t addr, uint8_t value) override + { + if((addr >= 0xC000) && (addr <= 0xDFFF)) { + value ^= 0xFF; + } + + MMC3::WriteRegister(addr, value); + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index de7d8b92a..f89525199 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -195,6 +195,8 @@ #include "MMC3_249.h" #include "MMC3_250.h" #include "MMC3_254.h" +#include "MMC3_422.h" +#include "MMC3_534.h" #include "MMC3_Bmc411120C.h" #include "MMC3_BmcF15.h" #include "MMC3_BmcGn26.h" @@ -651,6 +653,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) //352: case 366: return new BmcGn45(); + case 422: return new MMC3_422(); case 434: return new BmcS2009(); case 513: return new Sachen9602(); @@ -668,6 +671,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 528: return new Unl831128C(); case 529: return new T230(); case 530: return new Ax5705(); + case 534: return new MMC3_534(); case UnifBoards::Ac08: return new Ac08(); //mapper 42? case UnifBoards::Cc21: return new Cc21(); From a95a40608eb19aa53b3f784958baa582b3aade88 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 13:20:27 +0800 Subject: [PATCH 40/45] Mapper 236: Updated support for larger PRG/CHR ROM size --- Core/Bmc70in1.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/Bmc70in1.h b/Core/Bmc70in1.h index 3d2a68a90..e47b64a86 100644 --- a/Core/Bmc70in1.h +++ b/Core/Bmc70in1.h @@ -82,14 +82,15 @@ class Bmc70in1 : public BaseMapper { if(addr & 0x4000) { _bankMode = addr & 0x30; - _prgReg = addr & 0x07; + _prgReg = addr & 0x0F; } else { SetMirroringType(addr & 0x20 ? MirroringType::Horizontal : MirroringType::Vertical); if(_useOuterBank) { - _outerBank = (addr & 0x03) << 3; + _outerBank = (addr & 0x07) << 3; } else { - _chrReg = addr & 0x07; + _chrReg = addr & 0x0F; } + } UpdateState(); From cc48f4aad214292fb8c807de9fa8232973b0823c Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 15:17:13 +0800 Subject: [PATCH 41/45] Mapper 225: Support extra RAM --- Core/Mapper225.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Core/Mapper225.h b/Core/Mapper225.h index 8a5561f65..51bfc3682 100644 --- a/Core/Mapper225.h +++ b/Core/Mapper225.h @@ -7,16 +7,34 @@ class Mapper225 : public BaseMapper protected: virtual uint16_t GetPRGPageSize() override { return 0x4000; } virtual uint16_t GetCHRPageSize() override { return 0x2000; } + bool AllowRegisterRead() override { return true; } + + uint8_t RAM[4]; void InitMapper() override { + memset(RAM, 0, sizeof(RAM)); + SelectPRGPage(0, 0); SelectPRGPage(1, 1); SelectCHRPage(0, 0); + + AddRegisterRange(0x5800, 0x5FFF, MemoryOperation::Any); + RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read); + } + + uint8_t ReadRegister(uint16_t addr) override + { + return RAM[addr & 0x03] & 0x0F; } void WriteRegister(uint16_t addr, uint8_t value) override { + if(addr <= 0x5FFF) { + RAM[addr & 0x03] = value; + return; + } + uint8_t highBit = (addr >> 8) & 0x40; uint8_t prgPage = ((addr >> 6) & 0x3F) | highBit; if(addr & 0x1000) { From 7137db3fad6fe50cc48fe6078f71beaa485422d6 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 16:28:51 +0800 Subject: [PATCH 42/45] Mapper 217: Replace as an address latch mapper, support for 21-in-1 multicart' --- Core/Core.vcxproj | 2 +- Core/Core.vcxproj.filters | 6 +- Core/MMC3_217.h | 130 -------------------------------------- Core/Mapper217.h | 22 +++++++ Core/MapperFactory.cpp | 4 +- 5 files changed, 28 insertions(+), 136 deletions(-) delete mode 100644 Core/MMC3_217.h create mode 100644 Core/Mapper217.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 6d339f8fa..d01ebc69e 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -754,6 +754,7 @@ + @@ -774,7 +775,6 @@ - diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 557ba2d57..06609825b 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -946,6 +946,9 @@ Nes\Mappers\Unnamed + + Nes\Mappers\Unnamed + Nes\Mappers\MMC @@ -958,9 +961,6 @@ Nes\Mappers\MMC - - Nes\Mappers\MMC - Nes\Mappers\MMC diff --git a/Core/MMC3_217.h b/Core/MMC3_217.h deleted file mode 100644 index 32ca0060f..000000000 --- a/Core/MMC3_217.h +++ /dev/null @@ -1,130 +0,0 @@ -#pragma once -#include "stdafx.h" -#include "MMC3.h" - -class MMC3_217 : public MMC3 -{ -private: - uint8_t _exRegs[4]; - uint8_t _lut[8] = { 0,6,3,7,5,2,4,1 }; - -protected: - void InitMapper() override - { - AddRegisterRange(0x5000, 0x5001, MemoryOperation::Write); - AddRegisterRange(0x5007, 0x5007, MemoryOperation::Write); - - MMC3::InitMapper(); - } - - void Reset(bool softReset) override - { - _exRegs[0] = 0; - _exRegs[1] = 0xFF; - _exRegs[2] = 0x03; - _exRegs[3] = 0; - - BaseMapper::Reset(softReset); - - UpdateState(); - } - - void StreamState(bool saving) override - { - MMC3::StreamState(saving); - Stream(_exRegs[0], _exRegs[1], _exRegs[2], _exRegs[3]); - } - - void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override - { - if(!(_exRegs[1] & 0x08)) { - page = (_exRegs[1] << 3 & 0x80) | (page & 0x7F); - } - - MMC3::SelectCHRPage(slot, (_exRegs[1] << 8 & 0x0300) | page); - } - - void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override - { - if(_exRegs[1] & 0x08) { - page = (page & 0x1F); - } else { - page = (page & 0x0F) | (_exRegs[1] & 0x10); - } - - MMC3::SelectPRGPage(slot, (_exRegs[1] << 5 & 0x60) | page); - } - - void WriteRegister(uint16_t addr, uint8_t value) override - { - if(addr < 0x8000) { - switch(addr) { - case 0x5000: - _exRegs[0] = value; - - if(value & 0x80) { - value = (value & 0x0F) | (_exRegs[1] << 4 & 0x30); - value <<= 1; - SelectPRGPage(0, value); - SelectPRGPage(1, value + 1); - SelectPRGPage(2, value); - SelectPRGPage(3, value + 1); - } else { - UpdatePrgMapping(); - } - break; - - case 0x5001: - if(_exRegs[1] != value) { - _exRegs[1] = value; - UpdatePrgMapping(); - } - break; - - case 0x5007: - _exRegs[2] = value; - break; - } - } else { - switch(addr & 0xE001) { - case 0x8000: - MMC3::WriteRegister(_exRegs[2] ? 0xC000 : 0x8000, value); - break; - - case 0x8001: - if(_exRegs[2]) { - value = (value & 0xC0) | _lut[value & 0x07]; - _exRegs[3] = 1; - - MMC3::WriteRegister(0x8000, value); - } else { - MMC3::WriteRegister(0x8001, value); - } - break; - - case 0xA000: - if(_exRegs[2]) { - if(_exRegs[3] && ((_exRegs[0] & 0x80) == 0 || GetCurrentRegister() < 6)) { - _exRegs[3] = 0; - MMC3::WriteRegister(0x8001, value); - } - } else { - SetMirroringType(value & 0x01 ? MirroringType::Horizontal : MirroringType::Vertical); - } - break; - - case 0xA001: - if(_exRegs[2]) { - SetMirroringType(value & 0x01 ? MirroringType::Horizontal : MirroringType::Vertical); - } else { - MMC3::WriteRegister(0xA001, value); - } - break; - - default: - MMC3::WriteRegister(addr, value); - break; - } - } - } -}; \ No newline at end of file diff --git a/Core/Mapper217.h b/Core/Mapper217.h new file mode 100644 index 000000000..b18592c82 --- /dev/null +++ b/Core/Mapper217.h @@ -0,0 +1,22 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class Mapper217 : public BaseMapper +{ +protected: + virtual uint16_t GetPRGPageSize() override { return 0x8000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + + void InitMapper() override + { + WriteRegister(0, 0); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + SelectCHRPage(0, addr & 0x0F); + addr >>= 2; + SelectPRGPage(0, addr & 0x03); + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index f89525199..f46b49316 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -139,6 +139,7 @@ #include "Mapper213.h" #include "Mapper214.h" #include "Mapper216.h" +#include "Mapper217.h" #include "Mapper218.h" #include "Mapper221.h" #include "Mapper222.h" @@ -187,7 +188,6 @@ #include "MMC3_205.h" #include "MMC3_208.h" #include "MMC3_215.h" -#include "MMC3_217.h" #include "MMC3_219.h" #include "MMC3_224.h" #include "MMC3_238.h" @@ -532,7 +532,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) return new Unl8237A(); return new MMC3_215(); case 216: return new Mapper216(); - case 217: return new MMC3_217(); + case 217: return new Mapper217(); case 218: return new Mapper218(); case 219: return new MMC3_219(); case 220: return new Kaiser7057(); From 6f7be36c85eca3b2844b404f0faa91701357010d Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 17:31:48 +0800 Subject: [PATCH 43/45] MMC3 208: Updated - Add mirroring register - Support for submapper 1 cart --- Core/MMC3_208.h | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Core/MMC3_208.h b/Core/MMC3_208.h index 57784adc9..11f668e60 100644 --- a/Core/MMC3_208.h +++ b/Core/MMC3_208.h @@ -24,7 +24,7 @@ class MMC3_208 : public MMC3 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; - uint8_t _exRegs[6]; + uint8_t _exRegs[7]; protected: uint16_t RegisterStartAddress() override { return 0x8000; } @@ -35,23 +35,38 @@ class MMC3_208 : public MMC3 { _exRegs[5] = 3; MMC3::InitMapper(); - AddRegisterRange(0x4800, 0x4FFF, MemoryOperation::Write); - AddRegisterRange(0x6800, 0x6FFF, MemoryOperation::Write); - AddRegisterRange(0x5000, 0x5FFF, MemoryOperation::Write); - AddRegisterRange(0x5800, 0x5FFF, MemoryOperation::Read); + if(_romInfo.SubMapperID == 0) { + AddRegisterRange(0x4800, 0x4FFF, MemoryOperation::Write); + AddRegisterRange(0x6800, 0x6FFF, MemoryOperation::Write); + AddRegisterRange(0x5000, 0x5FFF, MemoryOperation::Write); + AddRegisterRange(0x5800, 0x5FFF, MemoryOperation::Read); + } RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read); } void StreamState(bool saving) override { MMC3::StreamState(saving); - ArrayInfo exRegs { _exRegs, 6 }; + ArrayInfo exRegs { _exRegs, 7 }; Stream(exRegs); } void UpdatePrgMapping() override { - SelectPrgPage4x(0, _exRegs[5] << 2); + if(_romInfo.SubMapperID == 1) { + SelectPrgPage4x(0, MMC3::_registers[6]); + } else { + SelectPrgPage4x(0, _exRegs[5] << 2); + } + } + + void UpdateMirroring() override + { + if(_romInfo.SubMapperID == 1) { + MMC3::UpdateMirroring(); + } else { + SetMirroringType(_exRegs[6] ? MirroringType::Horizontal : MirroringType::Vertical); + } } uint8_t ReadRegister(uint16_t addr) override @@ -69,6 +84,7 @@ class MMC3_208 : public MMC3 } } else if(addr < 0x8000) { _exRegs[5] = (value & 0x01) | ((value >> 3) & 0x02); + _exRegs[6] = (value >> 5) & 0x01; UpdatePrgMapping(); } else { MMC3::WriteRegister(addr, value); From 48c80c19beb2ff8d019caaf91bb3687d591f51a9 Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 18:57:01 +0800 Subject: [PATCH 44/45] Mapper 171: Fixed CHR banking issue --- Core/Kaiser7058.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Kaiser7058.h b/Core/Kaiser7058.h index 6c9c9dffd..93ebf5d4d 100644 --- a/Core/Kaiser7058.h +++ b/Core/Kaiser7058.h @@ -7,7 +7,7 @@ class Kaiser7058 : public BaseMapper protected: virtual uint16_t GetPRGPageSize() override { return 0x8000; } virtual uint16_t GetCHRPageSize() override { return 0x1000; } - virtual uint16_t RegisterStartAddress() override { return 0xF000; } + virtual uint16_t RegisterStartAddress() override { return 0x8000; } virtual uint16_t RegisterEndAddress() override { return 0xFFFF; } void InitMapper() override @@ -17,9 +17,9 @@ class Kaiser7058 : public BaseMapper void WriteRegister(uint16_t addr, uint8_t value) override { - switch(addr & 0xF080) { - case 0xF000: SelectCHRPage(0, value); break; - case 0xF080: SelectCHRPage(1, value); break; + switch(addr & 0x01) { + case 0x00: SelectCHRPage(0, value); break; + case 0x01: SelectCHRPage(1, value); break; } } }; \ No newline at end of file From f4df3ba8647e037fa8f0119e0dcdf322782b075c Mon Sep 17 00:00:00 2001 From: negativeExponent Date: Wed, 16 Mar 2022 23:09:09 +0800 Subject: [PATCH 45/45] Unrom512: Support larger PRG sized roms --- Core/UnRom512.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/UnRom512.h b/Core/UnRom512.h index 06902b2c7..49599252d 100644 --- a/Core/UnRom512.h +++ b/Core/UnRom512.h @@ -115,8 +115,8 @@ class UnRom512 : public BaseMapper void WriteRegister(uint16_t addr, uint8_t value) override { if(!HasBattery() || addr >= 0xC000) { - SelectPRGPage(0, value & 0x1F); - _prgBank = value & 0x1F; + SelectPRGPage(0, value); + _prgBank = value; SelectCHRPage(0, (value >> 5) & 0x03);