forked from AhmedAmrNabil/brick-breaker-assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_multi.py
77 lines (63 loc) · 1.55 KB
/
run_multi.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
import os
import subprocess
from time import sleep
filedata = r"""
[cpu]
cycles = max
[sdl]
fullresolution=640x400
windowresolution=640x400
output=openglpp
[autoexec]
mount C --path--/assembler
set PATH=%PATH%;C:
MOUNT D --path--
D:
"""
filedata = filedata.replace("--path--", os.getcwd())
files = [f for f in os.listdir() if os.path.isfile(f)]
if "main.asm" in files:
files.remove("main.asm")
files.insert(0, "main.asm")
linkingstr = "link "
m = {}
for file in files:
filename, file_extension = os.path.splitext(file)
if file_extension == ".OBJ" or file_extension == ".EXE":
os.remove(file)
elif file_extension == ".asm":
if len(filename) > 8:
filename = filename[:6]
if filename in m:
m[filename] += 1
else:
m[filename] = 1
filename += "~" + str(m[filename])
filedata += f"masm {filename}.asm;\n"
linkingstr += f"{filename}.OBJ+"
filedata += linkingstr[:-1]
filedata += ";"
filedata += "\nmain.exe"
filedata1 = (
filedata
+ r"""
[serial]
serial1=directserial realport:COM1
"""
)
filedata2 = (
filedata
+ r"""
[serial]
serial1=directserial realport:COM2
"""
)
with open("dosbox-x-generated1.conf", "w") as file:
file.write(filedata1)
with open("dosbox-x-generated2.conf", "w") as file:
file.write(filedata2)
prog1 = ["C:\DOSBox-X\dosbox-x.exe", "-conf", "dosbox-x-generated1.conf"]
prog2 = ["C:\DOSBox-X\dosbox-x.exe", "-conf", "dosbox-x-generated2.conf"]
subprocess.Popen(prog1)
sleep(2)
subprocess.Popen(prog2)