From 5af4805e59a3f83e12467fcb9443a18e2f6d5a4c Mon Sep 17 00:00:00 2001 From: Henny022p Date: Wed, 24 Mar 2021 01:58:52 +0100 Subject: [PATCH] documented most audio stuff --- asm/code_080A3480.s | 4 +- asm/code_080A3BD0.s | 8 +- asm/fileScreen.s | 4 +- asm/macros/scripts.inc | 2 +- asm/soundReq.s | 280 ------------------------------- constants/audio_constants.inc | 24 +-- data/scripts/script_0800A0FC.inc | 2 +- data/scripts/script_0800A1D8.inc | 2 +- data/scripts/script_0800AD54.inc | 2 +- data/scripts/script_0800B9B4.inc | 2 +- data/scripts/script_0800DB78.inc | 2 +- data/scripts/script_0800DCAC.inc | 2 +- data/scripts/script_0800DF24.inc | 2 +- data/scripts/script_0800DFB4.inc | 2 +- data/scripts/script_0800DFE4.inc | 2 +- data/scripts/script_0800E050.inc | 4 +- data/scripts/script_080100C8.inc | 2 +- data/scripts/script_08010BB4.inc | 6 +- data/scripts/script_08010F84.inc | 2 +- data/scripts/script_08011B40.inc | 2 +- data/scripts/script_0801232C.inc | 4 +- data/scripts/script_08012430.inc | 14 +- data/scripts/script_080126FC.inc | 2 +- data/scripts/script_0801319A.inc | 2 +- data/scripts/script_08014E14.inc | 6 +- data/scripts/script_0801548E.inc | 2 +- data/scripts/script_08015BE8.inc | 2 +- data/scripts/script_08015CD4.inc | 4 +- data/scripts/script_080160A8.inc | 2 +- data/scripts/script_08016482.inc | 2 +- include/audio.h | 42 +++-- include/functions.h | 2 +- include/main.h | 1 - include/structures.h | 17 -- linker.ld | 2 +- src/audio.c | 217 ++++++++++++------------ src/debugScreen.c | 2 +- src/fileScreen.c | 2 +- src/intro.c | 2 +- src/main.c | 2 +- src/manager/manager15.c | 2 +- src/manager/managerB.c | 4 +- src/room.c | 20 +-- src/save.c | 11 +- src/script.c | 8 +- 45 files changed, 223 insertions(+), 507 deletions(-) delete mode 100644 asm/soundReq.s diff --git a/asm/code_080A3480.s b/asm/code_080A3480.s index fefbe855..78965ce9 100644 --- a/asm/code_080A3480.s +++ b/asm/code_080A3480.s @@ -95,7 +95,7 @@ _080A365E: strh r0, [r2, #0x14] subs r0, #0x8a strh r0, [r2, #0x20] - bl sub_080A3210 + bl InitSoundPlayingInfo bl sub_0805E5B4 movs r1, #0x80 lsls r1, r1, #1 @@ -505,7 +505,7 @@ _080A39C8: strb r4, [r2, #3] movs r0, #1 bl DispReset - bl sub_080A3210 + bl InitSoundPlayingInfo bl sub_080A4D34 movs r0, #0xa bl LoadPaletteGroup diff --git a/asm/code_080A3BD0.s b/asm/code_080A3BD0.s index 08159cb0..72050efa 100644 --- a/asm/code_080A3BD0.s +++ b/asm/code_080A3BD0.s @@ -1249,7 +1249,7 @@ _080A4604: .4byte gMenu sub_080A4608: @ 0x080A4608 push {r4, lr} movs r0, #0x80 - bl sub_080A3248 + bl SetBgmVolume movs r0, #3 bl sub_080A4DA8 ldr r4, _080A46A0 @ =gPaletteBuffer @@ -1334,7 +1334,7 @@ sub_080A46C0: @ 0x080A46C0 push {lr} movs r0, #0x80 lsls r0, r0, #1 - bl sub_080A3248 + bl SetBgmVolume movs r0, #0x6c bl SoundReq movs r0, #2 @@ -2222,7 +2222,7 @@ sub_080A4D88: @ 0x080A4D88 movs r1, #0 bl MenuFadeIn movs r0, #0x80 - bl sub_080A3248 + bl SetBgmVolume pop {pc} .align 2, 0 _080A4DA4: .4byte gUnk_020344A0 @@ -2351,7 +2351,7 @@ sub_080A4EA0: @ 0x080A4EA0 bne _080A4EBC movs r0, #0x80 lsls r0, r0, #1 - bl sub_080A3248 + bl SetBgmVolume bl sub_080A71DC b _080A4F14 .align 2, 0 diff --git a/asm/fileScreen.s b/asm/fileScreen.s index ba7813d0..d743ac41 100755 --- a/asm/fileScreen.s +++ b/asm/fileScreen.s @@ -34,7 +34,7 @@ sub_080519B0: @ 0x080519B0 bne _08051A02 movs r0, #1 bl DispReset - bl sub_080A3210 + bl InitSoundPlayingInfo bl zMallocInit bl sub_080A7124 bl sub_0807059C @@ -726,7 +726,7 @@ _0805200C: .4byte gMenu thumb_func_start sub_08052010 sub_08052010: @ 0x08052010 push {r4, lr} - bl sub_080A3210 + bl InitSoundPlayingInfo bl MessageInitialize movs r0, #1 bl DispReset diff --git a/asm/macros/scripts.inc b/asm/macros/scripts.inc index 6b4b91c1..240d481d 100644 --- a/asm/macros/scripts.inc +++ b/asm/macros/scripts.inc @@ -670,7 +670,7 @@ .4byte \w .endm -.macro SoundReq0x80100000 +.macro StopBgm .2byte 0x047e .endm diff --git a/asm/soundReq.s b/asm/soundReq.s deleted file mode 100644 index 5e0055c6..00000000 --- a/asm/soundReq.s +++ /dev/null @@ -1,280 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start SoundReq -SoundReq: @ 0x080A3268 - push {r4, r5, lr} - adds r3, r0, #0 - ldr r0, _080A32AC @ =gMain - ldrb r2, [r0, #7] - cmp r2, #0 - beq _080A3276 - b _080A347C -_080A3276: - ldr r5, _080A32B0 @ =gUnk_02021EE0 - ldr r4, _080A32B4 @ =0x0000FFFF - ands r4, r3 - ldr r1, _080A32B8 @ =0xFFFF0000 - ands r1, r3 - ldr r0, _080A32BC @ =0x80090000 - cmp r1, r0 - bne _080A3288 - b _080A33A0 -_080A3288: - cmp r1, r0 - bhi _080A3310 - ldr r0, _080A32C0 @ =0x80040000 - cmp r1, r0 - bne _080A3294 - b _080A33F4 -_080A3294: - cmp r1, r0 - bhi _080A32D8 - ldr r0, _080A32C4 @ =0x80020000 - cmp r1, r0 - bne _080A32A0 - b _080A3384 -_080A32A0: - cmp r1, r0 - bhi _080A32CC - ldr r0, _080A32C8 @ =0x80010000 - cmp r1, r0 - beq _080A337C - b _080A3458 - .align 2, 0 -_080A32AC: .4byte gMain -_080A32B0: .4byte gUnk_02021EE0 -_080A32B4: .4byte 0x0000FFFF -_080A32B8: .4byte 0xFFFF0000 -_080A32BC: .4byte 0x80090000 -_080A32C0: .4byte 0x80040000 -_080A32C4: .4byte 0x80020000 -_080A32C8: .4byte 0x80010000 -_080A32CC: - ldr r0, _080A32D4 @ =0x80030000 - cmp r1, r0 - beq _080A338C - b _080A3458 - .align 2, 0 -_080A32D4: .4byte 0x80030000 -_080A32D8: - ldr r0, _080A32F0 @ =0x80060000 - cmp r1, r0 - bne _080A32E0 - b _080A340A -_080A32E0: - cmp r1, r0 - bhi _080A32F8 - ldr r0, _080A32F4 @ =0x80050000 - cmp r1, r0 - bne _080A32EC - b _080A33FE -_080A32EC: - b _080A3458 - .align 2, 0 -_080A32F0: .4byte 0x80060000 -_080A32F4: .4byte 0x80050000 -_080A32F8: - ldr r0, _080A3308 @ =0x80070000 - cmp r1, r0 - bne _080A3300 - b _080A340E -_080A3300: - ldr r0, _080A330C @ =0x80080000 - cmp r1, r0 - beq _080A3398 - b _080A3458 - .align 2, 0 -_080A3308: .4byte 0x80070000 -_080A330C: .4byte 0x80080000 -_080A3310: - ldr r0, _080A3330 @ =0x800D0000 - cmp r1, r0 - bne _080A3318 - b _080A343A -_080A3318: - cmp r1, r0 - bhi _080A3348 - ldr r0, _080A3334 @ =0x800B0000 - cmp r1, r0 - bne _080A3324 - b _080A3420 -_080A3324: - cmp r1, r0 - bhi _080A333C - ldr r0, _080A3338 @ =0x800A0000 - cmp r1, r0 - beq _080A33B6 - b _080A3458 - .align 2, 0 -_080A3330: .4byte 0x800D0000 -_080A3334: .4byte 0x800B0000 -_080A3338: .4byte 0x800A0000 -_080A333C: - ldr r0, _080A3344 @ =0x800C0000 - cmp r1, r0 - beq _080A33CC - b _080A3458 - .align 2, 0 -_080A3344: .4byte 0x800C0000 -_080A3348: - ldr r0, _080A335C @ =0x800F0000 - cmp r1, r0 - bne _080A3350 - b _080A344E -_080A3350: - cmp r1, r0 - bhi _080A3364 - ldr r0, _080A3360 @ =0x800E0000 - cmp r1, r0 - beq _080A3446 - b _080A3458 - .align 2, 0 -_080A335C: .4byte 0x800F0000 -_080A3360: .4byte 0x800E0000 -_080A3364: - ldr r0, _080A3374 @ =0x80100000 - cmp r1, r0 - beq _080A343E - ldr r0, _080A3378 @ =0x80110000 - cmp r1, r0 - beq _080A3454 - b _080A3458 - .align 2, 0 -_080A3374: .4byte 0x80100000 -_080A3378: .4byte 0x80110000 -_080A337C: - strh r2, [r5, #0x14] - bl m4aMPlayAllStop - b _080A347C -_080A3384: - movs r0, #0 - bl sub_080A3234 - b _080A347C -_080A338C: - bl sub_080A35C8 - movs r0, #0x80 - lsls r0, r0, #1 - strh r0, [r5, #0x12] - b _080A3418 -_080A3398: - ldrh r0, [r5, #0x14] - bl sub_080A35B4 - b _080A347C -_080A33A0: - cmp r4, #0 - bne _080A33A6 - ldrh r4, [r5, #0x14] -_080A33A6: - subs r0, r4, #1 - cmp r0, #0x62 - bhi _080A347C - strh r4, [r5, #0x14] - adds r0, r4, #0 - bl m4aSongNumStart - b _080A33C4 -_080A33B6: - subs r0, r4, #1 - cmp r0, #0x62 - bhi _080A347C - strh r4, [r5, #0x14] - adds r0, r4, #0 - bl m4aSongNumStartOrContinue -_080A33C4: - adds r0, r4, #0 - bl sub_080A35A0 - b _080A347C -_080A33CC: - ldr r2, _080A33EC @ =gMPlayTable - ldr r1, _080A33F0 @ =gSongTable - ldrh r0, [r5, #0x14] - lsls r0, r0, #3 - adds r0, r0, r1 - ldrh r1, [r0, #4] - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #2 - adds r0, r0, r2 - ldr r0, [r0] - adds r1, r4, #0 - bl m4aMPlayTempoControl - b _080A347C - .align 2, 0 -_080A33EC: .4byte gMPlayTable -_080A33F0: .4byte gSongTable -_080A33F4: - bl m4aMPlayAllStop - bl m4aSoundVSyncOff - b _080A347C -_080A33FE: - ldrh r0, [r5, #0x14] - cmp r0, #0 - beq _080A347C - bl m4aSongNumStop - b _080A347C -_080A340A: - bl m4aSoundVSyncOn -_080A340E: - ldrh r0, [r5, #0x14] - cmp r0, #0 - beq _080A347C - bl m4aSongNumStartOrContinue -_080A3418: - ldrh r0, [r5, #0x14] - bl sub_080A353C - b _080A347C -_080A3420: - subs r0, r4, #1 - cmp r0, #0x62 - bhi _080A347C - strh r4, [r5, #0x14] - adds r0, r4, #0 - bl m4aSongNumStartOrContinue - bl sub_080A35C8 - adds r0, r4, #0 - bl sub_080A353C - b _080A347C -_080A343A: - strh r2, [r5, #0x10] - b _080A347C -_080A343E: - strh r2, [r5, #0x10] - movs r0, #1 - strb r0, [r5, #2] - b _080A347C -_080A3446: - movs r0, #0x80 - lsls r0, r0, #1 - strh r0, [r5, #0x10] - b _080A347C -_080A344E: - bl sub_080A35C8 - b _080A347C -_080A3454: - strh r2, [r5, #0x14] - b _080A347C -_080A3458: - cmp r4, #0 - beq _080A347C - subs r0, r4, #1 - cmp r0, #0x62 - bhi _080A3470 - strh r4, [r5, #0x14] - adds r0, r4, #0 - bl m4aSongNumStart - bl sub_080A35C8 - b _080A3476 -_080A3470: - adds r0, r4, #0 - bl m4aSongNumStart -_080A3476: - adds r0, r4, #0 - bl sub_080A353C -_080A347C: - pop {r4, r5, pc} - .align 2, 0 diff --git a/constants/audio_constants.inc b/constants/audio_constants.inc index e0c259a9..b7cb230c 100644 --- a/constants/audio_constants.inc +++ b/constants/audio_constants.inc @@ -545,19 +545,19 @@ .equiv SFX_220, 0x220 .equiv SFX_221, 0x221 .equiv SONG_STOP_ALL, 0x80010000 - .equiv SONG_VOL_ZERO, 0x80020000 - .equiv SONG_VOL_RESET_ALL, 0x80030000 + .equiv SONG_MUTE, 0x80020000 + .equiv SONG_PLAY_VOL_RESET_ALL, 0x80030000 .equiv SONG_VSYNC_OFF, 0x80040000 .equiv SONG_STOP, 0x80050000 .equiv SONG_VSYNC_ON, 0x80060000 - .equiv SONG_UNK_7, 0x80070000 + .equiv SONG_CONTINUE, 0x80070000 .equiv SONG_VOL_FADE_OUT, 0x80080000 - .equiv SONG_UNK_9, 0x80090000 - .equiv SONG_UNK_A, 0x800a0000 - .equiv SONG_VOL_RESET, 0x800b0000 - .equiv SONG_UNK_C, 0x800c0000 - .equiv SONG_VOL_CHAN1_SILENT, 0x800d0000 - .equiv SONG_VOL_CHAN1_RESET, 0x800e0000 - .equiv SONG_UNK_F, 0x800f0000 - .equiv SONG_RESET_UNK, 0x80100000 - .equiv SONG_UNK_11, 0x80110000 + .equiv SONG_FADE_IN, 0x80090000 + .equiv SONG_FADE_IN_CONTINUE, 0x800a0000 + .equiv SONG_PLAY_VOL_RESET, 0x800b0000 + .equiv SONG_PLAY_TEMPO_CONTROL, 0x800c0000 + .equiv SONG_FADE_OUT_BGM, 0x800d0000 + .equiv SONG_FADE_IN_BGM, 0x800e0000 + .equiv SONG_INIT, 0x800f0000 + .equiv SONG_STOP_BGM, 0x80100000 + .equiv SONG_BGM_0, 0x80110000 diff --git a/data/scripts/script_0800A0FC.inc b/data/scripts/script_0800A0FC.inc index 95fac91b..80b3c50f 100644 --- a/data/scripts/script_0800A0FC.inc +++ b/data/scripts/script_0800A0FC.inc @@ -6,7 +6,7 @@ script_0800A0FE: BeginBlock _0807E864 Call sub_0807DF28 - SoundReq0x80100000 + StopBgm Call sub_0807FBFC SetEntityPositionRelative 0x00b0, 0x0058 Call sub_0807F844 diff --git a/data/scripts/script_0800A1D8.inc b/data/scripts/script_0800A1D8.inc index c5e46d75..2aaed6d4 100644 --- a/data/scripts/script_0800A1D8.inc +++ b/data/scripts/script_0800A1D8.inc @@ -47,7 +47,7 @@ SCRIPT_START script_0800A1D8 WaitForSomething2 0x000000c0 TextboxNoOverlapFollowPos 0x165c, 0x000e _0807EA94 - SoundReq0x80100000 + StopBgm TextboxNoOverlapFollowPos 0x165d, 0x000e _0807EA94 _0807E5F8 0x00000006 diff --git a/data/scripts/script_0800AD54.inc b/data/scripts/script_0800AD54.inc index 03b12d66..fb45912a 100644 --- a/data/scripts/script_0800AD54.inc +++ b/data/scripts/script_0800AD54.inc @@ -45,7 +45,7 @@ SCRIPT_START script_0800AD54 Call sub_0807F2D4 Wait 0x001e _0807E5F8 0x00000020 - SoundReq0x80100000 + StopBgm Call CreateDust Call sub_0806305C Call sub_080630A4 diff --git a/data/scripts/script_0800B9B4.inc b/data/scripts/script_0800B9B4.inc index 0c51b534..f6fc9214 100644 --- a/data/scripts/script_0800B9B4.inc +++ b/data/scripts/script_0800B9B4.inc @@ -51,7 +51,7 @@ script_0800BA46: _0807EA94 _0807E3E8 JumpIfNot script_0800BA6C - SoundReq0x80100000 + StopBgm Call sub_0806E964 PlayBGM script_0800BA6C: diff --git a/data/scripts/script_0800DB78.inc b/data/scripts/script_0800DB78.inc index c810df2f..829bc9d0 100644 --- a/data/scripts/script_0800DB78.inc +++ b/data/scripts/script_0800DB78.inc @@ -40,7 +40,7 @@ script_0800DBCA: _0807EA94 Call sub_0807F3F8 _0807E5F8 0x00000001 - SoundReq0x80100000 + StopBgm Call sub_08094F98 CallWithArg sub_0805DDEC, 0x00000001 _0807F0C8 0xffff, 0x0000 diff --git a/data/scripts/script_0800DCAC.inc b/data/scripts/script_0800DCAC.inc index 7f7db9f6..7ac06b7e 100644 --- a/data/scripts/script_0800DCAC.inc +++ b/data/scripts/script_0800DCAC.inc @@ -14,7 +14,7 @@ script_0800DCD0: DoPostScriptAction 0x0010 SetEntityPositionRelative 0x0078, 0x0068 WaitForSomething2 0x00000001 - SoundReq0x80100000 + StopBgm Call sub_08066E50 PlaySound SFX_1C9 Call sub_0807F2D4 diff --git a/data/scripts/script_0800DF24.inc b/data/scripts/script_0800DF24.inc index ec233b1c..5711733f 100644 --- a/data/scripts/script_0800DF24.inc +++ b/data/scripts/script_0800DF24.inc @@ -7,7 +7,7 @@ SCRIPT_START script_0800DF24 _0807E864 Call sub_0807F9A4 Call sub_0807DF28 - SoundReq0x80100000 + StopBgm _0807E8E4_2 Wait 0x005a Call sub_0807F3F8 diff --git a/data/scripts/script_0800DFB4.inc b/data/scripts/script_0800DFB4.inc index ab607bb6..e3de08af 100644 --- a/data/scripts/script_0800DFB4.inc +++ b/data/scripts/script_0800DFB4.inc @@ -3,7 +3,7 @@ SCRIPT_START script_0800DFB4 script_0800DFB6: CheckRoomFlag 0x0001 JumpIfNot script_0800DFB6 - SoundReq0x80100000 + StopBgm _0807E864 Call sub_0807DF28 PlaySound SFX_EVAPORATE diff --git a/data/scripts/script_0800DFE4.inc b/data/scripts/script_0800DFE4.inc index 9c5fb927..46080434 100644 --- a/data/scripts/script_0800DFE4.inc +++ b/data/scripts/script_0800DFE4.inc @@ -3,7 +3,7 @@ SCRIPT_START script_0800DFE4 Call sub_0807DF28 _0807E864 EndBlock - SoundReq0x80100000 + StopBgm TextboxNoOverlapFollowPos 0x1632, 0x0002 _0807EA94 SetRoomFlag 0x0003 diff --git a/data/scripts/script_0800E050.inc b/data/scripts/script_0800E050.inc index f44b8f44..7bafd454 100644 --- a/data/scripts/script_0800E050.inc +++ b/data/scripts/script_0800E050.inc @@ -3,8 +3,8 @@ SCRIPT_START script_0800E050 Call sub_0807DF28 _0807E864 EndBlock - SoundReq0x80100000 - SoundReq0x80100000 + StopBgm + StopBgm Wait 0x0078 _0807EB28 0x1638 _0807EA94 diff --git a/data/scripts/script_080100C8.inc b/data/scripts/script_080100C8.inc index 23a9d13e..b136cbde 100644 --- a/data/scripts/script_080100C8.inc +++ b/data/scripts/script_080100C8.inc @@ -80,7 +80,7 @@ script_080101AC: Call sub_0807DF28 TextboxNoOverlapFollowPos 0x3004, 0x0007 _0807EA94 - SoundReq0x80100000 + StopBgm _0807E778 0x0004 DoFade5 WaitFor_2 diff --git a/data/scripts/script_08010BB4.inc b/data/scripts/script_08010BB4.inc index cb38dd26..2caa5a7f 100644 --- a/data/scripts/script_08010BB4.inc +++ b/data/scripts/script_08010BB4.inc @@ -33,7 +33,7 @@ script_08010BCA: WaitForSomething2 0x00000020 TextboxNoOverlapFollowPos 0x1038, 0x000c _0807EA94 - SoundReq0x80100000 + StopBgm _0807E778 0x0004 DoFade5 WaitFor_2 @@ -95,7 +95,7 @@ script_08010BCA: Wait 0x003c WaitForSomething2 0x00000200 _0807E5F8 0x00280000 - SoundReq0x80100000 + StopBgm PlaySound SFX_9B _0807E5F8 0x00000100 WaitForSomething2 0x00000200 @@ -118,7 +118,7 @@ script_08010BCA: TextboxNoOverlapFollowPos 0x1044, 0x0000 _0807EA94 SetEntityPositionRelative 0x01f8, 0x0098 - SoundReq0x80100000 + StopBgm Wait 0x003c PlayBgm BGM_VAATI_REBORN _0807E5F8 0x00028000 diff --git a/data/scripts/script_08010F84.inc b/data/scripts/script_08010F84.inc index 0b534de1..d10ec983 100644 --- a/data/scripts/script_08010F84.inc +++ b/data/scripts/script_08010F84.inc @@ -26,7 +26,7 @@ SCRIPT_START script_08010F84 _0807F0C8 0x0000, 0x0000 _0807E5F8 0x00000010 WaitForSomething2 0x00000020 - SoundReq0x80100000 + StopBgm Wait 0x003c TextboxNoOverlapFollowPos 0x104a, 0x0000 _0807EA94 diff --git a/data/scripts/script_08011B40.inc b/data/scripts/script_08011B40.inc index 28efb83c..4c2d3a58 100644 --- a/data/scripts/script_08011B40.inc +++ b/data/scripts/script_08011B40.inc @@ -60,7 +60,7 @@ script_08011BBC: script_08011C04: CheckRoomFlag 0x0064 JumpIfNot script_08011C04 - SoundReq0x80100000 + StopBgm _0807E864 Wait 0x003c CameraTargetEntity diff --git a/data/scripts/script_0801232C.inc b/data/scripts/script_0801232C.inc index ac4e25d5..51bdb1e9 100644 --- a/data/scripts/script_0801232C.inc +++ b/data/scripts/script_0801232C.inc @@ -27,7 +27,7 @@ script_08012368: JumpIfNot script_08012368 Call sub_0807DF28 _0807E864 - SoundReq0x80100000 + StopBgm BeginBlock _0807E778 0x0004 _0807E788 0x00007fff @@ -49,7 +49,7 @@ script_08012368: WaitForSomething2 0x00000001 TextboxNoOverlap 0x1402 _0807EA94 - SoundReq0x80100000 + StopBgm SetEntity0x20 0x00010000 Wait 0x003c BeginBlock diff --git a/data/scripts/script_08012430.inc b/data/scripts/script_08012430.inc index 03bfdd21..9a96deb9 100644 --- a/data/scripts/script_08012430.inc +++ b/data/scripts/script_08012430.inc @@ -30,7 +30,7 @@ script_08012474: script_0801248A: CheckPlayerInRegion 0x0208, 0x02c8, 0x4020 JumpIfNot script_0801248A - SoundReq0x80100000 + StopBgm _0807E864 Call sub_0807F9A4 Call sub_0807DF28 @@ -61,7 +61,7 @@ script_0801248A: WaitForSomething2 0x00000100 _0807E5F8 0x00000004 WaitForSomething2 0x00000008 - SoundReq0x80100000 + StopBgm _0807E778 0x0004 _0807E80C 0x00000000 WaitFor_2 @@ -82,7 +82,7 @@ script_08012566: Call sub_0807F9A4 Call sub_0807DF28 Call sub_0806DC7C - SoundReq0x80100000 + StopBgm StartPlayerScript script_08012AC8 WaitForSomething2 0x00000001 SetEntityPositionRelative 0x0388, 0x0168 @@ -104,7 +104,7 @@ script_08012566: WaitForSomething2 0x00000100 _0807E5F8 0x00000004 WaitForSomething2 0x00000008 - SoundReq0x80100000 + StopBgm PlayBgm BGM_FIGHT_THEME2 Call sub_0807DF50 _0807E878 @@ -115,7 +115,7 @@ script_08012566: Call sub_0807FA40 Call sub_0807DF28 PlaySound SFX_SECRET - SoundReq0x80100000 + StopBgm _0807E5F8 0x00000004 WaitForSomething2 0x00000008 StartPlayerScript script_08012AF0 @@ -133,7 +133,7 @@ script_08012566: WaitForSomething2 0x00000008 _0807E5F8 0x00000004 WaitForSomething2 0x00000008 - SoundReq0x80100000 + StopBgm Wait 0x003c PlayBGM Call sub_0806DCA0 @@ -147,7 +147,7 @@ script_08012566: WaitForSomething2 0x00000008 _0807E5F8 0x00000004 WaitForSomething2 0x00000008 - SoundReq0x80100000 + StopBgm Wait 0x003c PlayBGM Call sub_08054570 diff --git a/data/scripts/script_080126FC.inc b/data/scripts/script_080126FC.inc index 930acbc1..123e7ed8 100644 --- a/data/scripts/script_080126FC.inc +++ b/data/scripts/script_080126FC.inc @@ -214,7 +214,7 @@ script_08012A3E: _0807E864 Call sub_0807F9A4 Call sub_0807DF28 - SoundReq0x80100000 + StopBgm DoPostScriptAction 0x000b _0807EB8C Call sub_0806D944 diff --git a/data/scripts/script_0801319A.inc b/data/scripts/script_0801319A.inc index 65a5b20e..95f13185 100644 --- a/data/scripts/script_0801319A.inc +++ b/data/scripts/script_0801319A.inc @@ -53,7 +53,7 @@ script_080131AC: _0807E778 0x0004 DoFade5 WaitFor_2 - SoundReq0x80100000 + StopBgm _0807E858 0x0000 Wait 0x003c CameraTargetPlayer diff --git a/data/scripts/script_08014E14.inc b/data/scripts/script_08014E14.inc index 7f06d9c2..ce05736b 100644 --- a/data/scripts/script_08014E14.inc +++ b/data/scripts/script_08014E14.inc @@ -138,7 +138,7 @@ script_08014FCC: _0807E864 Call sub_0807F9A4 Call sub_0807DF28 - SoundReq0x80100000 + StopBgm _0807F0B4 0x0001 CameraTargetEntity StartPlayerScript script_080152B4 @@ -164,7 +164,7 @@ script_08014FCC: WaitForSomething2 0x00000004 _0807EB28 0x1306 _0807EA94 - SoundReq0x80100000 + StopBgm StartPlayerScript script_080152DC CameraTargetEntity _0807F0B4 0x0003 @@ -206,7 +206,7 @@ script_08015104: _0807E864 Call sub_0807F9A4 Call sub_0807DF28 - SoundReq0x80100000 + StopBgm StartPlayerScript script_08015338 WaitForSomething2 0x00000001 Wait 0x003c diff --git a/data/scripts/script_0801548E.inc b/data/scripts/script_0801548E.inc index 8a97209e..4c3abbd4 100644 --- a/data/scripts/script_0801548E.inc +++ b/data/scripts/script_0801548E.inc @@ -17,7 +17,7 @@ SCRIPT_START script_0801548E _0807EA94 _0807E5F8 0x00000800 WaitForSomething2 0x00001000 - SoundReq0x80100000 + StopBgm _0807E778 0x0004 DoFade5 WaitFor_2 diff --git a/data/scripts/script_08015BE8.inc b/data/scripts/script_08015BE8.inc index 7e551f52..091c95fc 100644 --- a/data/scripts/script_08015BE8.inc +++ b/data/scripts/script_08015BE8.inc @@ -15,7 +15,7 @@ script_08015BF0: _0807E778 0x0004 _0807E80C 0x00000000 WaitFor_2 - SoundReq0x80100000 + StopBgm Call sub_08053BE8 BeginBlock _0807E864 diff --git a/data/scripts/script_08015CD4.inc b/data/scripts/script_08015CD4.inc index 15699b72..c565c3e9 100644 --- a/data/scripts/script_08015CD4.inc +++ b/data/scripts/script_08015CD4.inc @@ -42,7 +42,7 @@ SCRIPT_START script_08015CD4 WaitFor_2 _0807E5F8 0x00000010 LoadRoomEntityList gUnk_080FCE30 - SoundReq0x80100000 + StopBgm Wait 0x0078 _0807E778 0x0004 DoFade4 @@ -61,7 +61,7 @@ SCRIPT_START script_08015CD4 _0807E778 0x0004 DoFade5 WaitFor_2 - SoundReq0x80100000 + StopBgm SetRoomFlag 0x0000 DoPostScriptAction 0x0006 SCRIPT_END diff --git a/data/scripts/script_080160A8.inc b/data/scripts/script_080160A8.inc index d46b5f74..95381b9a 100644 --- a/data/scripts/script_080160A8.inc +++ b/data/scripts/script_080160A8.inc @@ -179,7 +179,7 @@ script_080162F6: Call sub_0807F594 Call sub_0807DF28 _0807E864 - SoundReq0x80100000 + StopBgm PlaySound SFX_TASK_COMPLETE Wait 0x003c PlayBgm BGM_LEARN_SCROLL diff --git a/data/scripts/script_08016482.inc b/data/scripts/script_08016482.inc index df0eea91..9ca8e7f6 100644 --- a/data/scripts/script_08016482.inc +++ b/data/scripts/script_08016482.inc @@ -63,7 +63,7 @@ SCRIPT_START script_08016482 PlaySound SFX_METAL_CLINK PlayBgm BGM_MINISH_WOODS SoundReq 0x00000074 - SoundReq0x80100000 + StopBgm ModRupees 0xff38 ModHealth 0x0010 IncreaseMaxHealth diff --git a/include/audio.h b/include/audio.h index 98a1f9cf..4f8ecb84 100644 --- a/include/audio.h +++ b/include/audio.h @@ -556,25 +556,43 @@ typedef enum { SFX_221, // special functions SONG_STOP_ALL = 0x80010000, - SONG_VOL_ZERO = 0x80020000, - SONG_VOL_RESET_ALL = 0x80030000, + SONG_MUTE = 0x80020000, + SONG_PLAY_VOL_RESET_ALL = 0x80030000, SONG_VSYNC_OFF = 0x80040000, SONG_STOP = 0x80050000, SONG_VSYNC_ON = 0x80060000, - SONG_UNK_7 = 0x80070000, + SONG_CONTINUE = 0x80070000, SONG_VOL_FADE_OUT = 0x80080000, - SONG_UNK_9 = 0x80090000, - SONG_UNK_A = 0x800A0000, - SONG_VOL_RESET = 0x800B0000, - SONG_UNK_C = 0x800C0000, - SONG_VOL_CHAN1_SILENT = 0x800D0000, - SONG_VOL_CHAN1_RESET = 0x800E0000, - SONG_UNK_F = 0x800F0000, - SONG_RESET_UNK = 0x80100000, - SONG_UNK_11 = 0x80110000, + SONG_FADE_IN = 0x80090000, + SONG_FADE_IN_CONTINUE = 0x800A0000, + SONG_PLAY_VOL_RESET = 0x800B0000, + SONG_PLAY_TEMPO_CONTROL = 0x800C0000, + SONG_FADE_OUT_BGM = 0x800D0000, + SONG_FADE_IN_BGM = 0x800E0000, + SONG_INIT = 0x800F0000, + SONG_STOP_BGM = 0x80100000, + SONG_BGM_0 = 0x80110000, } Sound; +typedef struct SoundPlayingInfo { + u16 unk_00; + bool8 stopBgm; + // u8 unk_03; + u16 unk_04; + s16 volumeMasterUnk; + s16 volumeMaster; + s16 volumeMasterTarget; + s16 volumeBgmUnk; + s16 volumeBgm; + s16 volumeBgmTarget; + s16 volumeSfx; + u16 currentBgm; +} SoundPlayingInfo; + +extern SoundPlayingInfo gSoundPlayingInfo; + void InitSound(void); void SoundReq(Sound sound); +void SoundLoop(void); #endif // AUDIO_H diff --git a/include/functions.h b/include/functions.h index 74c0471e..b73bd01d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -142,7 +142,7 @@ extern void sub_080AF2E4(void); extern void sub_0804F578(void); extern void sub_08059994(void); extern s32 sub_0801CFA8(u32); -extern void sub_080A3210(void); +extern void InitSoundPlayingInfo(void); extern void sub_080ADA14(u32, u32); // trampoline to sub_080B27F4 extern void sub_0801E1B8(u32, u32); extern void sub_0801E1EC(s32, s32, s32); diff --git a/include/main.h b/include/main.h index feaaf73e..3e8c63eb 100644 --- a/include/main.h +++ b/include/main.h @@ -88,7 +88,6 @@ extern void sub_08056260(void); extern void VBlankIntrWait(); extern void MessageUpdate(void); extern void sub_08050154(void); -extern void sub_080A3480(void); extern u8 gUnk_03003DE4; diff --git a/include/structures.h b/include/structures.h index 81bb36b4..d47ee7a1 100644 --- a/include/structures.h +++ b/include/structures.h @@ -182,23 +182,6 @@ typedef struct { extern EntityHandler gUnk_03003DC0; -typedef struct struct_02021EE0 { - u16 unk_00; - u8 unk_02; - u8 unk_03; - u16 unk_04; - s16 unk_06; - s16 unk_08; - s16 unk_0a; - s16 unk_0c; - s16 unk_0e; - s16 unk_10; - s16 unk_12; - u16 currentBgm; -} struct_02021EE0; - -extern struct_02021EE0 gUnk_02021EE0; - extern u8 gUnk_02022740[]; extern u8 gUnk_02034490[]; diff --git a/linker.ld b/linker.ld index 0976e69c..171afd37 100644 --- a/linker.ld +++ b/linker.ld @@ -78,7 +78,7 @@ SECTIONS { . = 0x00019EE0; gUnk_02019EE0 = .; . = 0x00019F6C; gUnk_02019F6C = .; . = 0x0001AEE0; gUnk_0201AEE0 = .; - . = 0x00021EE0; gUnk_02021EE0 = .; + . = 0x00021EE0; gSoundPlayingInfo = .; . = 0x00021F00; gUnk_02021F00 = .; . = 0x00021F20; gUnk_02021F20 = .; . = 0x00021F30; gBG1Buffer = .; diff --git a/src/audio.c b/src/audio.c index e294f01a..e43a1c21 100644 --- a/src/audio.c +++ b/src/audio.c @@ -3,88 +3,86 @@ #include "gba/m4a.h" #include "audio.h" #include "utils.h" -#include "structures.h" - -s32 sub_080A3518(s32, s32); -void sub_080A353C(u32); -void sub_080A35A0(u32); -void sub_080A35B4(u32); -void sub_080A35C8(void); #define IS_BGM(song) (song) - 1 <= NUM_BGM - 1 #define IS_SFX(song) (song) - 1 > NUM_BGM - 1 -void sub_080A3210(void); +void InitSoundPlayingInfo(void); +s32 fade(s32 target, s32 current); +void doPlaySound(u32 sound); +void PlayFadeIn(u32 sound); +void PlayFadeOut(u32 sound); +void InitVolume(void); -void InitSound(void){ - sub_080A3210(); +void InitSound(void) { + InitSoundPlayingInfo(); m4aSoundInit(); } -void sub_080A3210(void){ - MemClear(&gUnk_02021EE0, 0x18); - sub_080A35C8(); - gUnk_02021EE0.unk_12 = 0x100; - gUnk_02021EE0.unk_04 = 0x100; +void InitSoundPlayingInfo(void) { + MemClear(&gSoundPlayingInfo, sizeof(gSoundPlayingInfo)); + InitVolume(); + gSoundPlayingInfo.volumeSfx = 0x100; + gSoundPlayingInfo.unk_04 = 0x100; m4aMPlayAllStop(); } -void sub_080A3234(u32 arg){ - gUnk_02021EE0.unk_08 = arg; - gUnk_02021EE0.unk_0a = arg; - sub_080A353C(gUnk_02021EE0.currentBgm); +void SetMasterVolume(u32 volume) { + gSoundPlayingInfo.volumeMaster = volume; + gSoundPlayingInfo.volumeMasterTarget = volume; + doPlaySound(gSoundPlayingInfo.currentBgm); } -void sub_080A3248(u32 arg){ - gUnk_02021EE0.unk_10 = arg; - gUnk_02021EE0.unk_0e = arg; - sub_080A353C(gUnk_02021EE0.currentBgm); +void SetBgmVolume(u32 volume) { + gSoundPlayingInfo.volumeBgmTarget = volume; + gSoundPlayingInfo.volumeBgm = volume; + doPlaySound(gSoundPlayingInfo.currentBgm); } -void sub_080A325C(u32 arg){ - gUnk_02021EE0.unk_12 = arg; +void SetSfxVolume(u32 volume) { + gSoundPlayingInfo.volumeSfx = volume; } void SoundReq(Sound sound) { u32 song; - struct_02021EE0* ptr; + SoundPlayingInfo* ptr; if (gMain.field_0x7) return; - ptr = &gUnk_02021EE0; + ptr = &gSoundPlayingInfo; song = sound & 0xffff; switch (sound & 0xffff0000) { case SONG_STOP_ALL: ptr->currentBgm = 0; m4aMPlayAllStop(); return; - case SONG_VOL_ZERO: - sub_080A3234(0); + case SONG_MUTE: + SetMasterVolume(0); return; - case SONG_VOL_RESET_ALL: - sub_080A35C8(); - ptr->unk_12 = 0x100; - sub_080A353C(ptr->currentBgm); + case SONG_PLAY_VOL_RESET_ALL: + InitVolume(); + ptr->volumeSfx = 0x100; + doPlaySound(ptr->currentBgm); return; case SONG_VOL_FADE_OUT: - sub_080A35B4(ptr->currentBgm); + PlayFadeOut(ptr->currentBgm); return; - case SONG_UNK_9: + case SONG_FADE_IN: if (song == 0) song = ptr->currentBgm; if (IS_SFX(song)) return; ptr->currentBgm = song; m4aSongNumStart(song); - sub_080A35A0(song); + PlayFadeIn(song); return; - case SONG_UNK_A: + case SONG_FADE_IN_CONTINUE: if (IS_SFX(song)) return; ptr->currentBgm = song; m4aSongNumStartOrContinue(song); - sub_080A35A0(song); + PlayFadeIn(song); return; - case SONG_UNK_C: + case SONG_PLAY_TEMPO_CONTROL: m4aMPlayTempoControl(gMPlayTable[gSongTable[ptr->currentBgm].ms].info, song); return; case SONG_VSYNC_OFF: @@ -98,34 +96,34 @@ void SoundReq(Sound sound) { return; case SONG_VSYNC_ON: m4aSoundVSyncOn(); - case SONG_UNK_7: + case SONG_CONTINUE: if (ptr->currentBgm == 0) return; m4aSongNumStartOrContinue(ptr->currentBgm); - sub_080A353C(ptr->currentBgm); + doPlaySound(ptr->currentBgm); return; - case SONG_VOL_RESET: + case SONG_PLAY_VOL_RESET: if (IS_SFX(song)) return; ptr->currentBgm = song; m4aSongNumStartOrContinue(song); - sub_080A35C8(); - sub_080A353C(song); + InitVolume(); + doPlaySound(song); return; - case SONG_VOL_CHAN1_SILENT: - ptr->unk_10 = 0; + case SONG_FADE_OUT_BGM: + ptr->volumeBgmTarget = 0; return; - case SONG_RESET_UNK: - ptr->unk_10 = 0; - ptr->unk_02 = 1; + case SONG_STOP_BGM: + ptr->volumeBgmTarget = 0; + ptr->stopBgm = TRUE; return; - case SONG_VOL_CHAN1_RESET: - ptr->unk_10 = 0x100; + case SONG_FADE_IN_BGM: + ptr->volumeBgmTarget = 0x100; return; - case SONG_UNK_F: - sub_080A35C8(); + case SONG_INIT: + InitVolume(); return; - case SONG_UNK_11: + case SONG_BGM_0: ptr->currentBgm = 0; return; default: @@ -133,109 +131,106 @@ void SoundReq(Sound sound) { if (IS_BGM(song)) { ptr->currentBgm = song; m4aSongNumStart(song); - sub_080A35C8(); + InitVolume(); } else { m4aSongNumStart(song); } - sub_080A353C(song); + doPlaySound(song); } return; } } -void sub_080A3480(void) { - u32 iVar2; - struct_02021EE0* ptr = &gUnk_02021EE0; +void SoundLoop(void) { + s32 fadeValue; + SoundPlayingInfo* ptr = &gSoundPlayingInfo; - if (ptr->unk_0a != ptr->unk_08) { - iVar2 = sub_080A3518(ptr->unk_0a, ptr->unk_08); - if (iVar2 == 0) { - ptr->unk_08 = ptr->unk_0a; + if (ptr->volumeMasterTarget != ptr->volumeMaster) { + fadeValue = fade(ptr->volumeMasterTarget, ptr->volumeMaster); + if (fadeValue == 0) { + ptr->volumeMaster = ptr->volumeMasterTarget; } else { - ptr->unk_08 = ptr->unk_08 + iVar2; + ptr->volumeMaster = ptr->volumeMaster + fadeValue; } - if (ptr->unk_08 < 0) { - ptr->unk_0a = 0; - ptr->unk_08 = 0; + if (ptr->volumeMaster < 0) { + ptr->volumeMasterTarget = 0; + ptr->volumeMaster = 0; } - sub_080A353C(ptr->currentBgm); + doPlaySound(ptr->currentBgm); } else { - if (ptr->unk_10 != ptr->unk_0e) { - iVar2 = sub_080A3518(ptr->unk_10, ptr->unk_0e); - if (iVar2 == 0) { - if (ptr->unk_02 != 0 && ptr->unk_10 == 0) { - ptr->unk_02 = 0; + if (ptr->volumeBgmTarget != ptr->volumeBgm) { + fadeValue = fade(ptr->volumeBgmTarget, ptr->volumeBgm); + if (fadeValue == 0) { + if (ptr->stopBgm && ptr->volumeBgmTarget == 0) { + ptr->stopBgm = FALSE; ptr->currentBgm = 0; m4aSongNumStop(0); } else { - ptr->unk_0e = ptr->unk_10; + ptr->volumeBgm = ptr->volumeBgmTarget; } } else { - ptr->unk_0e += iVar2; + ptr->volumeBgm += fadeValue; } - if (ptr->unk_0e < 0) { - ptr->unk_10 = 0; - ptr->unk_0e = 0; + if (ptr->volumeBgm < 0) { + ptr->volumeBgmTarget = 0; + ptr->volumeBgm = 0; } - sub_080A353C(ptr->currentBgm); + doPlaySound(ptr->currentBgm); } } } -s32 sub_080A3518(s32 unk_1, s32 unk_2){ - if (unk_1 - unk_2 >= 1) { - unk_2 += 4; - if (unk_1 > unk_2) +s32 fade(s32 target, s32 current) { + if (target - current >= 1) { + current += 4; + if (target > current) return 4; - else - return 0; + return 0; } else { - unk_2 -= 4; - if (unk_1 < unk_2) + current -= 4; + if (target < current) return -4; - else - return 0; + return 0; } } -void sub_080A353C(u32 song){ +void doPlaySound(u32 sound) { u32 volume; u32 iVar2; MusicPlayerInfo* musicPlayerInfo; - if(song == 0) + if (sound == 0) return; - if (IS_BGM(song)) { - volume = gUnk_02021EE0.unk_0e; + if (IS_BGM(sound)) { + volume = gSoundPlayingInfo.volumeBgm; + } else { + volume = gSoundPlayingInfo.volumeSfx; } - else{ - volume = gUnk_02021EE0.unk_12; - } - iVar2 = gUnk_02021EE0.unk_08; + iVar2 = gSoundPlayingInfo.volumeMaster; volume = iVar2 * volume / 0x100; - musicPlayerInfo = gMPlayTable[gSongTable[song].ms].info; + musicPlayerInfo = gMPlayTable[gSongTable[sound].ms].info; m4aMPlayImmInit(musicPlayerInfo); m4aMPlayVolumeControl(musicPlayerInfo, 0xffff, volume); } -void sub_080A35A0(u32 song){ - gUnk_02021EE0.unk_0a = 0x100; - sub_080A353C(song); +void PlayFadeIn(u32 sound) { + gSoundPlayingInfo.volumeMasterTarget = 0x100; + doPlaySound(sound); } -void sub_080A35B4(u32 song){ - gUnk_02021EE0.unk_0a = 0; - sub_080A353C(song); +void PlayFadeOut(u32 sound) { + gSoundPlayingInfo.volumeMasterTarget = 0; + doPlaySound(sound); } -void sub_080A35C8(){ - gUnk_02021EE0.unk_06 = 0x100; - gUnk_02021EE0.unk_08 = 0x100; - gUnk_02021EE0.unk_0a = 0x100; - gUnk_02021EE0.unk_0c = 0x100; - gUnk_02021EE0.unk_0e = 0x100; - gUnk_02021EE0.unk_10 = 0x100; +void InitVolume() { + gSoundPlayingInfo.volumeMasterUnk = 0x100; + gSoundPlayingInfo.volumeMaster = 0x100; + gSoundPlayingInfo.volumeMasterTarget = 0x100; + gSoundPlayingInfo.volumeBgmUnk = 0x100; + gSoundPlayingInfo.volumeBgm = 0x100; + gSoundPlayingInfo.volumeBgmTarget = 0x100; } extern const SongHeader sfxNone; diff --git a/src/debugScreen.c b/src/debugScreen.c index bc034e8e..33b947af 100644 --- a/src/debugScreen.c +++ b/src/debugScreen.c @@ -33,7 +33,7 @@ void sub_0805FA04(void) { sub_08053320(); sub_0801D79C(0, 0x1144); gMain.funcIndex = 1; - sub_080A3210(); + InitSoundPlayingInfo(); sub_08050008(); } diff --git a/src/fileScreen.c b/src/fileScreen.c index b55977ca..4ac173c6 100644 --- a/src/fileScreen.c +++ b/src/fileScreen.c @@ -190,7 +190,7 @@ static void HandleFileScreenEnter(void) { u32 i; DispReset(1); - sub_080A3210(); + InitSoundPlayingInfo(); MemClear((void*)VRAM, 0x80); // clear palettes MessageInitialize(); EraseAllEntities(); diff --git a/src/intro.c b/src/intro.c index e3ee0f9d..6d24d922 100644 --- a/src/intro.c +++ b/src/intro.c @@ -158,7 +158,7 @@ static void HandleTitlescreen(void) { gIntroState.swordBgScaleRatio = 0x10; UpdateSwordBgAffineData(); } - sub_080A3210(); + InitSoundPlayingInfo(); SoundReq(BGM_TITLE_SCREEN); DoFade(6, 8); break; diff --git a/src/main.c b/src/main.c index 5cf16717..15f634fa 100644 --- a/src/main.c +++ b/src/main.c @@ -73,7 +73,7 @@ void AgbMain(void) { sScreenHandlers[gMain.screen](); MessageUpdate(); sub_08050154(); - sub_080A3480(); + SoundLoop(); break; } PrepNextFrame(); diff --git a/src/manager/manager15.c b/src/manager/manager15.c index 295f14c7..25cc4f87 100644 --- a/src/manager/manager15.c +++ b/src/manager/manager15.c @@ -81,7 +81,7 @@ void sub_0805A370(Manager15* this) { if (this->manager.unk_0d) { LoadRoomEntityList((EntityData*)&gUnk_080E4C08); this->manager.action = 3; - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); } } diff --git a/src/manager/managerB.c b/src/manager/managerB.c index ae0ea131..470ef89d 100644 --- a/src/manager/managerB.c +++ b/src/manager/managerB.c @@ -19,7 +19,7 @@ void (*const ManagerB_ActionFuncs[])(Manager*); void sub_080585F0(Manager* this) { - // make a distincion if this is a controller (unk_0a = 0) or a helper (unk_0a = 1) + // make a distincion if this is a controller (volumeMasterTarget = 0) or a helper (volumeMasterTarget = 1) ManagerB_ActionFuncs[this->unk_0a](this); } @@ -141,7 +141,7 @@ void ManagerBHelper_Monitor(ManagerBHelper* this, Entity* ent, u32 index) { this->manager.unk_0e++; } -// case unk_0a is 1: The manager is a helper +// case volumeMasterTarget is 1: The manager is a helper void ManagerBHelper_Main(Manager* this) { u8 i, anyRemaining; diff --git a/src/room.c b/src/room.c index 4a9527b7..e0e5a435 100644 --- a/src/room.c +++ b/src/room.c @@ -2241,7 +2241,7 @@ void sub_0804CD48(void) { if (CheckGlobalFlag(LV1_CLEAR)) { LoadRoomEntityList(&gUnk_080DF94C); } else { - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); gArea.musicIndex = gArea.pMusicIndex; } } @@ -2429,7 +2429,7 @@ void sub_0804CED8(void) { sub_0807AABC(&gPlayerEntity); LoadRoomEntityList(&gUnk_080E1814); } else { - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); gArea.musicIndex = gArea.pMusicIndex; } } @@ -2523,7 +2523,7 @@ void sub_0804CFB0(void) { if (!CheckFlags(0x31)) { if (gScreenTransition.field_0x38 == 0) { - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); } else { if (gScreenTransition.field_0x39 == 0) { SoundReq(SONG_STOP); @@ -2761,7 +2761,7 @@ void sub_0804D140(void) { if (CheckGlobalFlag(LV4_CLEAR)) { LoadRoomEntityList(&gUnk_080E49F4); } else { - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); gArea.musicIndex = gArea.pMusicIndex; } } @@ -3090,7 +3090,7 @@ void sub_0804D384(void) { sub_08078A90(3); LoadRoomEntityList(&gUnk_080E72E4); gArea.musicIndex = gArea.pMusicIndex; - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); } } } @@ -3498,7 +3498,7 @@ u32 sub_0804D6C4() { } void sub_0804D6C8(void) { - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); gArea.musicIndex = gArea.pMusicIndex; } @@ -4506,7 +4506,7 @@ void sub_0804E3C4() { index = 0xE; } sub_0804B3C4(&gUnk_080F0E1C[index]); - SoundReq(SONG_RESET_UNK); + SoundReq(SONG_STOP_BGM); } u32 sub_0804E45C() { @@ -4714,7 +4714,7 @@ extern EntityData gUnk_080F2E2C; void sub_0804E6E8(void) { if (!CheckGlobalFlag(OUTDOOR)) { gArea.musicIndex = gArea.pMusicIndex; - SoundReq(SONG_VOL_RESET | BGM_MINISH_CAP); + SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP); } if (!CheckGlobalFlag(START)) { LoadRoomEntityList(&gUnk_080F2E2C); @@ -4731,7 +4731,7 @@ extern EntityData gUnk_080F2EC4; void sub_0804E72C(void) { if (!CheckGlobalFlag(OUTDOOR)) { gArea.musicIndex = gArea.pMusicIndex; - SoundReq(SONG_VOL_RESET | BGM_MINISH_CAP); + SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP); } if (!CheckGlobalFlag(START)) { LoadRoomEntityList(&gUnk_080F2E94); @@ -4783,7 +4783,7 @@ void sub_0804E7DC(void) { } if (!CheckGlobalFlag(OUTDOOR)) { gArea.musicIndex = gArea.pMusicIndex; - SoundReq(SONG_VOL_RESET | BGM_MINISH_CAP); + SoundReq(SONG_PLAY_VOL_RESET | BGM_MINISH_CAP); } if ((gPlayerState.flags.all & 8) == 0) { LoadRoomEntityList(&gUnk_080F31D8); diff --git a/src/save.c b/src/save.c index be070f98..8f0a23b1 100644 --- a/src/save.c +++ b/src/save.c @@ -1,5 +1,6 @@ #include "save.h" #include "gba/eeprom.h" +#include "audio.h" typedef struct SaveFileStatus { u16 checksum1; @@ -67,8 +68,8 @@ SaveResult HandleSave(u32 arg0) { } SaveResult HandleSaveInit(u32 arg0) { - gUnk_02021EE0.unk_0a -= 8; - if (gUnk_02021EE0.unk_08 <= 0) { + gSoundPlayingInfo.volumeMasterTarget -= 8; + if (gSoundPlayingInfo.volumeMaster <= 0) { gMenu.field_0xa = 8; gMenu.storyPanelIndex = SAVE_IN_PROGRESS; } @@ -105,9 +106,9 @@ SaveResult HandleSaveDone(u32 arg0) { SaveResult result; result = SAVE_BUSY; - gUnk_02021EE0.unk_0a += 8; - if (gUnk_02021EE0.unk_06 <= gUnk_02021EE0.unk_0a) { - gUnk_02021EE0.unk_0a = gUnk_02021EE0.unk_06; + gSoundPlayingInfo.volumeMasterTarget += 8; + if (gSoundPlayingInfo.volumeMasterUnk <= gSoundPlayingInfo.volumeMasterTarget) { + gSoundPlayingInfo.volumeMasterTarget = gSoundPlayingInfo.volumeMasterUnk; sub_08050384(); gMenu.storyPanelIndex = SAVE_INIT; if (gMenu.field_0xa == 1) { diff --git a/src/script.c b/src/script.c index ea063d28..105f7af2 100644 --- a/src/script.c +++ b/src/script.c @@ -141,7 +141,7 @@ void ScriptCommand_DoPostScriptAction2(Entity* entity, ScriptExecutionContext* c void ScriptCommand_PlaySound(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_PlayBgm(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_SoundReq0x80100000(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_StopBgm(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_ModRupees(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_ModHealth(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_IncreaseMaxHealth(Entity* entity, ScriptExecutionContext* context); @@ -287,7 +287,7 @@ const ScriptCommand gScriptCommands[] = { ScriptCommandNop, ScriptCommand_PlaySound, ScriptCommand_PlayBgm, ScriptCommand_SoundReq, - ScriptCommand_SoundReq0x80100000, + ScriptCommand_StopBgm, ScriptCommand_ModRupees, ScriptCommand_ModHealth, ScriptCommand_IncreaseMaxHealth, @@ -1467,8 +1467,8 @@ void ScriptCommand_SoundReq(Entity* entity, ScriptExecutionContext* context) { SoundReq(GetNextScriptCommandWordAfterCommandMetadata(context->scriptInstructionPointer)); } -void ScriptCommand_SoundReq0x80100000(Entity* entity, ScriptExecutionContext* context) { - SoundReq(SONG_RESET_UNK); +void ScriptCommand_StopBgm(Entity* entity, ScriptExecutionContext* context) { + SoundReq(SONG_STOP_BGM); } void ScriptCommand_ModRupees(Entity* entity, ScriptExecutionContext* context) {