mirror of
https://github.com/libretro/Mesen.git
synced 2025-02-13 04:50:26 +00:00
6437be44f5
Zelda 1, MegaMan 2, Final Fantasy2 working correctly
31 lines
686 B
C++
31 lines
686 B
C++
#include "stdafx.h"
|
|
#include "BaseMapper.h"
|
|
#include "MMC1.h"
|
|
#include "ROMLoader.h"
|
|
|
|
class MapperFactory
|
|
{
|
|
public:
|
|
static shared_ptr<BaseMapper> InitializeFromFile(wstring filename)
|
|
{
|
|
ROMLoader loader(filename);
|
|
|
|
NESHeader header = loader.GetHeader();
|
|
|
|
uint8_t mapperID = header.GetMapperID();
|
|
BaseMapper* mapper = nullptr;
|
|
switch(mapperID) {
|
|
case 0: mapper = new DefaultMapper(); break;
|
|
case 1: mapper = new MMC1(); break;
|
|
case 2: mapper = new Mapper2(); break;
|
|
}
|
|
|
|
if(!mapper) {
|
|
throw std::exception("Unsupported mapper");
|
|
}
|
|
|
|
mapper->Initialize(header.GetMirroringType(), loader);
|
|
return shared_ptr<BaseMapper>(mapper);
|
|
}
|
|
};
|