-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMiSTer_SAM_on.sh
5326 lines (4648 loc) · 174 KB
/
MiSTer_SAM_on.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
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# https://github.com/mrchrisster/MiSTer_SAM/
# Copyright (c) 2023 by mrchrisster and Mellified
# 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.
# Description
# This cycles through arcade and console cores periodically
# Games are randomly pulled from their respective folders
# ======== Credits ========
# Original concept and implementation: mrchrisster
# Script layout & watchdog functionality: Mellified
# tty2oled submodule: Paradox
# Indexing tool: wizzomafizzo
#
# Thanks for the contributions and support:
# pocomane, kaloun34, redsteakraw, RetroDriven, woelper, LamerDeluxe, InquisitiveCoder, Sigismond, theypsilon
# tty2oled improvements by venice
# TODO implement playcurrentgame for amiga
# ======== INI VARIABLES ========
# Change these in the INI file
function init_vars() {
declare -g mrsampath="/media/fat/Scripts/.MiSTer_SAM"
declare -g misterpath="/media/fat"
declare -g mrsamtmp="/tmp/.SAM_tmp"
# Save our PID and process
declare -g sampid="${$}"
declare -g samprocess
samprocess="$(basename -- "${0}")"
declare -g menuonly="Yes"
declare -g key_activity_file="/tmp/.SAM_tmp/SAM_Keyboard_Activity"
declare -g joy_activity_file="/tmp/.SAM_tmp/SAM_Joy_Activity"
declare -g mouse_activity_file="/tmp/.SAM_tmp/SAM_Mouse_Activity"
declare -g sam_menu_file="/tmp/.SAM_tmp/.SAMmenu"
declare -g brfake="/tmp/.SAM_tmp/brfake"
declare -g samini_file="/media/fat/Scripts/MiSTer_SAM.ini"
declare -g samini_update_file="${mrsampath}/MiSTer_SAM.default.ini"
declare -gi inmenu=0
declare -gi sam_bgmmenu=0
declare -gi shown=0
declare -gi coreretries=3
declare -gi romloadfails=0
declare -g gamelistpath="${mrsampath}/SAM_Gamelists"
declare -g gamelistpathtmp="/tmp/.SAM_List"
declare -g gamelistpathtmp="/tmp/.SAM_List"
declare -g tmpfile="/tmp/.SAM_List/tmpfile"
declare -g tmpfile2="/tmp/.SAM_List/tmpfile2"
declare -g tmpfilefilter="/tmp/.SAM_List/tmpfilefilter"
declare -g corelisttmpfile="/tmp/.SAM_List/corelisttmp.tmp"
declare -g corelistfile="/tmp/.SAM_List/corelist.tmp"
declare -g core_count_file="/tmp/.SAM_tmp/sv_corecount"
declare -gi disablecoredel="0"
declare -gi gametimer=120
declare -gl corelist="amiga,amigacd32,ao486,arcade,atari2600,atari5200,atari7800,atarilynx,c64,coco2,fds,gb,gbc,gba,genesis,gg,megacd,n64,neogeo,neogeocd,nes,s32x,saturn,sgb,sms,snes,tgfx16,tgfx16cd,psx"
declare -gl corelistall="${corelist}"
declare -gl skipmessage="Yes"
declare -gl disablebootrom="no"
declare -gl skiptime="10"
declare -gl norepeat="Yes"
declare -gl disable_blacklist="No"
declare -gl disablebootrom="Yes"
declare -gl amigaselect="All"
declare -gl m82="no"
declare -gl sam_goat_list="no"
declare -gl mute="No"
declare -gi update_done=0
declare -gl ignore_when_skip="no"
declare -gl coreweight="No"
declare -gl playcurrentgame="No"
declare -gl kids_safe="No"
declare -gl dupe_mode="normal"
declare -gl listenmouse="Yes"
declare -gl listenkeyboard="Yes"
declare -gl listenjoy="Yes"
declare -g repository_url="https://github.com/mrchrisster/MiSTer_SAM"
declare -g branch="main"
declare -gi counter=0
declare -gA corewc
declare -gA corep
declare -g userstartup="/media/fat/linux/user-startup.sh"
declare -g userstartuptpl="/media/fat/linux/_user-startup.sh"
declare -gl useneogeotitles="Yes"
declare -gl arcadeorient
declare -gl checkzipsondisk="Yes"
declare -gi bootsleep="60"
declare -gi totalgamecount
# ======== DEBUG VARIABLES ========
declare -gl samdebug="No"
declare -gl samdebuglog="No"
# ======== BGM =======
declare -gl bgm="No"
declare -gl bgmplay="Yes"
declare -gl bgmstop="Yes"
declare -gi gvoladjust="0"
# ======== TTY2OLED =======
declare -g TTY_cmd_pipe="${mrsamtmp}/TTY_cmd_pipe"
declare -gl ttyenable="No"
declare -gi ttyupdate_pause=10
declare -g tty_currentinfo_file=${mrsamtmp}/tty_currentinfo
declare -g tty_sleepfile="/tmp/tty2oled_sleep"
declare -gl ttyname_cleanup="no"
declare -gA tty_currentinfo=(
[core_pretty]=""
[name]=""
[core]=""
[date]=0
[counter]=0
[name_scroll]=""
[name_scroll_position]=0
[name_scroll_direction]=1
[update_pause]=${ttyupdate_pause}
)
# ======== SAMVIDEO =======
declare -gA SV_TVC_CL
declare -gl samvideo
declare -gl samvideo_freq
declare -gl samvideo_output="hdmi"
declare -gl samvideo_source
declare -gl samvideo_tvc
declare -gl download_manager="yes"
declare -gl sv_aspectfix_vmode
declare -gl sv_inimod="yes"
declare -g samvideo_crtmode="video_mode=640,16,64,80,240,1,3,14,12380"
declare -g samvideo_displaywait="2"
declare -g tmpvideo="/tmp/SAMvideo.mp4"
declare -g ini_file="/media/fat/MiSTer.ini"
declare -g ini_contents=$(cat "$ini_file")
declare -g sv_core="/tmp/.SAM_tmp/sv_core"
declare -g sv_gametimer_file="/tmp/.SAM_tmp/sv_gametimer"
declare -g sv_loadcounter=0
declare -g samvideo_path="/media/fat/video"
declare -g sv_archive_hdmilist="https://archive.org/download/640x480_videogame_commercials/640x480_videogame_commercials_files.xml"
declare -g sv_archive_crtlist="https://archive.org/download/640x240_videogame_commercials/640x240_videogame_commercials_files.xml"
declare -g sv_youtube_hdmilist="${mrsampath}/sv_yt360_list.txt"
declare -g sv_youtube_crtlist="${mrsampath}/sv_yt240_list.txt"
# ======== CORE PATHS RBF ========
declare -g amigapathrbf="_Computer"
declare -g amigacd32pathrbf="_Computer"
declare -g arcadepathrbf="_Arcade"
declare -g ao486pathrbf="_Computer"
declare -g atari2600pathrbf="_Console"
declare -g atari5200pathrbf="_Console"
declare -g atari7800pathrbf="_Console"
declare -g atarilynxpathrbf="_Console"
declare -g c64pathrbf="_Computer"
declare -g coco2pathrbf="_Computer"
declare -g fdspathrbf="_Console"
declare -g gbpathrbf="_Console"
declare -g gbcpathrbf="_Console"
declare -g gbapathrbf="_Console"
declare -g genesispathrbf="_Console"
declare -g ggpathrbf="_Console"
declare -g megacdpathrbf="_Console"
declare -g n64pathrbf="_Console"
declare -g neogeopathrbf="_Console"
declare -g neogeocdpathrbf="_Console"
declare -g nespathrbf="_Console"
declare -g s32xpathrbf="_Console"
declare -g saturnpathrbf="_Console"
declare -g sgbpathrbf="_Console"
declare -g smspathrbf="_Console"
declare -g snespathrbf="_Console"
declare -g tgfx16pathrbf="_Console"
declare -g tgfx16cdpathrbf="_Console"
declare -g psxpathrbf="_Console"
if [[ "${corelist[@]}" == *"amiga"* ]] || [[ "${corelist[@]}" == *"amigacd32"* ]] || [[ "${corelist[@]}" == *"ao486"* ]] && [ -f "${mrsampath}"/samindex ]; then
declare -g amigapath="$("${mrsampath}"/samindex -q -s amiga -d |awk -F':' '{print $2}')"
declare -g amigacore="$(find /media/fat/_Computer/ -iname "*minimig*")"
declare -g amigacd32path="$("${mrsampath}"/samindex -q -s amigacd32 -d |awk -F':' '{print $2}')"
declare -g ao486path="$("${mrsampath}"/samindex -q -s ao486 -d |awk -F':' '{print $2}')"
fi
# ======= MiSTer.ini AITORGOMEZ FORK =======
declare -g cfgcore_configpath=$(
awk -F '=' '
BEGIN { found = 0 }
/^cfgcore_subfolder[[:space:]]*=/ {
if (!found) {
print "/media/fat/config/" $2;
found = 1
}
}
END {
if (!found) print ""
}
' "$ini_file" | tr -d '"' | sed -e 's|//|/|g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
)
declare -g cfgarcade_configpath=$(
awk -F '=' '
BEGIN { found = 0 }
/^cfgarcade_subfolder[[:space:]]*=/ {
if (!found) {
print "/media/fat/config/" $2;
found = 1
}
}
END {
if (!found) print ""
}
' "$ini_file" | tr -d '"' | sed -e 's|//|/|g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
)
if [[ -n "$cfgcore_configpath" ]]; then
declare -g configpath="$cfgcore_configpath"
else
declare -g configpath="/media/fat/config/"
fi
}
# ======== CORE CONFIG ========
function init_data() {
# Core to long name mappings
declare -gA CORE_PRETTY=(
["amiga"]="Commodore Amiga"
["amigacd32"]="Commodore Amiga CD32"
["arcade"]="MiSTer Arcade"
["ao486"]="PC 486 DX-100"
["atari2600"]="Atari 2600"
["atari5200"]="Atari 5200"
["atari7800"]="Atari 7800"
["atarilynx"]="Atari Lynx"
["c64"]="Commodore 64"
["coco2"]="TRS-80 Color Computer 2"
["fds"]="Nintendo Disk System"
["gb"]="Nintendo Game Boy"
["gbc"]="Nintendo Game Boy Color"
["gba"]="Nintendo Game Boy Advance"
["genesis"]="Sega Genesis / Megadrive"
["gg"]="Sega Game Gear"
["megacd"]="Sega CD / Mega CD"
["n64"]="Nintendo N64"
["neogeo"]="SNK NeoGeo"
["neogeocd"]="SNK NeoGeo CD"
["nes"]="Nintendo Entertainment System"
["s32x"]="Sega 32x"
["saturn"]="Sega Saturn"
["sgb"]="Super Gameboy"
["sms"]="Sega Master System"
["snes"]="Super Nintendo"
["tgfx16"]="NEC TurboGrafx-16 "
["tgfx16cd"]="NEC TurboGrafx-16 CD"
["psx"]="Sony Playstation"
)
# Core to file extension mappings
declare -glA CORE_EXT=(
["amiga"]="hdf" #This is just a placeholder
["amigacd32"]="chd,cue"
["ao486"]="vhd" #This is just a placeholder
["arcade"]="mra"
["atari2600"]="a26"
["atari5200"]="a52,car"
["atari7800"]="a78"
["atarilynx"]="lnx"
["c64"]="crt,prg" # need to be tested "reu,tap,flt,rom,c1581"
["coco2"]="ccc"
["fds"]="fds"
["gb"]="gb"
["gbc"]="gbc"
["gba"]="gba"
["genesis"]="md,gen"
["gg"]="gg"
["megacd"]="chd,cue"
["n64"]="n64,z64"
["neogeo"]="neo"
["neogeocd"]="cue,chd"
["nes"]="nes"
["s32x"]="32x"
["saturn"]="cue,chd"
["sgb"]="gb,gbc"
["sms"]="sms,sg"
["snes"]="sfc,smc" # Should we include? "bin,bs"
["tgfx16"]="pce,sgx"
["tgfx16cd"]="chd,cue"
["psx"]="chd,cue,exe"
)
# Core to path mappings
declare -gA PATHFILTER=(
["amiga"]="${amigapathfilter}"
["amigacd32"]="${amigacd32pathfilter}"
["ao486"]="${ao486pathfilter}"
["arcade"]="${arcadepathfilter}"
["atari2600"]="${atari2600pathfilter}"
["atari5200"]="${atari5200pathfilter}"
["atari7800"]="${atari7800pathfilter}"
["atarilynx"]="${atarilynxpathfilter}"
["c64"]="${c64pathfilter}"
["coco2"]="${coco2pathfilter}"
["fds"]="${fdspathfilter}"
["gb"]="${gbpathfilter}"
["gbc"]="${gbcpathfilter}"
["gba"]="${gbapathfilter}"
["genesis"]="${genesispathfilter}"
["gg"]="${ggpathfilter}"
["megacd"]="${megacdpathfilter}"
["n64"]="${n64pathfilter}"
["neogeo"]="${neogeopathfilter}"
["neogeocd"]="${neogeocdpathfilter}"
["nes"]="${nespathfilter}"
["s32x"]="${s32xpathfilter}"
["saturn"]="${saturnpathfilter}"
["sgb"]="${sgbpathfilter}"
["sms"]="${smspathfilter}"
["snes"]="${snespathfilter}"
["tgfx16"]="${tgfx16pathfilter}"
["tgfx16cd"]="${tgfx16cdpathfilter}"
["psx"]="${psxpathfilter}"
)
# Core to path mappings for rbf files
declare -gA CORE_PATH_RBF=(
["amiga"]="${amigapathrbf}"
["amigacd32"]="${amigacd32pathrbf}"
["ao486"]="${ao486pathrbf}"
["arcade"]="${arcadepathrbf}"
["atari2600"]="${atari2600pathrbf}"
["atari5200"]="${atari5200pathrbf}"
["atari7800"]="${atari7800pathrbf}"
["atarilynx"]="${atarilynxpathrbf}"
["c64"]="${c64pathrbf}"
["coco2"]="${coco2pathrbf}"
["fds"]="${fdspathrbf}"
["gb"]="${gbpathrbf}"
["gbc"]="${gbcpathrbf}"
["gba"]="${gbapathrbf}"
["genesis"]="${genesispathrbf}"
["gg"]="${ggpathrbf}"
["megacd"]="${megacdpathrbf}"
["n64"]="${n64pathrbf}"
["neogeo"]="${neogeopathrbf}"
["neogeocd"]="${neogeocdpathrbf}"
["nes"]="${nespathrbf}"
["s32x"]="${s32xpathrbf}"
["saturn"]="${saturnpathrbf}"
["sgb"]="${sgbpathrbf}"
["sms"]="${smspathrbf}"
["snes"]="${snespathrbf}"
["tgfx16"]="${tgfx16pathrbf}"
["tgfx16cd"]="${tgfx16cdpathrbf}"
["psx"]="${psxpathrbf}"
)
# Can this core skip Bios/Safety warning messages
declare -glA CORE_SKIP=(
["amiga"]="No"
["amigacd32"]="Yes"
["ao486"]="No"
["arcade"]="No"
["atari2600"]="No"
["atari5200"]="No"
["atari7800"]="No"
["atarilynx"]="No"
["c64"]="No"
["coco2"]="No"
["fds"]="Yes"
["gb"]="No"
["gbc"]="No"
["gba"]="No"
["genesis"]="No"
["gg"]="No"
["megacd"]="Yes"
["n64"]="No"
["neogeo"]="No"
["neogeocd"]="Yes"
["nes"]="No"
["s32x"]="No"
["saturn"]="Yes"
["sgb"]="No"
["sms"]="No"
["snes"]="No"
["tgfx16"]="No"
["tgfx16cd"]="Yes"
["psx"]="No"
)
# Core to input maps mapping
declare -gA CORE_LAUNCH=(
["amiga"]="Minimig"
["amigacd32"]="Minimig"
["ao486"]="ao486"
["arcade"]="Arcade"
["atari2600"]="ATARI7800"
["atari5200"]="ATARI5200"
["atari7800"]="ATARI7800"
["atarilynx"]="AtariLynx"
["c64"]="C64"
["coco2"]="CoCo2"
["fds"]="NES"
["gb"]="GAMEBOY"
["gbc"]="GAMEBOY"
["gba"]="GBA"
["genesis"]="MEGADRIVE"
["gg"]="SMS"
["megacd"]="MegaCD"
["n64"]="N64"
["neogeo"]="NEOGEO"
["neogeocd"]="NEOGEO"
["nes"]="NES"
["s32x"]="S32X"
["saturn"]="SATURN"
["sgb"]="SGB"
["sms"]="SMS"
["snes"]="SNES"
["tgfx16"]="TGFX16"
["tgfx16cd"]="TGFX16"
["psx"]="PSX"
)
# TTY2OLED Core Pic mappings
declare -gA TTY2OLED_PIC_NAME=(
["amiga"]="Minimig"
["amigacd32"]="Minimig"
["ao486"]="ao486"
["arcade"]="Arcade"
["atari2600"]="ATARI2600"
["atari5200"]="ATARI5200"
["atari7800"]="ATARI7800"
["atarilynx"]="AtariLynx"
["c64"]="C64"
["coco2"]="CoCo2"
["fds"]="fds"
["gb"]="GAMEBOY"
["gbc"]="GAMEBOY"
["gba"]="GBA"
["genesis"]="Genesis"
["gg"]="gamegear"
["megacd"]="MegaCD"
["n64"]="N64"
["neogeo"]="NEOGEO"
["neogeocd"]="NEOGEO"
["nes"]="NES"
["s32x"]="S32X"
["saturn"]="SATURN"
["sgb"]="SGB"
["sms"]="SMS"
["snes"]="SNES"
["tgfx16"]="TGFX16"
["tgfx16cd"]="TGFX16"
["psx"]="PSX"
)
# MGL core name settings
declare -gA MGL_CORE=(
["amiga"]="Minimig"
["amigacd32"]="Minimig"
["ao486"]="ao486"
["arcade"]="Arcade"
["atari2600"]="ATARI7800"
["atari5200"]="ATARI5200"
["atari7800"]="ATARI7800"
["atarilynx"]="AtariLynx"
["c64"]="C64"
["coco2"]="CoCo2"
["fds"]="NES"
["gb"]="GAMEBOY"
["gbc"]="GAMEBOY"
["gba"]="GBA"
["genesis"]="MegaDrive"
["gg"]="SMS"
["megacd"]="MegaCD"
["n64"]="N64"
["neogeo"]="NEOGEO"
["neogeocd"]="NEOGEO"
["nes"]="NES"
["s32x"]="S32X"
["saturn"]="SATURN"
["sgb"]="SGB"
["sms"]="SMS"
["snes"]="SNES"
["tgfx16"]="TurboGrafx16"
["tgfx16cd"]="TurboGrafx16"
["psx"]="PSX"
)
# MGL setname settings
declare -gA MGL_SETNAME=(
["amigacd32"]="AmigaCD32"
["gbc"]="GBC"
["gg"]="GameGear"
)
# MGL delay settings
declare -giA MGL_DELAY=(
["amiga"]="1"
["amigacd32"]="1"
["ao486"]="0"
["arcade"]="2"
["atari2600"]="1"
["atari5200"]="1"
["atari7800"]="1"
["atarilynx"]="1"
["c64"]="1"
["coco2"]="1"
["fds"]="2"
["gb"]="2"
["gbc"]="2"
["gba"]="2"
["genesis"]="1"
["gg"]="1"
["megacd"]="1"
["n64"]="1"
["neogeo"]="1"
["neogeocd"]="1"
["nes"]="2"
["s32x"]="1"
["saturn"]="1"
["sgb"]="1"
["sms"]="1"
["snes"]="2"
["tgfx16"]="1"
["tgfx16cd"]="1"
["psx"]="1"
)
# MGL index settings
declare -giA MGL_INDEX=(
["amiga"]="0"
["amigacd32"]="0"
["ao486"]="2"
["arcade"]="0"
["atari2600"]="0"
["atari5200"]="1"
["atari7800"]="1"
["atarilynx"]="1"
["c64"]="1"
["coco2"]="1"
["fds"]="0"
["gb"]="0"
["gbc"]="0"
["gba"]="0"
["genesis"]="0"
["gg"]="2"
["megacd"]="0"
["n64"]="1"
["neogeo"]="1"
["neogeocd"]="1"
["nes"]="0"
["s32x"]="0"
["saturn"]="1"
["sgb"]="1"
["sms"]="1"
["snes"]="0"
["tgfx16"]="1"
["tgfx16cd"]="0"
["psx"]="1"
)
# MGL type settings
declare -glA MGL_TYPE=(
["amiga"]="f"
["amigacd32"]="f"
["ao486"]="s"
["arcade"]="f"
["atari2600"]="f"
["atari5200"]="f"
["atari7800"]="f"
["atarilynx"]="f"
["c64"]="f"
["coco2"]="f"
["fds"]="f"
["gb"]="f"
["gbc"]="f"
["gba"]="f"
["genesis"]="f"
["gg"]="f"
["megacd"]="s"
["n64"]="f"
["neogeo"]="f"
["neogeocd"]="s"
["nes"]="f"
["s32x"]="f"
["saturn"]="s"
["sgb"]="f"
["sms"]="f"
["snes"]="f"
["tgfx16"]="f"
["tgfx16cd"]="s"
["psx"]="s"
)
# NEOGEO to long name mappings English
declare -gA NEOGEO_PRETTY_ENGLISH=(
["3countb"]="3 Count Bout"
["2020bb"]="2020 Super Baseball"
["2020bba"]="2020 Super Baseball (set 2)"
["2020bbh"]="2020 Super Baseball (set 3)"
["abyssal"]="Abyssal Infants"
["alpham2"]="Alpha Mission II"
["alpham2p"]="Alpha Mission II (prototype)"
["androdun"]="Andro Dunos"
["aodk"]="Aggressors of Dark Kombat"
["aof"]="Art of Fighting"
["aof2"]="Art of Fighting 2"
["aof2a"]="Art of Fighting 2 (NGH-056)"
["aof3"]="Art of Fighting 3: The Path of the Warrior"
["aof3k"]="Art of Fighting 3: The Path of the Warrior (Korean release)"
["b2b"]="Bang Bang Busters"
["badapple"]="Bad Apple Demo"
["bakatono"]="Bakatonosama Mahjong Manyuuki"
["bangbead"]="Bang Bead"
["bjourney"]="Blue's Journey"
["blazstar"]="Blazing Star"
["breakers"]="Breakers"
["breakrev"]="Breakers Revenge"
["brningfh"]="Burning Fight (NGH-018, US)"
["brningfp"]="Burning Fight (prototype, older)"
["brnngfpa"]="Burning Fight (prototype, near final, ver 23.3, 910326)"
["bstars"]="Baseball Stars Professional"
["bstars2"]="Baseball Stars 2"
["bstarsh"]="Baseball Stars Professional (NGH-002)"
["burningf"]="Burning Fight"
["burningfh"]="Burning Fight (NGH-018, US)"
["burningfp"]="Burning Fight (prototype, older)"
["burningfpa"]="Burning Fight (prototype, near final, ver 23.3, 910326)"
["cabalng"]="Cabal"
["columnsn"]="Columns"
["cphd"]="Crouching Pony Hidden Dragon Demo"
["crswd2bl"]="Crossed Swords 2 (CD conversion)"
["crsword"]="Crossed Swords"
["ct2k3sa"]="Crouching Tiger Hidden Dragon 2003 Super Plus (The King of Fighters 2001 bootleg)"
["ctomaday"]="Captain Tomaday"
["cyberlip"]="Cyber-Lip"
["diggerma"]="Digger Man"
["doubledr"]="Double Dragon"
["eightman"]="Eight Man"
["fatfursp"]="Fatal Fury Special"
["fatfurspa"]="Fatal Fury Special (NGM-058 ~ NGH-058, set 2)"
["fatfury1"]="Fatal Fury: King of Fighters"
["fatfury2"]="Fatal Fury 2"
["fatfury3"]="Fatal Fury 3: Road to the Final Victory"
["fbfrenzy"]="Football Frenzy"
["fghtfeva"]="Fight Fever (set 2)"
["fightfev"]="Fight Fever"
["fightfeva"]="Fight Fever (set 2)"
["flipshot"]="Battle Flip Shot"
["frogfest"]="Frog Feast"
["froman2b"]="Idol Mahjong Final Romance 2 (CD conversion)"
["fswords"]="Fighters Swords (Korean release of Samurai Shodown III)"
["ftfurspa"]="Fatal Fury Special (NGM-058 ~ NGH-058, set 2)"
["galaxyfg"]="Galaxy Fight: Universal Warriors"
["ganryu"]="Ganryu"
["garou"]="Garou: Mark of the Wolves"
["garoubl"]="Garou: Mark of the Wolves (bootleg)"
["garouh"]="Garou: Mark of the Wolves (earlier release)"
["garoup"]="Garou: Mark of the Wolves (prototype)"
["ghostlop"]="Ghostlop"
["goalx3"]="Goal! Goal! Goal!"
["gowcaizr"]="Voltage Fighter Gowcaizer"
["gpilots"]="Ghost Pilots"
["gpilotsh"]="Ghost Pilots (NGH-020, US)"
["gururin"]="Gururin"
["hyprnoid"]="Hypernoid"
["irnclado"]="Ironclad (prototype, bootleg)"
["ironclad"]="Ironclad"
["ironclado"]="Ironclad (prototype, bootleg)"
["irrmaze"]="The Irritating Maze"
["janshin"]="Janshin Densetsu: Quest of Jongmaster"
["joyjoy"]="Puzzled"
["kabukikl"]="Far East of Eden: Kabuki Klash"
["karnovr"]="Karnov's Revenge"
["kf2k2mp"]="The King of Fighters 2002 Magic Plus (bootleg)"
["kf2k2mp2"]="The King of Fighters 2002 Magic Plus II (bootleg)"
["kf2k2pla"]="The King of Fighters 2002 Plus (bootleg set 2)"
["kf2k2pls"]="The King of Fighters 2002 Plus (bootleg)"
["kf2k5uni"]="The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg)"
["kf10thep"]="The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg)"
["kizuna"]="Kizuna Encounter: Super Tag Battle"
["kof2k4se"]="The King of Fighters Special Edition 2004 (The King of Fighters 2002 bootleg)"
["kof94"]="The King of Fighters '94"
["kof95"]="The King of Fighters '95"
["kof95a"]="The King of Fighters '95 (NGM-084, alt board)"
["kof95h"]="The King of Fighters '95 (NGH-084)"
["kof96"]="The King of Fighters '96"
["kof96h"]="The King of Fighters '96 (NGH-214)"
["kof97"]="The King of Fighters '97"
["kof97h"]="The King of Fighters '97 (NGH-2320)"
["kof97k"]="The King of Fighters '97 (Korean release)"
["kof97oro"]="The King of Fighters '97 Chongchu Jianghu Plus 2003 (bootleg)"
["kof97pls"]="The King of Fighters '97 Plus (bootleg)"
["kof98"]="The King of Fighters '98: The Slugfest"
["kof98a"]="The King of Fighters '98: The Slugfest (NGM-2420, alt board)"
["kof98h"]="The King of Fighters '98: The Slugfest (NGH-2420)"
["kof98k"]="The King of Fighters '98: The Slugfest (Korean release)"
["kof98ka"]="The King of Fighters '98: The Slugfest (Korean release, set 2)"
["kof99"]="The King of Fighters '99: Millennium Battle"
["kof99e"]="The King of Fighters '99: Millennium Battle (earlier release)"
["kof99h"]="The King of Fighters '99: Millennium Battle (NGH-2510)"
["kof99k"]="The King of Fighters '99: Millennium Battle (Korean release)"
["kof99p"]="The King of Fighters '99: Millennium Battle (prototype)"
["kof2000"]="The King of Fighters 2000"
["kof2000n"]="The King of Fighters 2000"
["kof2001"]="The King of Fighters 2001"
["kof2001h"]="The King of Fighters 2001 (NGH-2621)"
["kof2002"]="The King of Fighters 2002"
["kof2002b"]="The King of Fighters 2002 (bootleg)"
["kof2003"]="The King of Fighters 2003"
["kof2003h"]="The King of Fighters 2003 (NGH-2710)"
["kof2003ps2"]="The King of Fighters 2003 (PS2)"
["kog"]="King of Gladiators (The King of Fighters '97 bootleg)"
["kotm"]="King of the Monsters"
["kotm2"]="King of the Monsters 2: The Next Thing"
["kotm2p"]="King of the Monsters 2: The Next Thing (prototype)"
["kotmh"]="King of the Monsters (set 2)"
["lans2004"]="Lansquenet"
["lastblad"]="The Last Blade"
["lastbladh"]="The Last Blade (NGH-2340)"
["lastbld2"]="The Last Blade 2"
["lasthope"]="Last Hope"
["lastsold"]="The Last Soldier"
["lbowling"]="League Bowling"
["legendos"]="Legend of Success Joe"
["lresort"]="Last Resort"
["lresortp"]="Last Resort (prototype)"
["lstbladh"]="Last Blade (NGH-2340)"
["magdrop2"]="Magical Drop II"
["magdrop3"]="Magical Drop III"
["maglord"]="Magician Lord"
["maglordh"]="Magician Lord (NGH-005)"
["mahretsu"]="Mahjong Kyo Retsuden"
["marukodq"]="Chibi Marukochan Deluxe Quiz"
["matrim"]="Power Instinct Matrimelee"
["miexchng"]="Money Puzzle Exchanger"
["minasan"]="Minasan no Okagesamadesu! Dai Sugoroku Taikai"
["montest"]="Monitor Test ROM"
["moshougi"]="Shougi no Tatsujin: Master of Syougi"
["ms4plus"]="Metal Slug 4 Plus (bootleg)"
["mslug"]="Metal Slug: Super Vehicle-001"
["mslug2"]="Metal Slug 2: Super Vehicle-001/II"
["mslug2t"]="Metal Slug 2 Turbo (hack)"
["mslug3"]="Metal Slug 3"
["mslug3b6"]="Metal Slug 6 (Metal Slug 3 bootleg)"
["mslug3h"]="Metal Slug 3 (NGH-2560)"
["mslug4"]="Metal Slug 4"
["mslug4h"]="Metal Slug 4 (NGH-2630)"
["mslug5"]="Metal Slug 5"
["mslug5h"]="Metal Slug 5 (NGH-2680)"
["mslug6"]="Metal Slug 6 (Metal Slug 3 bootleg)"
["mslugx"]="Metal Slug X: Super Vehicle-001"
["mutnat"]="Mutation Nation"
["nam1975"]="NAM-1975"
["nblktigr"]="Neo Black Tiger"
["ncombat"]="Ninja Combat"
["ncombath"]="Ninja Combat (NGH-009)"
["ncommand"]="Ninja Commando"
["neobombe"]="Neo Bomberman"
["neocup98"]="Neo-Geo Cup 98: The Road to the Victory"
["neodrift"]="Neo Drift Out: New Technology"
["neofight"]="Neo Fight"
["neomrdo"]="Neo Mr. Do!"
["neothund"]="Neo Thunder"
["neotris"]="NeoTRIS (free beta version)"
["ninjamas"]="Ninja Master's"
["nitd"]="Nightmare in the Dark"
["nitdbl"]="Nightmare in the Dark (bootleg)"
["nsmb"]="New Super Mario Bros."
["overtop"]="OverTop"
["panicbom"]="Panic Bomber"
["pbbblenb"]="Puzzle Bobble (bootleg)"
["pbobbl2n"]="Puzzle Bobble 2"
["pbobblen"]="Puzzle Bobble"
["pbobblenb"]="Puzzle Bobble (bootleg)"
["pgoal"]="Pleasure Goal"
["pnyaa"]="Pochi and Nyaa"
["popbounc"]="Pop 'n Bounce"
["preisle2"]="Prehistoric Isle 2"
["pspikes2"]="Power Spikes II"
["pulstar"]="Pulstar"
["puzzldpr"]="Puzzle De Pon! R!"
["puzzledp"]="Puzzle De Pon!"
["quizdai2"]="Quiz Meitantei Neo & Geo: Quiz Daisousa Sen part 2"
["quizdais"]="Quiz Daisousa Sen: The Last Count Down"
["quizdask"]="Quiz Salibtamjeong: The Last Count Down (Korean localized Quiz Daisousa Sen)"
["quizkof"]="Quiz King of Fighters"
["quizkofk"]="Quiz King of Fighters (Korean release)"
["ragnagrd"]="Ragnagard"
["rbff1"]="Real Bout Fatal Fury"
["rbff1a"]="Real Bout Fatal Fury (bug fix revision)"
["rbff2"]="Real Bout Fatal Fury 2: The Newcomers"
["rbff2h"]="Real Bout Fatal Fury 2: The Newcomers (NGH-2400)"
["rbff2k"]="Real Bout Fatal Fury 2: The Newcomers (Korean release)"
["rbffspck"]="Real Bout Fatal Fury Special (Korean release)"
["rbffspec"]="Real Bout Fatal Fury Special"
["rbffspeck"]="Real Bout Fatal Fury Special (Korean release)"
["ridhero"]="Riding Hero"
["ridheroh"]="Riding Hero (set 2)"
["roboarma"]="Robo Army (NGM-032 ~ NGH-032)"
["roboarmy"]="Robo Army"
["roboarmya"]="Robo Army (NGM-032 ~ NGH-032)"
["rotd"]="Rage of the Dragons"
["rotdh"]="Rage of the Dragons (NGH-2640?)"
["s1945p"]="Strikers 1945 Plus"
["samsh5fe"]="Samurai Shodown V Special Final Edition"
["samsh5pf"]="Samurai Shodown V Perfect"
["samsh5sp"]="Samurai Shodown V Special"
["samsh5sph"]="Samurai Shodown V Special (2nd release, less censored)"
["samsh5spho"]="Samurai Shodown V Special (1st release, censored)"
["samsho"]="Samurai Shodown"
["samsho2"]="Samurai Shodown II"
["samsho2k"]="Saulabi Spirits (Korean release of Samurai Shodown II)"
["samsho2ka"]="Saulabi Spirits (Korean release of Samurai Shodown II, set 2)"
["samsho3"]="Samurai Shodown III"
["samsho3h"]="Samurai Shodown III (NGH-087)"
["samsho4"]="Samurai Shodown IV: Amakusa's Revenge"
["samsho4k"]="Pae Wang Jeon Seol: Legend of a Warrior"
["samsho5"]="Samurai Shodown V"
["samsho5b"]="Samurai Shodown V (bootleg)"
["samsho5h"]="Samurai Shodown V (NGH-2700)"
["samsho5x"]="Samurai Shodown V (XBOX version hack)"
["samshoh"]="Samurai Shodown (NGH-045)"
["savagere"]="Savage Reign"
["sbp"]="Super Bubble Pop"
["scbrawlh"]="Soccer Brawl (NGH-031)"
["sdodgeb"]="Super Dodge Ball"
["sengoku"]="Sengoku"
["sengoku2"]="Sengoku 2"
["sengoku3"]="Sengoku 3"
["sengokuh"]="Sengoku (NGH-017, US)"
["shcktroa"]="Shock Troopers (set 2)"
["shocktr2"]="Shock Troopers: 2nd Squad"
["shocktro"]="Shock Troopers"
["shocktroa"]="Shock Troopers (set 2)"
["smbng"]="New Super Mario Bros. Demo"
["smsh5sph"]="Samurai Shodown V Special (2nd release, less censored)"
["smsh5spo"]="Samurai Shodown V Special (1st release, censored)"
["smsho2k2"]="Saulabi Spirits (Korean release of Samurai Shodown II, set 2)"
["socbrawl"]="Soccer Brawl"
["socbrawlh"]="Soccer Brawl (NGH-031)"
["sonicwi2"]="Aero Fighters 2"
["sonicwi3"]="Aero Fighters 3"
["spinmast"]="Spinmaster"
["ssideki"]="Super Sidekicks"
["ssideki2"]="Super Sidekicks 2: The World Championship"
["ssideki3"]="Super Sidekicks 3: The Next Glory"
["ssideki4"]="The Ultimate 11: The SNK Football Championship"
["stakwin"]="Stakes Winner"
["stakwin2"]="Stakes Winner 2"
["strhoop"]="Street Hoop / Street Slam"
["superspy"]="The Super Spy"
["svc"]="SNK vs. Capcom: SVC Chaos"
["svccpru"]="SNK vs. Capcom Remix Ultra"
["svcplus"]="SNK vs. Capcom Plus (bootleg)"
["svcsplus"]="SNK vs. Capcom Super Plus (bootleg)"
["teot"]="The Eye of Typhoon: Tsunami Edition"
["tetrismn"]="Tetris"
["tophuntr"]="Top Hunter: Roddy & Cathy"
["tophuntrh"]="Top Hunter: Roddy & Cathy (NGH-046)"
["totc"]="Treasure of the Caribbean"
["tpgolf"]="Top Player's Golf"
["tphuntrh"]="Top Hunter: Roddy & Cathy (NGH-046)"
["trally"]="Thrash Rally"
["turfmast"]="Neo Turf Masters"
["twinspri"]="Twinkle Star Sprites"
["tws96"]="Tecmo World Soccer '96"
["twsoc96"]="Tecmo World Soccer '96"
["viewpoin"]="Viewpoint"
["wakuwak7"]="Waku Waku 7"
["wh1"]="World Heroes"
["wh1h"]="World Heroes (ALH-005)"
["wh1ha"]="World Heroes (set 3)"
["wh2"]="World Heroes 2"
["wh2j"]="World Heroes 2 Jet"
["whp"]="World Heroes Perfect"
["wjammers"]="Windjammers"
["wjammss"]="Windjammers Supersonic"
["xenocrisis"]="Xeno Crisis"
["zedblade"]="Zed Blade"
["zintrckb"]="ZinTricK"
["zintrkcd"]="ZinTricK (CD conversion)"
["zupapa"]="Zupapa!"
)
declare -glA SV_TVC=(
["gb"]="gb\|game boy"
["gbc"]="gb\|game boy"
["genesis"]="genesis"
["megacd"]="megacd"
["nes"]="^nes-\| nes"
["snes"]="snes"
["n64"]="n64-\|n64"
["atari2600"]="atari vcs"
["atari5200"]="atari 5200"
["atari7800"]="atari 7800"
["atarilynx"]="atari lynx"
["saturn"]="sega saturn"
["s32x"]="sega 32x"
["sgb"]="super game boy\|gb-super game boy\|snes-super game boy"
["tgfx16cd"]="turboduo"
["tgfx16"]="turboduo\|turbografx-16"
["gg"]="sega game"
["sms"]="sega master"
["psx"]="psx\|playstation"
["arcade"]="arcade"
)
}
# ========= SOUCRCE INI & UPDATE =========
# Read INI
function read_samini() {
if [ ! -f "${samini_file}" ]; then
echo "Error: MiSTer_SAM.ini not found. Attempting to update now..."
get_samstuff MiSTer_SAM.ini /media/fat/Scripts
if [ $? -ne 0 ]; then
echo "Error: Please try again or update MiSTer_SAM.ini manually."
exit 1
fi
fi
source "${samini_file}"
# Remove trailing slash from paths
grep "^[^#;]" < "${samini_file}" | grep "pathfilter=" | cut -f1 -d"=" | while IFS= read -r var; do
declare -g "${var}"="${!var%/}"
done
#corelist=("$(echo "${corelist[@]}" | tr ',' ' ' | tr -s ' ')")
IFS=',' read -ra corelist <<< "${corelist}"
IFS=',' read -ra corelistall <<< "${corelistall}"
#BGM mode
if [ "${bgm}" == "yes" ]; then
unmute
mute="core"
fi
#Roulette Mode
if [ -f /tmp/.SAM_tmp/gameroulette.ini ]; then
source /tmp/.SAM_tmp/gameroulette.ini
fi
#GOAT Mode
if [ "$sam_goat_list" == "yes" ]; then
sam_goat_mode
fi
#NES M82 Mode
if [ "$m82" == "yes" ]; then
[ ! -d "/tmp/.SAM_List" ] && mkdir /tmp/.SAM_List/
[ ! -d "/tmp/.SAM_tmp" ] && mkdir /tmp/.SAM_tmp/
if [ ! -f "${gamelistpath}"/nes_gamelist.txt ]; then
samdebug "Creating NES gamelist"
${mrsampath}/samindex -q -s "nes" -o "${gamelistpath}"
if [ $? -gt 1 ]; then
echo "Error: NES gamelist missing. Make sure you have NES games."
fi
fi
if [ -f "${gamelistpathtmp}"/nes_gamelist.txt ]; then
rm "${gamelistpathtmp}"/nes_gamelist.txt
fi
local m82_list_path="${gamelistpath}"/m82_list.txt
# Check if the M82 list file exists
if [ ! -f "$m82_list_path" ]; then
echo "Error: The M82 list file ($m82_list_path) does not exist. Updating SAM now. Please try again."
repository_url="https://github.com/mrchrisster/MiSTer_SAM"
get_samstuff .MiSTer_SAM/SAM_Gamelists/m82_list.txt "${gamelistpath}"
fi
printf "%s\n" nes > "${corelistfile}"
if [[ "$m82_muted" == "yes" ]]; then
mute="global"
fi
gametimer="21"
listenjoy=no
fi
}
function update_samini() {
[ ! -f /media/fat/Scripts/.config/downloader/downloader.log ] && return
[ ! -f ${samini_file} ] && return
if [[ "$(cat /media/fat/Scripts/.config/downloader/downloader.log | grep -c "MiSTer_SAM.default.ini")" != "0" ]] && [ "${samini_update_file}" -nt "${samini_file}" ]; then
echo "New MiSTer_SAM.ini version downloaded from update_all. Merging with new ini."