From ad41b0561a61d336d0e96db22b6475acc3996d82 Mon Sep 17 00:00:00 2001 From: Souryo Date: Mon, 8 May 2017 22:47:59 -0400 Subject: [PATCH] Mapper 158 support (Emulate Alien Syndrome as mapper 158 instead of 118) --- Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 4 +++- Core/Rambo1.h | 2 +- Core/Rambo1_158.h | 38 ++++++++++++++++++++++++++++++++ GUI.NET/Dependencies/MesenDB.txt | 2 +- 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 Core/Rambo1_158.h diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index a7391386..3b3b467c 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -412,6 +412,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 1085cacf..4db4af4a 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1171,6 +1171,9 @@ Rewinder + + Nes\Mappers + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 203942b8..b438739f 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -186,6 +186,7 @@ #include "OekaKids.h" #include "Racermate.h" #include "Rambo1.h" +#include "Rambo1_158.h" #include "Rt01.h" #include "Sachen_133.h" #include "Sachen_136.h" @@ -257,7 +258,7 @@ Supported mappers: | 96| 97|===| 99|...|101|===|103|104|105|106|107|108|===|===|111| |112|113|114|115| |117|118|119|120|121|===|123|===|125|126|===| |===|===|===|===|132|133|134|===|136|137|138|139|140|141|142|143| -|144|145|146|147|148|149|150|151|152|153|154|155|156|157|???|159| +|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159| |---|===|162|163|164|165|166|167|168|===|170|171|172|173|===|175| |176|177|178|179|180|---|182|183|184|185|186|187|188|189|190|191| |192|193|194|195|196|197| |199|200|201|202|203|204|205|206|207| @@ -417,6 +418,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 155: return new MMC1_155(); case 156: return new DaouInfosys(); case 157: return new BandaiFcg(); + case 158: return new Rambo1_158(); case 159: return new BandaiFcg(); case 162: return new Waixing162(); case 163: return new Nanjing(); diff --git a/Core/Rambo1.h b/Core/Rambo1.h index d5a47ea2..57db9053 100644 --- a/Core/Rambo1.h +++ b/Core/Rambo1.h @@ -6,7 +6,7 @@ class Rambo1 : public BaseMapper { -private: +protected: const uint8_t PpuIrqDelay = 2; const uint8_t CpuIrqDelay = 1; bool _irqEnabled = false; diff --git a/Core/Rambo1_158.h b/Core/Rambo1_158.h new file mode 100644 index 00000000..8930047e --- /dev/null +++ b/Core/Rambo1_158.h @@ -0,0 +1,38 @@ +#pragma once +#include "stdafx.h" +#include "Rambo1.h" + +class Rambo1_158 : public Rambo1 +{ + void WriteRegister(uint16_t addr, uint8_t value) override + { + if((addr & 0xE001) == 0x8001) { + uint8_t nametable = value >> 7; + + if(_currentRegister & 0x80) { + switch(_currentRegister & 0x07) { + case 2: SetNametable(0, nametable); break; + case 3: SetNametable(1, nametable); break; + case 4: SetNametable(2, nametable); break; + case 5: SetNametable(3, nametable); break; + } + } else { + switch(_currentRegister & 0x07) { + case 0: + SetNametable(0, nametable); + SetNametable(1, nametable); + break; + + case 1: + SetNametable(2, nametable); + SetNametable(3, nametable); + break; + } + } + } + + if((addr & 0xE001) != 0xA000) { + Rambo1::WriteRegister(addr, value); + } + } +}; \ No newline at end of file diff --git a/GUI.NET/Dependencies/MesenDB.txt b/GUI.NET/Dependencies/MesenDB.txt index ba129dff..1b3040c7 100644 --- a/GUI.NET/Dependencies/MesenDB.txt +++ b/GUI.NET/Dependencies/MesenDB.txt @@ -2448,7 +2448,7 @@ CB5ACB49,Famicom,HVC-TKROM,HVC-TKROM-03,MMC3C,4,128,128,,0,8,1,,, CB8F9AB7,NesNtsc,,,,4,128,128,,0,0,0,,, CBAD8B09,Famicom,,,,0,32,8,,0,0,0,v,, CBBEFD1F,VsUni,,,,99,32,16,4,0,0,0,,, -CBF4366F,NesNtsc,TENGEN-800037,800037 REV A,337006,118,128,128,,0,0,0,,, +CBF4366F,NesNtsc,TENGEN-800037,800037 REV A,337006,158,128,128,,0,0,0,,, CBFB6DE5,Famicom,,,,4,128,128,,0,0,0,,, CC3544B0,Famicom,HVC-SLROM,HVC-SLROM-03,MMC1A,1,128,128,,0,0,0,,, CC37094C,NesNtsc,NES-SGROM,NES-SGROM-04,MMC1B2,1,256,,8,0,0,0,,,