payload_scan.py scans all writes into the payload region across the draw: 14,223 writes, every recoverable screen coordinate in x[66,236] = the object's range, nothing near 0/400/832. So this death-cam frame carries no geometry beyond the object -- the ~64 triangles account for essentially all payload writes; the rest is a background clear. The "ground and sky still to render" was a wrong premise for THIS frame: the array's object render IS this frame's geometry. Wider battle scenes with terrain live in mid-mission frames (a separate capture). Readout §05 + last-mile updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
69 lines
3.0 KiB
Python
69 lines
3.0 KiB
Python
"""Robustly capture the frame's geometry footprint from the compiled micro-code.
|
|
Hook EVERY write into the payload region (0x08014000..0x08019000) across the whole draw
|
|
and record two things per write: fixed-point screen coords (v<0x10000, v/256 in [10,832])
|
|
and edge/plane slope floats. No dedup, no timing assumption -> we see every primitive's
|
|
screen constants as they're compiled. If they spread across x[0,832] there is terrain."""
|
|
import sys, time, struct, pickle
|
|
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'])
|
|
|
|
LO, HI = 0x08014000, 0x08019000
|
|
coords = [] # (addr, screen_value)
|
|
slopes = []
|
|
nwrite = 0
|
|
orig = emu860.Mem.w32
|
|
def asf(w): return struct.unpack('<f', struct.pack('<I', w))[0]
|
|
def w32(self, addr, val):
|
|
global nwrite
|
|
a = addr & 0xffffffff
|
|
if LO <= a < HI:
|
|
nwrite += 1
|
|
w = val & 0xffffffff
|
|
if 0 < w < 0x10000:
|
|
v = w / 256.0
|
|
if 10.0 <= v <= 832.0:
|
|
coords.append((a, round(v, 1)))
|
|
else:
|
|
f = asf(w); e = (w >> 23) & 0xff
|
|
if 1e-4 < abs(f) < 1.0 and 1 < e < 254:
|
|
slopes.append(round(f, 5))
|
|
return orig(self, addr, val)
|
|
emu860.Mem.w32 = w32
|
|
|
|
t0 = time.time(); startq = r.qi
|
|
while time.time() - t0 < 200:
|
|
if r.qi >= startq + 3 and nwrite > 0: break # finish the first draw's compile
|
|
h = r.hooks.get(cpu.pc)
|
|
if h:
|
|
if h(cpu) == 'done': break
|
|
continue
|
|
if not cpu.step(): break
|
|
emu860.Mem.w32 = orig
|
|
|
|
cv = [c[1] for c in coords]
|
|
print("payload-region writes: %d coord-like: %d slope-like: %d (cmd %d)" %
|
|
(nwrite, len(coords), len(slopes), r.qi))
|
|
if cv:
|
|
print("coord range: [%.0f .. %.0f] distinct: %d" % (min(cv), max(cv), len(set(cv))))
|
|
import collections
|
|
hist = collections.Counter(int(c // 32) * 32 for c in cv)
|
|
print("\nscreen-coord spread (buckets of 32, x up to 832):")
|
|
mx = max(hist.values())
|
|
for b in range(0, 833, 32):
|
|
n = hist.get(b, 0)
|
|
if n: print(" %3d: %s %d" % (b, '#' * min(50, int(n / mx * 50) + 1), n))
|
|
print("\ndistinct coords:", sorted(set(cv)))
|
|
pickle.dump({'coords': coords, 'slopes': slopes}, open(S + r'\payload_scan.pkl', 'wb'))
|