diff --git a/include/common_structs.h b/include/common_structs.h index f126ac9bfb..9cb9732a55 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -140,7 +140,9 @@ typedef struct Npc { /* 0x0AC */ u8 unk_AC; /* 0x0AD */ char unk_AD[3]; /* 0x0B0 */ s32 unk_B0; - /* 0x0B4 */ char unk_B4[652]; + /* 0x0B4 */ char unk_B4[72]; + /* 0x0FC */ s32 unk_FC; + /* 0x100 */ char unk_100[576]; } Npc; // size = 0x340 typedef Npc* NpcList[MAX_NPCS]; @@ -298,7 +300,8 @@ typedef struct Entity { /* 0x04 */ u8 listIndex; /* 0x05 */ char unk_05; /* 0x06 */ u8 unk_06; - /* 0x07 */ char unk_07[3]; + /* 0x07 */ s8 unk_07; + /* 0x08 */ char unk_08[2]; /* 0x0A */ u8 unk_0A; /* 0x0B */ u8 alpha; /* 0x0C */ Vec3s aabb; @@ -1045,7 +1048,9 @@ typedef struct Shadow { /* 0x00 */ s32 flags; /* 0x04 */ char unk_04[2]; /* 0x06 */ u8 unk_06; - /* 0x07 */ char unk_07[9]; + /* 0x07 */ char unk_07; + /* 0x08 */ s16 unk_08; + /* 0x0A */ char unk_0A[6]; /* 0x10 */ struct Vec3f position; /* 0x1C */ struct Vec3f scale; /* 0x28 */ char unk_28[80]; diff --git a/src/code_a5dd0_len_114e0.c b/src/code_a5dd0_len_114e0.c index 67860a2ab5..835ca7eddd 100644 --- a/src/code_a5dd0_len_114e0.c +++ b/src/code_a5dd0_len_114e0.c @@ -33,6 +33,7 @@ extern s32 texPannerMainU[MAX_TEX_PANNERS]; extern s32 texPannerMainV[MAX_TEX_PANNERS]; extern s32 texPannerAuxU[MAX_TEX_PANNERS]; extern s32 texPannerAuxV[MAX_TEX_PANNERS]; +extern s32 D_8014AFB0; INCLUDE_ASM(s32, "code_a5dd0_len_114e0", update_entities); @@ -54,7 +55,9 @@ void func_8010FD98(s32 arg0, s32 alpha) { } } -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_8010FE44); +void func_8010FE44(s32 arg0) { + func_8010FD98(arg0, D_8014AFB0); +} void entity_model_set_shadow_color(s32 alpha) { gDPSetCombineLERP(gMasterGfxPos++, 0, 0, 0, 0, PRIMITIVE, 0, TEXEL0, 0, 0, 0, 0, 0, TEXEL0, 0, PRIMITIVE, 0); @@ -101,7 +104,13 @@ ShadowList* get_shadow_list(void) { return ret; } -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_80110678); +s32 func_80110678(Npc *npc) { + if (npc->currentAnim != 0) { + npc->flags |= 0x1000000; + return 1; + } + return 0; +} u32 get_entity_type(s32 index) { Entity* entity = get_entity_by_index(index); @@ -113,11 +122,66 @@ u32 get_entity_type(s32 index) { } } -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", delete_entity); +void delete_entity(s32 entityIndex) { + Entity* entity = get_entity_by_index(entityIndex); + Shadow* shadow; + EntityList** currentEntityListPtrTemp; -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", delete_entity_and_unload_data); + if (entity->dataBuf != NULL) { + heap_free(entity->dataBuf); + } -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_8011085C); + if (!(entity->flags & 8)) { + free_entity_model_by_index(entity->virtualModelIndex); + } else { + func_8011E438(get_anim_mesh(entity->virtualModelIndex)); + } + + if (entity->shadowIndex >= 0) { + shadow = get_shadow_by_index(entity->shadowIndex); + shadow->flags |= 0x10000000; + } + + currentEntityListPtrTemp = &gCurrentEntityListPtr; + heap_free((**currentEntityListPtrTemp)[entityIndex]); + (**currentEntityListPtrTemp)[entityIndex] = NULL; +} + +s32 delete_entity_and_unload_data(s32 entityIndex) { + Entity* entity; + Shadow* shadow; + EntityList** currentEntityListPtrTemp; + + entity = get_entity_by_index(entityIndex); + if (entity->dataBuf != NULL) { + heap_free(entity->dataBuf); + } + + if (!(entity->flags & 8)) { + free_entity_model_by_index(entity->virtualModelIndex); + } else { + func_8011E438(get_anim_mesh(entity->virtualModelIndex)); + } + func_801117DC(entity->staticData); + + if (entity->shadowIndex >= 0) { + shadow = get_shadow_by_index(entity->shadowIndex); + shadow->flags |= 0x10000000; + } + + currentEntityListPtrTemp = &gCurrentEntityListPtr; + heap_free((**currentEntityListPtrTemp)[entityIndex]); + (**currentEntityListPtrTemp)[entityIndex] = NULL; +} + +s32 func_8011085C(s32 shadowIndex) { + Shadow* shadow = get_shadow_by_index(shadowIndex); + ShadowList** currentShadowListPtr = &gCurrentShadowListPtr; + + free_entity_model_by_index(shadow->unk_08); + heap_free((**currentShadowListPtr)[shadowIndex]); + (**currentShadowListPtr)[shadowIndex] = NULL; +} INCLUDE_ASM(s32, "code_a5dd0_len_114e0", entity_get_collision_flags); @@ -129,9 +193,16 @@ s32 is_player_action_state(ActionState actionState) { return actionState == gPlayerActionState; } -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_80110BCC); +void func_80110BCC(Entity *entity) { + if (!(entity->flags & 8)) { + func_80122D7C(entity->virtualModelIndex); + } +} -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_80110BF8); +void func_80110BF8(Entity *entity) { + entity->unk_07 = 0; + entity->flags &= ~0x00010000; +} #ifdef NON_MATCHING #define AREA_SPECIFIC_ENTITY_VRAM &entity_default_VRAM @@ -178,6 +249,7 @@ INCLUDE_ASM(s32, "code_a5dd0_len_114e0", create_shadow_from_data); INCLUDE_ASM(s32, "code_a5dd0_len_114e0", MakeEntity, ScriptInstance* script, s32 isInitialCall); + INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_80111E9C); INCLUDE_ASM(s32, "code_a5dd0_len_114e0", UseDynamicShadow); diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/delete_entity.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/delete_entity.s deleted file mode 100644 index c26ba2b3c8..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/delete_entity.s +++ /dev/null @@ -1,56 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel delete_entity -/* A6DD0 801106D0 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* A6DD4 801106D4 AFB00010 */ sw $s0, 0x10($sp) -/* A6DD8 801106D8 0080802D */ daddu $s0, $a0, $zero -/* A6DDC 801106DC AFBF0018 */ sw $ra, 0x18($sp) -/* A6DE0 801106E0 0C04417A */ jal get_entity_by_index -/* A6DE4 801106E4 AFB10014 */ sw $s1, 0x14($sp) -/* A6DE8 801106E8 0040882D */ daddu $s1, $v0, $zero -/* A6DEC 801106EC 8E240040 */ lw $a0, 0x40($s1) -/* A6DF0 801106F0 10800003 */ beqz $a0, .L80110700 -/* A6DF4 801106F4 00000000 */ nop -/* A6DF8 801106F8 0C00AB4B */ jal heap_free -/* A6DFC 801106FC 00000000 */ nop -.L80110700: -/* A6E00 80110700 8E220000 */ lw $v0, ($s1) -/* A6E04 80110704 30420008 */ andi $v0, $v0, 8 -/* A6E08 80110708 14400005 */ bnez $v0, .L80110720 -/* A6E0C 8011070C 00000000 */ nop -/* A6E10 80110710 0C048B7F */ jal free_entity_model_by_index -/* A6E14 80110714 86240014 */ lh $a0, 0x14($s1) -/* A6E18 80110718 080441CC */ j .L80110730 -/* A6E1C 8011071C 00000000 */ nop -.L80110720: -/* A6E20 80110720 0C047FF8 */ jal get_anim_mesh -/* A6E24 80110724 86240014 */ lh $a0, 0x14($s1) -/* A6E28 80110728 0C04790E */ jal func_8011E438 -/* A6E2C 8011072C 0040202D */ daddu $a0, $v0, $zero -.L80110730: -/* A6E30 80110730 86240016 */ lh $a0, 0x16($s1) -/* A6E34 80110734 04800007 */ bltz $a0, .L80110754 -/* A6E38 80110738 00000000 */ nop -/* A6E3C 8011073C 0C044181 */ jal get_shadow_by_index -/* A6E40 80110740 00000000 */ nop -/* A6E44 80110744 8C430000 */ lw $v1, ($v0) -/* A6E48 80110748 3C041000 */ lui $a0, 0x1000 -/* A6E4C 8011074C 00641825 */ or $v1, $v1, $a0 -/* A6E50 80110750 AC430000 */ sw $v1, ($v0) -.L80110754: -/* A6E54 80110754 3C118015 */ lui $s1, %hi(gCurrentEntityListPtr) -/* A6E58 80110758 26311470 */ addiu $s1, $s1, %lo(gCurrentEntityListPtr) -/* A6E5C 8011075C 8E220000 */ lw $v0, ($s1) -/* A6E60 80110760 00108080 */ sll $s0, $s0, 2 -/* A6E64 80110764 02021021 */ addu $v0, $s0, $v0 -/* A6E68 80110768 0C00AB4B */ jal heap_free -/* A6E6C 8011076C 8C440000 */ lw $a0, ($v0) -/* A6E70 80110770 8E220000 */ lw $v0, ($s1) -/* A6E74 80110774 02028021 */ addu $s0, $s0, $v0 -/* A6E78 80110778 AE000000 */ sw $zero, ($s0) -/* A6E7C 8011077C 8FBF0018 */ lw $ra, 0x18($sp) -/* A6E80 80110780 8FB10014 */ lw $s1, 0x14($sp) -/* A6E84 80110784 8FB00010 */ lw $s0, 0x10($sp) -/* A6E88 80110788 03E00008 */ jr $ra -/* A6E8C 8011078C 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/delete_entity_and_unload_data.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/delete_entity_and_unload_data.s deleted file mode 100644 index 9f7eedbc73..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/delete_entity_and_unload_data.s +++ /dev/null @@ -1,59 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel delete_entity_and_unload_data -/* A6E90 80110790 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* A6E94 80110794 AFB00010 */ sw $s0, 0x10($sp) -/* A6E98 80110798 0080802D */ daddu $s0, $a0, $zero -/* A6E9C 8011079C AFBF0018 */ sw $ra, 0x18($sp) -/* A6EA0 801107A0 0C04417A */ jal get_entity_by_index -/* A6EA4 801107A4 AFB10014 */ sw $s1, 0x14($sp) -/* A6EA8 801107A8 0040882D */ daddu $s1, $v0, $zero -/* A6EAC 801107AC 8E240040 */ lw $a0, 0x40($s1) -/* A6EB0 801107B0 10800003 */ beqz $a0, .L801107C0 -/* A6EB4 801107B4 00000000 */ nop -/* A6EB8 801107B8 0C00AB4B */ jal heap_free -/* A6EBC 801107BC 00000000 */ nop -.L801107C0: -/* A6EC0 801107C0 8E220000 */ lw $v0, ($s1) -/* A6EC4 801107C4 30420008 */ andi $v0, $v0, 8 -/* A6EC8 801107C8 14400005 */ bnez $v0, .L801107E0 -/* A6ECC 801107CC 00000000 */ nop -/* A6ED0 801107D0 0C048B7F */ jal free_entity_model_by_index -/* A6ED4 801107D4 86240014 */ lh $a0, 0x14($s1) -/* A6ED8 801107D8 080441FC */ j .L801107F0 -/* A6EDC 801107DC 00000000 */ nop -.L801107E0: -/* A6EE0 801107E0 0C047FF8 */ jal get_anim_mesh -/* A6EE4 801107E4 86240014 */ lh $a0, 0x14($s1) -/* A6EE8 801107E8 0C04790E */ jal func_8011E438 -/* A6EEC 801107EC 0040202D */ daddu $a0, $v0, $zero -.L801107F0: -/* A6EF0 801107F0 8E240038 */ lw $a0, 0x38($s1) -/* A6EF4 801107F4 0C0445F7 */ jal func_801117DC -/* A6EF8 801107F8 00000000 */ nop -/* A6EFC 801107FC 86240016 */ lh $a0, 0x16($s1) -/* A6F00 80110800 04800007 */ bltz $a0, .L80110820 -/* A6F04 80110804 00000000 */ nop -/* A6F08 80110808 0C044181 */ jal get_shadow_by_index -/* A6F0C 8011080C 00000000 */ nop -/* A6F10 80110810 8C430000 */ lw $v1, ($v0) -/* A6F14 80110814 3C041000 */ lui $a0, 0x1000 -/* A6F18 80110818 00641825 */ or $v1, $v1, $a0 -/* A6F1C 8011081C AC430000 */ sw $v1, ($v0) -.L80110820: -/* A6F20 80110820 3C118015 */ lui $s1, %hi(gCurrentEntityListPtr) -/* A6F24 80110824 26311470 */ addiu $s1, $s1, %lo(gCurrentEntityListPtr) -/* A6F28 80110828 8E220000 */ lw $v0, ($s1) -/* A6F2C 8011082C 00108080 */ sll $s0, $s0, 2 -/* A6F30 80110830 02021021 */ addu $v0, $s0, $v0 -/* A6F34 80110834 0C00AB4B */ jal heap_free -/* A6F38 80110838 8C440000 */ lw $a0, ($v0) -/* A6F3C 8011083C 8E220000 */ lw $v0, ($s1) -/* A6F40 80110840 02028021 */ addu $s0, $s0, $v0 -/* A6F44 80110844 AE000000 */ sw $zero, ($s0) -/* A6F48 80110848 8FBF0018 */ lw $ra, 0x18($sp) -/* A6F4C 8011084C 8FB10014 */ lw $s1, 0x14($sp) -/* A6F50 80110850 8FB00010 */ lw $s0, 0x10($sp) -/* A6F54 80110854 03E00008 */ jr $ra -/* A6F58 80110858 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_8010FE44.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_8010FE44.s deleted file mode 100644 index acdfe29a8e..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_8010FE44.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8010FE44 -/* A6544 8010FE44 3C058015 */ lui $a1, %hi(D_8014AFB0) -/* A6548 8010FE48 8CA5AFB0 */ lw $a1, %lo(D_8014AFB0)($a1) -/* A654C 8010FE4C 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* A6550 8010FE50 AFBF0010 */ sw $ra, 0x10($sp) -/* A6554 8010FE54 0C043F66 */ jal func_8010FD98 -/* A6558 8010FE58 00000000 */ nop -/* A655C 8010FE5C 8FBF0010 */ lw $ra, 0x10($sp) -/* A6560 8010FE60 03E00008 */ jr $ra -/* A6564 8010FE64 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110678.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110678.s deleted file mode 100644 index 000c574269..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110678.s +++ /dev/null @@ -1,16 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80110678 -/* A6D78 80110678 0080282D */ daddu $a1, $a0, $zero -/* A6D7C 8011067C 8CA20028 */ lw $v0, 0x28($a1) -/* A6D80 80110680 14400003 */ bnez $v0, .L80110690 -/* A6D84 80110684 24020001 */ addiu $v0, $zero, 1 -/* A6D88 80110688 03E00008 */ jr $ra -/* A6D8C 8011068C 0000102D */ daddu $v0, $zero, $zero -.L80110690: -/* A6D90 80110690 8CA30000 */ lw $v1, ($a1) -/* A6D94 80110694 3C040100 */ lui $a0, 0x100 -/* A6D98 80110698 00641825 */ or $v1, $v1, $a0 -/* A6D9C 8011069C 03E00008 */ jr $ra -/* A6DA0 801106A0 ACA30000 */ sw $v1, ($a1) diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_8011085C.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_8011085C.s deleted file mode 100644 index f528ea13e6..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_8011085C.s +++ /dev/null @@ -1,27 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8011085C -/* A6F5C 8011085C 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* A6F60 80110860 AFB00010 */ sw $s0, 0x10($sp) -/* A6F64 80110864 0080802D */ daddu $s0, $a0, $zero -/* A6F68 80110868 AFBF0018 */ sw $ra, 0x18($sp) -/* A6F6C 8011086C 0C044181 */ jal get_shadow_by_index -/* A6F70 80110870 AFB10014 */ sw $s1, 0x14($sp) -/* A6F74 80110874 84440008 */ lh $a0, 8($v0) -/* A6F78 80110878 0C048B7F */ jal free_entity_model_by_index -/* A6F7C 8011087C 00108080 */ sll $s0, $s0, 2 -/* A6F80 80110880 3C118015 */ lui $s1, %hi(gCurrentShadowListPtr) -/* A6F84 80110884 26311658 */ addiu $s1, $s1, %lo(gCurrentShadowListPtr) -/* A6F88 80110888 8E220000 */ lw $v0, ($s1) -/* A6F8C 8011088C 02021021 */ addu $v0, $s0, $v0 -/* A6F90 80110890 0C00AB4B */ jal heap_free -/* A6F94 80110894 8C440000 */ lw $a0, ($v0) -/* A6F98 80110898 8E220000 */ lw $v0, ($s1) -/* A6F9C 8011089C 02028021 */ addu $s0, $s0, $v0 -/* A6FA0 801108A0 AE000000 */ sw $zero, ($s0) -/* A6FA4 801108A4 8FBF0018 */ lw $ra, 0x18($sp) -/* A6FA8 801108A8 8FB10014 */ lw $s1, 0x14($sp) -/* A6FAC 801108AC 8FB00010 */ lw $s0, 0x10($sp) -/* A6FB0 801108B0 03E00008 */ jr $ra -/* A6FB4 801108B4 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110BCC.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110BCC.s deleted file mode 100644 index 5a33af30ad..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110BCC.s +++ /dev/null @@ -1,16 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80110BCC -/* A72CC 80110BCC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* A72D0 80110BD0 AFBF0010 */ sw $ra, 0x10($sp) -/* A72D4 80110BD4 8C820000 */ lw $v0, ($a0) -/* A72D8 80110BD8 30420008 */ andi $v0, $v0, 8 -/* A72DC 80110BDC 14400003 */ bnez $v0, .L80110BEC -/* A72E0 80110BE0 00000000 */ nop -/* A72E4 80110BE4 0C048B5F */ jal func_80122D7C -/* A72E8 80110BE8 84840014 */ lh $a0, 0x14($a0) -.L80110BEC: -/* A72EC 80110BEC 8FBF0010 */ lw $ra, 0x10($sp) -/* A72F0 80110BF0 03E00008 */ jr $ra -/* A72F4 80110BF4 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110BF8.s b/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110BF8.s deleted file mode 100644 index 4a9e1d68f0..0000000000 --- a/ver/us/asm/nonmatchings/code_a5dd0_len_114e0/func_80110BF8.s +++ /dev/null @@ -1,11 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80110BF8 -/* A72F8 80110BF8 3C03FFFE */ lui $v1, 0xfffe -/* A72FC 80110BFC 8C820000 */ lw $v0, ($a0) -/* A7300 80110C00 3463FFFF */ ori $v1, $v1, 0xffff -/* A7304 80110C04 A0800007 */ sb $zero, 7($a0) -/* A7308 80110C08 00431024 */ and $v0, $v0, $v1 -/* A730C 80110C0C 03E00008 */ jr $ra -/* A7310 80110C10 AC820000 */ sw $v0, ($a0)