Mapper 199 support

This commit is contained in:
Souryo 2016-10-23 20:51:01 -04:00
parent af331bf5ae
commit c249d627ee
5 changed files with 82 additions and 3 deletions

View File

@ -481,6 +481,7 @@
<ClInclude Include="MMC3_126.h" />
<ClInclude Include="MMC3_134.h" />
<ClInclude Include="MMC3_196.h" />
<ClInclude Include="MMC3_199.h" />
<ClInclude Include="MMC3_219.h" />
<ClInclude Include="MMC3_238.h" />
<ClInclude Include="Mapper241.h" />

View File

@ -943,6 +943,9 @@
<ClInclude Include="MMC3_126.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="MMC3_199.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">

View File

@ -31,7 +31,7 @@ class MMC3 : public BaseMapper
bool _forceMmc3RevAIrqs;
struct {
struct Mmc3State {
uint8_t Reg8000;
uint8_t RegA000;
uint8_t RegA001;
@ -77,6 +77,11 @@ class MMC3 : public BaseMapper
return _currentRegister;
}
Mmc3State GetState()
{
return _state;
}
uint8_t GetChrMode()
{
return _chrMode;

68
Core/MMC3_199.h Normal file
View File

@ -0,0 +1,68 @@
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_199 : public MMC3
{
private:
uint8_t _exRegs[4];
protected:
uint32_t GetChrRamSize() { return 0x2000; }
uint16_t GetChrRamPageSize() { return 0x400; }
void InitMapper() override
{
_exRegs[0] = 0xFE;
_exRegs[1] = 0xFF;
_exRegs[2] = 1;
_exRegs[3] = 3;
MMC3::InitMapper();
}
void StreamState(bool saving) override
{
MMC3::StreamState(saving);
Stream(_exRegs[0], _exRegs[1], _exRegs[2], _exRegs[3]);
}
void WriteRegister(uint16_t addr, uint8_t value) override
{
if(addr == 0x8001 && (GetState().Reg8000 & 0x08)) {
_exRegs[GetState().Reg8000 & 0x03] = value;
UpdatePrgMapping();
UpdateChrMapping();
} else {
MMC3::WriteRegister(addr, value);
}
}
void UpdateMirroring() override
{
switch(GetState().RegA000 & 0x03) {
case 0: SetMirroringType(MirroringType::Vertical); break;
case 1: SetMirroringType(MirroringType::Horizontal); break;
case 2: SetMirroringType(MirroringType::ScreenAOnly); break;
case 3: SetMirroringType(MirroringType::ScreenBOnly); break;
}
}
void UpdatePrgMapping() override
{
MMC3::UpdatePrgMapping();
SelectPRGPage(2, _exRegs[0]);
SelectPRGPage(3, _exRegs[1]);
}
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override
{
MMC3::SelectCHRPage(slot, page, page < 8 ? ChrMemoryType::ChrRam : ChrMemoryType::ChrRom);
MMC3::SelectCHRPage(0, _registers[0], _registers[0] < 8 ? ChrMemoryType::ChrRam : ChrMemoryType::ChrRom);
MMC3::SelectCHRPage(1, _exRegs[2], _exRegs[2] < 8 ? ChrMemoryType::ChrRam : ChrMemoryType::ChrRom);
MMC3::SelectCHRPage(2, _registers[1], _registers[1] < 8 ? ChrMemoryType::ChrRam : ChrMemoryType::ChrRom);
MMC3::SelectCHRPage(3, _exRegs[3], _exRegs[3] < 8 ? ChrMemoryType::ChrRam : ChrMemoryType::ChrRom);
}
};

View File

@ -111,6 +111,7 @@
#include "MMC3_189.h"
#include "MMC3_196.h"
#include "MMC3_197.h"
#include "MMC3_199.h"
#include "MMC3_205.h"
#include "MMC3_219.h"
#include "MMC3_238.h"
@ -200,7 +201,7 @@ Supported mappers:
|144|145|146|147|148|149|150|151|152|153|154|155|156|157| |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|===|191|
|192|193|194|195|196|197| | |200|201|202|203|204|205|206|207|
|192|193|194|195|196|197| |199|200|201|202|203|204|205|206|207|
| |209|210|211|212|213|214| |216| |218|219| |221|222| |
| |225|226|227|228|229|230|231|232|233|234|235| |===|238|===|
|240|241|242|243|244|245|246|===|===|249|250|===|252|253|254|255|
@ -386,7 +387,8 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 194: return new MMC3_ChrRam(0x00, 0x01, 2);
case 195: return new MMC3_ChrRam(0x00, 0x03, 4);
case 196: return new MMC3_196();
case 197: return new MMC3_197();
case 197: return new MMC3_197();
case 199: return new MMC3_199();
case 200: return new Mapper200();
case 201: return new Mapper201();
case 202: return new Mapper202();