Mesen/Core/MMC3_47.h
2016-12-17 23:14:47 -05:00

57 lines
1.1 KiB
C++

#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_47 : public MMC3
{
private:
uint8_t _selectedBlock = 0;
protected:
virtual uint16_t RegisterStartAddress() override { return 0x6000; }
virtual uint16_t RegisterEndAddress() override { return 0xFFFF; }
virtual void StreamState(bool saving) override
{
MMC3::StreamState(saving);
Stream(_selectedBlock);
}
virtual void Reset(bool softReset) override
{
_selectedBlock = 0;
UpdateState();
}
virtual void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override
{
page &= 0x7F;
if(_selectedBlock == 1) {
page |= 0x80;
}
MMC3::SelectCHRPage(slot, page, memoryType);
}
virtual void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override
{
page &= 0x0F;
if(_selectedBlock == 1) {
page |= 0x10;
}
MMC3::SelectPRGPage(slot, page, memoryType);
}
void WriteRegister(uint16_t addr, uint8_t value) override
{
if(addr < 0x8000) {
if(CanWriteToWorkRam()) {
_selectedBlock = value & 0x01;
UpdateState();
}
} else {
MMC3::WriteRegister(addr, value);
}
}
};