"""Liveness probe: boot a capture, run ~30 draws, count per-draw hits at the known polygon sites. quadA=4/draw = background-only (dead, like ravtest); anything more (triB, VSTRIP, emitH>>12, quadA>4) = real scene content. Usage: probe_live.py """ import sys, time, struct, pickle, collections sys.path.insert(0, r'C:\VWE\TeslaRel410\emulator\firmware-decomp') sys.path.insert(0, r'C:\VWE\TeslaRel410\dpl3-revive\patha') import emu860, dis860, emu_main from vrboard import A emu860.Mem.log = lambda self, *a, **k: None CAP = sys.argv[1] NDRAW = int(sys.argv[2]) if len(sys.argv) > 2 else 30 r = emu_main.MainRunner(r'C:\VWE\TeslaRel410\dpl3-revive\patha\%s.raw.bin' % CAP, fw='capfw7', max_cmds=20000) cpu = r.start() DRAW = int(A.draw_scene) draw_idx = [i for i, (a, p) in enumerate(r.queue) if a == DRAW] stop_at = draw_idx[NDRAW - 1] + 2 if len(draw_idx) >= NDRAW else len(r.queue) print("%s: %d cmds, %d draws, first at %s; probing through cmd %d" % (CAP, len(r.queue), len(draw_idx), draw_idx[:3], stop_at), flush=True) SITES = {0xf0418a30: 'quadA', 0xf0418500: 'triB', 0xf041d148: 'emitH', 0xf041614c: 'VSTRIP'} percmd = collections.defaultdict(collections.Counter) t0 = time.time() while time.time() - t0 < 700: pc = cpu.pc s = SITES.get(pc) if s: percmd[r.qi][s] += 1 if r.qi >= stop_at: break h = r.hooks.get(pc) if h: if h(cpu) == 'done': break continue if not cpu.step(): break print("%s probed to cmd %d in %.0fs" % (CAP, r.qi, time.time() - t0)) tot = collections.Counter() for qi, c in sorted(percmd.items()): tot.update(c) print("%s TOTALS over %d cmds: %s" % (CAP, len(percmd), dict(tot))) rich = [(qi, dict(c)) for qi, c in sorted(percmd.items()) if c.get('triB', 0) or c.get('VSTRIP', 0) or c.get('quadA', 0) > 4 or c.get('emitH', 0) > 12] print("%s RICH cmds: %s" % (CAP, rich[:12] if rich else "NONE - background only"))