Mesen/Core/Mapper202.h

42 lines
916 B
C
Raw Normal View History

2016-01-20 19:01:10 -05:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class Mapper202 : public BaseMapper
{
private:
bool _prgMode1;
protected:
2016-12-17 23:14:47 -05:00
virtual uint16_t GetPRGPageSize() override { return 0x4000; }
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
2016-01-20 19:01:10 -05:00
2016-12-17 23:14:47 -05:00
void InitMapper() override
2016-01-20 19:01:10 -05:00
{
SelectPRGPage(0, 0);
SelectPRGPage(1, 0);
SelectCHRPage(0, 0);
}
2016-12-17 23:14:47 -05:00
virtual void StreamState(bool saving) override
2016-01-20 19:01:10 -05:00
{
BaseMapper::StreamState(saving);
Stream(_prgMode1);
2016-01-20 19:01:10 -05:00
}
2016-12-17 23:14:47 -05:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-01-20 19:01:10 -05:00
{
_prgMode1 = (addr & 0x09) == 0x09;
SelectCHRPage(0, (addr >> 1) & 0x07);
if(_prgMode1) {
SelectPRGPage(0, (addr >> 1) & 0x07);
SelectPRGPage(1, ((addr >> 1) & 0x07) + 1);
} else {
SelectPRGPage(0, (addr >> 1) & 0x07);
SelectPRGPage(1, (addr >> 1) & 0x07);
}
SetMirroringType(addr & 0x01 ? MirroringType::Horizontal : MirroringType::Vertical);
}
};