67using std::make_unique;
71[[nodiscard]]
static RomType guessRomType(
const Rom& rom)
81 if ((
size <= 0x4000) &&
82 (data[0] ==
'A') && (data[1] ==
'B')) {
83 auto initAddr =
word(data[2] + 256 * data[3]);
84 auto textAddr =
word(data[8] + 256 * data[9]);
85 if ((textAddr & 0xC000) == 0x8000) {
86 if ((initAddr == 0) ||
87 (((initAddr & 0xC000) == 0x8000) &&
88 (data[initAddr & (
size - 1)] == 0xC9))) {
96 }
else if (
size == 0x10000 && !((data[0] ==
'A') && (data[1] ==
'B'))) {
109 std::array<unsigned, ROM_LAST> typeGuess = {};
111 if (data[i] == 0x32) {
112 auto value =
word(data[i + 1] + (data[i + 2] << 8));
146 for (
auto [i, tg] :
enumerate(typeGuess)) {
148 if (tg && (tg >= typeGuess[type])) {
149 type =
static_cast<RomType>(i);
164 std::string_view typeStr = config.
getChildData(
"mappertype",
"Mirrored");
165 if (typeStr ==
"auto") {
175 if (machineType ==
"Coleco") {
176 if (rom.
size() ==
one_of(128*1024u, 256*1024u, 512*1024u, 1024*1024u)) {
182 return guessRomType(rom);
203 auto& doc =
const_cast<DeviceConfig&
>(config).getXMLDocument();
207 std::unique_ptr<MSXRom> result;
219 result = make_unique<RomPlain>(config, std::move(rom), type);
231 result = make_unique<RomPageNN>(config, std::move(rom), type);
234 result = make_unique<RomDRAM>(config, std::move(rom));
237 result = make_unique<RomGeneric8kB>(config, std::move(rom));
240 result = make_unique<RomGeneric16kB>(config, std::move(rom));
243 result = make_unique<RomKonamiSCC>(config, std::move(rom));
246 result = make_unique<RomKonami>(config, std::move(rom));
249 result = make_unique<RomKonamiKeyboardMaster>(config, std::move(rom));
252 result = make_unique<RomAscii8kB>(config, std::move(rom));
255 result = make_unique<RomAscii16kB>(config, std::move(rom));
258 result = make_unique<RomMSXWrite>(config, std::move(rom));
261 result = make_unique<RomPadial8kB>(config, std::move(rom));
264 result = make_unique<RomPadial16kB>(config, std::move(rom));
267 result = make_unique<RomSuperLodeRunner>(config, std::move(rom));
270 result = make_unique<RomSuperSwangi>(config, std::move(rom));
273 result = make_unique<RomMitsubishiMLTS2>(config, std::move(rom));
276 result = make_unique<RomMSXDOS2>(config, std::move(rom));
279 result = make_unique<RomRType>(config, std::move(rom));
282 result = make_unique<RomCrossBlaim>(config, std::move(rom));
285 result = make_unique<RomHarryFox>(config, std::move(rom));
288 result = make_unique<RomAscii8_8>(
292 result = make_unique<RomAscii8_8>(
296 result = make_unique<RomAscii8_8>(
300 result = make_unique<RomAscii8_8>(
304 result = make_unique<RomAscii8_8>(
308 result = make_unique<RomAscii8_8>(
318 result = make_unique<RomGameMaster2>(config, std::move(rom));
321 result = make_unique<RomPanasonic>(config, std::move(rom));
324 result = make_unique<RomNational>(config, std::move(rom));
327 result = make_unique<RomMajutsushi>(config, std::move(rom));
330 result = make_unique<RomSynthesizer>(config, std::move(rom));
333 result = make_unique<RomPlayBall>(config, std::move(rom));
336 result = make_unique<RomNettouYakyuu>(config, std::move(rom));
339 result = make_unique<RomHalnote>(config, std::move(rom));
342 result = make_unique<RomZemina25in1>(config, std::move(rom));
345 result = make_unique<RomZemina80in1>(config, std::move(rom));
348 result = make_unique<RomZemina90in1>(config, std::move(rom));
351 result = make_unique<RomZemina126in1>(config, std::move(rom));
354 result = make_unique<RomHolyQuran>(config, std::move(rom));
357 result = make_unique<RomHolyQuran2>(config, std::move(rom));
360 result = make_unique<RomFSA1FM1>(config, std::move(rom));
363 result = make_unique<RomFSA1FM2>(config, std::move(rom));
370 result = make_unique<RomManbow2>(config, std::move(rom), type);
373 result = make_unique<RomMatraInk>(config, std::move(rom));
376 result = make_unique<RomMatraCompilation>(config, std::move(rom));
379 result = make_unique<RomArc>(config, std::move(rom));
382 result = make_unique<ROMHunterMk2>(config, std::move(rom));
385 result = make_unique<MegaFlashRomSCCPlus>(config, std::move(rom));
388 result = make_unique<ReproCartridgeV1>(config, std::move(rom));
391 result = make_unique<ReproCartridgeV2>(config, std::move(rom));
394 result = make_unique<KonamiUltimateCollection>(config, std::move(rom));
397 result = make_unique<RomDooly>(config, std::move(rom));
400 result = make_unique<RomMSXtra>(config, std::move(rom));
403 result = make_unique<RomMultiRom>(config, std::move(rom));
406 result = make_unique<RomRamFile>(config, std::move(rom));
409 result = make_unique<RomColecoMegaCart>(config, std::move(rom));
Reactor & getReactor() const
MSXMotherBoard & getMotherBoard() const
std::string_view getChildData(std::string_view name) const
const XMLElement * getXML() const
std::string_view getAttributeValue(std::string_view attName) const
std::string_view getMachineType() const
RomDatabase & getSoftwareDatabase()
const RomInfo * fetchRomInfo(const Sha1Sum &sha1sum) const
Lookup an entry in the database by sha1sum.
static std::string_view romTypeToName(RomType type)
RomType getRomType() const
static RomType nameToRomType(std::string_view name)
const Sha1Sum & getSHA1() const
const Sha1Sum & getOriginalSHA1() const
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
std::unique_ptr< MSXDevice > create(const DeviceConfig &config)
uint16_t word
16 bit unsigned integer
@ ROM_MEGAFLASHROMSCCPLUS
@ ROM_KONAMI_ULTIMATE_COLLECTION
@ ROM_RBSC_FLASH_KONAMI_SCC
size_t size(std::string_view utf8)
constexpr auto xrange(T e)