Mesen/Core/MMC3_238.h

41 lines
779 B
C
Raw Normal View History

2016-08-12 23:41:47 +00:00
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_238 : public MMC3
{
private:
const uint8_t _securityLut[4] = { 0x00, 0x02, 0x02, 0x03 };
uint8_t _exReg;
protected:
2016-12-18 04:14:47 +00:00
virtual bool AllowRegisterRead() override { return true; }
2016-08-12 23:41:47 +00:00
2016-12-18 04:14:47 +00:00
void InitMapper() override
2016-08-12 23:41:47 +00:00
{
MMC3::InitMapper();
_exReg = 0;
AddRegisterRange(0x4020, 0x7FFF, MemoryOperation::Any);
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
}
2016-12-18 04:14:47 +00:00
void StreamState(bool saving) override
2016-08-12 23:41:47 +00:00
{
MMC3::StreamState(saving);
Stream(_exReg);
}
2016-12-18 04:14:47 +00:00
uint8_t ReadRegister(uint16_t addr) override
2016-08-12 23:41:47 +00:00
{
return _exReg;
}
2016-12-18 04:14:47 +00:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-08-12 23:41:47 +00:00
{
if(addr < 0x8000) {
_exReg = _securityLut[value & 0x03];
} else {
MMC3::WriteRegister(addr, value);
}
}
};