summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
7 files changed, 182 insertions, 9 deletions
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
{