diff --git a/asm/object/chestSpawner.s b/asm/object/chestSpawner.s deleted file mode 100644 index 24092230..00000000 --- a/asm/object/chestSpawner.s +++ /dev/null @@ -1,649 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_08083E4C -sub_08083E4C: @ 0x08083E4C - push {r4, lr} - adds r4, r0, #0 - ldr r0, _08083E80 @ =gUnk_0811F8B0 - str r0, [r4, #0x48] - ldrb r0, [r4, #0xb] - bl CheckLocalFlag - cmp r0, #0 - beq _08083E84 - ldrb r1, [r4, #0x18] - movs r0, #4 - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #1 - orrs r0, r1 - strb r0, [r4, #0x18] - movs r0, #5 - strb r0, [r4, #0xc] - adds r0, r4, #0 - bl sub_080842D8 - adds r0, r4, #0 - movs r1, #1 - bl InitializeAnimation - b _08083EAC - .align 2, 0 -_08083E80: .4byte gUnk_0811F8B0 -_08083E84: - adds r0, r4, #0 - adds r0, #0x86 - ldrh r0, [r0] - bl CheckFlags - cmp r0, #0 - bne _08083E98 - ldrb r0, [r4, #0xa] - cmp r0, #4 - bne _08083EA0 -_08083E98: - adds r0, r4, #0 - bl sub_08083E20 - b _08083EA4 -_08083EA0: - movs r0, #1 - strb r0, [r4, #0xc] -_08083EA4: - adds r0, r4, #0 - movs r1, #0 - bl InitializeAnimation -_08083EAC: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_08083EB0 -sub_08083EB0: @ 0x08083EB0 - push {r4, lr} - adds r4, r0, #0 - adds r0, #0x86 - ldrh r0, [r0] - bl CheckFlags - cmp r0, #0 - beq _08083F0A - ldr r1, _08083F0C @ =gScreen - adds r2, r1, #0 - adds r2, #0x66 - movs r3, #0 - movs r0, #0xf4 - lsls r0, r0, #4 - strh r0, [r2] - adds r1, #0x68 - adds r0, #0xc0 - strh r0, [r1] - ldr r1, _08083F10 @ =gUnk_02034490 - movs r2, #1 - movs r0, #1 - strb r0, [r1] - movs r0, #2 - strb r0, [r4, #0xc] - strb r3, [r4, #0xd] - movs r0, #0x1e - strb r0, [r4, #0xf] - ldrb r1, [r4, #0x18] - subs r0, #0x22 - ands r0, r1 - orrs r0, r2 - strb r0, [r4, #0x18] - ldrb r1, [r4, #0x19] - movs r0, #0xd - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #4 - orrs r0, r1 - strb r0, [r4, #0x19] - adds r0, r4, #0 - movs r1, #0x1e - bl RequestPriorityDuration - bl sub_0805BC4C -_08083F0A: - pop {r4, pc} - .align 2, 0 -_08083F0C: .4byte gScreen -_08083F10: .4byte gUnk_02034490 - - thumb_func_start sub_08083F14 -sub_08083F14: @ 0x08083F14 - push {r4, r5, lr} - adds r4, r0, #0 - movs r0, #0x1e - bl SetPriorityTimer - ldrb r0, [r4, #0xd] - cmp r0, #0 - beq _08083F78 - cmp r0, #1 - beq _08083FA4 - adds r0, r4, #0 - bl sub_0800445C - movs r1, #0x2e - ldrsh r0, [r4, r1] - movs r2, #0x32 - ldrsh r1, [r4, r2] - movs r2, #2 - bl CreateMagicSparkles - ldrb r0, [r4, #0xe] - subs r0, #1 - strb r0, [r4, #0xe] - movs r2, #0xff - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08083FE6 - movs r0, #8 - strb r0, [r4, #0xe] - ldrb r0, [r4, #0xf] - adds r0, #1 - strb r0, [r4, #0xf] - ands r2, r0 - ldr r3, _08083F74 @ =gScreen - movs r0, #0x10 - subs r0, r0, r2 - lsls r0, r0, #8 - movs r5, #0xff - lsls r5, r5, #8 - adds r1, r5, #0 - ands r0, r1 - orrs r0, r2 - adds r1, r3, #0 - adds r1, #0x68 - strh r0, [r1] - cmp r0, #0x10 - bne _08083FE6 - b _08083FCC - .align 2, 0 -_08083F74: .4byte gScreen -_08083F78: - ldr r5, _08083FA0 @ =gPlayerEntity - adds r0, r4, #0 - adds r1, r5, #0 - movs r2, #0x10 - movs r3, #8 - bl EntityInRectRadius - cmp r0, #0 - beq _08083F98 - movs r0, #0x10 - movs r1, #0 - movs r2, #0 - bl sub_08078AC0 - movs r0, #0x10 - strb r0, [r5, #0x15] -_08083F98: - movs r0, #1 - strb r0, [r4, #0xd] - b _08083FE6 - .align 2, 0 -_08083FA0: .4byte gPlayerEntity -_08083FA4: - ldrb r0, [r4, #0xa] - cmp r0, #5 - beq _08083FB2 - ldr r0, _08083FC8 @ =gPlayerEntity - ldrb r0, [r0, #0xc] - cmp r0, #1 - bne _08083FE6 -_08083FB2: - movs r1, #0 - movs r0, #2 - strb r0, [r4, #0xd] - movs r0, #8 - strb r0, [r4, #0xe] - strb r1, [r4, #0xf] - movs r0, #0xa5 - lsls r0, r0, #1 - bl SoundReq - b _08083FE6 - .align 2, 0 -_08083FC8: .4byte gPlayerEntity -_08083FCC: - ldr r1, _08083FE8 @ =gUnk_02034490 - movs r0, #0 - strb r0, [r1] - adds r1, r3, #0 - adds r1, #0x66 - movs r0, #0 - strh r0, [r1] - adds r0, r4, #0 - bl sub_08083E20 - movs r0, #0x73 - bl SoundReq -_08083FE6: - pop {r4, r5, pc} - .align 2, 0 -_08083FE8: .4byte gUnk_02034490 - - thumb_func_start sub_08083FEC -sub_08083FEC: @ 0x08083FEC - push {r4, lr} - adds r4, r0, #0 - bl sub_0800445C - adds r0, r4, #0 - adds r0, #0x39 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - beq _0808401E - movs r0, #4 - strb r0, [r4, #0xc] - movs r0, #0x1e - strb r0, [r4, #0xf] - adds r0, r4, #0 - bl sub_080788E0 - adds r0, r4, #0 - movs r1, #0x3c - bl RequestPriorityDuration - ldr r0, _08084020 @ =0x0000011B - bl SoundReq -_0808401E: - pop {r4, pc} - .align 2, 0 -_08084020: .4byte 0x0000011B - - thumb_func_start sub_08084024 -sub_08084024: @ 0x08084024 - push {r4, lr} - adds r4, r0, #0 - bl sub_0800445C - adds r0, r4, #0 - bl GetNextFrame - adds r0, r4, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _08084070 - ldrb r0, [r4, #0xf] - subs r0, #1 - strb r0, [r4, #0xf] - lsls r0, r0, #0x18 - cmp r0, #0 - bne _0808406A - ldrb r0, [r4, #0xe] - cmp r0, #0x18 - bne _08084060 - movs r0, #6 - strb r0, [r4, #0xc] - movs r0, #8 - strb r0, [r4, #0xe] - movs r0, #0x10 - strb r0, [r4, #0xf] - b _0808406A -_08084060: - movs r0, #5 - strb r0, [r4, #0xc] - ldrb r0, [r4, #0xb] - bl sub_08084074 -_0808406A: - ldrb r0, [r4, #0xb] - bl SetLocalFlag -_08084070: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_08084074 -sub_08084074: @ 0x08084074 - push {r4, lr} - adds r4, r0, #0 - movs r0, #3 - bl GetCurrentRoomProperty - adds r1, r0, #0 - cmp r1, #0 - beq _080840A4 - b _0808409E -_08084086: - cmp r0, #3 - bne _0808409C - ldrb r0, [r1, #1] - cmp r4, r0 - bne _0808409C - ldrb r0, [r1, #2] - ldrb r1, [r1, #3] - movs r2, #0 - bl CreateItemEntity - b _080840A4 -_0808409C: - adds r1, #8 -_0808409E: - ldrb r0, [r1] - cmp r0, #0 - bne _08084086 -_080840A4: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_080840A8 -sub_080840A8: @ 0x080840A8 - push {r4, r5, r6, r7, lr} - adds r6, r0, #0 - adds r7, r1, #0 - ldr r4, _0808413C @ =gUnk_0811F838 - bl Random - movs r1, #7 - ands r1, r0 - adds r1, r1, r4 - ldrb r1, [r1] - movs r0, #0 - movs r2, #0 - bl CreateObject - adds r5, r0, #0 - cmp r5, #0 - beq _08084138 - movs r0, #6 - strb r0, [r5, #0xe] - bl Random - movs r1, #7 - ands r0, r1 - adds r0, #0xc - movs r1, #0x80 - orrs r0, r1 - strb r0, [r5, #0x15] - bl Random - movs r1, #0xf - ands r1, r0 - lsls r1, r1, #1 - adds r1, #0x20 - strh r1, [r5, #0x24] - bl Random - ldr r1, _08084140 @ =gUnk_0811F840 - movs r4, #3 - ands r0, r4 - lsls r0, r0, #2 - adds r0, r0, r1 - ldr r0, [r0] - str r0, [r5, #0x20] - bl Random - ldr r1, _08084144 @ =gUnk_0811F850 - ands r0, r4 - adds r0, r0, r1 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - adds r0, r0, r6 - strh r0, [r5, #0x2e] - adds r0, r7, #1 - strh r0, [r5, #0x32] - ldr r0, _08084148 @ =0x0000FFF8 - strh r0, [r5, #0x36] - adds r0, r5, #0 - bl ResolveCollisionLayer - adds r0, r5, #0 - movs r1, #0x11 - movs r2, #0 - bl CreateFx - adds r5, r0, #0 - cmp r5, #0 - beq _08084138 - movs r0, #0x92 - lsls r0, r0, #1 - bl SoundReq -_08084138: - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_0808413C: .4byte gUnk_0811F838 -_08084140: .4byte gUnk_0811F840 -_08084144: .4byte gUnk_0811F850 -_08084148: .4byte 0x0000FFF8 - - thumb_func_start sub_0808414C -sub_0808414C: @ 0x0808414C - push {lr} - adds r1, r0, #0 - ldrb r0, [r1, #0xe] - subs r0, #1 - strb r0, [r1, #0xe] - movs r2, #0xff - lsls r0, r0, #0x18 - cmp r0, #0 - bne _08084180 - movs r0, #8 - strb r0, [r1, #0xe] - ldrb r0, [r1, #0xf] - subs r0, #1 - strb r0, [r1, #0xf] - ands r0, r2 - cmp r0, #0 - beq _0808417C - movs r2, #0x2e - ldrsh r0, [r1, r2] - movs r2, #0x32 - ldrsh r1, [r1, r2] - bl sub_080840A8 - b _08084180 -_0808417C: - movs r0, #5 - strb r0, [r1, #0xc] -_08084180: - pop {pc} - .align 2, 0 - - thumb_func_start sub_08084184 -sub_08084184: @ 0x08084184 - push {lr} - bl sub_0800445C - pop {pc} - - thumb_func_start nullsub_114 -nullsub_114: @ 0x0808418C - bx lr - .align 2, 0 - - thumb_func_start sub_08084190 -sub_08084190: @ 0x08084190 - push {r4, r5, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xc] - adds r0, #1 - strb r0, [r4, #0xc] - movs r0, #0x2e - ldrsh r1, [r4, r0] - ldr r2, _08084204 @ =gRoomControls - ldrh r0, [r2, #6] - subs r1, r1, r0 - asrs r1, r1, #4 - movs r3, #0x3f - ands r1, r3 - movs r5, #0x32 - ldrsh r0, [r4, r5] - ldrh r2, [r2, #8] - subs r0, r0, r2 - asrs r0, r0, #4 - ands r0, r3 - lsls r0, r0, #6 - orrs r1, r0 - adds r5, r4, #0 - adds r5, #0x70 - strh r1, [r5] - ldr r0, _08084208 @ =gUnk_0811F8A8 - str r0, [r4, #0x48] - adds r0, r4, #0 - bl GetTileTypeByEntity - cmp r0, #0x74 - bne _080841D2 - bl DeleteThisEntity -_080841D2: - adds r0, r4, #0 - adds r0, #0x86 - ldrh r0, [r0] - bl CheckFlags - cmp r0, #0 - beq _08084200 - movs r0, #3 - strb r0, [r4, #0xc] - ldrh r1, [r5] - adds r0, r4, #0 - adds r0, #0x38 - ldrb r2, [r0] - movs r0, #0x73 - bl sub_0807B7D8 - ldrb r1, [r4, #0xa] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - bne _08084200 - bl DeleteThisEntity -_08084200: - pop {r4, r5, pc} - .align 2, 0 -_08084204: .4byte gRoomControls -_08084208: .4byte gUnk_0811F8A8 - - thumb_func_start sub_0808420C -sub_0808420C: @ 0x0808420C - push {r4, lr} - adds r4, r0, #0 - adds r0, #0x86 - ldrh r0, [r0] - bl CheckFlags - cmp r0, #0 - beq _08084220 - movs r0, #2 - strb r0, [r4, #0xc] -_08084220: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_08084224 -sub_08084224: @ 0x08084224 - push {r4, lr} - adds r4, r0, #0 - adds r0, #0x70 - ldrh r1, [r0] - subs r0, #0x38 - ldrb r2, [r0] - movs r0, #0x73 - bl sub_0807B7D8 - ldrb r0, [r4, #0xa] - cmp r0, #7 - bgt _0808424C - cmp r0, #6 - blt _0808424C - ldr r0, _08084248 @ =0x00000215 - bl SoundReq - b _08084258 - .align 2, 0 -_08084248: .4byte 0x00000215 -_0808424C: - movs r0, #0x72 - bl SoundReq - adds r0, r4, #0 - bl CreateDust -_08084258: - movs r0, #3 - strb r0, [r4, #0xc] - ldrb r1, [r4, #0xe] - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #2 - adds r1, r4, #0 - adds r1, #0x72 - strh r0, [r1] - ldrb r1, [r4, #0xa] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - bne _08084278 - bl DeleteThisEntity -_08084278: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_0808427C -sub_0808427C: @ 0x0808427C - push {r4, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xa] - cmp r0, #1 - beq _0808428A - cmp r0, #7 - bne _080842D4 -_0808428A: - adds r0, r4, #0 - bl GetTileTypeByEntity - cmp r0, #0x74 - bne _0808429C - adds r0, r4, #0 - bl DeleteEntity - b _080842D4 -_0808429C: - adds r0, r4, #0 - adds r0, #0x86 - ldrh r0, [r0] - bl CheckFlags - cmp r0, #0 - bne _080842D4 - adds r1, r4, #0 - adds r1, #0x72 - ldrh r0, [r1] - cmp r0, #0 - beq _080842BA - subs r0, #1 - strh r0, [r1] - b _080842D4 -_080842BA: - movs r0, #1 - strb r0, [r4, #0xc] - adds r0, r4, #0 - adds r0, #0x70 - ldrh r0, [r0] - adds r1, r4, #0 - adds r1, #0x38 - ldrb r1, [r1] - bl sub_0807BA8C - adds r0, r4, #0 - bl CreateDust -_080842D4: - pop {r4, pc} - .align 2, 0 - - thumb_func_start sub_080842D8 -sub_080842D8: @ 0x080842D8 - push {r4, r5, r6, lr} - adds r5, r0, #0 - ldrh r2, [r5, #0x2e] - movs r1, #8 - adds r0, r1, #0 - ands r0, r2 - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - rsbs r0, r0, #0 - lsrs r2, r0, #0x1f - ldrh r0, [r5, #0x32] - ands r1, r0 - cmp r1, #0 - beq _080842F6 - adds r2, #2 -_080842F6: - ldr r1, _0808432C @ =gUnk_0811F898 - lsls r0, r2, #2 - adds r0, r0, r1 - ldr r0, [r0] - movs r2, #0x2e - ldrsh r1, [r5, r2] - ldr r3, _08084330 @ =gRoomControls - ldrh r2, [r3, #6] - subs r1, r1, r2 - asrs r1, r1, #4 - movs r4, #0x3f - ands r1, r4 - movs r6, #0x32 - ldrsh r2, [r5, r6] - ldrh r3, [r3, #8] - subs r2, r2, r3 - asrs r2, r2, #4 - ands r2, r4 - lsls r2, r2, #6 - orrs r1, r2 - adds r2, r5, #0 - adds r2, #0x38 - ldrb r2, [r2] - bl sub_0801AF18 - pop {r4, r5, r6, pc} - .align 2, 0 -_0808432C: .4byte gUnk_0811F898 -_08084330: .4byte gRoomControls diff --git a/assets/assets.json b/assets/assets.json index b94cde6d..9ae86a88 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -42272,51 +42272,6 @@ "size": 8, "type": "animation" }, - { - "path": "chestSpawner/gUnk_0811F838.bin", - "start": 1177656, - "size": 8 - }, - { - "path": "chestSpawner/gUnk_0811F840.bin", - "start": 1177664, - "size": 16 - }, - { - "path": "chestSpawner/gUnk_0811F850.bin", - "start": 1177680, - "size": 4 - }, - { - "path": "chestSpawner/gUnk_0811F854.bin", - "start": 1177684, - "size": 18 - }, - { - "path": "chestSpawner/gUnk_0811F866.bin", - "start": 1177702, - "size": 26 - }, - { - "path": "chestSpawner/gUnk_0811F880.bin", - "start": 1177728, - "size": 10 - }, - { - "path": "chestSpawner/gUnk_0811F88A.bin", - "start": 1177738, - "size": 14 - }, - { - "path": "chestSpawner/gUnk_0811F8A8.bin", - "start": 1177768, - "size": 8 - }, - { - "path": "chestSpawner/gUnk_0811F8B0.bin", - "start": 1177776, - "size": 8 - }, { "path": "animations/gSpriteAnimations_ObjectD_0.bin", "start": 1177880, diff --git a/data/const/object/chestSpawner.s b/data/const/object/chestSpawner.s deleted file mode 100644 index 2f8ff71e..00000000 --- a/data/const/object/chestSpawner.s +++ /dev/null @@ -1,64 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811F7E8:: @ 0811F7E8 - .4byte sub_08083DF0 - .4byte sub_08083DF0 - .4byte sub_08083E08 - .4byte sub_08083E08 - .4byte sub_08083E08 - .4byte sub_08083E08 - .4byte sub_08083DF0 - .4byte sub_08083DF0 - -gUnk_0811F808:: @ 0811F808 - .4byte sub_08084190 - .4byte sub_0808420C - .4byte sub_08084224 - .4byte sub_0808427C - -gUnk_0811F818:: @ 0811F818 - .4byte sub_08083E4C - .4byte sub_08083EB0 - .4byte sub_08083F14 - .4byte sub_08083FEC - .4byte sub_08084024 - .4byte sub_08084184 - .4byte sub_0808414C - .4byte nullsub_114 - -gUnk_0811F838:: @ 0811F838 - .incbin "chestSpawner/gUnk_0811F838.bin" - -gUnk_0811F840:: @ 0811F840 - .incbin "chestSpawner/gUnk_0811F840.bin" - -gUnk_0811F850:: @ 0811F850 - .incbin "chestSpawner/gUnk_0811F850.bin" - -gUnk_0811F854:: @ 0811F854 - .incbin "chestSpawner/gUnk_0811F854.bin" - -gUnk_0811F866:: @ 0811F866 - .incbin "chestSpawner/gUnk_0811F866.bin" - -gUnk_0811F880:: @ 0811F880 - .incbin "chestSpawner/gUnk_0811F880.bin" - -gUnk_0811F88A:: @ 0811F88A - .incbin "chestSpawner/gUnk_0811F88A.bin" - -gUnk_0811F898:: @ 0811F898 - .4byte gUnk_0811F854 - .4byte gUnk_0811F866 - .4byte gUnk_0811F880 - .4byte gUnk_0811F88A - -gUnk_0811F8A8:: @ 0811F8A8 - .incbin "chestSpawner/gUnk_0811F8A8.bin" - -gUnk_0811F8B0:: @ 0811F8B0 - .incbin "chestSpawner/gUnk_0811F8B0.bin" diff --git a/include/functions.h b/include/functions.h index 64ab6229..ac9efa91 100644 --- a/include/functions.h +++ b/include/functions.h @@ -209,4 +209,12 @@ extern void sub_08027870(Entity*); extern u32 sub_0804A044(Entity*, Entity*, u32); extern void sub_0804AA1C(Entity*); extern void sub_08049CF4(Entity*); +extern void sub_0806FCF4(Entity*, s32, s32, s32); +extern u32 sub_080041DC(Entity*, u32, u32); +extern void sub_080AE58C(Entity*, u32, u32); +extern u32 sub_0800132C(Entity*, Entity*); +extern bool32 sub_080AE4CC(Entity*, u32, u32, u32); +extern void sub_08008796(Entity*, u32, u32, u32); +extern void sub_08078AC0(u32, u32, u32); +extern void CreateMagicSparkles(u32, u32, u32); #endif diff --git a/include/object.h b/include/object.h index b728782f..bd200e9b 100644 --- a/include/object.h +++ b/include/object.h @@ -238,7 +238,7 @@ void LockedDoor(Entity*); void Object9(Entity*); void ObjectA(Entity*); void ObjectB(Entity*); -void ChestSpawner(Entity*); +void ChestSpawner(); void ObjectD(Entity*); void ObjectE(Entity*); void SpecialFx(Entity*); diff --git a/linker.ld b/linker.ld index 55fa9325..16209115 100644 --- a/linker.ld +++ b/linker.ld @@ -656,7 +656,6 @@ SECTIONS { src/object/objectA.o(.text); asm/object/objectB.o(.text); src/object/chestSpawner.o(.text); - asm/object/chestSpawner.o(.text); asm/object/objectD.o(.text); asm/object/objectE.o(.text); src/object/specialFx.o(.text); @@ -1375,7 +1374,7 @@ SECTIONS { data/const/object/object9.o(.rodata); data/animations/object/object9.o(.rodata); data/const/object/objectB.o(.rodata); - data/const/object/chestSpawner.o(.rodata); + src/object/chestSpawner.o(.rodata); data/animations/object/chestSpawner.o(.rodata); data/const/object/objectD.o(.rodata); data/animations/object/objectD.o(.rodata); diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 9198342b..4ae0be4e 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -11,7 +11,6 @@ #include "projectile.h" #include "game.h" -extern void sub_08078AC0(u32, u32, u32); extern u32 GetRandomByWeight(const u8*); extern void sub_080792BC(s32, u32, u32); diff --git a/src/manager/manager3.c b/src/manager/manager3.c index 868a2e13..db0f0237 100644 --- a/src/manager/manager3.c +++ b/src/manager/manager3.c @@ -7,6 +7,7 @@ #include "player.h" #include "sound.h" #include "object.h" +#include "functions.h" // Facilitates the usage of minish portals. @@ -27,7 +28,6 @@ typedef struct { extern s8 gUnk_08107C6C[]; extern u32 sub_08057810(void); extern u32 sub_080002C0(u16, u16, u8); -extern void CreateMagicSparkles(u32, u32, u32); void Manager3_Main(Manager3* this) { s8 tmp; diff --git a/src/npc/npc23.c b/src/npc/npc23.c index 9f64b7bb..a0a0c8bf 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -8,7 +8,6 @@ extern void (*const gUnk_081104C8[])(Entity*); bool32 sub_0806650C(Entity*); -extern void sub_08078AC0(u32, u32, u32); void sub_08066490(Entity*, Entity*); diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index 811817d7..20016663 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -1,31 +1,317 @@ +/** + * @file chestSpawner.c + * @ingroup Objects + * + * @brief Chest Spawner object + */ + +#define NENT_DEPRECATED #include "global.h" -#include "entity.h" +#include "object.h" +#include "functions.h" +#include "screen.h" +#include "structures.h" +#include "item.h" -extern void sub_080842D8(Entity*); -extern void sub_08078828(Entity*); -extern void sub_08083E20(Entity*); +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 tilePosition; + /*0x72*/ u16 unk_72; + /*0x74*/ u8 unk_74[0x12]; + /*0x86*/ u16 unk_86; +} ChestSpawnerEntity; -extern void (*const gUnk_0811F7E8[])(Entity*); -extern void (*const gUnk_0811F808[])(Entity*); -extern void (*const gUnk_0811F818[])(Entity*); +extern const Hitbox gUnk_0811F8A8; +extern const Hitbox gUnk_0811F8B0; -extern u32 gUnk_0811F8B0; -void ChestSpawner(Entity* this) { - gUnk_0811F7E8[this->type](this); +void sub_080842D8(ChestSpawnerEntity*); +void sub_08078828(ChestSpawnerEntity*); +void sub_08083E20(ChestSpawnerEntity*); +void sub_08084074(u32); +void sub_080840A8(s32, s32); +void ChestSpawner_Type0(ChestSpawnerEntity*); +void ChestSpawner_Type2(ChestSpawnerEntity*); +void ChestSpawner_Type0Init(ChestSpawnerEntity*); +void ChestSpawner_Type0Action1(ChestSpawnerEntity*); +void ChestSpawner_Type0Action2(ChestSpawnerEntity*); +void ChestSpawner_Type0Action3(ChestSpawnerEntity*); +void ChestSpawner_Type2Init(ChestSpawnerEntity*); +void ChestSpawner_Type2Action1(ChestSpawnerEntity*); +void ChestSpawner_Type2Action2(ChestSpawnerEntity*); +void ChestSpawner_Type2Action3(ChestSpawnerEntity*); +void ChestSpawner_Type2Action4(ChestSpawnerEntity*); +void ChestSpawner_Type2Action5(ChestSpawnerEntity*); +void ChestSpawner_Type2Action6(ChestSpawnerEntity*); +void ChestSpawner_Type2Action7(ChestSpawnerEntity*); + +void ChestSpawner(ChestSpawnerEntity* this) { + static void (*const ChestSpawner_Types[])(ChestSpawnerEntity*) = { + ChestSpawner_Type0, ChestSpawner_Type0, ChestSpawner_Type2, ChestSpawner_Type2, + ChestSpawner_Type2, ChestSpawner_Type2, ChestSpawner_Type0, ChestSpawner_Type0, + }; + ChestSpawner_Types[super->type](this); } -void sub_08083DF0(Entity* this) { - gUnk_0811F808[this->action](this); +void ChestSpawner_Type0(ChestSpawnerEntity* this) { + static void (*const ChestSpawner_Type0Actions[])(ChestSpawnerEntity*) = { + ChestSpawner_Type0Init, + ChestSpawner_Type0Action1, + ChestSpawner_Type0Action2, + ChestSpawner_Type0Action3, + }; + ChestSpawner_Type0Actions[super->action](this); } -void sub_08083E08(Entity* this) { - gUnk_0811F818[this->action](this); +void ChestSpawner_Type2(ChestSpawnerEntity* this) { + static void (*const ChestSpawner_Type2Actions[])(ChestSpawnerEntity*) = { + ChestSpawner_Type2Init, ChestSpawner_Type2Action1, ChestSpawner_Type2Action2, ChestSpawner_Type2Action3, + ChestSpawner_Type2Action4, ChestSpawner_Type2Action5, ChestSpawner_Type2Action6, ChestSpawner_Type2Action7, + }; + ChestSpawner_Type2Actions[super->action](this); } -void sub_08083E20(Entity* this) { - this->action = 3; - this->spriteSettings.draw = 1; - this->spriteRendering.alphaBlend = 0; +void sub_08083E20(ChestSpawnerEntity* this) { + super->action = 3; + super->spriteSettings.draw = 1; + super->spriteRendering.alphaBlend = 0; sub_080842D8(this); sub_08078828(this); } +void ChestSpawner_Type2Init(ChestSpawnerEntity* this) { + super->hitbox = (Hitbox*)&gUnk_0811F8B0; + if (CheckLocalFlag(super->type2)) { + super->spriteSettings.draw = 1; + super->action = 5; + sub_080842D8(this); + InitializeAnimation(super, 1); + } else { + if (CheckFlags(this->unk_86) || super->type == 4) { + sub_08083E20(this); + } else { + super->action = 1; + } + InitializeAnimation(super, 0); + } +} + +void ChestSpawner_Type2Action1(ChestSpawnerEntity* this) { + if (CheckFlags(this->unk_86)) { + gScreen.controls.layerFXControl = 0xf40; + gScreen.controls.alphaBlend = 0x1000; + gUnk_02034490.unk0 = 1; + super->action = 2; + super->subAction = 0; + super->field_0xf = 0x1e; + super->spriteSettings.draw = 1; + super->spriteRendering.alphaBlend = 1; + RequestPriorityDuration(super, 0x1e); + sub_0805BC4C(); + } +} + +void ChestSpawner_Type2Action2(ChestSpawnerEntity* this) { + u32 tmp; + + SetPriorityTimer(0x1e); + switch (super->subAction) { + case 0: + if (EntityInRectRadius(super, &gPlayerEntity, 0x10, 8)) { + sub_08078AC0(0x10, 0, 0); + gPlayerEntity.direction = 0x10; + } + super->subAction = 1; + break; + case 1: + if ((super->type == 5) || (gPlayerEntity.action == 1)) { + super->subAction = 2; + super->actionDelay = 8; + super->field_0xf = 0; + SoundReq(SFX_14A); + } + break; + default: + sub_0800445C(super); + CreateMagicSparkles(super->x.HALF.HI, super->y.HALF.HI, 2); + if (--super->actionDelay == 0) { + super->actionDelay = 8; + tmp = ++super->field_0xf; + gScreen.controls.alphaBlend = (((0x10 - tmp) * 0x100) & 0xff00) | tmp; + if (gScreen.controls.alphaBlend == 0x10) { + gUnk_02034490.unk0 = 0; + gScreen.controls.layerFXControl = 0; + sub_08083E20(this); + SoundReq(SFX_SECRET_BIG); + } + } + break; + } +} + +void ChestSpawner_Type2Action3(ChestSpawnerEntity* this) { + sub_0800445C(super); + if (super->interactType != 0) { + super->action = 4; + super->field_0xf = 0x1e; + sub_080788E0(super); + RequestPriorityDuration(super, 0x3c); + SoundReq(SFX_CHEST_OPEN); + } +} + +void ChestSpawner_Type2Action4(ChestSpawnerEntity* this) { + sub_0800445C(super); + GetNextFrame(super); + if ((super->frame & 0x80) != 0) { + if (--super->field_0xf == 0) { + if (super->actionDelay == 0x18) { + super->action = 6; + super->actionDelay = 8; + super->field_0xf = 0x10; + } else { + super->action = 5; + sub_08084074(super->type2); + } + } + SetLocalFlag(super->type2); + } +} + +void sub_08084074(u32 param_1) { + u8* arr = (u8*)GetCurrentRoomProperty(3); + if (arr != NULL) { + for (; arr[0] != 0; arr += 8) { + if ((arr[0] == 3) && (param_1 == arr[1])) { + CreateItemEntity(arr[2], arr[3], 0); + return; + } + } + } +} + +void sub_080840A8(s32 param_1, s32 param_2) { + static const u8 gUnk_0811F838[] = { 84, 84, 84, 84, 85, 85, 85, 86 }; + static const s32 gUnk_0811F840[] = { 393216, 458752, 524288, 589824 }; + static const s8 gUnk_0811F850[] = { -6, 0, 0, 6 }; + Entity* obj = CreateObject(GROUND_ITEM, gUnk_0811F838[Random() & 7], 0); + if (obj != NULL) { + obj->actionDelay = 6; + obj->direction = ((Random() & 7) + 0xc) | 0x80; + obj->speed = (Random() & 0xf) * 2 + 0x20; + obj->zVelocity = gUnk_0811F840[Random() & 3]; + obj->x.HALF.HI = gUnk_0811F850[Random() & 3] + param_1; + obj->y.HALF.HI = param_2 + 1; + obj->z.HALF.HI = 0xfff8; + ResolveCollisionLayer(obj); + obj = CreateFx(obj, FX_DASH, 0); + if (obj != NULL) { + SoundReq(SFX_124); + } + } +} + +void ChestSpawner_Type2Action6(ChestSpawnerEntity* this) { + if (--super->actionDelay == 0) { + super->actionDelay = 8; + if (--super->field_0xf != 0) { + sub_080840A8(super->x.HALF.HI, super->y.HALF.HI); + } else { + super->action = 5; + } + } +} + +void ChestSpawner_Type2Action5(ChestSpawnerEntity* this) { + sub_0800445C(super); +} + +void ChestSpawner_Type2Action7(ChestSpawnerEntity* this) { +} + +void ChestSpawner_Type0Init(ChestSpawnerEntity* this) { + super->action++; + this->tilePosition = COORD_TO_TILE(super); + super->hitbox = (Hitbox*)&gUnk_0811F8A8; + if (GetTileTypeByEntity(super) == 0x74) { + DeleteThisEntity(); + } + if (CheckFlags(this->unk_86)) { + super->action = 3; + sub_0807B7D8(0x73, this->tilePosition, super->collisionLayer); + if ((super->type & 1) == 0) { + DeleteThisEntity(); + } + } +} + +void ChestSpawner_Type0Action1(ChestSpawnerEntity* this) { + if (CheckFlags(this->unk_86)) { + super->action = 2; + } +} + +void ChestSpawner_Type0Action2(ChestSpawnerEntity* this) { + sub_0807B7D8(0x73, this->tilePosition, super->collisionLayer); + switch (super->type) { + case 6: + case 7: + SoundReq(SFX_215); + break; + default: + SoundReq(SFX_SECRET); + CreateDust(super); + break; + } + super->action = 3; + this->unk_72 = super->actionDelay * 0x3c; + if ((super->type & 1) == 0) { + DeleteThisEntity(); + } +} + +void ChestSpawner_Type0Action3(ChestSpawnerEntity* this) { + if ((super->type == 1) || (super->type == 7)) { + if (GetTileTypeByEntity(super) == 0x74) { + DeleteEntity(super); + } else { + if (!CheckFlags(this->unk_86)) { + if (this->unk_72 != 0) { + this->unk_72--; + } else { + super->action = 1; + sub_0807BA8C(this->tilePosition, super->collisionLayer); + CreateDust(super); + } + } + } + } +} + +void sub_080842D8(ChestSpawnerEntity* this) { + static const u8 gUnk_0811F854[] = { + 35, 64, 191, 255, 35, 64, 192, 255, 38, 64, 255, 255, 38, 64, 0, 0, 255, 255, + }; + static const u8 gUnk_0811F866[] = { + 39, 64, 191, 255, 35, 64, 192, 255, 40, 64, 193, 255, 41, 64, 255, 255, 38, 64, 0, 0, 42, 64, 1, 0, 255, 255, + }; + static const u8 gUnk_0811F880[] = { + 34, 64, 255, 255, 34, 64, 0, 0, 255, 255, + }; + static const u8 gUnk_0811F88A[] = { + 36, 64, 255, 255, 34, 64, 0, 0, 37, 64, 1, 0, 255, 255, + }; + static const u8* const gUnk_0811F898[] = { + gUnk_0811F854, + gUnk_0811F866, + gUnk_0811F880, + gUnk_0811F88A, + }; + s32 index = -(-(super->x.HALF.HI & 8) >> 0x1f); + if ((super->y.HALF.HI & 8) != 0) { + index += 2; + } + sub_0801AF18((u8*)gUnk_0811F898[index], COORD_TO_TILE(super), super->collisionLayer); +} + +const Hitbox gUnk_0811F8A8 = { 0, -3, { 0, 0, 0, 0 }, 6, 6 }; +const Hitbox gUnk_0811F8B0 = { 0, -3, { 0, 0, 0, 0 }, 12, 6 }; diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 92ba70b8..62d0cb95 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -29,7 +29,6 @@ void sub_0808681C(Entity*); static u8 sub_08086954(Entity*); extern u32 CheckRegionOnScreen(u32, u32, u32, u32); -extern void sub_08078AC0(u32, u32, u32); extern void (*const gUnk_081206B4[])(Entity*); extern Hitbox gUnk_081206AC; // TODO: should be const diff --git a/src/object/jarPortal.c b/src/object/jarPortal.c index a482621d..6be250de 100644 --- a/src/object/jarPortal.c +++ b/src/object/jarPortal.c @@ -5,7 +5,6 @@ extern void (*gUnk_08121488[])(Entity*); extern u32 sub_08057810(void); -extern void CreateMagicSparkles(u32, u32, u32); u32 sub_0808C128(Entity*); void sub_0808C13C(Entity*);