diff --git a/asm/object/specialFx.s b/asm/object/specialFx.s deleted file mode 100644 index 7d0ac4c2..00000000 --- a/asm/object/specialFx.s +++ /dev/null @@ -1,470 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start SpecialFx -SpecialFx: @ 0x080844C8 - push {lr} - ldr r2, _080844DC @ =gUnk_0811FAC0 - ldrb r1, [r0, #0xc] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_080844DC: .4byte gUnk_0811FAC0 - - thumb_func_start sub_080844E0 -sub_080844E0: @ 0x080844E0 - push {r4, r5, lr} - adds r5, r0, #0 - movs r2, #1 - movs r0, #1 - strb r0, [r5, #0xc] - ldrb r1, [r5, #0x10] - movs r0, #0x7f - ands r0, r1 - strb r0, [r5, #0x10] - ldrb r1, [r5, #0x18] - movs r0, #4 - rsbs r0, r0, #0 - ands r0, r1 - orrs r0, r2 - strb r0, [r5, #0x18] - adds r0, r5, #0 - movs r1, #6 - bl SetDefaultPriority - adds r0, r5, #0 - adds r0, #0x38 - ldrb r0, [r0] - cmp r0, #0 - bne _08084516 - adds r0, r5, #0 - bl ResolveCollisionLayer -_08084516: - ldrb r0, [r5, #0xa] - cmp r0, #0x20 - bne _08084524 - ldrb r0, [r5, #0x10] - movs r1, #0x20 - orrs r0, r1 - strb r0, [r5, #0x10] -_08084524: - ldrb r4, [r5, #0xa] - cmp r4, #3 - bne _08084538 - bl Random - ldr r1, _080845AC @ =gUnk_0811FAC8 - ands r4, r0 - adds r1, r4, r1 - ldrb r0, [r1] - strb r0, [r5, #0xa] -_08084538: - ldrb r0, [r5, #0xa] - cmp r0, #0x17 - bne _0808454E - bl Random - ldr r2, _080845B0 @ =gUnk_0811FACC - movs r1, #3 - ands r1, r0 - adds r1, r1, r2 - ldrb r0, [r1] - strb r0, [r5, #0xa] -_0808454E: - ldrb r1, [r5, #0xa] - adds r0, r5, #0 - bl InitializeAnimation - ldrb r0, [r5, #0xa] - lsls r0, r0, #2 - ldr r1, _080845B4 @ =gUnk_0811F960 - adds r4, r0, r1 - ldrb r1, [r4] - movs r0, #0xf - ands r0, r1 - cmp r0, #6 - bne _0808456C - movs r0, #0x40 - strh r0, [r5, #0x24] -_0808456C: - ldrh r0, [r4, #2] - cmp r0, #0 - beq _08084582 - ldrb r1, [r5, #0xb] - movs r0, #0x40 - ands r0, r1 - cmp r0, #0 - bne _08084582 - ldrh r0, [r4, #2] - bl EnqueueSFX -_08084582: - ldrb r1, [r5, #0xb] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08084594 - ldrb r1, [r4, #1] - adds r0, r5, #0 - bl CreateRandomItemDrop -_08084594: - ldrb r1, [r5, #0xb] - movs r0, #0x20 - ands r0, r1 - cmp r0, #0 - beq _080845AA - ldrb r0, [r5, #0x19] - movs r1, #0x3f - ands r1, r0 - movs r0, #0x40 - orrs r1, r0 - strb r1, [r5, #0x19] -_080845AA: - pop {r4, r5, pc} - .align 2, 0 -_080845AC: .4byte gUnk_0811FAC8 -_080845B0: .4byte gUnk_0811FACC -_080845B4: .4byte gUnk_0811F960 - - thumb_func_start sub_080845B8 -sub_080845B8: @ 0x080845B8 - push {lr} - ldr r3, _080845D4 @ =gUnk_0811FAD0 - ldr r2, _080845D8 @ =gUnk_0811F960 - ldrb r1, [r0, #0xa] - lsls r1, r1, #2 - adds r1, r1, r2 - ldrb r1, [r1] - lsls r1, r1, #0x1c - lsrs r1, r1, #0x1a - adds r1, r1, r3 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_080845D4: .4byte gUnk_0811FAD0 -_080845D8: .4byte gUnk_0811F960 - - thumb_func_start sub_080845DC -sub_080845DC: @ 0x080845DC - push {r4, lr} - adds r4, r0, #0 - bl GetNextFrame - adds r4, #0x5a - ldrb r1, [r4] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _080845F4 - bl DeleteThisEntity -_080845F4: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_080845F8 -sub_080845F8: @ 0x080845F8 - push {r4, lr} - adds r4, r0, #0 - ldrh r2, [r4, #0x2e] - movs r1, #0xf - adds r0, r1, #0 - ands r0, r2 - movs r2, #8 - subs r3, r2, r0 - ldrh r0, [r4, #0x32] - ands r1, r0 - subs r1, r2, r1 - adds r0, r3, #0 - orrs r0, r1 - cmp r0, #0 - beq _08084626 - adds r0, r3, #0 - bl sub_080045DA - lsrs r0, r0, #3 - strb r0, [r4, #0x15] - adds r0, r4, #0 - bl LinearMoveUpdate -_08084626: - adds r0, r4, #0 - bl sub_08084630 - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_08084630 -sub_08084630: @ 0x08084630 - push {r4, lr} - adds r4, r0, #0 - bl GetNextFrame - adds r0, r4, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _0808467E - ldrb r1, [r4, #0xb] - movs r3, #1 - adds r0, r3, #0 - ands r0, r1 - cmp r0, #0 - beq _0808467A - ldr r1, [r4, #0x54] - cmp r1, #0 - beq _0808467A - adds r1, #0x6a - ldrh r0, [r1] - subs r0, #1 - strh r0, [r1] - ldr r0, [r4, #0x68] - cmp r0, #0 - beq _0808467A - ldr r2, [r4, #0x54] - adds r2, #0x6c - subs r0, #1 - movs r1, #0x1f - ands r0, r1 - adds r1, r3, #0 - lsls r1, r0 - ldrh r0, [r2] - bics r0, r1 - strh r0, [r2] -_0808467A: - bl DeleteThisEntity -_0808467E: - pop {r4, pc} - - thumb_func_start sub_08084680 -sub_08084680: @ 0x08084680 - push {lr} - ldr r1, [r0, #0x34] - movs r2, #0x80 - lsls r2, r2, #7 - adds r1, r1, r2 - str r1, [r0, #0x34] - bl sub_080845DC - pop {pc} - .align 2, 0 - - thumb_func_start sub_08084694 -sub_08084694: @ 0x08084694 - push {r4, lr} - adds r4, r0, #0 - ldr r0, [r4, #0x50] - cmp r0, #0 - beq _080846A4 - ldr r0, [r0, #4] - cmp r0, #0 - bne _080846A8 -_080846A4: - bl DeleteThisEntity -_080846A8: - adds r0, r4, #0 - bl GetNextFrame - pop {r4, pc} - - thumb_func_start sub_080846B0 -sub_080846B0: @ 0x080846B0 - push {r4, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xe] - cmp r0, #0 - beq _080846D8 - ldrh r1, [r4, #0x24] - movs r2, #0x24 - ldrsh r0, [r4, r2] - cmp r0, #0 - beq _080846CA - adds r0, r1, #0 - subs r0, #0x10 - strh r0, [r4, #0x24] -_080846CA: - adds r0, r4, #0 - bl LinearMoveUpdate - adds r0, r4, #0 - bl sub_080845DC - b _08084718 -_080846D8: - movs r0, #1 - strb r0, [r4, #0xe] - ldrb r1, [r4, #0x14] - movs r0, #2 - orrs r0, r1 - cmp r0, #2 - bne _080846EA - movs r0, #0x1e - b _080846EC -_080846EA: - movs r0, #2 -_080846EC: - strb r0, [r4, #0x15] - ldrb r0, [r4, #0xf] - cmp r0, #0 - beq _08084712 - adds r1, r4, #0 - adds r1, #0x60 - ldrh r0, [r1] - adds r0, #1 - strh r0, [r1] - ldrb r0, [r4, #0x15] - movs r1, #1 - cmp r0, #0x17 - bls _08084708 - subs r1, #2 -_08084708: - adds r0, r0, r1 - strb r0, [r4, #0x15] - movs r0, #0xa0 - lsls r0, r0, #2 - b _08084716 -_08084712: - movs r0, #0xc0 - lsls r0, r0, #2 -_08084716: - strh r0, [r4, #0x24] -_08084718: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_0808471C -sub_0808471C: @ 0x0808471C - push {r4, r5, lr} - adds r5, r0, #0 - bl GetNextFrame - adds r0, r5, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08084768 - movs r4, #0 -_08084734: - adds r0, r5, #0 - movs r1, #0x24 - movs r2, #0 - bl CreateFx - adds r2, r0, #0 - cmp r2, #0 - beq _0808475E - lsls r1, r4, #1 - ldr r0, _0808476C @ =gUnk_0811FB08 - adds r1, r1, r0 - movs r0, #0 - ldrsb r0, [r1, r0] - ldrh r3, [r2, #0x2e] - adds r0, r0, r3 - strh r0, [r2, #0x2e] - movs r0, #1 - ldrsb r0, [r1, r0] - ldrh r1, [r2, #0x32] - adds r0, r0, r1 - strh r0, [r2, #0x32] -_0808475E: - adds r4, #1 - cmp r4, #3 - bls _08084734 - bl DeleteThisEntity -_08084768: - pop {r4, r5, pc} - .align 2, 0 -_0808476C: .4byte gUnk_0811FB08 - - thumb_func_start sub_08084770 -sub_08084770: @ 0x08084770 - push {lr} - ldr r1, [r0, #0x34] - ldr r2, _08084780 @ =0xFFFFC000 - adds r1, r1, r2 - str r1, [r0, #0x34] - bl sub_080845DC - pop {pc} - .align 2, 0 -_08084780: .4byte 0xFFFFC000 - - thumb_func_start sub_08084784 -sub_08084784: @ 0x08084784 - push {lr} - ldr r1, [r0, #0x34] - movs r2, #0x80 - lsls r2, r2, #7 - adds r1, r1, r2 - str r1, [r0, #0x34] - bl sub_080845DC - pop {pc} - .align 2, 0 - - thumb_func_start sub_08084798 -sub_08084798: @ 0x08084798 - push {r4, lr} - adds r4, r0, #0 - bl GetNextFrame - adds r0, r4, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080847B6 - ldr r0, [r4, #0x54] - ldr r0, [r0, #4] - cmp r0, #0 - bne _080847BA -_080847B6: - bl DeleteThisEntity -_080847BA: - pop {r4, pc} - - thumb_func_start sub_080847BC -sub_080847BC: @ 0x080847BC - push {lr} - ldr r1, [r0, #0x34] - ldr r2, _080847CC @ =0xFFFFE000 - adds r1, r1, r2 - str r1, [r0, #0x34] - bl sub_080845DC - pop {pc} - .align 2, 0 -_080847CC: .4byte 0xFFFFE000 - - thumb_func_start sub_080847D0 -sub_080847D0: @ 0x080847D0 - push {r4, lr} - adds r4, r0, #0 - bl LinearMoveUpdate - adds r0, r4, #0 - bl sub_080845DC - pop {r4, pc} - - thumb_func_start sub_080847E0 -sub_080847E0: @ 0x080847E0 - push {r4, r5, lr} - adds r5, r0, #0 - ldr r0, _08084814 @ =gRoomControls - ldrh r0, [r0] - cmp r0, #1 - bne _080847F0 - bl DeleteThisEntity -_080847F0: - ldr r4, _08084818 @ =gPlayerEntity - ldr r3, _0808481C @ =0xFFFD0000 - adds r0, r4, #0 - adds r1, r5, #0 - movs r2, #0 - bl PositionRelative - ldr r0, _08084820 @ =0x0000FFFD - strh r0, [r5, #0x36] - adds r0, r4, #0 - adds r1, r5, #0 - bl SortEntityAbove - adds r0, r5, #0 - bl sub_080845DC - pop {r4, r5, pc} - .align 2, 0 -_08084814: .4byte gRoomControls -_08084818: .4byte gPlayerEntity -_0808481C: .4byte 0xFFFD0000 -_08084820: .4byte 0x0000FFFD diff --git a/assets/assets.json b/assets/assets.json index c3103250..7af2eb13 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -43000,47 +43000,6 @@ "size": 56, "type": "animation" }, - { - "path": "specialFx/gUnk_0811F960.bin", - "start": 1177952, - "size": 155 - }, - { - "path": "specialFx/gUnk_0811F960_1_EU.bin", - "variants": [ - "EU" - ], - "starts": { - "EU": 1175875 - }, - "size": 197 - }, - { - "path": "specialFx/gUnk_0811F960_2_USA-JP-DEMO_USA-DEMO_JP.bin", - "variants": [ - "USA", - "JP", - "DEMO_USA", - "DEMO_JP" - ], - "start": 1178107, - "size": 197 - }, - { - "path": "specialFx/gUnk_0811FAC8.bin", - "start": 1178312, - "size": 4 - }, - { - "path": "specialFx/gUnk_0811FACC.bin", - "start": 1178316, - "size": 4 - }, - { - "path": "specialFx/gUnk_0811FB08.bin", - "start": 1178376, - "size": 8 - }, { "path": "object10/gUnk_0812056C.bin", "start": 1181036, @@ -51404,4 +51363,4 @@ }, "size": 129 } -] \ No newline at end of file +] diff --git a/data/const/object/specialFx.s b/data/const/object/specialFx.s deleted file mode 100644 index da0c9e6f..00000000 --- a/data/const/object/specialFx.s +++ /dev/null @@ -1,43 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811F960:: @ 0811F960 - .incbin "specialFx/gUnk_0811F960.bin" -.ifdef EU - @ TODO only small differences - .incbin "specialFx/gUnk_0811F960_1_EU.bin" -.else - .incbin "specialFx/gUnk_0811F960_2_USA-JP-DEMO_USA-DEMO_JP.bin" -.endif - -gUnk_0811FAC0:: @ 0811FAC0 - .4byte sub_080844E0 - .4byte sub_080845B8 - -gUnk_0811FAC8:: @ 0811FAC8 - .incbin "specialFx/gUnk_0811FAC8.bin" - -gUnk_0811FACC:: @ 0811FACC - .incbin "specialFx/gUnk_0811FACC.bin" - -gUnk_0811FAD0:: @ 0811FAD0 - .4byte sub_080845DC - .4byte sub_080845F8 - .4byte sub_08084630 - .4byte sub_08084694 - .4byte DeleteEntity - .4byte sub_08084680 - .4byte sub_080846B0 - .4byte sub_0808471C - .4byte sub_08084770 - .4byte sub_08084798 - .4byte sub_080847BC - .4byte sub_08084784 - .4byte sub_080847D0 - .4byte sub_080847E0 - -gUnk_0811FB08:: @ 0811FB08 - .incbin "specialFx/gUnk_0811FB08.bin" diff --git a/linker.ld b/linker.ld index 4caae1bc..6f10bdaa 100644 --- a/linker.ld +++ b/linker.ld @@ -661,7 +661,7 @@ SECTIONS { asm/object/chestSpawner.o(.text); asm/object/objectD.o(.text); asm/object/objectE.o(.text); - asm/object/specialFx.o(.text); + src/object/specialFx.o(.text); asm/object/object10.o(.text); asm/object/object11.o(.text); asm/object/object12.o(.text); @@ -1377,7 +1377,7 @@ SECTIONS { data/animations/object/chestSpawner.o(.rodata); data/const/object/objectD.o(.rodata); data/animations/object/objectD.o(.rodata); - data/const/object/specialFx.o(.rodata); + src/object/specialFx.o(.rodata); data/animations/object/specialFx.o(.rodata); data/const/object/object10.o(.rodata); data/const/object/object11.o(.rodata); diff --git a/src/object/specialFx.c b/src/object/specialFx.c new file mode 100644 index 00000000..dcd3a25a --- /dev/null +++ b/src/object/specialFx.c @@ -0,0 +1,306 @@ +#define NENT_DEPRECATED +#include "global.h" +#include "entity.h" +#include "object.h" +#include "functions.h" + +typedef struct { + Entity base; + u32 unk_68; + u8 unk_6c[0x1C]; +} SpecialFxObject; + +typedef struct { + u8 unk_00 : 4; + u8 unk_00_4 : 4; + u8 unk_01; + u16 unk_02; +} struct_0811F960; + +// way more legible like this than if clang-format were to put multiple elements on each line +// clang-format off +const struct_0811F960 gUnk_0811F960[] = { + {0x1, 0x0, 0x00, 0x12D}, + {0x0, 0x0, 0x00, 0x0FD}, + {0x0, 0x0, 0x00, 0x124}, + {0x0, 0x1, 0x11, 0x123}, + {0x0, 0x1, 0x12, 0x164}, + {0x0, 0x1, 0x13, 0x10D}, + {0x0, 0x0, 0x00, 0x0FF}, + {0x5, 0x1, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x2, 0x1, 0x00, 0x084}, + {0x2, 0x1, 0x00, 0x084}, + {0x0, 0x0, 0x00, 0x195}, + {0x0, 0x0, 0x00, 0x164}, + {0x0, 0x0, 0x00, 0x10D}, + {0x0, 0x1, 0x00, 0x074}, + {0x0, 0x0, 0x00, 0x10C}, + {0x5, 0x0, 0x00, 0x000}, + {0x0, 0x0, 0x10, 0x123}, + {0x5, 0x1, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x164}, + {0x0, 0x1, 0x14, 0x1A8}, + {0x0, 0x1, 0x10, 0x088}, + {0x0, 0x0, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x3, 0x0, 0x00, 0x197}, + {0x3, 0x0, 0x00, 0x000}, + {0x6, 0x1, 0x00, 0x074}, + {0x3, 0x0, 0x00, 0x074}, + {0x0, 0x0, 0x00, 0x074}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x7, 0x0, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x3, 0x1, 0x00, 0x000}, + {0x8, 0x1, 0x00, 0x000}, + {0x9, 0x1, 0x00, 0x15F}, + {0x0, 0x0, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x2, 0x1, 0x00, 0x084}, + {0x0, 0x0, 0x00, 0x074}, + {0x0, 0x0, 0x00, 0x164}, + {0xA, 0x1, 0x00, 0x000}, + {0xA, 0x1, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x9, 0x1, 0x00, 0x15F}, + {0x9, 0x1, 0x00, 0x15F}, + {0x9, 0x1, 0x00, 0x15F}, + {0x0, 0x0, 0x00, 0x000}, + {0x2, 0x0, 0x00, 0x17F}, + {0x0, 0x1, 0x11, 0x123}, + {0x0, 0x1, 0x11, 0x123}, + {0x0, 0x1, 0x11, 0x123}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x1B4}, + {0x0, 0x1, 0x13, 0x164}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x10, 0x088}, + {0x0, 0x1, 0x10, 0x088}, + {0x0, 0x1, 0x10, 0x088}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x11D}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x0, 0x00, 0x164}, + {0x0, 0x0, 0x00, 0x0FD}, + {0x0, 0x0, 0x00, 0x0FD}, + {0x0, 0x0, 0x00, 0x0FD}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0xB, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x000}, + {0x0, 0x1, 0x00, 0x0FD}, + {0x2, 0x1, 0x00, 0x084}, +#ifndef EU + {0x0, 0x0, 0x18, 0x124}, +#else + {0x0, 0x0, 0x16, 0x124}, +#endif + {0xC, 0x0, 0x00, 0x124}, + {0x0, 0x0, 0x00, 0x0FD}, + {0xD, 0x1, 0x00, 0x000}, + {0xD, 0x1, 0x00, 0x000}, +}; +// clang-format on + +void SpecialFx(Entity*); +void sub_080844E0(SpecialFxObject*); +void sub_080845B8(SpecialFxObject*); +void sub_080845DC(SpecialFxObject*); +void sub_080845F8(SpecialFxObject*); +void sub_08084630(SpecialFxObject*); +void sub_08084680(SpecialFxObject*); +void sub_08084694(SpecialFxObject*); +void sub_080846B0(SpecialFxObject*); +void sub_0808471C(SpecialFxObject*); +void sub_08084770(SpecialFxObject*); +void sub_08084784(SpecialFxObject*); +void sub_08084798(SpecialFxObject*); +void sub_080847BC(SpecialFxObject*); +void sub_080847D0(SpecialFxObject*); +void sub_080847E0(SpecialFxObject*); + +void SpecialFx(Entity* this) { + static void (*const gUnk_0811FAC0[])(SpecialFxObject*) = { + sub_080844E0, + sub_080845B8, + }; + gUnk_0811FAC0[this->action]((SpecialFxObject*)this); +} + +void sub_080844E0(SpecialFxObject* this) { + static const u8 gUnk_0811FAC8[] = { 0x03, 0x37, 0x38, 0x39 }; + static const u8 gUnk_0811FACC[] = { 0x17, 0x3e, 0x3f, 0x40 }; + const struct_0811F960* ptr; + super->action = 1; + super->flags &= ~0x80; + super->spriteSettings.draw = 1; + SetDefaultPriority(super, 6); + if (super->collisionLayer == 0) { + ResolveCollisionLayer(super); + } + if (super->type == 0x20) { + super->flags |= 0x20; + } + if (super->type == 0x3) { + super->type = gUnk_0811FAC8[Random() & 3]; + } + if (super->type == 0x17) { + super->type = gUnk_0811FACC[Random() & 3]; + } + InitializeAnimation(super, super->type); + ptr = &gUnk_0811F960[super->type]; + if (ptr->unk_00 == 6) { + super->speed = 0x40; + } + if (ptr->unk_02 && !(super->type2 & 0x40)) { + EnqueueSFX(ptr->unk_02); + } + if (super->type2 & 0x80) { + CreateRandomItemDrop(super, ptr->unk_01); + } + if (super->type2 & 0x20) { + super->spriteRendering.b3 = 1; + } +} + +void sub_080845B8(SpecialFxObject* this) { + static void (*const gUnk_0811FAD0[])(SpecialFxObject*) = { + sub_080845DC, sub_080845F8, sub_08084630, sub_08084694, (void (*)(SpecialFxObject*))DeleteEntity, + sub_08084680, sub_080846B0, sub_0808471C, sub_08084770, sub_08084798, + sub_080847BC, sub_08084784, sub_080847D0, sub_080847E0, + }; + gUnk_0811FAD0[gUnk_0811F960[super->type].unk_00](this); +} + +void sub_080845DC(SpecialFxObject* this) { + GetNextFrame(super); + if (super->frame & 0x80) { + DeleteThisEntity(); + } +} + +void sub_080845F8(SpecialFxObject* this) { + if (((8 - (super->x.HALF.HI & 0xF)) | (8 - (super->y.HALF.HI & 0xF))) != 0) { + super->direction = sub_080045DA((8 - (super->x.HALF.HI & 0xF)), (8 - (super->y.HALF.HI & 0xF))) >> 3; + LinearMoveUpdate(super); + } + sub_08084630(this); +} + +void sub_08084630(SpecialFxObject* this) { + GetNextFrame(super); + if (super->frame & 0x80) { + if ((super->type2 & 1) && (super->child != 0)) { + ((GenericEntity*)super->child)->field_0x6a.HWORD--; + if (this->unk_68 != 0) { + ((GenericEntity*)super->child)->field_0x6c.HWORD &= ~(1 << ((this->unk_68 - 1) & 0x1F)); + } + } + DeleteThisEntity(); + } +} + +void sub_08084680(SpecialFxObject* this) { + super->z.WORD += 0x4000; + sub_080845DC(this); +} + +void sub_08084694(SpecialFxObject* this) { + if (!super->parent || !super->parent->next) { + DeleteThisEntity(); + } + GetNextFrame(super); +} + +void sub_080846B0(SpecialFxObject* this) { + s32 tmp; + if (super->actionDelay != 0) { + if (super->speed != 0) { + super->speed -= 0x10; + } + LinearMoveUpdate(super); + sub_080845DC(this); + } else { + super->actionDelay = 1; + if ((super->animationState | 2) == 2) { + super->direction = 0x1e; + } else { + super->direction = 2; + } + if (super->field_0xf != 0) { + super->spriteVramOffset++; + tmp = (super->direction > 0x17 ? -1 : 1); + super->direction += tmp; + super->speed = 0x280; + } else { + super->speed = 0x300; + } + } +} + +void sub_0808471C(SpecialFxObject* this) { + static const s8 gUnk_0811FB08[] = { -8, -8, 8, -8, -8, 8, 8, 8 }; + GetNextFrame(super); + if (super->frame & 0x80) { + u32 i; + for (i = 0; i < 4; i++) { + Entity* fx = CreateFx(super, 0x24, 0); + if (fx) { + const s8* ptr = &gUnk_0811FB08[2 * i]; + fx->x.HALF.HI += ptr[0]; + fx->y.HALF.HI += ptr[1]; + } + } + DeleteThisEntity(); + } +} + +void sub_08084770(SpecialFxObject* this) { + super->z.WORD -= 0x4000; + sub_080845DC(this); +} + +void sub_08084784(SpecialFxObject* this) { + super->z.WORD += 0x4000; + sub_080845DC(this); +} + +void sub_08084798(SpecialFxObject* this) { + GetNextFrame(super); + if ((super->frame & 0x80) || !super->child->next) { + DeleteThisEntity(); + } +} + +void sub_080847BC(SpecialFxObject* this) { + super->z.WORD -= 0x2000; + sub_080845DC(this); +} + +void sub_080847D0(SpecialFxObject* this) { + LinearMoveUpdate(super); + sub_080845DC(this); +} + +void sub_080847E0(SpecialFxObject* this) { + if (gRoomControls.reload_flags == 1) { + DeleteThisEntity(); + } + PositionRelative(&gPlayerEntity, super, 0, -0x30000); + super->z.HALF.HI = -3; + SortEntityAbove(&gPlayerEntity, super); + sub_080845DC(this); +}