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"
|
|
|
|
#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"
|
2015-12-28 20:07:27 -05:00
|
|
|
#include "JalecoSs88006.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "MMC1.h"
|
|
|
|
#include "MMC2.h"
|
|
|
|
#include "MMC3.h"
|
2014-08-04 15:55:20 -04:00
|
|
|
#include "MMC3_189.h"
|
2015-12-28 13:57:26 -05:00
|
|
|
#include "MMC4.h"
|
2015-07-29 22:10:34 -04:00
|
|
|
#include "MMC5.h"
|
2014-07-12 22:23:08 -04:00
|
|
|
#include "Nanjing.h"
|
2015-12-30 11:47:36 -05:00
|
|
|
#include "Nina03_06.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "NROM.h"
|
2015-12-28 23:21:10 -05:00
|
|
|
#include "TaitoTc0190.h"
|
2015-12-29 22:10:30 -05:00
|
|
|
#include "UnlPci556.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "UNROM.h"
|
|
|
|
#include "VRC2_4.h"
|
2015-07-25 17:39:19 -04:00
|
|
|
#include "BF909x.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
|
|
|
|
BaseMapper* MapperFactory::GetMapperFromID(uint8_t mapperID)
|
|
|
|
{
|
2015-07-29 22:10:34 -04:00
|
|
|
#ifdef _DEBUG
|
|
|
|
MessageManager::DisplayMessage("Game Info", "Mapper: " + std::to_string(mapperID));
|
|
|
|
#endif
|
|
|
|
|
2014-07-09 19:05:07 -04:00
|
|
|
switch(mapperID) {
|
|
|
|
case 0: return new NROM();
|
|
|
|
case 1: return new MMC1();
|
|
|
|
case 2: return new UNROM();
|
|
|
|
case 3: return new CNROM();
|
|
|
|
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();
|
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();
|
2015-12-29 22:10:30 -05:00
|
|
|
case 34: break;
|
|
|
|
case 37: break;
|
|
|
|
case 38: return new UnlPci556();
|
|
|
|
case 66: return new GxRom();
|
2015-07-25 17:39:19 -04:00
|
|
|
case 71: return new BF909x();
|
2015-12-30 11:47:36 -05:00
|
|
|
case 79: return new Nina03_06();
|
|
|
|
//case 87: return new JalecoJf05();
|
2014-07-12 22:23:08 -04:00
|
|
|
case 163: return new Nanjing();
|
2014-08-04 15:55:20 -04:00
|
|
|
case 189: return new MMC3_189();
|
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)) {
|
2014-07-10 19:25:35 -04:00
|
|
|
uint8_t mapperID = loader.GetMapperID();
|
|
|
|
|
2015-07-05 19:05:33 -04:00
|
|
|
shared_ptr<BaseMapper> mapper(GetMapperFromID(mapperID));
|
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
|
|
|
|