mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-30 12:30:52 +00:00
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#pragma once
|
|
#include "BaseMapper.h"
|
|
|
|
class Mapper227 : public BaseMapper
|
|
{
|
|
protected:
|
|
uint16_t GetPRGPageSize() { return 0x4000; }
|
|
uint16_t GetCHRPageSize() { return 0x2000; }
|
|
|
|
void InitMapper()
|
|
{
|
|
WriteRegister(0x8000, 0);
|
|
}
|
|
|
|
void WriteRegister(uint16_t addr, uint8_t value)
|
|
{
|
|
uint16_t prgBank = ((addr >> 2) & 0x1F) | ((addr & 0x100) >> 3);
|
|
bool sFlag = (addr & 0x01) == 0x01;
|
|
bool lFlag = ((addr >> 9) & 0x01) == 0x01;
|
|
bool prgMode = ((addr >> 7) & 0x01) == 0x01;
|
|
|
|
if(prgMode) {
|
|
if(sFlag) {
|
|
SelectPrgPage2x(0, prgBank & 0xFE);
|
|
} else {
|
|
SelectPRGPage(0, prgBank);
|
|
SelectPRGPage(1, prgBank);
|
|
}
|
|
} else {
|
|
if(sFlag){
|
|
if(lFlag) {
|
|
SelectPRGPage(0, prgBank & 0x3E);
|
|
SelectPRGPage(1, prgBank | 0x07);
|
|
} else {
|
|
SelectPRGPage(0, prgBank & 0x3E);
|
|
SelectPRGPage(1, prgBank & 0x38);
|
|
}
|
|
} else {
|
|
if(lFlag) {
|
|
SelectPRGPage(0, prgBank);
|
|
SelectPRGPage(1, prgBank | 0x07);
|
|
} else {
|
|
SelectPRGPage(0, prgBank);
|
|
SelectPRGPage(1, prgBank & 0x38);
|
|
}
|
|
}
|
|
}
|
|
|
|
SetMirroringType((addr & 0x02) == 0x02 ? MirroringType::Horizontal : MirroringType::Vertical);
|
|
}
|
|
}; |