"""Numeric verification of the edge decode. The edge SEND payloads carry floats ~0.1262. Edges are pure screen-space (no z ambiguity), so if 0.1262 matches an object edge's line coefficient computed from the captured screen vertices, the edge decode is confirmed. Try normalised normal, raw dy/dx, and dx/len forms.""" import sys, time, struct, pickle, math sys.path.insert(0, r'C:\VWE\TeslaRel410\emulator\firmware-decomp') import emu860, dis860, emu_main emu860.Mem.log = lambda self, *a, **k: None S = r'C:\Users\cyd\AppData\Local\Temp\claude\c--VWE-TeslaRel410\4e848c76-6e89-4034-8047-d8d491cb32d8\scratchpad' snap = pickle.load(open(S + r'\snapv2.pkl', 'rb')) r = emu_main.MainRunner(r'C:\VWE\TeslaRel410\dpl3-revive\patha\cap7.raw.bin', fw='capfw7', max_cmds=6000) cpu = r.cpu cpu.mem.pages = {k: bytearray(v) for k, v in snap['pages'].items()} cpu.ctrl.clear(); cpu.ctrl.update(snap['ctrl']) cpu.r = list(snap['r']); cpu.f = list(snap['f']); cpu.cr = dict(snap['cr']); cpu.pc = snap['pc'] cpu._apipe = list(snap['apipe']); cpu._mpipe = list(snap['mpipe']); cpu._fp_pipes() cpu._lpipe = list(snap['lpipe']); cpu._gpipe = list(snap['gpipe']) cpu._kr, cpu._ki, cpu._t = snap['kr'], snap['ki'], snap['t'] cpu.lcc = snap['lcc']; r.qi = snap['qi']; r.heap = list(snap['heap']) t0 = time.time(); startq = r.qi while time.time() - t0 < 60: if r.qi >= startq + 2: break h = r.hooks.get(cpu.pc) if h: if h(cpu) == 'done': break continue if not cpu.step(): break def rw(a): return cpu.mem.r32(a & 0xffffffff) def asf(w): return struct.unpack(' candidate coefficient forms objs = pickle.load(open(S + r'\vfull.pkl', 'rb'))['objs'] allv = [v for o in objs for v in o] xs = sorted(set(round(v['mx'], 2) for v in allv)); zs = sorted(set(round(v['mz'], 2) for v in allv)) grid = {(round(v['mx'], 2), round(v['mz'], 2)): v for v in allv} cands = [] # (value, form, edge desc) for i in range(len(xs)-1): for j in range(len(zs)-1): tri = [grid[(xs[i],zs[j])], grid[(xs[i+1],zs[j])], grid[(xs[i],zs[j+1])]] for k in range(3): p, q = tri[k], tri[(k+1)%3] dx = q['sx']-p['sx']; dy = q['sy']-p['sy']; L = math.hypot(dx,dy) or 1 cands.append((abs(dy/L), 'norm|A|')) # normalised normal x-comp cands.append((abs(dx/L), 'norm|B|')) # normalised normal y-comp # match each payload edge float to nearest candidate print("\nmatches:") for ef in sorted(edge_floats, key=abs): best = min(cands, key=lambda c: abs(abs(ef)-c[0])) err = abs(abs(ef)-best[0]) / max(abs(ef), 1e-6) * 100 print(" payload %.5f ~ %.5f (%s) err %.1f%%" % (ef, best[0], best[1], err))