Bring the graphics-dev collaborator's dpl3-revive into the repo as first-class
project code (they've handed it off; it's ours now). This is the proven
Division renderer that our in-process rt_draw has been trying to be.
What's here:
- parser/ B2Z/V2Z/SVT/SCN/SPL/BGF/BMF/BSL decoders (pure Python).
- spec/ reverse-engineered format + the definitive VelociRender wire
protocol (from the original DIVISION source, matches our live
VPX node/action tables exactly).
- source-ref/ read-only copies of the original DIVISION C (BIZREAD.C,
DPLTYPES.H, DPL.H) that define the formats.
- patha/ the "virtual VelociRender board": vrboard.py (24-action protocol
server), vrview.py (numpy software rasterizer, the reference),
vrview_gl.py (moderngl GPU backend, 832x512@60Hz), plus the
run/replay/regress tooling and evidence renders. Drives FLYK/BLADE/
Star Trek demos AND our btl4opt/rpl4opt game binaries.
- viewer/ WebGL archive generators (.py); prebuilt HTML/data regeneratable.
- samples/ small test models/textures.
- bt*.raw.bin real BTL4OPT arena wire captures (kept for offline renderer
testing/regression against OUR game).
.gitignore keeps the multi-hundred-MB demo capture dumps + debug logs +
regeneratable viewer bundles out of history (they stay on disk).
Phase 0 of the integration is validated: their board decodes our bt8 capture
with zero errors (3748 nodes, 507 instances, 4 mechs) and renders our arena
(terrain/dome/sky, correct Division DAC gamma). Plan + status in memory;
integration continues in emulator/RENDERER-COLLAB.md.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
95 lines
3.8 KiB
Python
95 lines
3.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
analyze_scene.py -- decode the live scene graph FLYK streams to the board.
|
|
|
|
Parses the framed region of capture.raw.bin (skipping the raw .BTL boot), tracks
|
|
create/flush per handle, and dumps the DPL node structs (VIEW camera, DCS matrices,
|
|
INSTANCE placements, MATERIAL colours) plus the mystery 0x1c/0x1d ops -- so we can
|
|
feed the dpl3-revive renderer.
|
|
|
|
python analyze_scene.py [capture.raw.bin]
|
|
"""
|
|
import sys, struct
|
|
from vrboard import Assembler, A
|
|
|
|
TYPE = {2:'zone',3:'view',4:'instance',5:'dcs',6:'lmodel',7:'light',8:'object',
|
|
9:'lod',10:'geogroup',11:'geometry',12:'material',13:'texmap',14:'texture',15:'ramp'}
|
|
|
|
def floats(b, n=None):
|
|
n = n if n else len(b)//4
|
|
return list(struct.unpack_from('<%df' % n, b, 0))
|
|
|
|
def main():
|
|
path = sys.argv[1] if len(sys.argv) > 1 else "capture.raw.bin"
|
|
data = open(path, "rb").read()
|
|
# find framed start: first 0x40ff00NN length word past the BTL
|
|
start = None
|
|
for i in range(80000, len(data)-8):
|
|
w = struct.unpack_from('<I', data, i)[0]
|
|
if (w & 0xffff0000) == 0x40ff0000 and 8 <= (w & 0xffff) <= 1024:
|
|
act = struct.unpack_from('<I', data, i+4)[0]
|
|
if act in (A.init, A.code860, A.args860, A.data860, A.bss860):
|
|
start = i; break
|
|
print(f"framed region starts @ {start}")
|
|
asm = Assembler(); asm.feed(data[start:])
|
|
|
|
nodes = {} # handle -> {'type':.., 'body':..}
|
|
creates = []
|
|
op1c, op1d = [], []
|
|
for m in asm:
|
|
if m.iserver: continue
|
|
a, p = m.action, m.payload
|
|
if a == A.create:
|
|
typ = struct.unpack_from('<I', p, 0)[0]
|
|
h = struct.unpack_from('<I', p, 4)[0] if len(p) >= 8 else 0
|
|
nodes.setdefault(h, {})['type'] = typ
|
|
creates.append((h, typ))
|
|
elif a == A.flush:
|
|
h = struct.unpack_from('<I', p, 0)[0]
|
|
nodes.setdefault(h, {})['body'] = p
|
|
elif a == 0x1c: op1c.append(p)
|
|
elif a == 0x1d: op1d.append(p)
|
|
|
|
print(f"\nnodes: {len(nodes)} creates: {len(creates)} 0x1c: {len(op1c)} 0x1d: {len(op1d)}\n")
|
|
by_type = {}
|
|
for h, n in nodes.items():
|
|
by_type.setdefault(TYPE.get(n.get('type'), n.get('type')), []).append(h)
|
|
print("by type:", {k: len(v) for k, v in by_type.items()})
|
|
|
|
def show(h):
|
|
n = nodes[h]; t = TYPE.get(n.get('type'), n.get('type'))
|
|
body = n.get('body', b'')
|
|
print(f"\n--- handle {h:#x} type={t} body={len(body)}B ---")
|
|
# body = [remote:4][type_check:4][struct-specific...]
|
|
if len(body) >= 8:
|
|
rem, tc = struct.unpack_from('<II', body, 0)
|
|
print(f" remote={rem:#x} type_check={tc}")
|
|
rest = body[8:]
|
|
if t == 'dcs' and len(rest) >= 68: # node(4) + matrix(64)
|
|
mat = floats(rest[4:68], 16)
|
|
for r in range(4):
|
|
print(" [" + " ".join(f"{mat[r*4+c]:8.3f}" for c in range(4)) + "]")
|
|
elif t == 'view' and len(rest) >= 64:
|
|
mat = floats(rest[0:64], 16)
|
|
print(" camera matrix:")
|
|
for r in range(4):
|
|
print(" [" + " ".join(f"{mat[r*4+c]:8.3f}" for c in range(4)) + "]")
|
|
tail = floats(rest[64:64+13*4]) if len(rest) >= 64+52 else []
|
|
print(" view params (enable,x0,y0,x1,y1,zeye,xs,ys,hither,yon,bg3...):")
|
|
print(" ", [round(v,3) for v in tail])
|
|
else:
|
|
print(" floats:", [round(v,3) for v in floats(rest[:min(64,len(rest))])])
|
|
|
|
for t in ('view', 'dcs', 'instance', 'material'):
|
|
hs = by_type.get(t, [])
|
|
if hs:
|
|
show(hs[0])
|
|
|
|
if op1c:
|
|
print(f"\n0x1c sample ({len(op1c[0])}B):", op1c[0].hex())
|
|
if op1d:
|
|
p = op1d[0]; print(f"\n0x1d sample ({len(p)}B) as floats:", [round(v,3) for v in floats(p)])
|
|
|
|
if __name__ == '__main__':
|
|
main()
|