-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathprepare.ps1
1201 lines (1089 loc) · 39.1 KB
/
prepare.ps1
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
function DownloadFiles {
param ([String]$jsonDownloadOption)
Write-Host "Starting downloading of $jsonDownloadOption"
Get-Content "$scriptDir\download_list.json" | ConvertFrom-Json | Select-Object -expand $jsonDownloadOption | ForEach-Object {
$url = $_.url
$file = $_.file
$output = "$requirementsFolder\$file"
if(![System.IO.File]::Exists($output)){
Write-Host "INFO: Downloading $file"
if($PSVersionTable.PSEdition -eq "Core"){
Invoke-WebRequest $url -Out $output -SkipCertificateCheck
} else {
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
Invoke-WebRequest $url -Out $output
}
Write-Host "INFO: Finished Downloading $file successfully to: $output"
Write-Host "INFO: Size of the downloaded file is $((Get-Item $output).Length / 1MB) MB"
} else {
Write-Host $file "INFO: Already exists...Skipping download."
}
}
}
function GithubReleaseFiles {
Get-Content "$scriptDir\download_list.json" | ConvertFrom-Json | Select-Object -expand releases | ForEach-Object {
$repo = $_.repo
$file = $_.file
$releases = "https://api.github.com/repos/$repo/releases"
$tag = (Invoke-WebRequest $releases -usebasicparsing| ConvertFrom-Json)[0].tag_name
$url = "https://github.com/$repo/releases/download/$tag/$file"
$output = "$requirementsFolder\$file"
if(![System.IO.File]::Exists($output)) {
Write-Host "INFO: Downloading $file"
Invoke-WebRequest $url -Out $output
Write-Host "INFO: Finished Downloading $file successfully to: $output"
Write-Host "INFO: Size of the downloaded file is $((Get-Item $output).Length / 1MB) MB"
} else {
Write-Host $file "INFO: Already exists...Skipping download."
}
}
}
function Expand-Archive([string]$Path, [string]$Destination, [bool]$VerboseLogging = $false) {
$7z_Application = "C:\Program Files\7-Zip\7z.exe"
$7z_Arguments = @(
'x', # eXtract files with full paths
'-y', # assume Yes on all queries
"`"-o$($Destination)`"", # set Output directory
"`"$($Path)`"" # <archive_name>
)
Write-Output "Extracting file: $Path to destination: $Destination"
if ($VerboseLogging) {
& $7z_Application $7z_Arguments
if ($LASTEXITCODE -ne 0) {
throw "7-Zip exited with code $LASTEXITCODE"
}
} else {
& $7z_Application $7z_Arguments | Out-Null
}
}
# Get script path
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
Write-Host "INFO: Script directory is: $scriptDir"
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install git -y | Out-Null
# Install and setup scoop
if($env:path -match "scoop"){
Write-Host "INFO: Scoop appears to be installed, skipping installation"
} else {
Write-Host "INFO: Scoop not detected, installing scoop"
iwr -useb get.scoop.sh -outfile 'installScoop.ps1'
.\installScoop.ps1 -RunAsAdmin
}
Write-Host "INFO: Running Scoop Bucket Workaround"
# https://github.com/ScoopInstaller/Scoop/issues/4917#issuecomment-1125400640
scoop bucket rm main
scoop bucket add main
Write-Host "INFO: Adding scoop bucket"
scoop bucket add emulators https://github.com/borger/scoop-emulators.git
Write-Host "INFO: Installing Citra"
scoop install citra
scoop install ppsspp-dev
scoop install yuzu
scoop install rpcs3
$citraInstallDir = "$env:userprofile\scoop\apps\citra\current"
$ppssppInstallDir = "$env:userprofile\scoop\apps\ppsspp\current"
$yuzuInstallDir = "$env:userprofile\scoop\apps\yuzu\current"
$rpcs3InstallDir = "$env:userprofile\scoop\apps\rpcs3\current"
choco install 7zip --no-progress -y | Out-Null
choco install dolphin --pre --no-progress -y | Out-Null
choco install cemu --no-progress -y | Out-Null
# Acquire files
$requirementsFolder = "$PSScriptRoot\requirements"
New-Item -ItemType Directory -Force -Path $requirementsFolder
DownloadFiles("downloads")
DownloadFiles("other_downloads")
GithubReleaseFiles
# Install Emulation Station
Write-Host "INFO: Starting Emulation station to generate config"
Start-Process "$requirementsFolder\emulationstation_win32_latest.exe" -ArgumentList "/S" -Wait
# Generate Emulation Station config file
& "${env:ProgramFiles(x86)}\EmulationStation\emulationstation.exe"
while (!(Test-Path "$env:userprofile\.emulationstation\es_systems.cfg")) {
Write-Host "INFO: Checking for config file..."
Start-Sleep 10
}
Write-Host "INFO: Config file generated"
Stop-Process -Name "emulationstation"
#####
# Retroarch
#####
# Prepare Retroarch
$retroArchPath = "$env:userprofile\.emulationstation\systems\retroarch\"
$coresPath = "$retroArchPath\cores"
$retroArchBinary = "$requirementsFolder\RetroArch.7z"
if(Test-Path $retroArchBinary){
New-Item -ItemType Directory -Force -Path $retroArchPath
Expand-Archive -Path $retroArchBinary -Destination $requirementsFolder -VerboseLogging $true
# TO-DO - add an Out-Null when this has been tested
Copy-Item -Path RetroArch-Win64\* -Destination $retroArchPath -recurse -Force
# New path - $retroArchPath\RetroArch-Win64
} else {
Write-Host "ERROR: $retroArchBinary not found."
exit -1
}
# NES Setup
$nesCore = "$requirementsFolder\fceumm_libretro.dll.zip"
if(Test-Path $nesCore){
Expand-Archive -Path $nesCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $nesCore not found."
exit -1
}
# N64 Setup
$n64Core = "$requirementsFolder\parallel_n64_libretro.dll.zip"
if(Test-Path $n64Core){
Expand-Archive -Path $n64Core -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $n64Core not found."
exit -1
}
# FBA Setup
$fbaCore = "$requirementsFolder\fbalpha2012_libretro.dll.zip"
if(Test-Path $fbaCore){
Expand-Archive -Path $fbaCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $fbaCore not found."
exit -1
}
# GBA Setup
$gbaCore = "$requirementsFolder\vba_next_libretro.dll.zip"
if(Test-Path $gbaCore){
Expand-Archive -Path $gbaCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $gbaCore not found."
exit -1
}
# SNES Setup
$snesCore = "$requirementsFolder\snes9x_libretro.dll.zip"
if(Test-Path $snesCore){
Expand-Archive -Path $snesCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $snesCore not found."
exit -1
}
# Genesis GX Setup
$mdCore = "$requirementsFolder\genesis_plus_gx_libretro.dll.zip"
if(Test-Path $mdCore){
Expand-Archive -Path $mdCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $mdCore not found."
exit -1
}
# Game boy Colour Setup
$gbcCore = "$requirementsFolder\gambatte_libretro.dll.zip"
if(Test-Path $gbcCore){
Expand-Archive -Path $gbcCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $gbcCore not found."
exit -1
}
# Atari2600 Setup
$atari2600Core = "$requirementsFolder\stella_libretro.dll.zip"
if(Test-Path $atari2600Core){
Expand-Archive -Path $atari2600Core -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $atari2600Core not found."
exit -1
}
# MAME Setup
$mameCore = "$requirementsFolder\mame2010_libretro.dll.zip"
if(Test-Path $mameCore){
Expand-Archive -Path $mameCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $mameCore not found."
exit -1
}
# PSX Setup
$psxEmulator = "$requirementsFolder\ePSXe205.zip"
if(Test-Path $psxEmulator){
$psxEmulatorPath = "$env:userprofile\.emulationstation\systems\epsxe\"
$psxBiosPath = $psxEmulatorPath + "bios\"
New-Item -ItemType Directory -Force -Path $psxEmulatorPath | Out-Null
Expand-Archive -Path $psxEmulator -Destination $psxEmulatorPath | Out-Null
} else {
Write-Host "ERROR: $psxEmulator not found."
exit -1
}
# PS2 Setup
$ps2EmulatorMsi = "$requirementsFolder\pcsx2-1.6.0-setup.exe"
if(Test-Path $ps2EmulatorMsi){
$ps2EmulatorPath = "$env:userprofile\.emulationstation\systems\pcsx2\"
$ps2Binary = "$ps2EmulatorPath\`$TEMP\PCSX2 1.6.0\pcsx2.exe"
$ps2BiosPath = "$ps2EmulatorPath\bios\"
Expand-Archive -Path $ps2EmulatorMsi -Destination $ps2EmulatorPath | Out-Null
New-Item -ItemType Directory -Force -Path $ps2BiosPath | Out-Null
} else {
Write-Host "ERROR: $ps2EmulatorMsi not found."
exit -1
}
# NeoGeo Pocket Setup
$ngpCore = "$requirementsFolder\race_libretro.dll.zip"
if(Test-Path $ngpCore){
Expand-Archive -Path $ngpCore -Destination $coresPath | Out-Null
} else {
Write-Host "ERROR: $ngpCore not found."
exit -1
}
# Start Retroarch and generate a config.
$retroarchExecutable = "$retroArchPath\retroarch.exe"
$retroarchConfigPath = "$retroArchPath\retroarch.cfg"
if (Test-Path $retroarchExecutable) {
Write-Host "INFO: Retroarch executable found, launching"
Start-Process $retroarchExecutable
while (!(Test-Path $retroarchConfigPath)) {
Write-Host "INFO: Checking for retroarch config file"
Start-Sleep 5
}
$retroarchProcess = Get-Process retroarch.exe -ErrorAction SilentlyContinue
if ($retroarchProcess) {
$retroarchProcess.CloseMainWindow()
Start-sleep 5
if (!$retroarchProcess.HasExited) {
$retroarchProcess | Stop-Process -Force
}
}
Stop-Process -Name "retroarch" -ErrorAction SilentlyContinue
} else {
Write-Host "ERROR: Could not find retroarch.exe"
exit -1
}
# Tweak retroarch config!
Write-Host "INFO: Replacing retroarch config"
$settingToFind = 'video_fullscreen = "false"'
$settingToSet = 'video_fullscreen = "true"'
(Get-Content $retroarchConfigPath) -replace $settingToFind, $settingToSet | Set-Content $retroarchConfigPath
$settingToFind = 'savestate_auto_load = "false"'
$settingToSet = 'savestate_auto_load = "true"'
(Get-Content $retroarchConfigPath) -replace $settingToFind, $settingToSet | Set-Content $retroarchConfigPath
$settingToFind = 'input_player1_analog_dpad_mode = "0"'
$settingToSet = 'input_player1_analog_dpad_mode = "1"'
(Get-Content $retroarchConfigPath) -replace $settingToFind, $settingToSet | Set-Content $retroarchConfigPath
$settingToFind = 'input_player2_analog_dpad_mode = "0"'
$settingToSet = 'input_player2_analog_dpad_mode = "1"'
(Get-Content $retroarchConfigPath) -replace $settingToFind, $settingToSet | Set-Content $retroarchConfigPath
# Add roms
$romPath = "$env:userprofile\.emulationstation\roms"
New-Item -ItemType Directory -Force -Path $romPath | Out-Null
# Path creation + Open-Source / Freeware Rom population
Write-Host "INFO: Setup NES"
$nesPath = "$romPath\nes"
$nesRom = "$requirementsFolder\assimilate_full.zip"
if(Test-Path $nesRom){
New-Item -ItemType Directory -Force -Path $nesPath | Out-Null
Expand-Archive -Path $nesRom -Destination $nesPath | Out-Null
} else {
Write-Host "ERROR: $nesRom not found."
exit -1
}
Write-Host "INFO: Setup N64"
$n64Path = "$romPath\n64"
$n64Rom = "$requirementsFolder\pom-twin.zip"
if(Test-Path $n64Rom){
New-Item -ItemType Directory -Force -Path $n64Path | Out-Null
Expand-Archive -Path $n64Rom -Destination $n64Path | Out-Null
} else {
Write-Host "ERROR: $n64Rom not found."
exit -1
}
Write-Host "INFO: Setup psp"
$pspPath = "$romPath\psp"
$pspRom = "$requirementsFolder\cube.elf"
if (Test-Path $pspRom) {
New-Item -ItemType Directory -Force -Path $pspPath | Out-Null
Move-Item -Path $pspRom -Destination $pspPath -Force | Out-Null
}
else {
Write-Host "ERROR: $pspRom not found."
exit -1
}
Write-Host "INFO: Setup Nintendo Switch"
$switchPath = "$romPath\switch"
$switchRom = "$requirementsFolder\tetriswitch.nro"
if (Test-Path $switchRom) {
New-Item -ItemType Directory -Force -Path $switchPath | Out-Null
Move-Item -Path $switchRom -Destination $switchPath -Force | Out-Null
}
else {
Write-Host "ERROR: $switchRom not found."
exit -1
}
Write-Host "INFO: Setup PS3"
$ps3Path = "$romPath\ps3"
$ps3Rom = "$requirementsFolder\Avoidance_v1.3.pkg"
if (Test-Path $ps3Rom) {
New-Item -ItemType Directory -Force -Path $ps3Path | Out-Null
Move-Item -Path $ps3Rom -Destination $ps3Path | Out-Null
}
else {
Write-Host "ERROR: $ps3Rom not found."
exit -1
}
Write-Host "INFO: Setup PS Vita"
$vitaPath = "$romPath\vita"
$vitaRom = "$requirementsFolder\C4.vpk"
if (Test-Path $vitaRom) {
New-Item -ItemType Directory -Force -Path $vitaPath | Out-Null
Move-Item -Path $vitaRom -Destination $vitaPath -Force | Out-Null
}
else {
Write-Host "ERROR: $vitaRom not found."
exit -1
}
Write-Host "INFO: Setup Vita3k"
$vita3kInstallFolder = "${env:ProgramFiles}\Vita3k"
if(-not(Test-Path $vita3kInstallFolder)){
New-Item -ItemType Directory -Force -Path $vita3kInstallFolder | Out-Null
}
$vita3kLatestBuild = "$requirementsFolder\windows-latest.zip"
if(Test-Path $vita3kLatestBuild){
Expand-Archive -Path $vita3kLatestBuild -Destination $vita3kInstallFolder -force | Out-Null
} else {
Write-Host "ERROR: $vita3kLatestBuild not found."
exit -1
}
Write-Host "INFO: Setup 3DS"
$3dsPath = "$romPath\3ds"
$3dsRom = "$requirementsFolder\ccleste.3dsx"
if (Test-Path $3dsRom) {
New-Item -ItemType Directory -Force -Path $3dsPath | Out-Null
Move-Item -Path $3dsRom -Destination $3dsPath -Force | Out-Null
}
else {
Write-Host "ERROR: $3dsRom not found."
exit -1
}
Write-Host "INFO: Setup GBA"
$gbaPath = "$romPath\gba"
$gbaRom = "$requirementsFolder\uranus0ev_fix.gba"
if(Test-Path $gbaRom){
New-Item -ItemType Directory -Force -Path $gbaPath | Out-Null
Copy-Item -Path $gbaRom -Destination $gbaPath | Out-Null
} else {
Write-Host "ERROR: $gbaRom not found."
exit -1
}
Write-Host "INFO: Setup Megadrive"
$mdPath = "$romPath\megadrive"
$mdRom = "$requirementsFolder\rickdangerous.gen"
if(Test-Path $mdRom){
New-Item -ItemType Directory -Force -Path $mdPath | Out-Null
Copy-Item -Path $mdRom -Destination $mdPath | Out-Null
} else {
Write-Host "ERROR: $mdRom not found."
exit -1
}
Write-Host "INFO: Setup SNES"
$snesPath = "$romPath\snes"
$snesRom = "$requirementsFolder\N-Warp Daisakusen V1.1.smc"
if(Test-Path $snesRom){
New-Item -ItemType Directory -Force -Path $snesPath | Out-Null
Copy-Item -Path $snesRom -Destination $snesPath | Out-Null
} else {
Write-Host "ERROR: $snesRom not found."
exit -1
}
Write-Host "INFO: Setup PSX"
$psxPath = "$romPath\psx"
$psxRom = "$requirementsFolder\Marilyn_In_the_Magic_World_(010a).7z"
if(Test-Path $psxRom){
New-Item -ItemType Directory -Force -Path $psxPath | Out-Null
Expand-Archive -Path $psxRom -Destination $psxPath | Out-Null
} else {
Write-Host "ERROR: $psxRom not found."
exit -1
}
# Write-Host "INFO: Setup PS2"
# $ps2Path = "$romPath\ps2"
# $ps2Rom = "$requirementsFolder\hermes-v.latest-ps2.zip"
# if(Test-Path $ps2Rom){
# New-Item -ItemType Directory -Force -Path $ps2Path | Out-Null
# Expand-Archive -Path $ps2Rom -Destination $ps2Path | Out-Null
# } else {
# Write-Host "ERROR: $ps2Rom not found."
# exit -1
# }
Write-Host "INFO: Setup Gameboy"
$gbPath = "$romPath\gb"
New-Item -ItemType Directory -Force -Path $gbPath | Out-Null
Write-Host "INFO: Setup Gameboy Colour"
$gbcPath = "$romPath\gbc"
$gbcRom = "$requirementsFolder\star_heritage.zip"
if(Test-Path $gbcRom){
New-Item -ItemType Directory -Force -Path $gbcPath | Out-Null
Expand-Archive -Path $gbcRom -Destination $gbcPath | Out-Null
} else {
Write-Host "ERROR: $gbcRom not found."
exit -1
}
Write-Host "INFO: Setup Mastersystem"
$masterSystemPath = "$romPath\mastersystem"
$masterSystemRom = "$requirementsFolder\WahMunchers-SMS-R2.zip"
if(Test-Path $masterSystemRom){
New-Item -ItemType Directory -Force -Path $masterSystemPath | Out-Null
Expand-Archive -Path $masterSystemRom -Destination $masterSystemPath | Out-Null
} else {
Write-Host "ERROR: $masterSystemRom not found."
exit -1
}
Write-Host "INFO: Setup FBA"
$fbaPath = "$romPath\fba"
New-Item -ItemType Directory -Force -Path $fbaPath | Out-Null
Write-Host "INFO: Atari2600 Setup"
$atari2600Path = "$romPath\atari2600"
$atari2600Rom = "$requirementsFolder\ramless_pong.bin"
if(Test-Path $atari2600Rom){
New-Item -ItemType Directory -Force -Path $atari2600Path | Out-Null
Copy-Item -Path $atari2600Rom -Destination $atari2600Path | Out-Null
} else {
Write-Host "ERROR: $atari2600Rom not found."
exit -1
}
Write-Host "INFO: MAME setup"
$mamePath = "$romPath\mame"
New-Item -ItemType Directory -Force -Path $mamePath | Out-Null
# WIP: Need to test and find freeware games for these emulators.
# Need to write a bat to boot these
Write-Host "INFO: ScummVm Setup"
$scummVmPath = "$romPath\scummvm"
New-Item -ItemType Directory -Force -Path $scummVmPath | Out-Null
$wiiuPath = "$romPath\wiiu"
New-Item -ItemType Directory -Force -Path $wiiuPath | Out-Null
Write-Host "INFO: NeogeoPocket Setup"
$neogeoPocketPath = "$romPath\ngp"
$ngpRom = "$requirementsFolder\neopocket.zip"
if(Test-Path $ngpRom){
New-Item -ItemType Directory -Force -Path $neogeoPocketPath | Out-Null
Expand-Archive -Path $ngpRom -Destination $neogeoPocketPath | Out-Null
} else {
Write-Host "ERROR: $ngpRom not found."
exit -1
}
Write-Host "INFO: Neogeo Setup"
$neogeoPath = "$romPath\neogeo"
New-Item -ItemType Directory -Force -Path $neogeoPath | Out-Null
Write-Host "INFO: MSX Setup"
$msxPath = "$romPath\msx"
$msxCore = "$requirementsFolder\fmsx_libretro.dll.zip"
if(Test-Path $msxCore){
Expand-Archive -Path $msxCore -Destination $coresPath | Out-Null
New-Item -ItemType Directory -Force -Path $msxPath | Out-Null
} else {
Write-Host "ERROR: $msxCore not found."
exit -1
}
Write-Host "INFO: Commodore 64 Setup"
$commodore64Path = "$romPath\c64"
$commodore64Core = "$requirementsFolder\vice_x64_libretro.dll.zip"
if(Test-Path $commodore64Core){
Expand-Archive -Path $commodore64Core -Destination $coresPath | Out-Null
New-Item -ItemType Directory -Force -Path $commodore64Path | Out-Null
} else {
Write-Host "ERROR: $commodore64Core not found."
exit -1
}
Write-Host "INFO: Amiga Setup"
$amigaPath = "$romPath\amiga"
$amigaCore = "$requirementsFolder\puae_libretro.dll.zip"
if(Test-Path $amigaCore){
Expand-Archive -Path $amigaCore -Destination $coresPath | Out-Null
New-Item -ItemType Directory -Force -Path $amigaPath | Out-Null
} else {
Write-Host "ERROR: $amigaCore not found."
exit -1
}
Write-Host "INFO: Setup Atari7800"
$atari7800Path = "$romPath\atari7800"
$atari7800Core = "$requirementsFolder\prosystem_libretro.dll.zip"
if(Test-Path $atari7800Core){
Expand-Archive -Path $atari7800Core -Destination $coresPath | Out-Null
New-Item -ItemType Directory -Force -Path $atari7800Path | Out-Null
} else {
Write-Host "ERROR: $atari7800Core not found."
exit -1
}
Write-Host "INFO: Setup Wii/Gaemcube"
$gcPath = "$romPath\gc"
$wiiPath = "$romPath\wii"
$wiiRom = "$requirementsFolder\Homebrew.Channel.-.OHBC.wad"
New-Item -ItemType Directory -Force -Path $gcPath | Out-Null
New-Item -ItemType Directory -Force -Path $wiiPath | Out-Null
if(Test-Path $wiiRom){
Copy-Item $wiiRom $wiiPath | Out-Null
} else{
Write-Host "ERROR: $wiiRom not found."
exit -1
}
Write-Host "INFO: Setting up Emulation Station Config"
$esConfigFile = "$env:userprofile\.emulationstation\es_systems.cfg"
# TO-DO
# Vita Launching is a BIT hacky, works in powershell
# .\Vita3K.exe --vpk-path "%ROM% | .\Vita3K.exe
<#
----------------------------------
File extension supported by systems
----------------------------------
Sources for getting compatible file extension:
Vita3K: https://vita3k.org/faq.html
Yuzu: https://yuzu-emu.org/wiki/overview-of-switch-game-formats/
RPCS3: NOT FOUND
PPSSPP: https://www.ppsspp.org/faq.html
Citra: https://community.citra-emu.org/t/3ds-vs-cci-rom-file-formats/191/4
FCEUmm: https://docs.libretro.com/library/fceumm/
Snes9x: https://docs.libretro.com/library/snes9x/
ParaLLEl_n64: https://wiki.recalbox.com/en/emulators/consoles/nintendo-64/libretro-parallel_n64
Dolphine: https://wiki.dolphin-emu.org/index.php?title=Installing_Dolphin#Post-Installation_Quick_Guide
Gambatte: https://docs.libretro.com/library/gambatte/
VBA Next: https://docs.libretro.com/library/vba_next/
ePSXe: https://fantasyanime.com/emuhelp/epsxe#dumping-your-psx-games-to-iso (NOT OFFICIAL)
PCSX2: https://fantasyanime.com/emuhelp/pcsx2#loading-a-ps2-iso (NOT OFFICIAL)
#>
$newConfig = "<systemList>
<system>
<name>vita</name>
<fullname>Vita</fullname>
<path>$vitaPath</path>
<extension>.vpk .VPK</extension>
<command>C:\Program Files\Vita3k\Vita3K.exe --vpk-path %ROM%</command>
<platform>vita</platform>
<theme>vita</theme>
</system>
<system>
<name>switch</name>
<fullname>Switch</fullname>
<path>$switchPath</path>
<extension>.nsp .NSP .zip .ZIP .7z .nso .NSO .nro .NRO .nca .NCA .xci .XCI</extension>
<command>$yuzuInstallDir\yuzu.exe %ROM%</command>
<platform>switch</platform>
<theme>switch</theme>
</system>
<system>
<name>ps3</name>
<fullname>PS3</fullname>
<path>$ps3Path</path>
<extension>.iso .ISO .zip .ZIP .7z .pkg .PKG</extension>
<command>$rpcs3InstallDir\rpcs3.exe %ROM%</command>
<platform>ps3</platform>
<theme>ps3</theme>
</system>
<system>
<name>psp</name>
<fullname>Playstation Portable</fullname>
<path>$pspPath</path>
<extension>.iso .ISO .cso .CSO .elf .ELF .pbp .PBP</extension>
<command>$ppssppInstallDir\PPSSPPWindows.exe %ROM%</command>
<platform>psp</platform>
<theme>psp</theme>
</system>
<system>
<name>n3ds</name>
<fullname>Nintendo 3DS</fullname>
<path>$3dsPath</path>
<extension>.3ds .3DS .3dsx .3DSX .cci .CCI .cxi .CXI .elf .ELF</extension>
<command>$citraInstallDir\citra.exe %ROM%</command>
<platform>n3ds</platform>
<theme>3ds</theme>
</system>
<system>
<name>nes</name>
<fullname>Nintendo Entertainment System</fullname>
<path>$nesPath</path>
<extension>.nes .NES .fds .FDS .unif .UNIF .unf .UNF</extension>
<command>$retroarchExecutable -L $coresPath\fceumm_libretro.dll %ROM%</command>
<platform>nes</platform>
<theme>nes</theme>
</system>
<system>
<fullname>Super Nintendo</fullname>
<name>snes</name>
<path>$snesPath</path>
<extension>.smc .SMC .sfc .SFC .fig .FIG .swc .SWC .bs .BS .st .ST</extension>
<command>$retroarchExecutable -L $coresPath\snes9x_libretro.dll %ROM%</command>
<platform>snes</platform>
<theme>snes</theme>
</system>
<system>
<fullname>Nintendo 64</fullname>
<name>n64</name>
<path>$n64Path</path>
<extension>.z64 .Z64 .n64 .N64 .v64 .V64 .zip .ZIP .7z .7Z</extension>
<command>$retroarchExecutable -L $coresPath\parallel_n64_libretro.dll %ROM%</command>
<platform>n64</platform>
<theme>n64</theme>
</system>
<system>
<fullname>Gamecube</fullname>
<name>gc</name>
<path>$gcPath</path>
<extension>.iso .ISO .gxm .GCM .gcz .GCZ .rvz .RVZ .dol .DOL .elf .ELF</extension>
<command>C:\tools\Dolphin-Beta\Dolphin.exe -e `"%ROM_RAW%`"</command>
<platform>gc</platform>
<theme>gc</theme>
</system>
<system>
<name>wii</name>
<fullname>Nintendo Wii</fullname>
<path>$wiiPath</path>
<extension>.iso .ISO .wad .WAD .wbfs .WBFS .wia .WIA .dol .DOL .elf .ELF</extension>
<command>C:\tools\Dolphin-Beta\Dolphin.exe -e `"%ROM_RAW%`"</command>
<platform>wii</platform>
<theme>wii</theme>
</system>
<system>
<fullname>Game Boy</fullname>
<name>gb</name>
<path>$gbPath</path>
<extension>.gb .GB .dmg .DMG .zip .ZIP .7z .7Z</extension>
<command>$retroarchExecutable -L $coresPath\gambatte_libretro.dll %ROM%</command>
<platform>gb</platform>
<theme>gb</theme>
</system>
<system>
<fullname>Game Boy Color</fullname>
<name>gbc</name>
<path>$gbcPath</path>
<extension>.gbc .GBC .dmg .DMG .zip .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\gambatte_libretro.dll %ROM%</command>
<platform>gbc</platform>
<theme>gbc</theme>
</system>
<system>
<fullname>Game Boy Advance</fullname>
<name>gba</name>
<path>$gbaPath</path>
<extension>.gba .GBA</extension>
<command>$retroarchExecutable -L $coresPath\vba_next_libretro.dll %ROM%</command>
<platform>gba</platform>
<theme>gba</theme>
</system>
<system>
<fullname>Playstation</fullname>
<name>psx</name>
<path>$psxPath</path>
<extension>.cue .CUE .iso .ISO .pbp .PBP</extension>
<command>${psxEmulatorPath}ePSXe.exe -bios ${psxBiosPath}SCPH1001.BIN -nogui -loadbin %ROM%</command>
<platform>psx</platform>
<theme>psx</theme>
</system>
<system>
<fullname>Playstation 2</fullname>
<name>ps2</name>
<path>$ps2Path</path>
<extension>.iso .img .bin .mdf .z .z2 .bz2 .dump .cso .ima .gz</extension>
<command>${$ps2Binary} %ROM% --fullscreen --nogui</command>
<platform>ps2</platform>
<theme>ps2</theme>
</system>
<system>
<fullname>MAME</fullname>
<name>mame</name>
<path>$mamePath</path>
<extension>.zip .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\mame2010_libretro.dll %ROM%</command>
<platform>mame</platform>
<theme>mame</theme>
</system>
<system>
<fullname>Final Burn Alpha</fullname>
<name>fba</name>
<path>$fbaPath</path>
<extension>.zip .ZIP .fba .FBA</extension>
<command>$retroarchExecutable -L $coresPath\fbalpha2012_libretro.dll %ROM%</command>
<platform>arcade</platform>
<theme></theme>
</system>
<system>
<fullname>Amiga</fullname>
<name>amiga</name>
<path>$amigaPath</path>
<extension>.adf .ADF</extension>
<command>$retroarchExecutable -L $coresPath\puae_libretro.dll %ROM%</command>
<platform>amiga</platform>
<theme>amiga</theme>
</system>
<system>
<fullname>Atari 2600</fullname>
<name>atari2600</name>
<path>$atari2600Path</path>
<extension>.a26 .bin .rom .A26 .BIN .ROM</extension>
<command>$retroarchExecutable -L $coresPath\stella_libretro.dll %ROM%</command>
<platform>atari2600</platform>
<theme>atari2600</theme>
</system>
<system>
<fullname>Atari 7800 Prosystem</fullname>
<name>atari7800</name>
<path>$atari7800Path</path>
<extension>.a78 .bin .A78 .BIN</extension>
<command>$retroarchExecutable -L $coresPath\prosystem_libretro.dll %ROM%</command>
<platform>atari7800</platform>
<theme>atari7800</theme>
</system>
<system>
<fullname>Commodore 64</fullname>
<name>c64</name>
<path>$commodore64Path</path>
<extension>.crt .d64 .g64 .t64 .tap .x64 .zip .CRT .D64 .G64 .T64 .TAP .X64 .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\vice_x64_libretro.dll %ROM%</command>
<platform>c64</platform>
<theme>c64</theme>
</system>
<system>
<fullname>Sega Mega Drive / Genesis</fullname>
<name>megadrive</name>
<path>$mdPath</path>
<extension>.smd .SMD .bin .BIN .gen .GEN .md .MD .zip .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\genesis_plus_gx_libretro.dll %ROM%</command>
<platform>genesis,megadrive</platform>
<theme>megadrive</theme>
</system>
<system>
<fullname>Sega Master System</fullname>
<name>mastersystem</name>
<path>$masterSystemPath</path>
<extension>.bin .sms .zip .BIN .SMS .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\genesis_plus_gx_libretro.dll %ROM%</command>
<platform>mastersystem</platform>
<theme>mastersystem</theme>
</system>
<system>
<fullname>MSX</fullname>
<name>msx</name>
<path>$msxPath</path>
<extension>.col .dsk .mx1 .mx2 .rom .COL .DSK .MX1 .MX2 .ROM</extension>
<command>$retroarchExecutable -L $coresPath\fmsx_libretro.dll %ROM%</command>
<platform>msx</platform>
<theme>msx</theme>
</system>
<system>
<name>neogeo</name>
<fullname>Neo Geo</fullname>
<path>$neogeoPath</path>
<extension>.zip .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\fbalpha2012_libretro.dll %ROM%</command>
<platform>neogeo</platform>
<theme>neogeo</theme>
</system>
<system>
<fullname>Neo Geo Pocket</fullname>
<name>ngp</name>
<path>$neogeoPocketPath</path>
<extension>.ngp .ngc .zip .ZIP</extension>
<command>$retroarchExecutable -L $coresPath\race_libretro.dll %ROM%</command>
<platform>ngp</platform>
<theme>ngp</theme>
</system>
<system>
<fullname>ScummVM</fullname>
<name>scummvm</name>
<path>$scummVmPath</path>
<extension>.bat .BAT</extension>
<command>%ROM%</command>
<platform>pc</platform>
<theme>scummvm</theme>
</system>
<system>
<name>wiiu</name>
<fullname>Nintendo Wii U</fullname>
<path>$wiiuPath</path>
<extension>.rpx .RPX</extension>
<command>START /D C:\tools\cemu\ Cemu.exe -f -g `"%ROM_RAW%`"</command>
<platform>wiiu</platform>
<theme>wiiu</theme>
</system>
</systemList>
"
Set-Content $esConfigFile -Value $newConfig
Write-Host "INFO: Setting up Emulation Station theme recalbox-backport"
$themesPath = "$env:userprofile\.emulationstation\themes\recalbox-backport\"
$themesFile = "$requirementsFolder\recalbox-backport-v2.2.zip"
if(Test-Path $themesFile){
Expand-Archive -Path $themesFile -Destination $requirementsFolder -Force | Out-Null
$themesFolder = "$requirementsFolder\recalbox-backport\"
robocopy $themesFolder $themesPath /E /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
} else {
Write-Host "ERROR: $themesFile not found."
exit -1
}
Write-Host "INFO: Update EmulationStation binaries"
$emulationStationInstallFolder = "${env:ProgramFiles(x86)}\EmulationStation"
$updatedEmulationStatonBinaries = "$requirementsFolder\EmulationStation-Win32.zip"
if(Test-Path $updatedEmulationStatonBinaries){
Expand-Archive -Path $updatedEmulationStatonBinaries -Destination $emulationStationInstallFolder -Force | Out-Null
} else {
Write-Host "ERROR: $updatedEmulationStatonBinaries not found."
exit -1
}
Write-Host "INFO: Generate ES settings file with favorites enabled."
$esConfigFile = "$env:userprofile\.emulationstation\es_settings.cfg"
$newSettingsConfig = "<?xml version='1.0'?>
<bool name='BackgroundJoystickInput' value='false' />
<bool name='CaptionsCompatibility' value='true' />
<bool name='DrawFramerate' value='false' />
<bool name='EnableSounds' value='true' />
<bool name='MoveCarousel' value='true' />
<bool name='ParseGamelistOnly' value='false' />
<bool name='QuickSystemSelect' value='true' />
<bool name='SaveGamelistsOnExit' value='true' />
<bool name='ScrapeRatings' value='true' />
<bool name='ScreenSaverControls' value='true' />
<bool name='ScreenSaverOmxPlayer' value='false' />
<bool name='ShowHelpPrompts' value='true' />
<bool name='ShowHiddenFiles' value='false' />
<bool name='SlideshowScreenSaverCustomImageSource' value='false' />
<bool name='SlideshowScreenSaverRecurse' value='false' />
<bool name='SlideshowScreenSaverStretch' value='false' />
<bool name='SortAllSystems' value='false' />
<bool name='StretchVideoOnScreenSaver' value='false' />
<bool name='UseCustomCollectionsSystem' value='true' />
<bool name='VideoAudio' value='true' />
<bool name='VideoOmxPlayer' value='false' />
<int name='MaxVRAM' value='100' />
<int name='ScraperResizeHeight' value='0' />
<int name='ScraperResizeWidth' value='400' />
<int name='ScreenSaverSwapImageTimeout' value='10000' />
<int name='ScreenSaverSwapVideoTimeout' value='30000' />
<int name='ScreenSaverTime' value='300000' />
<string name='AudioDevice' value='Master' />
<string name='CollectionSystemsAuto' value='favorites' />
<string name='CollectionSystemsCustom' value='' />
<string name='GamelistViewStyle' value='automatic' />
<string name='OMXAudioDev' value='both' />
<string name='PowerSaverMode' value='disabled' />
<string name='Scraper' value='TheGamesDB' />
<string name='ScreenSaverBehavior' value='dim' />
<string name='ScreenSaverGameInfo' value='never' />
<string name='SlideshowScreenSaverBackgroundAudioFile' value='$env:userprofile/.emulationstation/slideshow/audio/slideshow_bg.wav' />
<string name='SlideshowScreenSaverImageDir' value='$env:userprofile/.emulationstation/slideshow/image' />
<string name='SlideshowScreenSaverImageFilter' value='.png,.jpg' />
<string name='ThemeSet' value='recalbox-backport' />
<string name='TransitionStyle' value='fade' />
"
Set-Content $esConfigFile -Value $newSettingsConfig
$requiredTmpFolder = "$env:userprofile\.emulationstation\tmp\"
New-Item -ItemType Directory -Force -Path $requiredTmpFolder | Out-Null
Write-Host "INFO: Genrating Dolphin Config"
$dolphinConfigFile = "$env:userprofile\.emulationstation\systems\retroarch\saves\User\Config\Dolphin.ini"
$dolphinConfigFolder = "$env:userprofile\.emulationstation\systems\retroarch\saves\User\Config\"
$dolphinConfigFileContent = "[General]
LastFilename =
ShowLag = False
ShowFrameCount = False
ISOPaths = 0
RecursiveISOPaths = False
NANDRootPath =
DumpPath =
WirelessMac =
WiiSDCardPath = $env:userprofile\.emulationstation\systems\retroarch\saves\User\Wii\sd.raw
[Interface]
ConfirmStop = True
UsePanicHandlers = True
OnScreenDisplayMessages = True
HideCursor = False
AutoHideCursor = False
MainWindowPosX = -2147483648
MainWindowPosY = -2147483648