Mesen-X/Core/UnRom512.h

48 lines
1.6 KiB
C
Raw Normal View History

2017-04-21 12:29:03 -04:00
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
//Missing flashing support + only tested on 1 game demo
class UnRom512 : public BaseMapper
{
private:
2018-03-15 19:51:28 -04:00
bool _enableMirroringBit;
2017-04-21 12:29:03 -04:00
protected:
virtual uint16_t GetPRGPageSize() override { return 0x4000; }
virtual uint16_t GetCHRPageSize() override { return 0x2000; }
virtual uint16_t RegisterStartAddress() override { return 0x8000; }
virtual uint16_t RegisterEndAddress() override { return 0xFFFF; }
virtual uint32_t GetChrRamSize() override { return 0x8000; }
virtual bool HasBusConflicts() override { return !HasBattery(); }
void InitMapper() override
{
SelectPRGPage(1, -1);
if(IsNes20()) {
2018-03-15 19:51:28 -04:00
_enableMirroringBit = GetMirroringType() == MirroringType::ScreenAOnly;
2017-04-21 12:29:03 -04:00
} else {
2018-03-15 19:51:28 -04:00
_enableMirroringBit = GetMirroringType() == MirroringType::FourScreens;
2017-04-21 12:29:03 -04:00
}
2018-03-15 19:51:28 -04:00
if(GetMirroringType() == MirroringType::FourScreens && _chrRam && _chrRamSize >= 0x8000) {
2017-04-21 12:29:03 -04:00
//InfiniteNesLives four-screen mirroring variation, last 8kb of CHR RAM is always mapped to 0x2000-0x3FFF (0x3EFF due to palette)
//This "breaks" the "UNROM512_4screen_test" test ROM - was the ROM actually tested on this board? Seems to contradict hardware specs
SetPpuMemoryMapping(0x2000, 0x3FFF, ChrMemoryType::ChrRam, 0x6000, MemoryAccessType::ReadWrite);
2017-04-21 12:29:03 -04:00
}
}
void WriteRegister(uint16_t addr, uint8_t value) override
{
if(!HasBattery() || addr >= 0xC000) {
SelectPRGPage(0, value & 0x1F);
SelectCHRPage(0, (value >> 5) & 0x03);
2018-03-15 19:51:28 -04:00
if(_enableMirroringBit) {
2017-04-21 12:29:03 -04:00
SetMirroringType(value & 0x80 ? MirroringType::ScreenBOnly : MirroringType::ScreenAOnly);
}
} else {
//Unimplemented (flash process)
}
}
};