Mapper 126 support

This commit is contained in:
Souryo 2016-10-22 09:13:45 -04:00
parent 2180fd6273
commit 98694abe97
4 changed files with 95 additions and 1 deletions

View File

@ -478,6 +478,7 @@
<ClInclude Include="Mapper183.h" />
<ClInclude Include="Mapper253.h" />
<ClInclude Include="MMC3_123.h" />
<ClInclude Include="MMC3_126.h" />
<ClInclude Include="MMC3_134.h" />
<ClInclude Include="MMC3_196.h" />
<ClInclude Include="MMC3_219.h" />

View File

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

88
Core/MMC3_126.h Normal file
View File

@ -0,0 +1,88 @@
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_126 : public MMC3
{
private:
uint8_t _exRegs[4];
void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType) override
{
uint16_t reg = _exRegs[0];
page &= ((~reg >> 2) & 0x10) | 0x0F;
page |= (reg & (0x06 | (reg & 0x40) >> 6)) << 4 | (reg & 0x10) << 3;
if(!(_exRegs[3] & 0x03)) {
MMC3::SelectPRGPage(slot, page, memoryType);
} else if((_prgMode << 1) == slot) {
if((_exRegs[3] & 0x03) == 0x03) {
MMC3::SelectPRGPage(0, page, memoryType);
MMC3::SelectPRGPage(1, page + 1, memoryType);
MMC3::SelectPRGPage(2, page + 2, memoryType);
MMC3::SelectPRGPage(3, page + 3, memoryType);
} else {
MMC3::SelectPRGPage(0, page, memoryType);
MMC3::SelectPRGPage(1, page + 1, memoryType);
MMC3::SelectPRGPage(2, page, memoryType);
MMC3::SelectPRGPage(3, page + 1, memoryType);
}
}
}
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override
{
if(!(_exRegs[3] & 0x10)) {
MMC3::SelectCHRPage(slot, GetChrOuterBank() | (page & ((_exRegs[0] & 0x80) - 1)));
}
}
uint16_t GetChrOuterBank()
{
uint16_t reg = _exRegs[0];
return
(~reg << 0 & 0x0080 & _exRegs[2]) |
(reg << 4 & 0x0080 & reg) |
(reg << 3 & 0x0100) |
(reg << 5 & 0x0200);
}
void InitMapper() override
{
MMC3::InitMapper();
memset(_exRegs, 0, sizeof(_exRegs));
AddRegisterRange(0x6000, 0x8000, MemoryOperation::Write);
}
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 < 0x8000) {
addr &= 0x03;
if(addr == 0x01 || addr == 0x02 || ((addr == 0x00 || addr == 0x03) && !(_exRegs[3] & 0x80))) {
if(_exRegs[addr] != value) {
_exRegs[addr] = value;
if(_exRegs[3] & 0x10) {
uint16_t page = GetChrOuterBank() | ((_exRegs[2] & 0x0F) << 3);
for(int i = 0; i < 8; i++) {
MMC3::SelectCHRPage(i, page + i);
}
} else {
MMC3::UpdateChrMapping();
}
MMC3::UpdatePrgMapping();
}
}
} else {
MMC3::WriteRegister(addr, value);
}
}
};

View File

@ -103,6 +103,7 @@
#include "MMC3_115.h"
#include "MMC3_121.h"
#include "MMC3_123.h"
#include "MMC3_126.h"
#include "MMC3_134.h"
#include "MMC3_165.h"
#include "MMC3_182.h"
@ -194,7 +195,7 @@ Supported mappers:
| 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|
| 96| 97|===| 99|...|101|===|103| |105|106|107|108|===|===|===|
|112|113|114|115| |117|118|119|120|121|===|123|===| | |===|
|112|113|114|115| |117|118|119|120|121|===|123|===| |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|
|---|===|162|163|164|165|166|167|168|===|170|171|172|173|===|175|
@ -327,6 +328,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 120: return new Mapper120();
case 121: return new MMC3_121();
case 123: return new MMC3_123();
case 126: return new MMC3_126();
case 132: return new Txc22211A();
case 133: return new Sachen_133();
case 134: return new MMC3_134();