This repository has been archived by the owner on Nov 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuae_config_maker.py
1426 lines (1052 loc) · 59 KB
/
uae_config_maker.py
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
import argparse
import glob
import math
import os
import shutil
import platform
from pathlib import Path
from utils import general_utils
from utils import text_utils
from utils import update_utils
from utils.text_utils import FontColours
from whdload import whdload_slave
def fix_ownership(path):
"""Change the owner of the file to SUDO_UID"""
uid = os.environ.get('SUDO_UID')
gid = os.environ.get('SUDO_GID')
if uid is not None:
os.chown(path, int(uid), int(gid))
def value_list(in_file, game_name):
file_name = "settings/" + in_file
if os.path.isfile(file_name) is False:
return 0
with open(file_name) as f:
content = f.readlines()
content = [x.strip() for x in content]
f.close()
answer = 0
for this_line in content:
if not this_line == "":
this_word = this_line.split()
if this_word[0] == game_name:
answer = this_word[1]
break
return answer
def check_list(in_file, game_name):
temp_game = game_name
if text_utils.right(temp_game.lower(),4) == ".iso" or text_utils.right(temp_game.lower(),4) == ".cue":
temp_game = text_utils.left(temp_game,len(temp_game)-4)
if text_utils.right(temp_game.lower(),4) == ".adf" or text_utils.right(temp_game.lower(),4) == ".hdf":
temp_game = text_utils.left(temp_game,len(temp_game)-4)
file_name = "settings/" + in_file
if os.path.isfile(file_name) is False:
return False
with open(file_name) as f:
content = f.readlines()
content = [x.strip() for x in content]
f.close()
answer = False
for this_line in content:
if this_line == temp_game:
answer = True
break
return answer
def find_host_option(in_option):
file_name = "templates/hostconfig.uaetemp"
if os.path.isfile(file_name) is False:
return ""
with open(file_name) as f:
content = f.readlines()
content = [x.strip() for x in content]
f.close()
answer = ""
for this_line in content:
if text_utils.left(this_line, len(in_option)) == in_option:
answer = this_line.replace(in_option, "")
answer = answer.replace("=", "").strip()
break
return answer
def do_scan(input_directory, pathname,output_directory):
print()
if os.path.isdir(input_directory + pathname):
print("Config Save Path: " + FontColours.OKBLUE + output_directory + FontColours.ENDC)
print("Games Files Path: " + FontColours.BOLD + FontColours.OKBLUE + pathname + FontColours.ENDC)
print()
else:
print(
"Specified Scan path " + FontColours.FAIL + input_directory + pathname + FontColours.ENDC +
" does not exist")
return
the_filter = ""
count = 1
skip_all = 0
# VARIOUS SETTINGS FROM HOST CONFIG ONLY
#
# command line forcing of overwrite of files
if FORCE_OVERWRITE is True:
skip_all = 1
# quit_button = find_host_option("button_for_quit")#
# menu_button = find_host_option("button_for_menu")
quit_key = find_host_option("key_for_quit")
menu_key = find_host_option("key_for_menu")
# if quit_button == "":
# quit_button = -1
# if menu_button == "":
# menu_button = -1
if quit_key == "":
quit_key = "Escape"
if menu_key == "":
menu_key = "F12"
# sort out the input items
input_1 = find_host_option("controller_1")
input_2 = find_host_option("controller_2")
input_3 = find_host_option("controller_3")
input_4 = find_host_option("controller_4")
if input_1 == "":
input_1 = "joy1"
if input_2 == "":
input_2 = "joy2"
if input_3 == "":
input_3 = "joy0"
if input_4 == "":
input_4 = "none"
input_mouse = find_host_option("controller_mouse")
if input_mouse == "":
input_mouse = "joy1"
mouse_map = find_host_option("mouse_map")
if mouse_map == "":
mouse_map = "left"
deadzone = find_host_option("joymouse_deadzone")
if deadzone == "":
deadzone = "33"
stereo_seperation = find_host_option("stereo_seperation")
if stereo_seperation == "":
stereo_seperation = "7"
mouse_speed = find_host_option("mouse_speed")
if mouse_speed == "":
mouse_speed = "5"
# retroarch toggles
retroarch_quit = find_host_option("retroarch_quit")
retroarch_menu = find_host_option("retroarch_menu")
retroarch_reset = find_host_option("retroarch_reset")
if retroarch_quit == "":
retroarch_quit = "True"
if retroarch_menu == "":
retroarch_menu = "True"
if retroarch_reset == "":
retroarch_reset = "False"
# cycle through all >>> files<<
# python 3.5+ only
# for file in glob.iglob(input_directory + pathname + '/**/*.*', recursive=True):
# python 3.4
for file2 in Path(input_directory + pathname + "/").glob('**/*.*'):
file = str(file2)
scan_pass = False
# Set criteria for each scan type
# use the extension to determine what we are working on.
# WHDLOAD scanmode finds .slave files but uses folders
if file.lower().find(".slave") > -1 and pathname.find("WHDLoad") > -1:
scan_mode = "WHDLoad"
scan_pass = True
# WHDLOAD scanmode will accept .zip
elif file.lower().find(".zip") > -1 and pathname.find("WHDLoad") > -1:
scan_mode = "WHDLoad"
scan_pass = True
# WHDLOAD HDF scanmode must have file extension as .hdf
elif file.lower().find(".hdf") > -1 and pathname.find("WHDLoad") > -1 and pathname.find("_HDF") > -1:
scan_mode = "WHDLoadHDF"
scan_pass = True
# CD32 folders prefer sub file with extension as .cue
elif file.lower().find(".cue") > -1 and pathname.find("CD32") > -1:
scan_mode = "CD32"
scan_pass = True
# CD32 folders prefer sub file with extension as .cue
elif file.lower().find(".iso") > -1 and pathname.find("CD32") > -1:
scan_mode = "CD32"
scan_pass = True
# CD folders prefer sub file with extension as .cue
elif file.lower().find(".cue") > -1:
scan_mode = "A1200CD"
scan_pass = True
# CD32 folders prefer sub file with extension as .cue
elif file.lower().find(".iso") > -1:
scan_mode = "A1200CD"
scan_pass = True
# regular HDF scanmode must have file extension as .hdf
elif file.lower().find(".hdf") > -1 and pathname.find("_HDF") > -1:
scan_mode = "HDF"
scan_pass = True
else:
scan_mode = "None"
# clear out the cue/iso confusion
if file.lower().find(".iso") > -1 and os.path.isfile(file.replace(".iso",".cue")):
scan_pass = False
if file.lower().find("track 01 of") > -1 and file.lower().find(".iso") > -1:
scan_pass = False
# remove the long filepath
this_file = os.path.basename(file)
# remove stupid OSX, UAE or badly renamed files
if text_utils.left(this_file.lower(),2) == "._" or text_utils.right(this_file.lower(),4) == "uaem" or this_file.lower()=="game.slave":
scan_pass = False
# name filter applies
if the_filter != '' and this_file.find(the_filter) < 0:
pass
# we passed the 'type' scan
elif scan_pass is True:
# horrible work around for annoying game name
temp_name = this_file.replace("R³sselsheim", "Russelsheim")
# inform the user how this is being processed
print(FontColours.OKBLUE + str(count) + FontColours.ENDC +
": Processing File: " + FontColours.BOLD + temp_name + FontColours.ENDC +
" - " + FontColours.HEADER + scan_mode + FontColours.ENDC )
game_path = file.replace(os.path.basename(file),"").replace(input_directory + pathname + "/","")
game_file = this_file
# remove extensions zip / iso /cue / adf / hdf
if this_file.lower().endswith(".zip") or this_file.lower().endswith(".cue") or this_file.lower().endswith(".iso") or this_file.lower().endswith(".hdf") or this_file.lower().endswith(".adf"):
this_file = text_utils.left(this_file, len(this_file) - 4)
# remove extensions slave
if this_file.lower().endswith(".slave"):
this_file = text_utils.left(this_file, len(this_file) - 6)
# Sort the naming out
# standard 'expand name' for WHDLoad folders
if scan_mode == "WHDLoad":
full_game_name = text_utils.make_full_name(this_file)
# standard 'expand name' for WHDLoad folders
elif scan_mode == "WHDLoadHDF":
#full_game_name = text_utils.make_full_name(text_utils.left(this_file, len(this_file) - 4))
full_game_name = text_utils.make_full_name(this_file)
full_game_name = full_game_name + " [WHDLoad HDF]"
# there is an alternative name changing for TOSEC CD32 images....
elif scan_mode == "CD32":
full_game_name = text_utils.make_full_cd32_name(this_file)
# there will probably an alternative name changing for TOSEC ADF files if we ever add it....
elif scan_mode == "ADF":
full_game_name = this_file
continue
else:
full_game_name = this_file
full_game_path = input_directory + pathname + "/" + game_path
# DISPLAY!
print()
print(" Full Name: " + FontColours.OKGREEN + full_game_name + FontColours.ENDC)
# normal method for machine selection
if full_game_name.find("AGA") > -1:
machine_type = "A1200/020"
elif scan_mode == "CD32":
machine_type = "CD32"
if full_game_name.find(" [CD32]")<0:
full_game_name += " [CD32] [ISO]"
elif full_game_name.find("AGA") > -1:
machine_type = "A1200/020"
elif full_game_name.find("CD32") > -1:
machine_type = "A1200/020"
else:
machine_type = "A600+"
# check if config already exists - yes/no to overwrite
create_config = True
answer = ""
# create the full name of output file
if NO_FILENAME_SPACES == False:
config_file = output_directory + full_game_name + ".uae"
else:
config_file = output_directory + full_game_name.replace(" ","_") + ".uae"
if os.path.isfile(config_file) == True and skip_all == 0:
while answer != "Y" and answer != "N" and answer != "S" and answer != "A":
answer = input(
FontColours.OKBLUE + " Config already exists - overwrite? " + "(Yes/No/Always/Skip) "
+ FontColours.ENDC)
if answer == "a" or answer == "s" or answer == "n" or answer == "y":
answer = answer.upper()
print()
elif os.path.isfile(config_file) == True and skip_all == -1:
create_config = False
print(FontColours.OKBLUE + " Skipping existing file." + FontColours.ENDC)
print()
# process the answers
if answer == "N":
create_config = False
elif answer == "Y":
create_config = True
elif answer == "A":
skip_all = 1
elif answer == "S":
skip_all = -1
create_config = False
# what to do 'automatically'
if skip_all == 1:
create_config = True
# black list
if check_list("UAEConfigMaker_BlackList.txt", game_file) is True:
print(FontColours.FAIL + " Skipping black-listed file." + FontColours.ENDC)
create_config = False
# this is where we start the code to actually build the config with changes
if create_config is True:
# lets do some work, based on what slave files we find.
# ===================
whd_chip_ram = 0
whd_fast_ram = 0
whd_aga = False
whd_020 = False
whd_cd32 = False
whd_kicks = ['']
whd_longname = ""
whd_realname = ""
whd_infoname = ""
whd_date = None
whd_page = ""
# note that this *only* works with WHDLoad folder scanning.
if scan_mode == "WHDLoad" and WHDLOAD_UPDATE==True:
whd_update_message = ""
for slave_file in glob.glob(full_game_path + "*"):
if slave_file.lower().endswith(".slave"):
this_slave = whdload_slave.whdload_factory(slave_file)
# print (this_slave.name)
# minimum chip ram
round_up = int(this_slave.base_mem_size/524288) + (this_slave.base_mem_size % 524288 > 0)
if round_up >= whd_chip_ram:
whd_chip_ram = round_up
if whd_chip_ram > 4:
whd_chip_ram = 4
# minimum fast ram
round_up = int(this_slave.exp_mem/1048576) + (this_slave.exp_mem % 1048576 >0)
if round_up >= whd_fast_ram: whd_fast_ram = round_up
# AGA needed
if this_slave.requires_aga == True: whd_aga = True
# 020 needed
if this_slave.requires_68020 == True: whd_020 = True
# CD32 controls patch is available
if this_slave.has_cd32_controls_patch == True: whd_cd32 = True
# Kickstarts (files needed to be checked in _BootWHD/devs/kickstarts
# and a warning produced if not present.
# put on hold until bugfix implemented
# (this_slave.kickstart_name)
# created date for slave will be needed for updates
# whd_dated = this_slave.created_timex
whd_longname = slave_file
whd_realname = os.path.basename(slave_file)
# +++ Lets scan for updates shall we? +++
# first, we'll find the WHDLoad web-page from the list
whd_page = text_utils.get_whdload_page(whd_realname)
# print(whd_realname + " === " + str(whd_infoname) + " === " + whd_page)
if whd_page == "":
whd_update_message += whd_realname + " not found on master WHDLoad page list." + chr(10) + "UAE Config Maker could not verify slave updates." + chr(10)
print (" Slave file: " + FontColours.OKBLUE + whd_realname + FontColours.ENDC + " not found on master WHDLoad page list." + chr(10))
break
# here's where we start checking again the WHDload page (OLLY!!!)
# print("whd page:" + whd_page)
have_found_slave = False
web_slaves = whdload_slave.whdload_factory(whd_page)
if isinstance(web_slaves,list):
for web_slave in web_slaves:
if web_slave.name == this_slave.name:
have_found_slave = True
break
else:
web_slave = web_slaves
if web_slave.name == this_slave.name:
have_found_slave = True
if have_found_slave == True and web_slave.modified_time.date() > this_slave.modified_time.date():
print()
print(" Slave file: " + FontColours.OKBLUE + whd_realname + FontColours.ENDC + " is an older version.")
print(" This version: " + FontColours.FAIL + str(this_slave.modified_time) + FontColours.ENDC
+ " New Version: " + FontColours.OKGREEN + str(web_slave.modified_time) + FontColours.ENDC)
print()
whd_update_message = whd_update_message + " Slave file: " + whd_realname + " is an older version." + chr(10) + chr(10)
whd_update_message = whd_update_message + " This version: " + str(this_slave.modified_time) + "" + chr(10)
whd_update_message = whd_update_message + " Detected Version: " +str(web_slave.modified_time) + "" + chr(10)
# delete old slave
# copy in new slave
# delete auto-startup (if included)
# web_slaveslave loop is finished
if whd_update_message !="":
text_file = open(full_game_path + "whdupdate_message", "w+")
text_file.write(whd_update_message)
text_file.close()
fix_ownership(full_game_path + "whdupdate_message")
print()
#print(" "+whd_update_message)
#continue
# ===================
# check other parameters
# hardware options
# ======== SYSTEM HARDWARE =======
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# override the machine type, if on a list
if check_list("System_A500.txt", this_file) is True:
machine_type = "A500"
elif check_list("System_A1200.txt", this_file) is True:
machine_type = "A1200/020"
elif check_list("System_A4000.txt", this_file) is True:
machine_type = "A4000/040"
elif check_list("System_CD32.txt", this_file) is True:
machine_type = "CD32"
# PRESETS: CPU / chipset/ kickstart
# WHD overrides are easier if we look at a base machine type
if whd_020 is True and machine_type == "A500":
machine_type = "A600+"
if whd_aga is True and (machine_type == "A500" or machine_type == "A600+"):
machine_type = "A1200/020"
# TODO: Convert settings to a dictionary or object ... yeah.... i'll leave this to you ;)
z3_ram = 0
if machine_type == "A500":
chipset = "OCS"
a_cpu = "68000"
kickstart = "kick13.rom"
kickstart_ext = ""
fast_ram = 0
chip_ram = 1
clock_speed = 0
elif machine_type == "A600+" or machine_type == "":
chipset = "ECS_Agnus"
a_cpu = "68020"
kickstart = "kick31.rom"
kickstart_ext = ""
chip_ram = 4
fast_ram = 8
clock_speed = 0
elif machine_type == "A1200":
chipset = "AGA"
a_cpu = "68ec020"
kickstart = "kick30.rom"
kickstart_ext = ""
chip_ram = 4
fast_ram = 8
clock_speed = 14
elif machine_type == "A1200/020":
chipset = "AGA"
a_cpu = "68020"
kickstart = "kick31.rom"
kickstart_ext = ""
chip_ram = 4
fast_ram = 8
clock_speed = 14
elif machine_type == "A4000":
chipset = "AGA"
a_cpu = "68040"
kickstart = "kick31.rom"
kickstart_ext = ""
chip_ram = 4
fast_ram = 8
clock_speed = 28
elif machine_type == "CD32":
chipset = "AGA"
a_cpu = "68ec020"
kickstart = "cd32kick31.rom"
kickstart_ext = "cd32ext.rom"
chip_ram = 4
fast_ram = 8
clock_speed = 14
elif machine_type == "A1200/32":
chipset = "AGA"
a_cpu = "68ec020"
kickstart = "cd32kick31.rom"
kickstart_ext = "cd32ext.rom"
chip_ram = 4
fast_ram = 8
clock_speed = 14
# pre-check for alt-kickstart
if check_list("CPU_68000.txt", this_file) is True:
kickstart = "kick205.rom"
# check rom requirement
rom_check = True
if IGNORE_ROM_REQUIREMENT == False:
if os.path.isfile(ROM_PATH + kickstart) == False:
print ("")
print (" Kickstart file: " + FontColours.FAIL + ROM_PATH + kickstart + FontColours.ENDC + " is missing!")
rom_check = False
if os.path.isfile(ROM_PATH + kickstart_ext) == False and kickstart_ext !="" :
print (" Extended Kickstart file: " + FontColours.FAIL + ROM_PATH + kickstart_ext + FontColours.ENDC + " is missing!")
rom_check = False
# '======== MEMORY SETTINGS =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' when we want different chip ram!!
old_chip_ram = chip_ram
for i in range(0, 4):
chip_ram = int(math.pow(2, i)) / 2
if chip_ram >= 1:
chip_ram = int(chip_ram)
if check_list("Memory_ChipRam_" + str(chip_ram) + ".txt", this_file) is True:
chip_ram = int(chip_ram * 2)
break
chip_ram = old_chip_ram
# whd chip-memory overwrite
if whd_chip_ram >= chip_ram: chip_ram = whd_chip_ram
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' when we want different fast ram!!
old_fast_ram = fast_ram
for i in range(0, 4):
fast_ram = int(math.pow(2, i))
if check_list("Memory_FastRam_" + str(fast_ram) + ".txt", this_file) is True:
break
fast_ram = old_fast_ram
# whd fast-memory overwrite
if whd_fast_ram >= fast_ram and whd_fast_ram <= 8 : fast_ram = whd_fast_ram
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' when we want different Z3 ram!!
for i in range(0, 8):
z3_ram = int(math.pow(2, i))
# print (z3_ram)
if check_list("Memory_Z3Ram_" + str(z3_ram) + ".txt", this_file) is True:
break
z3_ram = 0
# whd z3-memory overwrite
if whd_fast_ram >= z3_ram and whd_fast_ram > 8 : z3_ram = whd_chip_ram
# '======== CHIPSET SETTINGS =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' sprite collisions
sprite_collisions = "playfields"
if check_list("Chipset_CollisionLevel_playfields.txt", this_file) is True:
sprite_collisions = "playfields"
if check_list("Chipset_CollisionLevel_none.txt", this_file) is True:
sprite_collisions = "none"
if check_list("Chipset_CollisionLevel_sprites.txt", this_file) is True:
sprite_collisions = "sprites"
if check_list("Chipset_CollisionLevel_full.txt", this_file) is True:
sprite_collisions = "full"
chipset_compatible = "Generic"
if machine_type == "CD32":
chipset_compatible = "CD32"
# ' imm. blits & fast copper
fast_copper = not check_list("Chipset_NoFastCopper.txt", this_file)
immediate_blits = check_list("Chipset_ImmediateBlitter.txt", this_file)
# '======== CPU SETTINGS =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' max emu speed
a_cpu_speed = "real"
if check_list("CPU_MaxSpeed.txt", this_file) is True:
a_cpu_speed = "max"
# ' clock speed
if check_list("CPU_ClockSpeed_7.txt", this_file) is True:
clock_speed = 7
if check_list("CPU_ClockSpeed_14.txt", this_file) is True:
clock_speed = 14
if check_list("CPU_ClockSpeed_28.txt", this_file) is True:
clock_speed = 28
# ' cpu model 68000
if check_list("CPU_68000.txt", this_file) is True:
a_cpu = "68000"
# ' cpu model 68040
if check_list("CPU_68040.txt", this_file) is True:
a_cpu = "68040"
_24_bit_address = False
# ' 24 bit addressing / compatible CPU / JIT Cache
_24_bit_address = not check_list("CPU_No24BitAddress.txt", this_file)
compatible_cpu = check_list("CPU_Compatible.txt", this_file)
cycle_exact = check_list("CPU_CycleExact.txt", this_file)
use_jit = False
if check_list("CPU_ForceJIT.txt",this_file) == True:
use_jit = True
a_cpu_speed = "max"
elif check_list("CPU_NoJIT.txt", this_file) == False:
use_jit = False
# '======== DISPLAY SETTINGS =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' screen Y/X Offsets
screen_offset_y = value_list("Screen_OffsetY.txt", this_file)
#for Z in range(-16, 16):
# if check_list("Screen_OffsetY_" + str(Z) + ".txt", this_file) is True:
# screen_offset_y = Z
screen_offset_x = value_list("Screen_OffsetX.txt", this_file)
#for Z in range(-16, 16):
# if check_list("Screen_OffsetX_" + str(Z) + ".txt", this_file) is True:
# screen_offset_x = Z
# ' screen heights
screen_height = 240
if check_list("Screen_Height_270.txt", this_file) is True:
screen_height = 270
if check_list("Screen_Height_262.txt", this_file) is True:
screen_height = 262
if check_list("Screen_Height_256.txt", this_file) is True:
screen_height = 256
if check_list("Screen_Height_240.txt", this_file) is True:
screen_height = 240
if check_list("Screen_Height_224.txt", this_file) is True:
screen_height = 224
if check_list("Screen_Height_216.txt", this_file) is True:
screen_height = 216
if check_list("Screen_Height_200.txt", this_file) is True:
screen_height = 200
# ' screen widths
screen_width = 640
if check_list("Screen_Width_384.txt", this_file) is True:
screen_width = 384
if check_list("Screen_Width_352.txt", this_file) is True:
screen_width = 352
if check_list("Screen_Width_320.txt", this_file) is True:
screen_width = 320
if check_list("Screen_Width_768.txt", this_file) is True:
screen_width = 768
if check_list("Screen_Width_704.txt", this_file) is True:
screen_width = 704
if check_list("Screen_Width_640.txt", this_file) is True:
screen_width = 640
# ' extras
aspect_ratio = bool(check_list("Screen_Force43Aspect.txt", this_file))
if find_host_option("gfx_correct_aspect") != "":
aspect_ratio = find_host_option("gfx_correct_aspect")
linemode = ""
if find_host_option("gfx_linemode") != "":
linemode = find_host_option("gfx_linemode")
if linemode.lower() != "double" and linemode.lower() != "none":
linemode = "double"
use_frameskip = 0
if find_host_option("gfx_framerate") != "":
use_frameskip = find_host_option("gfx_framerate")
use_ntsc = check_list("Screen_ForceNTSC.txt", this_file)
# '======== CONTROL SETTINGS =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' mouse / mouse 2 / CD32
use_mouse1 = check_list("Control_Port0_Mouse.txt", this_file)
use_mouse2 = check_list("Control_Port1_Mouse.txt", this_file)
use_cd32_pad = check_list("Control_CD32.txt", this_file)
if scan_mode == "CD32" or full_game_name.lower().find("[cd32]") > -1:
use_cd32_pad = True
# '======== MISC SETTINGS =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' BSD Socket / Floppy Speed etc
use_bsd_socket = check_list("Misc_BSDSocket.txt", this_file)
floppy_speed = 400
disk = ["", "", "", ""]
if check_list("Floppy_Speed_100.txt", this_file) is True:
floppy_speed = 100
if check_list("Floppy_Speed_200.txt", this_file) is True:
floppy_speed = 200
if check_list("Floppy_Speed_400.txt", this_file) is True:
floppy_speed = 400
if check_list("Floppy_Speed_800.txt", this_file) is True:
floppy_speed = 800
# '======== SETUP CONFIG =======
# ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ' ....
# print("we are making a config ....")
if rom_check == True:
shutil.copyfile("templates/" + config_name + ".uaetemp", config_file)
else:
print(FontColours.FAIL + " Kickstart ROM(s) not present - no config created." + FontColours.ENDC)
if os.path.isfile(config_file) is False:
print(FontColours.FAIL + " Error creating config." + FontColours.ENDC)
# fall-back check for exising file that is with no kickstart
elif os.path.isfile(config_file) is True and rom_check == False:
os.remove (config_file)
else:
print(" Editing File: " + FontColours.HEADER + config_file + FontColours.ENDC)
# put the text from the file into a string
text_file = open(config_file, "r")
config_text = text_file.read()
text_file.close()
# all the major find/replaces from below....
# I needed an "override" option
# to force //home/pi/RetroPie/roms/amiga/ on
# external machines (allowing WHD packs to be created on external machines)
if FORCE_PATHS.lower() == "pi":
config_text = config_text.replace("<<inputdir>>", "/home/pi/RetroPie/roms/amiga-data/")
elif FORCE_PATHS.lower() == "android":
config_text = config_text.replace("<<inputdir>>", "/storage/emulated/0/roms/")
elif FORCE_PATHS != "":
config_text = config_text.replace("<<inputdir>>", FORCE_PATHS)
else:
config_text = config_text.replace("<<inputdir>>", input_directory)
# do somthing almost the same, for rom/kickpath
if ROM_PATH.lower() == "pi":
config_text = config_text.replace("<<romdir>>", "/home/pi/RetroPie/BIOS/Amiga/")
elif ROM_PATH.lower() == "android":
config_text = config_text.replace("<<romdir>>", "/storage/emulated/0/roms/kickstarts/")
else:
config_text = config_text.replace("<<romdir>>", ROM_PATH)
# game / path
config_text = config_text.replace("<<game>>", this_file)
config_text = config_text.replace("<<gamepath>>", game_path)
config_text = config_text.replace("<<gamefile>>", game_file)
config_text = config_text.replace("<<fullgame>>", full_game_name)
config_text = config_text.replace("<<hdpath>>", pathname)
# config_text = config_text.replace("<<quitbutton>>", str(quit_button))
# config_text = config_text.replace("<<menubutton>>", str(menu_button))
config_text = config_text.replace("<<retroarch_quit>>", str(retroarch_quit))
config_text = config_text.replace("<<retroarch_menu>>", str(retroarch_menu))
config_text = config_text.replace("<<retroarch_reset>>", str(retroarch_reset))
config_text = config_text.replace("<<quitkey>>", str(quit_key))
config_text = config_text.replace("<<menukey>>", str(menu_key))
# screens
config_text = config_text.replace("<<screenheight>>", str(screen_height))
if screen_width < 320:
screen_width == 640
config_text = config_text.replace("<<screenwidth>>", str(screen_width))
config_text = config_text.replace("<<offset_y>>", str(screen_offset_y))
config_text = config_text.replace("<<offset_x>>", str(screen_offset_x))
config_text = config_text.replace("<<43aspect>>", str(aspect_ratio))
config_text = config_text.replace("<<frameskip>>", str(use_frameskip))
config_text = config_text.replace("<<linemode>>", str(linemode))
config_text = config_text.replace("<<ntsc>>", str(bool(0 - use_ntsc)))
# memory
config_text = config_text.replace("<<chipmem>>", str(chip_ram))
config_text = config_text.replace("<<fastmem>>", str(fast_ram))
config_text = config_text.replace("<<z3mem>>", str(z3_ram))
if z3_ram > 0 and (a_cpu != "68020" and a_cpu != "68040"):
a_cpu = "68020"
# chipset
config_text = config_text.replace("<<chipset>>", chipset)
config_text = config_text.replace("<<spritecollision>>", sprite_collisions)
config_text = config_text.replace("<<chipsetcompatible>>", chipset_compatible)
config_text = config_text.replace("<<fastcopper>>", str(bool(0 - fast_copper)))
config_text = config_text.replace("<<immediateblitter>>", str(bool(0 - immediate_blits)))
# cpu
if a_cpu_speed == "max":
config_text = config_text.replace("finegrain_cpu_speed=", ";finegrain_cpu_speed=")
else:
if clock_speed == 14:
clock_speed = 1024
elif clock_speed == 28:
clock_speed = 128
else:
clock_speed = 0
config_text = config_text.replace("<<kickstart>>", kickstart)
config_text = config_text.replace("<<extkickstart>>", kickstart_ext)
config_text = config_text.replace("<<cputype>>", a_cpu)
config_text = config_text.replace("<<cpuspeed>>", a_cpu_speed)
if a_cpu_speed == "real":
config_text = config_text.replace("cpu_speed=real", ";cpu_speed=real")
config_text = config_text.replace("<<clockspeed>>", str(clock_speed))
config_text = config_text.replace("<<cpucompatible>>", str(bool(0 - compatible_cpu)))
config_text = config_text.replace("<<cycleexact>>", str(bool(0 - cycle_exact)))
config_text = config_text.replace("<<24bitaddress>>", str(bool(0 - _24_bit_address)))
if use_jit is False:
config_text = config_text.replace("<<jitcache>>", "0")
else:
config_text = config_text.replace("<<jitcache>>", "8192")
# misc
config_text = config_text.replace("<<bsdsocket>>", str(bool(0 - use_bsd_socket)))
# hard disk files
disk_nr = 0
if scan_mode == "HDF" and os.path.isfile(
pathname + this_file.replace(".hdf", "") + "_savedisk.adf") is True:
disk_nr = 1
config_text = config_text.replace("<<diskpath0>>", pathname)
config_text = config_text.replace("<<disk0>>", this_file.replace(".hdf", "") + "_savedisk.adf")
config_text = config_text.replace("<<disktype0>>", "0")
if scan_mode == "HDF":
# remove the boot drive-system (folder) DH0:
config_text = config_text.replace("uaehf0=dir,rw,DH0:DH0:", ";uaehf0=dir,rw,DH0:DH0:")
config_text = config_text.replace("filesystem2=rw,DH0:DH0:", ";filesystem2=rw,DH0:DH0:")
# remove the file-system (folder) DH1:
config_text = config_text.replace("uaehf1=dir,rw,DH1", ";uaehf1=dir,rw,DH1")
config_text = config_text.replace("filesystem2=rw,DH1", ";filesystem2=rw,DH1")
config_text = config_text.replace("uaehf1=hdf,rw,DH2", "uaehf0=hdf,rw,DH0")
config_text = config_text.replace("hardfile2=rw,DH2", "hardfile2=rw,DH0")
# WHDLoad HDF scanning
elif scan_mode == "WHDLoadHDF":
# remove the file-system (folder) DH1:
config_text = config_text.replace("uaehf1=dir,rw,DH1", ";uaehf1=dir,rw,DH1")
config_text = config_text.replace("filesystem2=rw,DH1", ";filesystem2=rw,DH1")
# adjust parameters for DH2 to become DH1:
config_text = config_text.replace(",32,1,2,512,50,,uae", ",32,1,2,512,-50,,uae")
config_text = config_text.replace("uaehf1=hdf,rw,DH2:", "uaehf1=hdf,rw,DH1:")
config_text = config_text.replace("hardfile2=rw,DH2", "hardfile2=rw,DH1")
# disable the HDF parameter
else:
config_text = config_text.replace("hardfile2=", ";hardfile2=")
config_text = config_text.replace("uaehf1=hdf,rw,DH2:", ";uaehf1=hdf,rw,DH2:")
for i in range(disk_nr, 4):
config_text = config_text.replace("<<diskpath" + str(i) + ">>", pathname)
config_text = config_text.replace("<<disk" + str(i) + ">>", disk[i])