From 803c2388ce23efebab04c86c6d58dc2d24a49dd2 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 10 Oct 2018 12:02:02 -0400 Subject: [PATCH] finish porting field_effect_helpers --- asm/field_effect_helpers.s | 2910 ------------------------------- data/field_effect_helpers.s | 18 +- include/event_object_movement.h | 2 + ld_script.txt | 1 - src/field_effect_helpers.c | 1232 ++++++++++++- 5 files changed, 1223 insertions(+), 2940 deletions(-) delete mode 100644 asm/field_effect_helpers.s diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s deleted file mode 100644 index 050d6b543..000000000 --- a/asm/field_effect_helpers.s +++ /dev/null @@ -1,2910 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8154C60 -sub_8154C60: @ 8154C60 - push {lr} - ldr r2, =gUnknown_085CDC4C - movs r3, 0x2E - ldrsh r1, [r0, r3] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8154C60 - - thumb_func_start sub_8154C7C -sub_8154C7C: @ 8154C7C - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x30] - adds r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x28 - ble _08154C92 - movs r0, 0x1 - strh r0, [r1, 0x2E] -_08154C92: - adds r0, r1, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - pop {r0} - bx r0 - thumb_func_end sub_8154C7C - - thumb_func_start sub_8154CA0 -sub_8154CA0: @ 8154CA0 - push {r4,lr} - adds r4, r0, 0 - adds r3, r4, 0 - adds r3, 0x3E - ldrb r2, [r3] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3] - ldrh r0, [r4, 0x30] - adds r0, 0x1 - strh r0, [r4, 0x30] - ldrb r1, [r3] - lsls r1, 29 - lsrs r1, 31 - adds r0, r4, 0 - bl UpdateEventObjectSpriteVisibility - movs r1, 0x30 - ldrsh r0, [r4, r1] - cmp r0, 0x38 - ble _08154CE4 - ldrh r1, [r4, 0x3C] - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldEffectStop -_08154CE4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8154CA0 - - thumb_func_start sub_8154CEC -sub_8154CEC: @ 8154CEC - push {r4-r6,lr} - ldr r6, =gFieldEffectArguments - ldrb r0, [r6] - ldrb r1, [r6, 0x4] - ldrb r2, [r6, 0x8] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gEventObjects - adds r5, r1, r0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x34] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x40 - beq _08154D76 - ldrb r0, [r5, 0x5] - bl GetEventObjectGraphicsInfo - lsls r3, r4, 4 - adds r3, r4 - lsls r3, 2 - ldr r4, =gSprites - adds r3, r4 - movs r1, 0x3E - adds r1, r3 - mov r12, r1 - ldrb r1, [r1] - movs r2, 0x2 - orrs r1, r2 - mov r2, r12 - strb r1, [r2] - ldrb r2, [r5, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrb r1, [r1, 0x5] - movs r2, 0xC - ands r2, r1 - ldrb r4, [r3, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r4 - orrs r1, r2 - strb r1, [r3, 0x5] - ldr r1, [r6] - strh r1, [r3, 0x2E] - ldr r1, [r6, 0x4] - strh r1, [r3, 0x30] - ldr r1, [r6, 0x8] - strh r1, [r3, 0x32] - ldrh r0, [r0, 0xA] - lsls r0, 16 - asrs r0, 17 - subs r0, 0x4 - strh r0, [r3, 0x26] - movs r0, 0x46 - bl PlaySE -_08154D76: - movs r0, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154CEC - - thumb_func_start sub_8154D90 -sub_8154D90: @ 8154D90 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _08154DC0 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x30] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r4, 0x32] - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - beq _08154DCA -_08154DC0: - adds r0, r4, 0 - movs r1, 0xF - bl FieldEffectStop - b _08154E0A -_08154DCA: - ldr r3, =gSprites - ldr r2, =gEventObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r0, [r0, 0x20] - strh r0, [r4, 0x20] - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r0, [r0, 0x22] - strh r0, [r4, 0x22] - adds r0, r4, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility -_08154E0A: - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8154D90 - - thumb_func_start sub_8154E1C -sub_8154E1C: @ 8154E1C - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0xC - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x38] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08154E78 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - ldr r0, [r4, 0x8] - strh r0, [r2, 0x2E] - movs r0, 0x10 - strh r0, [r2, 0x30] -_08154E78: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154E1C - - thumb_func_start oei_water_drop_tall -oei_water_drop_tall: @ 8154E8C - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x30] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08154EE8 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - ldr r0, [r4, 0x8] - strh r0, [r2, 0x2E] - movs r0, 0xE - strh r0, [r2, 0x30] -_08154EE8: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end oei_water_drop_tall - - thumb_func_start sub_8154EFC -sub_8154EFC: @ 8154EFC - push {r4-r7,lr} - ldr r7, =gFieldEffectArguments - ldrb r0, [r7] - ldrb r1, [r7, 0x4] - ldrb r2, [r7, 0x8] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gEventObjects - adds r6, r1, r0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x34] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x40 - beq _08154F92 - ldrb r0, [r6, 0x5] - bl GetEventObjectGraphicsInfo - adds r4, r0, 0 - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - ldr r3, =gSprites - adds r0, r3 - ldr r1, =sub_8154FB4 - str r1, [r0, 0x1C] - adds r5, r0, 0 - adds r5, 0x3E - ldrb r1, [r5] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r5] - ldrb r2, [r6, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - ldrb r1, [r1, 0x5] - movs r2, 0xC - ands r2, r1 - ldrb r3, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x5] - ldr r1, [r7] - strh r1, [r0, 0x2E] - ldr r1, [r7, 0x4] - strh r1, [r0, 0x30] - ldr r1, [r7, 0x8] - strh r1, [r0, 0x32] - ldr r1, =0x0000ffff - strh r1, [r0, 0x34] - movs r1, 0x1 - negs r1, r1 - strh r1, [r0, 0x36] - ldrh r1, [r4, 0xA] - lsls r1, 16 - asrs r1, 17 - subs r1, 0x4 - strh r1, [r0, 0x26] - movs r1, 0x1 - bl StartSpriteAnim -_08154F92: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154EFC - - thumb_func_start sub_8154FB4 -sub_8154FB4: @ 8154FB4 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x30] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r4, 0x32] - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _08154FEE - ldr r2, =gEventObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r5, r0, r2 - ldrb r0, [r5, 0x2] - lsls r0, 28 - cmp r0, 0 - blt _08154FFC -_08154FEE: - adds r0, r4, 0 - movs r1, 0x22 - bl FieldEffectStop - b _08155046 - .pool -_08154FFC: - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - ldrh r1, [r0, 0x20] - strh r1, [r4, 0x20] - ldrh r1, [r0, 0x22] - strh r1, [r4, 0x22] - adds r0, 0x43 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - ldr r1, [r5, 0x10] - ldr r0, [r4, 0x34] - cmp r1, r0 - beq _08155046 - ldrh r0, [r5, 0x10] - strh r0, [r4, 0x34] - ldrh r0, [r5, 0x12] - strh r0, [r4, 0x36] - adds r0, r4, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - bne _08155046 - movs r0, 0x46 - bl PlaySE -_08155046: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8154FB4 - - thumb_func_start oei_ripples -oei_ripples: @ 8155054 - push {r4,lr} - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x14] - ldr r4, =gFieldEffectArguments - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _081550A0 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x5 - strh r0, [r2, 0x2E] -_081550A0: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end oei_ripples - - thumb_func_start sub_81550B4 -sub_81550B4: @ 81550B4 - push {r4-r6,lr} - ldr r6, =gFieldEffectArguments - ldrb r0, [r6] - ldrb r1, [r6, 0x4] - ldrb r2, [r6, 0x8] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gEventObjects - adds r5, r1, r0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x7C] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08155140 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r4, =gSprites - adds r2, r4 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x5] - movs r1, 0xC - ands r1, r0 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - ldr r0, [r6] - strh r0, [r2, 0x2E] - ldr r0, [r6, 0x4] - strh r0, [r2, 0x30] - ldr r0, [r6, 0x8] - strh r0, [r2, 0x32] - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r0, [r0, 0x20] - strh r0, [r2, 0x34] - ldrb r1, [r5, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrh r0, [r0, 0x22] - strh r0, [r2, 0x36] -_08155140: - movs r0, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81550B4 - - thumb_func_start sub_8155158 -sub_8155158: @ 8155158 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x30] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r4, 0x32] - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _08155192 - ldr r5, =gEventObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r5 - ldrb r0, [r1, 0x2] - lsls r0, 26 - cmp r0, 0 - blt _081551A0 -_08155192: - adds r0, r4, 0 - movs r1, 0x2A - bl FieldEffectStop - b _081551E4 - .pool -_081551A0: - ldrb r0, [r1, 0x5] - bl GetEventObjectGraphicsInfo - mov r1, sp - ldrb r2, [r1] - lsls r1, r2, 3 - adds r1, r2 - lsls r1, 2 - adds r1, r5 - ldrb r2, [r1, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - ldr r2, =gSprites - adds r1, r2 - ldrh r2, [r1, 0x20] - strh r2, [r4, 0x20] - ldrh r0, [r0, 0xA] - lsls r0, 16 - asrs r0, 17 - ldrh r2, [r1, 0x22] - adds r0, r2 - subs r0, 0x8 - strh r0, [r4, 0x22] - adds r1, 0x43 - ldrb r0, [r1] - subs r0, 0x1 - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility -_081551E4: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155158 - - thumb_func_start sub_81551F0 -sub_81551F0: @ 81551F0 - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x44] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08155248 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x13 - strh r0, [r2, 0x2E] -_08155248: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81551F0 - - thumb_func_start sub_815525C -sub_815525C: @ 815525C - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x48] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _081552B4 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x14 - strh r0, [r2, 0x2E] -_081552B4: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_815525C - - thumb_func_start sub_81552C8 -sub_81552C8: @ 81552C8 - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x4C] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08155320 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x15 - strh r0, [r2, 0x2E] -_08155320: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81552C8 - - thumb_func_start sub_8155334 -sub_8155334: @ 8155334 - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x50] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _0815538C - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x16 - strh r0, [r2, 0x2E] -_0815538C: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155334 - - thumb_func_start ash -ash: @ 81553A0 - push {r4,lr} - lsls r2, 16 - lsrs r2, 16 - ldr r4, =gFieldEffectArguments - lsls r0, 16 - asrs r0, 16 - str r0, [r4] - lsls r1, 16 - asrs r1, 16 - str r1, [r4, 0x4] - movs r0, 0x52 - str r0, [r4, 0x8] - movs r0, 0x1 - str r0, [r4, 0xC] - str r2, [r4, 0x10] - lsls r3, 16 - asrs r3, 16 - str r3, [r4, 0x14] - movs r0, 0x7 - bl FieldEffectStart - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ash - - thumb_func_start oei_ash -oei_ash: @ 81553D4 - push {r4,r5,lr} - sub sp, 0x4 - ldr r5, =gFieldEffectArguments - ldrh r1, [r5] - mov r0, sp - strh r1, [r0] - ldrh r0, [r5, 0x4] - mov r4, sp - adds r4, 0x2 - strh r0, [r4] - mov r0, sp - adds r1, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x18] - mov r1, sp - movs r2, 0 - ldrsh r1, [r1, r2] - movs r3, 0 - ldrsh r2, [r4, r3] - ldrb r3, [r5, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _0815544A - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r5, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - ldr r0, [r5] - strh r0, [r2, 0x30] - ldr r0, [r5, 0x4] - strh r0, [r2, 0x32] - ldr r0, [r5, 0x10] - strh r0, [r2, 0x34] - ldr r0, [r5, 0x14] - strh r0, [r2, 0x36] -_0815544A: - movs r0, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end oei_ash - - thumb_func_start sub_8155460 -sub_8155460: @ 8155460 - push {lr} - ldr r2, =gUnknown_085CDC54 - movs r3, 0x2E - ldrsh r1, [r0, r3] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155460 - - thumb_func_start sub_815547C -sub_815547C: @ 815547C - push {lr} - adds r3, r0, 0 - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r2] - subs r2, 0x12 - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - ldrh r0, [r3, 0x36] - subs r0, 0x1 - strh r0, [r3, 0x36] - lsls r0, 16 - cmp r0, 0 - bne _081554A6 - movs r0, 0x1 - strh r0, [r3, 0x2E] -_081554A6: - pop {r0} - bx r0 - thumb_func_end sub_815547C - - thumb_func_start sub_81554AC -sub_81554AC: @ 81554AC - push {r4,lr} - adds r4, r0, 0 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - subs r2, 0x12 - ldrb r1, [r2] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r2, 0x32 - ldrsh r1, [r4, r2] - ldrh r2, [r4, 0x34] - bl MapGridSetMetatileIdAt - movs r1, 0x30 - ldrsh r0, [r4, r1] - movs r2, 0x32 - ldrsh r1, [r4, r2] - bl CurrentMapDrawMetatileAt - ldr r2, =gEventObjects - ldr r0, =gPlayerAvatar - ldrb r1, [r0, 0x5] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - movs r0, 0x2 - strh r0, [r4, 0x2E] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81554AC - - thumb_func_start sub_815550C -sub_815550C: @ 815550C - push {r4,lr} - adds r4, r0, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _0815552C - adds r0, r4, 0 - movs r1, 0x7 - bl FieldEffectStop -_0815552C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_815550C - - thumb_func_start sub_8155534 -sub_8155534: @ 8155534 - push {r4,r5,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x1C] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - movs r3, 0x96 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - adds r5, r0, 0 - cmp r0, 0x40 - beq _0815558E - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - adds r3, r1, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r3] - ldrb r2, [r1, 0x5] - movs r0, 0xF - ands r0, r2 - strb r0, [r1, 0x5] - ldr r0, [r4, 0x8] - strh r0, [r1, 0x32] - ldr r0, =0x0000ffff - strh r0, [r1, 0x34] - movs r0, 0x1 - negs r0, r0 - strh r0, [r1, 0x3A] - strh r0, [r1, 0x3C] -_0815558E: - movs r0, 0x8 - bl FieldEffectActiveListRemove - adds r0, r5, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155534 - - thumb_func_start sub_81555AC -sub_81555AC: @ 81555AC - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - ldr r3, =gSprites - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrh r0, [r2, 0x2E] - movs r3, 0x10 - negs r3, r3 - ands r3, r0 - movs r0, 0xF0 - lsls r0, 20 - ands r0, r1 - lsrs r0, 24 - orrs r0, r3 - strh r0, [r2, 0x2E] - bx lr - .pool - thumb_func_end sub_81555AC - - thumb_func_start sub_81555D8 -sub_81555D8: @ 81555D8 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - ldr r3, =gSprites - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - adds r2, r3 - ldrh r0, [r2, 0x2E] - movs r3, 0xF1 - negs r3, r3 - ands r3, r0 - movs r0, 0xF0 - lsls r0, 20 - ands r0, r1 - lsrs r0, 20 - orrs r3, r0 - strh r3, [r2, 0x2E] - bx lr - .pool - thumb_func_end sub_81555D8 - - thumb_func_start sub_8155604 -sub_8155604: @ 8155604 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - ldr r4, =gSprites - lsls r3, r0, 4 - adds r3, r0 - lsls r3, 2 - adds r3, r4 - ldrh r0, [r3, 0x2E] - ldr r4, =0xfffff0ff - ands r4, r0 - movs r0, 0xF0 - lsls r0, 20 - ands r0, r1 - lsrs r0, 16 - orrs r4, r0 - strh r4, [r3, 0x2E] - strh r2, [r3, 0x30] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155604 - - thumb_func_start sub_8155638 -sub_8155638: @ 8155638 - ldrh r1, [r0, 0x2E] - movs r0, 0xF - ands r0, r1 - bx lr - thumb_func_end sub_8155638 - - thumb_func_start sub_8155640 -sub_8155640: @ 8155640 - ldrh r1, [r0, 0x2E] - movs r0, 0xF0 - ands r0, r1 - lsrs r0, 4 - bx lr - thumb_func_end sub_8155640 - - thumb_func_start sub_815564C -sub_815564C: @ 815564C - ldrh r1, [r0, 0x2E] - movs r0, 0xF0 - lsls r0, 4 - ands r0, r1 - lsrs r0, 8 - bx lr - thumb_func_end sub_815564C - - thumb_func_start sub_8155658 -sub_8155658: @ 8155658 - push {r4-r6,lr} - adds r6, r0, 0 - movs r1, 0x32 - ldrsh r0, [r6, r1] - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - ldr r0, =gEventObjects - adds r4, r0 - ldrb r0, [r4, 0x4] - lsls r5, r0, 4 - adds r5, r0 - lsls r5, 2 - ldr r0, =gSprites - adds r5, r0 - adds r0, r4, 0 - adds r1, r6, 0 - bl sub_81556B0 - adds r0, r4, 0 - adds r1, r6, 0 - bl sub_81556E8 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - bl sub_815577C - ldrb r0, [r5, 0x5] - movs r1, 0xC - ands r1, r0 - ldrb r2, [r6, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r6, 0x5] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155658 - - thumb_func_start sub_81556B0 -sub_81556B0: @ 81556B0 - push {r4,r5,lr} - sub sp, 0xC - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, =gUnknown_085CDC60 - mov r0, sp - movs r2, 0x9 - bl memcpy - adds r0, r4, 0 - bl sub_8155640 - lsls r0, 24 - cmp r0, 0 - bne _081556DC - ldrb r0, [r5, 0x18] - lsrs r0, 4 - add r0, sp - ldrb r1, [r0] - adds r0, r4, 0 - bl StartSpriteAnimIfDifferent -_081556DC: - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81556B0 - - thumb_func_start sub_81556E8 -sub_81556E8: @ 81556E8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r4, r1, 0 - ldrh r2, [r0, 0x10] - mov r1, sp - strh r2, [r1] - ldrh r1, [r0, 0x12] - mov r0, sp - adds r0, 0x2 - strh r1, [r0] - movs r2, 0x26 - ldrsh r3, [r4, r2] - mov r8, r0 - cmp r3, 0 - bne _08155770 - mov r0, sp - movs r5, 0 - ldrsh r2, [r0, r5] - movs r5, 0x3A - ldrsh r0, [r4, r5] - cmp r2, r0 - bne _08155724 - lsls r0, r1, 16 - asrs r0, 16 - movs r5, 0x3C - ldrsh r1, [r4, r5] - cmp r0, r1 - beq _08155770 -_08155724: - strh r3, [r4, 0x38] - strh r2, [r4, 0x3A] - mov r1, r8 - movs r2, 0 - ldrsh r0, [r1, r2] - strh r0, [r4, 0x3C] - movs r5, 0x1 - mov r7, r8 - mov r6, sp -_08155736: - adds r0, r5, 0 - mov r1, sp - adds r2, r7, 0 - bl MoveCoords - movs r1, 0 - ldrsh r0, [r6, r1] - movs r2, 0 - ldrsh r1, [r7, r2] - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0815575C - ldrh r0, [r4, 0x38] - adds r0, 0x1 - strh r0, [r4, 0x38] - b _08155770 -_0815575C: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - ldrh r0, [r4, 0x3A] - strh r0, [r6] - ldrh r0, [r4, 0x3C] - mov r1, r8 - strh r0, [r1] - cmp r5, 0x4 - bls _08155736 -_08155770: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81556E8 - - thumb_func_start sub_815577C -sub_815577C: @ 815577C - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r1, 0 - adds r4, r2, 0 - ldr r1, =gUnknown_085CDC6A - mov r0, sp - movs r2, 0x4 - bl memcpy - adds r0, r4, 0 - bl sub_8155638 - lsls r0, 24 - lsrs r0, 24 - adds r2, r0, 0 - cmp r2, 0 - beq _081557F6 - ldrh r1, [r4, 0x36] - adds r1, 0x1 - strh r1, [r4, 0x36] - movs r3, 0x38 - ldrsh r0, [r4, r3] - lsls r0, 1 - add r0, sp - ldrh r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _081557BC - ldrh r0, [r4, 0x34] - ldrh r1, [r4, 0x26] - adds r0, r1 - strh r0, [r4, 0x26] -_081557BC: - ldrh r1, [r4, 0x36] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _081557CC - ldrh r0, [r4, 0x34] - negs r0, r0 - strh r0, [r4, 0x34] -_081557CC: - cmp r2, 0x2 - beq _081557F6 - adds r0, r4, 0 - bl sub_815564C - lsls r0, 24 - cmp r0, 0 - bne _081557E4 - ldrh r0, [r4, 0x26] - b _081557EA - .pool -_081557E4: - ldrh r0, [r4, 0x26] - ldrh r3, [r4, 0x30] - adds r0, r3 -_081557EA: - strh r0, [r5, 0x26] - ldrh r0, [r5, 0x20] - strh r0, [r4, 0x20] - ldrh r0, [r5, 0x22] - adds r0, 0x8 - strh r0, [r4, 0x22] -_081557F6: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_815577C - - thumb_func_start sub_8155800 -sub_8155800: @ 8155800 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gDummySpriteTemplate - movs r1, 0 - movs r2, 0 - movs r3, 0xFF - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r1, =gSprites - adds r2, r1 - ldr r1, =sub_8155850 - str r1, [r2, 0x1C] - movs r1, 0x3E - adds r1, r2 - mov r12, r1 - ldrb r1, [r1] - movs r3, 0x4 - orrs r1, r3 - mov r3, r12 - strb r1, [r3] - strh r4, [r2, 0x2E] - movs r1, 0x1 - strh r1, [r2, 0x30] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155800 - - thumb_func_start sub_8155850 -sub_8155850: @ 8155850 - push {lr} - adds r2, r0, 0 - movs r0, 0x2E - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r3, r0, r1 - ldrh r1, [r2, 0x32] - adds r0, r1, 0x1 - strh r0, [r2, 0x32] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - bne _08155878 - ldrh r0, [r2, 0x30] - ldrh r1, [r3, 0x26] - adds r0, r1 - strh r0, [r3, 0x26] -_08155878: - ldrh r1, [r2, 0x32] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _08155888 - ldrh r0, [r2, 0x30] - negs r0, r0 - strh r0, [r2, 0x30] -_08155888: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155850 - - thumb_func_start sub_8155890 -sub_8155890: @ 8155890 - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0xC - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x24] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _081558EC - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x5] - ldr r0, [r4, 0x8] - strh r0, [r2, 0x2E] - movs r0, 0xA - strh r0, [r2, 0x30] -_081558EC: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155890 - - thumb_func_start sub_8155900 -sub_8155900: @ 8155900 - push {r4-r7,lr} - ldr r7, =gFieldEffectArguments - ldrb r0, [r7] - ldrb r1, [r7, 0x4] - ldrb r2, [r7, 0x8] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =gEventObjects - adds r6, r1, r0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x74] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x40 - beq _081559A4 - ldrb r0, [r6, 0x5] - bl GetEventObjectGraphicsInfo - adds r5, r0, 0 - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r3] - ldrb r2, [r6, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrb r1, [r1, 0x5] - movs r2, 0xC - ands r2, r1 - ldrb r3, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x5] - ldr r1, [r7] - strh r1, [r0, 0x2E] - ldr r1, [r7, 0x4] - strh r1, [r0, 0x30] - ldr r1, [r7, 0x8] - strh r1, [r0, 0x32] - ldrb r2, [r6, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrh r1, [r1, 0x20] - strh r1, [r0, 0x34] - ldrb r2, [r6, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrh r1, [r1, 0x22] - strh r1, [r0, 0x36] - ldrh r1, [r5, 0xA] - lsls r1, 16 - asrs r1, 17 - subs r1, 0x2 - strh r1, [r0, 0x26] - movs r1, 0x2 - bl SeekSpriteAnim -_081559A4: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155900 - - thumb_func_start sub_81559BC -sub_81559BC: @ 81559BC - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r4, 0x30] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r4, 0x32] - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _081559F6 - ldr r2, =gEventObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - ldrb r0, [r1, 0x2] - lsls r0, 27 - cmp r0, 0 - blt _08155A04 -_081559F6: - adds r0, r4, 0 - movs r1, 0x27 - bl FieldEffectStop - b _08155A76 - .pool -_08155A04: - ldr r2, =gSprites - ldrb r1, [r1, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r5, [r0, 0x22] - ldrh r6, [r0, 0x20] - movs r2, 0x20 - ldrsh r1, [r0, r2] - movs r2, 0x34 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _08155A2C - lsls r0, r5, 16 - asrs r0, 16 - movs r2, 0x36 - ldrsh r1, [r4, r2] - cmp r0, r1 - beq _08155A46 -_08155A2C: - strh r6, [r4, 0x34] - strh r5, [r4, 0x36] - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08155A46 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAnim -_08155A46: - strh r6, [r4, 0x20] - strh r5, [r4, 0x22] - ldr r3, =gSprites - ldr r2, =gEventObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x43 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - adds r0, r4, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility -_08155A76: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81559BC - - thumb_func_start sub_8155A88 -sub_8155A88: @ 8155A88 - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - adds r0, 0x88 - ldr r0, [r0] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - movs r3, 0x52 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08155AD8 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - adds r3, r1, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r3] - ldrb r2, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1, 0x5] -_08155AD8: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155A88 - - thumb_func_start sub_8155AEC -sub_8155AEC: @ 8155AEC - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x2E] - adds r0, 0x80 - movs r1, 0x80 - lsls r1, 1 - ands r0, r1 - strh r0, [r4, 0x2E] - lsls r0, 16 - asrs r0, 24 - ldrh r1, [r4, 0x22] - subs r1, r0 - strh r1, [r4, 0x22] - adds r0, r4, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - ldrh r1, [r4, 0x3E] - ldr r0, =0x00001004 - ands r0, r1 - cmp r0, 0 - beq _08155B20 - adds r0, r4, 0 - movs r1, 0x35 - bl FieldEffectStop -_08155B20: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155AEC - - thumb_func_start sub_8155B2C -sub_8155B2C: @ 8155B2C - push {r4,lr} - ldr r4, =gFieldEffectArguments - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x4 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x58] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08155B8C - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - movs r0, 0x3 - ldrb r1, [r4, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r3, [r2, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r1 - movs r1, 0xF - ands r0, r1 - movs r1, 0x50 - orrs r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x17 - strh r0, [r2, 0x2E] -_08155B8C: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155B2C - - thumb_func_start ShowTreeDisguiseFieldEffect -@ u8 ShowTreeDisguiseFieldEffect() -ShowTreeDisguiseFieldEffect: @ 8155BA0 - push {lr} - movs r0, 0x1C - movs r1, 0x18 - movs r2, 0x4 - bl ShowDisguiseFieldEffect - pop {r1} - bx r1 - thumb_func_end ShowTreeDisguiseFieldEffect - - thumb_func_start ShowMountainDisguiseFieldEffect -@ u8 ShowMountainDisguiseFieldEffect() -ShowMountainDisguiseFieldEffect: @ 8155BB0 - push {lr} - movs r0, 0x1D - movs r1, 0x19 - movs r2, 0x3 - bl ShowDisguiseFieldEffect - pop {r1} - bx r1 - thumb_func_end ShowMountainDisguiseFieldEffect - - thumb_func_start ShowSandDisguiseFieldEffect -@ u8 ShowSandDisguiseFieldEffect() -ShowSandDisguiseFieldEffect: @ 8155BC0 - push {lr} - movs r0, 0x24 - movs r1, 0x1C - movs r2, 0x2 - bl ShowDisguiseFieldEffect - pop {r1} - bx r1 - thumb_func_end ShowSandDisguiseFieldEffect - - thumb_func_start ShowDisguiseFieldEffect -@ u8 ShowDisguiseFieldEffect(u8 fieldEffectId, u8 fieldEffectObjectId, u8 paletteSlot) -ShowDisguiseFieldEffect: @ 8155BD0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 - mov r8, r4 - lsls r1, 24 - lsrs r6, r1, 24 - lsls r2, 24 - lsrs r7, r2, 24 - ldr r5, =gFieldEffectArguments - ldrb r0, [r5] - ldrb r1, [r5, 0x4] - ldrb r2, [r5, 0x8] - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - beq _08155C08 - adds r0, r4, 0 - bl FieldEffectActiveListRemove - movs r0, 0x40 - b _08155C74 - .pool -_08155C08: - ldr r1, =gFieldEffectObjectTemplatePointers - lsls r0, r6, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSpriteAtEnd - mov r1, sp - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _08155C70 - mov r0, sp - ldrb r0, [r0] - lsls r2, r0, 4 - adds r2, r0 - lsls r2, 2 - ldr r0, =gSprites - adds r2, r0 - movs r0, 0x3E - adds r0, r2 - mov r12, r0 - ldrb r3, [r0] - lsls r1, r3, 30 - lsrs r1, 31 - adds r1, 0x1 - movs r0, 0x1 - ands r1, r0 - lsls r1, 1 - movs r0, 0x3 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] - lsls r3, r7, 4 - ldrb r1, [r2, 0x5] - movs r0, 0xF - ands r0, r1 - orrs r0, r3 - strb r0, [r2, 0x5] - mov r0, r8 - strh r0, [r2, 0x30] - ldr r0, [r5] - strh r0, [r2, 0x32] - ldr r0, [r5, 0x4] - strh r0, [r2, 0x34] - ldr r0, [r5, 0x8] - strh r0, [r2, 0x36] -_08155C70: - mov r0, sp - ldrb r0, [r0] -_08155C74: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end ShowDisguiseFieldEffect - - thumb_func_start sub_8155C88 -sub_8155C88: @ 8155C88 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - ldrh r0, [r5, 0x32] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r5, 0x34] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r5, 0x36] - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - beq _08155CB8 - ldrh r1, [r5, 0x30] - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl FieldEffectStop -_08155CB8: - ldr r4, =gEventObjects - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r0, [r0, 0x5] - bl GetEventObjectGraphicsInfo - mov r1, sp - ldrb r2, [r1] - lsls r1, r2, 3 - adds r1, r2 - lsls r1, 2 - adds r1, r4 - ldrb r1, [r1, 0x4] - lsls r2, r1, 4 - adds r2, r1 - lsls r2, 2 - ldr r1, =gSprites - adds r2, r1 - adds r1, r2, 0 - adds r1, 0x3E - ldrb r1, [r1] - movs r3, 0x3E - adds r3, r5 - mov r12, r3 - movs r3, 0x4 - ands r3, r1 - mov r1, r12 - ldrb r4, [r1] - movs r1, 0x5 - negs r1, r1 - ands r1, r4 - orrs r1, r3 - mov r3, r12 - strb r1, [r3] - ldrh r1, [r2, 0x20] - strh r1, [r5, 0x20] - ldrh r0, [r0, 0xA] - lsls r0, 16 - asrs r0, 17 - ldrh r1, [r2, 0x22] - adds r0, r1 - subs r0, 0x10 - strh r0, [r5, 0x22] - adds r2, 0x43 - ldrb r0, [r2] - subs r0, 0x1 - adds r1, r5, 0 - adds r1, 0x43 - strb r0, [r1] - ldrh r1, [r5, 0x2E] - movs r2, 0x2E - ldrsh r0, [r5, r2] - cmp r0, 0x1 - bne _08155D38 - adds r0, r1, 0x1 - strh r0, [r5, 0x2E] - adds r0, r5, 0 - movs r1, 0x1 - bl StartSpriteAnim -_08155D38: - movs r3, 0x2E - ldrsh r0, [r5, r3] - ldrh r2, [r5, 0x2E] - cmp r0, 0x2 - bne _08155D54 - adds r0, r5, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08155D54 - movs r0, 0x1 - strh r0, [r5, 0x3C] -_08155D54: - lsls r0, r2, 16 - asrs r0, 16 - cmp r0, 0x3 - bne _08155D68 - ldrh r1, [r5, 0x30] - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - bl FieldEffectStop -_08155D68: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155C88 - - thumb_func_start sub_8155D78 -sub_8155D78: @ 8155D78 - push {lr} - adds r1, r0, 0 - adds r0, 0x21 - ldrb r0, [r0] - cmp r0, 0x1 - bne _08155D96 - ldr r2, =gSprites - ldrb r1, [r1, 0x1A] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrh r1, [r0, 0x2E] - adds r1, 0x1 - strh r1, [r0, 0x2E] -_08155D96: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155D78 - - thumb_func_start sub_8155DA0 -sub_8155DA0: @ 8155DA0 - push {lr} - adds r2, r0, 0 - adds r2, 0x21 - ldrb r1, [r2] - cmp r1, 0x2 - beq _08155DD6 - cmp r1, 0 - beq _08155DD6 - ldrb r1, [r0, 0x1A] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r1, r0, r1 - movs r3, 0x3C - ldrsh r0, [r1, r3] - cmp r0, 0 - bne _08155DCC - movs r0, 0 - b _08155DD8 - .pool -_08155DCC: - movs r0, 0x2 - strb r0, [r2] - ldrh r0, [r1, 0x2E] - adds r0, 0x1 - strh r0, [r1, 0x2E] -_08155DD6: - movs r0, 0x1 -_08155DD8: - pop {r1} - bx r1 - thumb_func_end sub_8155DA0 - - thumb_func_start sub_8155DDC -sub_8155DDC: @ 8155DDC - push {r4,lr} - ldr r4, =gFieldEffectArguments - ldr r0, [r4] - adds r0, 0x7 - str r0, [r4] - ldr r0, [r4, 0x4] - adds r0, 0x7 - str r0, [r4, 0x4] - adds r1, r4, 0x4 - adds r0, r4, 0 - movs r2, 0x8 - movs r3, 0x8 - bl sub_80930E0 - ldr r0, =gFieldEffectObjectTemplatePointers - adds r0, 0x8C - ldr r0, [r0] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - movs r3, 0x52 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x40 - beq _08155E3C - ldr r0, =gSprites - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - movs r0, 0x3 - ldrb r2, [r4, 0x8] - ands r2, r0 - lsls r2, 2 - ldrb r3, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r1, 0x5] - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x2 - orrs r0, r2 - strb r0, [r1] -_08155E3C: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8155DDC - - thumb_func_start sub_8155E50 -sub_8155E50: @ 8155E50 - push {lr} - adds r2, r0, 0 - movs r1, 0x2E - ldrsh r0, [r2, r1] - cmp r0, 0 - bne _08155E84 - adds r0, r2, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08155E7C - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r3] - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] -_08155E7C: - movs r1, 0x2E - ldrsh r0, [r2, r1] - cmp r0, 0 - beq _08155E9A -_08155E84: - ldrh r0, [r2, 0x30] - adds r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x22 - ble _08155E9A - adds r0, r2, 0 - movs r1, 0x36 - bl FieldEffectStop -_08155E9A: - pop {r0} - bx r0 - thumb_func_end sub_8155E50 - - thumb_func_start sub_8155EA0 -sub_8155EA0: @ 8155EA0 - movs r1, 0 - strh r1, [r0, 0x3A] - strh r1, [r0, 0x3C] - bx lr - thumb_func_end sub_8155EA0 - - thumb_func_start sub_8155EA8 -sub_8155EA8: @ 8155EA8 - push {r4-r6,lr} - adds r5, r0, 0 - movs r6, 0 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0x1 - beq _08155EDE - cmp r0, 0x1 - bgt _08155EC0 - cmp r0, 0 - beq _08155ECA - b _08155F42 -_08155EC0: - cmp r0, 0x2 - beq _08155F06 - cmp r0, 0x3 - beq _08155F1A - b _08155F42 -_08155ECA: - movs r2, 0x3A - ldrsh r0, [r5, r2] - bl sub_809773C - ldrh r1, [r5, 0x24] - adds r0, r1 - strh r0, [r5, 0x24] - movs r2, 0x3A - ldrsh r0, [r5, r2] - b _08155F38 -_08155EDE: - ldrh r0, [r5, 0x3A] - movs r4, 0x47 - subs r0, r4, r0 - lsls r0, 16 - asrs r0, 16 - bl sub_809773C - ldrh r1, [r5, 0x24] - subs r1, r0 - strh r1, [r5, 0x24] - ldrh r0, [r5, 0x3A] - subs r4, r0 - lsls r4, 16 - asrs r4, 16 - adds r0, r4, 0 - bl sub_8097728 - ldrh r2, [r5, 0x26] - adds r0, r2 - b _08155F40 -_08155F06: - movs r1, 0x3A - ldrsh r0, [r5, r1] - bl sub_809773C - ldrh r1, [r5, 0x24] - subs r1, r0 - strh r1, [r5, 0x24] - movs r2, 0x3A - ldrsh r0, [r5, r2] - b _08155F38 -_08155F1A: - ldrh r0, [r5, 0x3A] - movs r4, 0x47 - subs r0, r4, r0 - lsls r0, 16 - asrs r0, 16 - bl sub_809773C - ldrh r2, [r5, 0x24] - adds r0, r2 - strh r0, [r5, 0x24] - ldrh r0, [r5, 0x3A] - subs r4, r0 - lsls r4, 16 - asrs r4, 16 - adds r0, r4, 0 -_08155F38: - bl sub_8097728 - ldrh r1, [r5, 0x26] - adds r0, r1 -_08155F40: - strh r0, [r5, 0x26] -_08155F42: - ldrh r1, [r5, 0x24] - negs r1, r1 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x10 - bl SetGpuReg - ldrh r0, [r5, 0x3A] - adds r0, 0x1 - movs r1, 0 - strh r0, [r5, 0x3A] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x48 - bne _08155F68 - strh r1, [r5, 0x3A] - ldrh r0, [r5, 0x3C] - adds r0, 0x1 - strh r0, [r5, 0x3C] -_08155F68: - movs r2, 0x3C - ldrsh r0, [r5, r2] - cmp r0, 0x4 - bne _08155F76 - strh r1, [r5, 0x26] - strh r1, [r5, 0x24] - movs r6, 0x1 -_08155F76: - adds r0, r6, 0 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8155EA8 - - thumb_func_start sub_8155F80 -sub_8155F80: @ 8155F80 - push {r4-r7,lr} - adds r5, r0, 0 - movs r1, 0x32 - ldrsh r0, [r5, r1] - cmp r0, 0x8 - bls _08155F8E - b _08156156 -_08155F8E: - lsls r0, 2 - ldr r1, =_08155F9C - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08155F9C: - .4byte _08155FC0 - .4byte _08156034 - .4byte _0815606C - .4byte _08156090 - .4byte _081560C0 - .4byte _081560D4 - .4byte _081560E0 - .4byte _0815610E - .4byte _08156120 -_08155FC0: - movs r2, 0x2E - ldrsh r0, [r5, r2] - movs r1, 0x3 - bl __divsi3 - movs r1, 0x78 - subs r1, r0 - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x12 - bl SetGpuReg - movs r3, 0x2E - ldrsh r0, [r5, r3] - cmp r0, 0x60 - bne _08156016 - movs r1, 0 - ldr r4, =0x0600f800 - mov r12, r4 - ldr r0, =0x0000bff4 - adds r7, r0, 0 -_08155FEA: - movs r2, 0xC - lsls r0, r1, 1 - adds r3, r1, 0x1 - lsls r6, r1, 5 - adds r0, r1 - lsls r4, r0, 1 -_08155FF6: - adds r0, r6, r2 - lsls r0, 1 - add r0, r12 - adds r1, r2, r7 - adds r1, r4, r1 - adds r1, 0x1 - strh r1, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x11 - bls _08155FF6 - lsls r0, r3, 24 - lsrs r1, r0, 24 - cmp r1, 0x2 - bls _08155FEA -_08156016: - movs r2, 0x2E - ldrsh r1, [r5, r2] - ldr r0, =0x00000137 - cmp r1, r0 - bgt _08156022 - b _08156156 -_08156022: - movs r1, 0 - movs r0, 0x1 - b _0815611A - .pool -_08156034: - ldr r4, =gSineTable - movs r3, 0x2E - ldrsh r0, [r5, r3] - movs r1, 0x3 - bl __divsi3 - lsls r0, 16 - asrs r0, 15 - adds r0, r4 - ldrh r0, [r0] - lsls r0, 16 - asrs r0, 18 - ldrh r4, [r5, 0x36] - adds r0, r4 - movs r1, 0 - strh r0, [r5, 0x22] - movs r2, 0x2E - ldrsh r0, [r5, r2] - cmp r0, 0xBD - bne _08156156 - movs r0, 0x2 - strh r0, [r5, 0x32] - strh r1, [r5, 0x38] - strh r1, [r5, 0x2E] - b _08156156 - .pool -_0815606C: - movs r3, 0x2E - ldrsh r0, [r5, r3] - cmp r0, 0x3C - bne _0815607E - ldrh r0, [r5, 0x38] - adds r0, 0x1 - movs r1, 0 - strh r0, [r5, 0x38] - strh r1, [r5, 0x2E] -_0815607E: - movs r4, 0x38 - ldrsh r0, [r5, r4] - cmp r0, 0x7 - bne _08156156 - movs r0, 0 - strh r0, [r5, 0x38] - movs r0, 0x3 - strh r0, [r5, 0x32] - b _08156156 -_08156090: - ldrh r2, [r5, 0x26] - movs r0, 0x26 - ldrsh r1, [r5, r0] - adds r3, r2, 0 - cmp r1, 0 - bne _081560A4 - strh r1, [r5, 0x2E] - ldrh r0, [r5, 0x32] - adds r0, 0x1 - strh r0, [r5, 0x32] -_081560A4: - movs r4, 0x2E - ldrsh r0, [r5, r4] - cmp r0, 0x5 - bne _08156156 - movs r0, 0 - strh r0, [r5, 0x2E] - cmp r1, 0 - ble _081560BA - subs r0, r3, 0x1 - strh r0, [r5, 0x26] - b _08156156 -_081560BA: - adds r0, r2, 0x1 - strh r0, [r5, 0x26] - b _08156156 -_081560C0: - movs r1, 0x2E - ldrsh r0, [r5, r1] - cmp r0, 0x3C - bne _08156156 - movs r1, 0 - movs r0, 0x5 - strh r0, [r5, 0x32] - strh r1, [r5, 0x2E] - strh r1, [r5, 0x38] - b _08156156 -_081560D4: - adds r0, r5, 0 - bl sub_8155EA0 - movs r1, 0 - movs r0, 0x6 - b _0815611A -_081560E0: - adds r0, r5, 0 - bl sub_8155EA8 - lsls r0, 24 - cmp r0, 0 - beq _08156156 - movs r1, 0 - strh r1, [r5, 0x2E] - ldrh r0, [r5, 0x38] - adds r0, 0x1 - strh r0, [r5, 0x38] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0x2 - bgt _08156106 - adds r0, r5, 0 - bl sub_8155EA0 - b _08156156 -_08156106: - strh r1, [r5, 0x38] - movs r0, 0x7 - strh r0, [r5, 0x32] - b _08156156 -_0815610E: - movs r2, 0x2E - ldrsh r0, [r5, r2] - cmp r0, 0x1E - bne _08156156 - movs r1, 0 - movs r0, 0x8 -_0815611A: - strh r0, [r5, 0x32] - strh r1, [r5, 0x2E] - b _08156156 -_08156120: - movs r1, 0 - ldr r6, =0x0600f800 - movs r4, 0 -_08156126: - movs r2, 0xC - adds r3, r1, 0x1 - lsls r1, 5 -_0815612C: - adds r0, r1, r2 - lsls r0, 1 - adds r0, r6 - strh r4, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x11 - bls _0815612C - lsls r0, r3, 24 - lsrs r1, r0, 24 - cmp r1, 0xE - bls _08156126 - movs r0, 0x12 - movs r1, 0 - bl SetGpuReg - adds r0, r5, 0 - movs r1, 0x40 - bl FieldEffectStop -_08156156: - movs r3, 0x32 - ldrsh r0, [r5, r3] - cmp r0, 0x1 - bne _08156184 - ldrh r1, [r5, 0x30] - movs r0, 0x7 - ands r0, r1 - adds r2, r1, 0 - cmp r0, 0 - bne _08156172 - ldrh r0, [r5, 0x34] - ldrh r4, [r5, 0x26] - adds r0, r4 - strh r0, [r5, 0x26] -_08156172: - movs r0, 0xF - ands r0, r2 - cmp r0, 0 - bne _08156180 - ldrh r0, [r5, 0x34] - negs r0, r0 - strh r0, [r5, 0x34] -_08156180: - adds r0, r1, 0x1 - strh r0, [r5, 0x30] -_08156184: - ldrh r0, [r5, 0x2E] - adds r0, 0x1 - strh r0, [r5, 0x2E] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8155F80 - - thumb_func_start sub_8156194 -sub_8156194: @ 8156194 - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081561B2 - ldrh r1, [r4, 0x30] - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl FieldEffectStop - b _081561C8 -_081561B2: - adds r0, r4, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - ldrh r0, [r4, 0x2E] - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - movs r2, 0 - bl SetObjectSubpriorityByZCoord -_081561C8: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_8156194 - - thumb_func_start sub_81561D0 -sub_81561D0: @ 81561D0 - push {lr} - adds r2, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081561EE - ldrh r1, [r2, 0x2E] - lsls r1, 24 - lsrs r1, 24 - adds r0, r2, 0 - bl FieldEffectStop - b _081561F6 -_081561EE: - adds r0, r2, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility -_081561F6: - pop {r0} - bx r0 - thumb_func_end sub_81561D0 - - thumb_func_start sub_81561FC -sub_81561FC: @ 81561FC - push {r4-r7,lr} - adds r6, r0, 0 - adds r0, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - adds r1, r6, 0 - bl SetObjectSubpriorityByZCoord - movs r7, 0 -_08156212: - lsls r0, r7, 3 - adds r0, r7 - lsls r0, 2 - ldr r1, =gEventObjects - adds r4, r0, r1 - ldrb r0, [r4] - lsls r0, 31 - cmp r0, 0 - beq _081562B4 - ldrb r0, [r4, 0x5] - bl GetEventObjectGraphicsInfo - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r5, r0, r1 - adds r0, r6, 0 - adds r0, 0x28 - movs r2, 0 - ldrsb r2, [r0, r2] - ldrh r0, [r6, 0x20] - adds r1, r0, r2 - subs r0, r2 - lsls r0, 16 - lsrs r4, r0, 16 - lsls r1, 16 - asrs r1, 16 - movs r0, 0x20 - ldrsh r2, [r5, r0] - cmp r1, r2 - bge _081562B4 - lsls r0, r4, 16 - asrs r0, 16 - cmp r0, r2 - ble _081562B4 - adds r0, r5, 0 - adds r0, 0x29 - movs r3, 0 - ldrsb r3, [r0, r3] - ldrh r2, [r5, 0x22] - adds r2, r3 - ldrh r4, [r5, 0x22] - adds r0, r6, 0 - adds r0, 0x29 - movs r1, 0 - ldrsb r1, [r0, r1] - ldrh r0, [r6, 0x22] - subs r0, r1 - lsls r0, 16 - asrs r0, 16 - adds r3, r0, r3 - lsls r2, 16 - asrs r2, 16 - lsls r3, 16 - asrs r3, 16 - cmp r2, r3 - blt _0815628C - cmp r2, r0 - bge _081562B4 -_0815628C: - lsls r0, r4, 16 - asrs r0, 16 - cmp r0, r3 - ble _081562B4 - adds r2, r6, 0 - adds r2, 0x43 - adds r0, r5, 0 - adds r0, 0x43 - ldrb r1, [r0] - ldrb r0, [r2] - cmp r0, r1 - bhi _081562B4 - adds r0, r1, 0x2 - strb r0, [r2] - b _081562BE - .pool -_081562B4: - adds r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0xF - bls _08156212 -_081562BE: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81561FC - - .align 2, 0 @ Don't pad with nop. diff --git a/data/field_effect_helpers.s b/data/field_effect_helpers.s index a1edac00c..e49592659 100644 --- a/data/field_effect_helpers.s +++ b/data/field_effect_helpers.s @@ -3,23 +3,9 @@ .section .rodata - .align 2 - -gUnknown_085CDC4C:: @ 85CDC4C - .4byte sub_8154C7C - .4byte sub_8154CA0 - -gUnknown_085CDC54:: @ 85CDC54 - .4byte sub_815547C - .4byte sub_81554AC - .4byte sub_815550C - -gUnknown_085CDC60:: @ 85CDC60 - .byte 0, 0, 1, 2, 3, 0, 0, 1, 1 - .byte 0 + .align 1 -gUnknown_085CDC6A:: @ 85CDC6A - .2byte 3, 7 +gUnknown_085CDC6E:: @ 85CDC6E @the following might be unref, not sure .byte 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00 diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 97c41a519..80b9f3fc0 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -192,6 +192,8 @@ u8 GetLedgeJumpDirection(s16, s16, u8); void CameraObjectSetFollowedObjectId(u8 objectId); u16 GetObjectPaletteTag(u8 palSlot); void UpdateEventObjectSpriteVisibility(struct Sprite *sprite, bool8 invisible); +s16 sub_809773C(s16 a1); +s16 sub_8097728(s16 a1); void MovementType_None(struct Sprite *); void MovementType_LookAround(struct Sprite *); diff --git a/ld_script.txt b/ld_script.txt index 15932d96c..90bb3694c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -202,7 +202,6 @@ SECTIONS { src/save.o(.text); src/mystery_event_script.o(.text); src/field_effect_helpers.o(.text); - asm/field_effect_helpers.o(.text); src/contest_ai.o(.text); src/battle_anim_sound_tasks.o(.text); src/battle_controller_safari.o(.text); diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 37ff63258..304f7a6f9 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -9,25 +9,25 @@ #include "field_effect.h" #include "field_effect_helpers.h" #include "constants/songs.h" +#include "gpu_regs.h" +#include "trig.h" void objc_reflection_maybe(struct Sprite *); void npc_pal_op(struct EventObject *eventObject, struct Sprite *sprite); void npc_pal_op_A(struct EventObject *, u8); void npc_pal_op_B(struct EventObject *, u8); void sub_81561FC(struct Sprite *, u8, u8); - -/* -static void FadeFootprintsTireTracks_Step0(struct Sprite *); -static void FadeFootprintsTireTracks_Step1(struct Sprite *); -static void UpdateAshFieldEffect_Step0(struct Sprite *); -static void UpdateAshFieldEffect_Step1(struct Sprite *); -static void UpdateAshFieldEffect_Step2(struct Sprite *); -static void UpdateFeetInFlowingWaterFieldEffect(struct Sprite *); -static void sub_8127FD4(struct EventObject *, struct Sprite *); -static void sub_812800C(struct EventObject *, struct Sprite *); -static void sub_81280A0(struct EventObject *, struct Sprite *, struct Sprite *); -static void sub_8128174(struct Sprite *); -static u32 ShowDisguiseFieldEffect(u8, u8, u8); */ +void sub_8154C7C(struct Sprite *); +void sub_8154CA0(struct Sprite *); +void sub_8154FB4(struct Sprite *); +void sub_815547C(struct Sprite *); +void sub_81554AC(struct Sprite *); +void sub_815550C(struct Sprite *); +void sub_81556B0(struct EventObject *, struct Sprite *); +void sub_81556E8(struct EventObject *, struct Sprite *); +void sub_815577C(struct EventObject *, struct Sprite *, struct Sprite *); +void sub_8155850(struct Sprite *); +u32 ShowDisguiseFieldEffect(u8, u8, u8); void SetUpReflection(struct EventObject *eventObject, struct Sprite *sprite, bool8 stillReflection) { @@ -566,3 +566,1209 @@ u32 sub_8154BEC(void) } return spriteId; } + +void (*const gFadeFootprintsTireTracksFuncs[])(struct Sprite *) = { + sub_8154C7C, + sub_8154CA0 +}; + +void sub_8154C60(struct Sprite *sprite) +{ + gFadeFootprintsTireTracksFuncs[sprite->data[0]](sprite); +} + +void sub_8154C7C(struct Sprite *sprite) +{ + // Wait 40 frames before the flickering starts. + if (++sprite->data[1] > 40) + sprite->data[0] = 1; + + UpdateEventObjectSpriteVisibility(sprite, FALSE); +} + +void sub_8154CA0(struct Sprite *sprite) +{ + sprite->invisible ^= 1; + sprite->data[1]++; + UpdateEventObjectSpriteVisibility(sprite, sprite->invisible); + if (sprite->data[1] > 56) + { + FieldEffectStop(sprite, sprite->data[7]); + } +} + +u32 sub_8154CEC(void) +{ + u8 eventObjectId; + struct EventObject *eventObject; + u8 spriteId; + struct Sprite *sprite; + const struct EventObjectGraphicsInfo *graphicsInfo; + struct Sprite *linkedSprite; + + eventObjectId = GetEventObjectIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + eventObject = &gEventObjects[eventObjectId]; + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[13], 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + linkedSprite = &gSprites[eventObject->spriteId]; + sprite->oam.priority = linkedSprite->oam.priority; + sprite->data[0] = gFieldEffectArguments[0]; + sprite->data[1] = gFieldEffectArguments[1]; + sprite->data[2] = gFieldEffectArguments[2]; + sprite->pos2.y = (graphicsInfo->height >> 1) - 4; + PlaySE(SE_MIZU); + } + return 0; +} + +void sub_8154D90(struct Sprite *sprite) +{ + u8 eventObjectId; + + if (sprite->animEnded || TryGetEventObjectIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &eventObjectId)) + { + FieldEffectStop(sprite, FLDEFF_SPLASH); + } + else + { + sprite->pos1.x = gSprites[gEventObjects[eventObjectId].spriteId].pos1.x; + sprite->pos1.y = gSprites[gEventObjects[eventObjectId].spriteId].pos1.y; + UpdateEventObjectSpriteVisibility(sprite, FALSE); + } +} + +u32 sub_8154E1C(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[14], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = gFieldEffectArguments[2]; + sprite->data[1] = FLDEFF_JUMP_SMALL_SPLASH; + } + return 0; +} + +u32 oei_water_drop_tall(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[12], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = gFieldEffectArguments[2]; + sprite->data[1] = FLDEFF_JUMP_BIG_SPLASH; + } + return 0; +} + +u32 sub_8154EFC(void) +{ + u8 eventObjectId; + struct EventObject *eventObject; + u8 spriteId; + struct Sprite *sprite; + const struct EventObjectGraphicsInfo *graphicsInfo; + + eventObjectId = GetEventObjectIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + eventObject = &gEventObjects[eventObjectId]; + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[13], 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + sprite = &gSprites[spriteId]; + sprite->callback = sub_8154FB4; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gSprites[eventObject->spriteId].oam.priority; + sprite->data[0] = gFieldEffectArguments[0]; + sprite->data[1] = gFieldEffectArguments[1]; + sprite->data[2] = gFieldEffectArguments[2]; + sprite->data[3] = -1; + sprite->data[4] = -1; + sprite->pos2.y = (graphicsInfo->height >> 1) - 4; + StartSpriteAnim(sprite, 1); + } + return 0; +} + +void sub_8154FB4(struct Sprite *sprite) +{ + u8 eventObjectId; + struct Sprite *linkedSprite; + struct EventObject *eventObject; + + if (TryGetEventObjectIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &eventObjectId) || !gEventObjects[eventObjectId].inShallowFlowingWater) + { + FieldEffectStop(sprite, FLDEFF_FEET_IN_FLOWING_WATER); + } + else + { + eventObject = &gEventObjects[eventObjectId]; + linkedSprite = &gSprites[eventObject->spriteId]; + sprite->pos1.x = linkedSprite->pos1.x; + sprite->pos1.y = linkedSprite->pos1.y; + sprite->subpriority = linkedSprite->subpriority; + UpdateEventObjectSpriteVisibility(sprite, FALSE); + if (eventObject->currentCoords.x != sprite->data[3] || eventObject->currentCoords.y != sprite->data[4]) + { + sprite->data[3] = eventObject->currentCoords.x; + sprite->data[4] = eventObject->currentCoords.y; + if (!sprite->invisible) + { + PlaySE(SE_MIZU); + } + } + } +} + +u32 oei_ripples(void) +{ + u8 spriteId; + struct Sprite *sprite; + + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[5], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = FLDEFF_RIPPLE; + } + return 0; +} + +u32 sub_81550B4(void) +{ + u8 eventObjectId; + struct EventObject *eventObject; + u8 spriteId; + struct Sprite *sprite; + + eventObjectId = GetEventObjectIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + eventObject = &gEventObjects[eventObjectId]; + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[31], 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gSprites[eventObject->spriteId].oam.priority; + sprite->data[0] = gFieldEffectArguments[0]; + sprite->data[1] = gFieldEffectArguments[1]; + sprite->data[2] = gFieldEffectArguments[2]; + sprite->data[3] = gSprites[eventObject->spriteId].pos1.x; + sprite->data[4] = gSprites[eventObject->spriteId].pos1.y; + } + return 0; +} + +void sub_8155158(struct Sprite *sprite) +{ + u8 eventObjectId; + const struct EventObjectGraphicsInfo *graphicsInfo; + struct Sprite *linkedSprite; + + if (TryGetEventObjectIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &eventObjectId) || !gEventObjects[eventObjectId].inHotSprings) + { + FieldEffectStop(sprite, FLDEFF_HOT_SPRINGS_WATER); + } + else + { + graphicsInfo = GetEventObjectGraphicsInfo(gEventObjects[eventObjectId].graphicsId); + linkedSprite = &gSprites[gEventObjects[eventObjectId].spriteId]; + sprite->pos1.x = linkedSprite->pos1.x; + sprite->pos1.y = (graphicsInfo->height >> 1) + linkedSprite->pos1.y - 8; + sprite->subpriority = linkedSprite->subpriority - 1; + UpdateEventObjectSpriteVisibility(sprite, FALSE); + } +} + +u32 sub_81551F0(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[17], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = FLDEFF_UNKNOWN_19; + } + return 0; +} + +u32 sub_815525C(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[18], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = FLDEFF_UNKNOWN_20; + } + return 0; +} + +u32 sub_81552C8(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[19], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = FLDEFF_UNKNOWN_21; + } + return 0; +} + +u32 sub_8155334(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[20], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = FLDEFF_UNKNOWN_22; + } + return 0; +} + +void ash(s16 x, s16 y, u16 c, s16 d) +{ + gFieldEffectArguments[0] = x; + gFieldEffectArguments[1] = y; + gFieldEffectArguments[2] = 0x52; + gFieldEffectArguments[3] = 1; + gFieldEffectArguments[4] = c; + gFieldEffectArguments[5] = d; + FieldEffectStart(FLDEFF_ASH); +} + +u32 oei_ash(void) +{ + s16 x; + s16 y; + u8 spriteId; + struct Sprite *sprite; + + x = gFieldEffectArguments[0]; + y = gFieldEffectArguments[1]; + sub_80930E0(&x, &y, 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[6], x, y, gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[1] = gFieldEffectArguments[0]; + sprite->data[2] = gFieldEffectArguments[1]; + sprite->data[3] = gFieldEffectArguments[4]; + sprite->data[4] = gFieldEffectArguments[5]; + } + return 0; +} + +void (*const gAshFieldEffectFuncs[])(struct Sprite *) = { + sub_815547C, + sub_81554AC, + sub_815550C +}; + +void sub_8155460(struct Sprite *sprite) +{ + gAshFieldEffectFuncs[sprite->data[0]](sprite); +} + +void sub_815547C(struct Sprite *sprite) +{ + sprite->invisible = TRUE; + sprite->animPaused = TRUE; + if (--sprite->data[4] == 0) + sprite->data[0] = 1; +} + +void sub_81554AC(struct Sprite *sprite) +{ + sprite->invisible = FALSE; + sprite->animPaused = FALSE; + MapGridSetMetatileIdAt(sprite->data[1], sprite->data[2], sprite->data[3]); + CurrentMapDrawMetatileAt(sprite->data[1], sprite->data[2]); + gEventObjects[gPlayerAvatar.eventObjectId].triggerGroundEffectsOnMove = TRUE; + sprite->data[0] = 2; +} + +void sub_815550C(struct Sprite *sprite) +{ + UpdateEventObjectSpriteVisibility(sprite, FALSE); + if (sprite->animEnded) + FieldEffectStop(sprite, FLDEFF_ASH); +} + +u32 sub_8155534(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[7], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x96); + if (spriteId !=MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.paletteNum = 0; + sprite->data[2] = gFieldEffectArguments[2]; + sprite->data[3] = -1; + sprite->data[6] = -1; + sprite->data[7] = -1; + } + FieldEffectActiveListRemove(FLDEFF_SURF_BLOB); + return spriteId; +} + +void sub_81555AC(u8 spriteId, u8 value) +{ + gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF) | (value & 0xF); +} + +void sub_81555D8(u8 spriteId, u8 value) +{ + gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF0) | ((value & 0xF) << 4); +} + +void sub_8155604(u8 spriteId, u8 value, s16 data1) +{ + gSprites[spriteId].data[0] = (gSprites[spriteId].data[0] & ~0xF00) | ((value & 0xF) << 8); + gSprites[spriteId].data[1] = data1; +} + +u8 sub_8155638(struct Sprite *sprite) +{ + return sprite->data[0] & 0xF; +} + +u8 sub_8155640(struct Sprite *sprite) +{ + return (sprite->data[0] & 0xF0) >> 4; +} + +u8 sub_815564C(struct Sprite *sprite) +{ + return (sprite->data[0] & 0xF00) >> 8; +} + +void sub_8155658(struct Sprite *sprite) +{ + struct EventObject *eventObject; + struct Sprite *linkedSprite; + + eventObject = &gEventObjects[sprite->data[2]]; + linkedSprite = &gSprites[eventObject->spriteId]; + sub_81556B0(eventObject, sprite); + sub_81556E8(eventObject, sprite); + sub_815577C(eventObject, linkedSprite, sprite); + sprite->oam.priority = linkedSprite->oam.priority; +} + +void sub_81556B0(struct EventObject *eventObject, struct Sprite *sprite) +{ + u8 surfBlobDirectionAnims[] = { + 0, // DIR_NONE + 0, // DIR_SOUTH + 1, // DIR_NORTH + 2, // DIR_WEST + 3, // DIR_EAST + 0, + 0, + 1, + 1, + }; + + if (sub_8155640(sprite) == 0) + StartSpriteAnimIfDifferent(sprite, surfBlobDirectionAnims[eventObject->movementDirection]); +} + +#ifdef NONMATCHING +void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite) +{ + s16 x; + s16 y; + u8 i; + + x = eventObject->currentCoords.x; + y = eventObject->currentCoords.y; + if (sprite->pos2.y == 0 && (x != sprite->data[6] || y != sprite->data[7])) + { + sprite->data[5] = sprite->pos2.y; + for (sprite->data[6] = x, sprite->data[7] = y, i = DIR_SOUTH; i <= DIR_EAST; i ++, x = sprite->data[6], y = sprite->data[7]) + { + MoveCoords(i, &x, &y); + if (MapGridGetZCoordAt(x, y) == 3) + { + sprite->data[5] ++; + break; + } + } + } +} +#else +NAKED void sub_81556E8(struct EventObject *eventObject, struct Sprite *sprite) +{ + asm_unified("push {r4-r7,lr}\n\ + mov r7, r8\n\ + push {r7}\n\ + sub sp, 0x4\n\ + adds r4, r1, 0\n\ + ldrh r2, [r0, 0x10]\n\ + mov r1, sp\n\ + strh r2, [r1]\n\ + ldrh r1, [r0, 0x12]\n\ + mov r0, sp\n\ + adds r0, 0x2\n\ + strh r1, [r0]\n\ + movs r2, 0x26\n\ + ldrsh r3, [r4, r2]\n\ + mov r8, r0\n\ + cmp r3, 0\n\ + bne _08155770\n\ + mov r0, sp\n\ + movs r5, 0\n\ + ldrsh r2, [r0, r5]\n\ + movs r5, 0x3A\n\ + ldrsh r0, [r4, r5]\n\ + cmp r2, r0\n\ + bne _08155724\n\ + lsls r0, r1, 16\n\ + asrs r0, 16\n\ + movs r5, 0x3C\n\ + ldrsh r1, [r4, r5]\n\ + cmp r0, r1\n\ + beq _08155770\n\ +_08155724:\n\ + strh r3, [r4, 0x38]\n\ + strh r2, [r4, 0x3A]\n\ + mov r1, r8\n\ + movs r2, 0\n\ + ldrsh r0, [r1, r2]\n\ + strh r0, [r4, 0x3C]\n\ + movs r5, 0x1\n\ + mov r7, r8\n\ + mov r6, sp\n\ +_08155736:\n\ + adds r0, r5, 0\n\ + mov r1, sp\n\ + adds r2, r7, 0\n\ + bl MoveCoords\n\ + movs r1, 0\n\ + ldrsh r0, [r6, r1]\n\ + movs r2, 0\n\ + ldrsh r1, [r7, r2]\n\ + bl MapGridGetZCoordAt\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + cmp r0, 0x3\n\ + bne _0815575C\n\ + ldrh r0, [r4, 0x38]\n\ + adds r0, 0x1\n\ + strh r0, [r4, 0x38]\n\ + b _08155770\n\ +_0815575C:\n\ + adds r0, r5, 0x1\n\ + lsls r0, 24\n\ + lsrs r5, r0, 24\n\ + ldrh r0, [r4, 0x3A]\n\ + strh r0, [r6]\n\ + ldrh r0, [r4, 0x3C]\n\ + mov r1, r8\n\ + strh r0, [r1]\n\ + cmp r5, 0x4\n\ + bls _08155736\n\ +_08155770:\n\ + add sp, 0x4\n\ + pop {r3}\n\ + mov r8, r3\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); +} +#endif + +void sub_815577C(struct EventObject *eventObject, struct Sprite *linkedSprite, struct Sprite *sprite) +{ + u16 unk_085CDC6A[] = {3, 7}; + u8 v0 = sub_8155638(sprite); + if (v0 != 0) + { + if (((u16)(++ sprite->data[4]) & unk_085CDC6A[sprite->data[5]]) == 0) + { + sprite->pos2.y += sprite->data[3]; + } + if ((sprite->data[4] & 0x0F) == 0) + { + sprite->data[3] = -sprite->data[3]; + } + if (v0 != 2) + { + if (sub_815564C(sprite) == 0) + linkedSprite->pos2.y = sprite->pos2.y; + else + linkedSprite->pos2.y = sprite->data[1] + sprite->pos2.y; + sprite->pos1.x = linkedSprite->pos1.x; + sprite->pos1.y = linkedSprite->pos1.y + 8; + } + } +} + +u8 sub_8155800(u8 oldSpriteId) +{ + u8 spriteId; + struct Sprite *sprite; + + spriteId = CreateSpriteAtEnd(&gDummySpriteTemplate, 0, 0, -1); + sprite = &gSprites[spriteId]; + sprite->callback = sub_8155850; + sprite->invisible = TRUE; + sprite->data[0] = oldSpriteId; + sprite->data[1] = 1; + return spriteId; +} + +void sub_8155850(struct Sprite *sprite) +{ + struct Sprite *oldSprite; + + oldSprite = &gSprites[sprite->data[0]]; + if (((sprite->data[2]++) & 0x03) == 0) + { + oldSprite->pos2.y += sprite->data[1]; + } + if ((sprite->data[2] & 0x0F) == 0) + { + sprite->data[1] = -sprite->data[1]; + } +} + +u32 sub_8155890(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[9], gFieldEffectArguments[0], gFieldEffectArguments[1], 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = gFieldEffectArguments[2]; + sprite->data[1] = 10; + } + return 0; +} + +u32 sub_8155900(void) +{ + u8 eventObjectId; + struct EventObject *eventObject; + u8 spriteId; + struct Sprite *sprite; + const struct EventObjectGraphicsInfo *graphicsInfo; + + eventObjectId = GetEventObjectIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + eventObject = &gEventObjects[eventObjectId]; + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[29], 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gSprites[eventObject->spriteId].oam.priority; + sprite->data[0] = gFieldEffectArguments[0]; + sprite->data[1] = gFieldEffectArguments[1]; + sprite->data[2] = gFieldEffectArguments[2]; + sprite->data[3] = gSprites[eventObject->spriteId].pos1.x; + sprite->data[4] = gSprites[eventObject->spriteId].pos1.y; + sprite->pos2.y = (graphicsInfo->height >> 1) - 2; + SeekSpriteAnim(sprite, 2); + } + return 0; +} + +void sub_81559BC(struct Sprite *sprite) +{ + u8 eventObjectId; + s16 x; + s16 y; + + if (TryGetEventObjectIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &eventObjectId) || !gEventObjects[eventObjectId].inSandPile) + { + FieldEffectStop(sprite, FLDEFF_SAND_PILE); + } + else + { + y = gSprites[gEventObjects[eventObjectId].spriteId].pos1.y; + x = gSprites[gEventObjects[eventObjectId].spriteId].pos1.x; + if (x != sprite->data[3] || y != sprite->data[4]) + { + sprite->data[3] = x; + sprite->data[4] = y; + if (sprite->animEnded) + { + StartSpriteAnim(sprite, 0); + } + } + sprite->pos1.x = x; + sprite->pos1.y = y; + sprite->subpriority = gSprites[gEventObjects[eventObjectId].spriteId].subpriority; + UpdateEventObjectSpriteVisibility(sprite, FALSE); + } +} + +u32 sub_8155A88(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 0); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[34], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = 1; + } + return 0; +} + +void sub_8155AEC(struct Sprite *sprite) +{ + sprite->data[0] += 0x80; + sprite->data[0] &= 0x100; + sprite->pos1.y -= sprite->data[0] >> 8; + UpdateEventObjectSpriteVisibility(sprite, FALSE); + if (sprite->invisible || sprite->animEnded) + { + FieldEffectStop(sprite, FLDEFF_BUBBLES); + } +} + +u32 sub_8155B2C(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 4); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[22], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->oam.paletteNum = 5; + sprite->data[0] = FLDEFF_BERRY_TREE_GROWTH_SPARKLE; + } + return 0; +} + +u32 ShowTreeDisguiseFieldEffect(void) +{ + return ShowDisguiseFieldEffect(FLDEFF_TREE_DISGUISE, 24, 4); +} + + +u32 ShowMountainDisguiseFieldEffect(void) +{ + return ShowDisguiseFieldEffect(FLDEFF_MOUNTAIN_DISGUISE, 25, 3); +} + + +u32 ShowSandDisguiseFieldEffect(void) +{ + return ShowDisguiseFieldEffect(FLDEFF_SAND_DISGUISE, 28, 2); +} + +u32 ShowDisguiseFieldEffect(u8 fldEff, u8 templateIdx, u8 paletteNum) +{ + u8 spriteId; + struct Sprite *sprite; + + if (TryGetEventObjectIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2], &spriteId)) + { + FieldEffectActiveListRemove(fldEff); + return MAX_SPRITES; + } + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[templateIdx], 0, 0, 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled ++; + sprite->oam.paletteNum = paletteNum; + sprite->data[1] = fldEff; + sprite->data[2] = gFieldEffectArguments[0]; + sprite->data[3] = gFieldEffectArguments[1]; + sprite->data[4] = gFieldEffectArguments[2]; + } + return spriteId; +} + +void sub_8155C88(struct Sprite *sprite) +{ + u8 eventObjectId; + const struct EventObjectGraphicsInfo *graphicsInfo; + struct Sprite *linkedSprite; + + if (TryGetEventObjectIdByLocalIdAndMap(sprite->data[2], sprite->data[3], sprite->data[4], &eventObjectId)) + { + FieldEffectStop(sprite, sprite->data[1]); + } + + graphicsInfo = GetEventObjectGraphicsInfo(gEventObjects[eventObjectId].graphicsId); + linkedSprite = &gSprites[gEventObjects[eventObjectId].spriteId]; + sprite->invisible = linkedSprite->invisible; + sprite->pos1.x = linkedSprite->pos1.x; + sprite->pos1.y = (graphicsInfo->height >> 1) + linkedSprite->pos1.y - 16; + sprite->subpriority = linkedSprite->subpriority - 1; + if (sprite->data[0] == 1) + { + sprite->data[0] ++; + StartSpriteAnim(sprite, 1); + } + if (sprite->data[0] == 2 && sprite->animEnded) + { + sprite->data[7] = 1; + } + if (sprite->data[0] == 3) + { + FieldEffectStop(sprite, sprite->data[1]); + } +} + +void sub_8155D78(struct EventObject *eventObject) +{ + if (eventObject->directionSequenceIndex == 1) + { + gSprites[eventObject->fieldEffectSpriteId].data[0]++; + } +} + +bool8 sub_8155DA0(struct EventObject *eventObject) +{ + struct Sprite *sprite; + + if (eventObject->directionSequenceIndex == 2) + { + return TRUE; + } + if (eventObject->directionSequenceIndex == 0) + { + return TRUE; + } + sprite = &gSprites[eventObject->fieldEffectSpriteId]; + if (sprite->data[7]) + { + eventObject->directionSequenceIndex = 2; + sprite->data[0]++; + return TRUE; + } + return FALSE; +} + +u32 sub_8155DDC(void) +{ + u8 spriteId; + + gFieldEffectArguments[0] += 7; + gFieldEffectArguments[1] += 7; + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[35], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].oam.priority = gFieldEffectArguments[2]; + gSprites[spriteId].coordOffsetEnabled = TRUE; + } + return 0; +} + +void sub_8155E50(struct Sprite *sprite) +{ + if (sprite->data[0] == 0) + { + if (sprite->animEnded) + { + sprite->invisible = TRUE; + sprite->data[0]++; + } + + if (sprite->data[0] == 0) + return; + } + + if (++sprite->data[1] > 34) + FieldEffectStop(sprite, FLDEFF_SPARKLE); +} + +void sub_8155EA0(struct Sprite *sprite) +{ + sprite->data[6] = 0; + sprite->data[7] = 0; +} + +bool8 sub_8155EA8(struct Sprite *sprite) +{ + bool8 returnBool = FALSE; + + switch (sprite->data[7]) + { + case 0: + sprite->pos2.x += sub_809773C(sprite->data[6]); + sprite->pos2.y += sub_8097728(sprite->data[6]); + break; + case 1: + sprite->pos2.x -= sub_809773C(0x47 - sprite->data[6]); + sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); + break; + case 2: + sprite->pos2.x -= sub_809773C(sprite->data[6]); + sprite->pos2.y += sub_8097728(sprite->data[6]); + break; + case 3: + sprite->pos2.x += sub_809773C(0x47 - sprite->data[6]); + sprite->pos2.y += sub_8097728(0x47 - sprite->data[6]); + break; + } + + SetGpuReg(REG_OFFSET_BG0HOFS, -sprite->pos2.x); + if (++sprite->data[6] == 72) + { + sprite->data[6] = 0; + sprite->data[7]++; + } + if (sprite->data[7] == 4) + { + sprite->pos2.y = 0; + sprite->pos2.x = 0; + returnBool = TRUE; + } + + return returnBool; +} + +void sub_8155F80(struct Sprite *sprite) +{ + u8 i, j; + + switch (sprite->data[2]) + { + case 0: + SetGpuReg(REG_OFFSET_BG0VOFS, 0x78 - (sprite->data[0] / 3)); + if (sprite->data[0] == 0x60) + { + for (i = 0; i < 3; i++) + { + for (j = 12; j < 18; j++) + { + ((u16*)(VRAM + 0xF800))[i * 32 + j] = 0xBFF4 + i * 6 + j + 1; + } + } + } + if (sprite->data[0] > 0x137) + { + sprite->data[2] = 1; + sprite->data[0] = 0; + } + break; + case 1: + sprite->pos1.y = (gSineTable[sprite->data[0] / 3] >> 2) + sprite->data[4]; + if (sprite->data[0] == 0xBD) + { + sprite->data[2] = 2; + sprite->data[5] = 0; + sprite->data[0] = 0; + } + break; + case 2: + if (sprite->data[0] == 0x3C) + { + sprite->data[5]++; + sprite->data[0] = 0; + } + if (sprite->data[5] == 7) + { + sprite->data[5] = 0; + sprite->data[2] = 3; + } + break; + case 3: + if (sprite->pos2.y == 0) + { + sprite->data[0] = 0; + sprite->data[2]++; + } + if (sprite->data[0] == 5) + { + sprite->data[0] = 0; + if (sprite->pos2.y > 0) + sprite->pos2.y--; + else + sprite->pos2.y++; + } + break; + case 4: + if (sprite->data[0] == 0x3C) + { + sprite->data[2] = 5; + sprite->data[0] = 0; + sprite->data[5] = 0; + } + break; + case 5: + sub_8155EA0(sprite); + sprite->data[2] = 6; + sprite->data[0] = 0; + break; + case 6: + if (sub_8155EA8(sprite)) + { + sprite->data[0] = 0; + if (++sprite->data[5] <= 2) + { + sub_8155EA0(sprite); + } + else + { + sprite->data[5] = 0; + sprite->data[2] = 7; + } + } + break; + case 7: + if (sprite->data[0] == 0x1E) + { + sprite->data[2] = 8; + sprite->data[0] = 0; + } + break; + case 8: + for (i = 0; i < 15; i++) + { + for (j = 12; j < 18; j++) + { + ((u16*)(VRAM + 0xF800))[i * 32 + j] = 0; + } + } + SetGpuReg(REG_OFFSET_BG0VOFS, 0); + FieldEffectStop(sprite, FLDEFF_64); + break; + } + + if (sprite->data[2] == 1) + { + if ((sprite->data[1] & 7) == 0) + sprite->pos2.y += sprite->data[3]; + if ((sprite->data[1] & 15) == 0) + sprite->data[3] = -sprite->data[3]; + sprite->data[1]++; + } + + sprite->data[0]++; +} + +void sub_8156194(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + FieldEffectStop(sprite, sprite->data[1]); + } + else + { + UpdateEventObjectSpriteVisibility(sprite, FALSE); + SetObjectSubpriorityByZCoord(sprite->data[0], sprite, 0); + } +} + +void sub_81561D0(struct Sprite *sprite) +{ + if (sprite->animEnded) + FieldEffectStop(sprite, sprite->data[0]); + else + UpdateEventObjectSpriteVisibility(sprite, FALSE); +} + +#ifdef NONMATCHING +void sub_81561FC(struct Sprite *sprite /*r6*/, u8 z, u8 offset) +{ + u8 i; + s16 xlo; + s16 xhi; + s16 lx; + s16 lyhi; + s16 ly; + s16 ylo; + s16 yhi; + struct EventObject *eventObject; // r4 + const struct EventObjectGraphicsInfo *graphicsInfo; // destroyed + struct Sprite *linkedSprite; // r5 + + SetObjectSubpriorityByZCoord(z, sprite, offset); + for (i = 0; i < 16; i ++) + { + eventObject = &gEventObjects[i]; + if (eventObject->active) + { + graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + linkedSprite = &gSprites[eventObject->spriteId]; + xhi = sprite->pos1.x + sprite->centerToCornerVecX; + xlo = sprite->pos1.x - sprite->centerToCornerVecX; + lx = linkedSprite->pos1.x; + if (xhi < lx && xlo > lx) + { + lyhi = linkedSprite->pos1.y + linkedSprite->centerToCornerVecY; + ly = linkedSprite->pos1.y; + ylo = sprite->pos1.y - sprite->centerToCornerVecY; + yhi = ylo + linkedSprite->centerToCornerVecY; + if ((lyhi < yhi || lyhi < ylo) && ly > yhi) + { + if (sprite->subpriority <= linkedSprite->subpriority) + { + sprite->subpriority = linkedSprite->subpriority + 2; + break; + } + } + } + } + } +} +#else +NAKED void sub_81561FC(struct Sprite *sprite /*r6*/, u8 z, u8 offset) +{ + asm_unified("push {r4-r7,lr}\n\ + adds r6, r0, 0\n\ + adds r0, r1, 0\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + lsls r2, 24\n\ + lsrs r2, 24\n\ + adds r1, r6, 0\n\ + bl SetObjectSubpriorityByZCoord\n\ + movs r7, 0\n\ +_08156212:\n\ + lsls r0, r7, 3\n\ + adds r0, r7\n\ + lsls r0, 2\n\ + ldr r1, =gEventObjects\n\ + adds r4, r0, r1\n\ + ldrb r0, [r4]\n\ + lsls r0, 31\n\ + cmp r0, 0\n\ + beq _081562B4\n\ + ldrb r0, [r4, 0x5]\n\ + bl GetEventObjectGraphicsInfo\n\ + ldrb r1, [r4, 0x4]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + ldr r1, =gSprites\n\ + adds r5, r0, r1\n\ + adds r0, r6, 0\n\ + adds r0, 0x28\n\ + movs r2, 0\n\ + ldrsb r2, [r0, r2]\n\ + ldrh r0, [r6, 0x20]\n\ + adds r1, r0, r2\n\ + subs r0, r2\n\ + lsls r0, 16\n\ + lsrs r4, r0, 16\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + movs r0, 0x20\n\ + ldrsh r2, [r5, r0]\n\ + cmp r1, r2\n\ + bge _081562B4\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + cmp r0, r2\n\ + ble _081562B4\n\ + adds r0, r5, 0\n\ + adds r0, 0x29\n\ + movs r3, 0\n\ + ldrsb r3, [r0, r3]\n\ + ldrh r2, [r5, 0x22]\n\ + adds r2, r3\n\ + ldrh r4, [r5, 0x22]\n\ + adds r0, r6, 0\n\ + adds r0, 0x29\n\ + movs r1, 0\n\ + ldrsb r1, [r0, r1]\n\ + ldrh r0, [r6, 0x22]\n\ + subs r0, r1\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + adds r3, r0, r3\n\ + lsls r2, 16\n\ + asrs r2, 16\n\ + lsls r3, 16\n\ + asrs r3, 16\n\ + cmp r2, r3\n\ + blt _0815628C\n\ + cmp r2, r0\n\ + bge _081562B4\n\ +_0815628C:\n\ + lsls r0, r4, 16\n\ + asrs r0, 16\n\ + cmp r0, r3\n\ + ble _081562B4\n\ + adds r2, r6, 0\n\ + adds r2, 0x43\n\ + adds r0, r5, 0\n\ + adds r0, 0x43\n\ + ldrb r1, [r0]\n\ + ldrb r0, [r2]\n\ + cmp r0, r1\n\ + bhi _081562B4\n\ + adds r0, r1, 0x2\n\ + strb r0, [r2]\n\ + b _081562BE\n\ + .pool\n\ +_081562B4:\n\ + adds r0, r7, 0x1\n\ + lsls r0, 24\n\ + lsrs r7, r0, 24\n\ + cmp r7, 0xF\n\ + bls _08156212\n\ +_081562BE:\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0"); +} +#endif