-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
executable file
·43 lines (30 loc) · 926 Bytes
/
run.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
#!/usr/bin/env python3
import pyximport;
pyximport.install()
import sys
from gb_pymulator import emulator
import os.path
GAMES_DIR = "games"
TESTS_DIR = "test_roms"
def main():
args = sys.argv
if len(args) < 2:
filename_arg = f"{GAMES_DIR}/dr_mario.gb"
elif len(args) == 2:
filename_arg = args[1]
else:
print(f"Usage: {args[0]} [ ROM_FILE_NAME ]")
return
if os.path.isfile(filename_arg):
rom_filename = filename_arg
elif os.path.isfile(f"{GAMES_DIR}/{filename_arg}"):
rom_filename = f"{GAMES_DIR}/{filename_arg}"
elif os.path.isfile(f"{TESTS_DIR}/{filename_arg}"):
rom_filename = f"{TESTS_DIR}/{filename_arg}"
else:
print(f"File not found: '{filename_arg}'")
return
print(f"Running emulator on ROM file: {rom_filename}")
emulator.run_game_from_file(rom_filename)
if __name__ == "__main__":
main()