2016-01-23 19:58:19 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "BaseMapper.h"
|
|
|
|
|
|
|
|
class Mapper225 : public BaseMapper
|
|
|
|
{
|
|
|
|
protected:
|
2016-12-18 04:14:47 +00:00
|
|
|
virtual uint16_t GetPRGPageSize() override { return 0x4000; }
|
|
|
|
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
|
2023-05-13 01:39:46 +00:00
|
|
|
bool AllowRegisterRead() override { return true; }
|
|
|
|
|
|
|
|
uint8_t RAM[4];
|
2016-01-23 19:58:19 +00:00
|
|
|
|
2016-12-18 04:14:47 +00:00
|
|
|
void InitMapper() override
|
2016-01-23 19:58:19 +00:00
|
|
|
{
|
2023-05-13 01:39:46 +00:00
|
|
|
memset(RAM, 0, sizeof(RAM));
|
|
|
|
|
2016-01-23 19:58:19 +00:00
|
|
|
SelectPRGPage(0, 0);
|
|
|
|
SelectPRGPage(1, 1);
|
|
|
|
SelectCHRPage(0, 0);
|
2023-05-13 01:39:46 +00:00
|
|
|
|
|
|
|
AddRegisterRange(0x5800, 0x5FFF, MemoryOperation::Any);
|
|
|
|
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t ReadRegister(uint16_t addr) override
|
|
|
|
{
|
|
|
|
return RAM[addr & 0x03] & 0x0F;
|
2016-01-23 19:58:19 +00:00
|
|
|
}
|
|
|
|
|
2016-12-18 04:14:47 +00:00
|
|
|
void WriteRegister(uint16_t addr, uint8_t value) override
|
2016-01-23 19:58:19 +00:00
|
|
|
{
|
2023-05-13 01:39:46 +00:00
|
|
|
if(addr <= 0x5FFF) {
|
|
|
|
RAM[addr & 0x03] = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-23 19:58:19 +00:00
|
|
|
uint8_t highBit = (addr >> 8) & 0x40;
|
|
|
|
uint8_t prgPage = ((addr >> 6) & 0x3F) | highBit;
|
2016-07-16 01:39:56 +00:00
|
|
|
if(addr & 0x1000) {
|
2016-01-23 19:58:19 +00:00
|
|
|
SelectPRGPage(0, prgPage);
|
|
|
|
SelectPRGPage(1, prgPage);
|
|
|
|
} else {
|
|
|
|
SelectPRGPage(0, prgPage & 0xFE);
|
|
|
|
SelectPRGPage(1, (prgPage & 0xFE) + 1);
|
|
|
|
}
|
|
|
|
|
2018-06-25 19:13:32 +00:00
|
|
|
SelectCHRPage(0, (addr & 0x3F) | highBit);
|
2016-01-23 19:58:19 +00:00
|
|
|
|
|
|
|
SetMirroringType(addr & 0x2000 ? MirroringType::Horizontal : MirroringType::Vertical);
|
|
|
|
}
|
|
|
|
};
|