-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.py
85 lines (33 loc) · 933 Bytes
/
Main.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
import time
from CPU import CPU
from GPU import GPU
from Memory import Memory
RUNNING = True
STEP = False
# Memory Init
Memory = Memory("TETRIS.gb")
# CPU Init
CPU = CPU(Memory)
CPU.DEBUG = False
# GPU Init, pass in the memory that has been initialized in the CPU
GPU = GPU(Memory)
time_display = time.clock()
while RUNNING:
cycles_before = CPU.cycles
CPU.fetch()
if CPU.PC >= 0x100:
print("0x" + hex(CPU.PC)[2:].zfill(4).upper() + " : ", end="")
CPU.decode()
print(CPU.debug_string + " ",end="")
for i in range(0,CPU.instruction_length-1):
print(hex(CPU.args[i])[2:].zfill(2).upper() + " ", end="")
print("")
CPU.print_registers()
#input()
else:
CPU.decode()
CPU.execute()
cycles_after = CPU.cycles
cycles_passed = cycles_after - cycles_before
GPU.update(cycles_passed)
#