diff --git a/Core/Bmc12in1.h b/Core/Bmc12in1.h new file mode 100644 index 00000000..0d2e4423 --- /dev/null +++ b/Core/Bmc12in1.h @@ -0,0 +1,50 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class Bmc12in1 : public BaseMapper +{ +private: + uint8_t _regs[2]; + uint8_t _mode; + +protected: + uint16_t GetPRGPageSize() override { return 0x4000; } + uint16_t GetCHRPageSize() override { return 0x1000; } + + void InitMapper() override + { + _regs[0] = _regs[1] = 0; + _mode = 0; + UpdateState(); + } + + void StreamState(bool saving) + { + BaseMapper::StreamState(saving); + Stream(_regs[0], _regs[1], _mode); + } + + void UpdateState() + { + uint8_t bank = (_mode & 0x03) << 3; + SelectCHRPage(0, (_regs[0] >> 3) | (bank << 2)); + SelectCHRPage(1, (_regs[1] >> 3) | (bank << 2)); + if(_mode & 0x08) { + SelectPrgPage2x(0, bank | (_regs[0] & 0x06)); + } else { + SelectPRGPage(0, bank | (_regs[0] & 0x07)); + SelectPRGPage(1, bank | 0x07); + } + SetMirroringType(_mode & 0x04 ? MirroringType::Horizontal : MirroringType::Vertical); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + switch(addr & 0xE000) { + case 0xA000: _regs[0] = value; UpdateState(); break; + case 0xC000: _regs[1] = value; UpdateState(); break; + case 0xE000: _mode = value & 0x0F; UpdateState(); break; + } + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 86c8cc8e..6bf98bf1 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -418,6 +418,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index aec41765..6252406b 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1048,6 +1048,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 6157135a..2142da66 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -17,6 +17,7 @@ #include "BF909x.h" #include "BF9096.h" #include "Bmc11160.h" +#include "Bmc12in1.h" #include "Bmc51.h" #include "Bmc63.h" #include "Bmc70in1.h" @@ -476,6 +477,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case UnifBoards::Ax5705: return new Ax5705(); case UnifBoards::Bb: return new Bb(); case UnifBoards::Bmc11160: return new Bmc11160(); + case UnifBoards::Bmc12in1: return new Bmc12in1(); case UnifBoards::Bmc70in1: return new Bmc70in1(); case UnifBoards::Bmc70in1B: return new Bmc70in1(); case UnifBoards::Bmc190in1: return new Bmc190in1(); diff --git a/Core/UnifBoards.h b/Core/UnifBoards.h index f831db51..73dd1b0e 100644 --- a/Core/UnifBoards.h +++ b/Core/UnifBoards.h @@ -34,6 +34,7 @@ namespace UnifBoards { Ac08, BmcG146, BmdNtd03, - Bmc11160 + Bmc11160, + Bmc12in1 }; } \ No newline at end of file diff --git a/Core/UnifLoader.h b/Core/UnifLoader.h index 2bf08547..70ce458b 100644 --- a/Core/UnifLoader.h +++ b/Core/UnifLoader.h @@ -10,7 +10,7 @@ class UnifLoader private: std::unordered_map _boardMappings = { { "11160", UnifBoards::Bmc11160 }, - { "12-IN-1", UnifBoards::UnknownBoard }, + { "12-IN-1", UnifBoards::Bmc12in1 }, { "13in1JY110", UnifBoards::UnknownBoard }, { "190in1", UnifBoards::Bmc190in1 }, { "22211", 132 },