Mesen/Core/MMC3_114.h

78 lines
1.5 KiB
C
Raw Normal View History

2016-07-31 00:45:52 +00:00
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_114 : public MMC3
{
private:
const uint8_t _security[8] = { 0,3,1,5,6,7,2,4 };
uint8_t _exRegs[2];
protected:
2016-12-18 04:14:47 +00:00
virtual uint16_t RegisterStartAddress() override { return 0x5000; }
virtual bool ForceMmc3RevAIrqs() override { return true; }
2016-07-31 00:45:52 +00:00
2016-12-18 04:14:47 +00:00
void InitMapper() override
2016-07-31 00:45:52 +00:00
{
MMC3::InitMapper();
_exRegs[0] = _exRegs[1] = 0;
}
2016-12-18 04:14:47 +00:00
virtual void StreamState(bool saving) override
2016-07-31 00:45:52 +00:00
{
MMC3::StreamState(saving);
Stream(_exRegs[0], _exRegs[1]);
}
2016-12-18 04:14:47 +00:00
virtual void UpdatePrgMapping() override
2016-07-31 00:45:52 +00:00
{
if(_exRegs[0] & 0x80) {
SelectPrgPage2x(0, (_exRegs[0] & 0x0F) << 1);
SelectPrgPage2x(1, (_exRegs[0] & 0x0F) << 1);
2016-07-31 00:45:52 +00:00
} else {
MMC3::UpdatePrgMapping();
}
}
2016-12-18 04:14:47 +00:00
virtual void WriteRegister(uint16_t addr, uint8_t value) override
2016-07-31 00:45:52 +00:00
{
if(addr < 0x8000) {
_exRegs[0] = value;
UpdatePrgMapping();
} else {
switch(addr & 0xE001) {
case 0x8001: MMC3::WriteRegister(0xA000, value); break;
case 0xA000:
MMC3::WriteRegister(0x8000, (value & 0xC0) | _security[value & 0x07]);
_exRegs[1] = 1;
break;
case 0xA001:
_irqReloadValue = value;
break;
2016-07-31 00:45:52 +00:00
case 0xC000:
if(_exRegs[1]) {
_exRegs[1] = 0;
MMC3::WriteRegister(0x8001, value);
}
break;
2016-07-31 00:45:52 +00:00
case 0xC001:
_irqReload = true;
break;
2016-07-31 00:45:52 +00:00
case 0xE000:
_console->GetCpu()->ClearIrqSource(IRQSource::External);
_irqEnabled = false;
break;
2016-07-31 00:45:52 +00:00
case 0xE001:
_irqEnabled = true;
break;
}
2016-07-31 00:45:52 +00:00
}
}
};