From 66dae9189da6d166734d7aa07b50da7b8f1365ed Mon Sep 17 00:00:00 2001 From: Sour Date: Mon, 18 Jun 2018 21:16:30 -0400 Subject: [PATCH] UNIF: Added support for UNL-8237A boards --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MMC3_215.h | 4 +-- Core/MapperFactory.cpp | 2 ++ Core/UnifBoards.h | 3 ++- Core/UnifLoader.cpp | 2 +- Core/Unl8237A.h | 53 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 Core/Unl8237A.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 4847e322..0b76ec2f 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -624,6 +624,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 738a04f2..4e198a47 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1420,6 +1420,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + diff --git a/Core/MMC3_215.h b/Core/MMC3_215.h index 043e6160..ea99e887 100644 --- a/Core/MMC3_215.h +++ b/Core/MMC3_215.h @@ -2,9 +2,10 @@ #include "stdafx.h" #include "MMC3.h" +//Unif: UNL-8237 class MMC3_215 : public MMC3 { -private: +protected: const uint8_t _lutReg[8][8] = { { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0, 2, 6, 1, 7, 3, 4, 5 }, @@ -30,7 +31,6 @@ private: uint8_t _exRegs[3]; -protected: uint16_t RegisterStartAddress() override { return 0x5000; } uint16_t RegisterEndAddress() override { return 0xFFFF; } diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index fa2b57f4..18349109 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -239,6 +239,7 @@ #include "Unl158B.h" #include "Unl255in1.h" #include "Unl43272.h" +#include "Unl8237A.h" #include "UnlD1038.h" #include "UnlPci556.h" #include "UnlPuzzle.h" @@ -583,6 +584,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case UnifBoards::Unl158B: return new Unl158B(); case UnifBoards::Unl255in1: return new Unl255in1(); case UnifBoards::Unl43272: return new Unl43272(); + case UnifBoards::Unl8237A: return new Unl8237A(); case UnifBoards::UnlD1038: return new UnlD1038(); case UnifBoards::UnlPuzzle: return new UnlPuzzle(); case UnifBoards::UnlVrc7: return new UnlVrc7(); diff --git a/Core/UnifBoards.h b/Core/UnifBoards.h index 3285cd25..2d205469 100644 --- a/Core/UnifBoards.h +++ b/Core/UnifBoards.h @@ -65,6 +65,7 @@ namespace UnifBoards { Dance2000, CityFighter, UnlVrc7, - Yoko + Yoko, + Unl8237A }; } \ No newline at end of file diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index 1aeb9448..29f40530 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -19,7 +19,7 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "810544-C-A1", UnifBoards::Bmc810544CA1 }, { "8157", UnifBoards::Bmc8157 }, { "8237", 215 }, - { "8237A", UnifBoards::UnknownBoard }, + { "8237A", UnifBoards::Unl8237A }, { "830118C", UnifBoards::Bmc830118C }, { "A65AS", UnifBoards::A65AS }, { "AC08", UnifBoards::Ac08 }, diff --git a/Core/Unl8237A.h b/Core/Unl8237A.h new file mode 100644 index 00000000..f65c4105 --- /dev/null +++ b/Core/Unl8237A.h @@ -0,0 +1,53 @@ +#pragma once +#include "stdafx.h" +#include "MMC3_215.h" + +class Unl8237A : public MMC3_215 +{ + void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override + { + if(_exRegs[0] & 0x40) { + MMC3::SelectCHRPage(slot, ((_exRegs[1] & 0x0E) << 7) | (page & 0x7F) | ((_exRegs[1] & 0x20) << 2), memoryType); + } else { + MMC3::SelectCHRPage(slot, ((_exRegs[1] & 0x0E) << 7) | page, memoryType); + } + } + + void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override + { + uint8_t sbank = 0; + uint8_t bank = 0; + uint8_t mask = 0; + + if(_exRegs[0] & 0x40) { + mask = 0x0F; + sbank = (_exRegs[1] & 0x10); + if(_exRegs[0] & 0x80) { + bank = ((_exRegs[1] & 0x03) << 4) | ((_exRegs[1] & 0x08) << 3) | (_exRegs[0] & 0x07) | (sbank >> 1); + } + } else { + mask = 0x1F; + if(_exRegs[0] & 0x80) { + bank = ((_exRegs[1] & 0x03) << 4) | ((_exRegs[1] & 0x08) << 3) | (_exRegs[0] & 0x0F); + } + } + + 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); + MMC3::SelectPRGPage(3, bank + 3); + } else { + MMC3::SelectPRGPage(0, bank); + MMC3::SelectPRGPage(1, bank + 1); + MMC3::SelectPRGPage(2, bank); + MMC3::SelectPRGPage(3, bank + 1); + } + } else { + MMC3::SelectPRGPage(slot, ((_exRegs[1] & 0x03) << 5) | ((_exRegs[1] & 0x08) << 4) | (page & mask) | sbank); + } + } +}; \ No newline at end of file