From b0c64ec3322b4a5747da57f2179fd9effb160043 Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 8 Jul 2018 16:37:31 -0400 Subject: [PATCH] Added support for mapper 324 (FARID-UNROM) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/FaridUnrom.h | 54 +++++++++++++++++++++++++++++++++++++++ Core/MapperFactory.cpp | 3 ++- Core/UnifLoader.cpp | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Core/FaridUnrom.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 0efc8daa..20bc6bdc 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -532,6 +532,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index c8340bec..590a2a3f 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1462,6 +1462,9 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + diff --git a/Core/FaridUnrom.h b/Core/FaridUnrom.h new file mode 100644 index 00000000..67140ece --- /dev/null +++ b/Core/FaridUnrom.h @@ -0,0 +1,54 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class FaridUnrom : public BaseMapper +{ +private: + uint8_t _reg; + +protected: + virtual uint16_t GetPRGPageSize() override { return 0x4000; } + virtual uint16_t GetCHRPageSize() override { return 0x2000; } + bool HasBusConflicts() override { return true; } + + void InitMapper() override + { + SelectPRGPage(0, 0); + SelectPRGPage(1, 7); + + SelectCHRPage(0, 0); + } + + void Reset(bool softReset) override + { + BaseMapper::Reset(softReset); + + if(softReset) { + _reg = _reg & 0x87; + } else { + _reg = 0; + } + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_reg); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + bool locked = _reg & 0x08; + if(!locked && (_reg & 0x80) == 0 && (value & 0x80)) { + //Latch bits + _reg = (_reg & 0x87) | (value & 0x78); + } + _reg = (_reg & 0x78) | (value & 0x87); + + uint8_t outer = _reg & 0x70; + + SelectPRGPage(0, (_reg & 0x07) | (outer >> 1)); + SelectPRGPage(1, 0x07 | (outer >> 1)); + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 6c43383d..879284b7 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -56,6 +56,7 @@ #include "Eh8813A.h" #include "FamicomBox.h" #include "FaridSlrom.h" +#include "FaridUnrom.h" #include "FDS.h" #include "FrontFareast.h" #include "Ghostbusters63in1.h" @@ -592,7 +593,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) //321 case 322: break; //K-3033 case 323: return new FaridSlrom(); - case 324: break; //FARID_UNROM_8-IN-1 + case 324: return new FaridUnrom(); case 325: return new MMC3_MaliSB(); case 327: break; //10-24-C-A1 case 328: return new Rt01(); diff --git a/Core/UnifLoader.cpp b/Core/UnifLoader.cpp index f184e8b7..044b4e0a 100644 --- a/Core/UnifLoader.cpp +++ b/Core/UnifLoader.cpp @@ -44,6 +44,7 @@ std::unordered_map UnifLoader::_boardMappings = std::unordered_map< { "ETROM", 5 }, { "EWROM", 5 }, { "FARID_SLROM_8-IN-1", 323 }, + { "FARID_UNROM_8-IN-1", 324 }, { "FK23C", UnifBoards::Fk23C }, { "FK23CA", UnifBoards::Fk23Ca }, { "FS304", 162 },