Mesen-X/Core/OekaKids.h

54 lines
1.1 KiB
C
Raw Permalink Normal View History

2016-07-23 16:25:52 -04:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class OekaKids : public BaseMapper
{
uint8_t _outerChrBank;
uint8_t _innerChrBank;
uint16_t _lastAddress;
protected:
2016-12-17 23:14:47 -05:00
virtual uint16_t GetPRGPageSize() override { return 0x8000; }
virtual uint16_t GetCHRPageSize() override { return 0x1000; }
virtual bool HasBusConflicts() override { return true; }
2016-07-23 16:25:52 -04:00
2016-12-17 23:14:47 -05:00
void InitMapper() override
2016-07-23 16:25:52 -04:00
{
_outerChrBank = 0;
_innerChrBank = 0;
_lastAddress = 0;
SelectPRGPage(0, 0);
}
2016-12-17 23:14:47 -05:00
void StreamState(bool saving) override
2016-07-23 16:25:52 -04:00
{
BaseMapper::StreamState(saving);
Stream(_outerChrBank, _innerChrBank, _lastAddress);
}
void UpdateChrBanks()
{
SelectCHRPage(0, _outerChrBank | _innerChrBank);
SelectCHRPage(1, _outerChrBank | 0x03);
2016-07-23 16:25:52 -04:00
}
2016-12-17 23:14:47 -05:00
void NotifyVRAMAddressChange(uint16_t addr) override
2016-07-23 16:25:52 -04:00
{
if((_lastAddress & 0x3000) != 0x2000 && (addr & 0x3000) == 0x2000) {
_innerChrBank = (addr >> 8) & 0x03;
UpdateChrBanks();
}
_lastAddress = addr;
}
2016-12-17 23:14:47 -05:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-07-23 16:25:52 -04:00
{
SelectPRGPage(0, value & 0x03);
_outerChrBank = value & 0x04;
UpdateChrBanks();
}
};