2018-06-17 00:02:07 +00:00
|
|
|
#pragma once
|
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "BaseMapper.h"
|
|
|
|
|
|
|
|
class Bmc8157 : public BaseMapper
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint16_t _lastAddr;
|
|
|
|
|
|
|
|
protected:
|
2019-02-09 00:39:35 +00:00
|
|
|
uint32_t GetDipSwitchCount() override { return 1; }
|
2018-06-17 00:02:07 +00:00
|
|
|
uint16_t GetPRGPageSize() override { return 0x4000; }
|
|
|
|
uint16_t GetCHRPageSize() override { return 0x2000; }
|
|
|
|
|
|
|
|
void InitMapper() override
|
|
|
|
{
|
|
|
|
_lastAddr = 0;
|
|
|
|
UpdateState();
|
|
|
|
SelectCHRPage(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StreamState(bool saving) override
|
|
|
|
{
|
|
|
|
BaseMapper::StreamState(saving);
|
2019-02-09 00:39:35 +00:00
|
|
|
Stream(_lastAddr);
|
2018-06-17 00:02:07 +00:00
|
|
|
|
|
|
|
if(!saving) {
|
|
|
|
UpdateState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateState()
|
|
|
|
{
|
|
|
|
uint8_t innerPrg0 = (_lastAddr >> 2) & 0x07;
|
|
|
|
uint8_t innerPrg1 = ((_lastAddr >> 7) & 0x01) | ((_lastAddr >> 8) & 0x02);
|
|
|
|
uint8_t outer128Prg = (_lastAddr >> 5) & 0x03;
|
|
|
|
uint8_t outer512Prg = (_lastAddr >> 8) & 0x01;
|
|
|
|
|
|
|
|
int baseBank;
|
|
|
|
if(innerPrg1 == 0) {
|
|
|
|
baseBank = 0;
|
|
|
|
} else if(innerPrg1 == 1) {
|
|
|
|
baseBank = innerPrg0;
|
|
|
|
} else {
|
|
|
|
baseBank = 7;
|
|
|
|
}
|
|
|
|
|
2019-02-09 00:39:35 +00:00
|
|
|
if(outer512Prg && _prgSize <= 1024 * 512 && GetDipSwitches() != 0) {
|
2018-06-17 00:02:07 +00:00
|
|
|
RemoveCpuMemoryMapping(0x8000, 0xFFFF);
|
|
|
|
} else {
|
|
|
|
SelectPRGPage(0, (outer512Prg << 6) | (outer128Prg << 3) | innerPrg0);
|
|
|
|
SelectPRGPage(1, (outer512Prg << 6) | (outer128Prg << 3) | baseBank);
|
|
|
|
SetMirroringType(_lastAddr & 0x02 ? MirroringType::Horizontal : MirroringType::Vertical);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteRegister(uint16_t addr, uint8_t value) override
|
|
|
|
{
|
|
|
|
_lastAddr = addr;
|
|
|
|
UpdateState();
|
|
|
|
}
|
|
|
|
};
|