-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_config.py
44 lines (33 loc) · 1.23 KB
/
make_config.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
import json
def make_training_config(
ini_path,
bios_path,
rom_path,
display_method="Direct3D9",
):
with open("ini_templates/training.ini") as fp:
template = json.load(fp)
_make_config(template, ini_path, bios_path, rom_path, display_method)
def make_enjoy_config(
ini_path,
bios_path,
rom_path,
display_method="Direct3D9",
):
with open("ini_templates/enjoy.ini") as fp:
template = json.load(fp)
_make_config(template, ini_path, bios_path, rom_path, display_method)
def _make_config(template, ini_path, bios_path, rom_path, display_method):
if display_method == "OpenGL":
template["DispMethod"] = 0
elif display_method == "Direct3D9":
template["DispMethod"] = 2
else:
display_methods = ["Direct3D9", "OpenGL"]
raise ValueError(f"display_method should be one of {display_methods}")
duo_slash_bios_path = str(bios_path).replace("\\", "\\\\")
duo_slash_rom_path = str(rom_path).replace("\\", "\\\\")
template["FirmwareUserSpecifications"] = {"PSX+U": duo_slash_bios_path}
template["RecentRoms"]["recentlist"] = [f"*OpenRom*{duo_slash_rom_path}"]
with open(ini_path, "w") as fp:
json.dump(template, fp, indent=2)