From 4932e93ba29a4297c4a19c363b9c6e8692a5a7d7 Mon Sep 17 00:00:00 2001 From: Roman971 <32455037+Roman971@users.noreply.github.com> Date: Fri, 1 May 2020 04:00:39 +0200 Subject: [PATCH] Decompile 2 small files (code_8006BA00.c and code_8006C3A0.c) (#101) * Decompile code_8006C3A0.c (handling "env" flags) * Decompile code_8006BA00.c (handling sound sources) --- asm/code_8006BA00.s | 137 ------------------ .../code/code_8006C3A0/func_8006C3A0.s | 15 -- .../code/code_8006C3A0/func_8006C3D0.s | 30 ---- .../code/code_8006C3A0/func_8006C438.s | 30 ---- .../code/code_8006C3A0/func_8006C4A4.s | 30 ---- asm/non_matchings/code/z_play/Gameplay_Init.s | 2 +- .../ovl_Bg_Relay_Objects/func_808A939C.s | 2 +- .../ovl_Bg_Spot00_Hanebasi/func_808A9BE8.s | 2 +- .../ovl_Bg_Spot11_Oasis/func_808B2980.s | 2 +- .../actors/ovl_Demo_Effect/func_80972008.s | 2 +- .../actors/ovl_Demo_Effect/func_80976404.s | 2 +- .../actors/ovl_Demo_Kankyo/DemoKankyo_Draw.s | 2 +- .../actors/ovl_Demo_Kankyo/func_809892A4.s | 2 +- .../overlays/actors/ovl_En_Mag/EnMag_Update.s | 4 +- .../actors/ovl_Obj_Bean/func_80B90158.s | 4 +- include/functions.h | 18 +-- include/z64.h | 11 +- spec | 2 +- src/code/code_8006BA00.c | 65 +++++++++ src/code/code_8006C3A0.c | 32 +++- src/code/z_actor.c | 2 +- src/code/z_demo.c | 12 +- src/code/z_effect_soft_sprite.c | 2 +- src/code/z_lib.c | 13 +- src/code/z_play.c | 2 +- .../ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c | 2 +- .../actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c | 2 +- src/overlays/actors/ovl_Demo_Go/z_demo_go.c | 2 +- src/overlays/actors/ovl_Door_Ana/z_door_ana.c | 2 +- .../z_en_okarina_effect.c | 4 +- src/overlays/actors/ovl_En_Ru1/z_en_ru1.c | 2 +- 31 files changed, 143 insertions(+), 296 deletions(-) delete mode 100644 asm/code_8006BA00.s delete mode 100644 asm/non_matchings/code/code_8006C3A0/func_8006C3A0.s delete mode 100644 asm/non_matchings/code/code_8006C3A0/func_8006C3D0.s delete mode 100644 asm/non_matchings/code/code_8006C3A0/func_8006C438.s delete mode 100644 asm/non_matchings/code/code_8006C3A0/func_8006C4A4.s create mode 100644 src/code/code_8006BA00.c diff --git a/asm/code_8006BA00.s b/asm/code_8006BA00.s deleted file mode 100644 index 49b5091d83..0000000000 --- a/asm/code_8006BA00.s +++ /dev/null @@ -1,137 +0,0 @@ -.include "macro.inc" - -# assembler directives -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches -.set gp=64 # allow use of 64-bit general purposee registers - -.section .text - -.align 4 - -glabel func_8006BA00 -/* AE2BA0 8006BA00 24831DB4 */ addiu $v1, $a0, 0x1db4 -/* AE2BA4 8006BA04 24040010 */ li $a0, 16 -/* AE2BA8 8006BA08 00001025 */ move $v0, $zero -.L8006BA0C: -/* AE2BAC 8006BA0C 24420004 */ addiu $v0, $v0, 4 -/* AE2BB0 8006BA10 A4600000 */ sh $zero, ($v1) -/* AE2BB4 8006BA14 A460001C */ sh $zero, 0x1c($v1) -/* AE2BB8 8006BA18 A4600038 */ sh $zero, 0x38($v1) -/* AE2BBC 8006BA1C A4600054 */ sh $zero, 0x54($v1) -/* AE2BC0 8006BA20 1444FFFA */ bne $v0, $a0, .L8006BA0C -/* AE2BC4 8006BA24 24630070 */ addiu $v1, $v1, 0x70 -/* AE2BC8 8006BA28 03E00008 */ jr $ra -/* AE2BCC 8006BA2C 00000000 */ nop - -glabel func_8006BA30 -/* AE2BD0 8006BA30 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* AE2BD4 8006BA34 AFB40028 */ sw $s4, 0x28($sp) -/* AE2BD8 8006BA38 AFB30024 */ sw $s3, 0x24($sp) -/* AE2BDC 8006BA3C AFB20020 */ sw $s2, 0x20($sp) -/* AE2BE0 8006BA40 AFB1001C */ sw $s1, 0x1c($sp) -/* AE2BE4 8006BA44 AFB00018 */ sw $s0, 0x18($sp) -/* AE2BE8 8006BA48 3C140001 */ lui $s4, (0x00011D60 >> 16) # lui $s4, 1 -/* AE2BEC 8006BA4C 00809025 */ move $s2, $a0 -/* AE2BF0 8006BA50 AFBF002C */ sw $ra, 0x2c($sp) -/* AE2BF4 8006BA54 24901DB4 */ addiu $s0, $a0, 0x1db4 -/* AE2BF8 8006BA58 36941D60 */ ori $s4, (0x00011D60 & 0xFFFF) # ori $s4, $s4, 0x1d60 -/* AE2BFC 8006BA5C 00008825 */ move $s1, $zero -/* AE2C00 8006BA60 24130010 */ li $s3, 16 -.L8006BA64: -/* AE2C04 8006BA64 96020000 */ lhu $v0, ($s0) -/* AE2C08 8006BA68 50400011 */ beql $v0, $zero, .L8006BAB0 -/* AE2C0C 8006BA6C 26310001 */ addiu $s1, $s1, 1 -/* AE2C10 8006BA70 14400003 */ bnez $v0, .L8006BA80 -/* AE2C14 8006BA74 244EFFFF */ addiu $t6, $v0, -1 -/* AE2C18 8006BA78 10000003 */ b .L8006BA88 -/* AE2C1C 8006BA7C 00001825 */ move $v1, $zero -.L8006BA80: -/* AE2C20 8006BA80 A60E0000 */ sh $t6, ($s0) -/* AE2C24 8006BA84 31C3FFFF */ andi $v1, $t6, 0xffff -.L8006BA88: -/* AE2C28 8006BA88 14600005 */ bnez $v1, .L8006BAA0 -/* AE2C2C 8006BA8C 02542021 */ addu $a0, $s2, $s4 -/* AE2C30 8006BA90 0C03E27A */ jal func_800F89E8 -/* AE2C34 8006BA94 26040010 */ addiu $a0, $s0, 0x10 -/* AE2C38 8006BA98 10000005 */ b .L8006BAB0 -/* AE2C3C 8006BA9C 26310001 */ addiu $s1, $s1, 1 -.L8006BAA0: -/* AE2C40 8006BAA0 26050004 */ addiu $a1, $s0, 4 -/* AE2C44 8006BAA4 0C029BBD */ jal func_800A6EF4 -/* AE2C48 8006BAA8 26060010 */ addiu $a2, $s0, 0x10 -/* AE2C4C 8006BAAC 26310001 */ addiu $s1, $s1, 1 -.L8006BAB0: -/* AE2C50 8006BAB0 1633FFEC */ bne $s1, $s3, .L8006BA64 -/* AE2C54 8006BAB4 2610001C */ addiu $s0, $s0, 0x1c -/* AE2C58 8006BAB8 8FBF002C */ lw $ra, 0x2c($sp) -/* AE2C5C 8006BABC 8FB00018 */ lw $s0, 0x18($sp) -/* AE2C60 8006BAC0 8FB1001C */ lw $s1, 0x1c($sp) -/* AE2C64 8006BAC4 8FB20020 */ lw $s2, 0x20($sp) -/* AE2C68 8006BAC8 8FB30024 */ lw $s3, 0x24($sp) -/* AE2C6C 8006BACC 8FB40028 */ lw $s4, 0x28($sp) -/* AE2C70 8006BAD0 03E00008 */ jr $ra -/* AE2C74 8006BAD4 27BD0030 */ addiu $sp, $sp, 0x30 - -glabel Audio_PlaySoundAtPosition -/* AE2C78 8006BAD8 27BDFFC8 */ addiu $sp, $sp, -0x38 -/* AE2C7C 8006BADC AFA40038 */ sw $a0, 0x38($sp) -/* AE2C80 8006BAE0 AFA5003C */ sw $a1, 0x3c($sp) -/* AE2C84 8006BAE4 24881DB4 */ addiu $t0, $a0, 0x1db4 -/* AE2C88 8006BAE8 AFBF001C */ sw $ra, 0x1c($sp) -/* AE2C8C 8006BAEC AFA60040 */ sw $a2, 0x40($sp) -/* AE2C90 8006BAF0 AFA70044 */ sw $a3, 0x44($sp) -/* AE2C94 8006BAF4 340AFFFF */ li $t2, 65535 -/* AE2C98 8006BAF8 24040010 */ li $a0, 16 -/* AE2C9C 8006BAFC 8FA50028 */ lw $a1, 0x28($sp) -/* AE2CA0 8006BB00 00004825 */ move $t1, $zero -.L8006BB04: -/* AE2CA4 8006BB04 95020000 */ lhu $v0, ($t0) -/* AE2CA8 8006BB08 10400007 */ beqz $v0, .L8006BB28 -/* AE2CAC 8006BB0C 004A082A */ slt $at, $v0, $t2 -/* AE2CB0 8006BB10 10200003 */ beqz $at, .L8006BB20 -/* AE2CB4 8006BB14 25290001 */ addiu $t1, $t1, 1 -/* AE2CB8 8006BB18 00405025 */ move $t2, $v0 -/* AE2CBC 8006BB1C 01002825 */ move $a1, $t0 -.L8006BB20: -/* AE2CC0 8006BB20 1524FFF8 */ bne $t1, $a0, .L8006BB04 -/* AE2CC4 8006BB24 2508001C */ addiu $t0, $t0, 0x1c -.L8006BB28: -/* AE2CC8 8006BB28 29210010 */ slti $at, $t1, 0x10 -/* AE2CCC 8006BB2C 14200004 */ bnez $at, .L8006BB40 -/* AE2CD0 8006BB30 24A40010 */ addiu $a0, $a1, 0x10 -/* AE2CD4 8006BB34 0C03E27A */ jal func_800F89E8 -/* AE2CD8 8006BB38 AFA50030 */ sw $a1, 0x30($sp) -/* AE2CDC 8006BB3C 8FA80030 */ lw $t0, 0x30($sp) -.L8006BB40: -/* AE2CE0 8006BB40 8FAE003C */ lw $t6, 0x3c($sp) -/* AE2CE4 8006BB44 25050004 */ addiu $a1, $t0, 4 -/* AE2CE8 8006BB48 3C010001 */ lui $at, (0x00011D60 >> 16) # lui $at, 1 -/* AE2CEC 8006BB4C 8DD80000 */ lw $t8, ($t6) -/* AE2CF0 8006BB50 34211D60 */ ori $at, (0x00011D60 & 0xFFFF) # ori $at, $at, 0x1d60 -/* AE2CF4 8006BB54 25060010 */ addiu $a2, $t0, 0x10 -/* AE2CF8 8006BB58 ACB80000 */ sw $t8, ($a1) -/* AE2CFC 8006BB5C 8DCF0004 */ lw $t7, 4($t6) -/* AE2D00 8006BB60 ACAF0004 */ sw $t7, 4($a1) -/* AE2D04 8006BB64 8DD80008 */ lw $t8, 8($t6) -/* AE2D08 8006BB68 ACB80008 */ sw $t8, 8($a1) -/* AE2D0C 8006BB6C 8FB90040 */ lw $t9, 0x40($sp) -/* AE2D10 8006BB70 A5190000 */ sh $t9, ($t0) -/* AE2D14 8006BB74 8FA40038 */ lw $a0, 0x38($sp) -/* AE2D18 8006BB78 AFA60020 */ sw $a2, 0x20($sp) -/* AE2D1C 8006BB7C 0C029BBD */ jal func_800A6EF4 -/* AE2D20 8006BB80 00812021 */ addu $a0, $a0, $at -/* AE2D24 8006BB84 3C078013 */ lui $a3, %hi(D_801333E0) # $a3, 0x8013 -/* AE2D28 8006BB88 3C0B8013 */ lui $t3, %hi(D_801333E8) # $t3, 0x8013 -/* AE2D2C 8006BB8C 24E733E0 */ addiu $a3, %lo(D_801333E0) # addiu $a3, $a3, 0x33e0 -/* AE2D30 8006BB90 256B33E8 */ addiu $t3, %lo(D_801333E8) # addiu $t3, $t3, 0x33e8 -/* AE2D34 8006BB94 AFAB0014 */ sw $t3, 0x14($sp) -/* AE2D38 8006BB98 AFA70010 */ sw $a3, 0x10($sp) -/* AE2D3C 8006BB9C 97A40046 */ lhu $a0, 0x46($sp) -/* AE2D40 8006BBA0 8FA50020 */ lw $a1, 0x20($sp) -/* AE2D44 8006BBA4 0C03DCE3 */ jal Audio_PlaySoundGeneral -/* AE2D48 8006BBA8 24060004 */ li $a2, 4 -/* AE2D4C 8006BBAC 8FBF001C */ lw $ra, 0x1c($sp) -/* AE2D50 8006BBB0 27BD0038 */ addiu $sp, $sp, 0x38 -/* AE2D54 8006BBB4 03E00008 */ jr $ra -/* AE2D58 8006BBB8 00000000 */ nop diff --git a/asm/non_matchings/code/code_8006C3A0/func_8006C3A0.s b/asm/non_matchings/code/code_8006C3A0/func_8006C3A0.s deleted file mode 100644 index d769b48fac..0000000000 --- a/asm/non_matchings/code/code_8006C3A0/func_8006C3A0.s +++ /dev/null @@ -1,15 +0,0 @@ -glabel func_8006C3A0 -/* AE3540 8006C3A0 00001025 */ move $v0, $zero -/* AE3544 8006C3A4 3C030001 */ lui $v1, 1 -.L8006C3A8: -/* AE3548 8006C3A8 00027040 */ sll $t6, $v0, 1 -/* AE354C 8006C3AC 24420001 */ addiu $v0, $v0, 1 -/* AE3550 8006C3B0 304200FF */ andi $v0, $v0, 0xff -/* AE3554 8006C3B4 008E7821 */ addu $t7, $a0, $t6 -/* AE3558 8006C3B8 28410014 */ slti $at, $v0, 0x14 -/* AE355C 8006C3BC 01E3C021 */ addu $t8, $t7, $v1 -/* AE3560 8006C3C0 1420FFF9 */ bnez $at, .L8006C3A8 -/* AE3564 8006C3C4 A70020FC */ sh $zero, 0x20fc($t8) -/* AE3568 8006C3C8 03E00008 */ jr $ra -/* AE356C 8006C3CC 00000000 */ nop - diff --git a/asm/non_matchings/code/code_8006C3A0/func_8006C3D0.s b/asm/non_matchings/code/code_8006C3A0/func_8006C3D0.s deleted file mode 100644 index 6bc453d230..0000000000 --- a/asm/non_matchings/code/code_8006C3A0/func_8006C3D0.s +++ /dev/null @@ -1,30 +0,0 @@ -glabel func_8006C3D0 -/* AE3570 8006C3D0 AFA50004 */ sw $a1, 4($sp) -/* AE3574 8006C3D4 00052C00 */ sll $a1, $a1, 0x10 -/* AE3578 8006C3D8 00052C03 */ sra $a1, $a1, 0x10 -/* AE357C 8006C3DC 04A10003 */ bgez $a1, .L8006C3EC -/* AE3580 8006C3E0 00057103 */ sra $t6, $a1, 4 -/* AE3584 8006C3E4 24A1000F */ addiu $at, $a1, 0xf -/* AE3588 8006C3E8 00017103 */ sra $t6, $at, 4 -.L8006C3EC: -/* AE358C 8006C3EC 000E7C00 */ sll $t7, $t6, 0x10 -/* AE3590 8006C3F0 000FC403 */ sra $t8, $t7, 0x10 -/* AE3594 8006C3F4 0018C840 */ sll $t9, $t8, 1 -/* AE3598 8006C3F8 00991021 */ addu $v0, $a0, $t9 -/* AE359C 8006C3FC 3C010001 */ lui $at, 1 -/* AE35A0 8006C400 00411021 */ addu $v0, $v0, $at -/* AE35A4 8006C404 944820FC */ lhu $t0, 0x20fc($v0) -/* AE35A8 8006C408 04A10004 */ bgez $a1, .L8006C41C -/* AE35AC 8006C40C 30A9000F */ andi $t1, $a1, 0xf -/* AE35B0 8006C410 11200002 */ beqz $t1, .L8006C41C -/* AE35B4 8006C414 00000000 */ nop -/* AE35B8 8006C418 2529FFF0 */ addiu $t1, $t1, -0x10 -.L8006C41C: -/* AE35BC 8006C41C 00095400 */ sll $t2, $t1, 0x10 -/* AE35C0 8006C420 000A5C03 */ sra $t3, $t2, 0x10 -/* AE35C4 8006C424 240C0001 */ li $t4, 1 -/* AE35C8 8006C428 016C7804 */ sllv $t7, $t4, $t3 -/* AE35CC 8006C42C 010FC025 */ or $t8, $t0, $t7 -/* AE35D0 8006C430 03E00008 */ jr $ra -/* AE35D4 8006C434 A45820FC */ sh $t8, 0x20fc($v0) - diff --git a/asm/non_matchings/code/code_8006C3A0/func_8006C438.s b/asm/non_matchings/code/code_8006C3A0/func_8006C438.s deleted file mode 100644 index e85a148c51..0000000000 --- a/asm/non_matchings/code/code_8006C3A0/func_8006C438.s +++ /dev/null @@ -1,30 +0,0 @@ -glabel func_8006C438 -/* AE35D8 8006C438 AFA50004 */ sw $a1, 4($sp) -/* AE35DC 8006C43C 00052C00 */ sll $a1, $a1, 0x10 -/* AE35E0 8006C440 00052C03 */ sra $a1, $a1, 0x10 -/* AE35E4 8006C444 04A10003 */ bgez $a1, .L8006C454 -/* AE35E8 8006C448 00057103 */ sra $t6, $a1, 4 -/* AE35EC 8006C44C 24A1000F */ addiu $at, $a1, 0xf -/* AE35F0 8006C450 00017103 */ sra $t6, $at, 4 -.L8006C454: -/* AE35F4 8006C454 000E7C00 */ sll $t7, $t6, 0x10 -/* AE35F8 8006C458 000FC403 */ sra $t8, $t7, 0x10 -/* AE35FC 8006C45C 0018C840 */ sll $t9, $t8, 1 -/* AE3600 8006C460 00991021 */ addu $v0, $a0, $t9 -/* AE3604 8006C464 3C010001 */ lui $at, 1 -/* AE3608 8006C468 00411021 */ addu $v0, $v0, $at -/* AE360C 8006C46C 944820FC */ lhu $t0, 0x20fc($v0) -/* AE3610 8006C470 04A10004 */ bgez $a1, .L8006C484 -/* AE3614 8006C474 30A9000F */ andi $t1, $a1, 0xf -/* AE3618 8006C478 11200002 */ beqz $t1, .L8006C484 -/* AE361C 8006C47C 00000000 */ nop -/* AE3620 8006C480 2529FFF0 */ addiu $t1, $t1, -0x10 -.L8006C484: -/* AE3624 8006C484 00095400 */ sll $t2, $t1, 0x10 -/* AE3628 8006C488 000A5C03 */ sra $t3, $t2, 0x10 -/* AE362C 8006C48C 240C0001 */ li $t4, 1 -/* AE3630 8006C490 016C6804 */ sllv $t5, $t4, $t3 -/* AE3634 8006C494 39B8FFFF */ xori $t8, $t5, 0xffff -/* AE3638 8006C498 0118C824 */ and $t9, $t0, $t8 -/* AE363C 8006C49C 03E00008 */ jr $ra -/* AE3640 8006C4A0 A45920FC */ sh $t9, 0x20fc($v0) diff --git a/asm/non_matchings/code/code_8006C3A0/func_8006C4A4.s b/asm/non_matchings/code/code_8006C3A0/func_8006C4A4.s deleted file mode 100644 index 00dab16a03..0000000000 --- a/asm/non_matchings/code/code_8006C3A0/func_8006C4A4.s +++ /dev/null @@ -1,30 +0,0 @@ -glabel func_8006C4A4 -/* AE3644 8006C4A4 AFA50004 */ sw $a1, 4($sp) -/* AE3648 8006C4A8 00052C00 */ sll $a1, $a1, 0x10 -/* AE364C 8006C4AC 00052C03 */ sra $a1, $a1, 0x10 -/* AE3650 8006C4B0 04A10003 */ bgez $a1, .L8006C4C0 -/* AE3654 8006C4B4 00057103 */ sra $t6, $a1, 4 -/* AE3658 8006C4B8 24A1000F */ addiu $at, $a1, 0xf -/* AE365C 8006C4BC 00017103 */ sra $t6, $at, 4 -.L8006C4C0: -/* AE3660 8006C4C0 000E7C00 */ sll $t7, $t6, 0x10 -/* AE3664 8006C4C4 000FC403 */ sra $t8, $t7, 0x10 -/* AE3668 8006C4C8 0018C840 */ sll $t9, $t8, 1 -/* AE366C 8006C4CC 00994021 */ addu $t0, $a0, $t9 -/* AE3670 8006C4D0 3C090001 */ lui $t1, 1 -/* AE3674 8006C4D4 240D0001 */ li $t5, 1 -/* AE3678 8006C4D8 01284821 */ addu $t1, $t1, $t0 -/* AE367C 8006C4DC 952920FC */ lhu $t1, 0x20fc($t1) -/* AE3680 8006C4E0 04A10004 */ bgez $a1, .L8006C4F4 -/* AE3684 8006C4E4 30AA000F */ andi $t2, $a1, 0xf -/* AE3688 8006C4E8 11400002 */ beqz $t2, .L8006C4F4 -/* AE368C 8006C4EC 00000000 */ nop -/* AE3690 8006C4F0 254AFFF0 */ addiu $t2, $t2, -0x10 -.L8006C4F4: -/* AE3694 8006C4F4 000A5C00 */ sll $t3, $t2, 0x10 -/* AE3698 8006C4F8 000B6403 */ sra $t4, $t3, 0x10 -/* AE369C 8006C4FC 018D7004 */ sllv $t6, $t5, $t4 -/* AE36A0 8006C500 000E7C00 */ sll $t7, $t6, 0x10 -/* AE36A4 8006C504 000FC403 */ sra $t8, $t7, 0x10 -/* AE36A8 8006C508 03E00008 */ jr $ra -/* AE36AC 8006C50C 01381024 */ and $v0, $t1, $t8 \ No newline at end of file diff --git a/asm/non_matchings/code/z_play/Gameplay_Init.s b/asm/non_matchings/code/z_play/Gameplay_Init.s index 18df21dde1..a836cb1c39 100644 --- a/asm/non_matchings/code/z_play/Gameplay_Init.s +++ b/asm/non_matchings/code/z_play/Gameplay_Init.s @@ -479,7 +479,7 @@ glabel Gameplay_Init /* B34274 800BD0D4 24841498 */ addiu $a0, %lo(D_80161498) # addiu $a0, $a0, 0x1498 /* B34278 800BD0D8 3C018016 */ lui $at, %hi(D_801614B0+3) # $at, 0x8016 /* B3427C 800BD0DC A02014B3 */ sb $zero, %lo(D_801614B0+3)($at) -/* B34280 800BD0E0 0C01B0E8 */ jal func_8006C3A0 +/* B34280 800BD0E0 0C01B0E8 */ jal Flags_UnsetAllEnv /* B34284 800BD0E4 02202025 */ move $a0, $s1 /* B34288 800BD0E8 26300074 */ addiu $s0, $s1, 0x74 /* B3428C 800BD0EC 0C030EE2 */ jal THA_GetSize diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Relay_Objects/func_808A939C.s b/asm/non_matchings/overlays/actors/ovl_Bg_Relay_Objects/func_808A939C.s index 4606a907ad..57a752bddd 100644 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Relay_Objects/func_808A939C.s +++ b/asm/non_matchings/overlays/actors/ovl_Bg_Relay_Objects/func_808A939C.s @@ -9,7 +9,7 @@ glabel func_808A939C /* 00554 808A93A4 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 /* 00558 808A93A8 AFBF001C */ sw $ra, 0x001C($sp) /* 0055C 808A93AC 00A02025 */ or $a0, $a1, $zero ## $a0 = 00000000 -/* 00560 808A93B0 0C01B129 */ jal func_8006C4A4 +/* 00560 808A93B0 0C01B129 */ jal Flags_GetEnv /* 00564 808A93B4 24050005 */ addiu $a1, $zero, 0x0005 ## $a1 = 00000005 /* 00568 808A93B8 10400006 */ beq $v0, $zero, .L808A93D4 /* 0056C 808A93BC 26040032 */ addiu $a0, $s0, 0x0032 ## $a0 = 00000032 diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Spot00_Hanebasi/func_808A9BE8.s b/asm/non_matchings/overlays/actors/ovl_Bg_Spot00_Hanebasi/func_808A9BE8.s index 5dd7b2cbe1..f9df2fd198 100644 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Spot00_Hanebasi/func_808A9BE8.s +++ b/asm/non_matchings/overlays/actors/ovl_Bg_Spot00_Hanebasi/func_808A9BE8.s @@ -36,7 +36,7 @@ glabel func_808A9BE8 /* 004E8 808A9C68 51A00016 */ beql $t5, $zero, .L808A9CC4 /* 004EC 808A9C6C 84D800B4 */ lh $t8, 0x00B4($a2) ## 000000B4 /* 004F0 808A9C70 AFA60020 */ sw $a2, 0x0020($sp) -/* 004F4 808A9C74 0C01B129 */ jal func_8006C4A4 +/* 004F4 808A9C74 0C01B129 */ jal Flags_GetEnv /* 004F8 808A9C78 AFA8001C */ sw $t0, 0x001C($sp) /* 004FC 808A9C7C 3C078016 */ lui $a3, %hi(gSaveContext) /* 00500 808A9C80 24E7E660 */ addiu $a3, %lo(gSaveContext) diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Spot11_Oasis/func_808B2980.s b/asm/non_matchings/overlays/actors/ovl_Bg_Spot11_Oasis/func_808B2980.s index 5801bf5b12..4c58cdac21 100644 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Spot11_Oasis/func_808B2980.s +++ b/asm/non_matchings/overlays/actors/ovl_Bg_Spot11_Oasis/func_808B2980.s @@ -4,7 +4,7 @@ glabel func_808B2980 /* 00198 808B2988 AFBF001C */ sw $ra, 0x001C($sp) /* 0019C 808B298C AFA50024 */ sw $a1, 0x0024($sp) /* 001A0 808B2990 00A02025 */ or $a0, $a1, $zero ## $a0 = 00000000 -/* 001A4 808B2994 0C01B129 */ jal func_8006C4A4 +/* 001A4 808B2994 0C01B129 */ jal Flags_GetEnv /* 001A8 808B2998 24050005 */ addiu $a1, $zero, 0x0005 ## $a1 = 00000005 /* 001AC 808B299C 5040000D */ beql $v0, $zero, .L808B29D4 /* 001B0 808B29A0 8FBF001C */ lw $ra, 0x001C($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80972008.s b/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80972008.s index 4ba733d30d..44bea6c809 100644 --- a/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80972008.s +++ b/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80972008.s @@ -5,7 +5,7 @@ glabel func_80972008 /* 010C4 80972014 AFA5002C */ sw $a1, 0x002C($sp) /* 010C8 80972018 00A02025 */ or $a0, $a1, $zero ## $a0 = 00000000 /* 010CC 8097201C 24050001 */ addiu $a1, $zero, 0x0001 ## $a1 = 00000001 -/* 010D0 80972020 0C01B129 */ jal func_8006C4A4 +/* 010D0 80972020 0C01B129 */ jal Flags_GetEnv /* 010D4 80972024 AFA60028 */ sw $a2, 0x0028($sp) /* 010D8 80972028 1040001C */ beq $v0, $zero, .L8097209C /* 010DC 8097202C 8FA60028 */ lw $a2, 0x0028($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80976404.s b/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80976404.s index f8c29ed57d..0cfda704c2 100644 --- a/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80976404.s +++ b/asm/non_matchings/overlays/actors/ovl_Demo_Effect/func_80976404.s @@ -22,7 +22,7 @@ glabel func_80976404 /* 054DC 8097642C 24010019 */ addiu $at, $zero, 0x0019 ## $at = 00000019 /* 054E0 80976430 1041000D */ beq $v0, $at, .L80976468 /* 054E4 80976434 00A02025 */ or $a0, $a1, $zero ## $a0 = 00000000 -/* 054E8 80976438 0C01B129 */ jal func_8006C4A4 +/* 054E8 80976438 0C01B129 */ jal Flags_GetEnv /* 054EC 8097643C 24050001 */ addiu $a1, $zero, 0x0001 ## $a1 = 00000001 /* 054F0 80976440 14400009 */ bne $v0, $zero, .L80976468 /* 054F4 80976444 3C028016 */ lui $v0, %hi(gSaveContext) diff --git a/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/DemoKankyo_Draw.s b/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/DemoKankyo_Draw.s index 98990fccfc..8e30619e48 100644 --- a/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/DemoKankyo_Draw.s +++ b/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/DemoKankyo_Draw.s @@ -46,7 +46,7 @@ glabel L809899F8 /* 00B80 80989A00 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00B84 80989A04 57010024 */ bnel $t8, $at, .L80989A98 /* 00B88 80989A08 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B8C 80989A0C 0C01B129 */ jal func_8006C4A4 +/* 00B8C 80989A0C 0C01B129 */ jal Flags_GetEnv /* 00B90 80989A10 24050001 */ addiu $a1, $zero, 0x0001 ## $a1 = 00000001 /* 00B94 80989A14 14400003 */ bne $v0, $zero, .L80989A24 /* 00B98 80989A18 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 diff --git a/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/func_809892A4.s b/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/func_809892A4.s index 88de3fc419..2e08f0ac6c 100644 --- a/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/func_809892A4.s +++ b/asm/non_matchings/overlays/actors/ovl_Demo_Kankyo/func_809892A4.s @@ -55,7 +55,7 @@ glabel L80989300 glabel L80989318 /* 00498 80989318 00C02025 */ or $a0, $a2, $zero ## $a0 = 00000000 /* 0049C 8098931C 24050002 */ addiu $a1, $zero, 0x0002 ## $a1 = 00000002 -/* 004A0 80989320 0C01B129 */ jal func_8006C4A4 +/* 004A0 80989320 0C01B129 */ jal Flags_GetEnv /* 004A4 80989324 AFA70018 */ sw $a3, 0x0018($sp) /* 004A8 80989328 104000E8 */ beq $v0, $zero, .L809896CC /* 004AC 8098932C 8FA70018 */ lw $a3, 0x0018($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Mag/EnMag_Update.s b/asm/non_matchings/overlays/actors/ovl_En_Mag/EnMag_Update.s index 13059a97bc..12489ff740 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Mag/EnMag_Update.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Mag/EnMag_Update.s @@ -444,7 +444,7 @@ glabel EnMag_Update /* 00918 80AA4418 24010002 */ addiu $at, $zero, 0x0002 ## $at = 00000002 /* 0091C 80AA441C 1460000A */ bne $v1, $zero, .L80AA4448 /* 00920 80AA4420 00000000 */ nop -/* 00924 80AA4424 0C01B129 */ jal func_8006C4A4 +/* 00924 80AA4424 0C01B129 */ jal Flags_GetEnv /* 00928 80AA4428 8FA40044 */ lw $a0, 0x0044($sp) /* 0092C 80AA442C 1040000E */ beq $v0, $zero, .L80AA4468 /* 00930 80AA4430 24060001 */ addiu $a2, $zero, 0x0001 ## $a2 = 00000001 @@ -456,7 +456,7 @@ glabel EnMag_Update .L80AA4448: /* 00948 80AA4448 14610007 */ bne $v1, $at, .L80AA4468 /* 0094C 80AA444C 8FA40044 */ lw $a0, 0x0044($sp) -/* 00950 80AA4450 0C01B129 */ jal func_8006C4A4 +/* 00950 80AA4450 0C01B129 */ jal Flags_GetEnv /* 00954 80AA4454 24050004 */ addiu $a1, $zero, 0x0004 ## $a1 = 00000004 /* 00958 80AA4458 10400003 */ beq $v0, $zero, .L80AA4468 /* 0095C 80AA445C 240C0003 */ addiu $t4, $zero, 0x0003 ## $t4 = 00000003 diff --git a/asm/non_matchings/overlays/actors/ovl_Obj_Bean/func_80B90158.s b/asm/non_matchings/overlays/actors/ovl_Obj_Bean/func_80B90158.s index d5ab86c9f1..9095282d52 100644 --- a/asm/non_matchings/overlays/actors/ovl_Obj_Bean/func_80B90158.s +++ b/asm/non_matchings/overlays/actors/ovl_Obj_Bean/func_80B90158.s @@ -12,7 +12,7 @@ glabel func_80B90158 /* 01700 80B90180 31CF0040 */ andi $t7, $t6, 0x0040 ## $t7 = 00000000 /* 01704 80B90184 15E00020 */ bne $t7, $zero, .L80B90208 /* 01708 80B90188 00000000 */ nop -/* 0170C 80B9018C 0C01B129 */ jal func_8006C4A4 +/* 0170C 80B9018C 0C01B129 */ jal Flags_GetEnv /* 01710 80B90190 24050005 */ addiu $a1, $zero, 0x0005 ## $a1 = 00000005 /* 01714 80B90194 1040001C */ beq $v0, $zero, .L80B90208 /* 01718 80B90198 3C0380B9 */ lui $v1, %hi(D_80B90E30) ## $v1 = 80B90000 @@ -50,7 +50,7 @@ glabel func_80B90158 /* 01794 80B90214 8FA4002C */ lw $a0, 0x002C($sp) /* 01798 80B90218 560A0008 */ bnel $s0, $t2, .L80B9023C /* 0179C 80B9021C 8FBF0024 */ lw $ra, 0x0024($sp) -/* 017A0 80B90220 0C01B129 */ jal func_8006C4A4 +/* 017A0 80B90220 0C01B129 */ jal Flags_GetEnv /* 017A4 80B90224 24050005 */ addiu $a1, $zero, 0x0005 ## $a1 = 00000005 /* 017A8 80B90228 3C0380B9 */ lui $v1, %hi(D_80B90E30) ## $v1 = 80B90000 /* 017AC 80B9022C 14400002 */ bne $v0, $zero, .L80B90238 diff --git a/include/functions.h b/include/functions.h index 4a0659c20d..9f8284da8e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -821,16 +821,16 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx); void Cutscene_SetSegment(GlobalContext* globalCtx, u32 segment); void* MemCopy(void* dest, void* src, s32 size); void func_800694A0(GlobalContext* globalCtx, s16 drawId); -// ? func_8006BA00(?); -// ? func_8006BA30(?); -void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos2, s32 radius, u16 sfxId); +void func_8006BA00(GlobalContext* globalCtx); +void func_8006BA30(GlobalContext* globalCtx); +void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId); u16 ElfMessage_GetSariaText(GlobalContext* globalCtx); u16 ElfMessage_GetCUpText(GlobalContext* globalCtx); u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet); -// ? func_8006C3A0(?); -// ? func_8006C3D0(?); -void func_8006C438(GlobalContext* globalCtx, s16 arg1); -s32 func_8006C4A4(GlobalContext*, s32); +void Flags_UnsetAllEnv(GlobalContext* globalCtx); +void Flags_SetEnv(GlobalContext* globalCtx, s16 flag); +void Flags_UnsetEnv(GlobalContext* globalCtx, s16 flag); +s32 Flags_GetEnv(GlobalContext* globalCtx, s16 flag); // ? func_8006C510(?); // ? func_8006C5A8(?); // ? func_8006CBAC(?); @@ -1249,7 +1249,7 @@ void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx); // ? func_800A698C(?); // ? func_800A6AC4(?); // ? func_800A6E10(?); -// ? func_800A6EF4(?); +void func_800A6EF4(MtxF* mf, Vec3f* src, Vec3f* dest); // ? func_800A6FA0(?); // ? func_800A72FC(?); // ? func_800A730C(?); @@ -2190,7 +2190,7 @@ void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* a1, u32 a2, u32* a3, u32* a4, u32* // ? func_800F8480(?); // ? func_800F87A0(?); // ? func_800F8884(?); -// ? func_800F89E8(?); +void func_800F89E8(Vec3f*); void func_800F8D04(u32 a0); // ? func_800F8D04(?); // ? func_800F8E3C(?); diff --git a/include/z64.h b/include/z64.h index fc7fe852f8..411db75f72 100644 --- a/include/z64.h +++ b/include/z64.h @@ -579,6 +579,12 @@ typedef struct { /* 0x28 */ CsCmdActorAction* actorActions[10]; // "npcdemopnt" } CutsceneContext; // size = 0x50 +typedef struct { + /* 0x00 */ u16 countdown; + /* 0x04 */ Vec3f originPos; + /* 0x10 */ Vec3f relativePos; +} SoundSource; // size = 0x1C + typedef struct { /* 0x00 */ char unk_0[0x4]; } SubGlobalContext1F74; // size = 0x4 @@ -1030,7 +1036,7 @@ typedef struct GlobalContext { /* 0x007C0 */ CollisionContext colCtx; /* 0x01C24 */ ActorContext actorCtx; /* 0x01D64 */ CutsceneContext csCtx; // "demo_play" - /* 0x01DB4 */ char unk_1DB4[0x1C0]; + /* 0x01DB4 */ SoundSource soundSources[16]; /* 0x01F74 */ SubGlobalContext1F74 sub_1F74; /* 0x01F78 */ SkyboxContext skyboxCtx; /* 0x020C8 */ char unk_20C8[0x10]; @@ -1075,9 +1081,8 @@ typedef struct GlobalContext { /* 0x11E5C */ s8 unk_11E5C; /* 0x11E5D */ s8 bombchuBowlingAmmo; // "bombchu_game_flag" /* 0x11E5E */ u8 fadeTransition; - /* 0x11E5F */ char unk_11E5F[0x1]; /* 0x11E60 */ CollisionCheckContext colChkCtx; - /* 0x120FC */ char unk_120FC[0x28]; + /* 0x120FC */ u16 envFlags[20]; /* 0x12124 */ PreRenderContext preRenderCtx; /* 0x121C8 */ TransitionContext transitionCtx; /* 0x12418 */ char unk_12418[0x3]; diff --git a/spec b/spec index 6e685a4ec8..289268f77c 100644 --- a/spec +++ b/spec @@ -311,7 +311,7 @@ beginseg include "build/src/code/z_demo.o" include "build/src/code/code_80069420.o" include "build/src/code/z_draw.o" - include "build/asm/code_8006BA00.o" + include "build/src/code/code_8006BA00.o" include "build/src/code/z_elf_message.o" include "build/src/code/z_face_reaction.o" include "build/src/code/code_8006C3A0.o" diff --git a/src/code/code_8006BA00.c b/src/code/code_8006BA00.c new file mode 100644 index 0000000000..af2c688143 --- /dev/null +++ b/src/code/code_8006BA00.c @@ -0,0 +1,65 @@ +#include +#include + +void func_8006BA00(GlobalContext* globalCtx) { + SoundSource* sources = &globalCtx->soundSources[0]; + s32 i; + + // clang-format off + for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; } + // clang-format on +} + +void func_8006BA30(GlobalContext* globalCtx) { + SoundSource* source; + s32 i; + + source = &globalCtx->soundSources[0]; + for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + if (source->countdown != 0) { + if (DECR(source->countdown) == 0) { + func_800F89E8(&source->relativePos); + } else { + func_800A6EF4(&globalCtx->mf_11D60, &source->originPos, &source->relativePos); + } + } + + source++; + } +} + +void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId) { + s32 countdown; + SoundSource* source; + s32 smallestCountdown; + SoundSource* backupSource; + s32 i; + + smallestCountdown = 0xFFFF; + + source = &globalCtx->soundSources[0]; + for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + if (source->countdown == 0) { + break; + } + + countdown = source->countdown; + if (countdown < smallestCountdown) { + smallestCountdown = countdown; + backupSource = source; + } + + source++; + } + + if (i >= ARRAY_COUNT(globalCtx->soundSources)) { + source = backupSource; + func_800F89E8(&source->relativePos); + } + + source->originPos = *pos; + source->countdown = duration; + + func_800A6EF4(&globalCtx->mf_11D60, &source->originPos, &source->relativePos); + Audio_PlaySoundGeneral(sfxId, &source->relativePos, 4, &D_801333E0, &D_801333E0, &D_801333E8); +} diff --git a/src/code/code_8006C3A0.c b/src/code/code_8006C3A0.c index 1b7c77c4c1..7898695987 100644 --- a/src/code/code_8006C3A0.c +++ b/src/code/code_8006C3A0.c @@ -1,10 +1,34 @@ #include #include -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C3A0.s") +void Flags_UnsetAllEnv(GlobalContext* globalCtx) { + u8 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C3D0.s") + for (i = 0; i < 20; i++) { + globalCtx->envFlags[i] = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C438.s") +void Flags_SetEnv(GlobalContext* globalCtx, s16 flag) { + s16 index = flag / 16; + s16 bit = flag % 16; + s16 mask = 1 << bit; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8006C3A0/func_8006C4A4.s") + globalCtx->envFlags[index] |= mask; +} + +void Flags_UnsetEnv(GlobalContext* globalCtx, s16 flag) { + s16 index = flag / 16; + s16 bit = flag % 16; + s16 mask = (1 << bit) ^ 0xFFFF; + + globalCtx->envFlags[index] &= mask; +} + +s32 Flags_GetEnv(GlobalContext* globalCtx, s16 flag) { + s16 index = flag / 16; + s16 bit = flag % 16; + s16 mask = 1 << bit; + + return globalCtx->envFlags[index] & mask; +} diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 4da4a7128f..aa3b4999c9 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3054,7 +3054,7 @@ Actor* Actor_Find(ActorContext* actorCtx, s32 actorId, s32 actorType) { void func_80032C7C(GlobalContext* globalCtx, Actor* actor) { globalCtx->actorCtx.unk_00 = 5; - Audio_PlaySoundAtPosition(globalCtx, &actor->posRot.pos, 0x14, NA_SE_EN_LAST_DAMAGE); + Audio_PlaySoundAtPosition(globalCtx, &actor->posRot.pos, 20, NA_SE_EN_LAST_DAMAGE); } s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3) { diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 2a39229ac1..4a5c483063 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -193,9 +193,9 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* break; case 3: if (sp3F != 0) { - func_8006C3D0(globalCtx, 0); + Flags_SetEnv(globalCtx, 0); if (gSaveContext.entranceIndex == 0x0053) { - func_8006C3D0(globalCtx, 2); + Flags_SetEnv(globalCtx, 2); } } break; @@ -225,7 +225,7 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* globalCtx->envCtx.unk_EE[3] = 0x10; break; case 10: - func_8006C3D0(globalCtx, 1); + Flags_SetEnv(globalCtx, 1); break; case 11: if (globalCtx->unk_11D30[0] < 0x672) { @@ -350,10 +350,10 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* globalCtx->unk_11DE9 = 0; break; case 30: - func_8006C3D0(globalCtx, 3); + Flags_SetEnv(globalCtx, 3); break; case 31: - func_8006C3D0(globalCtx, 4); + Flags_SetEnv(globalCtx, 4); break; case 32: if (sp3F != 0) { @@ -1935,7 +1935,7 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) { } if ((gSaveContext.cutsceneIndex >= 0xFFF0) && (csCtx->state == CS_STATE_IDLE)) { - func_8006C438(globalCtx, 0); + Flags_UnsetEnv(globalCtx, 0); D_8011E1C0 = 0; D_8011E1C4 = 0; diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 34b264bf42..c5c9a7864c 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -36,7 +36,7 @@ void Effect_SS_Clear(GlobalContext* globalCtx) { void Effect_SS_Delete(LoadedParticleEntry* particle) { if (particle->flags & 2) { - func_800F89E8(particle); + func_800F89E8(&particle->position); } if (particle->flags & 4) { diff --git a/src/code/z_lib.c b/src/code/z_lib.c index c76e400c8f..d59cf7374c 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -2,16 +2,11 @@ #include void Lib_MemSet(u8* dest, size_t size, u8 val) { - u32 i = 0; + u32 i; - // TODO: Convert this to while/for if possible - if (i == size) { - return; - } - do { - *dest++ = val; - i++; - } while (i != size); + // clang-format off + for (i = 0; i < size; i++) { *dest++ = val; } + // clang-format on } f32 Math_Coss(s16 angle) { diff --git a/src/code/z_play.c b/src/code/z_play.c index 2723d2fa3f..1e20e00cba 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -367,7 +367,7 @@ void Gameplay_Init(GlobalContext* globalCtx) { TransitionFade_Start(&globalCtx->transitionFade); func_800AD000(&D_80161498); D_801614B0.a = 0x00; - func_8006C3A0(globalCtx); + Flags_UnsetAllEnv(globalCtx); osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetSize(&globalCtx->state.tha)); zAllocSize = THA_GetSize(&globalCtx->state.tha); diff --git a/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c b/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c index af7d5e0395..8f273446b7 100644 --- a/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c +++ b/src/overlays/actors/ovl_Bg_Spot05_Soko/z_bg_spot05_soko.c @@ -81,7 +81,7 @@ void func_808AE5A8(BgSpot05Soko* this, GlobalContext* globalCtx) { void func_808AE5B4(BgSpot05Soko* this, GlobalContext* globalCtx) { Actor* thisx = &this->dyna.actor; if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - Audio_PlaySoundAtPosition(globalCtx, &thisx->posRot.pos, 0x1E, NA_SE_EV_METALDOOR_CLOSE); + Audio_PlaySoundAtPosition(globalCtx, &thisx->posRot.pos, 30, NA_SE_EV_METALDOOR_CLOSE); Actor_SetHeight(thisx, 50.0f); func_80080480(globalCtx, thisx); this->actionFunc = func_808AE630; diff --git a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c index 00730a83a7..f8f152e2e1 100644 --- a/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c +++ b/src/overlays/actors/ovl_Bg_Toki_Swd/z_bg_toki_swd.c @@ -263,7 +263,7 @@ void func_808BB0AC(BgTokiSwd* this, GlobalContext* globalCtx) { } void func_808BB128(BgTokiSwd* this, GlobalContext* globalCtx) { - if ((func_8006C4A4(globalCtx, 1) != 0) && (globalCtx->unk_11D30[0] < 0xFF)) { + if (Flags_GetEnv(globalCtx, 1) && (globalCtx->unk_11D30[0] < 0xFF)) { globalCtx->unk_11D30[0] += 5; } } diff --git a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c index 3baf97a8fa..5e936fe7fb 100644 --- a/src/overlays/actors/ovl_Demo_Go/z_demo_go.c +++ b/src/overlays/actors/ovl_Demo_Go/z_demo_go.c @@ -80,7 +80,7 @@ void func_8097C8A8(DemoGo* this, GlobalContext* globalCtx) { if ((thisx->params == 0) || (thisx->params == 1)) { func_800A6E10(&globalCtx->mf_11D60, &thisx->posRot.pos, &sp20, &sp1C); - Audio_PlaySoundAtPosition(globalCtx, &sp20, 0x14, 0x28A0); + Audio_PlaySoundAtPosition(globalCtx, &sp20, 20, 0x28A0); } } diff --git a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index 467cb00900..a332ed58fa 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -87,7 +87,7 @@ void DoorAna_Update_Hidden(DoorAna* this, GlobalContext* globalCtx) { bool openGrotto = false; if ((this->actor.params & 0x200) == 0) { // opening with song of storms - if (this->actor.waterSurfaceDist < 40000.0f && func_8006C4A4(globalCtx, 5) != 0) { + if (this->actor.waterSurfaceDist < 40000.0f && Flags_GetEnv(globalCtx, 5)) { openGrotto = true; this->actor.flags &= ~0x10; } diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c index 85be094b27..81cb4cee59 100644 --- a/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c +++ b/src/overlays/actors/ovl_En_Okarina_Effect/z_en_okarina_effect.c @@ -73,7 +73,7 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, GlobalContext* globalCt } void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, GlobalContext* globalCtx) { - func_8006C438(globalCtx, 5); // clear bean grow env flag + Flags_UnsetEnv(globalCtx, 5); // clear storms env flag if (((globalCtx->pauseCtx.state == 0) && (globalCtx->unk_10A20 == 0) && (globalCtx->msgCtx.unk_E300 == 0) && (func_800C0D28(globalCtx) == 0) && ((globalCtx->transitionMode == 0) || (gSaveContext.gameMode != 0))) || (this->timer >= 250)) { @@ -84,7 +84,7 @@ void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, GlobalContext* globalCtx if (this->timer == 308) { // "Let's grow some beans" osSyncPrintf("\n\n\n豆よ のびろ 指定\n\n\n"); - func_8006C3D0(globalCtx, 5); // set bean grow env flag + Flags_SetEnv(globalCtx, 5); // set storms env flag } } diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index d11e8480bc..82ac2bb0f8 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -1930,7 +1930,7 @@ void func_80AEF40C(EnRu1* this) { } void func_80AEF4A8(EnRu1* this, GlobalContext* globalCtx) { - Audio_PlaySoundAtPosition(globalCtx, &this->actor.unk_E4, 0x14, NA_SE_VO_RT_FALL); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.unk_E4, 20, NA_SE_VO_RT_FALL); } void func_80AEF4E0(EnRu1* this) {