From 35ee9f67c0d89d73c7ef4c8d272dca767ceeb7c4 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 9 Oct 2018 17:32:39 -0400 Subject: [PATCH 1/5] ported some of field_effect_helpers --- asm/field_effect_helpers.s | 1693 ------------------------------- data/field_effect_helpers.s | 11 +- include/event_object_movement.h | 4 + ld_script.txt | 2 + src/field_effect_helpers.c | 568 +++++++++++ 5 files changed, 576 insertions(+), 1702 deletions(-) create mode 100755 src/field_effect_helpers.c diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index 9a019f60c..050d6b543 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -5,1699 +5,6 @@ .text - thumb_func_start SetUpReflection -SetUpReflection: @ 8153ED4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - adds r4, r1, 0 - lsls r5, r2, 24 - lsrs r5, 24 - movs r0, 0x20 - ldrsh r1, [r4, r0] - movs r0, 0x22 - ldrsh r2, [r4, r0] - adds r0, r4, 0 - movs r3, 0x98 - bl CreateCopySpriteAt - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r7, r1, r0 - ldr r0, =objc_reflection_maybe - str r0, [r7, 0x1C] - ldrb r1, [r7, 0x5] - movs r0, 0xC - orrs r1, r0 - strb r1, [r7, 0x5] - ldr r2, =gReflectionEffectPaletteMap - lsrs r0, r1, 4 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 4 - movs r2, 0xF - ands r1, r2 - orrs r1, r0 - strb r1, [r7, 0x5] - movs r1, 0x3F - adds r1, r7 - mov r8, r1 - ldrb r0, [r1] - movs r1, 0x40 - orrs r0, r1 - mov r1, r8 - strb r0, [r1] - ldr r0, =gDummySpriteAnimTable - str r0, [r7, 0x8] - adds r0, r7, 0 - movs r1, 0 - bl StartSpriteAnim - ldr r0, =gDummySpriteAffineAnimTable - str r0, [r7, 0x10] - mov r1, r8 - ldrb r0, [r1] - movs r1, 0x8 - orrs r0, r1 - mov r1, r8 - strb r0, [r1] - adds r2, r7, 0 - adds r2, 0x42 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - strb r0, [r2] - ldrh r0, [r4, 0x2E] - strh r0, [r7, 0x2E] - ldrb r0, [r6, 0x8] - strh r0, [r7, 0x30] - strh r5, [r7, 0x3C] - adds r0, r6, 0 - adds r1, r7, 0 - bl npc_pal_op - cmp r5, 0 - bne _08153F7A - ldrb r0, [r7, 0x1] - movs r1, 0x4 - negs r1, r1 - ands r1, r0 - movs r0, 0x1 - orrs r1, r0 - strb r1, [r7, 0x1] -_08153F7A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end SetUpReflection - - thumb_func_start sub_8153F98 -sub_8153F98: @ 8153F98 - push {lr} - ldrb r0, [r0, 0x5] - bl GetEventObjectGraphicsInfo - ldrh r0, [r0, 0xA] - subs r0, 0x2 - lsls r0, 16 - asrs r0, 16 - pop {r1} - bx r1 - thumb_func_end sub_8153F98 - - thumb_func_start npc_pal_op -@ void npc_pal_op(struct npc_state *npcState, struct obj *obj) -npc_pal_op: @ 8153FAC - push {r4,r5,lr} - sub sp, 0x8 - adds r5, r0, 0 - adds r4, r1, 0 - ldr r1, =gUnknown_085CDC38 - mov r0, sp - movs r2, 0x6 - bl memcpy - movs r0, 0 - strh r0, [r4, 0x32] - ldrb r0, [r5, 0x5] - bl GetEventObjectGraphicsInfo - ldrb r1, [r0, 0xC] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _08154008 - ldrb r0, [r5, 0x1F] - bl MetatileBehavior_GetBridgeSth - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08153FEE - ldrb r0, [r5, 0x1E] - bl MetatileBehavior_GetBridgeSth - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08154008 -_08153FEE: - subs r0, 0x1 - lsls r0, 1 - add r0, sp - ldrh r0, [r0] - strh r0, [r4, 0x32] - ldrb r1, [r4, 0x5] - lsrs r1, 4 - adds r0, r5, 0 - bl npc_pal_op_A - b _08154012 - .pool -_08154008: - ldrb r1, [r4, 0x5] - lsrs r1, 4 - adds r0, r5, 0 - bl npc_pal_op_B -_08154012: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end npc_pal_op - - thumb_func_start npc_pal_op_B -@ void npc_pal_op_B(void *a1, u8 slot) -npc_pal_op_B: @ 815401C - push {r4,lr} - lsls r1, 24 - lsrs r4, r1, 24 - ldrb r0, [r0, 0x5] - bl GetEventObjectGraphicsInfo - adds r2, r0, 0 - ldrh r1, [r2, 0x4] - ldr r0, =0x000011ff - cmp r1, r0 - beq _08154070 - ldrb r0, [r2, 0xC] - movs r1, 0xF - ands r1, r0 - cmp r1, 0 - bne _0815404C - ldrh r0, [r2, 0x2] - adds r1, r4, 0 - bl LoadPlayerObjectReflectionPalette - b _0815406A - .pool -_0815404C: - cmp r1, 0xA - bne _0815405A - ldrh r0, [r2, 0x2] - adds r1, r4, 0 - bl LoadSpecialObjectReflectionPalette - b _0815406A -_0815405A: - adds r0, r4, 0 - bl GetObjectPaletteTag - lsls r0, 16 - lsrs r0, 16 - adds r1, r4, 0 - bl PatchObjectPalette -_0815406A: - adds r0, r4, 0 - bl UpdateSpritePaletteWithWeather -_08154070: - pop {r4} - pop {r0} - bx r0 - thumb_func_end npc_pal_op_B - - thumb_func_start npc_pal_op_A -npc_pal_op_A: @ 8154078 - push {r4,lr} - lsls r1, 24 - lsrs r4, r1, 24 - ldrb r0, [r0, 0x5] - bl GetEventObjectGraphicsInfo - adds r2, r0, 0 - ldrh r1, [r2, 0x4] - ldr r0, =0x000011ff - cmp r1, r0 - beq _0815409C - adds r0, r1, 0 - adds r1, r4, 0 - bl PatchObjectPalette - adds r0, r4, 0 - bl UpdateSpritePaletteWithWeather -_0815409C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end npc_pal_op_A - - thumb_func_start objc_reflection_maybe -@ void objc_reflection_maybe(struct obj *object) -objc_reflection_maybe: @ 81540A8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r4, r0, 0 - movs r0, 0x2E - ldrsh r1, [r4, r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gEventObjects - adds r7, r0, r1 - ldrb r1, [r7, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r5, r0, r1 - ldr r0, [r7] - ldr r1, =0x00020001 - ands r0, r1 - cmp r0, r1 - bne _081540E0 - ldrb r1, [r7, 0x8] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r1, r0 - beq _081540FC -_081540E0: - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - movs r0, 0x2 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - b _08154214 - .pool -_081540FC: - ldr r1, =gReflectionEffectPaletteMap - ldrb r0, [r5, 0x5] - lsrs r0, 4 - adds r0, r1 - ldrb r1, [r0] - lsls r1, 4 - ldrb r2, [r4, 0x5] - movs r0, 0xF - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x5] - ldrb r1, [r5, 0x1] - lsrs r1, 6 - lsls r1, 6 - ldrb r2, [r4, 0x1] - movs r3, 0x3F - adds r0, r3, 0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x1] - ldrb r0, [r5, 0x3] - lsrs r0, 6 - lsls r0, 6 - ldrb r2, [r4, 0x3] - adds r1, r3, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r4, 0x3] - ldrb r0, [r5, 0x3] - lsls r0, 26 - lsrs r0, 27 - movs r2, 0x10 - orrs r0, r2 - lsls r0, 1 - subs r2, 0x4F - mov r9, r2 - ands r1, r2 - orrs r1, r0 - strb r1, [r4, 0x3] - ldrh r1, [r5, 0x4] - lsls r1, 22 - lsrs r1, 22 - ldrh r2, [r4, 0x4] - ldr r0, =0xfffffc00 - ands r0, r2 - orrs r0, r1 - strh r0, [r4, 0x4] - ldr r0, [r5, 0x18] - str r0, [r4, 0x18] - adds r0, r5, 0 - adds r0, 0x42 - ldrb r0, [r0] - lsls r0, 26 - lsrs r0, 26 - adds r2, r4, 0 - adds r2, 0x42 - ands r3, r0 - ldrb r1, [r2] - movs r0, 0x40 - negs r0, r0 - ands r0, r1 - orrs r0, r3 - strb r0, [r2] - movs r0, 0x3E - adds r0, r5 - mov r8, r0 - ldrb r0, [r0] - adds r6, r4, 0 - adds r6, 0x3E - movs r1, 0x4 - ands r1, r0 - ldrb r2, [r6] - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r6] - ldrh r0, [r5, 0x20] - strh r0, [r4, 0x20] - adds r0, r7, 0 - bl sub_8153F98 - ldrh r1, [r5, 0x22] - adds r0, r1 - ldrh r1, [r4, 0x32] - adds r1, r0 - strh r1, [r4, 0x22] - adds r0, r5, 0 - adds r0, 0x28 - ldrb r1, [r0] - adds r0, r4, 0 - adds r0, 0x28 - strb r1, [r0] - adds r0, r5, 0 - adds r0, 0x29 - ldrb r0, [r0] - adds r1, r4, 0 - adds r1, 0x29 - strb r0, [r1] - ldrh r0, [r5, 0x24] - strh r0, [r4, 0x24] - ldrh r0, [r5, 0x26] - negs r0, r0 - strh r0, [r4, 0x26] - mov r2, r8 - ldrb r1, [r2] - movs r0, 0x2 - ands r0, r1 - ldrb r1, [r6] - movs r2, 0x3 - negs r2, r2 - ands r2, r1 - orrs r2, r0 - strb r2, [r6] - ldrb r0, [r7, 0x3] - lsls r0, 28 - cmp r0, 0 - bge _081541EE - movs r0, 0x4 - orrs r2, r0 - strb r2, [r6] -_081541EE: - movs r1, 0x3C - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _08154214 - ldrb r0, [r4, 0x3] - mov r2, r9 - ands r2, r0 - strb r2, [r4, 0x3] - ldrb r0, [r5, 0x3] - lsls r0, 26 - lsrs r0, 27 - movs r1, 0x8 - ands r0, r1 - cmp r0, 0 - beq _08154214 - movs r1, 0x2 - adds r0, r2, 0 - orrs r0, r1 - strb r0, [r4, 0x3] -_08154214: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end objc_reflection_maybe - - thumb_func_start sub_8154228 -sub_8154228: @ 8154228 - push {r4,lr} - ldr r0, =gFieldEffectObjectTemplatePointers - ldr r0, [r0, 0x20] - movs r1, 0 - movs r2, 0 - movs r3, 0x52 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - cmp r0, 0x40 - beq _08154266 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - ldrb r2, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - movs r3, 0x4 - orrs r0, r3 - strb r0, [r1, 0x5] - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x2 - orrs r0, r2 - orrs r0, r3 - strb r0, [r1] -_08154266: - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154228 - - thumb_func_start objid_set_invisible -objid_set_invisible: @ 8154278 - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - adds r1, 0x3E - ldrb r0, [r1] - movs r2, 0x4 - orrs r0, r2 - strb r0, [r1] - bx lr - .pool - thumb_func_end objid_set_invisible - - thumb_func_start sub_8154298 -sub_8154298: @ 8154298 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r8, r1 - lsls r2, 16 - lsrs r7, r2, 16 - lsls r3, 16 - lsrs r6, r3, 16 - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - ldr r1, =gSprites - adds r2, r0, r1 - adds r0, r2, 0 - adds r0, 0x3E - ldrb r1, [r0] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - bne _081542E2 - movs r0, 0x2E - ldrsh r1, [r2, r0] - lsls r0, r7, 16 - asrs r0, 16 - cmp r1, r0 - bne _081542E2 - movs r0, 0x30 - ldrsh r1, [r2, r0] - lsls r0, r6, 16 - asrs r0, 16 - cmp r1, r0 - beq _0815432E -_081542E2: - lsls r0, r7, 16 - asrs r0, 16 - lsls r1, r6, 16 - asrs r1, 16 - mov r4, sp - adds r4, 0x2 - mov r2, sp - adds r3, r4, 0 - bl sub_8093038 - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - ldr r1, =gSprites - adds r2, r0, r1 - mov r0, sp - ldrh r0, [r0] - adds r0, 0x8 - strh r0, [r2, 0x20] - ldrh r0, [r4] - adds r0, 0x8 - strh r0, [r2, 0x22] - adds r3, r2, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r3] - strh r7, [r2, 0x2E] - strh r6, [r2, 0x30] - mov r1, r8 - subs r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - adds r0, r2, 0 - bl StartSpriteAnim -_0815432E: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8154298 - - thumb_func_start oei_shadow -oei_shadow: @ 8154340 - push {r4,r5,lr} - ldr r5, =gFieldEffectArguments - ldrb r0, [r5] - ldrb r1, [r5, 0x4] - ldrb r2, [r5, 0x8] - bl GetEventObjectIdByLocalIdAndMap - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gEventObjects - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1, 0x5] - bl GetEventObjectGraphicsInfo - adds r4, r0, 0 - ldr r2, =gFieldEffectObjectTemplatePointers - ldr r1, =gUnknown_085CDC3E - ldrb r0, [r4, 0xC] - lsls r0, 26 - lsrs r0, 30 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - movs r1, 0 - movs r2, 0 - movs r3, 0x94 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _081543C4 - ldr r0, =gSprites - lsls r2, r1, 4 - adds r2, r1 - lsls r2, 2 - adds r2, r0 - adds r3, r2, 0 - adds r3, 0x3E - ldrb r0, [r3] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r3] - ldr r0, [r5] - strh r0, [r2, 0x2E] - ldr r0, [r5, 0x4] - strh r0, [r2, 0x30] - ldr r0, [r5, 0x8] - strh r0, [r2, 0x32] - ldrh r1, [r4, 0xA] - lsls r1, 16 - asrs r1, 17 - ldr r3, =gUnknown_085CDC42 - ldrb r0, [r4, 0xC] - lsls r0, 26 - lsrs r0, 30 - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - subs r1, r0 - strh r1, [r2, 0x34] -_081543C4: - movs r0, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end oei_shadow - - thumb_func_start oamc_shadow -oamc_shadow: @ 81543E4 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - ldrh r0, [r5, 0x2E] - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r5, 0x30] - lsls r1, 24 - lsrs r1, 24 - ldrh r2, [r5, 0x32] - lsls r2, 24 - lsrs r2, 24 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - beq _08154412 - adds r0, r5, 0 - movs r1, 0x3 - bl FieldEffectStop - b _08154498 -_08154412: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gEventObjects - adds r4, r0, r1 - ldrb r0, [r4, 0x4] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r0, =gSprites - adds r1, r0 - ldrb r0, [r1, 0x5] - movs r2, 0xC - ands r2, r0 - ldrb r3, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r3 - orrs r0, r2 - strb r0, [r5, 0x5] - ldrh r0, [r1, 0x20] - strh r0, [r5, 0x20] - ldrh r0, [r5, 0x34] - ldrh r1, [r1, 0x22] - adds r0, r1 - strh r0, [r5, 0x22] - ldr r0, [r4] - ldr r1, =0x00400001 - ands r0, r1 - cmp r0, r1 - bne _08154490 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsPokeGrass - lsls r0, 24 - cmp r0, 0 - bne _08154490 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - bne _08154490 - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsSurfableWaterOrUnderwater - lsls r0, 24 - cmp r0, 0 - bne _08154490 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsReflective - lsls r0, 24 - cmp r0, 0 - bne _08154490 - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsReflective - lsls r0, 24 - cmp r0, 0 - beq _08154498 -_08154490: - adds r0, r5, 0 - movs r1, 0x3 - bl FieldEffectStop -_08154498: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end oamc_shadow - - thumb_func_start oei_grass_normal -oei_grass_normal: @ 81544AC - 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, 0x10] - mov r1, sp - movs r2, 0 - ldrsh r1, [r1, r2] - movs r3, 0 - ldrsh r2, [r4, r3] - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _08154538 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r3, r0, r1 - adds r2, r3, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x3 - ldrb r1, [r5, 0xC] - ands r1, r0 - lsls r1, 2 - ldrb r2, [r3, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r3, 0x5] - ldr r0, [r5, 0x8] - strh r0, [r3, 0x2E] - ldr r0, [r5] - strh r0, [r3, 0x30] - ldr r0, [r5, 0x4] - strh r0, [r3, 0x32] - ldr r0, [r5, 0x10] - strh r0, [r3, 0x34] - ldr r0, [r5, 0x14] - strh r0, [r3, 0x36] - ldr r0, [r5, 0x18] - strh r0, [r3, 0x38] - ldr r0, [r5, 0x1C] - cmp r0, 0 - beq _08154538 - adds r0, r3, 0 - movs r1, 0x4 - bl SeekSpriteAnim -_08154538: - movs r0, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end oei_grass_normal - - thumb_func_start unc_grass_normal -unc_grass_normal: @ 8154550 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r5, r0, 0 - ldrh r0, [r5, 0x38] - lsrs r4, r0, 8 - lsls r0, 24 - lsrs r7, r0, 24 - ldr r3, =gCamera - ldrb r1, [r3] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0815459C - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - movs r0, 0x5 - ldrsb r0, [r2, r0] - cmp r0, r4 - bne _08154582 - movs r0, 0x4 - ldrsb r0, [r2, r0] - cmp r0, r7 - beq _0815459C -_08154582: - ldr r1, [r3, 0x4] - ldrh r0, [r5, 0x30] - subs r0, r1 - strh r0, [r5, 0x30] - ldr r1, [r3, 0x8] - ldrh r0, [r5, 0x32] - subs r0, r1 - strh r0, [r5, 0x32] - ldrb r1, [r2, 0x5] - lsls r1, 8 - ldrb r0, [r2, 0x4] - orrs r0, r1 - strh r0, [r5, 0x38] -_0815459C: - ldrh r0, [r5, 0x34] - lsrs r1, r0, 8 - mov r8, r1 - lsls r0, 24 - lsrs r4, r0, 24 - ldrh r0, [r5, 0x36] - lsls r0, 24 - lsrs r7, r0, 24 - movs r2, 0x30 - ldrsh r0, [r5, r2] - movs r2, 0x32 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r6, r0, 24 - mov r0, r8 - adds r1, r4, 0 - adds r2, r7, 0 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _081545F0 - adds r0, r6, 0 - bl MetatileBehavior_IsTallGrass - lsls r0, 24 - cmp r0, 0 - beq _081545F0 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _08154604 - adds r0, r5, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08154604 -_081545F0: - adds r0, r5, 0 - movs r1, 0x4 - bl FieldEffectStop - b _08154648 - .pool -_08154604: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gEventObjects - adds r2, r0, r1 - ldr r0, [r2, 0x10] - ldr r1, [r5, 0x30] - cmp r0, r1 - beq _08154624 - ldr r0, [r2, 0x14] - cmp r0, r1 - beq _08154624 - movs r0, 0x1 - strh r0, [r5, 0x3C] -_08154624: - movs r6, 0 - adds r0, r5, 0 - adds r0, 0x2B - ldrb r0, [r0] - cmp r0, 0 - bne _08154632 - movs r6, 0x4 -_08154632: - adds r0, r5, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - ldrh r1, [r5, 0x2E] - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - adds r2, r6, 0 - bl sub_81561FC -_08154648: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end unc_grass_normal - - thumb_func_start sub_8154658 -sub_8154658: @ 8154658 - 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, 0x28] - 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 _081546B4 - 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, 0xC - strh r0, [r2, 0x30] -_081546B4: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154658 - - thumb_func_start sub_81546C8 -sub_81546C8: @ 81546C8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r4, [sp, 0x18] - lsls r0, 24 - lsrs r0, 24 - mov r12, r0 - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 24 - lsrs r6, r2, 24 - movs r5, 0 - ldr r0, =gSprites - mov r8, r0 - lsls r3, 16 - asrs r3, 16 - lsls r4, 16 - asrs r4, 16 -_081546EC: - lsls r0, r5, 4 - adds r0, r5 - lsls r0, 2 - mov r1, r8 - adds r2, r0, r1 - adds r0, r2, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - beq _08154740 - ldr r1, [r2, 0x1C] - ldr r0, =unc_grass_normal - cmp r1, r0 - bne _08154740 - movs r1, 0x30 - ldrsh r0, [r2, r1] - cmp r3, r0 - bne _08154740 - movs r1, 0x32 - ldrsh r0, [r2, r1] - cmp r4, r0 - bne _08154740 - ldrh r1, [r2, 0x34] - lsrs r0, r1, 8 - cmp r12, r0 - bne _08154740 - movs r0, 0xFF - ands r0, r1 - cmp r7, r0 - bne _08154740 - movs r1, 0x36 - ldrsh r0, [r2, r1] - cmp r6, r0 - bne _08154740 - adds r0, r5, 0 - b _0815474C - .pool -_08154740: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3F - bls _081546EC - movs r0, 0x40 -_0815474C: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_81546C8 - - thumb_func_start sub_8154758 -sub_8154758: @ 8154758 - 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, 0x3C] - mov r1, sp - movs r2, 0 - ldrsh r1, [r1, r2] - movs r3, 0 - ldrsh r2, [r4, r3] - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _081547E8 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - adds r2, r4, 0 - adds r2, 0x3E - ldrb r0, [r2] - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2] - ldrb r0, [r5, 0x8] - bl ZCoordToPriority - movs r1, 0x3 - ands r1, r0 - lsls r1, 2 - ldrb r2, [r4, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x5] - ldr r0, [r5, 0x8] - strh r0, [r4, 0x2E] - ldr r0, [r5] - strh r0, [r4, 0x30] - ldr r0, [r5, 0x4] - strh r0, [r4, 0x32] - ldr r0, [r5, 0x10] - strh r0, [r4, 0x34] - ldr r0, [r5, 0x14] - strh r0, [r4, 0x36] - ldr r0, [r5, 0x18] - strh r0, [r4, 0x38] - ldr r0, [r5, 0x1C] - cmp r0, 0 - beq _081547E8 - adds r0, r4, 0 - movs r1, 0x6 - bl SeekSpriteAnim -_081547E8: - movs r0, 0 - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154758 - - thumb_func_start unc_grass_tall -unc_grass_tall: @ 8154800 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r5, r0, 0 - ldrh r0, [r5, 0x38] - lsrs r7, r0, 8 - lsls r0, 24 - lsrs r6, r0, 24 - ldr r3, =gCamera - ldrb r1, [r3] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0815484C - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - movs r0, 0x5 - ldrsb r0, [r2, r0] - cmp r0, r7 - bne _08154832 - movs r0, 0x4 - ldrsb r0, [r2, r0] - cmp r0, r6 - beq _0815484C -_08154832: - ldr r1, [r3, 0x4] - ldrh r0, [r5, 0x30] - subs r0, r1 - strh r0, [r5, 0x30] - ldr r1, [r3, 0x8] - ldrh r0, [r5, 0x32] - subs r0, r1 - strh r0, [r5, 0x32] - ldrb r1, [r2, 0x5] - lsls r1, 8 - ldrb r0, [r2, 0x4] - orrs r0, r1 - strh r0, [r5, 0x38] -_0815484C: - ldrh r0, [r5, 0x34] - lsrs r1, r0, 8 - mov r8, r1 - lsls r0, 24 - lsrs r7, r0, 24 - ldrh r0, [r5, 0x36] - lsls r0, 24 - lsrs r6, r0, 24 - movs r2, 0x30 - ldrsh r0, [r5, r2] - movs r2, 0x32 - ldrsh r1, [r5, r2] - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r4, r0, 24 - mov r0, r8 - adds r1, r7, 0 - adds r2, r6, 0 - mov r3, sp - bl TryGetEventObjectIdByLocalIdAndMap - lsls r0, 24 - cmp r0, 0 - bne _081548A0 - adds r0, r4, 0 - bl MetatileBehavior_IsLongGrass - lsls r0, 24 - cmp r0, 0 - beq _081548A0 - movs r1, 0x3C - ldrsh r0, [r5, r1] - cmp r0, 0 - beq _081548B4 - adds r0, r5, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _081548B4 -_081548A0: - adds r0, r5, 0 - movs r1, 0x11 - bl FieldEffectStop - b _081548EA - .pool -_081548B4: - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =gEventObjects - adds r2, r0, r1 - ldr r0, [r2, 0x10] - ldr r1, [r5, 0x30] - cmp r0, r1 - beq _081548D4 - ldr r0, [r2, 0x14] - cmp r0, r1 - beq _081548D4 - movs r0, 0x1 - strh r0, [r5, 0x3C] -_081548D4: - adds r0, r5, 0 - movs r1, 0 - bl UpdateEventObjectSpriteVisibility - ldrh r1, [r5, 0x2E] - lsls r1, 24 - lsrs r1, 24 - adds r0, r5, 0 - movs r2, 0 - bl sub_81561FC -_081548EA: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end unc_grass_tall - - thumb_func_start sub_81548FC -sub_81548FC: @ 81548FC - 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, 0x40] - 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 _08154958 - 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, 0x12 - strh r0, [r2, 0x30] -_08154958: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81548FC - - thumb_func_start sub_815496C -sub_815496C: @ 815496C - 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, 0x78] - movs r1, 0 - movs r2, 0 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - beq _081549F8 - 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] -_081549F8: - movs r0, 0 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_815496C - - thumb_func_start sub_8154A10 -sub_8154A10: @ 8154A10 - push {r4-r7,lr} - mov r7, r8 - push {r7} - 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 _08154A4E - 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, 29 - cmp r0, 0 - blt _08154A5C -_08154A4E: - adds r0, r4, 0 - movs r1, 0x29 - bl FieldEffectStop - b _08154AF2 - .pool -_08154A5C: - ldrb r0, [r1, 0x5] - bl GetEventObjectGraphicsInfo - mov r8, r0 - mov r0, sp - ldrb r1, [r0] - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r6, r0, r1 - ldrh r5, [r6, 0x22] - ldrh r7, [r6, 0x20] - movs r0, 0x20 - ldrsh r1, [r6, r0] - movs r2, 0x34 - ldrsh r0, [r4, r2] - cmp r1, r0 - bne _08154A98 - lsls r0, r5, 16 - asrs r0, 16 - movs r2, 0x36 - ldrsh r1, [r4, r2] - cmp r0, r1 - beq _08154AB2 -_08154A98: - strh r7, [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 _08154AB2 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAnim -_08154AB2: - strh r7, [r4, 0x20] - strh r5, [r4, 0x22] - mov r1, r8 - ldrh r0, [r1, 0xA] - lsls r0, 16 - asrs r0, 17 - subs r0, 0x8 - strh r0, [r4, 0x26] - adds r0, r6, 0 - adds r0, 0x43 - ldrb r0, [r0] - subs r0, 0x1 - adds r1, r4, 0 - adds r1, 0x43 - strb r0, [r1] - ldrb r0, [r6, 0x5] - movs r1, 0xC - ands r1, r0 - ldrb r2, [r4, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, 0x5] - adds r0, r6, 0 - adds r0, 0x3E - ldrb r1, [r0] - lsls r1, 29 - lsrs r1, 31 - adds r0, r4, 0 - bl UpdateEventObjectSpriteVisibility -_08154AF2: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8154A10 - - thumb_func_start sub_8154B04 -sub_8154B04: @ 8154B04 - 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, 0x2C] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x40 - beq _08154B62 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r3] - movs r1, 0x3 - ldrb r2, [r4, 0xC] - ands r2, r1 - lsls r2, 2 - ldrb r3, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x5] - movs r1, 0xD - strh r1, [r0, 0x3C] - ldrb r1, [r4, 0x10] - bl StartSpriteAnim -_08154B62: - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154B04 - - thumb_func_start sub_8154B78 -sub_8154B78: @ 8154B78 - 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, 0x5C] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - adds r5, r1, 0 - cmp r1, 0x40 - beq _08154BD8 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r3] - movs r1, 0x3 - ldrb r2, [r4, 0xC] - ands r2, r1 - lsls r2, 2 - ldrb r3, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x5] - movs r1, 0x18 - strh r1, [r0, 0x3C] - ldrb r1, [r4, 0x10] - bl StartSpriteAnim -_08154BD8: - adds r0, r5, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154B78 - - thumb_func_start sub_8154BEC -sub_8154BEC: @ 8154BEC - 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, 0x6C] - movs r2, 0 - ldrsh r1, [r4, r2] - movs r3, 0x4 - ldrsh r2, [r4, r3] - ldrb r3, [r4, 0x8] - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r1, r0, 24 - adds r5, r1, 0 - cmp r1, 0x40 - beq _08154C4C - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x2 - orrs r1, r2 - strb r1, [r3] - movs r1, 0x3 - ldrb r2, [r4, 0xC] - ands r2, r1 - lsls r2, 2 - ldrb r3, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x5] - movs r1, 0x23 - strh r1, [r0, 0x3C] - ldrb r1, [r4, 0x10] - bl StartSpriteAnim -_08154C4C: - adds r0, r5, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8154BEC - thumb_func_start sub_8154C60 sub_8154C60: @ 8154C60 push {lr} diff --git a/data/field_effect_helpers.s b/data/field_effect_helpers.s index 63fc1580e..a1edac00c 100644 --- a/data/field_effect_helpers.s +++ b/data/field_effect_helpers.s @@ -2,15 +2,8 @@ .include "constants/constants.inc" .section .rodata - -gUnknown_085CDC38:: @ 85CDC38 - .2byte 12, 28, 44 - -gUnknown_085CDC3E:: @ 85CDC3E - .byte 0x00, 0x01, 0x02, 0x03 - -gUnknown_085CDC42:: @ 85CDC42 - .2byte 0x0004, 0x0004, 0x0004, 0x0010, 0x0000 + + .align 2 gUnknown_085CDC4C:: @ 85CDC4C .4byte sub_8154C7C diff --git a/include/event_object_movement.h b/include/event_object_movement.h index d43dd78ea..97c41a519 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -80,6 +80,7 @@ struct LockedAnimEventObjects }; extern const struct SpriteFrameImage gEventObjectPicTable_PechaBerryTree[]; +extern const u8 gReflectionEffectPaletteMap[]; void sub_808D438(void); u8 GetMoveDirectionAnimNum(u8); @@ -189,6 +190,8 @@ u8 GetMoveDirectionFasterAnimNum(u8); u8 GetMoveDirectionFastestAnimNum(u8); u8 GetLedgeJumpDirection(s16, s16, u8); void CameraObjectSetFollowedObjectId(u8 objectId); +u16 GetObjectPaletteTag(u8 palSlot); +void UpdateEventObjectSpriteVisibility(struct Sprite *sprite, bool8 invisible); void MovementType_None(struct Sprite *); void MovementType_LookAround(struct Sprite *); @@ -249,6 +252,7 @@ u8 GetSlideMovementAction(u32); u8 GetJumpInPlaceMovementAction(u32); u8 GetJumpMovementAction(u32); u8 GetJump2MovementAction(u32); +u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority); u8 MovementType_WanderAround_Step0(struct EventObject *, struct Sprite *); u8 MovementType_WanderAround_Step1(struct EventObject *, struct Sprite *); diff --git a/ld_script.txt b/ld_script.txt index 43a556034..15932d96c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -201,6 +201,7 @@ SECTIONS { src/rom_81520A8.o(.text); 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); @@ -491,6 +492,7 @@ SECTIONS { src/battle_message.o(.rodata); data/cable_car.o(.rodata); src/save.o(.rodata); + src/field_effect_helpers.o(.rodata); data/field_effect_helpers.o(.rodata); src/contest_ai.o(.rodata); src/battle_controller_safari.o(.rodata); diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c new file mode 100755 index 000000000..37ff63258 --- /dev/null +++ b/src/field_effect_helpers.c @@ -0,0 +1,568 @@ +#include "global.h" +#include "sprite.h" +#include "fieldmap.h" +#include "metatile_behavior.h" +#include "sound.h" +#include "event_object_movement.h" +#include "field_camera.h" +#include "field_weather.h" +#include "field_effect.h" +#include "field_effect_helpers.h" +#include "constants/songs.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 SetUpReflection(struct EventObject *eventObject, struct Sprite *sprite, bool8 stillReflection) +{ + struct Sprite *reflectionSprite; + + reflectionSprite = &gSprites[CreateCopySpriteAt(sprite, sprite->pos1.x, sprite->pos1.y, 0x98)]; + reflectionSprite->callback = objc_reflection_maybe; + reflectionSprite->oam.priority = 3; + reflectionSprite->oam.paletteNum = gReflectionEffectPaletteMap[reflectionSprite->oam.paletteNum]; + reflectionSprite->usingSheet = TRUE; + reflectionSprite->anims = gDummySpriteAnimTable; + StartSpriteAnim(reflectionSprite, 0); + reflectionSprite->affineAnims = gDummySpriteAffineAnimTable; + reflectionSprite->affineAnimBeginning = TRUE; + reflectionSprite->subspriteMode = SUBSPRITES_OFF; + reflectionSprite->data[0] = sprite->data[0]; + reflectionSprite->data[1] = eventObject->localId; + reflectionSprite->data[7] = stillReflection; + npc_pal_op(eventObject, reflectionSprite); + + if (!stillReflection) + reflectionSprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; +} + +s16 sub_8153F98(struct EventObject *eventObject) +{ + return GetEventObjectGraphicsInfo(eventObject->graphicsId)->height - 2; +} + +void npc_pal_op(struct EventObject *eventObject, struct Sprite *sprite) +{ + u8 bridgeType; + u16 bridgeReflectionVerticalOffsets[] = { 12, 28, 44 }; + sprite->data[2] = 0; + if (!GetEventObjectGraphicsInfo(eventObject->graphicsId)->disableReflectionPaletteLoad && ((bridgeType = MetatileBehavior_GetBridgeSth(eventObject->previousMetatileBehavior)) || (bridgeType = MetatileBehavior_GetBridgeSth(eventObject->currentMetatileBehavior)))) + { + sprite->data[2] = bridgeReflectionVerticalOffsets[bridgeType - 1]; + npc_pal_op_A(eventObject, sprite->oam.paletteNum); + } + else + { + npc_pal_op_B(eventObject, sprite->oam.paletteNum); + } +} + +void npc_pal_op_B(struct EventObject *eventObject, u8 paletteIndex) +{ + const struct EventObjectGraphicsInfo *graphicsInfo; + + graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + if (graphicsInfo->paletteTag2 != 0x11ff) + { + if (graphicsInfo->paletteSlot == 0) + { + LoadPlayerObjectReflectionPalette(graphicsInfo->paletteTag1, paletteIndex); + } + else if (graphicsInfo->paletteSlot == 10) + { + LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag1, paletteIndex); + } + else + { + PatchObjectPalette(GetObjectPaletteTag(paletteIndex), paletteIndex); + } + UpdateSpritePaletteWithWeather(paletteIndex); + } +} + +// When walking on a bridge high above water (Route 120), the reflection is a solid dark blue color. +// This is so the sprite blends in with the dark water metatile underneath the bridge. +void npc_pal_op_A(struct EventObject *eventObject, u8 paletteNum) +{ + const struct EventObjectGraphicsInfo *graphicsInfo; + + graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId); + if (graphicsInfo->paletteTag2 != 0x11ff) + { + PatchObjectPalette(graphicsInfo->paletteTag2, paletteNum); + UpdateSpritePaletteWithWeather(paletteNum); + } +} + +void objc_reflection_maybe(struct Sprite *reflectionSprite) +{ + struct EventObject *eventObject; + struct Sprite *mainSprite; + + eventObject = &gEventObjects[reflectionSprite->data[0]]; + mainSprite = &gSprites[eventObject->spriteId]; + if (!eventObject->active || !eventObject->hasReflection || eventObject->localId != reflectionSprite->data[1]) + { + reflectionSprite->inUse = FALSE; + } + else + { + reflectionSprite->oam.paletteNum = gReflectionEffectPaletteMap[mainSprite->oam.paletteNum]; + reflectionSprite->oam.shape = mainSprite->oam.shape; + reflectionSprite->oam.size = mainSprite->oam.size; + reflectionSprite->oam.matrixNum = mainSprite->oam.matrixNum | 0x10; + reflectionSprite->oam.tileNum = mainSprite->oam.tileNum; + reflectionSprite->subspriteTables = mainSprite->subspriteTables; + reflectionSprite->subspriteTableNum = mainSprite->subspriteTableNum; + reflectionSprite->invisible = mainSprite->invisible; + reflectionSprite->pos1.x = mainSprite->pos1.x; + // reflectionSprite->data[2] holds an additional vertical offset, used by the high bridges on Route 120 + reflectionSprite->pos1.y = mainSprite->pos1.y + sub_8153F98(eventObject) + reflectionSprite->data[2]; + reflectionSprite->centerToCornerVecX = mainSprite->centerToCornerVecX; + reflectionSprite->centerToCornerVecY = mainSprite->centerToCornerVecY; + reflectionSprite->pos2.x = mainSprite->pos2.x; + reflectionSprite->pos2.y = -mainSprite->pos2.y; + reflectionSprite->coordOffsetEnabled = mainSprite->coordOffsetEnabled; + + if (eventObject->unk3_3 == TRUE) + reflectionSprite->invisible = TRUE; + + // Check if the reflection is not still. + if (reflectionSprite->data[7] == FALSE) + { + // Sets the reflection sprite's rot/scale matrix to the appropriate + // matrix based on whether or not the main sprite is horizontally flipped. + // If the sprite is facing to the east, then it is flipped, and its matrixNum is 8. + reflectionSprite->oam.matrixNum = 0; + if (mainSprite->oam.matrixNum & 0x8) + reflectionSprite->oam.matrixNum = 1; + } + } +} + +extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; + +u8 sub_8154228(void) +{ + u8 spriteId; + struct Sprite *sprite; + + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[8], 0, 0, 0x52); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->oam.priority = 1; + sprite->coordOffsetEnabled = TRUE; + sprite->invisible = TRUE; + } + return spriteId; +} + +void objid_set_invisible(u8 spriteId) +{ + gSprites[spriteId].invisible = TRUE; +} + +void sub_8154298(u8 spriteId, u8 direction, s16 x, s16 y) +{ + s16 x2; + s16 y2; + struct Sprite *sprite; + + sprite = &gSprites[spriteId]; + if (sprite->invisible || sprite->data[0] != x || sprite->data[1] != y) + { + sub_8093038(x, y, &x2, &y2); + sprite = &gSprites[spriteId]; + sprite->pos1.x = x2 + 8; + sprite->pos1.y = y2 + 8; + sprite->invisible = FALSE; + sprite->data[0] = x; + sprite->data[1] = y; + StartSpriteAnim(sprite, direction - 1); + } +} + +const u8 gShadowEffectTemplateIds[] = { + 0, + 1, + 2, + 3 +}; + +const u16 gShadowVerticalOffsets[] = { + 4, + 4, + 4, + 16 +}; + +u32 oei_shadow(void) +{ + u8 eventObjectId; + const struct EventObjectGraphicsInfo *graphicsInfo; + u8 spriteId; + + eventObjectId = GetEventObjectIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + graphicsInfo = GetEventObjectGraphicsInfo(gEventObjects[eventObjectId].graphicsId); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[gShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94); + if (spriteId != MAX_SPRITES) + { + gSprites[spriteId].coordOffsetEnabled = TRUE; + gSprites[spriteId].data[0] = gFieldEffectArguments[0]; + gSprites[spriteId].data[1] = gFieldEffectArguments[1]; + gSprites[spriteId].data[2] = gFieldEffectArguments[2]; + gSprites[spriteId].data[3] = (graphicsInfo->height >> 1) - gShadowVerticalOffsets[graphicsInfo->shadowSize]; + } + return 0; +} + +void oamc_shadow(struct Sprite *sprite) +{ + u8 eventObjectId; + struct EventObject *eventObject; + struct Sprite *linkedSprite; + + if (TryGetEventObjectIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &eventObjectId)) + { + FieldEffectStop(sprite, FLDEFF_SHADOW); + } + else + { + eventObject = &gEventObjects[eventObjectId]; + linkedSprite = &gSprites[eventObject->spriteId]; + sprite->oam.priority = linkedSprite->oam.priority; + sprite->pos1.x = linkedSprite->pos1.x; + sprite->pos1.y = linkedSprite->pos1.y + sprite->data[3]; + if (!eventObject->active || !eventObject->hasShadow + || MetatileBehavior_IsPokeGrass(eventObject->currentMetatileBehavior) + || MetatileBehavior_IsSurfableWaterOrUnderwater(eventObject->currentMetatileBehavior) + || MetatileBehavior_IsSurfableWaterOrUnderwater(eventObject->previousMetatileBehavior) + || MetatileBehavior_IsReflective(eventObject->currentMetatileBehavior) + || MetatileBehavior_IsReflective(eventObject->previousMetatileBehavior)) + { + FieldEffectStop(sprite, FLDEFF_SHADOW); + } + } +} + +u32 oei_grass_normal(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[4], x, y, 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[0] = gFieldEffectArguments[2]; + sprite->data[1] = gFieldEffectArguments[0]; + sprite->data[2] = gFieldEffectArguments[1]; + sprite->data[3] = gFieldEffectArguments[4]; + sprite->data[4] = gFieldEffectArguments[5]; + sprite->data[5] = gFieldEffectArguments[6]; + if (gFieldEffectArguments[7]) + { + SeekSpriteAnim(sprite, 4); + } + } + return 0; +} + +void unc_grass_normal(struct Sprite *sprite) +{ + u8 mapNum; + u8 mapGroup; + u8 metatileBehavior; + u8 localId; + u8 eventObjectId; + struct EventObject *eventObject; + + mapNum = sprite->data[5] >> 8; + mapGroup = sprite->data[5]; + if (gCamera.active && (gSaveBlock1Ptr->location.mapNum != mapNum || gSaveBlock1Ptr->location.mapGroup != mapGroup)) + { + sprite->data[1] -= gCamera.x; + sprite->data[2] -= gCamera.y; + sprite->data[5] = ((u8)gSaveBlock1Ptr->location.mapNum << 8) | (u8)gSaveBlock1Ptr->location.mapGroup; + } + localId = sprite->data[3] >> 8; + mapNum = sprite->data[3]; + mapGroup = sprite->data[4]; + metatileBehavior = MapGridGetMetatileBehaviorAt(sprite->data[1], sprite->data[2]); + if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId) || !MetatileBehavior_IsTallGrass(metatileBehavior) || (sprite->data[7] && sprite->animEnded)) + { + FieldEffectStop(sprite, FLDEFF_TALL_GRASS); + } + else + { + eventObject = &gEventObjects[eventObjectId]; + if ((eventObject->currentCoords.x != sprite->data[1] || eventObject->currentCoords.y != sprite->data[2]) && (eventObject->previousCoords.x != sprite->data[1] || eventObject->previousCoords.y != sprite->data[2])) + sprite->data[7] = TRUE; + + metatileBehavior = 0; + if (sprite->animCmdIndex == 0) + metatileBehavior = 4; + + UpdateEventObjectSpriteVisibility(sprite, 0); + sub_81561FC(sprite, sprite->data[0], metatileBehavior); + } +} + +u32 sub_8154658(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 12); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[10], 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] = 12; + } + return 0; +} + +u8 sub_81546C8(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y) +{ + struct Sprite *sprite; + u8 i; + + for (i = 0; i < MAX_SPRITES; i ++) + { + if (gSprites[i].inUse) + { + sprite = &gSprites[i]; + if (sprite->callback == unc_grass_normal && (x == sprite->data[1] && y == sprite->data[2]) && (localId == (u8)(sprite->data[3] >> 8) && mapNum == (sprite->data[3] & 0xFF) && mapGroup == sprite->data[4])) + return i; + } + } + + return MAX_SPRITES; +} + +u32 sub_8154758(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[15], x, y, 0); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = ZCoordToPriority(gFieldEffectArguments[2]); + sprite->data[0] = gFieldEffectArguments[2]; + sprite->data[1] = gFieldEffectArguments[0]; + sprite->data[2] = gFieldEffectArguments[1]; + sprite->data[3] = gFieldEffectArguments[4]; + sprite->data[4] = gFieldEffectArguments[5]; + sprite->data[5] = gFieldEffectArguments[6]; + if (gFieldEffectArguments[7]) + { + SeekSpriteAnim(sprite, 6); + } + } + return 0; +} + +void unc_grass_tall(struct Sprite *sprite) +{ + u8 mapNum; + u8 mapGroup; + u8 metatileBehavior; + u8 localId; + u8 eventObjectId; + struct EventObject *eventObject; + + mapNum = sprite->data[5] >> 8; + mapGroup = sprite->data[5]; + if (gCamera.active && (gSaveBlock1Ptr->location.mapNum != mapNum || gSaveBlock1Ptr->location.mapGroup != mapGroup)) + { + sprite->data[1] -= gCamera.x; + sprite->data[2] -= gCamera.y; + sprite->data[5] = ((u8)gSaveBlock1Ptr->location.mapNum << 8) | (u8)gSaveBlock1Ptr->location.mapGroup; + } + localId = sprite->data[3] >> 8; + mapNum = sprite->data[3]; + mapGroup = sprite->data[4]; + metatileBehavior = MapGridGetMetatileBehaviorAt(sprite->data[1], sprite->data[2]); + if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId) || !MetatileBehavior_IsLongGrass(metatileBehavior) || (sprite->data[7] && sprite->animEnded)) + { + FieldEffectStop(sprite, FLDEFF_LONG_GRASS); + } + else + { + eventObject = &gEventObjects[eventObjectId]; + if ((eventObject->currentCoords.x != sprite->data[1] || eventObject->currentCoords.y != sprite->data[2]) && (eventObject->previousCoords.x != sprite->data[1] || eventObject->previousCoords.y != sprite->data[2])) + { + sprite->data[7] = TRUE; + } + UpdateEventObjectSpriteVisibility(sprite, 0); + sub_81561FC(sprite, sprite->data[0], 0); + } +} + +u32 sub_81548FC(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[16], 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] = 18; + } + return 0; +} + +u32 sub_815496C(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[30], 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_8154A10(struct Sprite *sprite) +{ + u8 eventObjectId; + s16 x; + s16 y; + const struct EventObjectGraphicsInfo *graphicsInfo; + struct Sprite *linkedSprite; + + if (TryGetEventObjectIdByLocalIdAndMap(sprite->data[0], sprite->data[1], sprite->data[2], &eventObjectId) || !gEventObjects[eventObjectId].inShortGrass) + { + FieldEffectStop(sprite, FLDEFF_SHORT_GRASS); + } + else + { + graphicsInfo = GetEventObjectGraphicsInfo(gEventObjects[eventObjectId].graphicsId); + linkedSprite = &gSprites[gEventObjects[eventObjectId].spriteId]; + y = linkedSprite->pos1.y; + x = linkedSprite->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->pos2.y = (graphicsInfo->height >> 1) - 8; + sprite->subpriority = linkedSprite->subpriority - 1; + sprite->oam.priority = linkedSprite->oam.priority; + UpdateEventObjectSpriteVisibility(sprite, linkedSprite->invisible); + } +} + +u32 sub_8154B04(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[11], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[7] = FLDEFF_SAND_FOOTPRINTS; + StartSpriteAnim(sprite, gFieldEffectArguments[4]); + } + return 0; +} + +u32 sub_8154B78(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[23], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[7] = FLDEFF_DEEP_SAND_FOOTPRINTS; + StartSpriteAnim(sprite, gFieldEffectArguments[4]); + } + return spriteId; +} + +u32 sub_8154BEC(void) +{ + u8 spriteId; + struct Sprite *sprite; + + sub_80930E0((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8); + spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[27], gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]); + if (spriteId != MAX_SPRITES) + { + sprite = &gSprites[spriteId]; + sprite->coordOffsetEnabled = TRUE; + sprite->oam.priority = gFieldEffectArguments[3]; + sprite->data[7] = FLDEFF_BIKE_TIRE_TRACKS; + StartSpriteAnim(sprite, gFieldEffectArguments[4]); + } + return spriteId; +} From 803c2388ce23efebab04c86c6d58dc2d24a49dd2 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 10 Oct 2018 12:02:02 -0400 Subject: [PATCH 2/5] 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 From 7a008a944aaac6e34d6425eb650a1886448395e1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 14:43:19 +0200 Subject: [PATCH 3/5] Move 'blend_palette'.c to util.c --- include/blend_palette.h | 6 ------ include/util.h | 1 + ld_script.txt | 1 - src/battle_anim_80A5C6C.c | 1 - src/battle_anim_80A9C70.c | 2 +- src/battle_factory.c | 2 +- src/battle_gfx_sfx_util.c | 1 - src/battle_transition.c | 2 +- src/blend_palette.c | 19 ------------------- src/contest.c | 1 - src/evolution_scene.c | 2 +- src/hall_of_fame.c | 2 +- src/intro.c | 2 +- src/palette.c | 2 +- src/pokeblock_feed.c | 2 +- src/pokemon_animation.c | 2 +- src/tileset_anims.c | 2 +- src/util.c | 18 ++++++++++++++++++ 18 files changed, 29 insertions(+), 39 deletions(-) delete mode 100644 include/blend_palette.h delete mode 100644 src/blend_palette.c diff --git a/include/blend_palette.h b/include/blend_palette.h deleted file mode 100644 index a00847bc3..000000000 --- a/include/blend_palette.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GUARD_BLEND_PALETTE_H -#define GUARD_BLEND_PALETTE_H - -void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor); - -#endif // GUARD_BLEND_PALETTE_H diff --git a/include/util.h b/include/util.h index 63887b13f..997c8f713 100644 --- a/include/util.h +++ b/include/util.h @@ -13,5 +13,6 @@ int CountTrailingZeroBits(u32 value); u16 CalcCRC16(u8 *data, s32 length); u16 CalcCRC16WithTable(u8 *data, u32 length); u32 CalcByteArraySum(const u8* data, u32 length); +void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor); #endif // GUARD_UTIL_H diff --git a/ld_script.txt b/ld_script.txt index b77c50547..779e1853d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -76,7 +76,6 @@ SECTIONS { src/trig.o(.text); src/random.o(.text); src/util.o(.text); - src/blend_palette.o(.text); src/daycare.o(.text); src/egg_hatch.o(.text); src/battle_interface.o(.text); diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index f4a4946c3..a461d3d1d 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -3,7 +3,6 @@ #include "constants/species.h" #include "battle.h" #include "battle_anim.h" -#include "blend_palette.h" #include "contest.h" #include "data2.h" #include "decompress.h" diff --git a/src/battle_anim_80A9C70.c b/src/battle_anim_80A9C70.c index 1f8a53993..9b9218b1c 100644 --- a/src/battle_anim_80A9C70.c +++ b/src/battle_anim_80A9C70.c @@ -3,7 +3,7 @@ #include "battle_anim.h" #include "constants/battle_anim.h" #include "constants/rgb.h" -#include "blend_palette.h" +#include "util.h" #include "decompress.h" #include "palette.h" #include "sprite.h" diff --git a/src/battle_factory.c b/src/battle_factory.c index 36c5ed2e8..2c8ab1052 100644 --- a/src/battle_factory.c +++ b/src/battle_factory.c @@ -20,7 +20,7 @@ #include "pokemon_summary_screen.h" #include "sound.h" #include "pokedex.h" -#include "blend_palette.h" +#include "util.h" #include "trainer_pokemon_sprites.h" #include "constants/battle_frontier.h" #include "constants/songs.h" diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 80e1574a4..05958395d 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -19,7 +19,6 @@ #include "decompress.h" #include "data2.h" #include "palette.h" -#include "blend_palette.h" #include "contest.h" #include "constants/songs.h" #include "constants/rgb.h" diff --git a/src/battle_transition.c b/src/battle_transition.c index d1d92cb50..fc8c0eeee 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -19,7 +19,7 @@ #include "gpu_regs.h" #include "decompress.h" #include "bg.h" -#include "blend_palette.h" +#include "util.h" struct TransitionData { diff --git a/src/blend_palette.c b/src/blend_palette.c deleted file mode 100644 index c9503388f..000000000 --- a/src/blend_palette.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "global.h" -#include "palette.h" - -void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor) -{ - u16 i; - for (i = 0; i < numEntries; i++) - { - u16 index = i + palOffset; - struct PlttData *data1 = (struct PlttData *)&gPlttBufferUnfaded[index]; - s8 r = data1->r; - s8 g = data1->g; - s8 b = data1->b; - struct PlttData *data2 = (struct PlttData *)&blendColor; - gPlttBufferFaded[index] = ((r + (((data2->r - r) * coeff) >> 4)) << 0) - | ((g + (((data2->g - g) * coeff) >> 4)) << 5) - | ((b + (((data2->b - b) * coeff) >> 4)) << 10); - } -} diff --git a/src/contest.c b/src/contest.c index 8eacc89c3..473f77f9c 100644 --- a/src/contest.c +++ b/src/contest.c @@ -10,7 +10,6 @@ #include "constants/flags.h" #include "battle.h" #include "battle_anim.h" -#include "blend_palette.h" #include "contest.h" #include "data2.h" #include "decompress.h" diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 91ac90b1b..c00aaeb15 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -25,7 +25,7 @@ #include "gpu_regs.h" #include "bg.h" #include "link.h" -#include "blend_palette.h" +#include "util.h" #include "trig.h" struct EvoInfo diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 2b0904672..f2975e739 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -17,7 +17,7 @@ #include "bg.h" #include "constants/species.h" #include "constants/game_stat.h" -#include "blend_palette.h" +#include "util.h" #include "string_util.h" #include "m4a.h" #include "international_string_util.h" diff --git a/src/intro.c b/src/intro.c index e1d61242c..fe5c012b0 100644 --- a/src/intro.c +++ b/src/intro.c @@ -22,7 +22,7 @@ #include "graphics.h" #include "sound.h" #include "constants/species.h" -#include "blend_palette.h" +#include "util.h" #include "title_screen.h" #include "constants/rgb.h" #include "constants/battle_anim.h" diff --git a/src/palette.c b/src/palette.c index fd4ad32ad..1e92f4bba 100644 --- a/src/palette.c +++ b/src/palette.c @@ -1,6 +1,6 @@ #include "global.h" -#include "blend_palette.h" #include "palette.h" +#include "util.h" #include "decompress.h" #include "gpu_regs.h" #include "task.h" diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 1449d4a00..10f7d34d8 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -6,7 +6,7 @@ #include "menu.h" #include "malloc.h" #include "pokemon.h" -#include "blend_palette.h" +#include "util.h" #include "main.h" #include "menu_helpers.h" #include "bg.h" diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index e75f2eeba..6734fce06 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -4,7 +4,7 @@ #include "pokemon_animation.h" #include "trig.h" #include "task.h" -#include "blend_palette.h" +#include "util.h" #include "constants/rgb.h" struct UnkAnimStruct diff --git a/src/tileset_anims.c b/src/tileset_anims.c index 454a2e435..f7c3cd482 100644 --- a/src/tileset_anims.c +++ b/src/tileset_anims.c @@ -1,7 +1,7 @@ // Includes #include "global.h" #include "palette.h" -#include "blend_palette.h" +#include "util.h" #include "battle_transition.h" #include "task.h" #include "battle_transition.h" diff --git a/src/util.c b/src/util.c index 9c8766a97..47112774a 100644 --- a/src/util.c +++ b/src/util.c @@ -1,6 +1,7 @@ #include "global.h" #include "util.h" #include "sprite.h" +#include "palette.h" const u32 gBitTable[] = { @@ -258,3 +259,20 @@ u32 CalcByteArraySum(const u8* data, u32 length) sum += data[i]; return sum; } + +void BlendPalette(u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor) +{ + u16 i; + for (i = 0; i < numEntries; i++) + { + u16 index = i + palOffset; + struct PlttData *data1 = (struct PlttData *)&gPlttBufferUnfaded[index]; + s8 r = data1->r; + s8 g = data1->g; + s8 b = data1->b; + struct PlttData *data2 = (struct PlttData *)&blendColor; + gPlttBufferFaded[index] = ((r + (((data2->r - r) * coeff) >> 4)) << 0) + | ((g + (((data2->g - g) * coeff) >> 4)) << 5) + | ((b + (((data2->b - b) * coeff) >> 4)) << 10); + } +} From 541043a66154aab69fa3be85325ebb632707f8c1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 15:04:25 +0200 Subject: [PATCH 4/5] Use defines for text chars --- include/string_util.h | 2 +- include/text.h | 1 + src/string_util.c | 104 +++++++++++++++++++++--------------------- src/text.c | 68 +++++++++++++-------------- 4 files changed, 88 insertions(+), 87 deletions(-) diff --git a/include/string_util.h b/include/string_util.h index f26646082..7b685fcea 100644 --- a/include/string_util.h +++ b/include/string_util.h @@ -24,7 +24,7 @@ u8 *ConvertUIntToDecimalStringN(u8 *dest, u32 value, enum StringConvertMode mode u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 n); u8 *StringExpandPlaceholders(u8 *dest, const u8 *src); u8 *StringBraille(u8 *dest, const u8 *src); -u8 *GetExpandedPlaceholder(u32 id); +const u8 *GetExpandedPlaceholder(u32 id); u8 *StringFill(u8 *dest, u8 c, u16 n); u8 *StringCopyPadded(u8 *dest, const u8 *src, u8 c, u16 n); u8 *StringFillWithTerminator(u8 *dest, u16 n); diff --git a/include/text.h b/include/text.h index e2120efa3..f677f2ced 100644 --- a/include/text.h +++ b/include/text.h @@ -76,6 +76,7 @@ #define CHAR_y 0xED #define CHAR_z 0xEE #define CHAR_SPECIAL_F7 0xF7 +#define CHAR_SPECIAL_F8 0xF8 #define CHAR_SPECIAL_F9 0xF9 #define CHAR_COLON 0xF0 #define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog diff --git a/src/string_util.c b/src/string_util.c index ea50ba5a5..3fbf79d87 100644 --- a/src/string_util.c +++ b/src/string_util.c @@ -20,20 +20,20 @@ static const s32 sPowersOfTen[] = 1000000000, }; -extern u8 gExpandedPlaceholder_Empty[]; -extern u8 gExpandedPlaceholder_Kun[]; -extern u8 gExpandedPlaceholder_Chan[]; -extern u8 gExpandedPlaceholder_Sapphire[]; -extern u8 gExpandedPlaceholder_Ruby[]; -extern u8 gExpandedPlaceholder_Emerald[]; -extern u8 gExpandedPlaceholder_Aqua[]; -extern u8 gExpandedPlaceholder_Magma[]; -extern u8 gExpandedPlaceholder_Archie[]; -extern u8 gExpandedPlaceholder_Maxie[]; -extern u8 gExpandedPlaceholder_Kyogre[]; -extern u8 gExpandedPlaceholder_Groudon[]; -extern u8 gExpandedPlaceholder_Brendan[]; -extern u8 gExpandedPlaceholder_May[]; +extern const u8 gExpandedPlaceholder_Empty[]; +extern const u8 gExpandedPlaceholder_Kun[]; +extern const u8 gExpandedPlaceholder_Chan[]; +extern const u8 gExpandedPlaceholder_Sapphire[]; +extern const u8 gExpandedPlaceholder_Ruby[]; +extern const u8 gExpandedPlaceholder_Emerald[]; +extern const u8 gExpandedPlaceholder_Aqua[]; +extern const u8 gExpandedPlaceholder_Magma[]; +extern const u8 gExpandedPlaceholder_Archie[]; +extern const u8 gExpandedPlaceholder_Maxie[]; +extern const u8 gExpandedPlaceholder_Kyogre[]; +extern const u8 gExpandedPlaceholder_Groudon[]; +extern const u8 gExpandedPlaceholder_Brendan[]; +extern const u8 gExpandedPlaceholder_May[]; u8 *StringCopy10(u8 *dest, const u8 *src) { @@ -348,7 +348,7 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src) { u8 c = *src++; u8 placeholderId; - u8 *expandedString; + const u8 *expandedString; switch (c) { @@ -383,9 +383,9 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src) case EOS: *dest = EOS; return dest; - case 0xFA: - case 0xFB: - case 0xFE: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + case CHAR_NEWLINE: default: *dest++ = c; } @@ -394,8 +394,8 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src) u8 *StringBraille(u8 *dest, const u8 *src) { - u8 setBrailleFont[] = { 0xFC, 0x06, 0x06, 0xFF }; - u8 gotoLine2[] = { 0xFE, 0xFC, 0x0E, 0x02, 0xFF }; + u8 setBrailleFont[] = { EXT_CTRL_CODE_BEGIN, 0x06, 0x06, EOS }; + u8 gotoLine2[] = { CHAR_NEWLINE, EXT_CTRL_CODE_BEGIN, 0x0E, 0x02, EOS }; dest = StringCopy(dest, setBrailleFont); @@ -408,7 +408,7 @@ u8 *StringBraille(u8 *dest, const u8 *src) case EOS: *dest = c; return dest; - case 0xFE: + case CHAR_NEWLINE: dest = StringCopy(dest, gotoLine2); break; default: @@ -419,32 +419,32 @@ u8 *StringBraille(u8 *dest, const u8 *src) } } -static u8 *ExpandPlaceholder_UnknownStringVar(void) +static const u8 *ExpandPlaceholder_UnknownStringVar(void) { return gUnknownStringVar; } -static u8 *ExpandPlaceholder_PlayerName(void) +static const u8 *ExpandPlaceholder_PlayerName(void) { return gSaveBlock2Ptr->playerName; } -static u8 *ExpandPlaceholder_StringVar1(void) +static const u8 *ExpandPlaceholder_StringVar1(void) { return gStringVar1; } -static u8 *ExpandPlaceholder_StringVar2(void) +static const u8 *ExpandPlaceholder_StringVar2(void) { return gStringVar2; } -static u8 *ExpandPlaceholder_StringVar3(void) +static const u8 *ExpandPlaceholder_StringVar3(void) { return gStringVar3; } -static u8 *ExpandPlaceholder_KunChan(void) +static const u8 *ExpandPlaceholder_KunChan(void) { if (gSaveBlock2Ptr->playerGender == MALE) return gExpandedPlaceholder_Kun; @@ -452,7 +452,7 @@ static u8 *ExpandPlaceholder_KunChan(void) return gExpandedPlaceholder_Chan; } -static u8 *ExpandPlaceholder_RivalName(void) +static const u8 *ExpandPlaceholder_RivalName(void) { if (gSaveBlock2Ptr->playerGender == MALE) return gExpandedPlaceholder_May; @@ -460,44 +460,44 @@ static u8 *ExpandPlaceholder_RivalName(void) return gExpandedPlaceholder_Brendan; } -static u8 *ExpandPlaceholder_Version(void) +static const u8 *ExpandPlaceholder_Version(void) { return gExpandedPlaceholder_Emerald; } -static u8 *ExpandPlaceholder_Aqua(void) +static const u8 *ExpandPlaceholder_Aqua(void) { return gExpandedPlaceholder_Aqua; } -static u8 *ExpandPlaceholder_Magma(void) +static const u8 *ExpandPlaceholder_Magma(void) { return gExpandedPlaceholder_Magma; } -static u8 *ExpandPlaceholder_Archie(void) +static const u8 *ExpandPlaceholder_Archie(void) { return gExpandedPlaceholder_Archie; } -static u8 *ExpandPlaceholder_Maxie(void) +static const u8 *ExpandPlaceholder_Maxie(void) { return gExpandedPlaceholder_Maxie; } -static u8 *ExpandPlaceholder_Kyogre(void) +static const u8 *ExpandPlaceholder_Kyogre(void) { return gExpandedPlaceholder_Kyogre; } -static u8 *ExpandPlaceholder_Groudon(void) +static const u8 *ExpandPlaceholder_Groudon(void) { return gExpandedPlaceholder_Groudon; } -u8 *GetExpandedPlaceholder(u32 id) +const u8 *GetExpandedPlaceholder(u32 id) { - typedef u8 *(*ExpandPlaceholderFunc)(void); + typedef const u8 *(*ExpandPlaceholderFunc)(void); static const ExpandPlaceholderFunc funcs[] = { @@ -574,7 +574,7 @@ u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n) else { *dest++ = *src++; - if (*(src - 1) == 0xF9) + if (*(src - 1) == CHAR_SPECIAL_F9) *dest++ = *src++; } } @@ -589,7 +589,7 @@ u32 StringLength_Multibyte(u8 *str) while (*str != EOS) { - if (*str == 0xF9) + if (*str == CHAR_SPECIAL_F9) str++; str++; length++; @@ -600,7 +600,7 @@ u32 StringLength_Multibyte(u8 *str) u8 *WriteColorChangeControlCode(u8 *dest, u32 colorType, u8 color) { - *dest = 0xFC; + *dest = EXT_CTRL_CODE_BEGIN; dest++; switch (colorType) @@ -630,7 +630,7 @@ bool32 IsStringJapanese(u8 *str) while (*str != EOS) { if (*str <= 0xA0) - if (*str != 0) + if (*str != CHAR_SPACE) return TRUE; str++; } @@ -645,7 +645,7 @@ bool32 sub_800924C(u8 *str, s32 n) for (i = 0; *str != EOS && i < n; i++) { if (*str <= 0xA0) - if (*str != 0) + if (*str != CHAR_SPACE) return TRUE; str++; } @@ -692,7 +692,7 @@ u8 GetExtCtrlCodeLength(u8 code) static const u8 *SkipExtCtrlCode(const u8 *s) { - while (*s == 0xFC) + while (*s == EXT_CTRL_CODE_BEGIN) { s++; s += GetExtCtrlCodeLength(*s); @@ -716,11 +716,11 @@ s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2) if (*str1 < *str2) { retVal = -1; - if (*str2 == 0xFF) + if (*str2 == EOS) retVal = 1; } - if (*str1 == 0xFF) + if (*str1 == EOS) return retVal; str1++; @@ -729,7 +729,7 @@ s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2) retVal = 1; - if (*str1 == 0xFF) + if (*str1 == EOS) retVal = -1; return retVal; @@ -743,9 +743,9 @@ void ConvertInternationalString(u8 *s, u8 language) StripExtCtrlCodes(s); i = StringLength(s); - s[i++] = 0xFC; + s[i++] = EXT_CTRL_CODE_BEGIN; s[i++] = 22; - s[i++] = 0xFF; + s[i++] = EOS; i--; @@ -755,7 +755,7 @@ void ConvertInternationalString(u8 *s, u8 language) i--; } - s[0] = 0xFC; + s[0] = EXT_CTRL_CODE_BEGIN; s[1] = 21; } } @@ -764,9 +764,9 @@ void StripExtCtrlCodes(u8 *str) { u16 srcIndex = 0; u16 destIndex = 0; - while (str[srcIndex] != 0xFF) + while (str[srcIndex] != EOS) { - if (str[srcIndex] == 0xFC) + if (str[srcIndex] == EXT_CTRL_CODE_BEGIN) { srcIndex++; srcIndex += GetExtCtrlCodeLength(str[srcIndex]); @@ -776,5 +776,5 @@ void StripExtCtrlCodes(u8 *str) str[destIndex++] = str[srcIndex++]; } } - str[destIndex] = 0xFF; + str[destIndex] = EOS; } diff --git a/src/text.c b/src/text.c index e5a9feed8..ec0d26ab1 100644 --- a/src/text.c +++ b/src/text.c @@ -3095,13 +3095,13 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) temp = strLocal[strPos++]; switch (temp) { - case 0xFE: - case 0xFF: + case CHAR_NEWLINE: + case EOS: lineWidths[line] = width; width = 0; line++; break; - case 0xFC: + case EXT_CTRL_CODE_BEGIN: temp2 = strLocal[strPos++]; switch (temp2) { @@ -3135,21 +3135,21 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) break; } break; - case 0xF7: - case 0xFD: + case CHAR_SPECIAL_F7: + case PLACEHOLDER_BEGIN: ++strPos; break; - case 0xFA: - case 0xFB: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: break; - case 0xF8: - case 0xF9: + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: ++strPos; default: ++width; break; } - } while (temp != 0xFF); + } while (temp != EOS); for (width = 0, strPos = 0; strPos < 8; ++strPos) { @@ -3201,16 +3201,16 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) lineWidth = 0; bufferPointer = 0; - while (*str != 0xFF) + while (*str != EOS) { switch (*str) { - case 0xFE: + case CHAR_NEWLINE: if (lineWidth > width) width = lineWidth; lineWidth = 0; break; - case 0xFD: + case PLACEHOLDER_BEGIN: switch (*++str) { case 0x2: @@ -3225,10 +3225,10 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) default: return 0; } - case 0xF7: + case CHAR_SPECIAL_F7: if (bufferPointer == NULL) bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); - while (*bufferPointer != 0xFF) + while (*bufferPointer != EOS) { glyphWidth = func(*bufferPointer++, isJapanese); if (minGlyphWidth > 0) @@ -3240,13 +3240,13 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) else { lineWidth += glyphWidth; - if (isJapanese && str[1] != 0xFF) + if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } } bufferPointer = 0; break; - case 0xFC: + case EXT_CTRL_CODE_BEGIN: switch (*++str) { case 0x4: @@ -3299,9 +3299,9 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) break; } break; - case 0xF8: - case 0xF9: - if (*str == 0xF9) + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + if (*str == CHAR_SPECIAL_F9) glyphWidth = func(*++str | 0x100, isJapanese); else glyphWidth = GetKeypadIconWidth(*++str); @@ -3315,12 +3315,12 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) else { lineWidth += glyphWidth; - if (isJapanese && str[1] != 0xFF) + if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } break; - case 0xFA: - case 0xFB: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: break; default: glyphWidth = func(*str, isJapanese); @@ -3333,7 +3333,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) else { lineWidth += glyphWidth; - if (isJapanese && str[1] != 0xFF) + if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } break; @@ -3372,7 +3372,7 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) temp = strLocal[strPos++]; switch (temp) { - case 0xFC: + case EXT_CTRL_CODE_BEGIN: temp2 = strLocal[strPos++]; switch (temp2) { @@ -3421,16 +3421,16 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) continue; } break; - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFD: + case CHAR_SPECIAL_F7: + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + case PLACEHOLDER_BEGIN: ++strPos; break; - case 0xFA: - case 0xFB: - case 0xFE: - case 0xFF: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + case CHAR_NEWLINE: + case EOS: break; default: switch (fontId) @@ -3450,7 +3450,7 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) break; } } - while (temp != 0xFF); + while (temp != EOS); RestoreTextColors(&colorBackup[0], &colorBackup[1], &colorBackup[2]); return 1; From c3113db931ad406154c3bfd60dc26458e0d5fe3f Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 20:00:14 +0200 Subject: [PATCH 5/5] Move HEAP_SIZE to malloc and use void instead of empty argument list --- include/field_weather.h | 2 +- include/global.h | 2 -- include/malloc.h | 1 + include/palette.h | 2 +- include/party_menu.h | 4 ++-- include/rotating_gate.h | 2 +- src/battle_anim_80A5C6C.c | 2 +- src/field_player_avatar.c | 4 ++-- src/fldeff_sweetscent.c | 2 +- src/item_use.c | 4 ++-- src/task.c | 4 ++-- 11 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/field_weather.h b/include/field_weather.h index 7ad8d21e7..a48361b8a 100644 --- a/include/field_weather.h +++ b/include/field_weather.h @@ -155,7 +155,7 @@ void sub_80AEDBC(void); void SetSav1WeatherFromCurrMapHeader(void); // ... void DoCurrentWeather(void); -void sub_8080750(); +void sub_8080750(void); bool8 IsWeatherNotFadingIn(void); bool8 IsWeatherChangeComplete(void); diff --git a/include/global.h b/include/global.h index 9ae892b5c..3dab84a3a 100644 --- a/include/global.h +++ b/include/global.h @@ -61,8 +61,6 @@ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) -#define HEAP_SIZE 0x1C000 - extern u8 gStringVar1[]; extern u8 gStringVar2[]; extern u8 gStringVar3[]; diff --git a/include/malloc.h b/include/malloc.h index 6efa8fbef..c215f56c0 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -13,6 +13,7 @@ } extern u8 gHeap[]; + void *Alloc(u32 size); void *AllocZeroed(u32 size); void Free(void *pointer); diff --git a/include/palette.h b/include/palette.h index d14fa1fcd..c14e9f453 100644 --- a/include/palette.h +++ b/include/palette.h @@ -55,7 +55,7 @@ bool8 unref_sub_8073D3C(u32, u8, u8, u8, u16); void unref_sub_8073D84(u8, u32 *); void ResetPaletteStructByUid(u16); void ResetPaletteStruct(u8); -void ResetPaletteFadeControl(); +void ResetPaletteFadeControl(void); void unref_sub_8074168(u16); void unref_sub_8074194(u16); void InvertPlttBuffer(u32); diff --git a/include/party_menu.h b/include/party_menu.h index b93b78544..170fcafc1 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -50,8 +50,8 @@ void sub_81B1370(u8 taskId); void display_pokemon_menu_message(u8 windowId); void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); void sub_81B1B5C(void *a, u8 b); -u8 sub_81B1BD4(); -void sub_81B8448(); +u8 sub_81B1BD4(void); +void sub_81B8448(void); void sub_81B8518(u8 unused); u8 sub_81B1360(void); void sub_81B8904(u8 arg0, void (*callback)(void)); diff --git a/include/rotating_gate.h b/include/rotating_gate.h index 2ae26aa5b..fd86a6b04 100644 --- a/include/rotating_gate.h +++ b/include/rotating_gate.h @@ -2,7 +2,7 @@ #define GUARD_ROTATING_GATE_H void RotatingGatePuzzleCameraUpdate(s16, s16); -void RotatingGate_InitPuzzleAndGraphics(); +void RotatingGate_InitPuzzleAndGraphics(void); u32 CheckForRotatingGatePuzzleCollision(u8, s16, s16); bool32 CheckForRotatingGatePuzzleCollisionWithoutAnimation(u8, s16, s16); diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c index a461d3d1d..ebe1718b7 100644 --- a/src/battle_anim_80A5C6C.c +++ b/src/battle_anim_80A5C6C.c @@ -860,7 +860,7 @@ bool8 IsBattlerSpritePresent(u8 battlerId) return FALSE; } -bool8 IsDoubleBattle() +bool8 IsDoubleBattle(void) { return IS_DOUBLE_BATTLE(); } diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index fd315dd98..b9cf7d102 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -285,7 +285,7 @@ void MovementType_Player(struct Sprite *sprite) UpdateEventObjectCurrentMovement(&gEventObjects[sprite->data[0]], sprite, EventObjectCB2_NoMovement2); } -static u8 EventObjectCB2_NoMovement2() +static u8 EventObjectCB2_NoMovement2(void) { return 0; } @@ -375,7 +375,7 @@ static void PlayerAllowForcedMovementIfMovingSameDirection(void) gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_5; } -static bool8 TryDoMetatileBehaviorForcedMovement() +static bool8 TryDoMetatileBehaviorForcedMovement(void) { return gUnknown_08497444[GetForcedMovementByMetatileBehavior()](); } diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index 14da87eb3..f592ed532 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -35,7 +35,7 @@ void hm2_sweet_scent(void) gFieldEffectArguments[0] = GetCursorSelectionMonId(); } -bool8 FldEff_SweetScent() +bool8 FldEff_SweetScent(void) { u8 taskId; diff --git a/src/item_use.c b/src/item_use.c index 67bdabd87..633d975a8 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -203,7 +203,7 @@ u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId) return 0; } -void sub_80FD254() +void sub_80FD254(void) { struct MailStruct mail; mail.itemId = gSpecialVar_ItemId; @@ -249,7 +249,7 @@ void ItemUseOnFieldCB_Bike(u8 taskId) DestroyTask(taskId); } -bool32 CanFish() +bool32 CanFish(void) { s16 x, y; u16 tileBehavior; diff --git a/src/task.c b/src/task.c index fafa7c70d..f067e21b4 100644 --- a/src/task.c +++ b/src/task.c @@ -7,7 +7,7 @@ struct Task gTasks[NUM_TASKS]; static void InsertTask(u8 newTaskId); -static u8 FindFirstActiveTask(); +static u8 FindFirstActiveTask(void); void ResetTasks(void) { @@ -124,7 +124,7 @@ void RunTasks(void) } } -static u8 FindFirstActiveTask() +static u8 FindFirstActiveTask(void) { u8 taskId;