-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathyac8e.py
executable file
·92 lines (80 loc) · 3.12 KB
/
yac8e.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
#!/usr/bin/env python
"""
Copyright (C) 2024 Craig Thomas
This project uses an MIT style license - see LICENSE for details.
A simple Chip 8 emulator - see the README file for more information.
"""
# I M P O R T S ###############################################################
import argparse
import os
# G L O B A L S ###############################################################
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
# F U N C T I O N S ##########################################################
def parse_arguments():
"""
Parses the command-line arguments passed to the emulator.
:return: the parsed command-line arguments
"""
parser = argparse.ArgumentParser(
description="Starts a simple Chip 8 "
"emulator. See README.md for more information, and LICENSE for "
"terms of use.")
parser.add_argument(
"rom", help="the ROM file to load on startup")
parser.add_argument(
"--scale", help="the scale factor to apply to the display "
"(default is 5)", type=int, default=5, dest="scale")
parser.add_argument(
"--delay", help="sets the CPU operation to take at least "
"the specified number of milliseconds to execute (default is 1)",
type=int, default=1, dest="op_delay")
parser.add_argument(
"--shift_quirks", help="Enable shift quirks",
action="store_true", dest="shift_quirks"
)
parser.add_argument(
"--index_quirks", help="Enable index quirks",
action="store_true", dest="index_quirks"
)
parser.add_argument(
"--jump_quirks", help="Enable jump quirks",
action="store_true", dest="jump_quirks"
)
parser.add_argument(
"--clip_quirks", help="Enable screen clipping quirks",
action="store_true", dest="clip_quirks"
)
parser.add_argument(
"--logic_quirks", help="Enable logic quirks",
action="store_true", dest="logic_quirks"
)
parser.add_argument(
"--mem_size", help="Maximum memory size (64K default)",
dest="mem_size", choices=["4K", "64K"], default="64K"
)
parser.add_argument(
"--trace", help="print registers and instructions to STDOUT",
action="store_true", dest="trace"
)
parser.add_argument(
"--color_0", help="the hex color to use for the background (default=000000)",
dest="color_0", default="000000"
)
parser.add_argument(
"--color_1", help="the hex color to use for bitplane 1 (default=ff33cc)",
dest="color_1", default="ff33cc"
)
parser.add_argument(
"--color_2", help="the hex color to use for bitplane 2 (default=33ccff)",
dest="color_2", default="33ccff"
)
parser.add_argument(
"--color_3", help="the hex color to use for bitplane overlaps (default=FFFFFF)",
dest="color_3", default="FFFFFF"
)
return parser.parse_args()
# M A I N #####################################################################
if __name__ == "__main__":
from chip8.emulator import main_loop
main_loop(parse_arguments())
# E N D O F F I L E #######################################################