From fb49fbb6c9336dbe0c1d725bbca6cc232090c2fa Mon Sep 17 00:00:00 2001 From: Souryo Date: Sat, 25 Jul 2015 17:39:19 -0400 Subject: [PATCH] Mapper 71 (BF909x) support - Fixes firehawk --- Core/BF909x.h | 36 ++++++++++++++++++++++++++++++++++++ Core/Core.vcxproj | 1 + Core/Core.vcxproj.filters | 3 +++ Core/MapperFactory.cpp | 3 ++- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Core/BF909x.h diff --git a/Core/BF909x.h b/Core/BF909x.h new file mode 100644 index 00000000..934bcf05 --- /dev/null +++ b/Core/BF909x.h @@ -0,0 +1,36 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class BF909x : public BaseMapper +{ +private: + bool _bf9097Mode = false; //Auto-detect for firehawk + +protected: + virtual uint32_t GetPRGPageSize() { return 0x4000; } + virtual uint32_t GetCHRPageSize() { return 0x2000; } + + void InitMapper() + { + //First and last PRG page + SelectPRGPage(0, 0); + SelectPRGPage(1, -1); + + SelectCHRPage(0, 0); + } + + void WriteRegister(uint16_t addr, uint8_t value) + { + if(addr == 0x9000) { + //Firehawk uses $9000 to change mirroring + _bf9097Mode = true; + } + + if(addr >= 0xC000 || !_bf9097Mode) { + SelectPRGPage(0, value); + } else if(addr < 0xC000) { + _mirroringType = (value & 0x10) ? MirroringType::ScreenAOnly : MirroringType::ScreenBOnly; + } + } +}; \ No newline at end of file diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index b6206bf1..be0bd35c 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -266,6 +266,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 4a2bfa94..eb12fe65 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -224,6 +224,9 @@ Header Files + + Header Files\Mappers + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 8a1d4aef..86e43398 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -14,6 +14,7 @@ #include "NROM.h" #include "UNROM.h" #include "VRC2_4.h" +#include "BF909x.h" BaseMapper* MapperFactory::GetMapperFromID(uint8_t mapperID) { @@ -34,7 +35,7 @@ BaseMapper* MapperFactory::GetMapperFromID(uint8_t mapperID) case 23: return new VRC2_4(VRCVariant::VRC2b); //Conflicts: VRC4e case 25: return new VRC2_4(VRCVariant::VRC4b); //Conflicts: VRC2c, VRC4d case 27: return new VRC2_4(VRCVariant::VRC4_27); //Untested - case 71: return new UNROM(); //TODO: "It's largely a clone of UNROM, and Camerica games were initially emulated under iNES Mapper 002 before 071 was assigned." + case 71: return new BF909x(); case 163: return new Nanjing(); case 189: return new MMC3_189(); default: MessageManager::DisplayMessage("Error", "Unsupported mapper, cannot load game.");