Mesen/Core/Mapper15.h

50 lines
1.1 KiB
C
Raw Normal View History

2016-05-19 22:54:49 +00:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class Mapper15 : public BaseMapper
{
protected:
2016-12-18 04:14:47 +00:00
virtual uint16_t GetPRGPageSize() override { return 0x2000; }
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
2016-05-19 22:54:49 +00:00
2016-12-18 04:14:47 +00:00
void InitMapper() override
2016-05-19 22:54:49 +00:00
{
WriteRegister(0x8000, 0);
SelectCHRPage(0, 0);
}
2016-12-18 04:14:47 +00:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-05-19 22:54:49 +00:00
{
SetMirroringType(value & 0x40 ? MirroringType::Horizontal : MirroringType::Vertical);
uint8_t subBank = value >> 7;
uint8_t bank = (value & 0x7F) << 1;
switch(addr & 0x03) {
case 0:
SelectPRGPage(0, bank ^ subBank);
SelectPRGPage(1, (bank + 1) ^ subBank);
SelectPRGPage(2, (bank + 2) ^ subBank);
SelectPRGPage(3, (bank + 3) ^ subBank);
break;
case 1:
case 3:
bank |= subBank;
SelectPRGPage(0, bank);
SelectPRGPage(1, bank + 1);
SelectPRGPage(2, bank + ((addr & 0x02) ? 0 : 1));
SelectPRGPage(3, bank + 1);
break;
case 2:
bank |= subBank;
SelectPRGPage(0, bank);
SelectPRGPage(1, bank);
SelectPRGPage(2, bank);
SelectPRGPage(3, bank);
break;
}
}
};