From a1d39c1c1e0be59e58d067c05a5bcc24ab1dd3b5 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Mon, 21 Sep 2020 20:56:17 -0400 Subject: [PATCH] Sounds and flags --- .../player_enter_blue_pipe.s | 105 ------------ asm/nonmatchings/code_16c8e0/ActorExists.s | 95 ----------- asm/nonmatchings/code_16c8e0/func_8026DEF0.s | 98 +++++++++++ .../code_dba20_len_350/clear_area_flag.s | 29 ---- .../code_dba20_len_350/clear_global_flag.s | 37 ---- .../code_dba20_len_350/get_global_flag.s | 34 ---- .../code_dba20_len_350/set_area_flag.s | 28 --- .../code_dba20_len_350/set_global_flag.s | 36 ---- .../code_de740_len_23f0/play_sound.s | 15 -- .../code_de740_len_23f0/play_sound_at_npc.s | 28 --- .../play_sound_at_player.s | 18 -- include/common_structs.h | 6 +- include/functions.h | 2 + include/variables.h | 2 + src/code_109660_len_1270.c | 36 +++- src/code_16c8e0.c | 38 ++++- src/code_759b0_len_61b0.c | 2 +- src/code_dba20_len_350.c | 160 ++++++++++++------ src/code_de740_len_23f0.c | 18 +- undefined_syms.txt | 2 + 20 files changed, 302 insertions(+), 487 deletions(-) delete mode 100644 asm/nonmatchings/code_109660_len_1270/player_enter_blue_pipe.s create mode 100644 asm/nonmatchings/code_16c8e0/func_8026DEF0.s delete mode 100644 asm/nonmatchings/code_dba20_len_350/clear_area_flag.s delete mode 100644 asm/nonmatchings/code_dba20_len_350/clear_global_flag.s delete mode 100644 asm/nonmatchings/code_dba20_len_350/get_global_flag.s delete mode 100644 asm/nonmatchings/code_dba20_len_350/set_area_flag.s delete mode 100644 asm/nonmatchings/code_dba20_len_350/set_global_flag.s delete mode 100644 asm/nonmatchings/code_de740_len_23f0/play_sound.s delete mode 100644 asm/nonmatchings/code_de740_len_23f0/play_sound_at_npc.s delete mode 100644 asm/nonmatchings/code_de740_len_23f0/play_sound_at_player.s diff --git a/asm/nonmatchings/code_109660_len_1270/player_enter_blue_pipe.s b/asm/nonmatchings/code_109660_len_1270/player_enter_blue_pipe.s deleted file mode 100644 index 241bd6f6af..0000000000 --- a/asm/nonmatchings/code_109660_len_1270/player_enter_blue_pipe.s +++ /dev/null @@ -1,105 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel player_enter_blue_pipe -/* 10A54C 802E8CCC 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 10A550 802E8CD0 AFBF0020 */ sw $ra, 0x20($sp) -/* 10A554 802E8CD4 8C850040 */ lw $a1, 0x40($a0) -/* 10A558 802E8CD8 3C040001 */ lui $a0, 1 -/* 10A55C 802E8CDC 34840002 */ ori $a0, $a0, 2 -/* 10A560 802E8CE0 3C038007 */ lui $v1, 0x8007 -/* 10A564 802E8CE4 8C637410 */ lw $v1, 0x7410($v1) -/* 10A568 802E8CE8 3C014334 */ lui $at, 0x4334 -/* 10A56C 802E8CEC 44811000 */ mtc1 $at, $f2 -/* 10A570 802E8CF0 00031080 */ sll $v0, $v1, 2 -/* 10A574 802E8CF4 00431021 */ addu $v0, $v0, $v1 -/* 10A578 802E8CF8 00021080 */ sll $v0, $v0, 2 -/* 10A57C 802E8CFC 00431023 */ subu $v0, $v0, $v1 -/* 10A580 802E8D00 000218C0 */ sll $v1, $v0, 3 -/* 10A584 802E8D04 00431021 */ addu $v0, $v0, $v1 -/* 10A588 802E8D08 000210C0 */ sll $v0, $v0, 3 -/* 10A58C 802E8D0C 3C01800B */ lui $at, 0x800b -/* 10A590 802E8D10 00220821 */ addu $at, $at, $v0 -/* 10A594 802E8D14 C4201DEC */ lwc1 $f0, 0x1dec($at) -/* 10A598 802E8D18 24060002 */ addiu $a2, $zero, 2 -/* 10A59C 802E8D1C 46020000 */ add.s $f0, $f0, $f2 -/* 10A5A0 802E8D20 3C038011 */ lui $v1, 0x8011 -/* 10A5A4 802E8D24 2463EFC8 */ addiu $v1, $v1, -0x1038 -/* 10A5A8 802E8D28 24020019 */ addiu $v0, $zero, 0x19 -/* 10A5AC 802E8D2C E4600080 */ swc1 $f0, 0x80($v1) -/* 10A5B0 802E8D30 ACA20004 */ sw $v0, 4($a1) -/* 10A5B4 802E8D34 2402000D */ addiu $v0, $zero, 0xd -/* 10A5B8 802E8D38 A06200BE */ sb $v0, 0xbe($v1) -/* 10A5BC 802E8D3C 24020001 */ addiu $v0, $zero, 1 -/* 10A5C0 802E8D40 24050005 */ addiu $a1, $zero, 5 -/* 10A5C4 802E8D44 0040382D */ daddu $a3, $v0, $zero -/* 10A5C8 802E8D48 AFA20010 */ sw $v0, 0x10($sp) -/* 10A5CC 802E8D4C AFA00014 */ sw $zero, 0x14($sp) -/* 10A5D0 802E8D50 0C0B77FE */ jal func_802DDFF8 -/* 10A5D4 802E8D54 AFA00018 */ sw $zero, 0x18($sp) -/* 10A5D8 802E8D58 0C05272D */ jal play_sound -/* 10A5DC 802E8D5C 24040163 */ addiu $a0, $zero, 0x163 -/* 10A5E0 802E8D60 0C038039 */ jal disable_player_shadow -/* 10A5E4 802E8D64 00000000 */ nop -/* 10A5E8 802E8D68 8FBF0020 */ lw $ra, 0x20($sp) -/* 10A5EC 802E8D6C 03E00008 */ jr $ra -/* 10A5F0 802E8D70 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 10A5F4 802E8D74 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 10A5F8 802E8D78 3C058011 */ lui $a1, 0x8011 -/* 10A5FC 802E8D7C 24A5EFC8 */ addiu $a1, $a1, -0x1038 -/* 10A600 802E8D80 AFBF0024 */ sw $ra, 0x24($sp) -/* 10A604 802E8D84 AFB00020 */ sw $s0, 0x20($sp) -/* 10A608 802E8D88 C4A0002C */ lwc1 $f0, 0x2c($a1) -/* 10A60C 802E8D8C 3C013F80 */ lui $at, 0x3f80 -/* 10A610 802E8D90 44811000 */ mtc1 $at, $f2 -/* 10A614 802E8D94 0080802D */ daddu $s0, $a0, $zero -/* 10A618 802E8D98 46020001 */ sub.s $f0, $f0, $f2 -/* 10A61C 802E8D9C 8E030040 */ lw $v1, 0x40($s0) -/* 10A620 802E8DA0 E4A0002C */ swc1 $f0, 0x2c($a1) -/* 10A624 802E8DA4 8C620004 */ lw $v0, 4($v1) -/* 10A628 802E8DA8 2442FFFF */ addiu $v0, $v0, -1 -/* 10A62C 802E8DAC AC620004 */ sw $v0, 4($v1) -/* 10A630 802E8DB0 2403FFFF */ addiu $v1, $zero, -1 -/* 10A634 802E8DB4 14430012 */ bne $v0, $v1, .L802E8E00 -/* 10A638 802E8DB8 2402000D */ addiu $v0, $zero, 0xd -/* 10A63C 802E8DBC 3C040001 */ lui $a0, 1 -/* 10A640 802E8DC0 34840002 */ ori $a0, $a0, 2 -/* 10A644 802E8DC4 C4A0002C */ lwc1 $f0, 0x2c($a1) -/* 10A648 802E8DC8 3C014248 */ lui $at, 0x4248 -/* 10A64C 802E8DCC 44811000 */ mtc1 $at, $f2 -/* 10A650 802E8DD0 A0A200BE */ sb $v0, 0xbe($a1) -/* 10A654 802E8DD4 AFA00010 */ sw $zero, 0x10($sp) -/* 10A658 802E8DD8 46020001 */ sub.s $f0, $f0, $f2 -/* 10A65C 802E8DDC AFA00014 */ sw $zero, 0x14($sp) -/* 10A660 802E8DE0 AFA00018 */ sw $zero, 0x18($sp) -/* 10A664 802E8DE4 E4A0002C */ swc1 $f0, 0x2c($a1) -/* 10A668 802E8DE8 0000282D */ daddu $a1, $zero, $zero -/* 10A66C 802E8DEC 00A0302D */ daddu $a2, $a1, $zero -/* 10A670 802E8DF0 0C0B77FE */ jal func_802DDFF8 -/* 10A674 802E8DF4 00A0382D */ daddu $a3, $a1, $zero -/* 10A678 802E8DF8 0C043F5A */ jal func_8010FD68 -/* 10A67C 802E8DFC 0200202D */ daddu $a0, $s0, $zero -.L802E8E00: -/* 10A680 802E8E00 8FBF0024 */ lw $ra, 0x24($sp) -/* 10A684 802E8E04 8FB00020 */ lw $s0, 0x20($sp) -/* 10A688 802E8E08 03E00008 */ jr $ra -/* 10A68C 802E8E0C 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 10A690 802E8E10 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 10A694 802E8E14 3C05800A */ lui $a1, 0x800a -/* 10A698 802E8E18 24A5A650 */ addiu $a1, $a1, -0x59b0 -/* 10A69C 802E8E1C 2406FFBF */ addiu $a2, $zero, -0x41 -/* 10A6A0 802E8E20 AFBF0010 */ sw $ra, 0x10($sp) -/* 10A6A4 802E8E24 8C830040 */ lw $v1, 0x40($a0) -/* 10A6A8 802E8E28 8CA20000 */ lw $v0, ($a1) -/* 10A6AC 802E8E2C 8C630010 */ lw $v1, 0x10($v1) -/* 10A6B0 802E8E30 00461024 */ and $v0, $v0, $a2 -/* 10A6B4 802E8E34 ACA20000 */ sw $v0, ($a1) -/* 10A6B8 802E8E38 0C04419E */ jal func_80110678 -/* 10A6BC 802E8E3C AC830028 */ sw $v1, 0x28($a0) -/* 10A6C0 802E8E40 8FBF0010 */ lw $ra, 0x10($sp) -/* 10A6C4 802E8E44 03E00008 */ jr $ra -/* 10A6C8 802E8E48 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_16c8e0/ActorExists.s b/asm/nonmatchings/code_16c8e0/ActorExists.s index f98d95dd58..cc68fc7ee7 100644 --- a/asm/nonmatchings/code_16c8e0/ActorExists.s +++ b/asm/nonmatchings/code_16c8e0/ActorExists.s @@ -42,98 +42,3 @@ glabel ActorExists /* 19C7C4 8026DEE4 24020002 */ addiu $v0, $zero, 2 /* 19C7C8 8026DEE8 03E00008 */ jr $ra /* 19C7CC 8026DEEC 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 19C7D0 8026DEF0 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 19C7D4 8026DEF4 AFB20018 */ sw $s2, 0x18($sp) -/* 19C7D8 8026DEF8 0080902D */ daddu $s2, $a0, $zero -/* 19C7DC 8026DEFC AFBF0020 */ sw $ra, 0x20($sp) -/* 19C7E0 8026DF00 AFB3001C */ sw $s3, 0x1c($sp) -/* 19C7E4 8026DF04 AFB10014 */ sw $s1, 0x14($sp) -/* 19C7E8 8026DF08 AFB00010 */ sw $s0, 0x10($sp) -/* 19C7EC 8026DF0C 8E50000C */ lw $s0, 0xc($s2) -/* 19C7F0 8026DF10 8E050000 */ lw $a1, ($s0) -/* 19C7F4 8026DF14 0C0B1EAF */ jal get_variable -/* 19C7F8 8026DF18 26100004 */ addiu $s0, $s0, 4 -/* 19C7FC 8026DF1C 0040882D */ daddu $s1, $v0, $zero -/* 19C800 8026DF20 8E050000 */ lw $a1, ($s0) -/* 19C804 8026DF24 26100004 */ addiu $s0, $s0, 4 -/* 19C808 8026DF28 0C0B1EAF */ jal get_variable -/* 19C80C 8026DF2C 0240202D */ daddu $a0, $s2, $zero -/* 19C810 8026DF30 0040982D */ daddu $s3, $v0, $zero -/* 19C814 8026DF34 2402FF81 */ addiu $v0, $zero, -0x7f -/* 19C818 8026DF38 16220002 */ bne $s1, $v0, .L8026DF44 -/* 19C81C 8026DF3C 8E100000 */ lw $s0, ($s0) -/* 19C820 8026DF40 8E510148 */ lw $s1, 0x148($s2) -.L8026DF44: -/* 19C824 8026DF44 0C09A75B */ jal get_actor -/* 19C828 8026DF48 0220202D */ daddu $a0, $s1, $zero -/* 19C82C 8026DF4C 0040202D */ daddu $a0, $v0, $zero -/* 19C830 8026DF50 0C099117 */ jal get_actor_part -/* 19C834 8026DF54 0260282D */ daddu $a1, $s3, $zero -/* 19C838 8026DF58 0240202D */ daddu $a0, $s2, $zero -/* 19C83C 8026DF5C 8C460084 */ lw $a2, 0x84($v0) -/* 19C840 8026DF60 0C0B2026 */ jal set_variable -/* 19C844 8026DF64 0200282D */ daddu $a1, $s0, $zero -/* 19C848 8026DF68 8FBF0020 */ lw $ra, 0x20($sp) -/* 19C84C 8026DF6C 8FB3001C */ lw $s3, 0x1c($sp) -/* 19C850 8026DF70 8FB20018 */ lw $s2, 0x18($sp) -/* 19C854 8026DF74 8FB10014 */ lw $s1, 0x14($sp) -/* 19C858 8026DF78 8FB00010 */ lw $s0, 0x10($sp) -/* 19C85C 8026DF7C 24020002 */ addiu $v0, $zero, 2 -/* 19C860 8026DF80 03E00008 */ jr $ra -/* 19C864 8026DF84 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 19C868 8026DF88 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 19C86C 8026DF8C AFB20018 */ sw $s2, 0x18($sp) -/* 19C870 8026DF90 0080902D */ daddu $s2, $a0, $zero -/* 19C874 8026DF94 AFBF0020 */ sw $ra, 0x20($sp) -/* 19C878 8026DF98 AFB3001C */ sw $s3, 0x1c($sp) -/* 19C87C 8026DF9C AFB10014 */ sw $s1, 0x14($sp) -/* 19C880 8026DFA0 AFB00010 */ sw $s0, 0x10($sp) -/* 19C884 8026DFA4 8E50000C */ lw $s0, 0xc($s2) -/* 19C888 8026DFA8 8E050000 */ lw $a1, ($s0) -/* 19C88C 8026DFAC 0C0B1EAF */ jal get_variable -/* 19C890 8026DFB0 26100004 */ addiu $s0, $s0, 4 -/* 19C894 8026DFB4 0040882D */ daddu $s1, $v0, $zero -/* 19C898 8026DFB8 8E050000 */ lw $a1, ($s0) -/* 19C89C 8026DFBC 26100004 */ addiu $s0, $s0, 4 -/* 19C8A0 8026DFC0 0C0B1EAF */ jal get_variable -/* 19C8A4 8026DFC4 0240202D */ daddu $a0, $s2, $zero -/* 19C8A8 8026DFC8 0040982D */ daddu $s3, $v0, $zero -/* 19C8AC 8026DFCC 2402FF81 */ addiu $v0, $zero, -0x7f -/* 19C8B0 8026DFD0 16220002 */ bne $s1, $v0, .L8026DFDC -/* 19C8B4 8026DFD4 8E100000 */ lw $s0, ($s0) -/* 19C8B8 8026DFD8 8E510148 */ lw $s1, 0x148($s2) -.L8026DFDC: -/* 19C8BC 8026DFDC 0C09A75B */ jal get_actor -/* 19C8C0 8026DFE0 0220202D */ daddu $a0, $s1, $zero -/* 19C8C4 8026DFE4 0040202D */ daddu $a0, $v0, $zero -/* 19C8C8 8026DFE8 0C099117 */ jal get_actor_part -/* 19C8CC 8026DFEC 0260282D */ daddu $a1, $s3, $zero -/* 19C8D0 8026DFF0 0240202D */ daddu $a0, $s2, $zero -/* 19C8D4 8026DFF4 8C46008C */ lw $a2, 0x8c($v0) -/* 19C8D8 8026DFF8 0C0B2026 */ jal set_variable -/* 19C8DC 8026DFFC 0200282D */ daddu $a1, $s0, $zero -/* 19C8E0 8026E000 8FBF0020 */ lw $ra, 0x20($sp) -/* 19C8E4 8026E004 8FB3001C */ lw $s3, 0x1c($sp) -/* 19C8E8 8026E008 8FB20018 */ lw $s2, 0x18($sp) -/* 19C8EC 8026E00C 8FB10014 */ lw $s1, 0x14($sp) -/* 19C8F0 8026E010 8FB00010 */ lw $s0, 0x10($sp) -/* 19C8F4 8026E014 24020002 */ addiu $v0, $zero, 2 -/* 19C8F8 8026E018 03E00008 */ jr $ra -/* 19C8FC 8026E01C 27BD0028 */ addiu $sp, $sp, 0x28 - -/* 19C900 8026E020 8C82000C */ lw $v0, 0xc($a0) -/* 19C904 8026E024 8C420000 */ lw $v0, ($v0) -/* 19C908 8026E028 3C01800E */ lui $at, 0x800e -/* 19C90C 8026E02C A422C0E0 */ sh $v0, -0x3f20($at) -/* 19C910 8026E030 03E00008 */ jr $ra -/* 19C914 8026E034 24020002 */ addiu $v0, $zero, 2 - -/* 19C918 8026E038 8C82000C */ lw $v0, 0xc($a0) -/* 19C91C 8026E03C 8C420000 */ lw $v0, ($v0) -/* 19C920 8026E040 3C01800E */ lui $at, 0x800e -/* 19C924 8026E044 AC22C0E4 */ sw $v0, -0x3f1c($at) -/* 19C928 8026E048 03E00008 */ jr $ra -/* 19C92C 8026E04C 24020002 */ addiu $v0, $zero, 2 - diff --git a/asm/nonmatchings/code_16c8e0/func_8026DEF0.s b/asm/nonmatchings/code_16c8e0/func_8026DEF0.s new file mode 100644 index 0000000000..93b6b35da6 --- /dev/null +++ b/asm/nonmatchings/code_16c8e0/func_8026DEF0.s @@ -0,0 +1,98 @@ +.set noat # allow manual use of $at +.set noreorder # don't insert nops after branches + +glabel func_8026DEF0 +/* 19C7D0 8026DEF0 27BDFFD8 */ addiu $sp, $sp, -0x28 +/* 19C7D4 8026DEF4 AFB20018 */ sw $s2, 0x18($sp) +/* 19C7D8 8026DEF8 0080902D */ daddu $s2, $a0, $zero +/* 19C7DC 8026DEFC AFBF0020 */ sw $ra, 0x20($sp) +/* 19C7E0 8026DF00 AFB3001C */ sw $s3, 0x1c($sp) +/* 19C7E4 8026DF04 AFB10014 */ sw $s1, 0x14($sp) +/* 19C7E8 8026DF08 AFB00010 */ sw $s0, 0x10($sp) +/* 19C7EC 8026DF0C 8E50000C */ lw $s0, 0xc($s2) +/* 19C7F0 8026DF10 8E050000 */ lw $a1, ($s0) +/* 19C7F4 8026DF14 0C0B1EAF */ jal get_variable +/* 19C7F8 8026DF18 26100004 */ addiu $s0, $s0, 4 +/* 19C7FC 8026DF1C 0040882D */ daddu $s1, $v0, $zero +/* 19C800 8026DF20 8E050000 */ lw $a1, ($s0) +/* 19C804 8026DF24 26100004 */ addiu $s0, $s0, 4 +/* 19C808 8026DF28 0C0B1EAF */ jal get_variable +/* 19C80C 8026DF2C 0240202D */ daddu $a0, $s2, $zero +/* 19C810 8026DF30 0040982D */ daddu $s3, $v0, $zero +/* 19C814 8026DF34 2402FF81 */ addiu $v0, $zero, -0x7f +/* 19C818 8026DF38 16220002 */ bne $s1, $v0, .L8026DF44 +/* 19C81C 8026DF3C 8E100000 */ lw $s0, ($s0) +/* 19C820 8026DF40 8E510148 */ lw $s1, 0x148($s2) +.L8026DF44: +/* 19C824 8026DF44 0C09A75B */ jal get_actor +/* 19C828 8026DF48 0220202D */ daddu $a0, $s1, $zero +/* 19C82C 8026DF4C 0040202D */ daddu $a0, $v0, $zero +/* 19C830 8026DF50 0C099117 */ jal get_actor_part +/* 19C834 8026DF54 0260282D */ daddu $a1, $s3, $zero +/* 19C838 8026DF58 0240202D */ daddu $a0, $s2, $zero +/* 19C83C 8026DF5C 8C460084 */ lw $a2, 0x84($v0) +/* 19C840 8026DF60 0C0B2026 */ jal set_variable +/* 19C844 8026DF64 0200282D */ daddu $a1, $s0, $zero +/* 19C848 8026DF68 8FBF0020 */ lw $ra, 0x20($sp) +/* 19C84C 8026DF6C 8FB3001C */ lw $s3, 0x1c($sp) +/* 19C850 8026DF70 8FB20018 */ lw $s2, 0x18($sp) +/* 19C854 8026DF74 8FB10014 */ lw $s1, 0x14($sp) +/* 19C858 8026DF78 8FB00010 */ lw $s0, 0x10($sp) +/* 19C85C 8026DF7C 24020002 */ addiu $v0, $zero, 2 +/* 19C860 8026DF80 03E00008 */ jr $ra +/* 19C864 8026DF84 27BD0028 */ addiu $sp, $sp, 0x28 + +/* 19C868 8026DF88 27BDFFD8 */ addiu $sp, $sp, -0x28 +/* 19C86C 8026DF8C AFB20018 */ sw $s2, 0x18($sp) +/* 19C870 8026DF90 0080902D */ daddu $s2, $a0, $zero +/* 19C874 8026DF94 AFBF0020 */ sw $ra, 0x20($sp) +/* 19C878 8026DF98 AFB3001C */ sw $s3, 0x1c($sp) +/* 19C87C 8026DF9C AFB10014 */ sw $s1, 0x14($sp) +/* 19C880 8026DFA0 AFB00010 */ sw $s0, 0x10($sp) +/* 19C884 8026DFA4 8E50000C */ lw $s0, 0xc($s2) +/* 19C888 8026DFA8 8E050000 */ lw $a1, ($s0) +/* 19C88C 8026DFAC 0C0B1EAF */ jal get_variable +/* 19C890 8026DFB0 26100004 */ addiu $s0, $s0, 4 +/* 19C894 8026DFB4 0040882D */ daddu $s1, $v0, $zero +/* 19C898 8026DFB8 8E050000 */ lw $a1, ($s0) +/* 19C89C 8026DFBC 26100004 */ addiu $s0, $s0, 4 +/* 19C8A0 8026DFC0 0C0B1EAF */ jal get_variable +/* 19C8A4 8026DFC4 0240202D */ daddu $a0, $s2, $zero +/* 19C8A8 8026DFC8 0040982D */ daddu $s3, $v0, $zero +/* 19C8AC 8026DFCC 2402FF81 */ addiu $v0, $zero, -0x7f +/* 19C8B0 8026DFD0 16220002 */ bne $s1, $v0, .L8026DFDC +/* 19C8B4 8026DFD4 8E100000 */ lw $s0, ($s0) +/* 19C8B8 8026DFD8 8E510148 */ lw $s1, 0x148($s2) +.L8026DFDC: +/* 19C8BC 8026DFDC 0C09A75B */ jal get_actor +/* 19C8C0 8026DFE0 0220202D */ daddu $a0, $s1, $zero +/* 19C8C4 8026DFE4 0040202D */ daddu $a0, $v0, $zero +/* 19C8C8 8026DFE8 0C099117 */ jal get_actor_part +/* 19C8CC 8026DFEC 0260282D */ daddu $a1, $s3, $zero +/* 19C8D0 8026DFF0 0240202D */ daddu $a0, $s2, $zero +/* 19C8D4 8026DFF4 8C46008C */ lw $a2, 0x8c($v0) +/* 19C8D8 8026DFF8 0C0B2026 */ jal set_variable +/* 19C8DC 8026DFFC 0200282D */ daddu $a1, $s0, $zero +/* 19C8E0 8026E000 8FBF0020 */ lw $ra, 0x20($sp) +/* 19C8E4 8026E004 8FB3001C */ lw $s3, 0x1c($sp) +/* 19C8E8 8026E008 8FB20018 */ lw $s2, 0x18($sp) +/* 19C8EC 8026E00C 8FB10014 */ lw $s1, 0x14($sp) +/* 19C8F0 8026E010 8FB00010 */ lw $s0, 0x10($sp) +/* 19C8F4 8026E014 24020002 */ addiu $v0, $zero, 2 +/* 19C8F8 8026E018 03E00008 */ jr $ra +/* 19C8FC 8026E01C 27BD0028 */ addiu $sp, $sp, 0x28 + +/* 19C900 8026E020 8C82000C */ lw $v0, 0xc($a0) +/* 19C904 8026E024 8C420000 */ lw $v0, ($v0) +/* 19C908 8026E028 3C01800E */ lui $at, 0x800e +/* 19C90C 8026E02C A422C0E0 */ sh $v0, -0x3f20($at) +/* 19C910 8026E030 03E00008 */ jr $ra +/* 19C914 8026E034 24020002 */ addiu $v0, $zero, 2 + +/* 19C918 8026E038 8C82000C */ lw $v0, 0xc($a0) +/* 19C91C 8026E03C 8C420000 */ lw $v0, ($v0) +/* 19C920 8026E040 3C01800E */ lui $at, 0x800e +/* 19C924 8026E044 AC22C0E4 */ sw $v0, -0x3f1c($at) +/* 19C928 8026E048 03E00008 */ jr $ra +/* 19C92C 8026E04C 24020002 */ addiu $v0, $zero, 2 + diff --git a/asm/nonmatchings/code_dba20_len_350/clear_area_flag.s b/asm/nonmatchings/code_dba20_len_350/clear_area_flag.s deleted file mode 100644 index 399ad85b41..0000000000 --- a/asm/nonmatchings/code_dba20_len_350/clear_area_flag.s +++ /dev/null @@ -1,29 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel clear_area_flag -/* 0DBC4C 8014554C 04810002 */ bgez $a0, .L80145558 -/* 0DBC50 80145550 0080102D */ daddu $v0, $a0, $zero -/* 0DBC54 80145554 2482001F */ addiu $v0, $a0, 0x1f -.L80145558: -/* 0DBC58 80145558 00021143 */ sra $v0, $v0, 5 -/* 0DBC5C 8014555C 00021940 */ sll $v1, $v0, 5 -/* 0DBC60 80145560 00831823 */ subu $v1, $a0, $v1 -/* 0DBC64 80145564 3C04800E */ lui $a0, 0x800e -/* 0DBC68 80145568 2484ACC0 */ addiu $a0, $a0, -0x5340 -/* 0DBC6C 8014556C 00021080 */ sll $v0, $v0, 2 -/* 0DBC70 80145570 00442821 */ addu $a1, $v0, $a0 -/* 0DBC74 80145574 24020001 */ addiu $v0, $zero, 1 -/* 0DBC78 80145578 8CA412B0 */ lw $a0, 0x12b0($a1) -/* 0DBC7C 8014557C 00621004 */ sllv $v0, $v0, $v1 -/* 0DBC80 80145580 00821824 */ and $v1, $a0, $v0 -/* 0DBC84 80145584 54600001 */ bnel $v1, $zero, .L8014558C -/* 0DBC88 80145588 24030001 */ addiu $v1, $zero, 1 -.L8014558C: -/* 0DBC8C 8014558C 00021027 */ nor $v0, $zero, $v0 -/* 0DBC90 80145590 00821024 */ and $v0, $a0, $v0 -/* 0DBC94 80145594 ACA212B0 */ sw $v0, 0x12b0($a1) -/* 0DBC98 80145598 03E00008 */ jr $ra -/* 0DBC9C 8014559C 0060102D */ daddu $v0, $v1, $zero - diff --git a/asm/nonmatchings/code_dba20_len_350/clear_global_flag.s b/asm/nonmatchings/code_dba20_len_350/clear_global_flag.s deleted file mode 100644 index 0754164162..0000000000 --- a/asm/nonmatchings/code_dba20_len_350/clear_global_flag.s +++ /dev/null @@ -1,37 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel clear_global_flag -/* 0DBAE0 801453E0 3C02F8D8 */ lui $v0, 0xf8d8 -/* 0DBAE4 801453E4 3442F200 */ ori $v0, $v0, 0xf200 -/* 0DBAE8 801453E8 0044102A */ slt $v0, $v0, $a0 -/* 0DBAEC 801453EC 14400003 */ bnez $v0, .L801453FC -/* 0DBAF0 801453F0 3C0207BF */ lui $v0, 0x7bf -/* 0DBAF4 801453F4 3442A480 */ ori $v0, $v0, 0xa480 -/* 0DBAF8 801453F8 00822021 */ addu $a0, $a0, $v0 -.L801453FC: -/* 0DBAFC 801453FC 04810002 */ bgez $a0, .L80145408 -/* 0DBB00 80145400 0080102D */ daddu $v0, $a0, $zero -/* 0DBB04 80145404 2482001F */ addiu $v0, $a0, 0x1f -.L80145408: -/* 0DBB08 80145408 00021143 */ sra $v0, $v0, 5 -/* 0DBB0C 8014540C 00021940 */ sll $v1, $v0, 5 -/* 0DBB10 80145410 00831823 */ subu $v1, $a0, $v1 -/* 0DBB14 80145414 3C04800E */ lui $a0, 0x800e -/* 0DBB18 80145418 2484ACC0 */ addiu $a0, $a0, -0x5340 -/* 0DBB1C 8014541C 00021080 */ sll $v0, $v0, 2 -/* 0DBB20 80145420 00442821 */ addu $a1, $v0, $a0 -/* 0DBB24 80145424 24020001 */ addiu $v0, $zero, 1 -/* 0DBB28 80145428 8CA40FB0 */ lw $a0, 0xfb0($a1) -/* 0DBB2C 8014542C 00621004 */ sllv $v0, $v0, $v1 -/* 0DBB30 80145430 00821824 */ and $v1, $a0, $v0 -/* 0DBB34 80145434 54600001 */ bnel $v1, $zero, .L8014543C -/* 0DBB38 80145438 24030001 */ addiu $v1, $zero, 1 -.L8014543C: -/* 0DBB3C 8014543C 00021027 */ nor $v0, $zero, $v0 -/* 0DBB40 80145440 00821024 */ and $v0, $a0, $v0 -/* 0DBB44 80145444 ACA20FB0 */ sw $v0, 0xfb0($a1) -/* 0DBB48 80145448 03E00008 */ jr $ra -/* 0DBB4C 8014544C 0060102D */ daddu $v0, $v1, $zero - diff --git a/asm/nonmatchings/code_dba20_len_350/get_global_flag.s b/asm/nonmatchings/code_dba20_len_350/get_global_flag.s deleted file mode 100644 index cb4bea4c5d..0000000000 --- a/asm/nonmatchings/code_dba20_len_350/get_global_flag.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel get_global_flag -/* 0DBBBC 801454BC 0080282D */ daddu $a1, $a0, $zero -/* 0DBBC0 801454C0 3C02F8D8 */ lui $v0, 0xf8d8 -/* 0DBBC4 801454C4 3442F200 */ ori $v0, $v0, 0xf200 -/* 0DBBC8 801454C8 0045102A */ slt $v0, $v0, $a1 -/* 0DBBCC 801454CC 14400003 */ bnez $v0, .L801454DC -/* 0DBBD0 801454D0 3C0207BF */ lui $v0, 0x7bf -/* 0DBBD4 801454D4 3442A480 */ ori $v0, $v0, 0xa480 -/* 0DBBD8 801454D8 00A22821 */ addu $a1, $a1, $v0 -.L801454DC: -/* 0DBBDC 801454DC 04A10002 */ bgez $a1, .L801454E8 -/* 0DBBE0 801454E0 00A0182D */ daddu $v1, $a1, $zero -/* 0DBBE4 801454E4 24A3001F */ addiu $v1, $a1, 0x1f -.L801454E8: -/* 0DBBE8 801454E8 00031943 */ sra $v1, $v1, 5 -/* 0DBBEC 801454EC 00032140 */ sll $a0, $v1, 5 -/* 0DBBF0 801454F0 00A42023 */ subu $a0, $a1, $a0 -/* 0DBBF4 801454F4 00031880 */ sll $v1, $v1, 2 -/* 0DBBF8 801454F8 24020001 */ addiu $v0, $zero, 1 -/* 0DBBFC 801454FC 3C01800E */ lui $at, 0x800e -/* 0DBC00 80145500 00230821 */ addu $at, $at, $v1 -/* 0DBC04 80145504 8C23BC70 */ lw $v1, -0x4390($at) -/* 0DBC08 80145508 00821004 */ sllv $v0, $v0, $a0 -/* 0DBC0C 8014550C 00621024 */ and $v0, $v1, $v0 -/* 0DBC10 80145510 54400001 */ bnel $v0, $zero, .L80145518 -/* 0DBC14 80145514 24020001 */ addiu $v0, $zero, 1 -.L80145518: -/* 0DBC18 80145518 03E00008 */ jr $ra -/* 0DBC1C 8014551C 00000000 */ nop - diff --git a/asm/nonmatchings/code_dba20_len_350/set_area_flag.s b/asm/nonmatchings/code_dba20_len_350/set_area_flag.s deleted file mode 100644 index 80a09ca210..0000000000 --- a/asm/nonmatchings/code_dba20_len_350/set_area_flag.s +++ /dev/null @@ -1,28 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel set_area_flag -/* 0DBCA0 801455A0 04810002 */ bgez $a0, .L801455AC -/* 0DBCA4 801455A4 0080102D */ daddu $v0, $a0, $zero -/* 0DBCA8 801455A8 2482001F */ addiu $v0, $a0, 0x1f -.L801455AC: -/* 0DBCAC 801455AC 00021143 */ sra $v0, $v0, 5 -/* 0DBCB0 801455B0 00021940 */ sll $v1, $v0, 5 -/* 0DBCB4 801455B4 00831823 */ subu $v1, $a0, $v1 -/* 0DBCB8 801455B8 3C04800E */ lui $a0, 0x800e -/* 0DBCBC 801455BC 2484ACC0 */ addiu $a0, $a0, -0x5340 -/* 0DBCC0 801455C0 00021080 */ sll $v0, $v0, 2 -/* 0DBCC4 801455C4 00442821 */ addu $a1, $v0, $a0 -/* 0DBCC8 801455C8 24020001 */ addiu $v0, $zero, 1 -/* 0DBCCC 801455CC 8CA412B0 */ lw $a0, 0x12b0($a1) -/* 0DBCD0 801455D0 00621004 */ sllv $v0, $v0, $v1 -/* 0DBCD4 801455D4 00821824 */ and $v1, $a0, $v0 -/* 0DBCD8 801455D8 54600001 */ bnel $v1, $zero, .L801455E0 -/* 0DBCDC 801455DC 24030001 */ addiu $v1, $zero, 1 -.L801455E0: -/* 0DBCE0 801455E0 00821025 */ or $v0, $a0, $v0 -/* 0DBCE4 801455E4 ACA212B0 */ sw $v0, 0x12b0($a1) -/* 0DBCE8 801455E8 03E00008 */ jr $ra -/* 0DBCEC 801455EC 0060102D */ daddu $v0, $v1, $zero - diff --git a/asm/nonmatchings/code_dba20_len_350/set_global_flag.s b/asm/nonmatchings/code_dba20_len_350/set_global_flag.s deleted file mode 100644 index f3e9933478..0000000000 --- a/asm/nonmatchings/code_dba20_len_350/set_global_flag.s +++ /dev/null @@ -1,36 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel set_global_flag -/* 0DBB50 80145450 3C02F8D8 */ lui $v0, 0xf8d8 -/* 0DBB54 80145454 3442F200 */ ori $v0, $v0, 0xf200 -/* 0DBB58 80145458 0044102A */ slt $v0, $v0, $a0 -/* 0DBB5C 8014545C 14400003 */ bnez $v0, .L8014546C -/* 0DBB60 80145460 3C0207BF */ lui $v0, 0x7bf -/* 0DBB64 80145464 3442A480 */ ori $v0, $v0, 0xa480 -/* 0DBB68 80145468 00822021 */ addu $a0, $a0, $v0 -.L8014546C: -/* 0DBB6C 8014546C 04810002 */ bgez $a0, .L80145478 -/* 0DBB70 80145470 0080102D */ daddu $v0, $a0, $zero -/* 0DBB74 80145474 2482001F */ addiu $v0, $a0, 0x1f -.L80145478: -/* 0DBB78 80145478 00021143 */ sra $v0, $v0, 5 -/* 0DBB7C 8014547C 00021940 */ sll $v1, $v0, 5 -/* 0DBB80 80145480 00831823 */ subu $v1, $a0, $v1 -/* 0DBB84 80145484 3C04800E */ lui $a0, 0x800e -/* 0DBB88 80145488 2484ACC0 */ addiu $a0, $a0, -0x5340 -/* 0DBB8C 8014548C 00021080 */ sll $v0, $v0, 2 -/* 0DBB90 80145490 00442821 */ addu $a1, $v0, $a0 -/* 0DBB94 80145494 24020001 */ addiu $v0, $zero, 1 -/* 0DBB98 80145498 8CA40FB0 */ lw $a0, 0xfb0($a1) -/* 0DBB9C 8014549C 00621004 */ sllv $v0, $v0, $v1 -/* 0DBBA0 801454A0 00821824 */ and $v1, $a0, $v0 -/* 0DBBA4 801454A4 54600001 */ bnel $v1, $zero, .L801454AC -/* 0DBBA8 801454A8 24030001 */ addiu $v1, $zero, 1 -.L801454AC: -/* 0DBBAC 801454AC 00821025 */ or $v0, $a0, $v0 -/* 0DBBB0 801454B0 ACA20FB0 */ sw $v0, 0xfb0($a1) -/* 0DBBB4 801454B4 03E00008 */ jr $ra -/* 0DBBB8 801454B8 0060102D */ daddu $v0, $v1, $zero - diff --git a/asm/nonmatchings/code_de740_len_23f0/play_sound.s b/asm/nonmatchings/code_de740_len_23f0/play_sound.s deleted file mode 100644 index 34ab85b2dc..0000000000 --- a/asm/nonmatchings/code_de740_len_23f0/play_sound.s +++ /dev/null @@ -1,15 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel play_sound -/* 0E03B4 80149CB4 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0E03B8 80149CB8 0000282D */ daddu $a1, $zero, $zero -/* 0E03BC 80149CBC 00A0302D */ daddu $a2, $a1, $zero -/* 0E03C0 80149CC0 AFBF0010 */ sw $ra, 0x10($sp) -/* 0E03C4 80149CC4 0C0526AE */ jal _play_sound -/* 0E03C8 80149CC8 00A0382D */ daddu $a3, $a1, $zero -/* 0E03CC 80149CCC 8FBF0010 */ lw $ra, 0x10($sp) -/* 0E03D0 80149CD0 03E00008 */ jr $ra -/* 0E03D4 80149CD4 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/asm/nonmatchings/code_de740_len_23f0/play_sound_at_npc.s b/asm/nonmatchings/code_de740_len_23f0/play_sound_at_npc.s deleted file mode 100644 index 9fc1bf9b01..0000000000 --- a/asm/nonmatchings/code_de740_len_23f0/play_sound_at_npc.s +++ /dev/null @@ -1,28 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel play_sound_at_npc -/* 0E0408 80149D08 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 0E040C 80149D0C AFB00018 */ sw $s0, 0x18($sp) -/* 0E0410 80149D10 0080802D */ daddu $s0, $a0, $zero -/* 0E0414 80149D14 AFB1001C */ sw $s1, 0x1c($sp) -/* 0E0418 80149D18 00A0882D */ daddu $s1, $a1, $zero -/* 0E041C 80149D1C AFBF0020 */ sw $ra, 0x20($sp) -/* 0E0420 80149D20 0C00EAD2 */ jal get_npc_safe -/* 0E0424 80149D24 00C0202D */ daddu $a0, $a2, $zero -/* 0E0428 80149D28 10400007 */ beqz $v0, .L80149D48 -/* 0E042C 80149D2C 0200202D */ daddu $a0, $s0, $zero -/* 0E0430 80149D30 C4400040 */ lwc1 $f0, 0x40($v0) -/* 0E0434 80149D34 E7A00010 */ swc1 $f0, 0x10($sp) -/* 0E0438 80149D38 8C460038 */ lw $a2, 0x38($v0) -/* 0E043C 80149D3C 8C47003C */ lw $a3, 0x3c($v0) -/* 0E0440 80149D40 0C052757 */ jal play_sound_at_position -/* 0E0444 80149D44 0220282D */ daddu $a1, $s1, $zero -.L80149D48: -/* 0E0448 80149D48 8FBF0020 */ lw $ra, 0x20($sp) -/* 0E044C 80149D4C 8FB1001C */ lw $s1, 0x1c($sp) -/* 0E0450 80149D50 8FB00018 */ lw $s0, 0x18($sp) -/* 0E0454 80149D54 03E00008 */ jr $ra -/* 0E0458 80149D58 27BD0028 */ addiu $sp, $sp, 0x28 - diff --git a/asm/nonmatchings/code_de740_len_23f0/play_sound_at_player.s b/asm/nonmatchings/code_de740_len_23f0/play_sound_at_player.s deleted file mode 100644 index abcd1f510d..0000000000 --- a/asm/nonmatchings/code_de740_len_23f0/play_sound_at_player.s +++ /dev/null @@ -1,18 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - - -glabel play_sound_at_player -/* 0E03D8 80149CD8 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0E03DC 80149CDC 3C028011 */ lui $v0, 0x8011 -/* 0E03E0 80149CE0 2442EFC8 */ addiu $v0, $v0, -0x1038 -/* 0E03E4 80149CE4 AFBF0018 */ sw $ra, 0x18($sp) -/* 0E03E8 80149CE8 C4400030 */ lwc1 $f0, 0x30($v0) -/* 0E03EC 80149CEC E7A00010 */ swc1 $f0, 0x10($sp) -/* 0E03F0 80149CF0 8C460028 */ lw $a2, 0x28($v0) -/* 0E03F4 80149CF4 0C052757 */ jal play_sound_at_position -/* 0E03F8 80149CF8 8C47002C */ lw $a3, 0x2c($v0) -/* 0E03FC 80149CFC 8FBF0018 */ lw $ra, 0x18($sp) -/* 0E0400 80149D00 03E00008 */ jr $ra -/* 0E0404 80149D04 27BD0020 */ addiu $sp, $sp, 0x20 - diff --git a/include/common_structs.h b/include/common_structs.h index 0efa114222..62813ee864 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -156,8 +156,8 @@ typedef struct PlayerData { typedef struct Trigger { /* 0x00 */ s16 genericFlagIndex; /* 0x02 */ char unk_02[2]; - /* 0x04 */ s16 crateFlagIndex; - /* 0x06 */ s16 panelFlagIndex; + /* 0x04 */ s32 crateFlagIndex; + ///* 0x06 */ s16 panelFlagIndex; /* 0x08 */ s32 colliderID; /* 0x0C */ UNK_FUN_PTR(functionHandler); /* 0x10 */ Bytecode* scriptStart; @@ -1445,7 +1445,7 @@ typedef struct SaveData { /* 0x046C */ s16 entryID; /* 0x046E */ char unk_46E[2]; /* 0x0470 */ s32 enemyDefeatFlags[720]; - /* 0x0FB0 */ s8 globalFlags[256]; + /* 0x0FB0 */ s32 globalFlags[64]; /* 0x10B0 */ s8 globalBytes[512]; /* 0x12B0 */ s32 areaFlags[8]; /* 0x12D0 */ s8 areaBytes[16]; diff --git a/include/functions.h b/include/functions.h index e74974d637..575ba54fae 100644 --- a/include/functions.h +++ b/include/functions.h @@ -55,6 +55,8 @@ void make_item_entity_delayed(s32 itemID, f32 x, f32 y, f32 z, s32 unk1, s32 unk void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height); +void disable_player_shadow(void); + Npc* get_npc_safe(NpcId npcId); Npc* get_npc_unsafe(NpcId npcId); Npc* resolve_npc(ScriptInstance* script, NpcId npcIdOrPtr); diff --git a/include/variables.h b/include/variables.h index 79dbce9b8c..f686c684e7 100644 --- a/include/variables.h +++ b/include/variables.h @@ -17,6 +17,8 @@ extern StaticItem gItemTable[364]; extern s16 gMainGameState; /* 0 = battle, 1 = pause, 2 = world */ extern UNK_FUN_PTR(gCurrentUpdateFunction); +extern BattleStatus gBattleStatus; + extern ScriptInstance* gWorldScriptList[128]; extern ScriptInstance* gBattleScriptList[128]; extern ScriptInstance** gCurrentScriptListPtr[128]; diff --git a/src/code_109660_len_1270.c b/src/code_109660_len_1270.c index 97f2495c27..f585ca7fac 100644 --- a/src/code_109660_len_1270.c +++ b/src/code_109660_len_1270.c @@ -4,6 +4,40 @@ INCLUDE_ASM("code_109660_len_1270", func_802E7DE0); INCLUDE_ASM("code_109660_len_1270", func_802E7F6C); -INCLUDE_ASM("code_109660_len_1270", player_enter_blue_pipe); +void player_enter_blue_pipe(Entity* bluePipe) { + PlayerStatus* playerStatus = &gPlayerStatus; + Trigger* pipeTrigger = bluePipe->trigger; + + playerStatus->targetYaw = gCameras[gCurrentCameraID].currentYaw + 180.0f; + pipeTrigger->crateFlagIndex = 0x19; + playerStatus->renderMode = 0xD; + + func_802DDFF8(0x10002, 5, 2, 1, 1, 0, 0); + play_sound(0x163); + disable_player_shadow(); +} + +void func_802E8D74(Entity* entity) { + PlayerStatus* playerStatus = &gPlayerStatus; + Trigger* entityTrigger = entity->trigger; + + playerStatus->position.y--; + entityTrigger->crateFlagIndex--; + + if (entityTrigger->crateFlagIndex == -1) { + playerStatus->renderMode = 0xD; + playerStatus->position.y -= 50.0f; + func_802DDFF8(0x10002, 0, 0, 0, 0, 0, 0); + func_8010FD68(entity); + } +} + +void func_802E8E10(Entity* entity) { + Bytecode* triggerScriptStart = entity->trigger->scriptStart; + + D_8009A650[0] &= ~0x40; + entity->boundScript = triggerScriptStart; + func_80110678(); +} INCLUDE_ASM("code_109660_len_1270", push_entity_matrix); diff --git a/src/code_16c8e0.c b/src/code_16c8e0.c index 3398e48135..4dcb8c79e0 100644 --- a/src/code_16c8e0.c +++ b/src/code_16c8e0.c @@ -650,7 +650,7 @@ INCLUDE_ASM("code_16c8e0", set_part_absolute_position); INCLUDE_ASM("code_16c8e0", set_actor_home_position); -INCLUDE_ASM("code_16c8e0", get_actor); +Actor* INCLUDE_ASM("code_16c8e0", get_actor, s32 actorID); INCLUDE_API_ASM("code_16c8e0", LoadBattleSection); @@ -820,7 +820,26 @@ INCLUDE_API_ASM("code_16c8e0", GetOwnerID); INCLUDE_API_ASM("code_16c8e0", SetOwnerID); -INCLUDE_API_ASM("code_16c8e0", ActorExists); +ApiStatus ActorExists(ScriptInstance* script, s32 isInitialCall) { + Bytecode isExist; + Actor* partner = gBattleStatus.partnerActor; + Bytecode* args = script->ptrReadPos; + ActorId actorID = get_variable(script, *args++); + + if (actorID == -0x7F) { + actorID = script->ownerActorID; + } + + isExist = get_actor(actorID) != NULL; + if ((actorID == ActorId_PARTNER) && (partner == NULL)) { + isExist = FALSE; + } + + set_variable(script, *args++, isExist); + return ApiStatus_DONE2; +} + +INCLUDE_API_ASM("code_16c8e0", func_8026DEF0); INCLUDE_API_ASM("code_16c8e0", SetBattleInputMask); @@ -1082,7 +1101,20 @@ INCLUDE_ASM("code_16c8e0", dispatch_damage_event_partner_1); INCLUDE_API_ASM("code_16c8e0", MakeOwnerTargetIndex); -INCLUDE_API_ASM("code_16c8e0", GetActorLevel); +ApiStatus GetActorLevel(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + s32 actorID = get_variable(script, *args++); + Bytecode* outVar; + + if (actorID == -0x7F) { + actorID = script->ownerActorID; + } + + outVar = *args++; + set_variable(script, outVar, get_actor(actorID)->staticActorData->level); + + return ApiStatus_DONE2; +} INCLUDE_API_ASM("code_16c8e0", PartnerDamageEnemy); diff --git a/src/code_759b0_len_61b0.c b/src/code_759b0_len_61b0.c index d86b99aff6..72ab9185b0 100644 --- a/src/code_759b0_len_61b0.c +++ b/src/code_759b0_len_61b0.c @@ -70,7 +70,7 @@ INCLUDE_ASM("code_759b0_len_61b0", func_800E0088); INCLUDE_ASM("code_759b0_len_61b0", enable_player_shadow); -INCLUDE_ASM("code_759b0_len_61b0", disable_player_shadow); +void INCLUDE_ASM("code_759b0_len_61b0", disable_player_shadow); INCLUDE_ASM("code_759b0_len_61b0", enable_player_physics); diff --git a/src/code_dba20_len_350.c b/src/code_dba20_len_350.c index 5ebd16efa4..a31e991a3e 100644 --- a/src/code_dba20_len_350.c +++ b/src/code_dba20_len_350.c @@ -1,57 +1,117 @@ #include "common.h" +#ifdef NON_MATCHING +void clear_saved_variables(void) { + SaveData* saveFile = &gCurrentSaveFile; + s32 i; + + for (i = ARRAY_COUNT(saveFile->globalFlags) - 1; i >= 0; i--) { + saveFile->globalFlags[i] = 0; + } + + for (i = ARRAY_COUNT(saveFile->globalBytes) - 1; i >= 0; i--) { + saveFile->globalBytes[i] = 0; + } + + for (i = ARRAY_COUNT(saveFile->areaFlags) - 1; i >= 0; i--) { + saveFile->areaFlags[i] = 0; + } + + for (i = ARRAY_COUNT(saveFile->areaBytes) - 1; i >= 0; i--) { + saveFile->areaBytes[i] = 0; + } +} +#else INCLUDE_ASM("code_dba20_len_350", clear_saved_variables); - -INCLUDE_ASM("code_dba20_len_350", clear_area_flags); - -INCLUDE_ASM("code_dba20_len_350", clear_global_flag); - +#endif #ifdef NON_MATCHING -s32 set_global_flag(s32 index) { - //SaveData* saveFile = &gCurrentSaveFile; +void clear_area_flags(void) { + SaveData* saveFile = &gCurrentSaveFile; + s32 i; + + if (GAME_STATUS->changedArea) { + for (i = ARRAY_COUNT(saveFile->areaFlags) - 1; i >= 0; i--) { + saveFile->areaFlags[i] = 0; + } + + for (i = ARRAY_COUNT(saveFile->areaBytes) - 1; i >= 0; i--) { + saveFile->areaBytes[i] = 0; + } + } +} +#else +INCLUDE_ASM("code_dba20_len_350", clear_area_flags); +#endif + +s32 clear_global_flag(s32 index) { + s32 wordIdx; + s32 bitIdx; + SaveData* saveFile; s32 flag; if (index <= -120000000) { index += 130000000; } - flag = gCurrentSaveFile->globalFlags[index / 32] & (1 << (index % 32)); + wordIdx = index / 32; + bitIdx = index % 32; + + saveFile = &gCurrentSaveFile; + flag = saveFile->globalFlags[wordIdx] & (1 << bitIdx); if (flag) { flag = 1; } - gCurrentSaveFile->globalFlags[index / 32] |= (1 << (index % 32)); + saveFile->globalFlags[wordIdx] &= ~(1 << bitIdx); return flag; } -#else -INCLUDE_ASM("code_dba20_len_350", set_global_flag); -#endif -#ifdef NON_MATCHING -s32 get_global_flag(s32 index) { - s32 bitIdx; +s32 set_global_flag(s32 index) { s32 wordIdx; - s32 bit; + s32 bitIdx; + SaveData* saveFile; + s32 flag; + + if (index <= -120000000) { + index += 130000000; + } + + wordIdx = index / 32; + bitIdx = index % 32; + + saveFile = &gCurrentSaveFile; + flag = saveFile->globalFlags[wordIdx] & (1 << bitIdx); + + if (flag) { + flag = 1; + } + + saveFile->globalFlags[wordIdx] |= (1 << bitIdx); + return flag; +} + +s32 get_global_flag(s32 index) { + s32 wordIdx; + s32 bitIdx; + s32 flag; s32 phi_return; if (index <= -120000000) { index += 130000000; } + wordIdx = index / 32; bitIdx = index % 32; - bit = gCurrentSaveFile->globalFlags[wordIdx] & (1 << bitIdx); + flag = gCurrentSaveFile.globalFlags[wordIdx] & (1 << bitIdx); - if (bit != 0) { - bit = 1; + if (flag != 0) { + flag = 1; } - return bit; - //return (bit != 0) ? 1 : bit; // ??? surely this is `bit != 0` + return flag; } -#else -s32 INCLUDE_ASM("code_dba20_len_350", get_global_flag, s32 index); -#endif + s8 set_global_byte(s32 index, s8 value) { SaveData* saveFile = &gCurrentSaveFile; @@ -65,45 +125,43 @@ s8 get_global_byte(s32 index) { return gCurrentSaveFile.globalBytes[index]; } -INCLUDE_ASM("code_dba20_len_350", clear_area_flag); - -#ifdef NON_MATCHING -s32 set_area_flag(s32 index) { - SaveData* saveFile = &gCurrentSaveFile; - s32 flag; - s32 flagIdx; - s32 flagShift; - - flagIdx = index / 32; - flagShift = index % 32; - - flag = saveFile->areaFlags[flagIdx] & (1 << flagShift); +s32 clear_area_flag(s32 index) { + s32 wordIdx = index / 32; + s32 bitIdx = index % 32; + SaveData *saveFile = &gCurrentSaveFile; + s32 flag = saveFile->areaFlags[wordIdx] & (1 << bitIdx); if (flag != 0) { flag = 1; } - saveFile->areaFlags[flagIdx] |= (1 << flagShift); - + saveFile->areaFlags[wordIdx] &= ~(1 << bitIdx); return flag; } -#else -INCLUDE_ASM("code_dba20_len_350", set_area_flag); -#endif -s32 get_area_flag(s32 index) { - s32 flag; - s32 flagIdx; - s32 flagShift; - - flagIdx = index / 32; - flagShift = index % 32; - - flag = gCurrentSaveFile.areaFlags[flagIdx] & (1 << flagShift); +s32 set_area_flag(s32 index) { + s32 wordIdx = index / 32; + s32 bitIdx = index % 32; + SaveData *saveFile = &gCurrentSaveFile; + s32 flag = saveFile->areaFlags[wordIdx] & (1 << bitIdx); if (flag != 0) { flag = 1; } + + saveFile->areaFlags[wordIdx] |= 1 << bitIdx; + return flag; +} + +s32 get_area_flag(s32 index) { + s32 wordIdx = index / 32; + s32 bitIdx = index % 32; + s32 flag = gCurrentSaveFile.areaFlags[wordIdx] & (1 << bitIdx); + + if (flag != 0) { + flag = 1; + } + return flag; } diff --git a/src/code_de740_len_23f0.c b/src/code_de740_len_23f0.c index f25f1ecd26..2b9bc379be 100644 --- a/src/code_de740_len_23f0.c +++ b/src/code_de740_len_23f0.c @@ -38,11 +38,23 @@ INCLUDE_ASM("code_de740_len_23f0", _play_sound); INCLUDE_ASM("code_de740_len_23f0", stop_sound); -INCLUDE_ASM("code_de740_len_23f0", play_sound); +void play_sound(s32 soundID) { + _play_sound(soundID, 0, 0, 0); +} -INCLUDE_ASM("code_de740_len_23f0", play_sound_at_player); +void play_sound_at_player(s32 soundID, s32 arg1) { + PlayerStatus* playerStatus = &gPlayerStatus; -INCLUDE_ASM("code_de740_len_23f0", play_sound_at_npc); + play_sound_at_position(soundID, arg1, playerStatus->position.x, playerStatus->position.y, playerStatus->position.z); +} + +void play_sound_at_npc(s32 soundID, s32 arg1, s32 npcID) { + Npc* npc = get_npc_safe(npcID); + + if (npc != NULL) { + play_sound_at_position(soundID, arg1, npc->pos.x, npc->pos.y, npc->pos.z); + } +} s32 INCLUDE_ASM("code_de740_len_23f0", play_sound_at_position, s32 soundID, s32 value2, f32 posX, f32 posY, f32 posZ); diff --git a/undefined_syms.txt b/undefined_syms.txt index 1956a2254b..c25c189c46 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -27,6 +27,8 @@ D_800A0944 = 0x800A0944; D_8010CD10 = 0x8010CD10; D_8010CD12 = 0x8010CD12; +gBattleStatus = 0x800DC070; + D_000759B0 = 0x000759B0; D_000759B0_end = 0x000A5DD0; D_000A5DD0 = 0x000A5DD0;