#include "stdafx.h" #include "ROMLoader.h" #include "CNROM.h" #include "MMC1.h" #include "MMC3.h" #include "NROM.h" #include "UNROM.h" class MapperFactory { public: static shared_ptr InitializeFromFile(wstring filename) { ROMLoader loader(filename); uint8_t mapperID = loader.GetMapperID(); BaseMapper* mapper = nullptr; switch(mapperID) { case 0: mapper = new NROM(); break; case 1: mapper = new MMC1(); break; case 2: mapper = new UNROM(); break; case 3: mapper = new CNROM(); break; case 4: mapper = new MMC3(); break; } if(!mapper) { throw std::exception("Unsupported mapper"); } mapper->Initialize(loader); return shared_ptr(mapper); } };