payload_scan_mid.py scans a mid-mission frame (snapfull1, cmd 19,889): identical 9 coordinates as cmd 735 (65.5/72/181/236, all x[66,236]). So cap7 redraws the same static surface patch every frame across its whole length -- no terrain, no battle, ever. Corrects the earlier "mid-mission frames have battle scenes" guess: a full battle scene lives in a different capture entirely. Readout last-mile updated. The decode + array render fully account for cap7's content. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
72 lines
3.0 KiB
Python
72 lines
3.0 KiB
Python
"""Decisive test: does a MID-MISSION cap7 frame carry a full battle scene (terrain)?
|
|
Restore snapfull1 (cmd 19889, paused mid-draw) and scan payload-region writes the same
|
|
way. If screen coords spread across x[0,832] there IS terrain to render; if they cluster
|
|
or are absent, cap7's mid-mission draws are empty and full-battle frames need another capture."""
|
|
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'\snapfull1.pkl', 'rb'))
|
|
r = emu_main.MainRunner(r'C:\VWE\TeslaRel410\dpl3-revive\patha\cap7.raw.bin', fw='capfw7', max_cmds=60000)
|
|
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
|
|
def asf(w): return struct.unpack('<f', struct.pack('<I', w))[0]
|
|
|
|
# first: snapshot the CURRENT payload-region coords (this draw already compiled some)
|
|
def scan_now():
|
|
cs = []
|
|
for a in range(LO, HI, 4):
|
|
w = cpu.mem.r32(a)
|
|
if 0 < w < 0x10000:
|
|
v = w / 256.0
|
|
if 10.0 <= v <= 832.0: cs.append(round(v, 1))
|
|
return cs
|
|
cur = scan_now()
|
|
print("payload coords present at restore (cmd %d): %d, range %s" %
|
|
(snap['qi'], len(cur), ("[%.0f,%.0f]" % (min(cur), max(cur))) if cur else "none"))
|
|
|
|
coords = []; nwrite = 0
|
|
orig = emu860.Mem.w32
|
|
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(round(v, 1))
|
|
return orig(self, addr, val)
|
|
emu860.Mem.w32 = w32
|
|
t0 = time.time(); startq = r.qi
|
|
while time.time() - t0 < 200:
|
|
if r.qi >= startq + 6: break # a few draws
|
|
h = r.hooks.get(cpu.pc)
|
|
if h:
|
|
if h(cpu) == 'done': break
|
|
continue
|
|
if not cpu.step(): break
|
|
emu860.Mem.w32 = orig
|
|
|
|
allc = cur + coords
|
|
print("payload writes over cmds %d..%d: %d coord-like total: %d" % (startq, r.qi, nwrite, len(allc)))
|
|
if allc:
|
|
import collections
|
|
print("coord range: [%.0f..%.0f] distinct: %d" % (min(allc), max(allc), len(set(allc))))
|
|
hist = collections.Counter(int(c // 40) * 40 for c in allc); mx = max(hist.values())
|
|
print("spread (buckets of 40, x to 832):")
|
|
for b in range(0, 833, 40):
|
|
n = hist.get(b, 0)
|
|
if n: print(" %3d: %s %d" % (b, '#' * min(50, int(n/mx*50)+1), n))
|
|
else:
|
|
print("NO payload geometry in this mid-mission frame -> draws are empty here.")
|