2016-01-18 19:33:50 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "MMC3.h"
|
|
|
|
|
|
|
|
class MMC3_115 : public MMC3
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint8_t _prgReg = 0;
|
|
|
|
uint8_t _chrReg = 0;
|
|
|
|
|
2016-07-30 20:45:52 -04:00
|
|
|
protected:
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual uint16_t RegisterStartAddress() override { return 0x6000; }
|
2016-01-18 19:33:50 -05:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override
|
2016-01-18 19:33:50 -05:00
|
|
|
{
|
|
|
|
page |= (_chrReg << 8);
|
|
|
|
BaseMapper::SelectCHRPage(slot, page);
|
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual void UpdateState() override
|
2016-01-18 19:33:50 -05:00
|
|
|
{
|
|
|
|
MMC3::UpdateState();
|
|
|
|
|
|
|
|
if(_prgReg & 0x80) {
|
|
|
|
SelectPRGPage(0, (_prgReg & 0x0F) << 1);
|
|
|
|
SelectPRGPage(1, ((_prgReg & 0x0F) << 1) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual void WriteRegister(uint16_t addr, uint8_t value) override
|
2016-07-30 20:45:52 -04:00
|
|
|
{
|
|
|
|
if(addr < 0x8000) {
|
|
|
|
if(addr & 0x01) {
|
|
|
|
_chrReg = value & 0x01;
|
|
|
|
} else {
|
|
|
|
_prgReg = value;
|
|
|
|
}
|
|
|
|
UpdateState();
|
|
|
|
} else {
|
|
|
|
MMC3::WriteRegister(addr, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual void StreamState(bool saving) override
|
2016-01-18 19:33:50 -05:00
|
|
|
{
|
|
|
|
MMC3::StreamState(saving);
|
2016-06-02 20:20:26 -04:00
|
|
|
Stream(_prgReg, _chrReg);
|
2016-01-18 19:33:50 -05:00
|
|
|
}
|
|
|
|
};
|