2014-07-09 19:05:07 -04:00
|
|
|
#include "stdafx.h"
|
2015-07-01 23:17:14 -04:00
|
|
|
#include "MessageManager.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "MapperFactory.h"
|
|
|
|
#include "ROMLoader.h"
|
|
|
|
#include "AXROM.h"
|
2015-12-30 16:41:47 -05:00
|
|
|
#include "Bandai74161_7432.h"
|
2015-12-31 09:51:01 -05:00
|
|
|
#include "BnRom.h"
|
2016-01-18 20:47:29 -05:00
|
|
|
#include "BF909x.h"
|
|
|
|
#include "BF9096.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "CNROM.h"
|
2015-12-28 15:16:50 -05:00
|
|
|
#include "CpRom.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "ColorDreams.h"
|
2015-12-29 22:10:30 -05:00
|
|
|
#include "GxRom.h"
|
2015-12-28 21:07:32 -05:00
|
|
|
#include "IremG101.h"
|
2016-01-19 23:45:54 -05:00
|
|
|
#include "IremLrog017.h"
|
2016-01-18 18:24:22 -05:00
|
|
|
#include "IremTamS1.h"
|
2016-01-19 23:32:02 -05:00
|
|
|
#include "JalecoJf16.h"
|
2016-01-19 23:12:47 -05:00
|
|
|
#include "JalecoJf17_19.h"
|
2015-12-30 16:41:47 -05:00
|
|
|
#include "JalecoJfxx.h"
|
2015-12-28 20:07:27 -05:00
|
|
|
#include "JalecoSs88006.h"
|
2016-01-23 11:33:11 -05:00
|
|
|
#include "Mapper57.h"
|
2016-01-19 20:48:09 -05:00
|
|
|
#include "Mapper58.h"
|
2016-01-23 11:44:40 -05:00
|
|
|
#include "Mapper61.h"
|
2016-01-23 11:57:24 -05:00
|
|
|
#include "Mapper62.h"
|
2016-01-19 22:33:29 -05:00
|
|
|
#include "Mapper107.h"
|
2016-01-23 14:38:54 -05:00
|
|
|
#include "Mapper112.h"
|
2016-01-18 22:48:09 -05:00
|
|
|
#include "Mapper200.h"
|
2016-01-20 19:08:36 -05:00
|
|
|
#include "Mapper201.h"
|
2016-01-20 19:01:10 -05:00
|
|
|
#include "Mapper202.h"
|
2016-01-20 18:42:03 -05:00
|
|
|
#include "Mapper203.h"
|
2016-01-23 14:58:19 -05:00
|
|
|
#include "Mapper225.h"
|
2016-01-18 22:26:54 -05:00
|
|
|
#include "Mapper231.h"
|
2016-01-18 21:54:04 -05:00
|
|
|
#include "Mapper240.h"
|
2016-01-18 21:46:53 -05:00
|
|
|
#include "Mapper242.h"
|
2016-01-18 22:08:00 -05:00
|
|
|
#include "Mapper246.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "MMC1.h"
|
|
|
|
#include "MMC2.h"
|
|
|
|
#include "MMC3.h"
|
2016-01-20 20:32:49 -05:00
|
|
|
#include "MMC3_12.h"
|
2016-01-20 19:44:52 -05:00
|
|
|
#include "MMC3_37.h"
|
2016-01-21 01:01:25 -05:00
|
|
|
#include "MMC3_44.h"
|
2016-01-20 21:06:56 -05:00
|
|
|
#include "MMC3_47.h"
|
2016-01-23 09:38:20 -05:00
|
|
|
#include "MMC3_49.h"
|
2016-01-23 10:33:23 -05:00
|
|
|
#include "MMC3_52.h"
|
2016-01-18 19:33:50 -05:00
|
|
|
#include "MMC3_115.h"
|
2014-08-04 15:55:20 -04:00
|
|
|
#include "MMC3_189.h"
|
2016-01-20 19:32:28 -05:00
|
|
|
#include "MMC3_205.h"
|
2016-01-19 20:16:00 -05:00
|
|
|
#include "MMC3_ChrRam.h"
|
2015-12-28 13:57:26 -05:00
|
|
|
#include "MMC4.h"
|
2015-07-29 22:10:34 -04:00
|
|
|
#include "MMC5.h"
|
2016-01-01 12:34:16 -05:00
|
|
|
#include "Namco108.h"
|
|
|
|
#include "Namco108_76.h"
|
|
|
|
#include "Namco108_88.h"
|
|
|
|
#include "Namco108_95.h"
|
|
|
|
#include "Namco108_154.h"
|
2014-07-12 22:23:08 -04:00
|
|
|
#include "Nanjing.h"
|
2015-12-31 09:51:01 -05:00
|
|
|
#include "Nina01.h"
|
2015-12-30 11:47:36 -05:00
|
|
|
#include "Nina03_06.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "NROM.h"
|
2016-01-19 16:59:01 -05:00
|
|
|
#include "NtdecTc112.h"
|
2015-12-31 10:51:00 -05:00
|
|
|
#include "Sachen_145.h"
|
|
|
|
#include "Sachen_147.h"
|
2015-12-31 11:04:26 -05:00
|
|
|
#include "Sachen_148.h"
|
|
|
|
#include "Sachen_149.h"
|
2016-01-23 12:51:10 -05:00
|
|
|
#include "Sunsoft3.h"
|
2016-01-23 13:48:48 -05:00
|
|
|
#include "Sunsoft4.h"
|
2015-12-30 20:31:54 -05:00
|
|
|
#include "Sunsoft89.h"
|
|
|
|
#include "Sunsoft93.h"
|
|
|
|
#include "Sunsoft184.h"
|
2015-12-28 23:21:10 -05:00
|
|
|
#include "TaitoTc0190.h"
|
2015-12-30 18:26:40 -05:00
|
|
|
#include "TaitoX1005.h"
|
2015-12-29 22:10:30 -05:00
|
|
|
#include "UnlPci556.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "UNROM.h"
|
2016-01-18 18:43:06 -05:00
|
|
|
#include "UnRom_94.h"
|
2016-01-18 18:03:42 -05:00
|
|
|
#include "UnRom_180.h"
|
2015-12-30 20:59:02 -05:00
|
|
|
#include "VRC1.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "VRC2_4.h"
|
2016-01-23 13:07:56 -05:00
|
|
|
#include "VRC3.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
|
2015-12-31 09:51:01 -05:00
|
|
|
BaseMapper* MapperFactory::GetMapperFromID(ROMLoader &romLoader)
|
2014-07-09 19:05:07 -04:00
|
|
|
{
|
2015-07-29 22:10:34 -04:00
|
|
|
#ifdef _DEBUG
|
2015-12-31 09:51:01 -05:00
|
|
|
MessageManager::DisplayMessage("Game Info", "Mapper: " + std::to_string(romLoader.GetMapperID()));
|
2015-07-29 22:10:34 -04:00
|
|
|
#endif
|
|
|
|
|
2015-12-31 09:51:01 -05:00
|
|
|
switch(romLoader.GetMapperID()) {
|
2014-07-09 19:05:07 -04:00
|
|
|
case 0: return new NROM();
|
|
|
|
case 1: return new MMC1();
|
|
|
|
case 2: return new UNROM();
|
2015-12-30 19:41:01 -05:00
|
|
|
case 3: return new CNROM(false);
|
2014-07-09 19:05:07 -04:00
|
|
|
case 4: return new MMC3();
|
2015-07-29 22:10:34 -04:00
|
|
|
case 5: return new MMC5();
|
2014-07-09 19:05:07 -04:00
|
|
|
case 7: return new AXROM();
|
|
|
|
case 9: return new MMC2();
|
2015-12-28 13:57:26 -05:00
|
|
|
case 10: return new MMC4();
|
2014-07-09 19:05:07 -04:00
|
|
|
case 11: return new ColorDreams();
|
2016-01-20 20:32:49 -05:00
|
|
|
case 12: return new MMC3_12();
|
2015-12-28 15:16:50 -05:00
|
|
|
case 13: return new CpRom();
|
2014-07-09 19:05:07 -04:00
|
|
|
case 16: break; //18 games
|
2015-12-28 20:07:27 -05:00
|
|
|
case 18: return new JalecoSs88006();
|
2014-07-09 19:05:07 -04:00
|
|
|
case 19: break; //16 games
|
|
|
|
case 21: return new VRC2_4(VRCVariant::VRC4a); //Conflicts: VRC4c
|
|
|
|
case 22: return new VRC2_4(VRCVariant::VRC2a);
|
|
|
|
case 23: return new VRC2_4(VRCVariant::VRC2b); //Conflicts: VRC4e
|
|
|
|
case 25: return new VRC2_4(VRCVariant::VRC4b); //Conflicts: VRC2c, VRC4d
|
|
|
|
case 27: return new VRC2_4(VRCVariant::VRC4_27); //Untested
|
2015-12-28 21:07:32 -05:00
|
|
|
case 32: return new IremG101();
|
2015-12-28 23:21:10 -05:00
|
|
|
case 33: return new TaitoTc0190();
|
2016-01-16 20:21:14 -05:00
|
|
|
case 34: return (romLoader.GetChrSize() > 0) ? (BaseMapper*)new Nina01() : (BaseMapper*)new BnRom(); //BnROM uses CHR RAM (so no CHR rom in the .NES file)
|
2016-01-20 19:44:52 -05:00
|
|
|
case 37: return new MMC3_37();
|
2015-12-29 22:10:30 -05:00
|
|
|
case 38: return new UnlPci556();
|
2016-01-21 01:01:25 -05:00
|
|
|
case 44: return new MMC3_44();
|
2016-01-20 21:06:56 -05:00
|
|
|
case 47: return new MMC3_47();
|
2016-01-23 09:38:20 -05:00
|
|
|
case 49: return new MMC3_49();
|
2016-01-23 10:33:23 -05:00
|
|
|
case 52: return new MMC3_52();
|
2016-01-23 11:33:11 -05:00
|
|
|
case 57: return new Mapper57();
|
2016-01-19 20:48:09 -05:00
|
|
|
case 58: return new Mapper58();
|
2016-01-23 11:44:40 -05:00
|
|
|
case 61: return new Mapper61();
|
2016-01-23 11:57:24 -05:00
|
|
|
case 62: return new Mapper62();
|
2015-12-29 22:10:30 -05:00
|
|
|
case 66: return new GxRom();
|
2016-01-23 12:51:10 -05:00
|
|
|
case 67: return new SunSoft3();
|
2016-01-23 13:48:48 -05:00
|
|
|
case 68: return new SunSoft4(); //incomplete support
|
2015-12-30 16:41:47 -05:00
|
|
|
case 70: return new Bandai74161_7432(false);
|
2015-07-25 17:39:19 -04:00
|
|
|
case 71: return new BF909x();
|
2016-01-19 23:12:47 -05:00
|
|
|
case 72: return new JalecoJf17_19(false);
|
2016-01-23 13:07:56 -05:00
|
|
|
case 73: return new VRC3();
|
2016-01-19 20:16:00 -05:00
|
|
|
case 74: return new MMC3_ChrRam(0x08, 0x09, 2);
|
2015-12-30 20:59:02 -05:00
|
|
|
case 75: return new VRC1();
|
2016-01-01 12:34:16 -05:00
|
|
|
case 76: return new Namco108_76();
|
2016-01-19 23:45:54 -05:00
|
|
|
case 77: return new IremLrog017();
|
2016-01-19 23:32:02 -05:00
|
|
|
case 78: return new JalecoJf16(romLoader.GetSubMapper() == 3);
|
2015-12-31 08:47:33 -05:00
|
|
|
case 79: return new Nina03_06(false);
|
2015-12-30 18:26:40 -05:00
|
|
|
case 80: return new TaitoX1005();
|
2015-12-30 16:41:47 -05:00
|
|
|
case 87: return new JalecoJfxx(false);
|
2016-01-01 12:34:16 -05:00
|
|
|
case 88: return new Namco108_88();
|
2015-12-30 20:31:54 -05:00
|
|
|
case 89: return new Sunsoft89();
|
2016-01-19 23:12:47 -05:00
|
|
|
case 92: return new JalecoJf17_19(true);
|
2015-12-30 20:31:54 -05:00
|
|
|
case 93: return new Sunsoft93();
|
2016-01-18 18:43:06 -05:00
|
|
|
case 94: return new UnRom_94();
|
2016-01-01 12:34:16 -05:00
|
|
|
case 95: return new Namco108_95();
|
2016-01-18 18:24:22 -05:00
|
|
|
case 97: return new IremTamS1();
|
2015-12-30 16:41:47 -05:00
|
|
|
case 101: return new JalecoJfxx(true);
|
2016-01-19 22:33:29 -05:00
|
|
|
case 107: return new Mapper107();
|
2016-01-23 14:38:54 -05:00
|
|
|
case 112: return new Mapper112();
|
2015-12-31 08:47:33 -05:00
|
|
|
case 113: return new Nina03_06(true);
|
2016-01-18 19:33:50 -05:00
|
|
|
case 115: return new MMC3_115();
|
2016-01-19 20:16:00 -05:00
|
|
|
case 119: return new MMC3_ChrRam(0x40, 0x7F, 8);
|
2015-12-31 10:51:00 -05:00
|
|
|
case 145: return new Sachen_145();
|
|
|
|
case 146: return new Nina03_06(false);
|
|
|
|
case 147: return new Sachen_147();
|
2015-12-31 11:04:26 -05:00
|
|
|
case 148: return new Sachen_148();
|
|
|
|
case 149: return new Sachen_149();
|
2015-12-30 16:41:47 -05:00
|
|
|
case 152: return new Bandai74161_7432(true);
|
2016-01-01 12:34:16 -05:00
|
|
|
case 154: return new Namco108_154();
|
2014-07-12 22:23:08 -04:00
|
|
|
case 163: return new Nanjing();
|
2016-01-18 18:03:42 -05:00
|
|
|
case 180: return new UnRom_180();
|
2015-12-30 20:31:54 -05:00
|
|
|
case 184: return new Sunsoft184();
|
2015-12-30 19:41:01 -05:00
|
|
|
case 185: return new CNROM(true);
|
2014-08-04 15:55:20 -04:00
|
|
|
case 189: return new MMC3_189();
|
2016-01-19 20:16:00 -05:00
|
|
|
case 191: return new MMC3_ChrRam(0x80, 0xFF, 2);
|
|
|
|
case 192: return new MMC3_ChrRam(0x08, 0x0B, 4);
|
2016-01-19 16:59:01 -05:00
|
|
|
case 193: return new NtdecTc112();
|
2016-01-19 20:16:00 -05:00
|
|
|
case 194: return new MMC3_ChrRam(0x00, 0x01, 2);
|
|
|
|
case 195: return new MMC3_ChrRam(0x00, 0x03, 4);
|
2016-01-18 22:48:09 -05:00
|
|
|
case 200: return new Mapper200();
|
2016-01-20 19:08:36 -05:00
|
|
|
case 201: return new Mapper201();
|
2016-01-20 19:01:10 -05:00
|
|
|
case 202: return new Mapper202();
|
2016-01-20 18:42:03 -05:00
|
|
|
case 203: return new Mapper203();
|
2016-01-20 19:32:28 -05:00
|
|
|
case 205: return new MMC3_205();
|
2016-01-01 12:34:16 -05:00
|
|
|
case 206: return new Namco108();
|
2016-01-23 14:58:19 -05:00
|
|
|
case 225: return new Mapper225();
|
2016-01-18 22:26:54 -05:00
|
|
|
case 231: return new Mapper231();
|
2016-01-18 20:47:29 -05:00
|
|
|
case 232: return new BF9096();
|
2016-01-18 21:54:04 -05:00
|
|
|
case 240: return new Mapper240();
|
2016-01-18 21:46:53 -05:00
|
|
|
case 242: return new Mapper242();
|
2016-01-18 22:08:00 -05:00
|
|
|
case 246: return new Mapper246();
|
2014-07-09 19:05:07 -04:00
|
|
|
}
|
|
|
|
|
2015-12-29 22:10:30 -05:00
|
|
|
MessageManager::DisplayMessage("Error", "Unsupported mapper, cannot load game.");
|
2014-07-09 19:05:07 -04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-12-27 18:41:38 -05:00
|
|
|
shared_ptr<BaseMapper> MapperFactory::InitializeFromFile(string romFilename, stringstream *filestream, string ipsFilename)
|
2014-07-09 19:05:07 -04:00
|
|
|
{
|
2014-07-10 19:25:35 -04:00
|
|
|
ROMLoader loader;
|
2014-07-09 19:05:07 -04:00
|
|
|
|
2015-12-27 18:41:38 -05:00
|
|
|
if(loader.LoadFile(romFilename, filestream, ipsFilename)) {
|
2015-12-31 09:51:01 -05:00
|
|
|
shared_ptr<BaseMapper> mapper(GetMapperFromID(loader));
|
2014-07-10 19:25:35 -04:00
|
|
|
|
|
|
|
if(mapper) {
|
|
|
|
mapper->Initialize(loader);
|
2015-07-05 19:05:33 -04:00
|
|
|
return mapper;
|
2014-07-10 19:25:35 -04:00
|
|
|
}
|
|
|
|
}
|
2015-07-05 19:05:33 -04:00
|
|
|
return nullptr;
|
2014-07-09 19:05:07 -04:00
|
|
|
}
|
2015-12-26 17:11:00 -05:00
|
|
|
|