diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index c182ac9d..7bba24ce 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -658,6 +658,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 80d41a9a..43179853 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1009,6 +1009,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + diff --git a/Core/MMC3_Super24in1Sc03.h b/Core/MMC3_Super24in1Sc03.h new file mode 100644 index 00000000..ab02f2b0 --- /dev/null +++ b/Core/MMC3_Super24in1Sc03.h @@ -0,0 +1,55 @@ +#pragma once +#include "stdafx.h" +#include "MMC3.h" + +class MMC3_Super24in1Sc03 : public MMC3 +{ +private: + const int _prgMask[8] = { 0x3F, 0x1F, 0x0F, 0x01, 0x03, 0, 0, 0 }; + uint8_t _exRegs[3]; + +protected: + uint32_t GetChrRamSize() override { return 0x2000; } + uint16_t GetChrRamPageSize() override { return 0x400; } + + void InitMapper() override + { + _exRegs[0] = 0x24; + _exRegs[1] = 0x9F; + _exRegs[2] = 0; + + MMC3::InitMapper(); + + AddRegisterRange(0x5FF0, 0x5FF2, MemoryOperation::Write); + } + + void StreamState(bool saving) override + { + MMC3::StreamState(saving); + Stream(_exRegs[0], _exRegs[1], _exRegs[2]); + + if(!saving) { + UpdateState(); + } + } + + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override + { + MMC3::SelectCHRPage(slot, ((_exRegs[2] << 3) & 0xF00) | page, _exRegs[0] & 0x20 ? ChrMemoryType::ChrRam : ChrMemoryType::ChrRom); + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + MMC3::SelectPRGPage(slot, ((_exRegs[1] << 1) | (page & _prgMask[_exRegs[0] & 0x07])) & 0xFF); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr < 0x8000) { + _exRegs[addr & 0x03] = value; + UpdateState(); + } else { + MMC3::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 4c328f16..69d5bd19 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -138,6 +138,7 @@ #include "MMC3_Coolboy.h" #include "MMC3_Kof97.h" #include "MMC3_StreetHeroes.h" +#include "MMC3_Super24in1Sc03.h" #include "MMC4.h" #include "MMC5.h" #include "Namco108.h" @@ -250,6 +251,7 @@ const uint16_t MapperFactory::UnifMalee; const uint16_t MapperFactory::UnifNovelDiamond; const uint16_t MapperFactory::UnifStreetHeroes; const uint16_t MapperFactory::UnifSmb2j; +const uint16_t MapperFactory::UnifSuper24in1Sc03; const uint16_t MapperFactory::UnifT262; const uint16_t MapperFactory::UnifTf1201; @@ -496,6 +498,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case MapperFactory::UnifNovelDiamond: return new NovelDiamond(); case MapperFactory::UnifSmb2j: return new Smb2j(); case MapperFactory::UnifStreetHeroes: return new MMC3_StreetHeroes(); + case MapperFactory::UnifSuper24in1Sc03: return new MMC3_Super24in1Sc03(); case MapperFactory::UnifT262: return new T262(); case MapperFactory::UnifTf1201: return new Tf1201(); diff --git a/Core/MapperFactory.h b/Core/MapperFactory.h index 59cbab93..69e8eb67 100644 --- a/Core/MapperFactory.h +++ b/Core/MapperFactory.h @@ -31,6 +31,7 @@ class MapperFactory static const uint16_t UnifBmc70in1 = 65516; static const uint16_t UnifBmc70in1B = 65515; static const uint16_t UnifAx5705 = 65514; + static const uint16_t UnifSuper24in1Sc03 = 65513; static shared_ptr InitializeFromFile(string romFilename, stringstream *filestream, string ipsFilename, int32_t archiveFileIndex); }; diff --git a/Core/UnifLoader.h b/Core/UnifLoader.h index 28410851..7a2d29f3 100644 --- a/Core/UnifLoader.h +++ b/Core/UnifLoader.h @@ -120,7 +120,7 @@ private: { "Sachen-8259B", 138 }, { "Sachen-8259C", 139 }, { "Sachen-8259D", 137 }, - { "Super24in1SC03", MapperFactory::UnknownBoard }, + { "Super24in1SC03", MapperFactory::UnifSuper24in1Sc03 }, { "SuperHIK8in1", 45 }, { "Supervision16in1", 53 }, { "T-227-1", MapperFactory::UnknownBoard },