From b2f0bdc869ccca908b91d97eef230e94366d28fa Mon Sep 17 00:00:00 2001 From: dark-samus Date: Mon, 23 Nov 2020 02:52:10 -0500 Subject: [PATCH] a few more --- asm/nonmatchings/code_106ef0/func_802E5670.s | 13 ---- asm/nonmatchings/code_106ef0/func_802E5E50.s | 71 -------------------- include/common_structs.h | 6 +- include/functions.h | 1 + src/code_106ef0.c | 36 +++++++++- src/os/code_4ac90_len_3910.c | 3 +- 6 files changed, 42 insertions(+), 88 deletions(-) delete mode 100644 asm/nonmatchings/code_106ef0/func_802E5670.s delete mode 100644 asm/nonmatchings/code_106ef0/func_802E5E50.s diff --git a/asm/nonmatchings/code_106ef0/func_802E5670.s b/asm/nonmatchings/code_106ef0/func_802E5670.s deleted file mode 100644 index 617a71094f..0000000000 --- a/asm/nonmatchings/code_106ef0/func_802E5670.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802E5670 -/* 106EF0 802E5670 948200D0 */ lhu $v0, 0xd0($a0) -/* 106EF4 802E5674 00451023 */ subu $v0, $v0, $a1 -/* 106EF8 802E5678 04420001 */ bltzl $v0, .L802E5680 -/* 106EFC 802E567C 24420014 */ addiu $v0, $v0, 0x14 -.L802E5680: -/* 106F00 802E5680 00021080 */ sll $v0, $v0, 2 -/* 106F04 802E5684 00821021 */ addu $v0, $a0, $v0 -/* 106F08 802E5688 03E00008 */ jr $ra -/* 106F0C 802E568C C44000D4 */ lwc1 $f0, 0xd4($v0) diff --git a/asm/nonmatchings/code_106ef0/func_802E5E50.s b/asm/nonmatchings/code_106ef0/func_802E5E50.s deleted file mode 100644 index 8dfe7e80e9..0000000000 --- a/asm/nonmatchings/code_106ef0/func_802E5E50.s +++ /dev/null @@ -1,71 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_802E5E50 -/* 1076D0 802E5E50 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 1076D4 802E5E54 AFB10024 */ sw $s1, 0x24($sp) -/* 1076D8 802E5E58 0080882D */ daddu $s1, $a0, $zero -/* 1076DC 802E5E5C AFBF0028 */ sw $ra, 0x28($sp) -/* 1076E0 802E5E60 AFB00020 */ sw $s0, 0x20($sp) -/* 1076E4 802E5E64 0C0B9607 */ jal func_802E581C -/* 1076E8 802E5E68 8E300040 */ lw $s0, 0x40($s1) -/* 1076EC 802E5E6C 9202000A */ lbu $v0, 0xa($s0) -/* 1076F0 802E5E70 54400001 */ bnel $v0, $zero, .L802E5E78 -/* 1076F4 802E5E74 AE20003C */ sw $zero, 0x3c($s1) -.L802E5E78: -/* 1076F8 802E5E78 C62C0064 */ lwc1 $f12, 0x64($s1) -/* 1076FC 802E5E7C 3C014008 */ lui $at, 0x4008 -/* 107700 802E5E80 44810800 */ mtc1 $at, $f1 -/* 107704 802E5E84 44800000 */ mtc1 $zero, $f0 -/* 107708 802E5E88 46006321 */ cvt.d.s $f12, $f12 -/* 10770C 802E5E8C 46206300 */ add.d $f12, $f12, $f0 -/* 107710 802E5E90 0C00A6C9 */ jal clamp_angle -/* 107714 802E5E94 46206320 */ cvt.s.d $f12, $f12 -/* 107718 802E5E98 E6200064 */ swc1 $f0, 0x64($s1) -/* 10771C 802E5E9C 960200D0 */ lhu $v0, 0xd0($s0) -/* 107720 802E5EA0 00021080 */ sll $v0, $v0, 2 -/* 107724 802E5EA4 02021021 */ addu $v0, $s0, $v0 -/* 107728 802E5EA8 E44000D4 */ swc1 $f0, 0xd4($v0) -/* 10772C 802E5EAC 960200D0 */ lhu $v0, 0xd0($s0) -/* 107730 802E5EB0 24420001 */ addiu $v0, $v0, 1 -/* 107734 802E5EB4 A60200D0 */ sh $v0, 0xd0($s0) -/* 107738 802E5EB8 3042FFFF */ andi $v0, $v0, 0xffff -/* 10773C 802E5EBC 2C420015 */ sltiu $v0, $v0, 0x15 -/* 107740 802E5EC0 50400001 */ beql $v0, $zero, .L802E5EC8 -/* 107744 802E5EC4 A60000D0 */ sh $zero, 0xd0($s0) -.L802E5EC8: -/* 107748 802E5EC8 9202000A */ lbu $v0, 0xa($s0) -/* 10774C 802E5ECC 1440001B */ bnez $v0, .L802E5F3C -/* 107750 802E5ED0 00000000 */ nop -/* 107754 802E5ED4 3C02800A */ lui $v0, %hi(D_8009A650) -/* 107758 802E5ED8 8C42A650 */ lw $v0, %lo(D_8009A650)($v0) -/* 10775C 802E5EDC 14400017 */ bnez $v0, .L802E5F3C -/* 107760 802E5EE0 00000000 */ nop -/* 107764 802E5EE4 92020002 */ lbu $v0, 2($s0) -/* 107768 802E5EE8 2442FFFF */ addiu $v0, $v0, -1 -/* 10776C 802E5EEC A2020002 */ sb $v0, 2($s0) -/* 107770 802E5EF0 00021600 */ sll $v0, $v0, 0x18 -/* 107774 802E5EF4 1C400011 */ bgtz $v0, .L802E5F3C -/* 107778 802E5EF8 24020032 */ addiu $v0, $zero, 0x32 -/* 10777C 802E5EFC 3C0141B0 */ lui $at, 0x41b0 -/* 107780 802E5F00 44810000 */ mtc1 $at, $f0 -/* 107784 802E5F04 3C014100 */ lui $at, 0x4100 -/* 107788 802E5F08 44811000 */ mtc1 $at, $f2 -/* 10778C 802E5F0C A2020002 */ sb $v0, 2($s0) -/* 107790 802E5F10 24020004 */ addiu $v0, $zero, 4 -/* 107794 802E5F14 AFA20018 */ sw $v0, 0x18($sp) -/* 107798 802E5F18 24020014 */ addiu $v0, $zero, 0x14 -/* 10779C 802E5F1C AFA2001C */ sw $v0, 0x1c($sp) -/* 1077A0 802E5F20 E7A00010 */ swc1 $f0, 0x10($sp) -/* 1077A4 802E5F24 E7A20014 */ swc1 $f2, 0x14($sp) -/* 1077A8 802E5F28 8E250048 */ lw $a1, 0x48($s1) -/* 1077AC 802E5F2C 8E26004C */ lw $a2, 0x4c($s1) -/* 1077B0 802E5F30 8E270050 */ lw $a3, 0x50($s1) -/* 1077B4 802E5F34 0C01C154 */ jal func_80070550 -/* 1077B8 802E5F38 24040003 */ addiu $a0, $zero, 3 -.L802E5F3C: -/* 1077BC 802E5F3C 8FBF0028 */ lw $ra, 0x28($sp) -/* 1077C0 802E5F40 8FB10024 */ lw $s1, 0x24($sp) -/* 1077C4 802E5F44 8FB00020 */ lw $s0, 0x20($sp) -/* 1077C8 802E5F48 03E00008 */ jr $ra -/* 1077CC 802E5F4C 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/include/common_structs.h b/include/common_structs.h index 8c98d730bb..15c74c9f08 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1619,12 +1619,16 @@ typedef struct struct802E3650 { typedef struct struct802E4B10 { /* 0x00 */ u8 unk_00; /* 0x01 */ u8 unk_01; - /* 0x02 */ char unk_02[7]; + /* 0x02 */ s8 unk_02; + /* 0x03 */ char unk_03[6]; /* 0x09 */ u8 unk_09; /* 0x0A */ u8 unk_0A; /* 0x0B */ char unk_0B; // padding? /* 0x0C */ s32 unk_0C; /* 0x10 */ s32 unk_10; + /* 0x14 */ char unk_14[0xBC]; + /* 0xD0 */ u16 unk_D0; + /* 0xD4 */ f32 unk_D4[0]; } struct802E4B10; // END ENTITY-SPECIFIC STRUCTS diff --git a/include/functions.h b/include/functions.h index 17c376ed71..b9de153a78 100644 --- a/include/functions.h +++ b/include/functions.h @@ -25,6 +25,7 @@ f32 integrate_gravity(void); u32 get_entity_type(s32 arg0); Entity* get_entity_by_index(s32 index); s32 create_entity(StaticEntityData*, s32, s32, s32, s32, s32); +void func_80070550(s32, f32, f32, f32, f32, f32, s32, s32); UNK_TYPE func_80072230(s32, f32, f32, f32, f32, s32); diff --git a/src/code_106ef0.c b/src/code_106ef0.c index a7f42bf50e..1245e8ce14 100644 --- a/src/code_106ef0.c +++ b/src/code_106ef0.c @@ -1,6 +1,14 @@ #include "common.h" -INCLUDE_ASM(s32, "code_106ef0", func_802E5670); +f32 func_802E5670(struct802E4B10* arg0, s32 arg1) { + s32 temp_v0; + + temp_v0 = arg0->unk_D0 - arg1; + if (arg0->unk_D0 - arg1 < 0) { + temp_v0 += 0x14; + } + return arg0->unk_D4[temp_v0]; +} void func_802E5690(s32 entityIndex) { s16 temp_a0; @@ -73,7 +81,31 @@ void func_802E581C(Entity* entity) { // display list func INCLUDE_ASM(s32, "code_106ef0", func_802E586C); -INCLUDE_ASM(s32, "code_106ef0", func_802E5E50); +void func_802E5E50(Entity* entity) { + f32 clampedAngle; + struct802E4B10* temp_s0 = entity->dataBuf; + + func_802E581C(entity); + if (temp_s0->unk_0A != 0) { + entity->unk_3C = NULL; + } + + clampedAngle = clamp_angle(entity->rotation.y + 3.0); + entity->rotation.y = clampedAngle; + temp_s0->unk_D4[temp_s0->unk_D0] = clampedAngle; + if (++temp_s0->unk_D0 >= 0x15) { + temp_s0->unk_D0 = 0; + } + + if (temp_s0->unk_0A == 0) { + if (D_8009A650[0] == 0) { + if (--temp_s0->unk_02 <= 0) { + temp_s0->unk_02 = 0x32; + func_80070550(3, entity->position.x, entity->position.y, entity->position.z, 22.0f, 8.0f, 4, 0x14); + } + } + } +} void func_802E5F50(Entity* entity) { struct802E3650* temp; diff --git a/src/os/code_4ac90_len_3910.c b/src/os/code_4ac90_len_3910.c index c72a80c65e..42e2b4744c 100644 --- a/src/os/code_4ac90_len_3910.c +++ b/src/os/code_4ac90_len_3910.c @@ -68,7 +68,8 @@ INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_80070490); INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_800704F0); -INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_80070550); +INCLUDE_ASM(void, "os/code_4ac90_len_3910", func_80070550, s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, + s32 arg6, s32 arg7); INCLUDE_ASM(s32, "os/code_4ac90_len_3910", func_800705B0);