CNROM w/ copy protection (Mapper 185) support

This commit is contained in:
Souryo 2015-12-30 19:41:01 -05:00
parent f729f67bb8
commit ae3e6c4978
3 changed files with 41 additions and 12 deletions

View file

@ -143,6 +143,7 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
for(uint16_t i = startAddr; i <= endAddr; i++) {
_prgPages[i] = source;
_prgPageAccessType[i] = accessType != -1 ? accessType : defaultAccessType;
source += 0x100;
}
}
@ -166,10 +167,19 @@ class BaseMapper : public IMemoryHandler, public Snapshotable, public INotificat
for(uint16_t i = startAddr; i <= endAddr; i++) {
_chrPages[i] = sourceMemory;
_chrPageAccessType[i] = accessType != -1 ? accessType : MemoryAccessType::ReadWrite;
sourceMemory += 0x100;
if(sourceMemory != nullptr) {
sourceMemory += 0x100;
}
}
}
void RemovePpuMemoryMapping(uint16_t startAddr, uint16_t endAddr)
{
//Unmap this section of memory (causing open bus behavior)
SetPpuMemoryMapping(startAddr, endAddr, nullptr, MemoryAccessType::NoAccess);
}
uint8_t InternalReadRam(uint16_t addr)
{
return _prgPages[addr >> 8] ? _prgPages[addr >> 8][addr & 0xFF] : 0;

View file

@ -4,18 +4,36 @@
class CNROM : public BaseMapper
{
protected:
virtual uint16_t GetPRGPageSize() { return 0x8000; }
virtual uint16_t GetCHRPageSize() { return 0x2000; }
private:
bool _enableCopyProtection;
void InitMapper()
{
SelectPRGPage(0, 0);
SelectCHRPage(0, 0);
}
protected:
virtual uint16_t GetPRGPageSize() { return 0x8000; }
virtual uint16_t GetCHRPageSize() { return 0x2000; }
void WriteRegister(uint16_t addr, uint8_t value)
{
void InitMapper()
{
SelectPRGPage(0, 0);
SelectCHRPage(0, 0);
}
void WriteRegister(uint16_t addr, uint8_t value)
{
if(_enableCopyProtection) {
//"if C AND $0F is nonzero, and if C does not equal $13: CHR is enabled"
//This means Seicross (mapper 185 version) will not work (to allow Spy vs Spy (J) to work
if((value & 0x0F) != 0 && value != 0x13) {
SelectCHRPage(0, 0);
} else {
RemovePpuMemoryMapping(0x0000, 0x1FFF);
}
} else {
SelectCHRPage(0, value);
}
}
public:
CNROM(bool enableCopyProtection) : _enableCopyProtection(enableCopyProtection)
{
}
};

View file

@ -37,7 +37,7 @@ BaseMapper* MapperFactory::GetMapperFromID(uint8_t mapperID)
case 0: return new NROM();
case 1: return new MMC1();
case 2: return new UNROM();
case 3: return new CNROM();
case 3: return new CNROM(false);
case 4: return new MMC3();
case 5: return new MMC5();
case 7: return new AXROM();
@ -67,6 +67,7 @@ BaseMapper* MapperFactory::GetMapperFromID(uint8_t mapperID)
case 101: return new JalecoJfxx(true);
case 152: return new Bandai74161_7432(true);
case 163: return new Nanjing();
case 185: return new CNROM(true);
case 189: return new MMC3_189();
}