2016-08-13 14:26:56 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "BaseMapper.h"
|
2019-12-20 22:59:09 -05:00
|
|
|
#include "TxcChip.h"
|
2016-08-13 14:26:56 -04:00
|
|
|
|
|
|
|
class Sachen_136 : public BaseMapper
|
|
|
|
{
|
|
|
|
private:
|
2019-12-20 22:59:09 -05:00
|
|
|
TxcChip _txc = TxcChip(true);
|
2016-08-13 14:26:56 -04:00
|
|
|
|
|
|
|
protected:
|
2019-12-20 22:59:09 -05:00
|
|
|
uint16_t GetPRGPageSize() override { return 0x8000; }
|
|
|
|
uint16_t GetCHRPageSize() override { return 0x2000; }
|
|
|
|
uint16_t RegisterStartAddress() override { return 0x8000; }
|
|
|
|
uint16_t RegisterEndAddress() override { return 0xFFFF; }
|
|
|
|
bool AllowRegisterRead() override { return true; }
|
2016-08-13 14:26:56 -04:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void InitMapper() override
|
2016-08-13 14:26:56 -04:00
|
|
|
{
|
2019-12-20 22:59:09 -05:00
|
|
|
AddRegisterRange(0x4020, 0x5FFF, MemoryOperation::Any);
|
|
|
|
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
|
|
|
|
|
2016-08-13 14:26:56 -04:00
|
|
|
SelectPRGPage(0, 0);
|
|
|
|
SelectCHRPage(0, 0);
|
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void StreamState(bool saving) override
|
2016-08-13 14:26:56 -04:00
|
|
|
{
|
|
|
|
BaseMapper::StreamState(saving);
|
2019-12-20 22:59:09 -05:00
|
|
|
Stream(&_txc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateState()
|
|
|
|
{
|
|
|
|
SelectCHRPage(0, _txc.GetOutput());
|
2016-08-13 14:26:56 -04:00
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
uint8_t ReadRegister(uint16_t addr) override
|
2016-08-13 14:26:56 -04:00
|
|
|
{
|
2019-12-20 22:59:09 -05:00
|
|
|
uint8_t openBus = _console->GetMemoryManager()->GetOpenBus();
|
|
|
|
uint8_t value;
|
|
|
|
if((addr & 0x103) == 0x100) {
|
|
|
|
value = (openBus & 0xC0) | (_txc.Read() & 0x3F);
|
|
|
|
} else {
|
|
|
|
value = openBus;
|
|
|
|
}
|
|
|
|
UpdateState();
|
|
|
|
return value;
|
2016-08-13 14:26:56 -04:00
|
|
|
}
|
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void WriteRegister(uint16_t addr, uint8_t value) override
|
2016-08-13 14:26:56 -04:00
|
|
|
{
|
2019-12-20 22:59:09 -05:00
|
|
|
_txc.Write(addr, value & 0x3F);
|
|
|
|
UpdateState();
|
2016-08-13 14:26:56 -04:00
|
|
|
}
|
|
|
|
};
|