summaryrefslogtreecommitdiff
path: root/soh/src/code/code_800E4FE0.c
diff options
context:
space:
mode:
authorDavid Racine <bass_dr@hotmail.com>2026-06-12 23:36:25 -0400
committerGitHub <noreply@github.com>2026-06-13 03:36:25 +0000
commiteb4142835eba466852cdf8d588f548a5c6d7c9fe (patch)
tree8eb0bbe4c67be9904e322899e84ecfc14530ce87 /soh/src/code/code_800E4FE0.c
parentf3413bfd26f9c9f95b7bc46359bc919423e2a3ad (diff)
Fix custom music corruption past 256 sequences (#5989) (#6736)
The resolved replacement id (which can exceed 255) rode a single per-player seqToPlay slot, written at enqueue but consumed asynchronously on the audio thread; back-to-back starts and priority-queue promotions clobbered it. sSeqFlags[0x6F] was also indexed by raw id, reading out of bounds past the authentic range. - func_800F9280 resolves the replacement and packs the full 16-bit id into the 0x82/0x85 play command; the handler reads opArgs & 0xFFFF. Audio_QueueSeqCmd no longer pre-writes the shared slot. - SyncInitSeqPlayerInternal uses the command-carried id and bounds-checks it against the calloc'd sequence map (+0xF headroom for reserved-range skips). - Route sSeqFlags reads through a bounded Audio_GetSeqFlags helper. - Warn and skip gracefully past the 16-bit id limit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'soh/src/code/code_800E4FE0.c')
-rw-r--r--soh/src/code/code_800E4FE0.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/soh/src/code/code_800E4FE0.c b/soh/src/code/code_800E4FE0.c
index 440fb05a6..05d89b78d 100644
--- a/soh/src/code/code_800E4FE0.c
+++ b/soh/src/code/code_800E4FE0.c
@@ -247,11 +247,12 @@ void func_800E5584(AudioCmd* cmd) {
AudioLoad_SyncLoadSeqParts(cmd->arg1, cmd->arg2);
return;
case 0x82:
- AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2);
+ // 16-bit seqId packed in opArgs bits 0-15. See func_800F9280().
+ AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->opArgs & 0xFFFF, 0);
func_800E59AC(cmd->arg0, cmd->data);
return;
case 0x85:
- AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->data);
+ AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->opArgs & 0xFFFF, cmd->data);
return;
case 0x83:
if (gAudioContext.seqPlayers[cmd->arg0].enabled) {