Mesen-X/Core/Caltron41.h

52 lines
1.3 KiB
C
Raw Permalink Normal View History

2016-07-20 20:11:37 -04:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class Caltron41 : public BaseMapper
{
private:
uint8_t _prgBank;
uint8_t _chrBank;
protected:
2016-12-17 23:14:47 -05:00
virtual uint16_t GetPRGPageSize() override { return 0x8000; }
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
virtual uint16_t RegisterStartAddress() override { return 0x8000; }
virtual uint16_t RegisterEndAddress() override { return 0xFFFF; }
2016-07-20 20:11:37 -04:00
2016-12-17 23:14:47 -05:00
void InitMapper() override
2016-07-20 20:11:37 -04:00
{
AddRegisterRange(0x6000, 0x67FF, MemoryOperation::Write);
}
2016-12-17 23:14:47 -05:00
void Reset(bool softReset) override
2016-07-20 20:11:37 -04:00
{
_chrBank = 0;
_prgBank = 0;
WriteRegister(0x6000, 0);
WriteRegister(0x8000, 0);
}
2016-12-17 23:14:47 -05:00
void StreamState(bool saving) override
2016-07-20 20:11:37 -04:00
{
BaseMapper::StreamState(saving);
Stream(_prgBank, _chrBank);
}
2016-12-17 23:14:47 -05:00
void WriteRegister(uint16_t addr, uint8_t value) override
2016-07-20 20:11:37 -04:00
{
if(addr <= 0x67FF) {
_prgBank = addr & 0x07;
_chrBank = (_chrBank & 0x03) | ((addr >> 1) & 0x0C);
SelectPRGPage(0, _prgBank);
SelectCHRPage(0, _chrBank);
SetMirroringType(addr & 0x20 ? MirroringType::Horizontal : MirroringType::Vertical);
} else {
//"Note that the Inner CHR Bank Select only can be written while the PRG ROM bank is 4, 5, 6, or 7"
if(_prgBank >= 4) {
_chrBank = (_chrBank & 0x0C) | (value & 0x03);
SelectCHRPage(0, _chrBank);
}
}
}
};