mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-27 19:10:21 +00:00
51 lines
898 B
C++
51 lines
898 B
C++
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
#include "MMC3.h"
|
|
|
|
class MMC3_115 : public MMC3
|
|
{
|
|
private:
|
|
uint8_t _prgReg = 0;
|
|
uint8_t _chrReg = 0;
|
|
|
|
virtual uint16_t RegisterStartAddress() { return 0x6000; }
|
|
|
|
virtual void WriteRegister(uint16_t addr, uint8_t value)
|
|
{
|
|
if(addr < 0x8000) {
|
|
if(addr & 0x01) {
|
|
_chrReg = value & 0x01;
|
|
} else {
|
|
_prgReg = value;
|
|
}
|
|
UpdateState();
|
|
} else {
|
|
MMC3::WriteRegister(addr, value);
|
|
}
|
|
}
|
|
|
|
protected:
|
|
virtual void SelectCHRPage(uint16_t slot, uint16_t page)
|
|
{
|
|
page |= (_chrReg << 8);
|
|
BaseMapper::SelectCHRPage(slot, page);
|
|
}
|
|
|
|
virtual void UpdateState()
|
|
{
|
|
MMC3::UpdateState();
|
|
|
|
if(_prgReg & 0x80) {
|
|
SelectPRGPage(0, (_prgReg & 0x0F) << 1);
|
|
SelectPRGPage(1, ((_prgReg & 0x0F) << 1) + 1);
|
|
}
|
|
}
|
|
|
|
virtual void StreamState(bool saving)
|
|
{
|
|
MMC3::StreamState(saving);
|
|
Stream<uint8_t>(_prgReg);
|
|
Stream<uint8_t>(_chrReg);
|
|
}
|
|
}; |