Files
TeslaRel410/emulator/firmware-decomp/emu860c/mission.py
T
CydandClaude Opus 4.8 cff783d2ad Full-mission replay through the C core: 26,422 commands / 3.49B steps in 39s
The complete cap7 mission -- every command, all 8,562 draws -- executes in
39 seconds at 89.6M steps/s sustained (199,857 Python hook services). The
replayed dict matches the QUEUE ground truth exactly; the old 'baseline'
dict (16793/8397) is exposed as a budget-truncated artifact: the historic
Python regressions hit the 2e9-step budget ~96% through and silently
dropped the last 497 commands. This is the first complete execution of the
whole mission. + M4-LIVE-SEAM.md (the remaining path to live DOSBox) and
emu860c.step1() for hook-driven single-steps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 13:37:38 -05:00

54 lines
1.9 KiB
Python

"""Full-mission replay through the C core: all 26,422 cap7 commands.
Must reproduce the known-good replayed dict; reports wall time."""
import sys, os, time
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
sys.path.insert(0, os.path.dirname(HERE))
sys.path.insert(0, r'C:\VWE\TeslaRel410\dpl3-revive\patha')
import emu860, emu_main, emu860c
from driver import boot, CpuShim
emu860.Mem.log = lambda self, *a, **k: None
t_boot = time.time()
r = boot()
shim = CpuShim()
print("boot+copy: %.1fs" % (time.time() - t_boot), flush=True)
t0 = time.time()
hooks = 0
while True:
reason, steps = emu860c.run(2_000_000_000)
if reason == 0:
pc = emu860c.getstate()['pc']
h = r.hooks.get(pc)
if h is None:
print("sentinel: main returned", flush=True)
break
hooks += 1
if h(shim) == 'done':
print("capture exhausted", flush=True)
break
continue
if reason == 1:
print("STOP pc=%#x msg?" % emu860c.getstate()['pc'], flush=True)
break
if reason == 2:
st = emu860c.getstate()
print("FP fallback pc=%#x w=%08x" % (st['pc'], emu860c.r32(st['pc'])), flush=True)
break
if reason == 3:
print("budget exhausted", flush=True)
break
dt = time.time() - t0
st = emu860c.getstate()
print("MISSION: %d commands, %d steps, %d hook services in %.1fs = %d steps/s" %
(r.qi, st['steps'], hooks, dt, st['steps'] / max(dt, 1e-9)), flush=True)
print("replayed:", r.done, flush=True)
BASE = {'init': 1, 'create': 124, 42: 124, 'flush': 250, 'dcs_link': 2,
'list_add': 107, 'set_texmap_texels': 101, 25: 23, 28: 3, 29: 16793,
'draw_scene': 8397}
norm = {(k if isinstance(k, int) else str(k)): v for k, v in r.done.items()}
basen = {(k if isinstance(k, int) else str(k)): v for k, v in BASE.items()}
print("BASELINE MATCH:", norm == basen, flush=True)