From f5e777bef860af3fb491d009043c22ef4e45e40e Mon Sep 17 00:00:00 2001 From: Souryo Date: Sat, 23 Jul 2016 16:25:52 -0400 Subject: [PATCH] Mapper 96 (Oeka Kids) support --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 5 ++-- Core/OekaKids.h | 52 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 Core/OekaKids.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index b01864c2..95e25f03 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -498,6 +498,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 00249f5f..ecadaec0 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -811,6 +811,9 @@ Nes\Mappers\MMC + + Nes\Mappers + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 7a6778f7..bf3d2404 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -103,6 +103,7 @@ #include "NsfCart31.h" #include "NsfMapper.h" #include "NtdecTc112.h" +#include "OekaKids.h" #include "Rambo1.h" #include "Sachen_133.h" #include "Sachen_143.h" @@ -156,7 +157,7 @@ Supported mappers: | 48| 49| 50| 51| 52| | | | 56| 57| 58|===| 60| 61| 62| 63| | 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79| | 80|===| 82| |===| 85| 86| 87| 88| 89| 90| 91| 92| 93| 94| 95| -| | 97| | 99|...|101| | | | | |107|108| | | | +| 96| 97| | 99|...|101| | | | | |107|108| | | | |112|113| |115| | |118|119| | | | | | | | | | | | | |132|133| | | |137|138|139|140|141|142|143| |144|145|146|147|148|149|150|151|152|153|154|155|156|157| |159| @@ -267,7 +268,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 93: return new Sunsoft93(); case 94: return new UnRom_94(); case 95: return new Namco108_95(); - case 96: break; //Bandai - Oeka Tablet + case 96: return new OekaKids(); case 97: return new IremTamS1(); case 99: return new VsSystem(); case 101: return new JalecoJfxx(true); diff --git a/Core/OekaKids.h b/Core/OekaKids.h new file mode 100644 index 00000000..d9751950 --- /dev/null +++ b/Core/OekaKids.h @@ -0,0 +1,52 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class OekaKids : public BaseMapper +{ + uint8_t _outerChrBank; + uint8_t _innerChrBank; + uint16_t _lastAddress; + +protected: + virtual uint16_t GetPRGPageSize() { return 0x8000; } + virtual uint16_t GetCHRPageSize() { return 0x2000; } + virtual bool HasBusConflicts() { return true; } + + void InitMapper() + { + _outerChrBank = 0; + _innerChrBank = 0; + _lastAddress = 0; + + SelectPRGPage(0, 0); + } + + void StreamState(bool saving) + { + BaseMapper::StreamState(saving); + Stream(_outerChrBank, _innerChrBank, _lastAddress); + } + + void UpdateChrBanks() + { + SelectCHRPage(0, _outerChrBank | _innerChrBank); + } + + void NotifyVRAMAddressChange(uint16_t addr) + { + if((_lastAddress & 0x3000) != 0x2000 && (addr & 0x3000) == 0x2000) { + _innerChrBank = (addr >> 8) & 0x03; + UpdateChrBanks(); + } + + _lastAddress = addr; + } + + void WriteRegister(uint16_t addr, uint8_t value) + { + SelectPRGPage(0, value & 0x03); + _outerChrBank = value & 0x04; + UpdateChrBanks(); + } +};