Mesen-X/Core/Mapper212.h

40 lines
913 B
C
Raw Permalink Normal View History

2016-07-24 09:15:38 -04:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class Mapper212 : public BaseMapper
{
protected:
2016-12-17 23:14:47 -05:00
virtual uint16_t GetPRGPageSize() override { return 0x4000; }
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
virtual bool AllowRegisterRead() override { return true; }
2016-07-24 09:15:38 -04:00
2016-12-17 23:14:47 -05:00
void InitMapper() override
2016-07-24 09:15:38 -04:00
{
2017-04-12 20:11:32 -04:00
AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Read);
2016-07-24 09:15:38 -04:00
WriteRegister(0x8000, 0);
}
2016-12-17 23:14:47 -05:00
uint8_t ReadRegister(uint16_t addr) override
2016-07-24 09:15:38 -04:00
{
uint8_t value = InternalReadRam(addr);
if((addr & 0xE010) == 0x6000) {
value |= 0x80;
}
return value;
}
2016-12-17 23:14:47 -05:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-07-24 09:15:38 -04:00
{
if(addr & 0x4000) {
SelectPrgPage2x(0, addr & 0x06);
} else {
SelectPRGPage(0, addr & 0x07);
SelectPRGPage(1, addr & 0x07);
}
SelectCHRPage(0, addr & 0x07);
SetMirroringType(addr & 0x08 ? MirroringType::Horizontal : MirroringType::Vertical);
}
};