def __init__(self): super().__init__() nes = Nes() nes.load('roms/mario.nes') # configure ppu self._ppu_bus = Bus() self._ppu_pattern = PatternTable() self._ppu_pattern.load(nes.chr) self._ppu_name = NameTable() self._ppu_palette = PaletteTable() self._ppu_bus.connect(self._ppu_pattern) self._ppu_bus.connect(self._ppu_name) self._ppu_bus.connect(self._ppu_palette) self._ppu = Ppu(self._ppu_bus) # configure cpu self._cpu_ram = Ram() self._pgr = PGRRom() self._pgr.load(nes.pgr) self._papu_ram = PAuExp() self._cpu_bus = Bus() self._cpu_bus.connect(self._pgr) self._cpu_bus.connect(self._cpu_ram) self._cpu_bus.connect(self._papu_ram) self._cpu_bus.connect(self._ppu.get_register()) self._cpu = Cpu6502(self._cpu_bus) self._cpu.reset() self._ppu.set_request_nmi(self._cpu.request_nmi) self._addr_map, self._code = self._cpu.decode(0x8000, 0xFF00) self._font = pygame.font.SysFont('inconsolatan', 24) self._cpu_running = False self._cpu_time_last = 0
def ppu_test(): nes = Nes() nes.load('roms/mario.nes') chr_rom = CHRRom() chr_rom.load(nes.chr) v_ram = VRam()
def main(): _ppu_bus = Bus() _ppu_pattern = PatternTable() # _ppu_pattern.load(nes.chr) _ppu_name = NameTable() _ppu_palette = PaletteTable() _ppu_bus.connect(_ppu_pattern) _ppu_bus.connect(_ppu_name) _ppu_bus.connect(_ppu_palette) _ppu = Ppu(_ppu_bus) ram = Ram() pgr = PGRRom() ppu_reg = PPURegister(_ppu_bus) pau_exp = PAuExp() nes = Nes() nes.load('roms/nestest.nes') pgr.load(nes.pgr) bus = Bus() bus.connect(pgr) bus.connect(ram) bus.connect(pau_exp) bus.connect(ppu_reg) cpu = Cpu6502(bus) cpu.test_mode() real_log = Log() n = 0 while True: n += 1 log = cpu.log() if not real_log.check(log): # print('F: {}'.format(OrderedDict(log))) # print('T: {}'.format(OrderedDict(real_log.log()))) # print('{} Addr: {}, Data: {}'.format(n, cpu._addr, cpu._data)) break else: pass # print('T: {}'.format(OrderedDict(log))) cpu.run() end = real_log.next() if end: break print('{} ins passed'.format(n))
from pprint import pprint from nes import Nes emulator = Nes() emulator.load('../roms/tutor.nes') pprint(emulator.__dict__)
# #for i in range(100): # surf[i][10:51] = screen.map_rgb((0, 255, 0)) # #s = screen.map_rgb((0, 255, 0)) #pygame.display.update() #while True: # for event in pygame.event.get(): # if event.type == pygame.QUIT: # break # from nes import Nes import pygame nes = Nes() nes.loadRom('test.nes') nes.start() eventCheckCount = 0 while nes.isRunning: eventCheckCount += 1 if eventCheckCount >= 10000: for event in pygame.event.get(): if event.type == pygame.QUIT: nes.stop() break eventCheckCount = 0 nes.cpu.emulate()
import yaml from nes import Nes, CartridgeFactory if __name__ == '__main__': config = yaml.load(open('config.yaml', 'rt'), Loader=yaml.FullLoader) cart = CartridgeFactory.create('nestest.nes') nes = Nes(config) nes.insert_cartridge(cart) for i in range(32): nes.buses['ppu'].write(0x3F00 + i, i) nes.startup() nes.main_loop() nes.shutdown()