From 065fd8edf189e22e8a92912fd0151d8f779a5f66 Mon Sep 17 00:00:00 2001 From: Rael Gugelmin Cunha Date: Wed, 9 May 2018 22:29:46 -0300 Subject: [PATCH] Skip mame bios/devices --- es-app/src/FileData.cpp | 10 + es-app/src/FileData.h | 1 + es-app/src/Gamelist.cpp | 24 ++- es-app/src/SystemData.cpp | 9 +- es-core/src/MameNames.cpp | 75 +++++++ es-core/src/MameNames.h | 8 +- resources/mamebioses.xml | 71 +++++++ resources/mamedevices.xml | 404 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 590 insertions(+), 12 deletions(-) create mode 100644 resources/mamebioses.xml create mode 100644 resources/mamedevices.xml diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 828f43f0c..c9c5330b8 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -196,6 +196,16 @@ std::string FileData::getKey() { return getFileName(); } +const bool FileData::isArcadeAsset() +{ + const std::string stem = Utils::FileSystem::getStem(mPath); + return ( + (mSystem && (mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO))) + && + (MameNames::getInstance()->isBios(stem) || MameNames::getInstance()->isDevice(stem)) + ); +} + FileData* FileData::getSourceFileData() { return this; diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 343cb056f..63a9ce16e 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -61,6 +61,7 @@ public: virtual inline void refreshMetadata() { return; }; virtual std::string getKey(); + const bool isArcadeAsset(); inline std::string getFullPath() { return getPath(); }; inline std::string getFileName() { return Utils::FileSystem::getFileName(getPath()); }; virtual FileData* getSourceFileData(); diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index 784c28125..01259431e 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -48,7 +48,12 @@ FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType } FileData* file = new FileData(type, path, system->getSystemEnvData(), system); - treeNode->addChild(file); + + // skipping arcade assets from gamelist + if(!file->isArcadeAsset()) + { + treeNode->addChild(file); + } return file; } @@ -124,16 +129,17 @@ void parseGamelist(SystemData* system) LOG(LogError) << "Error finding/creating FileData for \"" << path << "\", skipping."; continue; } + else if(!file->isArcadeAsset()) + { + std::string defaultName = file->metadata.get("name"); + file->metadata = MetaDataList::createFromXML(GAME_METADATA, fileNode, relativeTo); - //load the metadata - std::string defaultName = file->metadata.get("name"); - file->metadata = MetaDataList::createFromXML(GAME_METADATA, fileNode, relativeTo); + //make sure name gets set if one didn't exist + if(file->metadata.get("name").empty()) + file->metadata.set("name", defaultName); - //make sure name gets set if one didn't exist - if(file->metadata.get("name").empty()) - file->metadata.set("name", defaultName); - - file->metadata.resetChangedFlag(); + file->metadata.resetChangedFlag(); + } } } } diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 30790798e..cd56b2145 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -112,8 +112,13 @@ void SystemData::populateFolder(FileData* folder) continue; FileData* newGame = new FileData(GAME, filePath, mEnvData, this); - folder->addChild(newGame); - isGame = true; + + // preventing new arcade assets to be added + if(!newGame->isArcadeAsset()) + { + folder->addChild(newGame); + isGame = true; + } } //add directories that also do not match an extension as folders diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index 78743b5dd..7821af366 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -57,6 +57,50 @@ MameNames::MameNames() NamePair namePair = { gameNode.child("mamename").text().get(), gameNode.child("realname").text().get() }; mNamePairs.push_back(namePair); } + + // Read bios + xmlpath = ResourceManager::getInstance()->getResourcePath(":/mamebioses.xml"); + + if(!Utils::FileSystem::exists(xmlpath)) + return; + + LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; + + result = doc.load_file(xmlpath.c_str()); + + if(!result) + { + LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description(); + return; + } + + for(pugi::xml_node biosNode = doc.child("bios"); biosNode; biosNode = biosNode.next_sibling("bios")) + { + std::string bios = biosNode.text().get(); + mMameBioses.push_back(bios); + } + + // Read devices + xmlpath = ResourceManager::getInstance()->getResourcePath(":/mamedevices.xml"); + + if(!Utils::FileSystem::exists(xmlpath)) + return; + + LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"..."; + + result = doc.load_file(xmlpath.c_str()); + + if(!result) + { + LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description(); + return; + } + + for(pugi::xml_node deviceNode = doc.child("device"); deviceNode; deviceNode = deviceNode.next_sibling("device")) + { + std::string device = deviceNode.text().get(); + mMameDevices.push_back(device); + } } // MameNames @@ -83,3 +127,34 @@ std::string MameNames::getRealName(const std::string& _mameName) return _mameName; } // getRealName + +const bool MameNames::isBios(const std::string& _biosName) +{ + return MameNames::find(mMameBioses, _biosName); + +} // isBios + +const bool MameNames::isDevice(const std::string& _deviceName) +{ + return MameNames::find(mMameDevices, _deviceName); + +} // isDevice + +const bool MameNames::find(std::vector devices, const std::string& name) +{ + size_t start = 0; + size_t end = devices.size(); + + while(start < end) + { + const size_t index = (start + end) / 2; + const int compare = strcmp(devices[index].c_str(), name.c_str()); + + if(compare < 0) start = index + 1; + else if( compare > 0) end = index; + else return true; + } + + return false; + +} diff --git a/es-core/src/MameNames.h b/es-core/src/MameNames.h index 52fd71455..6f0ae2181 100644 --- a/es-core/src/MameNames.h +++ b/es-core/src/MameNames.h @@ -13,6 +13,8 @@ public: static void deinit (); static MameNames* getInstance(); std::string getRealName(const std::string& _mameName); + const bool isBios(const std::string& _biosName); + const bool isDevice(const std::string& _deviceName); private: @@ -29,7 +31,11 @@ private: static MameNames* sInstance; - namePairVector mNamePairs; + namePairVector mNamePairs; + std::vector mMameBioses; + std::vector mMameDevices; + + const bool find(const std::vector devices, const std::string& name); }; // MameNames diff --git a/resources/mamebioses.xml b/resources/mamebioses.xml new file mode 100644 index 000000000..0e1f6c638 --- /dev/null +++ b/resources/mamebioses.xml @@ -0,0 +1,71 @@ +3dobios +airlbios +aleck64 +alg_bios +allied +ar_bios +aristmk5 +aristmk6 +atarisy1 +awbios +bubsys +cdibios +cedmag +chihiro +coh1000a +coh1000c +coh1000t +coh1000w +coh1001l +coh1002e +coh1002m +coh1002v +coh3002c +coh3002t +crysbios +cubo +decocass +f355bios +f355dlx +galgbios +gp_110 +gq863 +gts1 +gts1s +hikaru +hng64 +hod2bios +isgsm +iteagle +konamigv +konamigx +kviper +lindbios +list.txt +macsbios +maxaflex +megaplay +megatech +naomi2 +naomi +naomigd +neogeo +nss +pgm +playch10 +pyson +sammymdl +segasp +sfcbox +shtzone +skns +stvbios +su2000 +sys246 +sys256 +sys573 +taitotz +tourvis +triforce +v4bios + diff --git a/resources/mamedevices.xml b/resources/mamedevices.xml new file mode 100644 index 000000000..c959462cc --- /dev/null +++ b/resources/mamedevices.xml @@ -0,0 +1,404 @@ +22vp931 +3c505 +a1cass +a2091 +a2ap16 +a2ap16a +a2aplcrd +a2cffa02 +a2cffa2 +a2corvus +a2diskii +a2diskiing +a2hsscsi +a2iwm_flop +a2memexp +a2mouse +a2pic +a2ramfac +a2scsi +a2ssc +a2swyft +a2thunpl +a2tmstho +a2ultrme +a2ulttrm +a2vidtrm +a2vtc1 +a2vtc2 +a2vulcan +a2vulgld +a2zipdrv +a3fdc +a590 +abc1600mac +abc1600mover +abc55 +abc77 +abc800kb +abc830 +abc832 +abc834 +abc838 +abc99 +abc_fd2 +abc_hdc +abc_mem +abcsio +adam_ddp +adam_fdc +adam_kb +adam_prn +adam_spi +aga +aga_pc200 +aha1542 +alto2_cpu +amiga_ar1 +amiga_ar2 +amiga_ar3 +amigakbd +ap2000 +at_keybc +bbc_acorn1770 +bbc_acorn8271 +bbc_cumana1 +bbc_cumana2 +bbc_opus1770 +bbc_opus2791 +bbc_opus2793 +bbc_opus3 +bbc_weddb2 +bbc_weddb3 +betadisk +bml3kanji +bml3mp1802 +bml3mp1805 +bsmt2000 +buddha +bw2_ramcard +c1526 +c1540 +c1541 +c1541c +c1541dd +c1541ii +c1541pd +c1541pdc +c1551 +c1563 +c1570 +c1571 +c1581 +c2031 +c2040 +c2040fdc +c3040 +c4023 +c4040 +c64_cs +c64_fcc +c64_mscr +c64_nl10 +c64_supercpu +c64_xl80 +c8050 +c8050fdc +c8250 +c8250lp +c8280 +cbm2_hrga +cbm2_hrgb +cbm8000_hsg_a +cbm8000_hsg_b +cffa1 +cga +cga_iskr1030m +cga_iskr1031 +cga_m24 +cga_mc1502 +cga_poisk2 +cgenie_fdc +clgd542x +cmdhd +coco3_hdb1 +coco_fdc +coco_fdc_v11 +compiskb +comx_clm +comx_eb +comx_epr +comx_fd +comx_pl80 +comx_prn +comx_thm +cp400_fdc +cpc_brunword4 +cpc_ddi1 +cpc_dkspeech +cpc_hd20 +cpc_mf2 +cpc_ser +cpc_serams +cpc_smartwatch +cpc_ssa1 +cpc_transtape +crvfdc01 +crvfdc02 +csd1 +cuda +d2fdc +d9060 +d9090 +dectalk_isa +dj2db +djdma +dm_clgd5430 +dms3d2kp +dmv_k220 +dmv_k230 +dmv_k231 +dmv_k235 +dmv_k806 +dmv_keyb +dragon_fdc +dsp1bleg +dsp1leg +dsp1leg_hi +dsp2leg +dsp3leg +dsp4leg +e01 +e01s +ec1840_0002 +ec1841_0002 +ef9365 +ega +egret +electron_m2105 +electron_plus3 +ep64_exdos +epson_pf10 +epson_tf20 +et4000 +ex800 +fc_disksys +fd2000 +fd4000 +fdc344 +fdcmag +filetto_cga +finalchs +fsd1 +fsd2 +gfxultra +gfxultrp +gic +grip +hardbox +hd44780_a00 +hd61830 +hdc +hdc_ec1841 +hp98034 +hp98035 +ibm_mfc +ibm_vga +ie15_keyboard +imi5000h +indusgt +interpod +intv_ecs +intv_voice +iq151_disc2 +iq151_minigraf +iq151_ms151a +iq151_video32 +iq151_video64 +isa_hercules +isa_ibm_mda +isa_ibm_pgc +isbc_215g +jasmin +jvs13551 +k573dio +k573mcr +k573msu +k573npu +k7659kb +kb_3270pc +kb_ec1841 +kb_iskr1030 +kb_pcat84 +kb_pcxt83 +kc_d004 +kc_d004gide +keytronic_pc3270 +km035 +ks0066_f05 +laserfdc +ldv1000 +list.txt +lk201 +lux10828 +lux21046 +lux21056 +lx800 +lx810l +m1comm +m20_8086 +m24_kbd +m24_z8000 +m50458 +mach64 +mackbd +mc1502_rom +microdisc +midssio +mie +minichif +mm1kb +mpu401 +ms7004 +ms_natural +mshark +msm6222b +msx_cart_bm_012 +msx_cart_sfg01 +msx_cart_sfg05 +msx_moonsound +namco50 +namco51 +namco52 +namco53 +namco54 +namco62 +namcoc69 +namcoc70 +namcoc74 +namcoc75 +namcoc76 +nb_48gc +nb_824gc +nb_aenet +nb_amc3b +nb_cb264 +nb_image +nb_m2hr +nb_m2vc +nb_rtpd +nb_sp8s3 +nb_spdq +nb_vikbw +nb_wspt +newbrain_eim +newbrain_fdc +nmk004 +nsmdsa +nsmdsad +o2_voice +p1_fdc +p1_hdc +p1_rom +p72 +pc1512kb +pc1640_iga +pcd_kbd +pcd_video +pcx_video +pd3_30hr +pd3_c264 +pd3_lviw +pd3_mclr +pd3_pc16 +pdc +pds_sefp +pet_softbox +pet_superpet +pr8210 +psx_cd +ql_cumanafdi +ql_gold +ql_kdi +ql_mhd +ql_mpfdi +ql_opdbm +ql_pcmlqdi +ql_qdisc +ql_qplus4 +ql_qubide +ql_sdisk +ql_sqboard256 +ql_sqboard512 +ql_sqmouse512 +ql_sqmouse +ql_trump256 +ql_trump512 +ql_trump768 +ql_trump +qsound +s1410 +s3_764 +s3virge +s3virgedx +saa5050 +saa5052 +sb16 +sdtandy_fdc +sed1200 +segadimm +serbox +seta10leg +seta11leg +sfd1001 +side116 +simutrek +slutprov +sns_rom_sgb2 +sns_rom_sgb +spc1000_fdd_exp +stereo_fx +stic +sv603 +sx1541 +t5182 +tetriskr_cga +tgui9680 +ti99_bwg +ti99_evpc +ti99_fdc +ti99_gkracker +ti99_hfdc +ti99_myarcmem +ti99_pcode +ti99_rs232 +ti99_speech +tiki100_8088 +tms32031 +tms32032 +tvc_hbf +uni800 +unidisk +upd7220 +vic1515 +vic1520 +vic20_fe3 +victor9k_fdc +victor9kb +votrax +vp700 +vz_rs232 +vz_rtty +wangpc_lic +wangpc_rtc +wangpc_wdc +wangpckb +wd1002a_wx1 +wdxt_gen +wordpro +wyse700 +x68k_cz6bs1 +x820kb +xtide +ym2608 +