import sys, time from famicom_python.dual import VsDualSystem from famicom_python.video import machine_palette, to_rgb, write_png rom, frames, out = sys.argv[1], int(sys.argv[2]), sys.argv[3] coin = int(sys.argv[4]) if len(sys.argv) > 4 else None d = VsDualSystem.from_rom(rom) t=time.time() for f in range(frames): if coin is not None and f == coin: d.insert_coin(0); d.insert_coin(1) press = coin is not None and coin+90 <= f < coin+98 for s in d.sides: for p in s.board.pads: p.buttons = 0x04 if press else 0 d.run_frames(1) pal = machine_palette(d.machine.timing) a, b = d.pictures rows = b"".join(to_rgb(a[y*256:(y+1)*256], pal) + to_rgb(b[y*256:(y+1)*256], pal) for y in range(240)) write_png(out, rows, 512, 240) print(d.machine.name, 'resets', d.watchdog_resets, 'pcs', hex(d.primary.cpu.pc), hex(d.secondary.cpu.pc), 'coins', [s.board.vs.coins_counted for s in d.sides], round(time.time()-t), 's', 'owner', d.ram.owner)