Mapper 117 support

This commit is contained in:
Souryo 2016-08-20 12:21:07 -04:00
parent a0fc28fb65
commit c5b97c877e
5 changed files with 139 additions and 1 deletions

52
Core/A12Watcher.h Normal file
View File

@ -0,0 +1,52 @@
#include "stdafx.h"
#include "CPU.h"
#include "PPU.h"
#include "Snapshotable.h"
enum class A12StateChange
{
None = 0,
Rise = 1,
Fall = 2
};
class A12Watcher : public Snapshotable
{
private:
uint32_t _lastCycle = 0;
uint32_t _cyclesDown = 0;
public:
void StreamState(bool saving)
{
Stream(_lastCycle, _cyclesDown);
}
A12StateChange UpdateVramAddress(uint16_t addr)
{
A12StateChange result = A12StateChange::None;
uint32_t cycle = PPU::GetFrameCycle();
if((addr & 0x1000) == 0) {
if(_cyclesDown == 0) {
_cyclesDown = 1;
} else {
if(_lastCycle > cycle) {
//We changed frames
_cyclesDown += (89342 - _lastCycle) + cycle;
} else {
_cyclesDown += (cycle - _lastCycle);
}
}
result = A12StateChange::Fall;
} else if(addr & 0x1000) {
if(_cyclesDown > 8) {
result = A12StateChange::Rise;
}
_cyclesDown = 0;
}
_lastCycle = cycle;
return result;
}
};

View File

@ -398,6 +398,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="A12Watcher.h" />
<ClInclude Include="Action53.h" />
<ClInclude Include="ActionEnterprises.h" />
<ClInclude Include="APU.h" />
@ -450,6 +451,7 @@
<ClInclude Include="Mapper107.h" />
<ClInclude Include="Mapper108.h" />
<ClInclude Include="Mapper112.h" />
<ClInclude Include="Mapper117.h" />
<ClInclude Include="Mapper120.h" />
<ClInclude Include="Mapper15.h" />
<ClInclude Include="Mapper170.h" />

View File

@ -904,6 +904,12 @@
<ClInclude Include="Mapper106.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper117.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="A12Watcher.h">
<Filter>Nes\Mappers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">

76
Core/Mapper117.h Normal file
View File

@ -0,0 +1,76 @@
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
#include "A12Watcher.h"
class Mapper117 : public BaseMapper
{
private:
uint8_t _irqCounter;
uint8_t _irqReloadValue;
bool _irqEnabled;
bool _irqEnabledAlt;
A12Watcher _a12Watcher;
protected:
virtual uint16_t GetPRGPageSize() { return 0x2000; }
virtual uint16_t GetCHRPageSize() { return 0x400; }
void InitMapper()
{
_irqEnabled = false;
_irqEnabledAlt = false;
_irqCounter = 0;
_irqReloadValue = 0;
SelectPrgPage4x(0, -4);
}
void StreamState(bool saving)
{
BaseMapper::StreamState(saving);
Stream(_irqCounter, _irqEnabled, _irqEnabledAlt, _irqReloadValue, _a12Watcher);
}
void NotifyVRAMAddressChange(uint16_t addr)
{
if(_a12Watcher.UpdateVramAddress(addr) == A12StateChange::Rise) {
if(_irqEnabled && _irqEnabledAlt && _irqCounter) {
_irqCounter--;
if(_irqCounter == 0) {
CPU::SetIRQSource(IRQSource::External);
_irqEnabledAlt = false;
}
}
}
}
void WriteRegister(uint16_t addr, uint8_t value)
{
switch(addr) {
case 0x8000: case 0x8001: case 0x8002: case 0x8003:
SelectPRGPage(addr & 0x03, value );
break;
case 0xA000: case 0xA001: case 0xA002: case 0xA003:
case 0xA004: case 0xA005: case 0xA006: case 0xA007:
SelectCHRPage(addr & 0x07, value);
break;
case 0xC001: _irqReloadValue = value; break;
case 0xC002: CPU::ClearIRQSource(IRQSource::External); break;
case 0xC003:
_irqCounter = _irqReloadValue;
_irqEnabledAlt = true;
break;
case 0xD000: SetMirroringType(value & 0x01 ? MirroringType::Horizontal : MirroringType::Vertical); break;
case 0xE000:
_irqEnabled = (value & 0x01) == 0x01;
CPU::ClearIRQSource(IRQSource::External);
break;
}
}
};

View File

@ -56,6 +56,7 @@
#include "Mapper107.h"
#include "Mapper108.h"
#include "Mapper112.h"
#include "Mapper117.h"
#include "Mapper120.h"
#include "Mapper170.h"
#include "Mapper183.h"
@ -185,7 +186,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| | |106|107|108|===|===|===|
|112|113|114|115| | |118|119|120|121|===| |===| | |===|
|112|113|114|115| |117|118|119|120|121|===| |===| | |===|
|===|===|===|===|132|133| |===|136|137|138|139|140|141|142|143|
|144|145|146|147|148|149|150|151|152|153|154|155|156|157| |159|
| |===| |163|164|165|166|167|168|===|170|171|172|173|===|175|
@ -312,6 +313,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 113: return new Nina03_06(true);
case 114: return new MMC3_114();
case 115: return new MMC3_115();
case 117: return new Mapper117();
case 118: return new TxSRom();
case 119: return new MMC3_ChrRam(0x40, 0x7F, 8);
case 120: return new Mapper120();