diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 5481c2b1..879c103d 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -446,6 +446,7 @@ + @@ -678,6 +679,7 @@ + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 8a89c4cc..ddc6817a 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -1027,6 +1027,12 @@ Nes\Mappers\Unif + + Nes\Mappers\Unif + + + Nes\Mappers\Unif + diff --git a/Core/Hp898f.h b/Core/Hp898f.h new file mode 100644 index 00000000..6a0aff12 --- /dev/null +++ b/Core/Hp898f.h @@ -0,0 +1,45 @@ +#pragma once +#include "stdafx.h" +#include "BaseMapper.h" + +class Hp898f : public BaseMapper +{ +private: + uint8_t _regs[2]; + +protected: + uint16_t GetPRGPageSize() override { return 0x4000; } + uint16_t GetCHRPageSize() override { return 0x2000; } + uint16_t RegisterStartAddress() override { return 0x6000; } + uint16_t RegisterEndAddress() override { return 0xFFFF; } + + void InitMapper() override + { + _regs[0] = _regs[1] = 0; + UpdateState(); + } + + void StreamState(bool saving) override + { + BaseMapper::StreamState(saving); + Stream(_regs[0], _regs[1]); + } + + void UpdateState() + { + uint8_t prgReg = (_regs[1] >> 3) & 7; + uint8_t prgMask = (_regs[1] >> 4) & 4; + SelectCHRPage(0, (((_regs[0] >> 4) & 0x07) & ~(((_regs[0] & 0x01) << 2) | (_regs[0] & 0x02)))); + SelectPRGPage(0, prgReg & (~prgMask)); + SelectPRGPage(1, prgReg | prgMask); + SetMirroringType(_regs[1] & 0x80 ? MirroringType::Vertical : MirroringType::Horizontal); + } + + void WriteRegister(uint16_t addr, uint8_t value) override + { + if((addr & 0x6000) == 0x6000) { + _regs[(addr & 0x04) >> 2] = value; + UpdateState(); + } + } +}; \ No newline at end of file diff --git a/Core/MapperFactory.cpp b/Core/MapperFactory.cpp index 2962d2e2..3d323350 100644 --- a/Core/MapperFactory.cpp +++ b/Core/MapperFactory.cpp @@ -2,6 +2,8 @@ #include "MessageManager.h" #include "MapperFactory.h" #include "RomLoader.h" +#include "UnifBoards.h" + #include "A65AS.h" #include "Action53.h" #include "ActionEnterprises.h" @@ -37,6 +39,7 @@ #include "GxRom.h" #include "Henggedianzi177.h" #include "Henggedianzi179.h" +#include "Hp898f.h" #include "IremG101.h" #include "IremH3001.h" #include "IremLrog017.h" @@ -236,34 +239,6 @@ Supported mappers: ----------------------------------------------------------------- */ -const uint16_t MapperFactory::FdsMapperID; -const uint16_t MapperFactory::NsfMapperID; -const uint16_t MapperFactory::UnknownBoard; -const uint16_t MapperFactory::UnifA65AS; -const uint16_t MapperFactory::UnifAx5705; -const uint16_t MapperFactory::UnifBmc70in1; -const uint16_t MapperFactory::UnifBmc70in1B; -const uint16_t MapperFactory::UnifBmc190in1; -const uint16_t MapperFactory::UnifBs5; -const uint16_t MapperFactory::UnifCc21; -const uint16_t MapperFactory::UnifCoolboy; -const uint16_t MapperFactory::UnifDreamTech01; -const uint16_t MapperFactory::UnifEdu2000; -const uint16_t MapperFactory::UnifGhostbusters63in1; -const uint16_t MapperFactory::UnifGs2004; -const uint16_t MapperFactory::UnifGs2013; -const uint16_t MapperFactory::UnifKof97; -const uint16_t MapperFactory::UnifKs7016; -const uint16_t MapperFactory::UnifMalee; -const uint16_t MapperFactory::UnifNovelDiamond; -const uint16_t MapperFactory::UnifRt01; -const uint16_t MapperFactory::UnifStreetHeroes; -const uint16_t MapperFactory::UnifSmb2j; -const uint16_t MapperFactory::UnifSuper24in1Sc03; -const uint16_t MapperFactory::UnifSuper40in1Ws; -const uint16_t MapperFactory::UnifT262; -const uint16_t MapperFactory::UnifTf1201; - BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) { #ifdef _DEBUG @@ -491,30 +466,31 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData) case 254: return new MMC3_254(); case 255: return new Bmc255(); - case MapperFactory::UnifA65AS: return new A65AS(); - case MapperFactory::UnifAx5705: return new Ax5705(); - case MapperFactory::UnifBmc70in1: return new Bmc70in1(); - case MapperFactory::UnifBmc70in1B: return new Bmc70in1(); - case MapperFactory::UnifBmc190in1: return new Bmc190in1(); - case MapperFactory::UnifBs5: return new Bs5(); - case MapperFactory::UnifCc21: return new Cc21(); - case MapperFactory::UnifCoolboy: return new MMC3_Coolboy(); - case MapperFactory::UnifDreamTech01: return new DreamTech01(); - case MapperFactory::UnifEdu2000: return new Edu2000(); - case MapperFactory::UnifGhostbusters63in1: return new Ghostbusters63in1(); - case MapperFactory::UnifGs2004: return new Gs2004(); - case MapperFactory::UnifGs2013: return new Gs2013(); - case MapperFactory::UnifKof97: return new MMC3_Kof97(); - case MapperFactory::UnifKs7016: return new Kaiser7016(); - case MapperFactory::UnifMalee: return new Malee(); - case MapperFactory::UnifNovelDiamond: return new NovelDiamond(); - case MapperFactory::UnifRt01: return new Rt01(); - case MapperFactory::UnifSmb2j: return new Smb2j(); - case MapperFactory::UnifStreetHeroes: return new MMC3_StreetHeroes(); - case MapperFactory::UnifSuper24in1Sc03: return new MMC3_Super24in1Sc03(); - case MapperFactory::UnifSuper40in1Ws: return new Super40in1Ws(); - case MapperFactory::UnifT262: return new T262(); - case MapperFactory::UnifTf1201: return new Tf1201(); + case UnifBoards::A65AS: return new A65AS(); + case UnifBoards::Ax5705: return new Ax5705(); + case UnifBoards::Bmc70in1: return new Bmc70in1(); + case UnifBoards::Bmc70in1B: return new Bmc70in1(); + case UnifBoards::Bmc190in1: return new Bmc190in1(); + case UnifBoards::Bs5: return new Bs5(); + case UnifBoards::Cc21: return new Cc21(); + case UnifBoards::Coolboy: return new MMC3_Coolboy(); + case UnifBoards::DreamTech01: return new DreamTech01(); + case UnifBoards::Edu2000: return new Edu2000(); + case UnifBoards::Ghostbusters63in1: return new Ghostbusters63in1(); + case UnifBoards::Gs2004: return new Gs2004(); + case UnifBoards::Gs2013: return new Gs2013(); + case UnifBoards::Hp898f: return new Hp898f(); + case UnifBoards::Kof97: return new MMC3_Kof97(); + case UnifBoards::Ks7016: return new Kaiser7016(); + case UnifBoards::Malee: return new Malee(); + case UnifBoards::NovelDiamond: return new NovelDiamond(); + case UnifBoards::Rt01: return new Rt01(); + case UnifBoards::Smb2j: return new Smb2j(); + case UnifBoards::StreetHeroes: return new MMC3_StreetHeroes(); + case UnifBoards::Super24in1Sc03: return new MMC3_Super24in1Sc03(); + case UnifBoards::Super40in1Ws: return new Super40in1Ws(); + case UnifBoards::T262: return new T262(); + case UnifBoards::Tf1201: return new Tf1201(); case MapperFactory::NsfMapperID: return new NsfMapper(); case MapperFactory::FdsMapperID: return new FDS(); diff --git a/Core/MapperFactory.h b/Core/MapperFactory.h index 1b848720..84110dd7 100644 --- a/Core/MapperFactory.h +++ b/Core/MapperFactory.h @@ -11,31 +11,6 @@ class MapperFactory public: static const uint16_t FdsMapperID = 65535; static const uint16_t NsfMapperID = 65534; - static const uint16_t UnknownBoard = 65533; - static const uint16_t UnifTf1201 = 65532; - static const uint16_t UnifCoolboy = 65531; - static const uint16_t UnifSmb2j = 65530; - static const uint16_t UnifMalee = 65529; - static const uint16_t UnifStreetHeroes = 65528; - static const uint16_t UnifDreamTech01 = 65527; - static const uint16_t UnifEdu2000 = 65526; - static const uint16_t UnifGs2013 = 65525; - static const uint16_t UnifGs2004 = 65524; - static const uint16_t UnifNovelDiamond = 65523; - static const uint16_t UnifKof97 = 65522; - static const uint16_t UnifT262 = 65521; - static const uint16_t UnifA65AS = 65520; - static const uint16_t UnifBs5 = 65519; - static const uint16_t UnifBmc190in1 = 65518; - static const uint16_t UnifGhostbusters63in1 = 65517; - static const uint16_t UnifBmc70in1 = 65516; - static const uint16_t UnifBmc70in1B = 65515; - static const uint16_t UnifAx5705 = 65514; - static const uint16_t UnifSuper24in1Sc03 = 65513; - static const uint16_t UnifSuper40in1Ws = 65512; - static const uint16_t UnifCc21 = 65511; - static const uint16_t UnifKs7016 = 65510; - static const uint16_t UnifRt01 = 65509; static shared_ptr InitializeFromFile(string romFilename, stringstream *filestream, string ipsFilename, int32_t archiveFileIndex); }; diff --git a/Core/UnifBoards.h b/Core/UnifBoards.h new file mode 100644 index 00000000..48df0f82 --- /dev/null +++ b/Core/UnifBoards.h @@ -0,0 +1,34 @@ +#pragma once +#include "stdafx.h" + +namespace UnifBoards { + enum UnifBoards + { + UnknownBoard = 32768, + Tf1201, + Coolboy, + Smb2j, + Malee, + StreetHeroes, + DreamTech01, + Edu2000, + Gs2013, + Gs2004, + NovelDiamond, + Kof97, + T262, + A65AS, + Bs5, + Bmc190in1, + Ghostbusters63in1, + Bmc70in1, + Bmc70in1B, + Ax5705, + Super24in1Sc03, + Super40in1Ws, + Cc21, + Ks7016, + Rt01, + Hp898f, + }; +} \ No newline at end of file diff --git a/Core/UnifLoader.h b/Core/UnifLoader.h index bc1faae2..1922af92 100644 --- a/Core/UnifLoader.h +++ b/Core/UnifLoader.h @@ -2,89 +2,90 @@ #include "stdafx.h" #include "RomData.h" #include "GameDatabase.h" +#include "UnifBoards.h" #include class UnifLoader { private: std::unordered_map _boardMappings = { - { "11160", MapperFactory::UnknownBoard }, - { "12-IN-1", MapperFactory::UnknownBoard }, - { "13in1JY110", MapperFactory::UnknownBoard }, - { "190in1", MapperFactory::UnifBmc190in1 }, + { "11160", UnifBoards::UnknownBoard }, + { "12-IN-1", UnifBoards::UnknownBoard }, + { "13in1JY110", UnifBoards::UnknownBoard }, + { "190in1", UnifBoards::Bmc190in1 }, { "22211", 132 }, - { "3D-BLOCK", MapperFactory::UnknownBoard }, - { "411120-C", MapperFactory::UnknownBoard }, + { "3D-BLOCK", UnifBoards::UnknownBoard }, + { "411120-C", UnifBoards::UnknownBoard }, { "42in1ResetSwitch", 226 }, - { "43272", MapperFactory::UnknownBoard }, + { "43272", UnifBoards::UnknownBoard }, { "603-5052", 238 }, - { "64in1NoRepeat", MapperFactory::UnknownBoard }, - { "70in1", MapperFactory::UnifBmc70in1 }, - { "70in1B", MapperFactory::UnifBmc70in1B }, - { "810544-C-A1", MapperFactory::UnknownBoard }, - { "8157", MapperFactory::UnknownBoard }, + { "64in1NoRepeat", UnifBoards::UnknownBoard }, + { "70in1", UnifBoards::Bmc70in1 }, + { "70in1B", UnifBoards::Bmc70in1B }, + { "810544-C-A1", UnifBoards::UnknownBoard }, + { "8157", UnifBoards::UnknownBoard }, { "8237", 215 }, - { "8237A", MapperFactory::UnknownBoard }, - { "830118C", MapperFactory::UnknownBoard }, - { "A65AS", MapperFactory::UnifA65AS }, - { "AC08", MapperFactory::UnknownBoard }, + { "8237A", UnifBoards::UnknownBoard }, + { "830118C", UnifBoards::UnknownBoard }, + { "A65AS", UnifBoards::A65AS }, + { "AC08", UnifBoards::UnknownBoard }, { "ANROM", 7 }, - { "AX5705", MapperFactory::UnifAx5705 }, - { "BB", MapperFactory::UnknownBoard }, - { "BS-5", MapperFactory::UnifBs5 }, - { "CC-21", MapperFactory::UnifCc21 }, - { "CITYFIGHT", MapperFactory::UnknownBoard }, - { "COOLBOY", MapperFactory::UnifCoolboy }, - { "10-24-C-A1", MapperFactory::UnknownBoard }, + { "AX5705", UnifBoards::Ax5705 }, + { "BB", UnifBoards::UnknownBoard }, + { "BS-5", UnifBoards::Bs5 }, + { "CC-21", UnifBoards::Cc21 }, + { "CITYFIGHT", UnifBoards::UnknownBoard }, + { "COOLBOY", UnifBoards::Coolboy }, + { "10-24-C-A1", UnifBoards::UnknownBoard }, { "CNROM", 3 }, { "CPROM", 13 }, { "D1038", 60 }, - { "DANCE", MapperFactory::UnknownBoard }, - { "DANCE2000", MapperFactory::UnknownBoard }, - { "DREAMTECH01", MapperFactory::UnifDreamTech01 }, - { "EDU2000", MapperFactory::UnifEdu2000 }, + { "DANCE", UnifBoards::UnknownBoard }, + { "DANCE2000", UnifBoards::UnknownBoard }, + { "DREAMTECH01", UnifBoards::DreamTech01 }, + { "EDU2000", UnifBoards::Edu2000 }, { "EKROM", 5 }, { "ELROM", 5 }, { "ETROM", 5 }, { "EWROM", 5 }, - { "FK23C", MapperFactory::UnknownBoard }, - { "FK23CA", MapperFactory::UnknownBoard }, + { "FK23C", UnifBoards::UnknownBoard }, + { "FK23CA", UnifBoards::UnknownBoard }, { "FS304", 162 }, - { "G-146", MapperFactory::UnknownBoard }, + { "G-146", UnifBoards::UnknownBoard }, { "GK-192", 58 }, - { "GS-2004", MapperFactory::UnifGs2004 }, - { "GS-2013", MapperFactory::UnifGs2013 }, - { "Ghostbusters63in1", MapperFactory::UnifGhostbusters63in1 }, + { "GS-2004", UnifBoards::Gs2004 }, + { "GS-2013", UnifBoards::Gs2013 }, + { "Ghostbusters63in1", UnifBoards::Ghostbusters63in1 }, { "H2288", 123 }, - { "HKROM", MapperFactory::UnknownBoard }, - { "KOF97", MapperFactory::UnifKof97 }, - { "KONAMI-QTAI", MapperFactory::UnknownBoard }, - { "KS7010", MapperFactory::UnknownBoard }, - { "KS7012", MapperFactory::UnknownBoard }, - { "KS7013B", MapperFactory::UnknownBoard }, - { "KS7016", MapperFactory::UnifKs7016 }, - { "KS7017", MapperFactory::UnknownBoard }, - { "KS7030", MapperFactory::UnknownBoard }, - { "KS7031", MapperFactory::UnknownBoard }, + { "HKROM", UnifBoards::UnknownBoard }, + { "KOF97", UnifBoards::Kof97 }, + { "KONAMI-QTAI", UnifBoards::UnknownBoard }, + { "KS7010", UnifBoards::UnknownBoard }, + { "KS7012", UnifBoards::UnknownBoard }, + { "KS7013B", UnifBoards::UnknownBoard }, + { "KS7016", UnifBoards::Ks7016 }, + { "KS7017", UnifBoards::UnknownBoard }, + { "KS7030", UnifBoards::UnknownBoard }, + { "KS7031", UnifBoards::UnknownBoard }, { "KS7032", 142 }, - { "KS7037", MapperFactory::UnknownBoard }, - { "KS7057", MapperFactory::UnknownBoard }, - { "LE05", MapperFactory::UnknownBoard }, - { "LH10", MapperFactory::UnknownBoard }, + { "KS7037", UnifBoards::UnknownBoard }, + { "KS7057", UnifBoards::UnknownBoard }, + { "LE05", UnifBoards::UnknownBoard }, + { "LH10", UnifBoards::UnknownBoard }, { "LH32", 125 }, - { "LH53", MapperFactory::UnknownBoard }, - { "MALISB", MapperFactory::UnknownBoard }, - { "MARIO1-MALEE2", MapperFactory::UnifMalee }, + { "LH53", UnifBoards::UnknownBoard }, + { "MALISB", UnifBoards::UnknownBoard }, + { "MARIO1-MALEE2", UnifBoards::Malee }, { "MHROM", 66 }, { "N625092", 221 }, { "NROM", 0 }, { "NROM-128", 0 }, { "NROM-256", 0 }, { "NTBROM", 68 }, - { "NTD-03", MapperFactory::UnknownBoard }, - { "NovelDiamond9999999in1", MapperFactory::UnifNovelDiamond }, - { "OneBus", MapperFactory::UnknownBoard }, - { "PEC-586", MapperFactory::UnknownBoard }, + { "NTD-03", UnifBoards::UnknownBoard }, + { "NovelDiamond9999999in1", UnifBoards::NovelDiamond }, + { "OneBus", UnifBoards::UnknownBoard }, + { "PEC-586", UnifBoards::UnknownBoard }, { "RET-CUFROM", 29 }, { "RROM", 0 }, { "RROM-128", 0 }, @@ -95,7 +96,7 @@ private: { "SA-016-1M", 146 }, { "SA-72007", 145 }, { "SA-72008", 133 }, - { "SA-9602B", MapperFactory::UnknownBoard }, + { "SA-9602B", UnifBoards::UnknownBoard }, { "SA-NROM", 143 }, { "SAROM", 1 }, { "SBROM", 1 }, @@ -103,16 +104,16 @@ private: { "SCROM", 1 }, { "SEROM", 1 }, { "SGROM", 1 }, - { "SHERO", MapperFactory::UnifStreetHeroes }, + { "SHERO", UnifBoards::StreetHeroes }, { "SKROM", 1 }, { "SL12", 116 }, { "SL1632", 14 }, { "SL1ROM", 1 }, { "SLROM", 1 }, - { "SMB2J", MapperFactory::UnifSmb2j }, + { "SMB2J", UnifBoards::Smb2j }, { "SNROM", 1 }, { "SOROM", 1 }, - { "SSS-NROM-256", MapperFactory::UnknownBoard }, + { "SSS-NROM-256", UnifBoards::UnknownBoard }, { "SUNSOFT_UNROM", 93 }, { "Sachen-74LS374N", 150 }, { "Sachen-74LS374NA", 243 }, @@ -120,17 +121,17 @@ private: { "Sachen-8259B", 138 }, { "Sachen-8259C", 139 }, { "Sachen-8259D", 137 }, - { "Super24in1SC03", MapperFactory::UnifSuper24in1Sc03 }, + { "Super24in1SC03", UnifBoards::Super24in1Sc03 }, { "SuperHIK8in1", 45 }, { "Supervision16in1", 53 }, - { "T-227-1", MapperFactory::UnknownBoard }, - { "T-230", MapperFactory::UnknownBoard }, - { "T-262", MapperFactory::UnifT262 }, + { "T-227-1", UnifBoards::UnknownBoard }, + { "T-230", UnifBoards::UnknownBoard }, + { "T-262", UnifBoards::T262 }, { "TBROM", 4 }, { "TC-U01-1.5M", 147 }, { "TEK90", 90 }, { "TEROM", 4 }, - { "TF1201", MapperFactory::UnifTf1201 }, + { "TF1201", UnifBoards::Tf1201 }, { "TFROM", 4 }, { "TGROM", 4 }, { "TKROM", 4 }, @@ -141,24 +142,24 @@ private: { "TR1ROM", 4 }, { "TSROM", 4 }, { "TVROM", 4 }, - { "Transformer", MapperFactory::UnknownBoard }, + { "Transformer", UnifBoards::UnknownBoard }, { "UNROM", 2 }, { "UNROM-512-8", 30 }, { "UNROM-512-16", 30 }, { "UNROM-512-32", 30 }, { "UOROM", 2 }, - { "VRC7", MapperFactory::UnknownBoard }, - { "YOKO", MapperFactory::UnknownBoard }, - { "SB-2000", MapperFactory::UnknownBoard }, - { "158B", MapperFactory::UnknownBoard }, - { "DRAGONFIGHTER", MapperFactory::UnknownBoard }, - { "EH8813A", MapperFactory::UnknownBoard }, - { "HP898F", MapperFactory::UnknownBoard }, - { "F-15", MapperFactory::UnknownBoard }, - { "RT-01", MapperFactory::UnifRt01 }, - { "81-01-31-C", MapperFactory::UnknownBoard }, - { "8-IN-1", MapperFactory::UnknownBoard }, - { "WS", MapperFactory::UnifSuper40in1Ws } + { "VRC7", UnifBoards::UnknownBoard }, + { "YOKO", UnifBoards::UnknownBoard }, + { "SB-2000", UnifBoards::UnknownBoard }, + { "158B", UnifBoards::UnknownBoard }, + { "DRAGONFIGHTER", UnifBoards::UnknownBoard }, + { "EH8813A", UnifBoards::UnknownBoard }, + { "HP898F", UnifBoards::Hp898f }, + { "F-15", UnifBoards::UnknownBoard }, + { "RT-01", UnifBoards::Rt01 }, + { "81-01-31-C", UnifBoards::UnknownBoard }, + { "8-IN-1", UnifBoards::UnknownBoard }, + { "WS", UnifBoards::Super40in1Ws } }; vector _prgChunks[16]; @@ -297,7 +298,7 @@ private: MessageManager::Log("[UNIF] Error: Unknown board"); - return MapperFactory::UnknownBoard; + return UnifBoards::UnknownBoard; } public: @@ -353,7 +354,7 @@ public: GameDatabase::SetGameInfo(romData.Crc32, romData, !EmulationSettings::CheckFlag(EmulationFlags::DisableGameDatabase)); - if(romData.MapperID == MapperFactory::UnknownBoard) { + if(romData.MapperID == UnifBoards::UnknownBoard) { MessageManager::DisplayMessage("Error", "UnsupportedMapper", "UNIF: " + _mapperName); romData.Error = true; }