"""Full-mission replay through the C core: all 26,422 cap7 commands. Must reproduce the known-good replayed dict; reports wall time.""" import sys, os, time HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) sys.path.insert(0, os.path.dirname(HERE)) sys.path.insert(0, r'C:\VWE\TeslaRel410\dpl3-revive\patha') import emu860, emu_main, emu860c from driver import boot, CpuShim emu860.Mem.log = lambda self, *a, **k: None t_boot = time.time() r = boot() shim = CpuShim() print("boot+copy: %.1fs" % (time.time() - t_boot), flush=True) t0 = time.time() hooks = 0 while True: reason, steps = emu860c.run(2_000_000_000) if reason == 0: pc = emu860c.getstate()['pc'] h = r.hooks.get(pc) if h is None: print("sentinel: main returned", flush=True) break hooks += 1 if h(shim) == 'done': print("capture exhausted", flush=True) break continue if reason == 1: print("STOP pc=%#x msg?" % emu860c.getstate()['pc'], flush=True) break if reason == 2: st = emu860c.getstate() print("FP fallback pc=%#x w=%08x" % (st['pc'], emu860c.r32(st['pc'])), flush=True) break if reason == 3: print("budget exhausted", flush=True) break dt = time.time() - t0 st = emu860c.getstate() print("MISSION: %d commands, %d steps, %d hook services in %.1fs = %d steps/s" % (r.qi, st['steps'], hooks, dt, st['steps'] / max(dt, 1e-9)), flush=True) print("replayed:", r.done, flush=True) BASE = {'init': 1, 'create': 124, 42: 124, 'flush': 250, 'dcs_link': 2, 'list_add': 107, 'set_texmap_texels': 101, 25: 23, 28: 3, 29: 16793, 'draw_scene': 8397} norm = {(k if isinstance(k, int) else str(k)): v for k, v in r.done.items()} basen = {(k if isinstance(k, int) else str(k)): v for k, v in BASE.items()} print("BASELINE MATCH:", norm == basen, flush=True)