2014-06-24 02:47:32 -04:00
|
|
|
#include "stdafx.h"
|
2014-06-24 21:59:58 -04:00
|
|
|
#include "ROMLoader.h"
|
|
|
|
#include "CNROM.h"
|
2014-06-24 02:47:32 -04:00
|
|
|
#include "MMC1.h"
|
2014-06-24 21:59:58 -04:00
|
|
|
#include "MMC3.h"
|
|
|
|
#include "NROM.h"
|
2014-06-24 14:28:19 -04:00
|
|
|
#include "UNROM.h"
|
2014-06-24 02:47:32 -04:00
|
|
|
|
|
|
|
class MapperFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static shared_ptr<BaseMapper> InitializeFromFile(wstring filename)
|
|
|
|
{
|
|
|
|
ROMLoader loader(filename);
|
|
|
|
|
2014-06-24 10:19:24 -04:00
|
|
|
uint8_t mapperID = loader.GetMapperID();
|
2014-06-24 02:47:32 -04:00
|
|
|
|
|
|
|
BaseMapper* mapper = nullptr;
|
|
|
|
switch(mapperID) {
|
2014-06-24 14:28:19 -04:00
|
|
|
case 0: mapper = new NROM(); break;
|
2014-06-24 02:47:32 -04:00
|
|
|
case 1: mapper = new MMC1(); break;
|
2014-06-24 14:28:19 -04:00
|
|
|
case 2: mapper = new UNROM(); break;
|
|
|
|
case 3: mapper = new CNROM(); break;
|
2014-06-24 21:59:58 -04:00
|
|
|
case 4: mapper = new MMC3(); break;
|
2014-06-24 02:47:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!mapper) {
|
|
|
|
throw std::exception("Unsupported mapper");
|
|
|
|
}
|
|
|
|
|
2014-06-24 10:19:24 -04:00
|
|
|
mapper->Initialize(loader);
|
2014-06-24 02:47:32 -04:00
|
|
|
return shared_ptr<BaseMapper>(mapper);
|
|
|
|
}
|
|
|
|
};
|