"""THE TRUE FRAME, attempt 1: walk the bin-page chains (trek_wide30) region by region; for each content SEND (payloads at 0x815xxxx+, from trek_content30) parse the payload, extract float coefficients, reconstruct edge triples -> triangle vertices (pairwise line intersection), place by the region's TILE origin, plot everything.""" import pickle, struct, collections S = r'C:\Users\cyd\AppData\Local\Temp\claude\c--VWE-TeslaRel410\4e848c76-6e89-4034-8047-d8d491cb32d8\scratchpad' wide = pickle.load(open(S + r'\trek_wide30.pkl', 'rb'))['mem'] content = pickle.load(open(S + r'\trek_content30.pkl', 'rb'))['mem'] def asf(w): return struct.unpack('> 23) & 0xff return 1 < e < 254 and 1e-6 < abs(asf(w)) < 1e6 # 1) per-region chains from bin pages: collect (send_addr, size) + tile id per page OPS = {0x1: 'SEND', 0x9: 'SENDE', 0x2: 'TILE', 0x3: 'TXDN', 0x6: 'FLUSH', 0x0: 'GOTO', 0xf: 'STOP', 0x8: 'WAIT'} regions = [] # (page, tile_id, [(addr,size,op)]) for page_base in sorted(set(a & ~0xfff for a in wide if a >= 0x0801e000)): sends = []; tile = None a = page_base while a < page_base + 0x800: w0 = wide.get(a); w1 = wide.get(a + 4) if w0 is None or w1 is None: a += 8; continue code = (w1 >> 28) & 0xf name = OPS.get(code) if name in ('SEND', 'SENDE') and w0 >= 0x08000000: sends.append((w0, w1 & 0x7f, name)) elif name == 'TILE': tile = w0 a += 8 if sends: regions.append((page_base, tile, sends)) print("regions with sends: %d" % len(regions)) # 2) parse content payloads: floats per block def parse_payload(addr, size): floats = [] for i in range(size): w = content.get(addr + i * 4) if w is None: w = wide.get(addr + i * 4) if w is None: continue if isf(w): floats.append((i, asf(w))) return floats # 3) reconstruct: for each region, each content send -> triangle from edge triples def isect(e1, e2): (a1, b1, c1), (a2, b2, c2) = e1, e2 d = a1 * b2 - a2 * b1 if abs(d) < 1e-9: return None return ((b1 * c2 - b2 * c1) / d, (a2 * c1 - a1 * c2) / d) tris = [] # (tile, [(x,y)..]) stats = collections.Counter() sample_shown = 0 for page, tile, sends in regions: for addr, size, op in sends: if 0x08014000 <= addr < 0x08018000: stats['std'] += 1; continue stats['content'] += 1 fl = parse_payload(addr, size) if sample_shown < 3 and len(fl) >= 6: print("\nsample payload @%08x size=%d tile=%s floats:" % (addr, size, tile)) for i, f in fl[:12]: print(" +%02x %.6g" % (i * 4, f)) sample_shown += 1 # edge-triple attempt: first 9 floats as 3x(A,B,C) vals = [f for _, f in fl] if len(vals) >= 9: e = [tuple(vals[k*3:k*3+3]) for k in range(3)] pts = [isect(e[0], e[1]), isect(e[1], e[2]), isect(e[2], e[0])] if all(p and -200 < p[0] < 200 and -200 < p[1] < 200 for p in pts): tris.append((tile, pts)) print("\nstats:", dict(stats), " reconstructed tris:", len(tris)) if tris: # place by tile origin: id=(row<<5)|col W, H = 832, 512 canvas = [[0]*104 for _ in range(40)] for tile, pts in tris: ox = ((tile or 0) & 0x1f) * 64; oy = (((tile or 0) >> 5) & 0x1f) * 128 for x, y in pts: gx = int((ox + x) / W * 103); gy = int((oy + y) / H * 39) if 0 <= gx < 104 and 0 <= gy < 40: canvas[gy][gx] += 1 print("vertex scatter (tile-placed):") mx = max(max(r) for r in canvas) or 1 for row in canvas: print(" " + "".join(" .:-=+*#%@"[min(9, int(c/mx*9.99))] if c else " " for c in row))