-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate-systems-lr-mess_mame-1v8-alpha.sh
601 lines (513 loc) · 31.1 KB
/
generate-systems-lr-mess_mame-1v8-alpha.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
#!/bin/bash
#
# Author : @folly
# Date : 16/03/2021
#
# Copyright 2021 @folly
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#--------------------------------------
#about this project :
#i have created this project while i was busy with the RetroPie-setup fork from @valerino
#@valerino made modulescripts for systems running with lr-mess
#some systems were not created by @valerino so i created 2 myself
#while doing that, creating such a script was basically the same everytime
#that is why i made this script to automate this process
#
#it basically creates a virtual excel sheet in arrays from the mame command output, and injects this information in the scripts that are being generated
#
#i started this script for "lr-mess" but it's now also possible to do somewhat the same with "mame"
#because "mame" and "lr-mess" can be compile from the same mamedev source i use now the universal name "mamedev" in this script
#
#because mame is also added as emulator and because mame is using a different BIOS dir : $HOME/RetroPie/BIOS/mame
#the lr-mess command is changed to use the same BIOS dir, so they can use the same bios files
#part 1 : help
# show the the help options when running with "-h"
while getopts ":h" option; do
case $option in
h) # display Help
echo "options :"
echo "-h this help "
echo "<system> choosen system to generate "
echo
echo "Version --> $0 (testing, WIP)"
echo "!!! THIS VERSION GENERATES @VALERINO ALIKE SCRIPTS AND ORIGINAL LR-MESS COMMAND SCRIPTS !!!"
echo "!!! WHILE DOING THIS, IT TRIES TO USE RETROPIE NAMES IF A MATCH IS FOUND !!!"
echo "!!! IT ALSO USES THE NEW RETROPIE PLATFORM NAMES, USED BY THE @DTEAM HANDHELD TUTORIAL !!!"
echo "Creator --> @folly"
echo "Dependancies"
echo "--> MAME and lr-mess (install in RetroPie-Setup)"
echo " use --> generated scripts tested on version 4.7.8 / should work on :"
echo " > original RetroPie-setup and the run_mess.sh script of @valerino's fork"
echo " manually install run_mess.sh :"
echo " wget -nv -O /home/pi/RetroPie-Setup/scriptmodules/run_mess.sh https://raw.githubusercontent.com/valerino/RetroPie-Setup/master/scriptmodules/run_mess.sh"
echo " or -->generated scripts not tested / probably will work on :"
echo " > @valerino's fork of RetroPie-Setup (https://github.com/valerino/RetroPie-Setup)"
echo "======= extra information ======="
echo "Run"
echo "- generate for all systems: bash $0 "
echo "- generate only one system: bash $0 <system> "
echo "- batch generate only desired systems: bash generate-desired-systems.sh "
echo "Example"
echo "- generating only one system: bash $0 fm77av "
echo "- generating konamih cmd script: bash $0 kgradius "
echo "(creating this can be done with one game)(a cmd script can be used for more konamih games !)"
echo "Advise : create files not directly in the RetroPie-Setup use copy and paste"
echo "If you want to create the scripts directly in RetroPie-Setup,"
echo "place and run the script from this directory"
echo "$HOME/RetroPie-Setup"
echo "MAME commands"
echo "- help"
echo "/opt/retropie/emulators/mame/mame -h "
echo "- get system names in a textfile"
echo "/opt/retropie/emulators/mame/mame -listdevices | grep Driver > possiblesystems.txt "
echo "- check for compatible media"
echo "/opt/retropie/emulators/mame/mame -listmedia | grep <system> "
exit;;
esac
done
echo start
date
#part 2 : define strings, arrays and @DTEAM handheld platform information
#mamedev arrays
systems=(); uniquesystems=(); mediadescriptions=(); media=(); extensions=(); allextensions=(); descriptions=()
#retropie arrays
systemsrp=(); descriptionsrp=()
#create new array while matching
newsystems=()
#filter out column names and <none> media
namesfilter="\(brief|------"
#filter on usefull media, otherwise we also get many unusefull scripts
mediafilter="none\)|prin\)|quik\)|\(memc|\(rom1|\(cart|\(flop|\(cass|dump\)|cdrm\)"
#string for adding extra extensions in all generated scripts
addextensions=".zip .7z"
#string for adding extra extensions in all generated command scripts
addextensionscmd=".cmd"
#string for adding mamedev config options, this doesn't seem to work in the generated command scripts with lr-mess
mamedevcfgoptions="-autoframeskip"
#array data for "game system names" of "handhelds" that cannot be detected or matched with the mamedev database
#systems that cannot be detected (all_in1, classich, konamih, tigerh) (*h is for handheld)
#systems that can be detected (jakks, tigerrz), these added later in the script for normal matching
#a system that can be detected (gameandwatch), already in RetroPie naming for normal matching
#using @DTEAM naming for compatibitity with possible existing es-themes
#hoping this will be the future RetroPie naming for these handhelds
all_in1=( "ablmini" "ablpinb" "bittboy" "cybar120" "dgun2573" "dnv200fs" "fapocket" "fcpocket" "fordrace" "gprnrs1" "gprnrs16" "ii32in1" "ii8in1" "intact89" "intg5410" "itvg49" "lexiseal" "lexizeus" "lx_jg7415" "m505neo" "m521neo" "majkon" "mc_105te" "mc_110cb" "mc_138cb" "mc_7x6ss" "mc_89in1" "mc_8x6cb" "mc_8x6ss" "mc_9x6ss" "mc_aa2" "mc_cb280" "mc_dcat8" "mc_dg101" "mc_dgear" "mc_hh210" "mc_sam60" "mc_sp69" "mc_tv200" "megapad" "mgt20in1" "miwi2_7" "mysprtch" "mysprtcp" "mysptqvc" "njp60in1" "oplayer" "pdc100" "pdc150t" "pdc200" "pdc40t" "pdc50" "pjoyn50" "pjoys30" "pjoys60" "ppgc200g" "react" "reactmd" "rminitv" "sarc110" "sudopptv" "sy888b" "sy889" "techni4" "timetp36" "tmntpdc" "unk1682" "vgcaplet" "vgpmini" "vgpocket" "vjpp2" "vsplus" "zdog" "zone7in1" "zudugo" "namcons1" "namcons2" "taitons1" "taitons2" "tak_geig" "namcons1" "namcons2" "taitons1" "taitons2" "tak_geig" "tomcpin" )
classich=( "alnattck" "alnchase" "astrocmd" "bambball" "bankshot" "bbtime" "bcclimbr" "bdoramon" "bfriskyt" "bmboxing" "bmsafari" "bmsoccer" "bpengo" "bultrman" "bzaxxon" "cdkong" "cfrogger" "cgalaxn" "cmspacmn" "cmsport" "cnbaskb" "cnfball" "cnfball2" "cpacman" "cqback" "ebaskb2" "ebball" "ebball2" "ebball3" "edracula" "efball" "egalaxn2" "einvader" "einvader2" "epacman2" "esoccer" "estargte" "eturtles" "flash" "funjacks" "galaxy2" "gckong" "gdigdug" "ghalien" "ginv" "ginv1000" "ginv2000" "gjungler" "h2hbaseb" "h2hbaskb" "h2hfootb" "h2hhockey" "h2hsoccerc" "hccbaskb" "invspace" "kingman" "machiman" "mcompgin" "msthawk" "mwcbaseb" "packmon" "pairmtch" "pbqbert" "phpball" "raisedvl" "rockpin" "splasfgt" "splitsec" "ssfball" "tbaskb" "tbreakup" "tcaveman" "tccombat" "tmpacman" "tmscramb" "tmtennis" "tmtron" "trshutvoy" "trsrescue" "ufombs" "us2pfball" "vinvader" "zackman" )
konamih=( "kbilly" "kblades" "kbucky" "kcontra" "kdribble" "kgarfld" "kgradius" "kloneran" "knfl" "ktmnt" "ktopgun" )
tigerh=( "taddams" "taltbeast" "tapollo13" "tbatfor" "tbatman" "tbatmana" "tbtoads" "tbttf" "tddragon" "tddragon3" "tdennis" "tdummies" "tflash" "tgaiden" "tgaunt" "tgoldeye" "tgoldnaxe" "thalone" "thalone2" "thook" "tinday" "tjdredd" "tjpark" "tkarnov" "tkazaam" "tmchammer" "tmkombat" "tnmarebc" "topaliens" "trobhood" "trobocop2" "trobocop3" "trockteer" "tsddragon" "tsf2010" "tsfight2" "tshadow" "tsharr2" "tsjam" "tskelwarr" "tsonic" "tsonic2" "tspidman" "tstrider" "tswampt" "ttransf2" "tvindictr" "twworld" "txmen" "txmenpx" )
#platform config lines systems that are not in the platform.cfg (no strings, read the same way as info from platform.cfg)
#tigerh_exts=".7z .cue .fba .iso .zip .cdi .chd .gdi .sh"
#tigerh_fullname="Tiger Handheld Electronics"
#
#tigerrz_exts=".7z .cue .fba .iso .zip .cdi .chd .gdi .sh"
#tigerrz_fullname="Tiger R-Zone"
#
#jakks_exts=".7z .cue .fba .iso .zip .cdi .chd .gdi .sh"
#jakks_fullname="JAKKS Pacific TV Games"
#
#konamih_exts=".7z .cue .fba .iso .zip .cdi .chd .gdi .sh"
#konamih_fullname="Konami Handheld"
#
#all_in1_exts=".7z .cue .fba .iso .zip .cdi .chd .gdi .sh"
#all_in1_fullname="All in One Handheld and Plug and Play"
#
#classich_exts=".mgw .7z"
#classich_fullname="Classic Handheld Systems"
#
#bbcmicro_exts=".ssd"
#bbcmicro_fullname="BBC Micro"
#
#bbcmicro_exts=".ssd"
#bbcmicro_fullname="BBC Master"
#part 3 : turning off creating all scripts
#if this part is commented and no option is added while running this scripts, it is possible to generate all possible scripts
#because of the time it will consume, it is turned off in this part !
if [[ -z "$1" ]]; then
echo -ne "\ngenerating all possible files is turned off, \nbecause it will probably take more than 5 hours to do so !\n\nyou can comment part 3, in the script, to turn it on again !\n"
exit
fi
#part 4 : extract system data to array
# read system(s) using "mame" to extract the data and add them in the systems array
# some things are filtered with grep
while read LINE; do
# check for "system" in line
# an example output for the msx system hbf700p is :
#hbf700p printout (prin) .prn
# cassette (cass) .wav .tap .cas
# cartridge1 (cart1) .mx1 .bin .rom
# cartridge2 (cart2) .mx1 .bin .rom
# floppydisk (flop) .dsk .dmk .d77 .d88 .1dd .dfi .hfe .imd .ipf .mfi .mfm .td0 .cqm .cqi
# if no "sytem" in line place add the last value again, in the system array so it can be properly used in our script, we get this data structure :
#(systems)
# hbf700p printout (prin) .prn
# hbf700p cassette (cass) .wav .tap .cas
# hbf700p cartridge1 (cart1) .mx1 .bin .rom
# hbf700p cartridge2 (cart2) .mx1 .bin .rom
# hbf700p floppydisk (flop) .dsk .dmk .d77 .d88 .1dd .dfi .hfe .imd .ipf .mfi .mfm .td0 .cqm .cqi
if [[ -z $LINE ]]; then
systems+=( "${systems[-1]}" )
##echo ${systems[-1]} $LINE
else
# use the first column if seperated by a space
systems+=( "$(echo $LINE)" )
fi
done < <(/opt/retropie/emulators/mame/mame -listmedia $1 | grep -v -E "$namesfilter" | grep -E "$mediafilter" | cut -d " " -f 1)
#part 5 : indication on how many scripts can be generated
echo "read system(s)"
unique=$(echo ${systems[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ')
IFS=$' ' GLOBIGNORE='*' command eval 'uniquesystems=($(echo $unique))'
echo "- detected ${#uniquesystems[@]} unique mamedev system type(s)"
echo "- cannot calculate the amound of generating possible scripts now"
#part 6 : extract all extension data per system to array
# an example output for the msx system hbf700p is :
#hbf700p printout (prin) .prn
# cassette (cass) .wav .tap .cas
# cartridge1 (cart1) .mx1 .bin .rom
# cartridge2 (cart2) .mx1 .bin .rom
# floppydisk (flop) .dsk .dmk .d77 .d88 .1dd .dfi .hfe .imd .ipf .mfi .mfm .td0 .cqm .cqi
# from this example all extensions are added and this information is stored like this in (allextensions) :
#.prn .wav .tap .cas .mx1 .bin .rom .mx1 .bin .rom .dsk .dmk .d77 .d88 .1dd .dfi .hfe .imd .ipf .mfi .mfm .td0 .cqm .cqi
echo "read all available extensions per system"
for index in "${!systems[@]}"; do
# export all supported media per system on unique base
allextensions+=( "$(/opt/retropie/emulators/mame/mame -listmedia ${systems[$index]} | grep -o "\...." | tr ' ' '\n' | sort -u | tr '\n' ' ')" )
#testline
#echo ${systems[$index]} ${allextensions[$index]}
done
#testline
#echo ${allextensions[@]} ${#allextensions[@]}
#part 7 : extract only extension data per media per system to array
#the collected data stored in the specific arrays using this example structure for the msx system hbf700p, information is stored like this :
#(mediadescriptions) (media) (extensions)
# printout (prin) .prn
# cassette (cass) .wav .tap .cas
# cartridge1 (cart1) .mx1 .bin .rom
# cartridge2 (cart2) .mx1 .bin .rom
# floppydisk (flop) .dsk .dmk .d77 .d88 .1dd .dfi .hfe .imd .ipf .mfi .mfm .td0 .cqm .cqi
echo "read compatible extension(s) for the individual media"
index=0
while read LINE; do
# if any?, remove earlier detected system(s) from the line
substitudeline=$(echo $LINE | sed "s/${systems[$index]}//g")
# use the first column if seperated by a space
mediadescriptions+=( "$(echo $substitudeline | cut -d " " -f 1)" )
# use the third column if seperated by a space and remove ( ) characters and add - for media
media+=( "$(echo $substitudeline | cut -d " " -f 2 | sed s/\(/-/g | sed s/\)//g)" )
# use the second column if seperated by a ) character and cut off the first space
extensions+=( "$(echo $substitudeline | cut -d ")" -f 2 | cut -c 2-)" )
index=$(( $index + 1 ))
done < <(/opt/retropie/emulators/mame/mame -listmedia $1 | grep -v -E "$namesfilter" | grep -E "$mediafilter")
#part 8 : do some filtering and read mamedev system descriptions into (descriptions)
echo "read computer description(s)"
#a manual command example would be :
#/opt/retropie/emulators/mame/mame -listdevices hbf700p | grep Driver | sed s/hbf700p//g | cut -c 10- | sed s/\)\://g
#the output, stored in the (descriptions) would be :
#HB-F700P (MSX2)
#
# keep the good info and delete text in lines ( "Driver"(cut), "system"(sed), "):"(sed) )
for index in "${!systems[@]}"; do descriptions+=( "$(/opt/retropie/emulators/mame/mame -listdevices ${systems[$index]} | grep Driver | sed s/$(echo ${systems[$index]})//g | cut -c 10- | sed s/\)\://g)" ); done
#part 9 : read RetroPie systems and descriptions from the platforms.cfg
echo "read and match RetroPie names with mamedev names"
while read LINE; do
# read retropie rom directory names
systemsrp+=( "$(echo $LINE | cut -d '_' -f 1)" )
# read retropie full system names
#
#sed is used to turn off the name (PC => -PC-),
#otherwise it has also matches with CPC ,PC Engine etc., for PC a solution still has to be found
#and change :
#(Atari Jaguar => Jaguar)
#(Mega CD => Mega-CD)
#(Sega 32X => 32X)
#(Commodore Amiga => Amiga)
#(Game and Watch => Game & Watch) , (and => &)
#&
#also some "words" have to be filtered out :
#(ProSystem)
#otherwise we don't have matches for these systems
#
descriptionsrp+=( "$(echo $LINE | sed 's/\"PC\"/\"-PC-\"/g' | sed 's/Atari Jaguar/Jaguar/g' | sed 's/Mega CD/Mega-CD/g' | sed 's/Sega 32X/32X/g' | sed 's/Commodore Amiga/Amiga/g' | sed 's/ and / \& /g' | sed 's/ProSystem//g' | cut -d '"' -f 2)" )
done < <(cat $HOME/RetroPie-Setup/platforms.cfg | grep fullname)
#part 10 : add extra possible future/unknown RetroPie names
#added because of the @DTEAM in Handheld tutorial
#!!! this name "handheld" not used by @DTEAM in Handheld tutorial !!! <=> can't extract "konamih" and "tigerh" from mamedev database, for now
systemsrp+=( "handheld" ) # can be overruled by added @DTEAM name changing
descriptionsrp+=( "handheld" ) # can be overruled by added @DTEAM name changing
#this name "jakks" is used by @DTEAM in Handheld tutorial <=> "jakks" can be extracted from mamedev database
#because "jakks" is not in the RetroPie platforms we add this here for later matching
systemsrp+=( "jakks" )
descriptionsrp+=( "JAKKS" )
#this name "tigerrz" is used by @DTEAM in Handheld tutorial <=> "tigerrz" can be extracted from mamedev database
#because "tigerrz" is not in the RetroPie platforms we add this here for later matching
systemsrp+=( "tigerrz" )
descriptionsrp+=( "R-Zone" )
#bbcmicro for BBC Micro is not in the original platforms.cfg
systemsrp+=( "bbcmicro" )
descriptionsrp+=( "BBC Micro" )
#bbcmicro for BBC Master is not in the original platforms.cfg
systemsrp+=( "bbcmicro" )
descriptionsrp+=( "BBC Master" )
#testlines
#echo ${systemsrp[@]}
#echo ${descriptionsrp[@]}
#part 11 : match the RetroPie descriptions to the mamedev descriptions
newsystems+=( "${systems[@]}" )
# use this in if function *${descriptionsrp[$rpindex]}* for match for a global match (containing parts)
# use this in if function "${descriptionsrp[$rpindex]}" for an exact match
# test array to check the code
#descriptionsrp=()
#descriptionsrp=("MSX" "Vectrex" "Atari 2600")
# end test array
# how many platforms in platforms.cfg
#echo ${#descriptionsrp[@]}
#platform PC is a bit tricky and should be checked the first time, if there is a second match
#the second match is probably the best match
# ??? have to find a solution for this ??? filter out or put in first index of array
for mamedevindex in "${!descriptions[@]}"; do
for rpindex in "${!descriptionsrp[@]}"; do
#create an empty array and split the the retropie name descriptions into seperate "words" in an array
splitdescriptionsrp=()
IFS=$' ' GLOBIGNORE='*' command eval 'splitdescriptionsrp=($(echo ${descriptionsrp[$rpindex]}))'
#check if every "word" is in the mess name descriptions * *=globally , " "=exact,
#!!! exact matching does not work here, because many times you are matching 1 "word" against multiple "words" !!!
if [[ "${descriptions[$mamedevindex]}" == *${splitdescriptionsrp[@]}* ]]; then
# If descriptions are exactly the same then use the system name of retropie as romdirectory
# for the other arrays we use the mamedev information
newsystems[$mamedevindex]=${systemsrp[$rpindex]}
echo "match - mamedev(description) - ${descriptions[$mamedevindex]} -- rp(description) - ${descriptionsrp[$rpindex]}"
echo "match - mamedev(romdir) - ${systems[$mamedevindex]} -- rp(romdir) - ${newsystems[$mamedevindex]} (RetroPie name is used)"
fi
done
done
#part 12 : match the added @DTEAM/RetroPie descriptions to the mamedev descriptions
#create a subarray "dteam_systems" containing the arrays that have to be used here
#now only two "for loops" can be use for checking multiple arrays against the RetroPie names
#note:some systems are not added because they should be recognised in a normal way
dteam_systems=("all_in1" "classich" "konamih" "tigerh")
#multiple arrays over one for loop:
#https://unix.stackexchange.com/questions/545502/bash-array-of-arrays
for mamedevindex in "${!systems[@]}"; do
for dteam_system in "${dteam_systems[@]}"; do
declare -n games="$dteam_system"
#testline#echo "system name: ${dteam_system} with system members: ${games[@]}"
for game in "${games[@]}"; do
#compare array game names with the mess systems ( * *=globally , " "=exact )
#testline#echo "${systems[$mamedevindex]}" == "$game"
if [[ "${systems[$mamedevindex]}" == "$game" ]]; then
# If descriptions are exactly the same then use the system name of retropie as romdirectory
# for the other arrays we use the mess information
newsystems[$mamedevindex]=$dteam_system
echo "Now using pseudo RetroPie systemname for ${systems[$mamedevindex]} becomes ${newsystems[$mamedevindex]}"
fi
done
done
done
# test line total output
#for index in "${!systems[@]}"; do echo $index ${systems[$index]} -- ${newsystems[$index]} | more ; echo -ne '\n'; done
# for index in "${!systems[@]}"; do
# if [[ "${systems[$index]}" != "${newsystems[$index]}" ]]; then
# echo "$index ${systems[$index]} => ${newsystems[$index]}"
# fi
# done
#part 13 : use all stored data to generate the modulescript containing "lr-mess" and "mame" commands with media option
# "install" in front of the filename is used for distinquish the files from others in the directory
# in the script libretro commands index use "lr-*" for compatibility with runcommand.sh
# (perhaps adding the future abitity of loading game specific retroarch configs)
# because mame is added and because mame is using this BIOS dir : $HOME/RetroPie/BIOS/mame
# the lr-mess command is changed to use the same BIOS dir
echo "generate and write the install-<RPname>-from-mamedev-system-<MESSname><-media>.sh script file(s)"
# put everything in a seperate directory
mkdir -p $HOME/RetroPie-Setup/scriptmodules/libretrocores 2>&-
# !!! .zip is manually added as extension in every generated script !!!
# used quotes in the next line, if there are spaces in the values of the arrays the file can not be generated, kept it in for debugging
for index in "${!systems[@]}"; do sleep 0.001; [[ -n ${allextensions[$index]} ]] && cat > "$HOME/RetroPie-Setup/scriptmodules/libretrocores/install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}".sh << _EOF_
#!/usr/bin/env bash
# This file is part of The RetroPie Project
#
# The RetroPie Project is the legal property of its developers, whose names are
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
#
# See the LICENSE.md file at the top-level directory of this distribution and
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
#
rp_module_id="install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}"
rp_module_name="${descriptions[$index]} with ${mediadescriptions[$index]} support"
rp_module_ext="$addextensions ${allextensions[$index]}"
rp_module_desc="Use lr-mess/mame emulator for (\$rp_module_name)"
rp_module_help="ROM Extensions: \$rp_module_ext\n
Above extensions are included for compatibility between different media installs.\n\n
ROM extensions only supported by this install:\n
$addextensions ${extensions[$index]}\n\n
Put games in:\n
\$romdir/${newsystems[$index]}\n\n
Put BIOS files in \$biosdir/mame:\n
${systems[$index]}.zip\n
Note:\n
BIOS info is automatically generated,\n
but some systems don't need a BIOS file!\n\n"
rp_module_licence="GPL2 https://raw.githubusercontent.com/libretro/mame/master/LICENSE.md"
rp_module_section="exp"
rp_module_flags=""
function depends_install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}() {
local _mess=\$(dirname "\$md_inst")/lr-mess/mess_libretro.so
if [[ ! -f "\$_mess" ]]; then
printMsgs dialog "cannot find '\$_mess' !\n\nplease install 'lr-mess' package."
exit 1
fi
}
function sources_install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}() {
true
}
function build_install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}() {
true
}
function install_install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}() {
true
}
function configure_install-${newsystems[$index]}-from-mamedev-system-${systems[$index]}${media[$index]}() {
local _mess=\$(dirname "\$md_inst")/lr-mess/mess_libretro.so
local _retroarch_bin="\$rootdir/emulators/retroarch/bin/retroarch"
local _system="${newsystems[$index]}"
local _config="\$configdir/\$_system/retroarch.cfg"
local _add_config="\$_config.add"
local _custom_coreconfig="\$configdir/\$_system/custom-core-options.cfg"
local _script="\$scriptdir/scriptmodules/run_mess.sh"
# create retroarch configuration
ensureSystemretroconfig "\$_system"
# ensure it works without softlists, using a custom per-fake-core config
iniConfig " = " "\"" "\$_custom_coreconfig"
iniSet "mame_softlists_enable" "disabled"
iniSet "mame_softlists_auto_media" "disabled"
iniSet "mame_boot_from_cli" "disabled"
iniSet "mame_mouse_enable" "enabled"
# this will get loaded too via --append_config
iniConfig " = " "\"" "\$_add_config"
iniSet "core_options_path" "\$_custom_coreconfig"
#iniSet "save_on_exit" "false"
# set permissions for configurations
chown \$user:\$user "\$_custom_coreconfig"
chown \$user:\$user "\$_add_config"
# setup rom folder # edit newsystem RetroPie name
mkRomDir "\$_system"
# ensure run_mess.sh script is executable
chmod 755 "\$_script"
# add the emulators.cfg as normal, pointing to the above script # use old mess name for booting
addEmulator 0 "lr-mess-system-${systems[$index]}${media[$index]}" "\$_system" "\$_script \$_retroarch_bin \$_mess \$_config \\${systems[$index]} \$biosdir/mame $mamedevcfgoptions ${media[$index]} %ROM%"
addEmulator 0 "mame-system-${systems[$index]}${media[$index]}" "\$_system" "/opt/retropie/emulators/mame/mame -v -c ${systems[$index]} ${media[$index]} %ROM%"
addEmulator 0 "mame-system-${systems[$index]}${media[$index]}-autoframeskip" "\$_system" "/opt/retropie/emulators/mame/mame -v -c -autoframeskip ${systems[$index]} ${media[$index]} %ROM%"
# add system to es_systems.cfg
#the line used by @valerino didn't work for the original RetroPie-setup
#therefore the information is added in a different way
addSystem "\$_system" "${descriptions[$index]}" "$addextensions ${allextensions[$index]}"
}
_EOF_
done
#part 14 : use all stored data to generate the modulescript containing "lr-mess" and "mame" commands for loading handmade .cmd files or to run basenames
# the none media mamedev system types have no extensions in the mamedev database
# in order to switch between emulators at retropie rom boot
# we have to add these extensions
# otherwise extensions supported by other emulators will not be shown anymore
# because mame is added and because mame is using this BIOS dir : $HOME/RetroPie/BIOS/mame
# the lr-mess command is changed to use the same BIOS dir
# "install" in front of the filename is used for distinquish the files from others in the directory
# in the script libretro commands index use "lr-*" for compatibility with runcommand.sh
# (perhaps adding the future abitity of loading game specific retroarch configs)(for example configs for overlays)
echo "generate and write the install-<RPname>-cmd.sh command script file(s)"
# put everything in a seperate directory
mkdir -p $HOME/RetroPie-Setup/scriptmodules/libretrocores 2>&-
# !!! .zip is manually added as extension in every generated script !!!
# used quotes in the next line, if there are spaces in the values of the arrays the file can not be generated, kept it in for debugging
# grep function is used to get all extensions compatible with all possible emulation methods so switching within emulationstation is possible
# grep searches in both platform.cfg and this script ($0) , so also extensions are added that are not in platform.cfg
# using grep this way can create double extension, but this should not be a problem
for index in "${!newsystems[@]}"; do sleep 0.001; platformextensionsrp=$(grep ${newsystems[$index]}_exts $HOME/RetroPie-Setup/platforms.cfg $0 | cut -d '"' -f 2); cat > "$HOME/RetroPie-Setup/scriptmodules/libretrocores/install-${newsystems[$index]}-cmd".sh << _EOF_
#!/usr/bin/env bash
# This file is part of The RetroPie Project
#
# The RetroPie Project is the legal property of its developers, whose names are
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
#
# See the LICENSE.md file at the top-level directory of this distribution and
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
#
rp_module_id="install-${newsystems[$index]}-cmd"
rp_module_name="${newsystems[$index]} with command and game-BIOS support"
rp_module_ext="$addextensionscmd $addextensions ${allextensions[$index]}$platformextensionsrp"
rp_module_desc="Use lr-mess and mame emulator for ${newsystems[$index]}"
rp_module_help="ROM Extensions: \$rp_module_ext\n
Above extensions are included for compatibility between different media installs.\n\n
ROM extensions only supported by this install:\n
$addextensionscmd $addextensions ${extensions[$index]}\n\n
Put games or *game-BIOS files in (* for handhelds ...):\n
\$romdir/${newsystems[$index]}\n
Note ! : with this setup, multiple lr-mess/mame system types can be run.\n
So no specific BIOS info can be given.\n
Put BIOS files in \$biosdir/mame\n
When using game-BIOS files, no BIOS is needed in the BIOS directory.\n"
rp_module_licence="GPL2 https://raw.githubusercontent.com/libretro/mame/master/LICENSE.md"
rp_module_section="exp"
rp_module_flags=""
function depends_install-${newsystems[$index]}-cmd() {
local _mess=\$(dirname "\$md_inst")/lr-mess/mess_libretro.so
if [[ ! -f "\$_mess" ]]; then
printMsgs dialog "cannot find '\$_mess' !\n\nplease install 'lr-mess' package."
exit 1
fi
}
function sources_install-${newsystems[$index]}-cmd() {
true
}
function build_install-${newsystems[$index]}-cmd() {
true
}
function install_install-${newsystems[$index]}-cmd() {
true
}
function configure_install-${newsystems[$index]}-cmd() {
local _retroarch_bin="\$rootdir/emulators/retroarch/bin/retroarch"
local _mess=\$(dirname "\$md_inst")/lr-mess/mess_libretro.so
local _system="${newsystems[$index]}"
local _config="\$configdir/\$_system/retroarch.cfg"
mkRomDir "\$_system"
ensureSystemretroconfig "\$_system"
echo "enable cheats for lr-mess in \$configdir/all/retroarch-core-options.cfg"
iniConfig " = " "\"" "\$configdir/all/retroarch-core-options.cfg"
iniSet "mame_cheats_enable" "enabled"
chown \$user:\$user "\$configdir/all/retroarch-core-options.cfg"
echo "enable cheats for mame in \$romdir/mame/mame.ini"
iniConfig " " "" "\$romdir/mame/mame.ini"
iniSet "cheatpath" "\$romdir/mame/cheat"
iniSet "cheat" "1"
chown \$user:\$user "\$romdir/mame/mame.ini"
addEmulator 0 "lr-mess-cmd" "\$_system" "\$_retroarch_bin --config \$_config -v -L \$_mess %ROM%"
addEmulator 0 "lr-mess-basename" "\$_system" "\$_retroarch_bin --config \$_config -v -L \$_mess %BASENAME%"
addEmulator 0 "mame-cmd" "\$_system" "/opt/retropie/emulators/mame/mame -rompath $HOME/RetroPie/roms/${newsystems[$index]} -v -c %BASENAME%"
addEmulator 0 "mame-cmd-autoframeskip" "\$_system" "/opt/retropie/emulators/mame/mame -rompath $HOME/RetroPie/roms/${newsystems[$index]} -v -c -autoframeskip %BASENAME%"
addEmulator 0 "mame-basename" "\$_system" "/opt/retropie/emulators/mame/mame -v -c ${newsystems[$index]} %BASENAME%"
addEmulator 0 "mame-basename-autoframeskip" "\$_system" "/opt/retropie/emulators/mame/mame -v -c -autoframeskip ${newsystems[$index]} %BASENAME%"
#turned these off, seems these commands will not work, but kept for future testing : https://retropie.org.uk/forum/topic/29682/development-of-module-script-generator-for-lr-mess-and-mame-standalone/33
##addEmulator 0 "mame-basename-test" "\$_system" "/opt/retropie/emulators/mame/mame -rompath $HOME/RetroPie/roms/${newsystems[$index]} -v -c %BASENAME%"
##addEmulator 0 "mame-basename-autoframeskip-test" "\$_system" "/opt/retropie/emulators/mame/mame -rompath $HOME/RetroPie/roms/${newsystems[$index]} -v -c -autoframeskip %BASENAME%"
# add system to es_systems.cfg
#the line used by @valerino didn't work for the original RetroPie-setup
#therefore the information is added in a different way
#the system name is also used as description because, for example, handhelds are generated with game system names
addSystem "\$_system" "\$_system" "$addextensionscmd $addextensions ${allextensions[$index]}$platformextensionsrp"
}
_EOF_
done
date
echo stop