diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014A498.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014A498.s index 013083418f..69f5b7c302 100644 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014A498.s +++ b/asm/nonmatchings/code_e0b30_len_b80/func_8014A498.s @@ -30,10 +30,10 @@ glabel func_8014A498 /* E0BF4 8014A4F4 1440FFF0 */ bnez $v0, .L8014A4B8 /* E0BF8 8014A4F8 24840030 */ addiu $a0, $a0, 0x30 /* E0BFC 8014A4FC 24020008 */ addiu $v0, $zero, 8 -/* E0C00 8014A500 3C018016 */ lui $at, %hi(D_80159AE2) -/* E0C04 8014A504 A4229AE2 */ sh $v0, %lo(D_80159AE2)($at) -/* E0C08 8014A508 3C018016 */ lui $at, %hi(D_80159AE4) -/* E0C0C 8014A50C A4229AE4 */ sh $v0, %lo(D_80159AE4)($at) +/* E0C00 8014A500 3C018016 */ lui $at, %hi(gMusicTargetVolume) +/* E0C04 8014A504 A4229AE2 */ sh $v0, %lo(gMusicTargetVolume)($at) +/* E0C08 8014A508 3C018016 */ lui $at, %hi(gMusicUnkVolume2) +/* E0C0C 8014A50C A4229AE4 */ sh $v0, %lo(gMusicUnkVolume2)($at) /* E0C10 8014A510 3C018016 */ lui $at, 0x8016 /* E0C14 8014A514 A4229AE6 */ sh $v0, -0x651a($at) /* E0C18 8014A518 0C015869 */ jal func_800561A4 diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AB0C.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AB0C.s deleted file mode 100644 index 8f8d3ba207..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AB0C.s +++ /dev/null @@ -1,27 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AB0C -/* E120C 8014AB0C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E1210 8014AB10 3C028016 */ lui $v0, 0x8016 -/* E1214 8014AB14 24429AF0 */ addiu $v0, $v0, -0x6510 -/* E1218 8014AB18 00041840 */ sll $v1, $a0, 1 -/* E121C 8014AB1C 00641821 */ addu $v1, $v1, $a0 -/* E1220 8014AB20 00031900 */ sll $v1, $v1, 4 -/* E1224 8014AB24 00621821 */ addu $v1, $v1, $v0 -/* E1228 8014AB28 AFBF0010 */ sw $ra, 0x10($sp) -/* E122C 8014AB2C 94620000 */ lhu $v0, ($v1) -/* E1230 8014AB30 30420001 */ andi $v0, $v0, 1 -/* E1234 8014AB34 10400006 */ beqz $v0, .L8014AB50 -/* E1238 8014AB38 00052C00 */ sll $a1, $a1, 0x10 -/* E123C 8014AB3C 8C640018 */ lw $a0, 0x18($v1) -/* E1240 8014AB40 0C015777 */ jal func_80055DDC -/* E1244 8014AB44 00052C03 */ sra $a1, $a1, 0x10 -/* E1248 8014AB48 08052AD5 */ j .L8014AB54 -/* E124C 8014AB4C 00000000 */ nop -.L8014AB50: -/* E1250 8014AB50 0000102D */ daddu $v0, $zero, $zero -.L8014AB54: -/* E1254 8014AB54 8FBF0010 */ lw $ra, 0x10($sp) -/* E1258 8014AB58 03E00008 */ jr $ra -/* E125C 8014AB5C 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AB60.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AB60.s deleted file mode 100644 index 46042b52a4..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AB60.s +++ /dev/null @@ -1,27 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AB60 -/* E1260 8014AB60 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E1264 8014AB64 3C028016 */ lui $v0, 0x8016 -/* E1268 8014AB68 24429AF0 */ addiu $v0, $v0, -0x6510 -/* E126C 8014AB6C 00041840 */ sll $v1, $a0, 1 -/* E1270 8014AB70 00641821 */ addu $v1, $v1, $a0 -/* E1274 8014AB74 00031900 */ sll $v1, $v1, 4 -/* E1278 8014AB78 00621821 */ addu $v1, $v1, $v0 -/* E127C 8014AB7C AFBF0010 */ sw $ra, 0x10($sp) -/* E1280 8014AB80 94620000 */ lhu $v0, ($v1) -/* E1284 8014AB84 30420001 */ andi $v0, $v0, 1 -/* E1288 8014AB88 10400006 */ beqz $v0, .L8014ABA4 -/* E128C 8014AB8C 00052C00 */ sll $a1, $a1, 0x10 -/* E1290 8014AB90 8C640018 */ lw $a0, 0x18($v1) -/* E1294 8014AB94 0C015792 */ jal func_80055E48 -/* E1298 8014AB98 00052C03 */ sra $a1, $a1, 0x10 -/* E129C 8014AB9C 08052AEA */ j .L8014ABA8 -/* E12A0 8014ABA0 00000000 */ nop -.L8014ABA4: -/* E12A4 8014ABA4 0000102D */ daddu $v0, $zero, $zero -.L8014ABA8: -/* E12A8 8014ABA8 8FBF0010 */ lw $ra, 0x10($sp) -/* E12AC 8014ABAC 03E00008 */ jr $ra -/* E12B0 8014ABB0 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014ABB4.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014ABB4.s deleted file mode 100644 index 1899e95433..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014ABB4.s +++ /dev/null @@ -1,27 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014ABB4 -/* E12B4 8014ABB4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* E12B8 8014ABB8 3C028016 */ lui $v0, 0x8016 -/* E12BC 8014ABBC 24429AF0 */ addiu $v0, $v0, -0x6510 -/* E12C0 8014ABC0 00041840 */ sll $v1, $a0, 1 -/* E12C4 8014ABC4 00641821 */ addu $v1, $v1, $a0 -/* E12C8 8014ABC8 00031900 */ sll $v1, $v1, 4 -/* E12CC 8014ABCC 00621821 */ addu $v1, $v1, $v0 -/* E12D0 8014ABD0 AFBF0010 */ sw $ra, 0x10($sp) -/* E12D4 8014ABD4 94620000 */ lhu $v0, ($v1) -/* E12D8 8014ABD8 30420001 */ andi $v0, $v0, 1 -/* E12DC 8014ABDC 10400006 */ beqz $v0, .L8014ABF8 -/* E12E0 8014ABE0 00052C00 */ sll $a1, $a1, 0x10 -/* E12E4 8014ABE4 8C640018 */ lw $a0, 0x18($v1) -/* E12E8 8014ABE8 0C015731 */ jal func_80055CC4 -/* E12EC 8014ABEC 00052C03 */ sra $a1, $a1, 0x10 -/* E12F0 8014ABF0 08052AFF */ j .L8014ABFC -/* E12F4 8014ABF4 00000000 */ nop -.L8014ABF8: -/* E12F8 8014ABF8 0000102D */ daddu $v0, $zero, $zero -.L8014ABFC: -/* E12FC 8014ABFC 8FBF0010 */ lw $ra, 0x10($sp) -/* E1300 8014AC00 03E00008 */ jr $ra -/* E1304 8014AC04 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC08.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AC08.s deleted file mode 100644 index 0b64c7e4d2..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC08.s +++ /dev/null @@ -1,25 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AC08 -/* E1308 8014AC08 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* E130C 8014AC0C 0000202D */ daddu $a0, $zero, $zero -/* E1310 8014AC10 2405FFFF */ addiu $a1, $zero, -1 -/* E1314 8014AC14 0080302D */ daddu $a2, $a0, $zero -/* E1318 8014AC18 240700FA */ addiu $a3, $zero, 0xfa -/* E131C 8014AC1C AFB00018 */ sw $s0, 0x18($sp) -/* E1320 8014AC20 24100008 */ addiu $s0, $zero, 8 -/* E1324 8014AC24 AFBF001C */ sw $ra, 0x1c($sp) -/* E1328 8014AC28 0C052A46 */ jal set_music_track -/* E132C 8014AC2C AFB00010 */ sw $s0, 0x10($sp) -/* E1330 8014AC30 24040001 */ addiu $a0, $zero, 1 -/* E1334 8014AC34 2405FFFF */ addiu $a1, $zero, -1 -/* E1338 8014AC38 0000302D */ daddu $a2, $zero, $zero -/* E133C 8014AC3C 240700FA */ addiu $a3, $zero, 0xfa -/* E1340 8014AC40 0C052A46 */ jal set_music_track -/* E1344 8014AC44 AFB00010 */ sw $s0, 0x10($sp) -/* E1348 8014AC48 8FBF001C */ lw $ra, 0x1c($sp) -/* E134C 8014AC4C 8FB00018 */ lw $s0, 0x18($sp) -/* E1350 8014AC50 24020001 */ addiu $v0, $zero, 1 -/* E1354 8014AC54 03E00008 */ jr $ra -/* E1358 8014AC58 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC5C.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AC5C.s deleted file mode 100644 index 3bc632238a..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC5C.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AC5C -/* E135C 8014AC5C 24020004 */ addiu $v0, $zero, 4 -/* E1360 8014AC60 3C018016 */ lui $at, %hi(D_80159AE4) -/* E1364 8014AC64 A4229AE4 */ sh $v0, %lo(D_80159AE4)($at) -/* E1368 8014AC68 03E00008 */ jr $ra -/* E136C 8014AC6C 00000000 */ nop diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC70.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AC70.s deleted file mode 100644 index 9b0abe19a3..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC70.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AC70 -/* E1370 8014AC70 24020008 */ addiu $v0, $zero, 8 -/* E1374 8014AC74 3C018016 */ lui $at, %hi(D_80159AE4) -/* E1378 8014AC78 A4229AE4 */ sh $v0, %lo(D_80159AE4)($at) -/* E137C 8014AC7C 03E00008 */ jr $ra -/* E1380 8014AC80 00000000 */ nop diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC94.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AC94.s index 3428a38914..f1b97ef67a 100644 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AC94.s +++ b/asm/nonmatchings/code_e0b30_len_b80/func_8014AC94.s @@ -13,15 +13,15 @@ glabel func_8014AC94 /* E13B4 8014ACB4 08052B4D */ j .L8014AD34 /* E13B8 8014ACB8 A4820000 */ sh $v0, ($a0) .L8014ACBC: -/* E13BC 8014ACBC 3C038016 */ lui $v1, %hi(D_80159AE2) -/* E13C0 8014ACC0 84639AE2 */ lh $v1, %lo(D_80159AE2)($v1) -/* E13C4 8014ACC4 3C028016 */ lui $v0, %hi(D_80159AE4) -/* E13C8 8014ACC8 84429AE4 */ lh $v0, %lo(D_80159AE4)($v0) -/* E13CC 8014ACCC 3C048016 */ lui $a0, %hi(D_80159AE2) -/* E13D0 8014ACD0 94849AE2 */ lhu $a0, %lo(D_80159AE2)($a0) +/* E13BC 8014ACBC 3C038016 */ lui $v1, %hi(gMusicTargetVolume) +/* E13C0 8014ACC0 84639AE2 */ lh $v1, %lo(gMusicTargetVolume)($v1) +/* E13C4 8014ACC4 3C028016 */ lui $v0, %hi(gMusicUnkVolume2) +/* E13C8 8014ACC8 84429AE4 */ lh $v0, %lo(gMusicUnkVolume2)($v0) +/* E13CC 8014ACCC 3C048016 */ lui $a0, %hi(gMusicTargetVolume) +/* E13D0 8014ACD0 94849AE2 */ lhu $a0, %lo(gMusicTargetVolume)($a0) /* E13D4 8014ACD4 0043102A */ slt $v0, $v0, $v1 -/* E13D8 8014ACD8 3C038016 */ lui $v1, %hi(D_80159AE4) -/* E13DC 8014ACDC 94639AE4 */ lhu $v1, %lo(D_80159AE4)($v1) +/* E13D8 8014ACD8 3C038016 */ lui $v1, %hi(gMusicUnkVolume2) +/* E13DC 8014ACDC 94639AE4 */ lhu $v1, %lo(gMusicUnkVolume2)($v1) /* E13E0 8014ACE0 54400001 */ bnel $v0, $zero, .L8014ACE8 /* E13E4 8014ACE4 0060202D */ daddu $a0, $v1, $zero .L8014ACE8: @@ -41,7 +41,7 @@ glabel func_8014AC94 /* E1418 8014AD18 3C048016 */ lui $a0, 0x8016 /* E141C 8014AD1C 84849AE6 */ lh $a0, -0x651a($a0) /* E1420 8014AD20 0C015869 */ jal func_800561A4 -/* E1424 8014AD24 00000000 */ nop +/* E1424 8014AD24 00000000 */ nop /* E1428 8014AD28 24020003 */ addiu $v0, $zero, 3 /* E142C 8014AD2C 3C018015 */ lui $at, 0x8015 /* E1430 8014AD30 A422F738 */ sh $v0, -0x8c8($at) diff --git a/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s b/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s deleted file mode 100644 index d105d8a217..0000000000 --- a/asm/nonmatchings/code_e0b30_len_b80/func_8014AF8C.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8014AF8C -/* E168C 8014AF8C 3C028016 */ lui $v0, 0x8016 -/* E1690 8014AF90 24429AF0 */ addiu $v0, $v0, -0x6510 -/* E1694 8014AF94 AC44001C */ sw $a0, 0x1c($v0) -/* E1698 8014AF98 03E00008 */ jr $ra -/* E169C 8014AF9C AC450020 */ sw $a1, 0x20($v0) diff --git a/include/common_structs.h b/include/common_structs.h index 74516f195e..3034c2317c 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -316,7 +316,9 @@ typedef struct MusicPlayer { /* 0x10 */ s32 songID; /* 0x14 */ s32 variation; /* 0x18 */ s32 unk_18; - /* 0x1C */ char unk_1C[20]; + /* 0x1C */ s32 unk_1C; + /* 0x20 */ s32 unk_20; + /* 0x24 */ char unk_24[12]; } MusicPlayer; // size = 0x30 typedef struct MenuIcon { diff --git a/include/variables.h b/include/variables.h index dff7fd36a2..0d6ce235df 100644 --- a/include/variables.h +++ b/include/variables.h @@ -80,8 +80,6 @@ extern s32 D_8010CD20; extern s32 D_8010EF08; extern s32 D_8010F094; // player shadow index? extern s32 D_801595A0; -extern s16 D_80159AE2; // music target volume? -extern s16 D_80159AE4; extern BackgroundHeader gBackgroundImage; extern PrintContext* gCurrentPrintContext; @@ -166,6 +164,7 @@ extern Bytecode* ShakeCam1; extern Bytecode* ShakeCamX; extern s16 gMusicUnkVolume; +extern s16 gMusicUnkVolume2; extern s16 gMusicCurrentVolume; extern s16 gMusicTargetVolume; extern MusicPlayer gMusicPlayers[]; diff --git a/src/code_e0b30_len_b80.c b/src/code_e0b30_len_b80.c index 0e24ebc7df..f186d032a8 100644 --- a/src/code_e0b30_len_b80.c +++ b/src/code_e0b30_len_b80.c @@ -1,6 +1,5 @@ #include "common.h" - void func_8014AC84(s16 volume); INCLUDE_ASM(s32, "code_e0b30_len_b80", get_default_variation_for_song); @@ -8,8 +7,8 @@ INCLUDE_ASM(s32, "code_e0b30_len_b80", get_default_variation_for_song); INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014A498); void func_8014A52C(void) { - D_80159AE2 = 0x08; - D_80159AE4 = 0x08; + gMusicTargetVolume = 8; + gMusicUnkVolume2 = 8; } INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014A548); @@ -126,20 +125,56 @@ s32 func_8014AA54(s32 playerIndex, s32 arg1, s16 arg2) { return 1; } -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AB0C); +s32 func_8014AB0C(s32 playerIndex, s16 arg1) { + MusicPlayer* musicPlayers = &gMusicPlayers; + MusicPlayer* musicPlayer = &musicPlayers[playerIndex]; -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AB60); + if (!(musicPlayer->flags & 1)) { + return 0; + } -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014ABB4); + return func_80055DDC(musicPlayer->unk_18, arg1); +} -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AC08); +s32 func_8014AB60(s32 playerIndex, s16 arg1) { + MusicPlayer* musicPlayers = &gMusicPlayers; + MusicPlayer* musicPlayer = &musicPlayers[playerIndex]; -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AC5C); + if (!(musicPlayer->flags & 1)) { + return 0; + } -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AC70); + return func_80055E48(musicPlayer->unk_18, arg1); +} + +s32 func_8014ABB4(s32 playerIndex, s16 arg1) { + MusicPlayer* musicPlayers = &gMusicPlayers; + MusicPlayer* musicPlayer = &musicPlayers[playerIndex]; + + if (!(musicPlayer->flags & 1)) { + return 0; + } + + return func_80055CC4(musicPlayer->unk_18, arg1); +} + +s32 func_8014AC08(void) { + set_music_track(0, -1, 0, 250, 8); + set_music_track(1, -1, 0, 250, 8); + + return 1; +} + +void func_8014AC5C(void) { + gMusicUnkVolume2 = 4; +} + +void func_8014AC70(void) { + gMusicUnkVolume2 = 8; +} void func_8014AC84(s16 volume) { - D_80159AE2 = volume; + gMusicTargetVolume = volume; } INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AC94); @@ -154,7 +189,11 @@ INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AE6C); INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AEF8); -INCLUDE_ASM(s32, "code_e0b30_len_b80", func_8014AF8C); +void func_8014AF8C(s32 arg0, s32 arg1) { + MusicPlayer* musicPlayer = &gMusicPlayers[0]; + musicPlayer->unk_1C = arg0; + musicPlayer->unk_20 = arg1; +} void func_8014AFA0(void) { } diff --git a/tools/symbol_addrs.txt b/tools/symbol_addrs.txt index c83ba8dce3..27ca6bc9e6 100644 --- a/tools/symbol_addrs.txt +++ b/tools/symbol_addrs.txt @@ -1901,5 +1901,6 @@ D_80078DB0;0x80078DB0 D_80078DB4;0x80078DB4 gMusicPlayers;0x80159AF0 gMusicUnkVolume;0x80159AE0 +gMusicUnkVolume2;0x80159AE4 gMusicTargetVolume;0x80159AE2 gMusicCurVolume;0x80159AE6 diff --git a/undefined_syms.txt b/undefined_syms.txt index ba19514be9..0442c35f66 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -179,8 +179,12 @@ gTriggerList2 = 0x80159290; gCurrentTriggerListPtr = 0x80159390; D_801595A0 = 0x801595A0; -D_80159AE2 = 0x80159AE2; -D_80159AE4 = 0x80159AE4; +gMusicUnkVolume = 0x80159AE0; +gMusicTargetVolume = 0x80159AE2; +gMusicUnkVolume2 = 0x80159AE4; +gMusicCurVolume = 0x80159AE6; +gMusicPlayers = 0x80159AF0; + gCollisionStatus = 0x8015A550; D_8015C7C0 = 0x8015C7C0; gLastCreatedEntityIndex = 0x801512EC; @@ -263,8 +267,3 @@ EnemyNpcDefeat = 0x8007809C; D_80078DB0 = 0x80078DB0; D_80078DB4 = 0x80078DB4; - -gMusicUnkVolume = 0x80159AE0; -gMusicTargetVolume = 0x80159AE2; -gMusicCurVolume = 0x80159AE6; -gMusicPlayers = 0x80159AF0;