From 52ca40f63241795b5c7d27363e21cceadcd877b7 Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Sun, 18 Apr 2021 18:30:54 +0100 Subject: [PATCH] DenSinH's PR (#269) --- include/common_structs.h | 10 ++- src/C50A0.c | 48 ++++++++++++- ver/us/asm/nonmatchings/C50A0/func_80130A04.s | 68 ------------------- ver/us/asm/nonmatchings/C50A0/func_80130ACC.s | 22 ------ ver/us/asm/nonmatchings/C50A0/init_got_item.s | 2 +- .../asm/nonmatchings/C50A0/make_item_entity.s | 2 +- .../nonmatchings/C50A0/update_item_entities.s | 2 +- 7 files changed, 58 insertions(+), 96 deletions(-) delete mode 100644 ver/us/asm/nonmatchings/C50A0/func_80130A04.s delete mode 100644 ver/us/asm/nonmatchings/C50A0/func_80130ACC.s diff --git a/include/common_structs.h b/include/common_structs.h index 148a8bf8ca..80fc604bca 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -893,7 +893,15 @@ typedef struct ItemEntity { /* 0x2E */ u8 unkCounter; /* 0x2F */ s8 unk_2F; /* 0x30 */ f32 scale; - /* 0x34 */ char unk_34[40]; + /* 0x34 */ char unk_34[8]; + /* 0x3C */ s32 framesLeft; + /* 0x40 */ s32* currentState; + /* 0x44 */ s32 unk_44; + /* 0x48 */ s32* sequenceStart; + /* 0x4C */ s32* unk_4C; + /* 0x50 */ s32* unk_50; + /* 0x54 */ s32 unk_54; + /* 0x58 */ s32 unk_58; } ItemEntity; // size = 0x5C typedef struct ModelNode { diff --git a/src/C50A0.c b/src/C50A0.c index de7b5adcc4..c12f78ca53 100644 --- a/src/C50A0.c +++ b/src/C50A0.c @@ -17,9 +17,53 @@ INCLUDE_ASM(s32, "C50A0", func_8012FE78); INCLUDE_ASM(s32, "C50A0", func_801309F0); -INCLUDE_ASM(s32, "C50A0", func_80130A04); +s32 next_sequence_step(ItemEntity *itemEntity) { + s32* currentState = itemEntity->currentState; -INCLUDE_ASM(s32, "C50A0", func_80130ACC); + switch (*currentState++) { + case 1: + itemEntity->framesLeft = *currentState++; + itemEntity->unk_44 = *currentState++; + itemEntity->currentState = currentState; + break; + + case 2: + itemEntity->currentState = itemEntity->sequenceStart; + return 1; + + case 3: + itemEntity->sequenceStart = currentState; + itemEntity->currentState = currentState; + return 1; + + case 7: + itemEntity->framesLeft = *currentState++; + itemEntity->unk_4C = *currentState++; + itemEntity->unk_50 = *currentState++; + itemEntity->unk_54 = *currentState++; + itemEntity->unk_58 = *currentState++; + itemEntity->currentState = currentState; + break; + + case 4: + itemEntity->currentState = currentState++; + itemEntity->currentState = currentState++; + + case 0: + return 1; + } + + return 0; +} + +void do_animation(ItemEntity* itemEntity) { + itemEntity->framesLeft--; + if (itemEntity->framesLeft <= 0) { + while (next_sequence_step(itemEntity) != 0) { + + } + } +} INCLUDE_ASM(s32, "C50A0", draw_coin_sparkles); diff --git a/ver/us/asm/nonmatchings/C50A0/func_80130A04.s b/ver/us/asm/nonmatchings/C50A0/func_80130A04.s deleted file mode 100644 index 04a5855f56..0000000000 --- a/ver/us/asm/nonmatchings/C50A0/func_80130A04.s +++ /dev/null @@ -1,68 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.section .rodata - -glabel jtbl_80150A60 -.word L80130ABC_C71BC, L80130A30_C7130, L80130A50_C7150, L80130A60_C7160, L80130AB4_C71B4, L80130AC4_C71C4, L80130AC4_C71C4, L80130A70_C7170 - -.section .text - -glabel func_80130A04 -/* C7104 80130A04 8C830040 */ lw $v1, 0x40($a0) -/* C7108 80130A08 8C650000 */ lw $a1, ($v1) -/* C710C 80130A0C 2CA20008 */ sltiu $v0, $a1, 8 -/* C7110 80130A10 1040002C */ beqz $v0, L80130AC4_C71C4 -/* C7114 80130A14 24630004 */ addiu $v1, $v1, 4 -/* C7118 80130A18 00051080 */ sll $v0, $a1, 2 -/* C711C 80130A1C 3C018015 */ lui $at, %hi(jtbl_80150A60) -/* C7120 80130A20 00220821 */ addu $at, $at, $v0 -/* C7124 80130A24 8C220A60 */ lw $v0, %lo(jtbl_80150A60)($at) -/* C7128 80130A28 00400008 */ jr $v0 -/* C712C 80130A2C 00000000 */ nop -glabel L80130A30_C7130 -/* C7130 80130A30 8C620000 */ lw $v0, ($v1) -/* C7134 80130A34 24630004 */ addiu $v1, $v1, 4 -/* C7138 80130A38 AC82003C */ sw $v0, 0x3c($a0) -/* C713C 80130A3C 8C620000 */ lw $v0, ($v1) -/* C7140 80130A40 24630004 */ addiu $v1, $v1, 4 -/* C7144 80130A44 AC830040 */ sw $v1, 0x40($a0) -/* C7148 80130A48 0804C2B1 */ j L80130AC4_C71C4 -/* C714C 80130A4C AC820044 */ sw $v0, 0x44($a0) -glabel L80130A50_C7150 -/* C7150 80130A50 8C830048 */ lw $v1, 0x48($a0) -/* C7154 80130A54 24020001 */ addiu $v0, $zero, 1 -/* C7158 80130A58 03E00008 */ jr $ra -/* C715C 80130A5C AC830040 */ sw $v1, 0x40($a0) -glabel L80130A60_C7160 -/* C7160 80130A60 24020001 */ addiu $v0, $zero, 1 -/* C7164 80130A64 AC830048 */ sw $v1, 0x48($a0) -/* C7168 80130A68 03E00008 */ jr $ra -/* C716C 80130A6C AC830040 */ sw $v1, 0x40($a0) -glabel L80130A70_C7170 -/* C7170 80130A70 8C620000 */ lw $v0, ($v1) -/* C7174 80130A74 24630004 */ addiu $v1, $v1, 4 -/* C7178 80130A78 AC82003C */ sw $v0, 0x3c($a0) -/* C717C 80130A7C 8C620000 */ lw $v0, ($v1) -/* C7180 80130A80 24630004 */ addiu $v1, $v1, 4 -/* C7184 80130A84 AC82004C */ sw $v0, 0x4c($a0) -/* C7188 80130A88 8C620000 */ lw $v0, ($v1) -/* C718C 80130A8C 24630004 */ addiu $v1, $v1, 4 -/* C7190 80130A90 AC820050 */ sw $v0, 0x50($a0) -/* C7194 80130A94 8C620000 */ lw $v0, ($v1) -/* C7198 80130A98 24630004 */ addiu $v1, $v1, 4 -/* C719C 80130A9C AC820054 */ sw $v0, 0x54($a0) -/* C71A0 80130AA0 8C620000 */ lw $v0, ($v1) -/* C71A4 80130AA4 24630004 */ addiu $v1, $v1, 4 -/* C71A8 80130AA8 AC830040 */ sw $v1, 0x40($a0) -/* C71AC 80130AAC 0804C2B1 */ j L80130AC4_C71C4 -/* C71B0 80130AB0 AC820058 */ sw $v0, 0x58($a0) -glabel L80130AB4_C71B4 -/* C71B4 80130AB4 24630004 */ addiu $v1, $v1, 4 -/* C71B8 80130AB8 AC830040 */ sw $v1, 0x40($a0) -glabel L80130ABC_C71BC -/* C71BC 80130ABC 03E00008 */ jr $ra -/* C71C0 80130AC0 24020001 */ addiu $v0, $zero, 1 -glabel L80130AC4_C71C4 -/* C71C4 80130AC4 03E00008 */ jr $ra -/* C71C8 80130AC8 0000102D */ daddu $v0, $zero, $zero diff --git a/ver/us/asm/nonmatchings/C50A0/func_80130ACC.s b/ver/us/asm/nonmatchings/C50A0/func_80130ACC.s deleted file mode 100644 index c900a6dfdd..0000000000 --- a/ver/us/asm/nonmatchings/C50A0/func_80130ACC.s +++ /dev/null @@ -1,22 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_80130ACC -/* C71CC 80130ACC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* C71D0 80130AD0 AFB00010 */ sw $s0, 0x10($sp) -/* C71D4 80130AD4 0080802D */ daddu $s0, $a0, $zero -/* C71D8 80130AD8 AFBF0014 */ sw $ra, 0x14($sp) -/* C71DC 80130ADC 8E02003C */ lw $v0, 0x3c($s0) -/* C71E0 80130AE0 2442FFFF */ addiu $v0, $v0, -1 -/* C71E4 80130AE4 1C400005 */ bgtz $v0, .L80130AFC -/* C71E8 80130AE8 AE02003C */ sw $v0, 0x3c($s0) -.L80130AEC: -/* C71EC 80130AEC 0C04C281 */ jal func_80130A04 -/* C71F0 80130AF0 0200202D */ daddu $a0, $s0, $zero -/* C71F4 80130AF4 1440FFFD */ bnez $v0, .L80130AEC -/* C71F8 80130AF8 00000000 */ nop -.L80130AFC: -/* C71FC 80130AFC 8FBF0014 */ lw $ra, 0x14($sp) -/* C7200 80130B00 8FB00010 */ lw $s0, 0x10($sp) -/* C7204 80130B04 03E00008 */ jr $ra -/* C7208 80130B08 27BD0018 */ addiu $sp, $sp, 0x18 diff --git a/ver/us/asm/nonmatchings/C50A0/init_got_item.s b/ver/us/asm/nonmatchings/C50A0/init_got_item.s index 06a1e01d49..c685aaedbd 100644 --- a/ver/us/asm/nonmatchings/C50A0/init_got_item.s +++ b/ver/us/asm/nonmatchings/C50A0/init_got_item.s @@ -180,7 +180,7 @@ glabel init_got_item /* C8498 80131D98 24A54AC0 */ addiu $a1, $a1, %lo(D_80104AC0) /* C849C 80131D9C 0C04C27C */ jal func_801309F0 /* C84A0 80131DA0 0220202D */ daddu $a0, $s1, $zero -/* C84A4 80131DA4 0C04C2B3 */ jal func_80130ACC +/* C84A4 80131DA4 0C04C2B3 */ jal do_animation /* C84A8 80131DA8 0220202D */ daddu $a0, $s1, $zero /* C84AC 80131DAC 02A0102D */ daddu $v0, $s5, $zero .L80131DB0: diff --git a/ver/us/asm/nonmatchings/C50A0/make_item_entity.s b/ver/us/asm/nonmatchings/C50A0/make_item_entity.s index 28c53362a9..e8c91f32f8 100644 --- a/ver/us/asm/nonmatchings/C50A0/make_item_entity.s +++ b/ver/us/asm/nonmatchings/C50A0/make_item_entity.s @@ -471,7 +471,7 @@ glabel L80131A0C_C810C /* C813C 80131A3C 24A54AC0 */ addiu $a1, $a1, %lo(D_80104AC0) /* C8140 80131A40 0C04C27C */ jal func_801309F0 /* C8144 80131A44 0200202D */ daddu $a0, $s0, $zero -/* C8148 80131A48 0C04C2B3 */ jal func_80130ACC +/* C8148 80131A48 0C04C2B3 */ jal do_animation /* C814C 80131A4C 0200202D */ daddu $a0, $s0, $zero /* C8150 80131A50 86030018 */ lh $v1, 0x18($s0) /* C8154 80131A54 2402015C */ addiu $v0, $zero, 0x15c diff --git a/ver/us/asm/nonmatchings/C50A0/update_item_entities.s b/ver/us/asm/nonmatchings/C50A0/update_item_entities.s index 17405fa662..62fe7eff58 100644 --- a/ver/us/asm/nonmatchings/C50A0/update_item_entities.s +++ b/ver/us/asm/nonmatchings/C50A0/update_item_entities.s @@ -60,7 +60,7 @@ glabel update_item_entities /* C869C 80131F9C 3C018015 */ lui $at, %hi(D_80155D90) /* C86A0 80131FA0 A4225D90 */ sh $v0, %lo(D_80155D90)($at) .L80131FA4: -/* C86A4 80131FA4 0C04C2B3 */ jal func_80130ACC +/* C86A4 80131FA4 0C04C2B3 */ jal do_animation /* C86A8 80131FA8 0220202D */ daddu $a0, $s1, $zero .L80131FAC: /* C86AC 80131FAC 0C04C775 */ jal func_80131DD4