1 #pragma once 2 #include "stdafx.h" 3 #include "BaseMapper.h" 4 5 class OekaKids : public BaseMapper 6 { 7 uint8_t _outerChrBank; 8 uint8_t _innerChrBank; 9 uint16_t _lastAddress; 10 11 protected: GetPRGPageSize()12 virtual uint16_t GetPRGPageSize() override { return 0x8000; } GetCHRPageSize()13 virtual uint16_t GetCHRPageSize() override { return 0x1000; } HasBusConflicts()14 virtual bool HasBusConflicts() override { return true; } 15 InitMapper()16 void InitMapper() override 17 { 18 _outerChrBank = 0; 19 _innerChrBank = 0; 20 _lastAddress = 0; 21 22 SelectPRGPage(0, 0); 23 } 24 StreamState(bool saving)25 void StreamState(bool saving) override 26 { 27 BaseMapper::StreamState(saving); 28 Stream(_outerChrBank, _innerChrBank, _lastAddress); 29 } 30 UpdateChrBanks()31 void UpdateChrBanks() 32 { 33 SelectCHRPage(0, _outerChrBank | _innerChrBank); 34 SelectCHRPage(1, _outerChrBank | 0x03); 35 } 36 NotifyVRAMAddressChange(uint16_t addr)37 void NotifyVRAMAddressChange(uint16_t addr) override 38 { 39 if((_lastAddress & 0x3000) != 0x2000 && (addr & 0x3000) == 0x2000) { 40 _innerChrBank = (addr >> 8) & 0x03; 41 UpdateChrBanks(); 42 } 43 44 _lastAddress = addr; 45 } 46 WriteRegister(uint16_t addr,uint8_t value)47 void WriteRegister(uint16_t addr, uint8_t value) override 48 { 49 SelectPRGPage(0, value & 0x03); 50 _outerChrBank = value & 0x04; 51 UpdateChrBanks(); 52 } 53 }; 54