From 86231c94e397a579e51fde56caaca1a4f906413d Mon Sep 17 00:00:00 2001 From: Sour Date: Mon, 25 Jun 2018 13:35:40 -0400 Subject: [PATCH] UNIF: Added support for BMC-60311C boards --- Core/Bmc60311C.h | 83 +++++++++++++++++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 ++ Core/MapperFactory.cpp | 2 + Core/UnifBoards.h | 1 + Core/UnifLoader.cpp | 1 + 6 files changed, 91 insertions(+) create mode 100644 Core/Bmc60311C.h diff --git a/Core/Bmc60311C.h b/Core/Bmc60311C.h new file mode 100644 index 00000000..336f3f20 --- /dev/null +++ b/Core/Bmc60311C.h @@ -0,0 +1,83 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class Bmc60311C : public BaseMapper +{ +private: + uint8_t _innerPrg; + uint8_t _outerPrg; + uint8_t _mode; + +protected: + uint16_t GetPRGPageSize() override { return 0x4000; } + uint16_t GetCHRPageSize() override { return 0x2000; } + uint16_t RegisterStartAddress() override { return 0x6000; } + uint16_t RegisterEndAddress() override { return 0xFFFF; } + + void InitMapper() override + { + _innerPrg = 0; + _outerPrg = 0; + _mode = 0; + + UpdateState(); + SelectCHRPage(0, 0); + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_innerPrg, _outerPrg, _mode); + } + + void UpdateState() + { + uint8_t page = _outerPrg | ((_mode & 0x04) ? 0 : _innerPrg); + + switch(_mode & 0x03) { + case 0: + //0: NROM-128: Same inner/outer 16 KiB bank at CPU $8000-$BFFF and $C000-$FFFF + SelectPRGPage(0, page); + SelectPRGPage(1, page); + break; + + case 1: + //1: NROM-256: 32 kiB bank at CPU $8000-$FFFF (Selected inner/outer bank SHR 1) + SelectPrgPage2x(0, page & 0xFE); + break; + + case 2: + //2: UNROM: Inner/outer bank at CPU $8000-BFFF, fixed inner bank 7 within outer bank at $C000-$FFFF + SelectPRGPage(0, page); + SelectPRGPage(1, _outerPrg | 7); + break; + + case 3: + //Unknown + break; + } + + SetMirroringType(_mode & 0x08 ? MirroringType::Horizontal : MirroringType::Vertical); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(addr >= 0x8000) { + _innerPrg = value & 0x07; + UpdateState(); + } else { + switch(addr & 0xE001) { + case 0x6000: + _mode = value & 0x0F; + UpdateState(); + break; + + case 0x6001: + _outerPrg = value; + UpdateState(); + break; + } + } + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 53e95109..da42535f 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -518,6 +518,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 4917a4b8..cad6c884 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1453,6 +1453,9 @@ Nes\MemoryManager + + Nes\Mappers\Unif + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 1c7191e0..ec6c6fba 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -25,6 +25,7 @@ #include "Bmc190in1.h" #include "Bmc235.h" #include "Bmc255.h" +#include "Bmc60311C.h" #include "Bmc8157.h" #include "Bmc80013B.h" #include "Bmc810544CA1.h" @@ -544,6 +545,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case UnifBoards::Bmc70in1: return new Bmc70in1(); case UnifBoards::Bmc70in1B: return new Bmc70in1(); case UnifBoards::Bmc190in1: return new Bmc190in1(); + case UnifBoards::Bmc60311C: return new Bmc60311C(); case UnifBoards::Bmc810544CA1: return new Bmc810544CA1(); case UnifBoards::Bmc830118C: return new Bmc830118C(); case UnifBoards::Bmc80013B: return new Bmc80013B(); diff --git a/Core/UnifBoards.h b/Core/UnifBoards.h index 016daf04..f2eb075b 100644 --- a/Core/UnifBoards.h +++ b/Core/UnifBoards.h @@ -72,5 +72,6 @@ namespace UnifBoards { BmcGn45, UnlDripGame, SssNrom256, + Bmc60311C, }; } \ No newline at end of file diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 3386cf5a..bf5e286a 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -161,4 +161,5 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "HPxx", UnifBoards::BmcHpxx }, { "GN-45", UnifBoards::BmcGn45 }, //Doesn't actually exist as a UNIF file (used to assign a mapper to GN-45 boards) { "DRIPGAME", UnifBoards::UnlDripGame }, + { "60311C", UnifBoards::Bmc60311C }, }; \ No newline at end of file