From 73327f0d44195f26d1af8b894326e1b98b609681 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Mon, 11 Jun 2018 10:23:14 -0500 Subject: [PATCH] Decompile field_ground_effect into event_object_movement.c --- asm/field_ground_effect.s | 1821 --------------------------- data/field_ground_effect.s | 63 - include/event_object_movement.h | 26 + include/field_effect_helpers.h | 3 + include/field_ground_effect.h | 24 - include/fieldmap.h | 1 + include/metatile_behavior.h | 2 +- include/pokenav.h | 1 + ld_script.txt | 3 +- src/event_object_movement.c | 724 ++++++++++- src/event_object_movement_helpers.c | 5 +- src/metatile_behavior.c | 3 +- src/overworld.c | 1 - 13 files changed, 758 insertions(+), 1919 deletions(-) delete mode 100644 asm/field_ground_effect.s delete mode 100644 include/field_ground_effect.h diff --git a/asm/field_ground_effect.s b/asm/field_ground_effect.s deleted file mode 100644 index 05f8ffce0..000000000 --- a/asm/field_ground_effect.s +++ /dev/null @@ -1,1821 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start FieldObjectUpdateMetatileBehaviors -@ void FieldObjectUpdateMetatileBehaviors(struct npc_state *fieldObject) -FieldObjectUpdateMetatileBehaviors: @ 8096728 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x14 - ldrsh r0, [r4, r1] - movs r2, 0x16 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - strb r0, [r4, 0x1F] - movs r1, 0x10 - ldrsh r0, [r4, r1] - movs r2, 0x12 - ldrsh r1, [r4, r2] - bl MapGridGetMetatileBehaviorAt - strb r0, [r4, 0x1E] - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldObjectUpdateMetatileBehaviors - - thumb_func_start GetGroundEffectFlags_Reflection -@ void GetGroundEffectFlags_Reflection(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_Reflection: @ 8096750 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, =gUnknown_0850E5DC - ldr r1, [r0, 0x4] - ldr r0, [r0] - str r0, [sp] - str r1, [sp, 0x4] - adds r0, r4, 0 - bl FieldObjectCheckForReflectiveSurface - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0 - beq _08096798 - ldrb r1, [r4, 0x2] - lsls r0, r1, 30 - cmp r0, 0 - blt _080967A2 - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - movs r1, 0x2 - orrs r0, r1 - strb r0, [r4, 0x2] - subs r0, r2, 0x1 - lsls r0, 2 - add r0, sp - ldr r1, [r5] - ldr r0, [r0] - orrs r1, r0 - str r1, [r5] - b _080967A2 - .pool -_08096798: - ldrb r1, [r4, 0x2] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x2] -_080967A2: - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_Reflection - - thumb_func_start GetGroundEffectFlags_TallGrassOnSpawn -@ void GetGroundEffectFlags_TallGrassOnSpawn(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_TallGrassOnSpawn: @ 80967AC - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_IsTallGrass - lsls r0, 24 - cmp r0, 0 - beq _080967C4 - ldr r0, [r4] - movs r1, 0x1 - orrs r0, r1 - str r0, [r4] -_080967C4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_TallGrassOnSpawn - - thumb_func_start GetGroundEffectFlags_TallGrassOnBeginStep -@ void GetGroundEffectFlags_TallGrassOnBeginStep(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_TallGrassOnBeginStep: @ 80967CC - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_IsTallGrass - lsls r0, 24 - cmp r0, 0 - beq _080967E4 - ldr r0, [r4] - movs r1, 0x2 - orrs r0, r1 - str r0, [r4] -_080967E4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_TallGrassOnBeginStep - - thumb_func_start GetGroundEffectFlags_LongGrassOnSpawn -@ void GetGroundEffectFlags_LongGrassOnSpawn(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_LongGrassOnSpawn: @ 80967EC - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_IsLongGrass - lsls r0, 24 - cmp r0, 0 - beq _08096804 - ldr r0, [r4] - movs r1, 0x4 - orrs r0, r1 - str r0, [r4] -_08096804: - pop {r4} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_LongGrassOnSpawn - - thumb_func_start GetGroundEffectFlags_LongGrassOnBeginStep -@ void GetGroundEffectFlags_LongGrassOnBeginStep(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_LongGrassOnBeginStep: @ 809680C - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_IsLongGrass - lsls r0, 24 - cmp r0, 0 - beq _08096824 - ldr r0, [r4] - movs r1, 0x8 - orrs r0, r1 - str r0, [r4] -_08096824: - pop {r4} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_LongGrassOnBeginStep - - thumb_func_start GetGroundEffectFlags_Tracks -@ void GetGroundEffectFlags_Tracks(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_Tracks: @ 809682C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsDeepSand - lsls r0, 24 - cmp r0, 0 - beq _08096846 - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 1 - b _08096862 -_08096846: - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsSandOrDeepSand - lsls r0, 24 - cmp r0, 0 - bne _0809685E - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsUnusedFootprintMetatile - lsls r0, 24 - cmp r0, 0 - beq _08096866 -_0809685E: - ldr r0, [r5] - movs r1, 0x80 -_08096862: - orrs r0, r1 - str r0, [r5] -_08096866: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_Tracks - - thumb_func_start GetGroundEffectFlags_SandHeap -@ void GetGroundEffectFlags_SandHeap(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_SandHeap: @ 809686C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsDeepSand - lsls r0, 24 - cmp r0, 0 - beq _080968AA - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsDeepSand - lsls r0, 24 - cmp r0, 0 - beq _080968AA - ldrb r1, [r4, 0x2] - lsls r0, r1, 27 - cmp r0, 0 - blt _080968B4 - movs r0, 0x11 - negs r0, r0 - ands r0, r1 - movs r1, 0x10 - orrs r0, r1 - strb r0, [r4, 0x2] - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 4 - orrs r0, r1 - str r0, [r5] - b _080968B4 -_080968AA: - ldrb r1, [r4, 0x2] - movs r0, 0x11 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x2] -_080968B4: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_SandHeap - - thumb_func_start GetGroundEffectFlags_ShallowFlowingWater -@ void GetGroundEffectFlags_ShallowFlowingWater(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_ShallowFlowingWater: @ 80968BC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsShallowFlowingWater - lsls r0, 24 - cmp r0, 0 - beq _080968DA - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsShallowFlowingWater - lsls r0, 24 - cmp r0, 0 - bne _080968F2 -_080968DA: - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsPacifidlogLog - lsls r0, 24 - cmp r0, 0 - beq _08096910 - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsPacifidlogLog - lsls r0, 24 - cmp r0, 0 - beq _08096910 -_080968F2: - ldrb r1, [r4, 0x2] - lsls r0, r1, 28 - cmp r0, 0 - blt _0809691A - movs r0, 0x9 - negs r0, r0 - ands r0, r1 - movs r1, 0x8 - orrs r0, r1 - strb r0, [r4, 0x2] - ldr r0, [r5] - movs r1, 0x40 - orrs r0, r1 - str r0, [r5] - b _0809691A -_08096910: - ldrb r1, [r4, 0x2] - movs r0, 0x9 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x2] -_0809691A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_ShallowFlowingWater - - thumb_func_start GetGroundEffectFlags_Puddle -@ void GetGroundEffectFlags_Puddle(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_Puddle: @ 8096920 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsPuddle - lsls r0, 24 - cmp r0, 0 - beq _08096948 - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsPuddle - lsls r0, 24 - cmp r0, 0 - beq _08096948 - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 3 - orrs r0, r1 - str r0, [r5] -_08096948: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_Puddle - - thumb_func_start GetGroundEffectFlags_Ripple -@ void GetGroundEffectFlags_Ripple(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_Ripple: @ 8096950 - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_HasRipples - lsls r0, 24 - cmp r0, 0 - beq _0809696A - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 2 - orrs r0, r1 - str r0, [r4] -_0809696A: - pop {r4} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_Ripple - - thumb_func_start GetGroundEffectFlags_ShortGrass -@ void GetGroundEffectFlags_ShortGrass(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_ShortGrass: @ 8096970 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsShortGrass - lsls r0, 24 - cmp r0, 0 - beq _080969AE - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsShortGrass - lsls r0, 24 - cmp r0, 0 - beq _080969AE - ldrb r1, [r4, 0x2] - lsls r0, r1, 29 - cmp r0, 0 - blt _080969B8 - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4, 0x2] - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 10 - orrs r0, r1 - str r0, [r5] - b _080969B8 -_080969AE: - ldrb r1, [r4, 0x2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x2] -_080969B8: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_ShortGrass - - thumb_func_start GetGroundEffectFlags_HotSprings -@ void GetGroundEffectFlags_HotSprings(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_HotSprings: @ 80969C0 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x1E] - bl MetatileBehavior_IsHotSprings - lsls r0, 24 - cmp r0, 0 - beq _080969FE - ldrb r0, [r4, 0x1F] - bl MetatileBehavior_IsHotSprings - lsls r0, 24 - cmp r0, 0 - beq _080969FE - ldrb r1, [r4, 0x2] - lsls r0, r1, 26 - cmp r0, 0 - blt _08096A08 - movs r0, 0x21 - negs r0, r0 - ands r0, r1 - movs r1, 0x20 - orrs r0, r1 - strb r0, [r4, 0x2] - ldr r0, [r5] - movs r1, 0x80 - lsls r1, 11 - orrs r0, r1 - str r0, [r5] - b _08096A08 -_080969FE: - ldrb r1, [r4, 0x2] - movs r0, 0x21 - negs r0, r0 - ands r0, r1 - strb r0, [r4, 0x2] -_08096A08: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_HotSprings - - thumb_func_start GetGroundEffectFlags_Seaweed -@ void GetGroundEffectFlags_Seaweed(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_Seaweed: @ 8096A10 - push {r4,lr} - adds r4, r1, 0 - ldrb r0, [r0, 0x1E] - bl MetatileBehavior_IsSeaweed - lsls r0, 24 - cmp r0, 0 - beq _08096A2A - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 12 - orrs r0, r1 - str r0, [r4] -_08096A2A: - pop {r4} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_Seaweed - - thumb_func_start GetGroundEffectFlags_JumpLanding -@ void GetGroundEffectFlags_JumpLanding(struct npc_state *fieldObject, u32 *flags) -GetGroundEffectFlags_JumpLanding: @ 8096A30 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r7, r0, 0 - adds r6, r1, 0 - ldr r0, [r7] - ldr r1, =0x02000020 - ands r0, r1 - cmp r0, 0x20 - bne _08096A82 - movs r5, 0 - ldr r0, =gUnknown_0850E5E4 - mov r8, r0 -_08096A4A: - lsls r4, r5, 2 - mov r0, r8 - adds r1, r4, r0 - ldrb r0, [r7, 0x1E] - ldr r1, [r1] - bl _call_via_r1 - lsls r0, 24 - cmp r0, 0 - beq _08096A78 - ldr r0, =gUnknown_0850E5FC - adds r0, r4, r0 - ldr r1, [r6] - ldr r0, [r0] - orrs r1, r0 - str r1, [r6] - b _08096A82 - .pool -_08096A78: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _08096A4A -_08096A82: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end GetGroundEffectFlags_JumpLanding - - thumb_func_start FieldObjectCheckForReflectiveSurface -@ u8 FieldObjectCheckForReflectiveSurface(struct npc_state *fieldObject) -FieldObjectCheckForReflectiveSurface: @ 8096A8C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r5, r0, 0 - ldrb r0, [r5, 0x5] - bl GetFieldObjectGraphicsInfo - movs r2, 0x8 - ldrsh r1, [r0, r2] - adds r1, 0x8 - lsls r1, 12 - lsrs r1, 16 - str r1, [sp] - movs r1, 0xA - ldrsh r0, [r0, r1] - adds r0, 0x8 - lsls r0, 12 - movs r4, 0 - lsrs r2, r0, 16 - str r2, [sp, 0x4] - asrs r0, 16 - cmp r4, r0 - blt _08096AC2 - b _08096BC8 -_08096AC2: - movs r0, 0x1 - mov r10, r0 -_08096AC6: - movs r1, 0x10 - ldrsh r0, [r5, r1] - movs r2, 0x12 - ldrsh r1, [r5, r2] - add r1, r10 - lsls r4, 16 - asrs r6, r4, 16 - adds r1, r6 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl GetReflectionTypeByMetatileBehavior - lsls r0, 24 - lsrs r0, 24 - mov r9, r4 - cmp r0, 0 - bne _08096BCA - movs r1, 0x14 - ldrsh r0, [r5, r1] - movs r2, 0x16 - ldrsh r1, [r5, r2] - add r1, r10 - adds r1, r6 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl GetReflectionTypeByMetatileBehavior - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08096BCA - movs r2, 0x1 - ldr r1, [sp] - lsls r0, r1, 16 - asrs r1, r0, 16 - mov r8, r0 - cmp r2, r1 - bge _08096BB6 - movs r0, 0x80 - lsls r0, 9 - asrs r7, r0, 16 -_08096B20: - movs r1, 0x10 - ldrsh r0, [r5, r1] - lsls r1, r2, 16 - asrs r4, r1, 16 - adds r0, r4 - movs r2, 0x12 - ldrsh r1, [r5, r2] - adds r1, r7 - adds r1, r6 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl GetReflectionTypeByMetatileBehavior - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08096BCA - movs r1, 0x10 - ldrsh r0, [r5, r1] - subs r0, r4 - movs r2, 0x12 - ldrsh r1, [r5, r2] - adds r1, r7 - adds r1, r6 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl GetReflectionTypeByMetatileBehavior - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08096BCA - movs r1, 0x14 - ldrsh r0, [r5, r1] - adds r0, r4 - movs r2, 0x16 - ldrsh r1, [r5, r2] - adds r1, r7 - adds r1, r6 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl GetReflectionTypeByMetatileBehavior - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08096BCA - movs r1, 0x14 - ldrsh r0, [r5, r1] - subs r0, r4 - movs r2, 0x16 - ldrsh r1, [r5, r2] - adds r1, r7 - adds r1, r6 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - bl GetReflectionTypeByMetatileBehavior - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _08096BCA - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - cmp r0, r8 - blt _08096B20 -_08096BB6: - movs r1, 0x80 - lsls r1, 9 - add r1, r9 - lsrs r4, r1, 16 - ldr r2, [sp, 0x4] - lsls r0, r2, 16 - cmp r1, r0 - bge _08096BC8 - b _08096AC6 -_08096BC8: - movs r0, 0 -_08096BCA: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end FieldObjectCheckForReflectiveSurface - - thumb_func_start GetReflectionTypeByMetatileBehavior -@ u8 GetReflectionTypeByMetatileBehavior(u8 metatileBehavior) -GetReflectionTypeByMetatileBehavior: @ 8096BDC - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl MetatileBehavior_IsIce - lsls r0, 24 - cmp r0, 0 - beq _08096BF2 - movs r0, 0x1 - b _08096C04 -_08096BF2: - adds r0, r4, 0 - bl MetatileBehavior_IsReflective - lsls r0, 24 - cmp r0, 0 - bne _08096C02 - movs r0, 0 - b _08096C04 -_08096C02: - movs r0, 0x2 -_08096C04: - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetReflectionTypeByMetatileBehavior - - thumb_func_start GetLedgeJumpDirection -@ u8 GetLedgeJumpDirection(u16 x, u16 y, u8 direction) -GetLedgeJumpDirection: @ 8096C0C - push {r4,lr} - lsls r0, 16 - lsrs r3, r0, 16 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 24 - lsrs r4, r2, 24 - cmp r4, 0 - beq _08096C52 - cmp r4, 0x4 - bls _08096C28 - subs r0, r4, 0x4 - lsls r0, 24 - lsrs r4, r0, 24 -_08096C28: - subs r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r3, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl MapGridGetMetatileBehaviorAt - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gUnknown_0850E614 - lsls r1, r4, 2 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08096C5C -_08096C52: - movs r0, 0 - b _08096C62 - .pool -_08096C5C: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r0, 24 -_08096C62: - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetLedgeJumpDirection - - thumb_func_start FieldObjectSetSpriteOamTableForLongGrass -@ void FieldObjectSetSpriteOamTableForLongGrass(struct npc_state *fieldObject, struct obj *object) -FieldObjectSetSpriteOamTableForLongGrass: @ 8096C68 - push {r4-r6,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldrb r0, [r5] - lsls r0, 27 - cmp r0, 0 - blt _08096CBC - ldrb r0, [r5, 0x1E] - bl MetatileBehavior_IsLongGrass - lsls r0, 24 - cmp r0, 0 - beq _08096CBC - ldrb r0, [r5, 0x1F] - bl MetatileBehavior_IsLongGrass - lsls r0, 24 - cmp r0, 0 - beq _08096CBC - adds r4, 0x42 - ldrb r1, [r4] - movs r6, 0x40 - negs r6, r6 - adds r0, r6, 0 - ands r0, r1 - movs r1, 0x4 - orrs r0, r1 - strb r0, [r4] - ldrb r0, [r5, 0xB] - lsrs r0, 4 - bl ZCoordToPriority - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08096CBC - ldrb r0, [r4] - adds r1, r6, 0 - ands r1, r0 - movs r0, 0x5 - orrs r1, r0 - strb r1, [r4] -_08096CBC: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end FieldObjectSetSpriteOamTableForLongGrass - - thumb_func_start IsZCoordMismatchAt -@ bool8 IsZCoordMismatchAt(u8 z, u16 x, u16 y) -IsZCoordMismatchAt: @ 8096CC4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 16 - lsrs r0, r1, 16 - lsls r2, 16 - lsrs r1, r2, 16 - cmp r4, 0 - beq _08096CF2 - lsls r0, 16 - asrs r0, 16 - lsls r1, 16 - asrs r1, 16 - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - beq _08096CF2 - cmp r0, 0xF - beq _08096CF2 - cmp r0, r4 - bne _08096CF6 -_08096CF2: - movs r0, 0 - b _08096CF8 -_08096CF6: - movs r0, 0x1 -_08096CF8: - pop {r4} - pop {r1} - bx r1 - thumb_func_end IsZCoordMismatchAt - - thumb_func_start FieldObjectUpdateZCoordAndPriority -@ void FieldObjectUpdateZCoordAndPriority(struct npc_state *fieldObject, struct obj *object) -FieldObjectUpdateZCoordAndPriority: @ 8096D00 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x3] - lsls r0, 29 - cmp r0, 0 - blt _08096D4E - adds r0, r4, 0 - bl FieldObjectUpdateZCoord - ldr r1, =gUnknown_0850E644 - ldrb r2, [r4, 0xB] - lsls r2, 24 - lsrs r0, r2, 28 - adds r0, r1 - ldrb r0, [r0] - adds r4, r5, 0 - adds r4, 0x42 - movs r1, 0x3F - ands r1, r0 - ldrb r3, [r4] - movs r0, 0x40 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4] - ldr r0, =gUnknown_0850E634 - lsrs r2, 28 - adds r2, r0 - movs r0, 0x3 - ldrb r1, [r2] - ands r1, r0 - lsls r1, 2 - ldrb r2, [r5, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - orrs r0, r1 - strb r0, [r5, 0x5] -_08096D4E: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectUpdateZCoordAndPriority - - thumb_func_start InitObjectPriorityByZCoord -@ void InitObjectPriorityByZCoord(struct obj *object, u8 z) -InitObjectPriorityByZCoord: @ 8096D5C - push {r4,lr} - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gUnknown_0850E644 - adds r2, r1, r2 - ldrb r2, [r2] - movs r3, 0x42 - adds r3, r0 - mov r12, r3 - movs r3, 0x3F - ands r3, r2 - mov r2, r12 - ldrb r4, [r2] - movs r2, 0x40 - negs r2, r2 - ands r2, r4 - orrs r2, r3 - mov r3, r12 - strb r2, [r3] - ldr r2, =gUnknown_0850E634 - adds r1, r2 - movs r3, 0x3 - ldrb r2, [r1] - ands r2, r3 - lsls r2, 2 - ldrb r3, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r3 - orrs r1, r2 - strb r1, [r0, 0x5] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end InitObjectPriorityByZCoord - - thumb_func_start ZCoordToPriority -@ u8 ZCoordToPriority(u8 z) -ZCoordToPriority: @ 8096DA8 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0850E634 - adds r0, r1 - ldrb r0, [r0] - bx lr - .pool - thumb_func_end ZCoordToPriority - - thumb_func_start FieldObjectUpdateZCoord -@ void FieldObjectUpdateZCoord(struct npc_state *fieldObject) -FieldObjectUpdateZCoord: @ 8096DB8 - push {r4,r5,lr} - adds r4, r0, 0 - movs r1, 0x10 - ldrsh r0, [r4, r1] - movs r2, 0x12 - ldrsh r1, [r4, r2] - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r5, r0, 24 - movs r1, 0x14 - ldrsh r0, [r4, r1] - movs r2, 0x16 - ldrsh r1, [r4, r2] - bl MapGridGetZCoordAt - lsls r0, 24 - lsrs r0, 24 - cmp r5, 0xF - beq _08096E06 - cmp r0, 0xF - beq _08096E06 - movs r3, 0xF - adds r0, r5, 0 - ands r0, r3 - ldrb r1, [r4, 0xB] - movs r2, 0x10 - negs r2, r2 - ands r2, r1 - orrs r2, r0 - strb r2, [r4, 0xB] - cmp r5, 0 - beq _08096E06 - cmp r5, 0xF - beq _08096E06 - lsls r0, r5, 4 - ands r2, r3 - orrs r2, r0 - strb r2, [r4, 0xB] -_08096E06: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldObjectUpdateZCoord - - thumb_func_start SetObjectSubpriorityByZCoord -@ void SetObjectSubpriorityByZCoord(u8 z, struct obj *object, u8 offset) -SetObjectSubpriorityByZCoord: @ 8096E0C - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - adds r3, r1, 0 - adds r3, 0x29 - movs r5, 0 - ldrsb r5, [r3, r5] - ldrh r4, [r1, 0x22] - ldr r3, =gSpriteCoordOffsetY - subs r4, r5 - ldrh r3, [r3] - adds r4, r3 - adds r4, 0x8 - movs r3, 0xFF - ands r4, r3 - lsrs r4, 4 - movs r3, 0x10 - subs r3, r4 - lsls r3, 17 - ldr r4, =gUnknown_0850E624 - adds r0, r4 - lsrs r3, 16 - ldrb r0, [r0] - adds r3, r0 - adds r2, r3 - adds r1, 0x43 - strb r2, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end SetObjectSubpriorityByZCoord - - thumb_func_start FieldObjectUpdateSubpriority -@ void FieldObjectUpdateSubpriority(struct npc_state *fieldObject, struct obj *object) -FieldObjectUpdateSubpriority: @ 8096E54 - push {lr} - adds r2, r0, 0 - ldrb r0, [r2, 0x3] - lsls r0, 29 - cmp r0, 0 - blt _08096E6A - ldrb r0, [r2, 0xB] - lsrs r0, 4 - movs r2, 0x1 - bl SetObjectSubpriorityByZCoord -_08096E6A: - pop {r0} - bx r0 - thumb_func_end FieldObjectUpdateSubpriority - - thumb_func_start AreZCoordsCompatible -@ bool8 AreZCoordsCompatible(u8 z1, u8 z2) -AreZCoordsCompatible: @ 8096E70 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - cmp r0, 0 - beq _08096E86 - cmp r1, 0 - beq _08096E86 - cmp r0, r1 - bne _08096E8A -_08096E86: - movs r0, 0x1 - b _08096E8C -_08096E8A: - movs r0, 0 -_08096E8C: - pop {r1} - bx r1 - thumb_func_end AreZCoordsCompatible - - thumb_func_start GroundEffect_SpawnOnTallGrass -@ void GroundEffect_SpawnOnTallGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_SpawnOnTallGrass: @ 8096E90 - push {lr} - ldr r3, =gFieldEffectArguments - movs r2, 0x10 - ldrsh r1, [r0, r2] - str r1, [r3] - movs r2, 0x12 - ldrsh r1, [r0, r2] - str r1, [r3, 0x4] - ldrb r1, [r0, 0xB] - lsrs r1, 4 - str r1, [r3, 0x8] - movs r1, 0x2 - str r1, [r3, 0xC] - ldrb r1, [r0, 0x8] - lsls r1, 8 - ldrb r2, [r0, 0x9] - orrs r1, r2 - str r1, [r3, 0x10] - ldrb r0, [r0, 0xA] - str r0, [r3, 0x14] - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldrb r0, [r1, 0x5] - lsls r0, 8 - ldrb r1, [r1, 0x4] - orrs r0, r1 - str r0, [r3, 0x18] - movs r0, 0x1 - str r0, [r3, 0x1C] - movs r0, 0x4 - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_SpawnOnTallGrass - - thumb_func_start GroundEffect_StepOnTallGrass -@ void GroundEffect_StepOnTallGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_StepOnTallGrass: @ 8096EDC - push {lr} - ldr r3, =gFieldEffectArguments - movs r2, 0x10 - ldrsh r1, [r0, r2] - str r1, [r3] - movs r2, 0x12 - ldrsh r1, [r0, r2] - str r1, [r3, 0x4] - ldrb r1, [r0, 0xB] - lsrs r1, 4 - str r1, [r3, 0x8] - movs r1, 0x2 - str r1, [r3, 0xC] - ldrb r1, [r0, 0x8] - lsls r1, 8 - ldrb r2, [r0, 0x9] - orrs r1, r2 - str r1, [r3, 0x10] - ldrb r0, [r0, 0xA] - str r0, [r3, 0x14] - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldrb r0, [r1, 0x5] - lsls r0, 8 - ldrb r1, [r1, 0x4] - orrs r0, r1 - str r0, [r3, 0x18] - movs r0, 0 - str r0, [r3, 0x1C] - movs r0, 0x4 - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_StepOnTallGrass - - thumb_func_start GroundEffect_SpawnOnLongGrass -@ void GroundEffect_SpawnOnLongGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_SpawnOnLongGrass: @ 8096F28 - push {lr} - ldr r3, =gFieldEffectArguments - movs r2, 0x10 - ldrsh r1, [r0, r2] - str r1, [r3] - movs r2, 0x12 - ldrsh r1, [r0, r2] - str r1, [r3, 0x4] - ldrb r1, [r0, 0xB] - lsrs r1, 4 - str r1, [r3, 0x8] - movs r1, 0x2 - str r1, [r3, 0xC] - ldrb r1, [r0, 0x8] - lsls r1, 8 - ldrb r2, [r0, 0x9] - orrs r1, r2 - str r1, [r3, 0x10] - ldrb r0, [r0, 0xA] - str r0, [r3, 0x14] - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldrb r0, [r1, 0x5] - lsls r0, 8 - ldrb r1, [r1, 0x4] - orrs r0, r1 - str r0, [r3, 0x18] - movs r0, 0x1 - str r0, [r3, 0x1C] - movs r0, 0x11 - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_SpawnOnLongGrass - - thumb_func_start GroundEffect_StepOnLongGrass -@ void GroundEffect_StepOnLongGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_StepOnLongGrass: @ 8096F74 - push {lr} - ldr r3, =gFieldEffectArguments - movs r2, 0x10 - ldrsh r1, [r0, r2] - str r1, [r3] - movs r2, 0x12 - ldrsh r1, [r0, r2] - str r1, [r3, 0x4] - ldrb r1, [r0, 0xB] - lsrs r1, 4 - str r1, [r3, 0x8] - movs r1, 0x2 - str r1, [r3, 0xC] - ldrb r1, [r0, 0x8] - lsls r1, 8 - ldrb r2, [r0, 0x9] - orrs r1, r2 - str r1, [r3, 0x10] - ldrb r0, [r0, 0xA] - str r0, [r3, 0x14] - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldrb r0, [r1, 0x5] - lsls r0, 8 - ldrb r1, [r1, 0x4] - orrs r0, r1 - str r0, [r3, 0x18] - movs r0, 0 - str r0, [r3, 0x1C] - movs r0, 0x11 - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_StepOnLongGrass - - thumb_func_start GroundEffect_WaterReflection -@ void GroundEffect_WaterReflection(struct npc_state *fieldObject, struct obj *object) -GroundEffect_WaterReflection: @ 8096FC0 - push {lr} - movs r2, 0 - bl SetUpReflection - pop {r0} - bx r0 - thumb_func_end GroundEffect_WaterReflection - - thumb_func_start GroundEffect_IceReflection -@ void GroundEffect_IceReflection(struct npc_state *fieldObject, struct obj *object) -GroundEffect_IceReflection: @ 8096FCC - push {lr} - movs r2, 0x1 - bl SetUpReflection - pop {r0} - bx r0 - thumb_func_end GroundEffect_IceReflection - - thumb_func_start GroundEffect_FlowingWater -@ void GroundEffect_FlowingWater(struct npc_state *fieldObject, struct obj *object) -GroundEffect_FlowingWater: @ 8096FD8 - push {lr} - adds r1, r0, 0 - movs r0, 0x22 - bl oe_exec_and_other_stuff - pop {r0} - bx r0 - thumb_func_end GroundEffect_FlowingWater - - thumb_func_start GroundEffect_SandTracks -@ void GroundEffect_SandTracks(struct npc_state *fieldObject, struct obj *object) -GroundEffect_SandTracks: @ 8096FE8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x5] - bl GetFieldObjectGraphicsInfo - ldr r1, =gUnknown_0850E654 - ldrb r0, [r0, 0xD] - lsls r0, 2 - adds r0, r1 - ldr r3, [r0] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0 - bl _call_via_r3 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_SandTracks - - thumb_func_start GroundEffect_DeepSandTracks -@ void GroundEffect_DeepSandTracks(struct npc_state *fieldObject, struct obj *object) -GroundEffect_DeepSandTracks: @ 8097014 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x5] - bl GetFieldObjectGraphicsInfo - ldr r1, =gUnknown_0850E654 - ldrb r0, [r0, 0xD] - lsls r0, 2 - adds r0, r1 - ldr r3, [r0] - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl _call_via_r3 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_DeepSandTracks - - thumb_func_start DoTracksGroundEffect_None -@ void DoTracksGroundEffect_None(struct npc_state *fieldObject, struct obj *object) -DoTracksGroundEffect_None: @ 8097040 - bx lr - thumb_func_end DoTracksGroundEffect_None - - thumb_func_start DoTracksGroundEffect_Footprints -@ void DoTracksGroundEffect_Footprints(struct npc_state *fieldObject, struct obj *object) -DoTracksGroundEffect_Footprints: @ 8097044 - push {r4,r5,lr} - sub sp, 0x4 - adds r5, r0, 0 - lsls r4, r2, 24 - lsrs r4, 24 - ldr r1, =gUnknown_0850E660 - mov r0, sp - movs r2, 0x4 - bl memcpy - ldr r1, =gFieldEffectArguments - movs r2, 0x14 - ldrsh r0, [r5, r2] - str r0, [r1] - movs r2, 0x16 - ldrsh r0, [r5, r2] - str r0, [r1, 0x4] - movs r0, 0x95 - str r0, [r1, 0x8] - movs r0, 0x2 - str r0, [r1, 0xC] - ldrb r0, [r5, 0x18] - lsls r0, 28 - lsrs r0, 28 - str r0, [r1, 0x10] - lsls r4, 1 - mov r1, sp - adds r0, r1, r4 - ldrb r0, [r0] - bl FieldEffectStart - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end DoTracksGroundEffect_Footprints - - thumb_func_start DoTracksGroundEffect_BikeTireTracks -@ void DoTracksGroundEffect_BikeTireTracks(struct npc_state *fieldObject, struct obj *object) -DoTracksGroundEffect_BikeTireTracks: @ 8097094 - push {r4,lr} - adds r4, r0, 0 - ldr r1, [r4, 0x10] - ldr r0, [r4, 0x14] - cmp r1, r0 - beq _080970D6 - ldr r2, =gFieldEffectArguments - movs r1, 0x14 - ldrsh r0, [r4, r1] - str r0, [r2] - movs r1, 0x16 - ldrsh r0, [r4, r1] - str r0, [r2, 0x4] - movs r0, 0x95 - str r0, [r2, 0x8] - movs r0, 0x2 - str r0, [r2, 0xC] - ldr r3, =gUnknown_0850E664 - ldrb r1, [r4, 0x18] - lsls r1, 28 - lsrs r1, 28 - adds r0, r4, 0 - adds r0, 0x20 - ldrb r0, [r0] - lsls r0, 2 - subs r0, 0x5 - adds r1, r0 - adds r1, r3 - ldrb r0, [r1] - str r0, [r2, 0x10] - movs r0, 0x23 - bl FieldEffectStart -_080970D6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end DoTracksGroundEffect_BikeTireTracks - - thumb_func_start GroundEffect_Ripple -@ void GroundEffect_Ripple(struct npc_state *fieldObject, struct obj *object) -GroundEffect_Ripple: @ 80970E4 - push {lr} - bl DoRippleFieldEffect - pop {r0} - bx r0 - thumb_func_end GroundEffect_Ripple - - thumb_func_start GroundEffect_StepOnPuddle -@ void GroundEffect_StepOnPuddle(struct npc_state *fieldObject, struct obj *object) -GroundEffect_StepOnPuddle: @ 80970F0 - push {lr} - adds r1, r0, 0 - movs r0, 0xF - bl oe_exec_and_other_stuff - pop {r0} - bx r0 - thumb_func_end GroundEffect_StepOnPuddle - - thumb_func_start GroundEffect_SandHeap -@ void GroundEffect_SandHeap(struct npc_state *fieldObject, struct obj *object) -GroundEffect_SandHeap: @ 8097100 - push {lr} - adds r1, r0, 0 - movs r0, 0x27 - bl oe_exec_and_other_stuff - pop {r0} - bx r0 - thumb_func_end GroundEffect_SandHeap - - thumb_func_start GroundEffect_JumpOnTallGrass -@ void GroundEffect_JumpOnTallGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_JumpOnTallGrass: @ 8097110 - push {r4-r7,lr} - sub sp, 0x4 - adds r5, r0, 0 - adds r6, r1, 0 - ldr r1, =gFieldEffectArguments - movs r2, 0x10 - ldrsh r0, [r5, r2] - str r0, [r1] - movs r4, 0x12 - ldrsh r0, [r5, r4] - str r0, [r1, 0x4] - ldrb r0, [r5, 0xB] - lsrs r0, 4 - str r0, [r1, 0x8] - movs r0, 0x2 - str r0, [r1, 0xC] - movs r0, 0xC - bl FieldEffectStart - ldrb r0, [r5, 0x8] - ldrb r1, [r5, 0x9] - ldrb r2, [r5, 0xA] - movs r7, 0x10 - ldrsh r3, [r5, r7] - movs r7, 0x12 - ldrsh r4, [r5, r7] - str r4, [sp] - bl sub_81546C8 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x40 - bne _0809715A - adds r0, r5, 0 - adds r1, r6, 0 - bl GroundEffect_SpawnOnTallGrass -_0809715A: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_JumpOnTallGrass - - thumb_func_start GroundEffect_JumpOnLongGrass -@ void GroundEffect_JumpOnLongGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_JumpOnLongGrass: @ 8097168 - push {lr} - ldr r2, =gFieldEffectArguments - movs r3, 0x10 - ldrsh r1, [r0, r3] - str r1, [r2] - movs r3, 0x12 - ldrsh r1, [r0, r3] - str r1, [r2, 0x4] - ldrb r0, [r0, 0xB] - lsrs r0, 4 - str r0, [r2, 0x8] - movs r0, 0x2 - str r0, [r2, 0xC] - movs r0, 0x12 - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_JumpOnLongGrass - - thumb_func_start GroundEffect_JumpOnShallowWater -@ void GroundEffect_JumpOnShallowWater(struct npc_state *fieldObject, struct obj *object) -GroundEffect_JumpOnShallowWater: @ 8097190 - push {r4,lr} - ldr r3, =gFieldEffectArguments - movs r4, 0x10 - ldrsh r2, [r0, r4] - str r2, [r3] - movs r4, 0x12 - ldrsh r2, [r0, r4] - str r2, [r3, 0x4] - ldrb r0, [r0, 0xB] - lsrs r0, 4 - str r0, [r3, 0x8] - ldrb r0, [r1, 0x5] - lsls r0, 28 - lsrs r0, 30 - str r0, [r3, 0xC] - movs r0, 0x10 - bl FieldEffectStart - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_JumpOnShallowWater - - thumb_func_start GroundEffect_JumpOnWater -@ void GroundEffect_JumpOnWater(struct npc_state *fieldObject, struct obj *object) -GroundEffect_JumpOnWater: @ 80971C0 - push {r4,lr} - ldr r3, =gFieldEffectArguments - movs r4, 0x10 - ldrsh r2, [r0, r4] - str r2, [r3] - movs r4, 0x12 - ldrsh r2, [r0, r4] - str r2, [r3, 0x4] - ldrb r0, [r0, 0xB] - lsrs r0, 4 - str r0, [r3, 0x8] - ldrb r0, [r1, 0x5] - lsls r0, 28 - lsrs r0, 30 - str r0, [r3, 0xC] - movs r0, 0xE - bl FieldEffectStart - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_JumpOnWater - - thumb_func_start GroundEffect_JumpLandingDust -@ void GroundEffect_JumpLandingDust(struct npc_state *fieldObject, struct obj *object) -GroundEffect_JumpLandingDust: @ 80971F0 - push {r4,lr} - ldr r3, =gFieldEffectArguments - movs r4, 0x10 - ldrsh r2, [r0, r4] - str r2, [r3] - movs r4, 0x12 - ldrsh r2, [r0, r4] - str r2, [r3, 0x4] - ldrb r0, [r0, 0xB] - lsrs r0, 4 - str r0, [r3, 0x8] - ldrb r0, [r1, 0x5] - lsls r0, 28 - lsrs r0, 30 - str r0, [r3, 0xC] - movs r0, 0xA - bl FieldEffectStart - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_JumpLandingDust - - thumb_func_start GroundEffect_ShortGrass -@ void GroundEffect_ShortGrass(struct npc_state *fieldObject, struct obj *object) -GroundEffect_ShortGrass: @ 8097220 - push {lr} - adds r1, r0, 0 - movs r0, 0x29 - bl oe_exec_and_other_stuff - pop {r0} - bx r0 - thumb_func_end GroundEffect_ShortGrass - - thumb_func_start GroundEffect_HotSprings -@ void GroundEffect_HotSprings(struct npc_state *fieldObject, struct obj *object) -GroundEffect_HotSprings: @ 8097230 - push {lr} - adds r1, r0, 0 - movs r0, 0x2A - bl oe_exec_and_other_stuff - pop {r0} - bx r0 - thumb_func_end GroundEffect_HotSprings - - thumb_func_start GroundEffect_Seaweed -@ void GroundEffect_Seaweed(struct npc_state *fieldObject, struct obj *object) -GroundEffect_Seaweed: @ 8097240 - push {lr} - ldr r2, =gFieldEffectArguments - movs r3, 0x10 - ldrsh r1, [r0, r3] - str r1, [r2] - movs r1, 0x12 - ldrsh r0, [r0, r1] - str r0, [r2, 0x4] - movs r0, 0x35 - bl FieldEffectStart - pop {r0} - bx r0 - .pool - thumb_func_end GroundEffect_Seaweed - - thumb_func_start DoFlaggedGroundEffects -@ void DoFlaggedGroundEffects(struct npc_state *fieldObject, struct obj *object, u32 flags) -DoFlaggedGroundEffects: @ 8097260 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - adds r7, r1, 0 - adds r5, r2, 0 - bl FieldObjectIsFarawayIslandMew - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08097284 - adds r0, r6, 0 - bl sub_81D4A58 - lsls r0, 24 - cmp r0, 0 - beq _080972AC -_08097284: - movs r4, 0 - ldr r0, =gUnknown_0850E674 - mov r8, r0 -_0809728A: - movs r0, 0x1 - ands r0, r5 - cmp r0, 0 - beq _080972A0 - lsls r0, r4, 2 - add r0, r8 - ldr r2, [r0] - adds r0, r6, 0 - adds r1, r7, 0 - bl _call_via_r2 -_080972A0: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - lsrs r5, 1 - cmp r4, 0x13 - bls _0809728A -_080972AC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end DoFlaggedGroundEffects - - thumb_func_start filters_out_some_ground_effects -@ void filters_out_some_ground_effects(struct npc_state *fieldObject, u32 *flags) -filters_out_some_ground_effects: @ 80972BC - push {lr} - adds r2, r0, 0 - adds r3, r1, 0 - ldrb r0, [r2] - lsls r0, 27 - cmp r0, 0 - bge _080972EA - ldrb r1, [r2, 0x2] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - movs r1, 0x11 - negs r1, r1 - ands r0, r1 - adds r1, 0x8 - ands r0, r1 - subs r1, 0x18 - ands r0, r1 - strb r0, [r2, 0x2] - ldr r0, [r3] - ldr r1, =0xfff9f7bd - ands r0, r1 - str r0, [r3] -_080972EA: - pop {r0} - bx r0 - .pool - thumb_func_end filters_out_some_ground_effects - - thumb_func_start FilterOutStepOnPuddleGroundEffectIfJumping -@ void FilterOutStepOnPuddleGroundEffectIfJumping(struct npc_state *fieldObject, u32 *flags) -FilterOutStepOnPuddleGroundEffectIfJumping: @ 80972F4 - push {lr} - adds r2, r1, 0 - ldrb r0, [r0] - lsls r0, 26 - cmp r0, 0 - bge _08097308 - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] -_08097308: - pop {r0} - bx r0 - .pool - thumb_func_end FilterOutStepOnPuddleGroundEffectIfJumping - - thumb_func_start DoGroundEffects_OnSpawn -@ void DoGroundEffects_OnSpawn(struct npc_state *fieldObject, struct obj *object) -DoGroundEffects_OnSpawn: @ 8097310 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4] - lsls r0, 29 - cmp r0, 0 - bge _08097354 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - bl FieldObjectUpdateZCoordAndPriority - adds r0, r4, 0 - mov r1, sp - bl GetAllGroundEffectFlags_OnSpawn - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetSpriteOamTableForLongGrass - ldr r2, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - bl DoFlaggedGroundEffects - ldrb r1, [r4] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - movs r1, 0x11 - negs r1, r1 - ands r0, r1 - strb r0, [r4] -_08097354: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end DoGroundEffects_OnSpawn - - thumb_func_start DoGroundEffects_OnBeginStep -@ void DoGroundEffects_OnBeginStep(struct npc_state *fieldObject, struct obj *object) -DoGroundEffects_OnBeginStep: @ 809735C - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4] - lsls r0, 29 - cmp r0, 0 - bge _080973A8 - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - bl FieldObjectUpdateZCoordAndPriority - adds r0, r4, 0 - mov r1, sp - bl GetAllGroundEffectFlags_OnBeginStep - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetSpriteOamTableForLongGrass - adds r0, r4, 0 - mov r1, sp - bl filters_out_some_ground_effects - ldr r2, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - bl DoFlaggedGroundEffects - ldrb r1, [r4] - movs r0, 0x5 - negs r0, r0 - ands r0, r1 - movs r1, 0x11 - negs r1, r1 - ands r0, r1 - strb r0, [r4] -_080973A8: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end DoGroundEffects_OnBeginStep - - thumb_func_start DoGroundEffects_OnFinishStep -@ void DoGroundEffects_OnFinishStep(struct npc_state *fieldObject, struct obj *object) -DoGroundEffects_OnFinishStep: @ 80973B0 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4] - lsls r0, 28 - cmp r0, 0 - bge _080973FC - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - bl FieldObjectUpdateZCoordAndPriority - adds r0, r4, 0 - mov r1, sp - bl GetAllGroundEffectFlags_OnFinishStep - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetSpriteOamTableForLongGrass - adds r0, r4, 0 - mov r1, sp - bl FilterOutStepOnPuddleGroundEffectIfJumping - ldr r2, [sp] - adds r0, r4, 0 - adds r1, r5, 0 - bl DoFlaggedGroundEffects - ldrb r1, [r4] - movs r0, 0x9 - negs r0, r0 - ands r0, r1 - movs r1, 0x21 - negs r1, r1 - ands r0, r1 - strb r0, [r4] -_080973FC: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end DoGroundEffects_OnFinishStep - - .align 2, 0 @ Don't pad with nop. diff --git a/data/field_ground_effect.s b/data/field_ground_effect.s index 989d2add7..686d9396b 100644 --- a/data/field_ground_effect.s +++ b/data/field_ground_effect.s @@ -4,66 +4,3 @@ .section .rodata .align 2, 0 -gUnknown_0850E5DC:: @ 850E5DC - .4byte 0x00000020, 0x00000010 - -gUnknown_0850E5E4:: @ 850E5E4 - .4byte MetatileBehavior_IsTallGrass - .4byte MetatileBehavior_IsLongGrass - .4byte MetatileBehavior_IsPuddle - .4byte MetatileBehavior_IsSurfableWaterOrUnderwater - .4byte MetatileBehavior_IsShallowFlowingWater - .4byte ShouldDoJumpLandingDustEffect - -gUnknown_0850E5FC:: @ 850E5FC - .4byte 0x00001000, 0x00002000, 0x00004000, 0x00008000, 0x00004000, 0x00010000 - -gUnknown_0850E614:: @ 850E614 - .4byte MetatileBehavior_IsJumpSouth - .4byte MetatileBehavior_IsJumpNorth - .4byte MetatileBehavior_IsJumpWest - .4byte MetatileBehavior_IsJumpEast - -gUnknown_0850E624:: @ 850E624 - .byte 0x73, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x00, 0x00, 0x73 - -gUnknown_0850E634:: @ 850E634 - .byte 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x00, 0x02 - -gUnknown_0850E644:: @ 850E644 - .byte 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01 - -gUnknown_0850E654:: @ 850E654 - .4byte DoTracksGroundEffect_None - .4byte DoTracksGroundEffect_Footprints - .4byte DoTracksGroundEffect_BikeTireTracks - -gUnknown_0850E660:: @ 850E660 - .byte 13, 0 - .byte 24, 0 - -gUnknown_0850E664:: @ 850E664 - .byte 0x01, 0x02, 0x07, 0x08, 0x01, 0x02, 0x06, 0x05, 0x05, 0x08, 0x03, 0x04, 0x06, 0x07, 0x03, 0x04 - -gUnknown_0850E674:: @ 850E674 - .4byte GroundEffect_SpawnOnTallGrass - .4byte GroundEffect_StepOnTallGrass - .4byte GroundEffect_SpawnOnLongGrass - .4byte GroundEffect_StepOnLongGrass - .4byte GroundEffect_WaterReflection - .4byte GroundEffect_IceReflection - .4byte GroundEffect_FlowingWater - .4byte GroundEffect_SandTracks - .4byte GroundEffect_DeepSandTracks - .4byte GroundEffect_Ripple - .4byte GroundEffect_StepOnPuddle - .4byte GroundEffect_SandHeap - .4byte GroundEffect_JumpOnTallGrass - .4byte GroundEffect_JumpOnLongGrass - .4byte GroundEffect_JumpOnShallowWater - .4byte GroundEffect_JumpOnWater - .4byte GroundEffect_JumpLandingDust - .4byte GroundEffect_ShortGrass - .4byte GroundEffect_HotSprings - .4byte GroundEffect_Seaweed - diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 7fd1fc93a..4e0d4ad22 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -20,6 +20,27 @@ enum SpinnerRunnerFollowPatterns { RUNFOLLOW_SOUTH_EAST_WEST }; +#define GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN (1 << 0) +#define GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE (1 << 1) +#define GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN (1 << 2) +#define GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE (1 << 3) +#define GROUND_EFFECT_FLAG_ICE_REFLECTION (1 << 4) +#define GROUND_EFFECT_FLAG_REFLECTION (1 << 5) +#define GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER (1 << 6) +#define GROUND_EFFECT_FLAG_SAND (1 << 7) +#define GROUND_EFFECT_FLAG_DEEP_SAND (1 << 8) +#define GROUND_EFFECT_FLAG_RIPPLES (1 << 9) +#define GROUND_EFFECT_FLAG_PUDDLE (1 << 10) +#define GROUND_EFFECT_FLAG_SAND_PILE (1 << 11) +#define GROUND_EFFECT_FLAG_LAND_IN_TALL_GRASS (1 << 12) +#define GROUND_EFFECT_FLAG_LAND_IN_LONG_GRASS (1 << 13) +#define GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER (1 << 14) +#define GROUND_EFFECT_FLAG_LAND_IN_DEEP_WATER (1 << 15) +#define GROUND_EFFECT_FLAG_LAND_ON_NORMAL_GROUND (1 << 16) +#define GROUND_EFFECT_FLAG_SHORT_GRASS (1 << 17) +#define GROUND_EFFECT_FLAG_HOT_SPRINGS (1 << 18) +#define GROUND_EFFECT_FLAG_SEAWEED (1 << 19) + // Exported RAM declarations // Exported ROM declarations @@ -95,6 +116,11 @@ u8 AddCameraObject(u8 linkedSpriteId); void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y); u8 GetSimpleGoAnimId(u32); u8 sub_8093514(u32); +bool8 AreZCoordsCompatible(u8, u8); +u8 ZCoordToPriority(u8); +void FieldObjectUpdateZCoord(struct MapObject *pObject); +void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); +bool8 IsZCoordMismatchAt(u8, s16, s16); // Exported data declarations diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h index 3c9e00b62..faf6290e4 100644 --- a/include/field_effect_helpers.h +++ b/include/field_effect_helpers.h @@ -15,5 +15,8 @@ bool8 sub_8155DA0(struct MapObject *); void sub_8155D78(struct MapObject *); void sub_81555AC(u8, u8); void ash(s16, s16, u16, s16); +void SetUpReflection(struct MapObject*, struct Sprite*, u8); +u32 StartFieldEffectForEventObject(u8, struct MapObject*); +u8 sub_81546C8(u8, u8, u8, s16, s16); #endif //GUARD_FIELD_EFFECT_HELPERS_H diff --git a/include/field_ground_effect.h b/include/field_ground_effect.h deleted file mode 100644 index 89b14aed1..000000000 --- a/include/field_ground_effect.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// Created by scott on 9/6/2017. -// - -#ifndef GUARD_FIELD_GROUND_EFFECT_H -#define GUARD_FIELD_GROUND_EFFECT_H - -// Exported type declarations - -// Exported RAM declarations - -// Exported ROM declarations -u8 ZCoordToPriority(u8); -void FieldObjectUpdateZCoord(struct MapObject *pObject); -void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8); -void InitObjectPriorityByZCoord(struct Sprite *, u8); -bool8 IsZCoordMismatchAt(u8, s16, s16); -bool8 AreZCoordsCompatible(u8, u8); -void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); -void DoGroundEffects_OnSpawn(struct MapObject *, struct Sprite *); -void DoGroundEffects_OnBeginStep(struct MapObject *, struct Sprite *); -void DoGroundEffects_OnFinishStep(struct MapObject *, struct Sprite *); - -#endif //GUARD_FIELD_GROUND_EFFECT_H diff --git a/include/fieldmap.h b/include/fieldmap.h index 699595580..01218493a 100644 --- a/include/fieldmap.h +++ b/include/fieldmap.h @@ -14,6 +14,7 @@ int CanCameraMoveInDirection(int direction); u16 GetBehaviorByMetatileId(u16 metatileId); void sav1_camera_get_focus_coords(u16 *x, u16 *y); u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y); +u8 MapGridGetZCoordAt(int x, int y); u8 CameraMove(s32 deltaX, s32 deltaY); void mapheader_copy_mapdata_with_padding(struct MapHeader *mapHeader); void map_copy_with_padding(u16 *map, u16 width, u16 height); diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index d6743b788..4b9fd2488 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -1,7 +1,7 @@ #ifndef GUARD_METATILE_BEHAVIOR #define GUARD_METATILE_BEHAVIOR -bool8 ShouldDoJumpLandingDustEffect(u8); +bool8 MetatileBehavior_IsATile(u8); bool8 MetatileBehavior_IsEncounterTile(u8); bool8 MetatileBehavior_IsJumpEast(u8); bool8 MetatileBehavior_IsJumpWest(u8); diff --git a/include/pokenav.h b/include/pokenav.h index 42affc938..734a1ec3f 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -21,6 +21,7 @@ void sub_81D1EC0(void); void sub_81D1D04(u8); bool8 sub_81D1C44(u8); void sub_81D5FB4(u16*); +bool8 sub_81D4A58(struct MapObject*); #endif //GUARD_POKENAV_H diff --git a/ld_script.txt b/ld_script.txt index 51e641fd1..b4d69ec4a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -93,7 +93,6 @@ SECTIONS { src/field_door.o(.text); asm/field_player_avatar.o(.text); src/event_object_movement.o(.text); - asm/field_ground_effect.o(.text); src/event_object_movement_helpers.o(.text); src/field_message_box.o(.text); src/map_obj_lock.o(.text); @@ -398,7 +397,7 @@ SECTIONS { src/field_door.o(.rodata); data/field_player_avatar.o(.rodata); data/event_object_movement.o(.rodata); - data/field_ground_effect.o(.rodata); + src/event_object_movement.o(.rodata); data/map_obj_8097404.o(.rodata); src/text_window.o(.rodata); src/scrcmd.o(.rodata); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 261f234f4..5c6f503ef 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -13,7 +13,6 @@ #include "event_data.h" #include "rom_818CFC8.h" #include "rom_81BE66C.h" -#include "field_ground_effect.h" #include "event_object_movement_helpers.h" #include "mauville_old_man.h" #include "metatile_behavior.h" @@ -23,6 +22,7 @@ #include "trainer_see.h" #include "decoration.h" #include "event_object_movement.h" +#include "pokenav.h" #define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51 @@ -175,7 +175,7 @@ extern u8 (*const gUnknown_0850DEE8[5])(u8); extern const s16 gUnknown_0850DFBC[3]; extern const s16 gUnknown_0850DFC2[3]; -/*static*/ void FieldObjectUpdateMetatileBehaviors(struct MapObject*); +static void FieldObjectUpdateMetatileBehaviors(struct MapObject*); /*static*/ void GetAllGroundEffectFlags_OnBeginStep(struct MapObject*, u32*); /*static*/ void GetGroundEffectFlags_Reflection(struct MapObject*, u32*); /*static*/ void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject*, u32*); @@ -191,6 +191,17 @@ extern const s16 gUnknown_0850DFC2[3]; /*static*/ void GetGroundEffectFlags_Ripple(struct MapObject*, u32*); /*static*/ void GetGroundEffectFlags_Seaweed(struct MapObject*, u32*); /*static*/ void GetGroundEffectFlags_JumpLanding(struct MapObject*, u32*); +/*static*/ u8 FieldObjectCheckForReflectiveSurface(struct MapObject*); +static u8 GetReflectionTypeByMetatileBehavior(u32); +static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z); +static void FieldObjectUpdateSubpriority(struct MapObject*, struct Sprite*); +static void DoTracksGroundEffect_None(struct MapObject*, struct Sprite*, u8); +static void DoTracksGroundEffect_Footprints(struct MapObject*, struct Sprite*, u8); +static void DoTracksGroundEffect_BikeTireTracks(struct MapObject*, struct Sprite*, u8); +/*static*/ void DoRippleFieldEffect(struct MapObject*, struct Sprite*); +static void DoGroundEffects_OnSpawn(struct MapObject*, struct Sprite*); +static void DoGroundEffects_OnBeginStep(struct MapObject*, struct Sprite*); +static void DoGroundEffects_OnFinishStep(struct MapObject*, struct Sprite*); // Code @@ -5174,3 +5185,712 @@ static void npc_update_obj_anim_flag(struct MapObject *mapObject, struct Sprite GetGroundEffectFlags_Seaweed(eventObj, flags); GetGroundEffectFlags_JumpLanding(eventObj, flags); } + +static void FieldObjectUpdateMetatileBehaviors(struct MapObject *eventObj) +{ + eventObj->previousMetatileBehavior = MapGridGetMetatileBehaviorAt(eventObj->previousCoords.x, eventObj->previousCoords.y); + eventObj->currentMetatileBehavior = MapGridGetMetatileBehaviorAt(eventObj->currentCoords.x, eventObj->currentCoords.y); +} + +void GetGroundEffectFlags_Reflection(struct MapObject *eventObj, u32 *flags) +{ + u32 reflectionFlags[2] = { GROUND_EFFECT_FLAG_REFLECTION, GROUND_EFFECT_FLAG_ICE_REFLECTION }; + u8 type = FieldObjectCheckForReflectiveSurface(eventObj); + + if (type) + { + if (!eventObj->hasReflection) + { + eventObj->hasReflection = 0; + eventObj->hasReflection = 1; + *flags |= reflectionFlags[type - 1]; + } + } + else + { + eventObj->hasReflection = 0; + } +} + +void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsTallGrass(eventObj->currentMetatileBehavior)) + *flags |= GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN; +} + +void GetGroundEffectFlags_TallGrassOnBeginStep(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsTallGrass(eventObj->currentMetatileBehavior)) + *flags |= GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE; +} + +void GetGroundEffectFlags_LongGrassOnSpawn(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsLongGrass(eventObj->currentMetatileBehavior)) + *flags |= GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN; +} + +void GetGroundEffectFlags_LongGrassOnBeginStep(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsLongGrass(eventObj->currentMetatileBehavior)) + *flags |= GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE; +} + +void GetGroundEffectFlags_Tracks(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsDeepSand(eventObj->previousMetatileBehavior)) + { + *flags |= GROUND_EFFECT_FLAG_DEEP_SAND; + } + else if (MetatileBehavior_IsSandOrDeepSand(eventObj->previousMetatileBehavior) + || MetatileBehavior_IsUnusedFootprintMetatile(eventObj->previousMetatileBehavior)) + { + *flags |= GROUND_EFFECT_FLAG_SAND; + } +} + +void GetGroundEffectFlags_SandHeap(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsDeepSand(eventObj->currentMetatileBehavior) + && MetatileBehavior_IsDeepSand(eventObj->previousMetatileBehavior)) + { + if (!eventObj->inSandPile) + { + eventObj->inSandPile = 0; + eventObj->inSandPile = 1; + *flags |= GROUND_EFFECT_FLAG_SAND_PILE; + } + } + else + { + eventObj->inSandPile = 0; + } +} + +void GetGroundEffectFlags_ShallowFlowingWater(struct MapObject *eventObj, u32 *flags) +{ + if ((MetatileBehavior_IsShallowFlowingWater(eventObj->currentMetatileBehavior) + && MetatileBehavior_IsShallowFlowingWater(eventObj->previousMetatileBehavior)) + || (MetatileBehavior_IsPacifidlogLog(eventObj->currentMetatileBehavior) + && MetatileBehavior_IsPacifidlogLog(eventObj->previousMetatileBehavior))) + { + if (!eventObj->inShallowFlowingWater) + { + eventObj->inShallowFlowingWater = 0; + eventObj->inShallowFlowingWater = 1; + *flags |= GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER; + } + } + else + { + eventObj->inShallowFlowingWater = 0; + } +} + +void GetGroundEffectFlags_Puddle(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsPuddle(eventObj->currentMetatileBehavior) + && MetatileBehavior_IsPuddle(eventObj->previousMetatileBehavior)) + { + *flags |= GROUND_EFFECT_FLAG_PUDDLE; + } +} + +void GetGroundEffectFlags_Ripple(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_HasRipples(eventObj->currentMetatileBehavior)) + *flags |= GROUND_EFFECT_FLAG_RIPPLES; +} + +void GetGroundEffectFlags_ShortGrass(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsShortGrass(eventObj->currentMetatileBehavior) + && MetatileBehavior_IsShortGrass(eventObj->previousMetatileBehavior)) + { + if (!eventObj->inShortGrass) + { + eventObj->inShortGrass = 0; + eventObj->inShortGrass = 1; + *flags |= GROUND_EFFECT_FLAG_SHORT_GRASS; + } + } + else + { + eventObj->inShortGrass = 0; + } +} + +void GetGroundEffectFlags_HotSprings(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsHotSprings(eventObj->currentMetatileBehavior) + && MetatileBehavior_IsHotSprings(eventObj->previousMetatileBehavior)) + { + if (!eventObj->inHotSprings) + { + eventObj->inHotSprings = 0; + eventObj->inHotSprings = 1; + *flags |= GROUND_EFFECT_FLAG_HOT_SPRINGS; + } + } + else + { + eventObj->inHotSprings = 0; + } +} + +void GetGroundEffectFlags_Seaweed(struct MapObject *eventObj, u32 *flags) +{ + if (MetatileBehavior_IsSeaweed(eventObj->currentMetatileBehavior)) + *flags |= GROUND_EFFECT_FLAG_SEAWEED; +} + +void GetGroundEffectFlags_JumpLanding(struct MapObject *eventObj, u32 *flags) +{ + typedef bool8 (*MetatileFunc)(u8); + + static const MetatileFunc metatileFuncs[] = { + MetatileBehavior_IsTallGrass, + MetatileBehavior_IsLongGrass, + MetatileBehavior_IsPuddle, + MetatileBehavior_IsSurfableWaterOrUnderwater, + MetatileBehavior_IsShallowFlowingWater, + MetatileBehavior_IsATile, + }; + + static const u32 jumpLandingFlags[] = { + GROUND_EFFECT_FLAG_LAND_IN_TALL_GRASS, + GROUND_EFFECT_FLAG_LAND_IN_LONG_GRASS, + GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER, + GROUND_EFFECT_FLAG_LAND_IN_DEEP_WATER, + GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER, + GROUND_EFFECT_FLAG_LAND_ON_NORMAL_GROUND, + }; + + if (eventObj->landingJump && !eventObj->disableJumpLandingGroundEffect) + { + u8 i; + + for (i = 0; i < ARRAY_COUNT(metatileFuncs); i++) + { + if (metatileFuncs[i](eventObj->currentMetatileBehavior)) + { + *flags |= jumpLandingFlags[i]; + return; + } + } + } +} + +u8 FieldObjectCheckForReflectiveSurface(struct MapObject *eventObj) +{ + const struct MapObjectGraphicsInfo *info = GetFieldObjectGraphicsInfo(eventObj->graphicsId); + + // ceil div by tile width? + s16 width = (info->width + 8) >> 4; + s16 height = (info->height + 8) >> 4; + s16 i; + s16 j; + u8 result; + u8 b; + s16 one; + +#define RETURN_REFLECTION_TYPE_AT(x, y) \ + b = MapGridGetMetatileBehaviorAt(x, y); \ + result = GetReflectionTypeByMetatileBehavior(b); \ + if (result != 0) \ + return result; + + for (i = 0, one = 1; i < height; i++) + { + RETURN_REFLECTION_TYPE_AT(eventObj->currentCoords.x, eventObj->currentCoords.y + one + i) + RETURN_REFLECTION_TYPE_AT(eventObj->previousCoords.x, eventObj->previousCoords.y + one + i) + for (j = 1; j < width; j++) + { + RETURN_REFLECTION_TYPE_AT(eventObj->currentCoords.x + j, eventObj->currentCoords.y + one + i) + RETURN_REFLECTION_TYPE_AT(eventObj->currentCoords.x - j, eventObj->currentCoords.y + one + i) + RETURN_REFLECTION_TYPE_AT(eventObj->previousCoords.x + j, eventObj->previousCoords.y + one + i) + RETURN_REFLECTION_TYPE_AT(eventObj->previousCoords.x - j, eventObj->previousCoords.y + one + i) + } + } + return 0; + +#undef RETURN_REFLECTION_TYPE_AT +} + +static u8 GetReflectionTypeByMetatileBehavior(u32 behavior) +{ + if (MetatileBehavior_IsIce(behavior)) + return 1; + else if (MetatileBehavior_IsReflective(behavior)) + return 2; + else + return 0; +} + +u8 GetLedgeJumpDirection(s16 x, s16 y, u8 z) +{ + static bool8 (*const unknown_08376040[])(u8) = { + MetatileBehavior_IsJumpSouth, + MetatileBehavior_IsJumpNorth, + MetatileBehavior_IsJumpWest, + MetatileBehavior_IsJumpEast, + }; + + u8 b; + u8 index = z; + + if (index == 0) + return 0; + else if (index > 4) + index -= 4; + + index--; + b = MapGridGetMetatileBehaviorAt(x, y); + + if (unknown_08376040[index](b) == 1) + return index + 1; + + return 0; +} + +void FieldObjectSetSpriteOamTableForLongGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + if (eventObj->disableCoveringGroundEffects) + return; + + if (!MetatileBehavior_IsLongGrass(eventObj->currentMetatileBehavior)) + return; + + if (!MetatileBehavior_IsLongGrass(eventObj->previousMetatileBehavior)) + return; + + sprite->subspriteTableNum = 4; + + if (ZCoordToPriority(eventObj->previousElevation) == 1) + sprite->subspriteTableNum = 5; +} + +bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y) +{ + u8 mapZ; + + if (z == 0) + return FALSE; + + mapZ = MapGridGetZCoordAt(x, y); + + if (mapZ == 0 || mapZ == 0xF) + return FALSE; + + if (mapZ != z) + return TRUE; + + return FALSE; +} + +static const u8 sUnknown_08376050[] = { + 0x73, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x00, 0x00, 0x73 +}; + +// Each byte corresponds to a sprite priority for an event object. +// This is directly the inverse of gEventObjectPriorities_08376070. +static const u8 sEventObjectPriorities_08376060[] = { + 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0, 0, 2 +}; + +// Each byte corresponds to a sprite priority for an event object. +// This is the inverse of gEventObjectPriorities_08376060. +// 1 = Above player sprite +// 2 = Below player sprite +static const u8 sEventObjectPriorities_08376070[] = { + 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1, +}; + +void FieldObjectUpdateZCoordAndPriority(struct MapObject *eventObj, struct Sprite *sprite) +{ + if (eventObj->fixedPriority) + return; + + FieldObjectUpdateZCoord(eventObj); + + sprite->subspriteTableNum = sEventObjectPriorities_08376070[eventObj->previousElevation]; + sprite->oam.priority = sEventObjectPriorities_08376060[eventObj->previousElevation]; +} + +static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z) +{ + sprite->subspriteTableNum = sEventObjectPriorities_08376070[z]; + sprite->oam.priority = sEventObjectPriorities_08376060[z]; +} + +u8 ZCoordToPriority(u8 z) +{ + return sEventObjectPriorities_08376060[z]; +} + +void FieldObjectUpdateZCoord(struct MapObject *eventObj) +{ + u8 z = MapGridGetZCoordAt(eventObj->currentCoords.x, eventObj->currentCoords.y); + u8 z2 = MapGridGetZCoordAt(eventObj->previousCoords.x, eventObj->previousCoords.y); + + if (z == 0xF || z2 == 0xF) + return; + + eventObj->currentElevation = z; + + if (z != 0 && z != 0xF) + eventObj->previousElevation = z; +} + +void SetObjectSubpriorityByZCoord(u8 a, struct Sprite *sprite, u8 b) +{ + s32 tmp = sprite->centerToCornerVecY; + u32 tmpa = *(u16 *)&sprite->pos1.y; + u32 tmpb = *(u16 *)&gSpriteCoordOffsetY; + s32 tmp2 = (tmpa - tmp) + tmpb; + u16 tmp3 = (0x10 - ((((u32)tmp2 + 8) & 0xFF) >> 4)) * 2; + sprite->subpriority = tmp3 + sUnknown_08376050[a] + b; +} + +static void FieldObjectUpdateSubpriority(struct MapObject *eventObj, struct Sprite *sprite) +{ + if (eventObj->fixedPriority) + return; + + SetObjectSubpriorityByZCoord(eventObj->previousElevation, sprite, 1); +} + +bool8 AreZCoordsCompatible(u8 a, u8 b) +{ + if (a == 0 || b == 0) + return TRUE; + + if (a != b) + return FALSE; + + return TRUE; +} + +void GroundEffect_SpawnOnTallGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = 2; + gFieldEffectArguments[4] = eventObj->localId << 8 | eventObj->mapNum; + gFieldEffectArguments[5] = eventObj->mapGroup; + gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup; + gFieldEffectArguments[7] = 1; + FieldEffectStart(FLDEFF_TALL_GRASS); +} + +void GroundEffect_StepOnTallGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = 2; + gFieldEffectArguments[4] = eventObj->localId << 8 | eventObj->mapNum; + gFieldEffectArguments[5] = eventObj->mapGroup; + gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup; + gFieldEffectArguments[7] = 0; + FieldEffectStart(FLDEFF_TALL_GRASS); +} + +void GroundEffect_SpawnOnLongGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = 2; + gFieldEffectArguments[4] = eventObj->localId << 8 | eventObj->mapNum; + gFieldEffectArguments[5] = eventObj->mapGroup; + gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup; + gFieldEffectArguments[7] = 1; + FieldEffectStart(FLDEFF_LONG_GRASS); +} + +void GroundEffect_StepOnLongGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = 2; + gFieldEffectArguments[4] = (eventObj->localId << 8) | eventObj->mapNum; + gFieldEffectArguments[5] = eventObj->mapGroup; + gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup; + gFieldEffectArguments[7] = 0; + FieldEffectStart(FLDEFF_LONG_GRASS); +} + +void GroundEffect_WaterReflection(struct MapObject *eventObj, struct Sprite *sprite) +{ + SetUpReflection(eventObj, sprite, 0); +} + +void GroundEffect_IceReflection(struct MapObject *eventObj, struct Sprite *sprite) +{ + SetUpReflection(eventObj, sprite, 1); +} + +void GroundEffect_FlowingWater(struct MapObject *eventObj, struct Sprite *sprite) +{ + StartFieldEffectForEventObject(FLDEFF_FEET_IN_FLOWING_WATER, eventObj); +} + +static void (*const sGroundEffectTracksFuncs[])(struct MapObject *eventObj, struct Sprite *sprite, u8 a) = { + DoTracksGroundEffect_None, + DoTracksGroundEffect_Footprints, + DoTracksGroundEffect_BikeTireTracks, +}; + +void GroundEffect_SandTracks(struct MapObject *eventObj, struct Sprite *sprite) +{ + const struct MapObjectGraphicsInfo *info = GetFieldObjectGraphicsInfo(eventObj->graphicsId); + sGroundEffectTracksFuncs[info->tracks](eventObj, sprite, 0); +} + +void GroundEffect_DeepSandTracks(struct MapObject *eventObj, struct Sprite *sprite) +{ + const struct MapObjectGraphicsInfo *info = GetFieldObjectGraphicsInfo(eventObj->graphicsId); + sGroundEffectTracksFuncs[info->tracks](eventObj, sprite, 1); +} + +static void DoTracksGroundEffect_None(struct MapObject *eventObj, struct Sprite *sprite, u8 a) +{ +} + +static void DoTracksGroundEffect_Footprints(struct MapObject *eventObj, struct Sprite *sprite, u8 a) +{ + // First half-word is a Field Effect script id. (gFieldEffectScriptPointers) + u16 sandFootprints_FieldEffectData[2] = { + FLDEFF_SAND_FOOTPRINTS, + FLDEFF_DEEP_SAND_FOOTPRINTS + }; + + gFieldEffectArguments[0] = eventObj->previousCoords.x; + gFieldEffectArguments[1] = eventObj->previousCoords.y; + gFieldEffectArguments[2] = 149; + gFieldEffectArguments[3] = 2; + gFieldEffectArguments[4] = eventObj->facingDirection; + FieldEffectStart(sandFootprints_FieldEffectData[a]); +} + +static void DoTracksGroundEffect_BikeTireTracks(struct MapObject *eventObj, struct Sprite *sprite, u8 a) +{ + // Specifies which bike track shape to show next. + // For example, when the bike turns from up to right, it will show + // a track that curves to the right. + // Each 4-byte row corresponds to the initial direction of the bike, and + // each byte in that row is for the next direction of the bike in the order + // of down, up, left, right. + static const u8 bikeTireTracks_Transitions[4][4] = { + 1, 2, 7, 8, + 1, 2, 6, 5, + 5, 8, 3, 4, + 6, 7, 3, 4, + }; + + if (eventObj->currentCoords.x != eventObj->previousCoords.x || eventObj->currentCoords.y != eventObj->previousCoords.y) + { + gFieldEffectArguments[0] = eventObj->previousCoords.x; + gFieldEffectArguments[1] = eventObj->previousCoords.y; + gFieldEffectArguments[2] = 149; + gFieldEffectArguments[3] = 2; + gFieldEffectArguments[4] = + bikeTireTracks_Transitions[eventObj->previousMovementDirection][eventObj->facingDirection - 5]; + FieldEffectStart(FLDEFF_BIKE_TIRE_TRACKS); + } +} + +void GroundEffect_Ripple(struct MapObject *eventObj, struct Sprite *sprite) +{ + DoRippleFieldEffect(eventObj, sprite); +} + +void GroundEffect_StepOnPuddle(struct MapObject *eventObj, struct Sprite *sprite) +{ + StartFieldEffectForEventObject(FLDEFF_SPLASH, eventObj); +} + +void GroundEffect_SandHeap(struct MapObject *eventObj, struct Sprite *sprite) +{ + StartFieldEffectForEventObject(FLDEFF_SAND_PILE, eventObj); +} + +void GroundEffect_JumpOnTallGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + u8 spriteId; + + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = 2; + FieldEffectStart(FLDEFF_JUMP_TALL_GRASS); + + spriteId = sub_81546C8( + eventObj->localId, eventObj->mapNum, eventObj->mapGroup, eventObj->currentCoords.x, eventObj->currentCoords.y); + + if (spriteId == MAX_SPRITES) + GroundEffect_SpawnOnTallGrass(eventObj, sprite); +} + +void GroundEffect_JumpOnLongGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = 2; + FieldEffectStart(FLDEFF_JUMP_LONG_GRASS); +} + +void GroundEffect_JumpOnShallowWater(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_JUMP_SMALL_SPLASH); +} + +void GroundEffect_JumpOnWater(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_JUMP_BIG_SPLASH); +} + +void GroundEffect_JumpLandingDust(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + gFieldEffectArguments[2] = eventObj->previousElevation; + gFieldEffectArguments[3] = sprite->oam.priority; + FieldEffectStart(FLDEFF_DUST); +} + +void GroundEffect_ShortGrass(struct MapObject *eventObj, struct Sprite *sprite) +{ + StartFieldEffectForEventObject(FLDEFF_SHORT_GRASS, eventObj); +} + +void GroundEffect_HotSprings(struct MapObject *eventObj, struct Sprite *sprite) +{ + StartFieldEffectForEventObject(FLDEFF_HOT_SPRINGS_WATER, eventObj); +} + +void GroundEffect_Seaweed(struct MapObject *eventObj, struct Sprite *sprite) +{ + gFieldEffectArguments[0] = eventObj->currentCoords.x; + gFieldEffectArguments[1] = eventObj->currentCoords.y; + FieldEffectStart(FLDEFF_BUBBLES); +} + +static void (*const sGroundEffectFuncs[])(struct MapObject *eventObj, struct Sprite *sprite) = { + GroundEffect_SpawnOnTallGrass, + GroundEffect_StepOnTallGrass, + GroundEffect_SpawnOnLongGrass, + GroundEffect_StepOnLongGrass, + GroundEffect_WaterReflection, + GroundEffect_IceReflection, + GroundEffect_FlowingWater, + GroundEffect_SandTracks, + GroundEffect_DeepSandTracks, + GroundEffect_Ripple, + GroundEffect_StepOnPuddle, + GroundEffect_SandHeap, + GroundEffect_JumpOnTallGrass, + GroundEffect_JumpOnLongGrass, + GroundEffect_JumpOnShallowWater, + GroundEffect_JumpOnWater, + GroundEffect_JumpLandingDust, + GroundEffect_ShortGrass, + GroundEffect_HotSprings, + GroundEffect_Seaweed +}; + +/*static*/ void DoFlaggedGroundEffects(struct MapObject *eventObj, struct Sprite *sprite, u32 flags) +{ + u8 i; + + if (FieldObjectIsFarawayIslandMew(eventObj) == TRUE && !sub_81D4A58(eventObj)) + return; + + for (i = 0; i < ARRAY_COUNT(sGroundEffectFuncs); i++, flags >>= 1) + if (flags & 1) + sGroundEffectFuncs[i](eventObj, sprite); +} + +void filters_out_some_ground_effects(struct MapObject *eventObj, u32 *flags) +{ + if (eventObj->disableCoveringGroundEffects) + { + eventObj->inShortGrass = 0; + eventObj->inSandPile = 0; + eventObj->inShallowFlowingWater = 0; + eventObj->inHotSprings = 0; + *flags &= ~(GROUND_EFFECT_FLAG_HOT_SPRINGS + | GROUND_EFFECT_FLAG_SHORT_GRASS + | GROUND_EFFECT_FLAG_SAND_PILE + | GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER + | GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE); + } +} + +void FilterOutStepOnPuddleGroundEffectIfJumping(struct MapObject *eventObj, u32 *flags) +{ + if (eventObj->landingJump) + *flags &= ~GROUND_EFFECT_FLAG_PUDDLE; +} + +static void DoGroundEffects_OnSpawn(struct MapObject *eventObj, struct Sprite *sprite) +{ + u32 flags; + + if (eventObj->triggerGroundEffectsOnMove) + { + flags = 0; + FieldObjectUpdateZCoordAndPriority(eventObj, sprite); + GetAllGroundEffectFlags_OnSpawn(eventObj, &flags); + FieldObjectSetSpriteOamTableForLongGrass(eventObj, sprite); + DoFlaggedGroundEffects(eventObj, sprite, flags); + eventObj->triggerGroundEffectsOnMove = 0; + eventObj->disableCoveringGroundEffects = 0; + } +} + +static void DoGroundEffects_OnBeginStep(struct MapObject *eventObj, struct Sprite *sprite) +{ + u32 flags; + + if (eventObj->triggerGroundEffectsOnMove) + { + flags = 0; + FieldObjectUpdateZCoordAndPriority(eventObj, sprite); + GetAllGroundEffectFlags_OnBeginStep(eventObj, &flags); + FieldObjectSetSpriteOamTableForLongGrass(eventObj, sprite); + filters_out_some_ground_effects(eventObj, &flags); + DoFlaggedGroundEffects(eventObj, sprite, flags); + eventObj->triggerGroundEffectsOnMove = 0; + eventObj->disableCoveringGroundEffects = 0; + } +} + +static void DoGroundEffects_OnFinishStep(struct MapObject *eventObj, struct Sprite *sprite) +{ + u32 flags; + + if (eventObj->triggerGroundEffectsOnStop) + { + flags = 0; + FieldObjectUpdateZCoordAndPriority(eventObj, sprite); + GetAllGroundEffectFlags_OnFinishStep(eventObj, &flags); + FieldObjectSetSpriteOamTableForLongGrass(eventObj, sprite); + FilterOutStepOnPuddleGroundEffectIfJumping(eventObj, &flags); + DoFlaggedGroundEffects(eventObj, sprite, flags); + eventObj->triggerGroundEffectsOnStop = 0; + eventObj->landingJump = 0; + } +} diff --git a/src/event_object_movement_helpers.c b/src/event_object_movement_helpers.c index 660c8961a..6a8b410f5 100755 --- a/src/event_object_movement_helpers.c +++ b/src/event_object_movement_helpers.c @@ -1,5 +1,4 @@ #include "global.h" -#include "field_ground_effect.h" #include "event_object_movement.h" #include "field_effect.h" #include "event_object_movement_helpers.h" @@ -504,7 +503,7 @@ bool32 sub_8097D9C(u8 var) return FALSE; } -u32 oe_exec_and_other_stuff(u8 fieldEffectId, struct MapObject *mapObject) +u32 StartFieldEffectForEventObject(u8 fieldEffectId, struct MapObject *mapObject) { FieldObjectGetLocalIdAndMap(mapObject, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); return FieldEffectStart(fieldEffectId); @@ -515,7 +514,7 @@ void DoShadowFieldEffect(struct MapObject *mapObject) if (!mapObject->hasShadow) { mapObject->hasShadow = 1; - oe_exec_and_other_stuff(FLDEFF_SHADOW, mapObject); + StartFieldEffectForEventObject(FLDEFF_SHADOW, mapObject); } } diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index b9760f522..ad0062c20 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -252,8 +252,7 @@ static const u8 sTileBitAttributes[] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), // ? 0xEF }; -// only used as default case for checking jump landing in field_ground_effect. -bool8 ShouldDoJumpLandingDustEffect(u8 var) +bool8 MetatileBehavior_IsATile(u8 var) { return TRUE; } diff --git a/src/overworld.c b/src/overworld.c index 3279ce4fb..045ebb4fd 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -10,7 +10,6 @@ #include "field_control_avatar.h" #include "field_effect.h" #include "field_fadetransition.h" -#include "field_ground_effect.h" #include "event_object_movement.h" #include "event_object_movement_helpers.h" #include "field_message_box.h"