69using std::make_unique;
73[[nodiscard]]
static RomType guessRomType(
const Rom& rom)
83 if ((
size <= 0x4000) &&
84 (data[0] ==
'A') && (data[1] ==
'B')) {
85 auto initAddr =
word(data[2] + 256 * data[3]);
86 auto textAddr =
word(data[8] + 256 * data[9]);
87 if ((textAddr & 0xC000) == 0x8000) {
88 if ((initAddr == 0) ||
89 (((initAddr & 0xC000) == 0x8000) &&
90 (data[initAddr & (
size - 1)] == 0xC9))) {
98 }
else if (
size == 0x10000 && !((data[0] ==
'A') && (data[1] ==
'B'))) {
111 std::array<unsigned, ROM_LAST> typeGuess = {};
113 if (data[i] == 0x32) {
114 auto value =
word(data[i + 1] + (data[i + 2] << 8));
148 for (
auto [i, tg] :
enumerate(typeGuess)) {
150 if (tg && (tg >= typeGuess[type])) {
151 type =
static_cast<RomType>(i);
166 std::string_view typeStr = config.
getChildData(
"mappertype",
"Mirrored");
167 if (typeStr ==
"auto") {
177 if (machineType ==
"Coleco") {
178 if (rom.
size() ==
one_of(128*1024u, 256*1024u, 512*1024u, 1024*1024u)) {
184 return guessRomType(rom);
205 auto& doc =
const_cast<DeviceConfig&
>(config).getXMLDocument();
209 std::unique_ptr<MSXRom> result;
221 result = make_unique<RomPlain>(config, std::move(rom), type);
233 result = make_unique<RomPageNN>(config, std::move(rom), type);
236 result = make_unique<RomDRAM>(config, std::move(rom));
239 result = make_unique<RomGeneric8kB>(config, std::move(rom));
242 result = make_unique<RomGeneric16kB>(config, std::move(rom));
245 result = make_unique<RomKonamiSCC>(config, std::move(rom));
248 result = make_unique<RomKonami>(config, std::move(rom));
251 result = make_unique<RomKonamiKeyboardMaster>(config, std::move(rom));
254 result = make_unique<RomAscii8kB>(config, std::move(rom));
257 result = make_unique<RomAscii16kB>(config, std::move(rom));
260 result = make_unique<RomMSXWrite>(config, std::move(rom));
263 result = make_unique<RomPadial8kB>(config, std::move(rom));
266 result = make_unique<RomPadial16kB>(config, std::move(rom));
269 result = make_unique<RomSuperLodeRunner>(config, std::move(rom));
272 result = make_unique<RomSuperSwangi>(config, std::move(rom));
275 result = make_unique<RomMitsubishiMLTS2>(config, std::move(rom));
278 result = make_unique<RomMSXDOS2>(config, std::move(rom));
281 result = make_unique<RomRType>(config, std::move(rom));
284 result = make_unique<RomCrossBlaim>(config, std::move(rom));
287 result = make_unique<RomHarryFox>(config, std::move(rom));
290 result = make_unique<RomAscii8_8>(
294 result = make_unique<RomAscii8_8>(
298 result = make_unique<RomAscii8_8>(
302 result = make_unique<RomAscii8_8>(
306 result = make_unique<RomAscii8_8>(
310 result = make_unique<RomAscii8_8>(
320 result = make_unique<RomGameMaster2>(config, std::move(rom));
323 result = make_unique<RomPanasonic>(config, std::move(rom));
326 result = make_unique<RomNational>(config, std::move(rom));
329 result = make_unique<RomMajutsushi>(config, std::move(rom));
332 result = make_unique<RomSynthesizer>(config, std::move(rom));
335 result = make_unique<RomPlayBall>(config, std::move(rom));
338 result = make_unique<RomNettouYakyuu>(config, std::move(rom));
341 result = make_unique<RomHalnote>(config, std::move(rom));
344 result = make_unique<RomZemina25in1>(config, std::move(rom));
347 result = make_unique<RomZemina80in1>(config, std::move(rom));
350 result = make_unique<RomZemina90in1>(config, std::move(rom));
353 result = make_unique<RomZemina126in1>(config, std::move(rom));
356 result = make_unique<RomHolyQuran>(config, std::move(rom));
359 result = make_unique<RomHolyQuran2>(config, std::move(rom));
362 result = make_unique<RomFSA1FM1>(config, std::move(rom));
365 result = make_unique<RomFSA1FM2>(config, std::move(rom));
372 result = make_unique<RomManbow2>(config, std::move(rom), type);
375 result = make_unique<RomMatraInk>(config, std::move(rom));
378 result = make_unique<RomMatraCompilation>(config, std::move(rom));
381 result = make_unique<RomArc>(config, std::move(rom));
384 result = make_unique<RomAlAlamiah30in1>(config, std::move(rom));
387 result = make_unique<RomRetroHard31in1>(config, std::move(rom));
390 result = make_unique<ROMHunterMk2>(config, std::move(rom));
393 result = make_unique<MegaFlashRomSCCPlus>(config, std::move(rom));
396 result = make_unique<ReproCartridgeV1>(config, std::move(rom));
399 result = make_unique<ReproCartridgeV2>(config, std::move(rom));
402 result = make_unique<KonamiUltimateCollection>(config, std::move(rom));
405 result = make_unique<RomDooly>(config, std::move(rom));
408 result = make_unique<RomMSXtra>(config, std::move(rom));
411 result = make_unique<RomMultiRom>(config, std::move(rom));
414 result = make_unique<RomRamFile>(config, std::move(rom));
417 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)