Stage light script (stNN.dat, header 0xD0 / 0xD4 / 0xD8)
One of the three header words points at a
small script (only one is set: 0xD0 for base
stages, 0xD4 for stNN+10, 0xD8 for stNN+20; st32
has none). converter/maplight.py
prints it, pdconv --layout writes
light.json. The Modding Wiki names
the 0xD0 entry the “maplight” SSB; the token
layout and call meanings below are our own
reading. Header 0xF4 (a light ALR, per the wiki)
was not needed for the static stage light and is
not decoded.
- Header: u32 code start (0x20), u32 code end, then sizes/ids (unused here).
- Tokens (little endian):
0x0Fpush 32-bit value (the u32 at +4; 8 bytes),0x0Epush s16 (+2; 4 bytes),0x01call (u8 argument count at +1, u16 function id at +2; 4 bytes),0x05end. Floats are pushed as f32 bits; small whole numbers (0, 1, colours below 0x8000) as s16, sign-extended. pdconv reads a pushed value below 0x10000 (or from 0xFFFF0000) as an integer, not a float: as f32 bits those would be denormals or NaNs. Header word 0xDC is never set (checked on the 20 versus stages and st32) and is not read. - Colours are
0x00RRGGBB. - Argument order
(capsulelook-fix): the interpreter
hands a call its arguments last-pushed first
(the 0x2002 handler indexes the set with its
first argument and reads the mode and colour
next, the reverse of the push order). The
function table is at 0x1403eede0 (0x2000 →
0x140206850, 0x2001 → 0x1402068a0, 0x2002 →
0x1402068c0, 0x2007 → 0x1402069e0). So the
0x2000 handler stores, per set, a 0x58-byte
record at 0x1403e8a40 + set·0x58: +0 the sky
colour, +4 the ground colour, +8 the light
colour, +0x14 the light direction and +0x20 the
hemisphere axis, each vector being the
script’s three numbers in reverse
order: the game’s x is the script’s
third number. light.json keeps the script’s
order;
PdData.game_orderreverses them (so for st03 the light travels towards +x, −z, not −x, +z). The 0x2005 point light positions are stored reversed the same way. - Light records (0x70 bytes
at 0x1405a6a40, index set·8 + 0x40 + k, +0x68 =
kind, 0 = unused): 0x140199670 (at start-up for
sets 0–3, from the 0x58-byte record) and
0x140199510 (the same with an intensity, used by
st12’s flashes) build k = 0 hemisphere (sky at
+0, ground at +0x10, axis at +0x20) and k = 1
directional (colour at +0 and +0x10, direction
at +0x20), colours byte/255. 0x140199970(set)
points the light slots 0x14057f3d0.. at a set’s
records (k = 0..4); 0x140199e70(player) points
them at set 1 plus that player’s point lights.
Every character draw runs 0x140199e70 and then
0x140199970(0) (0x140147f95 / 0x140148030), the
player pass ends with 0x140199970(0)
(0x14012c3d1), and no stage script calls 0x2007
(checked on every
stNN.dat), so everything else in a match, the capsules included, draws with set 0. An unused slot falls back to the record at 0x1405ad9d0, which device setup clears to zero (0x14029270f): no light. - Calls (the last argument is
the light set, 0–3):
0x2000(axis xyz, light dir xyz, light rgb, ground rgb, sky rgb, set): the hemisphere axis (cS0_VEC, close to +Y), the direction the light travels (cDL_VEC, points down), andcDL_COL,cS1_COL(ground, k = 0),cS0_COL(sky, k = 1).0x2002(a, b, rgb, mode, set): fog with the D3D fog mode: 3 linear (a = end, b = start, game units), 1 exp and 2 exp² (a = density; b unknown, ignored), 0 none.0x2005(range, x, y, z, rgb, index, set): point lights 0–2 (cP0_*). In set 0 they are all black on every stage. (skycol 11-15) In set 2 point light 0 is coloured on 14 of the 19 versus stages, with a range of 5e6..1e9: the sky’s fill light (“Sky colour: set 2’s point light”). The handler (0x140206960) stores index 0 in the set record at +0xC (colour), +0x2C..+0x34 (position, the script’s three numbers reversed like the vectors) and +0x44 (range); index 1 at +0x10, +0x38..+0x40 and +0x48; index 2 is dropped. (skycol 11-15) pdconv writes indices 0 and 1 of each set aspointsin light.json (used,color0..1,posin the script’s order,range); an uncalled one is black with range 0.PdData.game_orderreversesposlike the vectors.0x2001(0, rgb): the shadow colour (“Shadow volumes”); (skybright 11-15) not the background: the battle frame clears to black (“St03 sky brightness against the Xbox”).0x2003(f, rgb): the glow scale target f (0.7–1.1; st03 0.7) and a colour (“Glow pass”).
- Sets: set 0 is the only one
with fog on most stages and gives the original’s
look on st03, so Godot uses it. Set 1 has the
same directions with a brighter light and
usually no fog (characters, probably); sets 2
and 3 differ more. (skyglow 11-13,
corrected) Set 2 is the sky model’s
set and set 3 the far scenery’s (stage model
1): the sky object selects them around
its two draws, and selecting a set also applies
that set’s fog (“Sky and far scenery draw”).
Godot: set 0 for the stage, set 2 for model 2
and set 3 for model 1 (skyglow 11-13,
PdData.model_light_set). - Check (st03, set 0, no
tuning): see REPORT.md of the
lighting-rebranch: floor luma 5/50/95 % 48/93/136 vs the capture’s 44/88/132; walls median RGB 24/38/44 vs 17–29/28–40/34–45.