-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnes.py
More file actions
52 lines (42 loc) · 1.25 KB
/
Copy pathnes.py
File metadata and controls
52 lines (42 loc) · 1.25 KB
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
'''
The entry point for the emulator
'''
from cpu import cpu
import ppu
import cartridge
import cProfile
import pstats
import StringIO
class NES(object):
def __init__(self, rom=None, display=None):
if rom:
self.ppu = ppu.PPU(self, display)
self.rom = cartridge.Cartridge(self, rom)
self.cpu = cpu.CPU(self, self.rom)
self.halt_cpu = 0
self.power_up()
else:
self.rom = None
self.cpu = cpu.CPU(self, self.rom)
self.ppu = ppu.PPU(self)
self.halt_cpu = 0
def power_up(self):
self.cpu.set_reset_vector()
def save_state(self):
pass
def load_state(self):
pass
def step(self):
if not self.halt_cpu:
cycles = self.cpu.execute()
else:
cycles = 1
self.halt_cpu -= 1
for i in range(3 * cycles):
self.ppu.step()
def load_rom(self, rom_data):
self.rom = cartridge.Cartridge(self, rom_data)
# self.cpu.set_reset_vector()
def parse_input(self, gamepad, button, updown):
print "Button {} {}".format(button, "pressed" if updown else "released")
self.cpu.controller.button_change(gamepad, button, updown)