Mesen/Core/Bmc235.h

57 lines
1.2 KiB
C
Raw Normal View History

2016-07-21 01:06:36 +00:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class Bmc235 : 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; }
2016-07-21 01:06:36 +00:00
2023-05-13 01:39:46 +00:00
uint8_t _unrom;
2016-12-18 04:14:47 +00:00
void InitMapper() override
2016-07-21 01:06:36 +00:00
{
SelectPrgPage2x(0, 0);
SelectCHRPage(0, 0);
}
2016-12-18 04:14:47 +00:00
void Reset(bool softReset) override
2016-07-21 01:06:36 +00:00
{
SelectPrgPage2x(0, 0);
2023-05-13 01:39:46 +00:00
if(_prgSize & 0x20000) {
if(softReset) {
_unrom = !_unrom;
} else {
_unrom = false;
}
2016-07-21 01:06:36 +00:00
}
}
2016-12-18 04:14:47 +00:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-07-21 01:06:36 +00:00
{
2023-05-13 01:39:46 +00:00
uint8_t bank = ((addr >> 3) & 0x60) | (addr & 0x1F);
2016-07-21 01:06:36 +00:00
2023-05-13 01:39:46 +00:00
if(_unrom) {
SetMirroringType(MirroringType::Vertical);
SelectPRGPage(0, (GetPRGPageCount() & 0xC0) | (value & 0x07));
SelectPRGPage(1, (GetPRGPageCount() & 0xC0) | 0x07);
return;
}
2016-07-21 01:06:36 +00:00
2023-05-13 01:39:46 +00:00
if(bank >= (GetPRGPageCount() >> 1)) {
RemoveCpuMemoryMapping(0x8000, 0xFFFF);
return;
}
2016-07-21 01:06:36 +00:00
2023-05-13 01:39:46 +00:00
SetMirroringType((addr & 0x0400) ? MirroringType::ScreenAOnly : (addr & 0x2000) ? MirroringType::Horizontal : MirroringType::Vertical);
2016-07-21 01:06:36 +00:00
2023-05-13 01:39:46 +00:00
if(addr & 0x800) {
2016-07-21 01:06:36 +00:00
bank = (bank << 1) | (addr >> 12 & 0x01);
SelectPRGPage(0, bank);
SelectPRGPage(1, bank);
} else {
SelectPrgPage2x(0, bank << 1);
}
}
};