summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/field_ground_effect.s412
-rw-r--r--data/field_ground_effect.s22
-rw-r--r--include/asm.inc.h24
-rw-r--r--include/metatile_behavior.h136
-rw-r--r--src/battle_setup.c1
-rw-r--r--src/field_door.c1
-rw-r--r--src/field_ground_effect.c182
-rw-r--r--src/field_player_avatar.c1
-rw-r--r--src/metatile_behavior.c4
-rw-r--r--src/rom4.c1
-rw-r--r--src/wild_encounter.c1
11 files changed, 318 insertions, 467 deletions
diff --git a/asm/field_ground_effect.s b/asm/field_ground_effect.s
index f3c7eca4f..47c4b4c60 100644
--- a/asm/field_ground_effect.s
+++ b/asm/field_ground_effect.s
@@ -6,418 +6,6 @@
.text
- thumb_func_start GetGroundEffectFlags_TallGrassOnSpawn
-GetGroundEffectFlags_TallGrassOnSpawn: @ 8063764
- push {r4,lr}
- adds r4, r1, 0
- ldrb r0, [r0, 0x1E]
- bl MetatileBehavior_IsTallGrass
- lsls r0, 24
- cmp r0, 0
- beq _0806377C
- ldr r0, [r4]
- movs r1, 0x1
- orrs r0, r1
- str r0, [r4]
-_0806377C:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_TallGrassOnSpawn
-
- thumb_func_start GetGroundEffectFlags_TallGrassOnBeginStep
-GetGroundEffectFlags_TallGrassOnBeginStep: @ 8063784
- push {r4,lr}
- adds r4, r1, 0
- ldrb r0, [r0, 0x1E]
- bl MetatileBehavior_IsTallGrass
- lsls r0, 24
- cmp r0, 0
- beq _0806379C
- ldr r0, [r4]
- movs r1, 0x2
- orrs r0, r1
- str r0, [r4]
-_0806379C:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_TallGrassOnBeginStep
-
- thumb_func_start GetGroundEffectFlags_LongGrassOnSpawn
-GetGroundEffectFlags_LongGrassOnSpawn: @ 80637A4
- push {r4,lr}
- adds r4, r1, 0
- ldrb r0, [r0, 0x1E]
- bl MetatileBehavior_IsLongGrass
- lsls r0, 24
- cmp r0, 0
- beq _080637BC
- ldr r0, [r4]
- movs r1, 0x4
- orrs r0, r1
- str r0, [r4]
-_080637BC:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_LongGrassOnSpawn
-
- thumb_func_start GetGroundEffectFlags_LongGrassOnBeginStep
-GetGroundEffectFlags_LongGrassOnBeginStep: @ 80637C4
- push {r4,lr}
- adds r4, r1, 0
- ldrb r0, [r0, 0x1E]
- bl MetatileBehavior_IsLongGrass
- lsls r0, 24
- cmp r0, 0
- beq _080637DC
- ldr r0, [r4]
- movs r1, 0x8
- orrs r0, r1
- str r0, [r4]
-_080637DC:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_LongGrassOnBeginStep
-
- thumb_func_start GetGroundEffectFlags_Tracks
-GetGroundEffectFlags_Tracks: @ 80637E4
- 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 _080637FE
- ldr r0, [r5]
- movs r1, 0x80
- lsls r1, 1
- b _0806381A
-_080637FE:
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsSandOrDeepSand
- lsls r0, 24
- cmp r0, 0
- bne _08063816
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsUnusedFootprintMetatile
- lsls r0, 24
- cmp r0, 0
- beq _0806381E
-_08063816:
- ldr r0, [r5]
- movs r1, 0x80
-_0806381A:
- orrs r0, r1
- str r0, [r5]
-_0806381E:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_Tracks
-
- thumb_func_start GetGroundEffectFlags_SandHeap
-GetGroundEffectFlags_SandHeap: @ 8063824
- 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 _08063862
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsDeepSand
- lsls r0, 24
- cmp r0, 0
- beq _08063862
- ldrb r1, [r4, 0x2]
- lsls r0, r1, 27
- cmp r0, 0
- blt _0806386C
- 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 _0806386C
-_08063862:
- ldrb r1, [r4, 0x2]
- movs r0, 0x11
- negs r0, r0
- ands r0, r1
- strb r0, [r4, 0x2]
-_0806386C:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_SandHeap
-
- thumb_func_start GetGroundEffectFlags_ShallowFlowingWater
-GetGroundEffectFlags_ShallowFlowingWater: @ 8063874
- 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 _08063892
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsShallowFlowingWater
- lsls r0, 24
- cmp r0, 0
- bne _080638AA
-_08063892:
- ldrb r0, [r4, 0x1E]
- bl MetatileBehavior_IsPacifidlogLog
- lsls r0, 24
- cmp r0, 0
- beq _080638C8
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsPacifidlogLog
- lsls r0, 24
- cmp r0, 0
- beq _080638C8
-_080638AA:
- ldrb r1, [r4, 0x2]
- lsls r0, r1, 28
- cmp r0, 0
- blt _080638D2
- 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 _080638D2
-_080638C8:
- ldrb r1, [r4, 0x2]
- movs r0, 0x9
- negs r0, r0
- ands r0, r1
- strb r0, [r4, 0x2]
-_080638D2:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_ShallowFlowingWater
-
- thumb_func_start GetGroundEffectFlags_Puddle
-GetGroundEffectFlags_Puddle: @ 80638D8
- 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 _08063900
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsPuddle
- lsls r0, 24
- cmp r0, 0
- beq _08063900
- ldr r0, [r5]
- movs r1, 0x80
- lsls r1, 3
- orrs r0, r1
- str r0, [r5]
-_08063900:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_Puddle
-
- thumb_func_start GetGroundEffectFlags_Ripple
-GetGroundEffectFlags_Ripple: @ 8063908
- push {r4,lr}
- adds r4, r1, 0
- ldrb r0, [r0, 0x1E]
- bl MetatileBehavior_HasRipples
- lsls r0, 24
- cmp r0, 0
- beq _08063922
- ldr r0, [r4]
- movs r1, 0x80
- lsls r1, 2
- orrs r0, r1
- str r0, [r4]
-_08063922:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_Ripple
-
- thumb_func_start GetGroundEffectFlags_ShortGrass
-GetGroundEffectFlags_ShortGrass: @ 8063928
- 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 _08063966
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsShortGrass
- lsls r0, 24
- cmp r0, 0
- beq _08063966
- ldrb r1, [r4, 0x2]
- lsls r0, r1, 29
- cmp r0, 0
- blt _08063970
- 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 _08063970
-_08063966:
- ldrb r1, [r4, 0x2]
- movs r0, 0x5
- negs r0, r0
- ands r0, r1
- strb r0, [r4, 0x2]
-_08063970:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_ShortGrass
-
- thumb_func_start GetGroundEffectFlags_HotSprings
-GetGroundEffectFlags_HotSprings: @ 8063978
- 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 _080639B6
- ldrb r0, [r4, 0x1F]
- bl MetatileBehavior_IsHotSprings
- lsls r0, 24
- cmp r0, 0
- beq _080639B6
- ldrb r1, [r4, 0x2]
- lsls r0, r1, 26
- cmp r0, 0
- blt _080639C0
- 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 _080639C0
-_080639B6:
- ldrb r1, [r4, 0x2]
- movs r0, 0x21
- negs r0, r0
- ands r0, r1
- strb r0, [r4, 0x2]
-_080639C0:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_HotSprings
-
- thumb_func_start GetGroundEffectFlags_Seaweed
-GetGroundEffectFlags_Seaweed: @ 80639C8
- push {r4,lr}
- adds r4, r1, 0
- ldrb r0, [r0, 0x1E]
- bl MetatileBehavior_IsSeaweed
- lsls r0, 24
- cmp r0, 0
- beq _080639E2
- ldr r0, [r4]
- movs r1, 0x80
- lsls r1, 12
- orrs r0, r1
- str r0, [r4]
-_080639E2:
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_Seaweed
-
- thumb_func_start GetGroundEffectFlags_JumpLanding
-GetGroundEffectFlags_JumpLanding: @ 80639E8
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- adds r7, r0, 0
- adds r6, r1, 0
- ldr r0, [r7]
- ldr r1, _08063A24 @ =0x02000020
- ands r0, r1
- cmp r0, 0x20
- bne _08063A3A @ Is player landing after jumping?
- movs r5, 0
- ldr r0, _08063A28 @ =gJumpLanding_MetatileFunctionPointers
- mov r8, r0
-_08063A02:
- lsls r4, r5, 2
- mov r0, r8
- adds r1, r4, r0
- ldrb r0, [r7, 0x1E] @ Load metatile behavior
- ldr r1, [r1]
- bl _call_via_r1
- lsls r0, 24
- cmp r0, 0
- beq _08063A30
- ldr r0, _08063A2C @ =gJumpLanding_Bitmasks
- adds r0, r4, r0
- ldr r1, [r6]
- ldr r0, [r0]
- orrs r1, r0
- str r1, [r6]
- b _08063A3A
- .align 2, 0
-_08063A24: .4byte 0x02000020
-_08063A28: .4byte gJumpLanding_MetatileFunctionPointers
-_08063A2C: .4byte gJumpLanding_Bitmasks
-_08063A30:
- adds r0, r5, 0x1
- lsls r0, 24
- lsrs r5, r0, 24
- cmp r5, 0x5
- bls _08063A02
-_08063A3A:
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end GetGroundEffectFlags_JumpLanding
-
thumb_func_start FieldObjectCheckForReflectiveSurface
FieldObjectCheckForReflectiveSurface: @ 8063A44
push {r4-r7,lr}
diff --git a/data/field_ground_effect.s b/data/field_ground_effect.s
index d13a462a4..d3dbceedb 100644
--- a/data/field_ground_effect.s
+++ b/data/field_ground_effect.s
@@ -3,28 +3,6 @@
.section .rodata
-@ Functions used to determine which category of tile the player is landing
-@ on after jumping over a ledge.
- .align 2
-gJumpLanding_MetatileFunctionPointers:: @ 8376010
- .4byte MetatileBehavior_IsTallGrass
- .4byte MetatileBehavior_IsLongGrass
- .4byte MetatileBehavior_IsPuddle
- .4byte MetatileBehavior_IsSurfableWaterOrUnderwater
- .4byte MetatileBehavior_IsShallowFlowingWater
- .4byte sub_8056D9C
-
-@ This table contains bitmasks used for determining the animation that happens when the player lands on
-@ the ground after jumping over a ledge. Each entry corresponds to the gJumpLanding_MetatileFunctionPointers table.
- .align 2
-gJumpLanding_Bitmasks:: @ 8376028
- .4byte 0x00001000 @ Landing in tall grass
- .4byte 0x00002000 @ Landing in long grass
- .4byte 0x00004000 @ Landing on puddle
- .4byte 0x00008000 @ Landing on surfable water or underwater
- .4byte 0x00004000 @ Landing on shallow flowing water
- .4byte 0x00010000 @ Landing on any other type of ground
-
.align 2
gUnknown_08376040:: @ 8376040
.4byte MetatileBehavior_IsJumpSouth
diff --git a/include/asm.inc.h b/include/asm.inc.h
index c9d43c5b9..58c1592bd 100644
--- a/include/asm.inc.h
+++ b/include/asm.inc.h
@@ -37,30 +37,6 @@ void CreatePokeballSprite(u8 r0, u8 r1, u8 r2, u8 r3, u8 s1, u8 s2, u8 s3, u16 s
// asm/berry_blender.o
void sub_80516C4(u8, u16);
-// asm/metatile_behavior.o
-bool8 MetatileBehavior_IsSandOrDeepSand(char);
-bool8 is_tile_x69_2_warp_door(u8);
-u8 MetatileBehavior_IsDoor(u8);
-bool8 MetatileBehavior_IsLadder(u8);
-u8 sub_8056F08(u8);
-bool8 sub_8056F24(u8);
-u8 MetatileBehavior_IsSurfableWaterOrUnderwater(u8);
-bool8 MetatileBehavior_IsEastArrowWarp(u8);
-bool8 MetatileBehavior_IsWestArrowWarp(u8);
-bool8 MetatileBehavior_IsNorthArrowWarp(u8);
-bool8 MetatileBehavior_IsSouthArrowWarp(u8);
-bool8 MetatileBehavior_IsTallGrass(char);
-bool8 MetatileBehavior_IsLongGrass(char);
-u8 MetatileBehavior_IsBridge(u8);
-u8 sub_8057450(u8);
-u8 MetatileBehavior_IsLandWildEncounter(u8);
-u8 MetatileBehavior_IsWaterWildEncounter(u8);
-bool8 sub_80574C4(char);
-bool8 sub_80574D8(char);
-bool8 sub_8057568(char);
-bool8 sub_805759C(u8);
-bool8 MetatileBehavior_IsSurfableFishableWater(u8);
-
// src/field_door.o
void FieldSetDoorOpened(u32, u32);
void FieldSetDoorClosed(u32, u32);
diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h
new file mode 100644
index 000000000..34b660054
--- /dev/null
+++ b/include/metatile_behavior.h
@@ -0,0 +1,136 @@
+#ifndef GUARD_METATILE_BEHAVIOR
+#define GUARD_METATILE_BEHAVIOR
+
+bool8 sub_8056D9C(u8);
+bool8 sub_8056DA0(u8);
+bool8 MetatileBehavior_IsJumpEast(u8);
+bool8 MetatileBehavior_IsJumpWest(u8);
+bool8 MetatileBehavior_IsJumpNorth(u8);
+bool8 MetatileBehavior_IsJumpSouth(u8);
+bool8 sub_8056E14(u8);
+bool8 MetatileBehavior_IsSandOrDeepSand(u8);
+bool8 MetatileBehavior_IsDeepSand(u8);
+bool8 MetatileBehavior_IsReflective(u8);
+bool8 MetatileBehavior_IsIce(u8);
+bool8 is_tile_x69_2_warp_door(u8);
+bool8 MetatileBehavior_IsDoor(u8);
+bool8 MetatileBehavior_IsEscalator(u8);
+bool8 unref_sub_8056EE0(u8);
+bool8 MetatileBehavior_IsLadder(u8);
+bool8 sub_8056F08(u8);
+bool8 sub_8056F24(u8);
+bool8 MetatileBehavior_IsSurfableWaterOrUnderwater(u8);
+bool8 MetatileBehavior_IsEastArrowWarp(u8);
+bool8 MetatileBehavior_IsWestArrowWarp(u8);
+bool8 MetatileBehavior_IsNorthArrowWarp(u8);
+bool8 MetatileBehavior_IsSouthArrowWarp(u8);
+bool8 MetatileBehavior_IsArrowWarp(u8);
+bool8 sub_8056FFC(u8);
+bool8 MetatileBehavior_IsIce_2(u8);
+bool8 MetatileBehavior_IsTrickHouseSlipperyFloor(u8);
+bool8 MetatileBehavior_0x05(u8);
+bool8 MetatileBehavior_IsWalkNorth(u8);
+bool8 MetatileBehavior_IsWalkSouth(u8);
+bool8 MetatileBehavior_IsWalkWest(u8);
+bool8 MetatileBehavior_IsWalkEast(u8);
+bool8 MetatileBehavior_IsNorthwardCurrent(u8);
+bool8 MetatileBehavior_IsSouthwardCurrent(u8);
+bool8 MetatileBehavior_IsWestwardCurrent(u8);
+bool8 MetatileBehavior_IsEastwardCurrent(u8);
+bool8 MetatileBehavior_IsSlideNorth(u8);
+bool8 MetatileBehavior_IsSlideSouth(u8);
+bool8 MetatileBehavior_IsSlideWest(u8);
+bool8 MetatileBehavior_IsSlideEast(u8);
+bool8 MetatileBehavior_IsCounter(u8);
+bool8 MetatileBehavior_IsPlayerFacingTVScreen(u8, u8);
+bool8 MetatileBehavior_IsPC(u8);
+bool8 is_tile_x84(u8);
+bool8 sub_80571C0(u8);
+bool8 sub_80571EC(u8);
+bool8 sub_805720C(u8);
+bool8 is_tile_x98(u8);
+bool8 sub_8057238(u8);
+bool8 sub_805724C(u8);
+bool8 unref_sub_8057260(u8);
+bool8 sub_8057274(u8);
+bool8 sub_8057288(u8);
+bool8 sub_805729C(u8);
+bool8 sub_80572B0(u8);
+bool8 unref_sub_80572C4(u8);
+bool8 sub_80572D8(u8);
+bool8 sub_80572EC(u8);
+bool8 sub_8057300(u8);
+bool8 sub_8057314(u8);
+bool8 sub_8057328(u8);
+bool8 sub_805733C(u8);
+bool8 sub_8057350(u8);
+bool8 sub_8057364(u8);
+bool8 sub_8057378(u8);
+bool8 sub_805738C(u8);
+bool8 MetatileBehavior_HasRipples(u8);
+bool8 MetatileBehavior_IsPuddle(u8);
+bool8 MetatileBehavior_IsTallGrass(u8);
+bool8 MetatileBehavior_IsLongGrass(u8);
+bool8 MetatileBehavior_IsBerryTreeSoil(u8);
+bool8 MetatileBehavior_IsAsh(u8);
+bool8 MetatileBehavior_IsUnusedFootprintMetatile(u8);
+bool8 MetatileBehavior_IsBridge(u8);
+u8 sub_8057450(u8);
+bool8 MetatileBehavior_IsLandWildEncounter(u8);
+bool8 MetatileBehavior_IsWaterWildEncounter(u8);
+bool8 sub_80574C4(u8);
+bool8 sub_80574D8(u8);
+bool8 sub_80574EC(u8);
+bool8 sub_805750C(u8);
+bool8 MetatileBehavior_IsShallowFlowingWater(u8);
+bool8 sub_8057540(u8);
+bool8 sub_8057554(u8);
+bool8 sub_8057568(u8);
+bool8 unref_sub_8057584(u8);
+bool8 sub_805759C(u8);
+bool8 MetatileBehavior_IsEastBlocked(u8);
+bool8 MetatileBehavior_IsWestBlocked(u8);
+bool8 MetatileBehavior_IsNorthBlocked(u8);
+bool8 MetatileBehavior_IsSouthBlocked(u8);
+bool8 MetatileBehavior_IsShortGrass(u8);
+bool8 MetatileBehavior_IsHotSprings(u8);
+bool8 MetatileBehavior_IsWaterfall(u8);
+bool8 MetatileBehavior_IsFortreeBridge(u8);
+bool8 sub_80576A0(u8);
+bool8 sub_80576B4(u8);
+bool8 sub_80576C8(u8);
+bool8 sub_80576DC(u8);
+bool8 MetatileBehavior_IsPacifidlogLog(u8);
+bool8 is_tile_x8C(u8);
+bool8 is_tile_x85(u8);
+bool8 is_tile_x8B(u8);
+bool8 is_tile_x8A(u8);
+bool8 is_tile_x87(u8);
+bool8 MetatileBehavior_0xBB(u8);
+bool8 MetatileBehavior_0xBC(u8);
+bool8 sub_8057798(u8);
+bool8 is_role_x68(u8);
+bool8 MetatileBehavior_IsAquaHideoutWarp(u8);
+bool8 MetatileBehavior_IsSurfableFishableWater(u8);
+bool8 sub_8057804(u8);
+bool8 sub_8057818(u8);
+bool8 sub_805782C(u8);
+bool8 MetatileBehavior_IsMuddySlope(u8);
+bool8 MetatileBehavior_IsBumpySlope(u8);
+bool8 MetatileBehavior_IsIsolatedVerticalRail(u8);
+bool8 MetatileBehavior_IsIsolatedHorizontalRail(u8);
+bool8 MetatileBehavior_IsVerticalRail(u8);
+bool8 MetatileBehavior_IsHorizontalRail(u8);
+bool8 MetatileBehavior_IsSeaweed(u8);
+bool8 MetatileBehavior_IsRunningDisallowed(u8);
+bool8 sub_80578F8(u8);
+bool8 sub_805791C(u8);
+bool8 sub_8057930(u8);
+bool8 sub_8057944(u8);
+bool8 sub_8057958(u8);
+bool8 sub_805796C(u8);
+bool8 sub_8057980(u8);
+bool8 sub_8057994(u8);
+bool8 sub_80579A8(u8);
+
+#endif // GUARD_METATILE_BEHAVIOR
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 0174c794f..68690bf1d 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -20,6 +20,7 @@
#include "field_message_box.h"
#include "trainer.h"
#include "starter_choose.h"
+#include "metatile_behavior.h"
#define NUM_TRAINER_EYE_TRAINERS 56
#define TRAINER_REMATCH_STEPS 255
diff --git a/src/field_door.c b/src/field_door.c
index ff0537c42..85a5965a0 100644
--- a/src/field_door.c
+++ b/src/field_door.c
@@ -2,6 +2,7 @@
#include "asm.h"
#include "task.h"
#include "field_camera.h"
+#include "metatile_behavior.h"
struct DoorGraphics
{
diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c
index 358697339..42cf5d676 100644
--- a/src/field_ground_effect.c
+++ b/src/field_ground_effect.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "asm_fieldmap.h"
+#include "metatile_behavior.h"
extern u32 gUnknown_08376008[];
@@ -10,7 +11,7 @@ void GetGroundEffectFlags_TallGrassOnBeginStep(struct MapObject *, u32 *);
void GetGroundEffectFlags_LongGrassOnSpawn(struct MapObject *, u32 *);
void GetGroundEffectFlags_LongGrassOnBeginStep(struct MapObject *, u32 *);
void GetGroundEffectFlags_Tracks(struct MapObject *, u32 *);
-void GetGroundEffectFlags_SandHeap(struct MapObject *, u32 *);
+void GetGroundEffectFlags_SandPile(struct MapObject *, u32 *);
void GetGroundEffectFlags_ShallowFlowingWater(struct MapObject *, u32 *);
void GetGroundEffectFlags_Puddle(struct MapObject *, u32 *);
void GetGroundEffectFlags_Ripple(struct MapObject *, u32 *);
@@ -26,7 +27,7 @@ void GetAllGroundEffectFlags_OnSpawn(struct MapObject *mapObj, u32 *flags)
GetGroundEffectFlags_Reflection(mapObj, flags);
GetGroundEffectFlags_TallGrassOnSpawn(mapObj, flags);
GetGroundEffectFlags_LongGrassOnSpawn(mapObj, flags);
- GetGroundEffectFlags_SandHeap(mapObj, flags);
+ GetGroundEffectFlags_SandPile(mapObj, flags);
GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags);
GetGroundEffectFlags_ShortGrass(mapObj, flags);
GetGroundEffectFlags_HotSprings(mapObj, flags);
@@ -39,7 +40,7 @@ void GetAllGroundEffectFlags_OnBeginStep(struct MapObject *mapObj, u32 *flags)
GetGroundEffectFlags_TallGrassOnBeginStep(mapObj, flags);
GetGroundEffectFlags_LongGrassOnBeginStep(mapObj, flags);
GetGroundEffectFlags_Tracks(mapObj, flags);
- GetGroundEffectFlags_SandHeap(mapObj, flags);
+ GetGroundEffectFlags_SandPile(mapObj, flags);
GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags);
GetGroundEffectFlags_Puddle(mapObj, flags);
GetGroundEffectFlags_ShortGrass(mapObj, flags);
@@ -50,7 +51,7 @@ void GetAllGroundEffectFlags_OnFinishStep(struct MapObject *mapObj, u32 *flags)
{
FieldObjectUpdateMetatileBehaviors(mapObj);
GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags);
- GetGroundEffectFlags_SandHeap(mapObj, flags);
+ GetGroundEffectFlags_SandPile(mapObj, flags);
GetGroundEffectFlags_Puddle(mapObj, flags);
GetGroundEffectFlags_Ripple(mapObj, flags);
GetGroundEffectFlags_ShortGrass(mapObj, flags);
@@ -68,9 +69,7 @@ void FieldObjectUpdateMetatileBehaviors(struct MapObject *mapObj)
void GetGroundEffectFlags_Reflection(struct MapObject *mapObj, u32 *flags)
{
u32 reflectionFlags[2] = { 0x00000020, 0x00000010 };
- u8 type;
-
- type = FieldObjectCheckForReflectiveSurface(mapObj);
+ u8 type = FieldObjectCheckForReflectiveSurface(mapObj);
if (type)
{
@@ -86,3 +85,172 @@ void GetGroundEffectFlags_Reflection(struct MapObject *mapObj, u32 *flags)
mapObj->mapobj_bit_17 = 0;
}
}
+
+void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsTallGrass(mapObj->mapobj_unk_1E))
+ *flags |= 0x1;
+}
+
+void GetGroundEffectFlags_TallGrassOnBeginStep(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsTallGrass(mapObj->mapobj_unk_1E))
+ *flags |= 0x2;
+}
+
+void GetGroundEffectFlags_LongGrassOnSpawn(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsLongGrass(mapObj->mapobj_unk_1E))
+ *flags |= 0x4;
+}
+
+void GetGroundEffectFlags_LongGrassOnBeginStep(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsLongGrass(mapObj->mapobj_unk_1E))
+ *flags |= 0x8;
+}
+
+void GetGroundEffectFlags_Tracks(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsDeepSand(mapObj->mapobj_unk_1F))
+ {
+ *flags |= 0x100;
+ }
+ else if (MetatileBehavior_IsSandOrDeepSand(mapObj->mapobj_unk_1F)
+ || MetatileBehavior_IsUnusedFootprintMetatile(mapObj->mapobj_unk_1F))
+ {
+ *flags |= 0x80;
+ }
+}
+
+void GetGroundEffectFlags_SandPile(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsDeepSand(mapObj->mapobj_unk_1E)
+ && MetatileBehavior_IsDeepSand(mapObj->mapobj_unk_1F))
+ {
+ if (!mapObj->mapobj_bit_20)
+ {
+ mapObj->mapobj_bit_20 = 0;
+ mapObj->mapobj_bit_20 = 1;
+ *flags |= 0x800;
+ }
+ }
+ else
+ {
+ mapObj->mapobj_bit_20 = 0;
+ }
+}
+
+void GetGroundEffectFlags_ShallowFlowingWater(struct MapObject *mapObj, u32 *flags)
+{
+ if ((MetatileBehavior_IsShallowFlowingWater(mapObj->mapobj_unk_1E) && MetatileBehavior_IsShallowFlowingWater(mapObj->mapobj_unk_1F))
+ || (MetatileBehavior_IsPacifidlogLog(mapObj->mapobj_unk_1E) && MetatileBehavior_IsPacifidlogLog(mapObj->mapobj_unk_1F)))
+ {
+ if (!mapObj->mapobj_bit_19)
+ {
+ mapObj->mapobj_bit_19 = 0;
+ mapObj->mapobj_bit_19 = 1;
+ *flags |= 0x40;
+ }
+ }
+ else
+ {
+ mapObj->mapobj_bit_19 = 0;
+ }
+}
+
+void GetGroundEffectFlags_Puddle(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsPuddle(mapObj->mapobj_unk_1E)
+ && MetatileBehavior_IsPuddle(mapObj->mapobj_unk_1F))
+ {
+ *flags |= 0x400;
+ }
+}
+
+void GetGroundEffectFlags_Ripple(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_HasRipples(mapObj->mapobj_unk_1E))
+ *flags |= 0x200;
+}
+
+void GetGroundEffectFlags_ShortGrass(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsShortGrass(mapObj->mapobj_unk_1E)
+ && MetatileBehavior_IsShortGrass(mapObj->mapobj_unk_1F))
+ {
+ if (!mapObj->mapobj_bit_18)
+ {
+ mapObj->mapobj_bit_18 = 0;
+ mapObj->mapobj_bit_18 = 1;
+ *flags |= 0x20000;
+ }
+ }
+ else
+ {
+ mapObj->mapobj_bit_18 = 0;
+ }
+}
+
+void GetGroundEffectFlags_HotSprings(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsHotSprings(mapObj->mapobj_unk_1E)
+ && MetatileBehavior_IsHotSprings(mapObj->mapobj_unk_1F))
+ {
+ if (!mapObj->mapobj_bit_21)
+ {
+ mapObj->mapobj_bit_21 = 0;
+ mapObj->mapobj_bit_21 = 1;
+ *flags |= 0x40000;
+ }
+ }
+ else
+ {
+ mapObj->mapobj_bit_21 = 0;
+ }
+}
+
+void GetGroundEffectFlags_Seaweed(struct MapObject *mapObj, u32 *flags)
+{
+ if (MetatileBehavior_IsSeaweed(mapObj->mapobj_unk_1E))
+ *flags |= 0x80000;
+}
+
+void GetGroundEffectFlags_JumpLanding(struct MapObject *mapObj, u32 *flags)
+{
+ typedef bool8 (*MetatileFunc)(u8);
+
+ static const MetatileFunc metatileFuncs[] =
+ {
+ MetatileBehavior_IsTallGrass,
+ MetatileBehavior_IsLongGrass,
+ MetatileBehavior_IsPuddle,
+ MetatileBehavior_IsSurfableWaterOrUnderwater,
+ MetatileBehavior_IsShallowFlowingWater,
+ sub_8056D9C,
+ };
+
+ static const u32 jumpLandingFlags[] =
+ {
+ 0x00001000, // Landing in tall grass
+ 0x00002000, // Landing in long grass
+ 0x00004000, // Landing on puddle
+ 0x00008000, // Landing on surfable water or underwater
+ 0x00004000, // Landing on shallow flowing water
+ 0x00010000, // Landing on any other type of ground
+ };
+
+ if (mapObj->mapobj_bit_5 && !mapObj->mapobj_bit_25)
+ {
+ u8 i;
+
+ for (i = 0; i < 6; i++)
+ {
+ if (metatileFuncs[i](mapObj->mapobj_unk_1E))
+ {
+ *flags |= jumpLandingFlags[i];
+ return;
+ }
+ }
+ }
+}
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index 32835a431..5fffa785f 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -14,6 +14,7 @@
#include "field_effect.h"
#include "wild_encounter.h"
#include "asm_fieldmap.h"
+#include "metatile_behavior.h"
extern u8 gOtherText_OhABite[];
extern u8 gOtherText_PokeOnHook[];
diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c
index fe267df1c..dd1ac75e3 100644
--- a/src/metatile_behavior.c
+++ b/src/metatile_behavior.c
@@ -5,9 +5,9 @@ extern u8 gUnknown_08308E2C[];
bool8 MetatileBehavior_IsWaterfall(u8);
-s8 sub_8056D9C(void)
+bool8 sub_8056D9C(u8 var)
{
- return 1;
+ return TRUE;
}
bool8 sub_8056DA0(u8 var)
diff --git a/src/rom4.c b/src/rom4.c
index b81007fd5..bd5a9d285 100644
--- a/src/rom4.c
+++ b/src/rom4.c
@@ -30,6 +30,7 @@
#include "var.h"
#include "weather.h"
#include "wild_encounter.h"
+#include "metatile_behavior.h"
#ifdef SAPPHIRE
#define LEGENDARY_MUSIC BGM_OOAME // Heavy Rain
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 48fe3c116..1291242a7 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -11,6 +11,7 @@
#include "var.h"
#include "rom4.h"
#include "vars.h"
+#include "metatile_behavior.h"
struct WildPokemon
{