diff --git a/emulator/firmware-decomp/edge_verify.py b/emulator/firmware-decomp/edge_verify.py new file mode 100644 index 0000000..58c57c5 --- /dev/null +++ b/emulator/firmware-decomp/edge_verify.py @@ -0,0 +1,60 @@ +"""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)) diff --git a/emulator/firmware-decomp/render-readout.html b/emulator/firmware-decomp/render-readout.html index a3c3257..b7add28 100644 --- a/emulator/firmware-decomp/render-readout.html +++ b/emulator/firmware-decomp/render-readout.html @@ -266,10 +266,11 @@ line up into clean ×2 chains0.0079 · 0.016 · 0.032 · 0.063 · 0.126 · 0.252 · 0.504 · 1.009 — a coefficient stored as its binary place values C·2ᵏ, one per - bit-plane, exactly how a bit-serial adder holds a number. The recovered bases match the - object's own edge and z slopes computed from the captured vertices — so the coefficients - feeding the array simulator (§05) are cross-validated against the compiled stream the - hardware actually shipped.

+ bit-plane, exactly how a bit-serial adder holds a number. And the recovered values are the + object's own geometry: a payload edge coefficient (0.12527) lands on + the edge normal computed from the captured vertices (0.12555) to + 0.2%. The coefficients feeding the array simulator (§05) are + the ones the hardware actually shipped.