Phase 3f: lighting from wire normals; defuse shipped-in debug crash

Lighting: stride-8/9 vertices carry a normal (floats 3-5, uv at 6-7). The
backend transforms normals by the instance rotation and lights with a single
directional sun (GL_LIGHT0, smooth, two-sided, GL_COLOR_MATERIAL). Terrain
and hulls shade instead of reading flat.

LOD: the lod flush has no switch distances -- the host keeps the active LOD
at the child-list head and re-orders over the wire, so children[0] is right
and LOD changes come through as the sim runs.

The crash that halted the game once the RIO drove the sim was not ours: fault
at 0047E1D1 writing 0xFFFFFFFF is the RIO driver's DISABLE_AND_DIE debug
macro (PCSPAK.ASM, DIE_ON_ERROR=1), which deliberately faults on a serial-tx
anomaly -- error 3 = body char >0x7F during a RIO packet, i.e. a glitch on a
board reset. Release build (DIE_ON_ERROR=0) compiles it out and recovers
(and al,07Fh). patch_btl4opt.py NOPs all 12 sites by signature (with .orig
backup) = release behavior; game then survives RIO resets (1200+ frames).
(ALPHA_1 is git-ignored, so the tool ships, not the patched binary.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-03 17:13:46 -05:00
co-authored by Claude Opus 4.8
parent 0bb493dd5f
commit 08f71eb471
5 changed files with 139 additions and 8 deletions
+23 -2
View File
@@ -175,8 +175,29 @@ uploads it to GL keyed by material, and maps it with the wire UVs (stride-5
verts: floats 34; stride-8/9: floats 67). Result: the arena renders with
the ravine's actual brown dirt textures, live (`game-live-textured.png`).
Still to come: lighting from the wire normals, per-frame articulation once
the RIO holds sync, LOD selection by distance.
### 3f. Lighting + the shipped-in debug crash
Lighting: stride-8/9 vertices carry a **normal** at floats 35 (uv at 67).
The backend transforms them by the instance world matrix (rotation only) and
lights with a single directional "sun" (`GL_LIGHT0`, smooth shading,
two-sided, `GL_COLOR_MATERIAL` so texture/material color survives). Terrain
and hulls now shade instead of reading flat.
LOD note: the `lod` flush carries **no switch distances** — the host game
keeps the active LOD at the head of the object's child list and re-orders it
over the wire, so `children[0]` is correct and LOD changes as the sim runs
come through for free.
**The crash that halted the game with the RIO in sync was not ours.** Fault
`Exception 0E at 0047E1D1` writing to `0xFFFFFFFF` is a debug landmine the
build shipped with: the RIO serial driver's `DISABLE_AND_DIE` macro
(`PCSPAK.ASM`, gated by `DIE_ON_ERROR equ 1`) deliberately faults on any
serial-transmit anomaly. Error code 3 = a body char > 0x7F during a RIO
packet (`PCSPAK.ASM:1630`) — i.e. a serial glitch during a board reset. The
release build (`DIE_ON_ERROR equ 0`) compiles it out and takes the recovery
path (`and al,07Fh`). `patch_btl4opt.py` finds all 12 sites by their 14-byte
signature and NOPs them — exactly the release behavior — with a `.orig`
backup. After patching, the game survives RIO resets (1200+ frames).
## 3c. The full game runs through the live renderer (sync abort fixed)