2016-05-19 18:54:49 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "BaseMapper.h"
|
|
|
|
|
|
|
|
class Mapper15 : public BaseMapper
|
|
|
|
{
|
|
|
|
protected:
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual uint16_t GetPRGPageSize() override { return 0x2000; }
|
|
|
|
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
|
2016-05-19 18:54:49 -04:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void InitMapper() override
|
2016-05-19 18:54:49 -04:00
|
|
|
{
|
|
|
|
SelectCHRPage(0, 0);
|
|
|
|
}
|
|
|
|
|
2018-04-02 02:47:22 +08:00
|
|
|
void Reset(bool softReset) override
|
|
|
|
{
|
|
|
|
WriteRegister(0x8000, 0);
|
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void WriteRegister(uint16_t addr, uint8_t value) override
|
2016-05-19 18:54:49 -04:00
|
|
|
{
|
|
|
|
SetMirroringType(value & 0x40 ? MirroringType::Horizontal : MirroringType::Vertical);
|
|
|
|
|
|
|
|
uint8_t subBank = value >> 7;
|
|
|
|
uint8_t bank = (value & 0x7F) << 1;
|
2020-04-08 04:28:19 +02:00
|
|
|
uint8_t mode = addr & 0x03;
|
|
|
|
|
|
|
|
SetPpuMemoryMapping(0, 0x1FFF, 0, ChrMemoryType::Default, (mode == 0 || mode == 3) ? MemoryAccessType::Read : MemoryAccessType::ReadWrite);
|
|
|
|
|
|
|
|
switch(mode) {
|
2016-05-19 18:54:49 -04:00
|
|
|
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);
|
2020-04-10 23:44:45 +02:00
|
|
|
bank = ((mode == 3) ? bank : (bank | 0x0E)) | subBank;
|
2018-04-02 02:47:22 +08:00
|
|
|
SelectPRGPage(2, bank + 0);
|
2016-05-19 18:54:49 -04:00
|
|
|
SelectPRGPage(3, bank + 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
bank |= subBank;
|
|
|
|
SelectPRGPage(0, bank);
|
|
|
|
SelectPRGPage(1, bank);
|
|
|
|
SelectPRGPage(2, bank);
|
|
|
|
SelectPRGPage(3, bank);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|