0xbf play-bgm
Opcode 0xbf (191), audio. Investigated by OME, with high confidence (from investigation).
Play background music by id. BGM is addressed by DIRECT LITERAL NAME: id -> BGM{id:03d}.OGG (in DATA3), unlike ordinary resource operands, which are universal packed SYS4INI/AAI ids. E.g. play-bgm 5 -> BGM005. Reasserting the facade's current track id is idempotent and preserves playback position; a different id starts the new track, while fade-to-zero clears the current id so a later request can start it again.
Operands
| # | Role | Types seen | Access |
|---|---|---|---|
| 1 | bgm id (direct file-name number: BGM{id:03d}.OGG) | imm, g-int, l-int, l-ptr | read |
In the port
OME’s port implements it. It never waits: a wait parks the engine until input, a sleep, a transition, a dialog or a movie ends. What it can do with control besides waiting:
falls: it returns to the next instruction
OME derives these facts from the port’s handler (its tools/opcode_flow.py), and they over-approximate: a fact some path can reach is given.
By build
Whether each build’s scripts use it, as OME’s survey of the game’s scripts saw them, and how many evidence items name the build.
| Build | Game | Used by its scripts | Evidence |
|---|---|---|---|
4.24J (SYS4422) | Himegari Dungeon Meister | yes | 1 |
4.33G (SYS4433) | Kamidori Alchemy Meister | yes | — |
4.38D (SYS4438) | Soukoku no Arterial | yes | — |
Evidence
- native-re on SYS4422, high confidence; Himegari AGE.EXE Ghidra /v2 and decoded script corpus (
vm-map/opcodes.toml opcode 0xbf): By-ear confirmed (2026-07-06): SC0000 real game plays BGM005 for play-bgm 0x5 and BGM008 for play-bgm 0x8 (we initially mis-played BGM006/BGM009 via the disproven scene-section model). Direct-name proven by play-bgm 0x23 -> BGM035.OGG, a real standalone track (the BGM set skips 030-034). Ghidra /v2 op_0xbf_handler@0x420390 forwards the numeric track to the BGM facade rather than asset_open_indexed_entry; the facade retains that id at EngineCtx.current_bgm_track_id for op 0xc0 and numbered saves. FIELD intentionally reasserts stage_bgm_id from its common post-action/event cleanup at 0x884a, reached after unit movement; restarting an identical host stream there resets the music once per unit during enemy turns. An op 0xc2 fade to zero releases the source and clears the retained id when it completes; op_0xbf_handler first completes a running fade (clears run-state 0x200, bgm_fade_tick(..., 100)), so SC0000's fade at 0x7c1 ends at play-bgm 5 and BGM005 starts anew. Diagnostic:Ome.Cli audio SC0000.BIN. Ghidra (2026-11-20): 4.33G bgm_play_track@0x469e90 and 4.38D @0x4763e0 return early only when the track and the start mode (+0x414) both match, where 4.24J's @0x464750 compares the track alone; scene_context_init_reset zeroes the BGM object's +0x40c, +0x410 and +0x414 in all three (4.24J 0x40b513, 4.33G 0x40c438, 4.38D 0x40c7f4); op_0xbf reads set:KeepMusicVolume, which engine_settings_import_sys4ini_pairs fills from KEEPMUSICVOLUME (4.24J 0x46e204).
Details
OME’s notes on it, as the registry keeps them.
Implemented in the audio native (Audio.PlayBgm). Track 0 starts the retained track again, and with none releases the source: bgm_play_track's zero branch (創刻のアテリアル's DEBUGADV2 has the one site). 4.33G and 4.38D keep the stream only when the retained start mode is also 1, so a track op 0xb9 played once, or one a scene reset left, starts again; 4.24J compares the track alone (the build rule AudioRules.PlayComparesStartMode). A scene reset (op 0x9) zeroes the retained track, the pause flag and the start mode without stopping the stream, so a title's play of the track that plays starts it again. With set:KeepMusicVolume 1 (the SYS4INI key KEEPMUSICVOLUME), sound:MusicFadeOnVoicePlaying 1 and no duck release armed, the op then sets the BGM level to sound:MusicFadeOnVoicePlayingVolume x 100 in all three builds; no game sets the key, and the port does not model it.