-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (31 loc) · 849 Bytes
/
main.py
File metadata and controls
39 lines (31 loc) · 849 Bytes
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
import cpu
import memory
import screen
import pygame
def read_ROM(filename):
try:
with open(filename,"rb") as f:
file = f.read()
file_bytes = bytearray(file)
return file_bytes
except FileNotFoundError:
print("File not found")
except Exception as e:
print(e)
def main():
processor = cpu.CPU()
mem = memory.Memory()
disp = screen.Screen()
delay_timer = bytearray(1)
sound_timer = bytearray(1)
instruction_set = read_ROM("ROMs/CHIP-8 logo.ch8")
mem.write(0x200,len(instruction_set), instruction_set)
cpu.pc = 0x200
print("\n",mem.memory.hex())
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if __name__ == "__main__":
main()