-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
46 lines (35 loc) · 1.19 KB
/
game.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
import ctypes
import sys
def main(dll_path: str, rom: str):
dll = ctypes.CDLL(dll_path)
dll.CreateInteractiveConsole.argtypes = [ctypes.c_char_p]
dll.CreateInteractiveConsole.restype = ctypes.c_void_p
dll.Done.argtypes = [ctypes.c_void_p]
dll.Done.restype = ctypes.c_bool
dll.StepFrame.argtypes = [ctypes.c_void_p]
dll.HandleInteraction.argtypes = [ctypes.c_void_p]
dll.UpdateButtons.argtypes = [ctypes.c_void_p, ctypes.c_uint8]
dll.FrameLimit.argtypes = [ctypes.c_void_p]
# load up the console
console = dll.CreateInteractiveConsole(rom.encode("utf8"))
# skip ahead 10s
frame = 0
while not dll.Done(console):
dll.StepFrame(console)
dll.HandleInteraction(console)
frame += 1
if frame > 60 * 15:
# A = 0,
# B = 1,
# Select = 2,
# Start = 3,
# Up = 4,
# Down = 5,
# Left = 6,
# Right = 7,
# dll.UpdateButtons(console, frame % 60 == 2)
pass
dll.FrameLimit(console)
if __name__ == "__main__":
# DLL, ROM
main(sys.argv[1], sys.argv[2])