# Opening Audio Handler Review

This file records the original EXE path for the opening BGM and logo impact sounds.

## Numbering Rule

- Active audio references use the EXE internal zero-based id.
- WLK id `35` is encoded as `0x23`.
- MLK id `10` is encoded as `0x0a`.

## Opening Rows

| VA | bytes | decoded path | meaning |
| --- | --- | --- | --- |
| `0x004a2df4` | `26 30 00 0a b4 2c 4a 00` | opcode `0x26`, mode `0x30`, `data=0x004a2cb4` | play/load `middata.mlk`, MLK id `10` |
| `0x004a3060` | `24 01 00 23` | opcode `0x24`, mode `0x01` | play/load SFX WLK id `35` |
| `0x004a308c` | `24 01 00 23` | opcode `0x24`, mode `0x01` | second play/load SFX WLK id `35` |

## Opcode 0x26 MIDI Path

Opening row:

```text
0x004a2df4: 26 30 00 0a b4 2c 4a 00
```

Decoded from handler `0x00404a2f`:

- `stream+1 = 0x30`
- `0x30 & 0x7f`, then `-1`, dispatches to case target `0x00404c3b`
- case `0x00404c3b`:
  - stores `stream+4` into global `0x0059e2d4`
  - stores `stream+2 & 0x1f` into global `0x0059e2d1`
  - dispatches by the high bits of `stream+2`
  - for this opening row, calls:

```text
0x42cf5a(slot = 0, data = 0x004a2cb4, index = 0x0a)
```

`0x42cf5a` calls:

```text
0x42cde2(slot, data, index)
0x42d155(slot)
```

The downstream code reaches WinMM MIDI APIs through the import table:

- `midiStreamOpen`
- `midiStreamOut`
- `midiStreamRestart`
- `midiStreamPause`
- `midiStreamClose`
- `midiOutShortMsg`
- `midiOutSetVolume`
- `midiOutReset`

Conclusion: the BGM row is no longer just an adjacency guess. It is an opcode-backed MIDI manager call.

## Opcode 0x24 WLK/SFX Path

Opening row:

```text
0x004a3060: 24 01 00 23
0x004a308c: 24 01 00 23
```

Decoded from handler `0x004045a0`:

- `stream+1 = 0x01`
- dispatches to case target `0x0040463f`
- case `0x0040463f` calls:

```text
0x42af73(stream+2, stream+3)
```

For the opening rows:

```text
0x42af73(0, 0x23)
```

`0x42af73`:

- validates the first argument as a bank/group/slot no larger than `0x10`
- checks sound-table metadata under `0x005745b0..0x0058d6xx`
- searches/reuses one of 16 runtime DirectSound effect slots under `0x0058d618..`
- creates/locks/fills DirectSound buffers through COM vtable calls
- starts playback through DirectSound buffer methods

Conclusion: the two `24 01 00 23` rows are opcode-backed WLK/SFX calls for WLK id `35`.

## Remaining Unknowns

- Whether the first `0` argument to `0x42af73(0, 0x23)` is best named bank, sound group, archive id, or channel group.
- The exact WLK metadata table layout in `0x005745b0..`.
- Whether all SFX calls use this same mode or whether battle hit sounds use other `0x24`/`0x26` modes.
