2022-08-29 17:50:39 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "BaseMapper.h"
|
|
|
|
|
|
|
|
class BmcS2009 : public BaseMapper
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint8_t _prgBank;
|
|
|
|
uint8_t _outerBank;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint16_t GetPRGPageSize() override { return 0x4000; }
|
|
|
|
uint16_t GetCHRPageSize() override { return 0x2000; }
|
|
|
|
|
|
|
|
void InitMapper() override
|
|
|
|
{
|
|
|
|
AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write);
|
|
|
|
UpdateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset(bool softReset) override
|
|
|
|
{
|
|
|
|
_prgBank = 0;
|
|
|
|
_outerBank = 0;
|
|
|
|
UpdateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateState()
|
|
|
|
{
|
|
|
|
SelectPRGPage(0, (_outerBank << 3) | (_prgBank & 0x07));
|
|
|
|
SelectPRGPage(1, (_outerBank << 3) | 0x07);
|
|
|
|
SelectCHRPage(0, 0);
|
2023-05-13 01:39:46 +00:00
|
|
|
SetMirroringType(((_outerBank & 0x20) == 0x20) ? MirroringType::Vertical : MirroringType::Horizontal);
|
2022-08-29 17:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StreamState(bool saving) override
|
|
|
|
{
|
|
|
|
BaseMapper::StreamState(saving);
|
|
|
|
Stream(_prgBank, _outerBank);
|
|
|
|
}
|
|
|
|
|
2023-05-13 01:39:46 +00:00
|
|
|
// TODO: suppose to have bus conflicts but why it crash if done so?
|
|
|
|
|
2022-08-29 17:50:39 +00:00
|
|
|
void WriteRegister(uint16_t addr, uint8_t value) override
|
|
|
|
{
|
|
|
|
if(addr < 0x8000) {
|
|
|
|
_outerBank = value;
|
|
|
|
} else {
|
|
|
|
_prgBank = value;
|
|
|
|
}
|
|
|
|
UpdateState();
|
|
|
|
}
|
2023-05-13 01:39:46 +00:00
|
|
|
};
|