Mesen/Core/MMC3_12.h

47 lines
939 B
C
Raw Normal View History

2016-01-21 01:32:49 +00:00
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_12 : public MMC3
{
private:
uint8_t _chrSelection = 0;
protected:
2016-12-18 04:14:47 +00:00
virtual bool ForceMmc3RevAIrqs() override { return true; }
2016-01-21 01:32:49 +00:00
2016-12-18 04:14:47 +00:00
virtual void InitMapper() override
2016-01-21 01:32:49 +00:00
{
AddRegisterRange(0x4020, 0x5FFF);
MMC3::InitMapper();
}
2016-12-18 04:14:47 +00:00
virtual void StreamState(bool saving) override
2016-01-21 01:32:49 +00:00
{
MMC3::StreamState(saving);
Stream(_chrSelection);
2016-01-21 01:32:49 +00:00
}
2016-12-18 04:14:47 +00:00
virtual void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override
2016-01-21 01:32:49 +00:00
{
if(slot < 4 && (_chrSelection & 0x01)) {
//0x0000 to 0x0FFF
page |= 0x100;
} else if(slot >= 4 && (_chrSelection & 0x10)) {
//0x1000 to 0x1FFF
page |= 0x100;
}
MMC3::SelectCHRPage(slot, page, memoryType);
}
2016-12-18 04:14:47 +00:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-01-21 01:32:49 +00:00
{
if(addr <= 0x5FFF) {
_chrSelection = value;
UpdateState();
} else {
MMC3::WriteRegister(addr, value);
}
}
};