Mesen-X/Core/Mapper112.h

70 lines
1.3 KiB
C
Raw Normal View History

2016-01-23 14:38:54 -05:00
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class Mapper112 : public MMC3
{
private:
uint8_t _currentReg;
2017-05-01 20:45:07 -04:00
uint8_t _outerChrBank;
2016-01-23 14:38:54 -05:00
protected:
2016-12-17 23:14:47 -05:00
void InitMapper() override
2016-01-23 14:38:54 -05:00
{
2017-05-01 20:45:07 -04:00
_outerChrBank = 0;
2016-01-23 14:38:54 -05:00
MMC3::InitMapper();
SetMirroringType(MirroringType::Vertical);
}
2016-12-17 23:14:47 -05:00
void UpdateMirroring() override
2016-01-23 14:38:54 -05:00
{
}
2016-12-17 23:14:47 -05:00
void StreamState(bool saving) override
2016-01-23 14:38:54 -05:00
{
MMC3::StreamState(saving);
2017-05-01 20:45:07 -04:00
Stream(_currentReg, _outerChrBank);
}
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType)
{
switch(slot){
case 4: page |= (_outerChrBank & 0x10) << 4; break;
case 5: page |= (_outerChrBank & 0x20) << 3; break;
case 6: page |= (_outerChrBank & 0x40) << 2; break;
case 7: page |= (_outerChrBank & 0x80) << 1; break;
}
MMC3::SelectCHRPage(slot, page, memoryType);
2016-01-23 14:38:54 -05:00
}
2016-12-17 23:14:47 -05:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-01-23 14:38:54 -05:00
{
switch(addr & 0xE001) {
case 0x8000:
//Adjust register numbers to match MMC3
_currentReg = value & 0x07;
if(_currentReg >= 2) {
_currentReg -= 2;
} else {
_currentReg += 6;
}
break;
case 0xA000:
_registers[_currentReg] = value;
break;
2017-05-01 20:45:07 -04:00
case 0xC000:
_outerChrBank = value;
break;
2016-01-23 14:38:54 -05:00
case 0xE000:
SetMirroringType(value & 0x01 ? MirroringType::Horizontal : MirroringType::Vertical);
break;
}
UpdateState();
}
};