Stage sounds: the stage bank, sound emitters and effect cues
Our reading of the executable, checked with
stagesound.py (a struct dump of the
sound entries, synthetic test in
tests/test_stagesound.py) on every
stage layout. Confidence H
unless marked.
Play calls. The sound system
object (class handle pdvkSound,
pointer 0x140533748, set up at 0x14022c970,
ticked at 0x1402400f0) is reached through one
wrapper, 0x140276330(bank slot, cue,
parameter record, volume, pitch, position
pointer): volume and pitch are 16-bit
with 0x1000 = 1.0; the parameter record is the
cue number at nearly every site; a null position
gives a plain request (0x140240870), a position
a 3-D request (0x140240a00). It returns a
handle; 0x140240f40 (and 0x1402a9560(handle, 1))
stop a handle, 0x1402413a0 sets a playing
handle’s volume. Each bank slot has a “Sound
parameters” group in the s32 table
0x140533708[slot]; the cue’s flags byte is that
group’s record[cue].
| Bank slot | Bank | Parameter group |
|---|---|---|
| 0 | common (Sound/common.bin, 635
cues) |
0 |
| 1 | the stage’s bank (below) | stage ones digit (1–9) |
| 3 | title screen bank | — |
| 4 | boss bank | — |
| per player | voice banks (“Sound banks”) | 10+ |
Stage bank. The stage file
table 0x1403f2b60 (0x18-byte entries starting
with a name pointer) holds the nine
Sound/MapSE*.bin banks at entries
70–78. The loader 0x14021a6a0 takes area
= stage number mod 10 (0x140530264) and
loads entry 69 + area; area 0 has no bank. Its
callback 0x14021a5a0 registers the bank as slot
1 and sets slot 1’s parameter group to the area.
So all variants of a stage family share one
bank:
| Stage ones digit | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
MapSE… |
IsekiIn | Highway | ShoppingMall | Panorama | JuryokuHanten | YojoPlant | Kioku | IsekiOut | Underground |
| cues in the bank | 2 | 7 | 5 (4 filled) | 7 | 4 | 7 | 1 | 3 | 33 |
(The same order as the stage reverb table of “Sound banks”.) Parameter groups 1–8 hold 10 records and group 9 holds 40, so every bank fits its group.
Sound emitter (EF00 types 0x0B and
0x0C; class handle
pdvkEbSE). Corrects
“Stage ambient effects”, which left these two
types unnamed. Both types build the same
object (constructor 0x1401f1470 from the type
table at 0x1402dc528, vtable 0x14048bea0). The
entry’s parameter block (“Stage ambient
effects”: 4 bytes at +40, floats from +44):
| off | type | field |
|---|---|---|
| +40 | u8 | mode: 1 = held cue, 0 = one-shot. Overwritten at start with bit 3 of the cue’s parameter flags (the files already agree with it) |
| +41 | u8 | repeat (one-shot only): number of plays after which the emitter removes itself; 0 = forever |
| +42 | u8 | bank: 0 = common (slot 0), else the stage bank (slot 1) |
| +43 | u8 | positional: 0 = played without a position, else at the entry’s world position (for a prop’s list: the prop-relative position placed with the prop) |
| +52 | f32 | interval, ticks |
| +56 | f32 | cue number (negative = none) |
- Start (0x140221410): counter 0, no handle; parameter group = stage ones digit when the bank byte is set, else 0; mode = flags bit 3 of that record.
- Tick (0x1402214c0): while
counter < interval: counter + 1 and nothing
else. Then, held mode: if there
is no handle yet, start the cue (volume and
pitch 0x1000) and keep the handle; it is started
once and never restarted.
One-shot mode: play the cue,
counter = 0 (so the period is interval + 1
ticks), and with repeat ≠ 0 count the plays and
remove the emitter after
repeatof them. - Removal (0x140221490): a held cue’s handle is stopped.
So “Sound parameters” flags bit 3 (0x08) = held (looping) cue, the bit that section left open; bit 4 stays “positional” and equals the entry’s positional byte in every entry.
What the stage files hold (all cues are inside their bank; “bed” = held, no position; “point” = held, positional; counts are entries):
| Stage | Stage-wide list | Prop lists |
|---|---|---|
| st00, st09_0N, st32 | none | none |
| st01 | beds: cues 0, 1 | — |
| st02, st22 | bed: cue 2 | — |
| st12 | cues 2, 6 | — |
| st03, st13 | bed cue 0; point cue 1 × 10; cue 4 × 6 positional one-shots every 91 ticks | — |
| st23 | as st03 without cue 1 | — |
| st04 | bed cue 0; cues 3, 4, 5, 6 positional | — |
| st14 | cues 0, 4, 5, 6 | — |
| st24 | cues 0, 3, 4 × 3 | — |
| st05, st15, st25, st07, st17 | bed cue 0 | common cue 79, point |
| st06, st16, st26 | points: cue 3 × 8, cue 4 × 5; beds: cues 5, 6 | common cue 79 point; st06 / st26 also common cue 17 once after 52 ticks |
| st08 | cue 0 point, cue 2 bed | stage cue 1, one-shot once, on 29 props |
| st09 | 45 entries, cues 0..32 | — |
Levels come from the bank as for any cue (“Sound banks”): e.g. the Palace family’s cues have cue volumes 30–80 of 127 and their own speaker sends; the emitter itself always plays at 1.0.
Cues played by stage effects from the stage bank (slot 1; M unless marked):
| Who (class handle, site) | Cue | How |
|---|---|---|
highway sand storm (pdvkSStorm,
tick 0x140243250) |
0 | started once without a position; every tick its volume = clamp(storm intensity, 0, 1) × 4096 (H) |
near papers (pdvkSPaperNear,
0x1402440d0) |
1 | held, no position |
thunder (pdvkEleThunder,
0x140226b4e) |
random 0..2, + 3 when the stage ones digit is 2 | at the strike position (st12: Highway cues 3–5; st06 family: YojoPlant cues 0–2) (H) |
sparks (pdvkEbSpark,
0x140221a59) |
6 | at the entry |
steam (pdvkEbSteam,
0x140221f10) |
2 | at the entry |
collapse model (pdvkClpsModel2,
0x14021c210) |
1, 2 | (stagefx 11-15, corrected) without a position, once per model of system entries 0x36 / 0x37; st04 family and st08 only, not the Palace or Highway collapses |
| stage object classes (0x1401f2aea, 0x1401fc790, 0x1402007e0, 0x140200bc0, 0x140201110) | 0x0F, 0x10, 0x12 and others | Underground-range ids; not followed one by one (L) |
Not decoded: (soundparam bits 0 and 1 are the volume class, ambient run 11-14) the per-class details of the last table’s rows; whether a prop list’s emitter follows a moving prop.
Implementation notes for the rebuild
- Convert the stage’s
MapSEbank with the existing bank converter (pdsound.py) next to the common bank; pick it by stage ones digit. Stage 0 and the st09_0N rooms have none. - Spawn one emitter per EF00 0x0B/0x0C entry
(
stagesound.pyshows the fields; fold it intostagefx.py’s output when built). Held: start once afterintervalticks, loop until the stage unloads. One-shot: every interval + 1 ticks,repeattimes or forever. - Non-positional entries are plain stereo beds; positional ones use the cue’s attenuation and sends as other positional cues do.
- The held flag comes from soundparam bit 3; export it per cue (group = bank’s group).
- The storm bed’s volume follows the storm intensity each tick; thunder picks one of three cues at random with the game’s rand15 × 3 >> 15.