2014-06-24 14:28:19 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "BaseMapper.h"
|
|
|
|
|
|
|
|
class CNROM : public BaseMapper
|
|
|
|
{
|
2015-12-30 19:41:01 -05:00
|
|
|
private:
|
|
|
|
bool _enableCopyProtection;
|
2014-06-24 14:28:19 -04:00
|
|
|
|
2015-12-30 19:41:01 -05:00
|
|
|
protected:
|
2016-12-17 23:14:47 -05:00
|
|
|
virtual uint16_t GetPRGPageSize() override { return 0x8000; }
|
|
|
|
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
|
2015-12-30 19:41:01 -05:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void InitMapper() override
|
2015-12-30 19:41:01 -05:00
|
|
|
{
|
|
|
|
SelectPRGPage(0, 0);
|
2018-04-14 22:12:05 -04:00
|
|
|
SelectCHRPage(0, GetPowerOnByte());
|
2015-12-30 19:41:01 -05:00
|
|
|
}
|
2016-06-03 19:16:31 -04:00
|
|
|
|
2018-07-07 14:52:51 -04:00
|
|
|
bool HasBusConflicts() override { return (_romInfo.MapperID == 3 && _romInfo.SubMapperID == 2) || _romInfo.MapperID == 185; }
|
2014-06-24 14:28:19 -04:00
|
|
|
|
2016-12-17 23:14:47 -05:00
|
|
|
void WriteRegister(uint16_t addr, uint8_t value) override
|
2015-12-30 19:41:01 -05:00
|
|
|
{
|
|
|
|
if(_enableCopyProtection) {
|
2020-04-18 13:40:32 -04:00
|
|
|
//Submapper 0: Use heuristics - "if C AND $0F is nonzero, and if C does not equal $13: CHR is enabled"
|
|
|
|
//Submapper 4: Enable CHR-ROM if bits 0..1 of the latch hold the value 0, otherwise disable CHR-ROM.
|
|
|
|
//Submapper 5: Enable CHR-ROM if bits 0..1 of the latch hold the value 1, otherwise disable CHR-ROM.
|
|
|
|
//Submapper 6: Enable CHR-ROM if bits 0..1 of the latch hold the value 2, otherwise disable CHR-ROM.
|
|
|
|
//Submapper 7: Enable CHR-ROM if bits 0..1 of the latch hold the value 3, otherwise disable CHR-ROM.
|
|
|
|
bool validAccess = (
|
|
|
|
(_romInfo.SubMapperID == 0 && (value & 0x0F) != 0 && value != 0x13) ||
|
|
|
|
(_romInfo.SubMapperID == 4 && (value & 0x03) == 0) ||
|
|
|
|
(_romInfo.SubMapperID == 5 && (value & 0x03) == 1) ||
|
|
|
|
(_romInfo.SubMapperID == 6 && (value & 0x03) == 2) ||
|
|
|
|
(_romInfo.SubMapperID == 7 && (value & 0x03) == 3)
|
|
|
|
);
|
|
|
|
|
|
|
|
if(validAccess) {
|
2015-12-30 19:41:01 -05:00
|
|
|
SelectCHRPage(0, 0);
|
|
|
|
} else {
|
|
|
|
RemovePpuMemoryMapping(0x0000, 0x1FFF);
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-24 14:28:19 -04:00
|
|
|
SelectCHRPage(0, value);
|
|
|
|
}
|
2015-12-30 19:41:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
CNROM(bool enableCopyProtection) : _enableCopyProtection(enableCopyProtection)
|
|
|
|
{
|
|
|
|
}
|
2014-06-24 14:28:19 -04:00
|
|
|
};
|