diff --git a/Core/BaseMapper.h b/Core/BaseMapper.h index 0ab1cac5..d524743f 100644 --- a/Core/BaseMapper.h +++ b/Core/BaseMapper.h @@ -209,7 +209,7 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat } } - void SelectCHRPage(uint16_t slot, uint16_t page) + virtual void SelectCHRPage(uint16_t slot, uint16_t page) { _chrPageNumbers[slot] = page; diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index f78e662b..630c0370 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -197,6 +197,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 42d3bff2..8e76290c 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -353,6 +353,9 @@ Nes\Mappers + + Nes\Mappers + diff --git a/Core/MMC3_115.h b/Core/MMC3_115.h new file mode 100644 index 00000000..bc011292 --- /dev/null +++ b/Core/MMC3_115.h @@ -0,0 +1,51 @@ +#pragma once + +#include "stdafx.h" +#include "MMC3.h" + +class MMC3_115 : public MMC3 +{ +private: + uint8_t _prgReg = 0; + uint8_t _chrReg = 0; + + virtual uint16_t RegisterStartAddress() { return 0x6000; } + + virtual void WriteRegister(uint16_t addr, uint8_t value) + { + if(addr < 0x8000) { + if(addr & 0x01) { + _chrReg = value & 0x01; + } else { + _prgReg = value; + } + UpdateState(); + } else { + MMC3::WriteRegister(addr, value); + } + } + +protected: + virtual void SelectCHRPage(uint16_t slot, uint16_t page) + { + page |= (_chrReg << 8); + BaseMapper::SelectCHRPage(slot, page); + } + + virtual void UpdateState() + { + MMC3::UpdateState(); + + if(_prgReg & 0x80) { + SelectPRGPage(0, (_prgReg & 0x0F) << 1); + SelectPRGPage(1, ((_prgReg & 0x0F) << 1) + 1); + } + } + + virtual void StreamState(bool saving) + { + MMC3::StreamState(saving); + Stream(_prgReg); + Stream(_chrReg); + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index ec9c996e..bdb246a0 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -16,6 +16,7 @@ #include "MMC1.h" #include "MMC2.h" #include "MMC3.h" +#include "MMC3_115.h" #include "MMC3_189.h" #include "MMC4.h" #include "MMC5.h" @@ -92,6 +93,7 @@ BaseMapper* MapperFactory::GetMapperFromID(ROMLoader &romLoader) case 97: return new IremTamS1(); case 101: return new JalecoJfxx(true); case 113: return new Nina03_06(true); + case 115: return new MMC3_115(); case 145: return new Sachen_145(); case 146: return new Nina03_06(false); case 147: return new Sachen_147();