Music volume, the sound volume option and the battle UI cues
Our reading of the executable
(H unless marked). Completes
“Music” and “Music payload”; the converter is
converter/pdmusic.py (struct
reader; container credit as in “Music”).
Music volume.
- Fresh-save defaults (0x1401cb0e4): the music volume option byte 0x14052dfb4 = 60 and the sound volume option byte 0x14052dfb5 = 60 (one 16-bit store of 0x3c3c), range 0..100.
- Music scale (0x14019d0a0, native 0x1013 with v, 0x1000 = full): option × v / 100, clamped to 0..0x1000, stored at 0x14058280a; the play routine stores option × 0x1000 / 100 for tracks with flags bit 0. 0x1402aa020(slot, scale) sets the stream’s six send-scale words to the master word 0x1405827b0 (0x1000) × scale >> 12.
- The stream voice (0x140280830) takes each channel’s record volume byte and its 8 send bytes (copied in at 0x140280b20..). Per send: attenuation = min(2048 × log10(524288 / (send byte × scale word)), 10000) millibels below full; the voice itself: min(2048 × log10(524288 / (volume << 12)), 10000). Gain = 10^(−mB / 2000). So send 127 at scale 0x1000 is 0 dB; at the default option 60 a track with volume and send 127 plays about −4.7 dB.
- Sends: channel 0 → send 0 (front left), channel 1 → send 1 (front right) on every track; some tracks also send to the rear pair (sends 4 / 5), and two to sends 6 / 7.
- Native 0x1014(ticks, v) fades through the stream fader (0x1402a99f0..: modes 5 / 6 step the volume toward a target each tick and stop the stream at 0); the step size was not read (M).
Sound volume option. 0x140240108 stores option / 100.0 (the float constant at 0x1402f8060) at 0x1405336b8. Each play request multiplies its volume by it (0x14024090a, 0x140240a96, 0x140240cc4, 0x1402413d2). The volume sits inside the logarithm of the send formula (“Speaker sends”), so the option scales every cue’s gain by (option / 100)^(2048 / 2000): × 0.593 at 60.
Battle UI cues. Common bank, no position, volume and pitch 0x1000. Both are gated on the local flag of the player’s battle menu object (menu + 0x30, mirrored at C + 0x30; see the HUD aura point row), so only the local player hears them.
- Lock-on, cue 4: the HUD routine 0x1401536e0 runs once per player panel per tick. While the lock tracks a body (C + 0x13f1c set), the target index T = C + 0x13f20. The panel keeps the last index (+0x7c, −1 = none) and a timer (+0x80). If the last index was −1, the timer is set to 10; otherwise, while the timer is above 0 it is decreased, and reaching 0 plays cue 4. Then if the target’s projection is off screen (the flag of camera + 0x80 + T × 0x14, written by the camera tick) or T differs from the last index, the timer is set back to 10. Finally the last index = T (−1 when not tracking). The restart does not look at the timer, so it also re-arms the cue after it played. So the cue sounds 10 ticks after the lock, after a switch and after the last off-screen tick: a target that leaves the screen and comes back sounds it again 10 ticks after its return. The count comes before the restart in the routine, so on the tick the timer reaches 0 the cue plays even when that same tick (off screen, or a switch) sets the timer back to 10.
- Refused press, cue 2:
- The button routine 0x1402517c0: for each skill button pressed in character state 0, 1 or 8, with a capsule (kind 1), kind 2 or an environment capture (kind 3) in reach, cue 2 when status slot 5, 12 or 13 + button is set.
- The cast path: the card’s slot state word (+0x24, “slot state word”) nonzero with any bit other than 4 (aura short) set plays cue 2. So a card waiting only for aura is silent; the skill-allowed check (8) and an aura level below the cost (2) sound.
- The use check 0x140261e90: an empty button returns silently; a failed can-cast check (menu vtable + 0x40) plays cue 2 when menu + 0x30 is set. The cast fetch 0x140258180 plays cue 2 for card index −1.
- 0x140161fa0 (cue 4) is a three-entry menu cursor, not battle.
- KO: no cue was found at the
knockout sites read; battle end
is the
battleendmenu script’s (stop 0x1011, then 0x1010(37) and 0x1014 fades), part of the menus.
Implementation notes for the rebuild
- Music player: one stream; play(track, force) as “Music” (0 stops, above 60 ignored, the playing track returns at once, otherwise stop then start), the loop from “Music payload”, gain as above. The battle start runs stop / volume 0x1000 / play table[stage].
- Lock-on cue: a per-panel timer as above, fed by the local body’s lock and the target’s on-screen test.
- Refused cue: decide it on the local machine from its own body’s state (no network event).