diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 5927b628..0aa42607 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -723,6 +723,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index ffe5ead2..37686575 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1147,6 +1147,9 @@ Nes\Mappers + + Nes\Mappers + diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index ef0f1bed..abed0582 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -227,6 +227,7 @@ #include "UNROM.h" #include "UnRom_94.h" #include "UnRom_180.h" +#include "UnRom512.h" #include "VRC1.h" #include "VRC2_4.h" #include "VRC3.h" @@ -247,7 +248,7 @@ Supported mappers: ??? : No known roms ----------------------------------------------------------------- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14| 15| -| 16| 17| 18| 19|...| 21| 22| 23| 24| 25| 26| 27| 28| | | 31| +| 16| 17| 18| 19|...| 21| 22| 23| 24| 25| 26| 27| 28| | 30| 31| | 32| 33| 34| 35| 36| 37| 38|---| 40| 41| 42| 43| 44| 45| 46| 47| | 48| 49| 50| 51| 52| 53| 54|???| 56| 57| 58|===| 60| 61| 62| 63| | 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79| @@ -300,6 +301,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 26: return new VRC6(VRCVariant::VRC6b); case 27: return new VRC2_4(); case 28: return new Action53(); + case 30: return new UnRom512(); case 31: return new NsfCart31(); case 32: return new IremG101(); case 33: return new TaitoTc0190(); diff --git a/Core/RomData.h b/Core/RomData.h index a1c68fb9..2cffba66 100644 --- a/Core/RomData.h +++ b/Core/RomData.h @@ -198,7 +198,16 @@ struct NESHeader MirroringType GetMirroringType() { if(Byte6 & 0x08) { - return MirroringType::FourScreens; + if(GetRomHeaderVersion() == RomHeaderVersion::Nes2_0) { + if(Byte6 & 0x01) { + //Based on proposal by rainwarrior/Myask: http://wiki.nesdev.com/w/index.php/Talk:NES_2.0 + return MirroringType::ScreenAOnly; + } else { + return MirroringType::FourScreens; + } + } else { + return MirroringType::FourScreens; + } } else { return Byte6 & 0x01 ? MirroringType::Vertical : MirroringType::Horizontal; } diff --git a/Core/UnRom512.h b/Core/UnRom512.h new file mode 100644 index 00000000..4c785c82 --- /dev/null +++ b/Core/UnRom512.h @@ -0,0 +1,52 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +//Missing flashing support + only tested on 1 game demo +class UnRom512 : public BaseMapper +{ +private: + bool _oneScreenMirroring; + +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()) { + _oneScreenMirroring = GetMirroringType() == MirroringType::ScreenAOnly; + } else { + _oneScreenMirroring = GetMirroringType() == MirroringType::FourScreens; + } + } + + void SetDefaultNametables(uint8_t* nametableA, uint8_t* nametableB) override + { + BaseMapper::SetDefaultNametables(nametableA, nametableB); + if(IsNes20() && !_oneScreenMirroring && _chrRam && _chrRamSize >= 0x8000) { + //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, _chrRam + 0x6000); + } + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if(!HasBattery() || addr >= 0xC000) { + SelectPRGPage(0, value & 0x1F); + SelectCHRPage(0, (value >> 5) & 0x03); + + if(_oneScreenMirroring) { + SetMirroringType(value & 0x80 ? MirroringType::ScreenBOnly : MirroringType::ScreenAOnly); + } + } else { + //Unimplemented (flash process) + } + } +}; \ No newline at end of file