summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTouched <jtouched@gmail.com>2017-08-22 18:15:36 +0200
committerTouched <jtouched@gmail.com>2017-08-22 18:26:45 +0200
commite262fb05fb9a4a1fe1f1c3966e2c7e465b446ea9 (patch)
tree549aebd8f7c2d64880367fc206f768447848c6b9 /src
parent5adb839124412d5054630cf12020423e18161031 (diff)
Convert data/field_ground_effect.s to C
Diffstat (limited to 'src')
-rw-r--r--src/field_ground_effect.c169
1 files changed, 135 insertions, 34 deletions
diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c
index 79729471c..1a06b80f6 100644
--- a/src/field_ground_effect.c
+++ b/src/field_ground_effect.c
@@ -6,15 +6,122 @@
#include "fieldmap.h"
#include "metatile_behavior.h"
-extern u32 gUnknown_08376008[];
-extern u8 (*gUnknown_08376040[4])(u32 a);
-extern const u8 gFieldObjectPriorities_08376070[];
-extern const u8 gFieldObjectPriorities_08376060[];
-extern const u8 gUnknown_08376050[];
-extern void (*gUnknown_08376080[3])(struct MapObject *mapObj, struct Sprite *sprite, u8 a);
-extern const u8 gSandFootprints_FieldEffectData[4];
-extern const u8 gBikeTireTracks_Transitions[4][4];
-extern void (*gUnknown_083760A0[0x14])(struct MapObject *mapObj, struct Sprite *sprite);
+void nullsub_50(struct MapObject *mapObj, struct Sprite *sprite, u8);
+void DoTracksGroundEffect_Footprints(struct MapObject *mapObj, struct Sprite *sprite, u8);
+void DoTracksGroundEffect_BikeTireTracks(struct MapObject *mapObj, struct Sprite *sprite, u8);
+void GroundEffect_SpawnOnTallGrass(struct MapObject *mapObj, struct Sprite *sprite);
+void sub_8063E94(struct MapObject *mapObj, struct Sprite *sprite);
+void sub_8063EE0(struct MapObject *mapObj, struct Sprite *sprite);
+void sub_8063F2C(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_WaterReflection(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_IceReflection(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_FlowingWater(struct MapObject *mapObj, struct Sprite *sprite);
+void sub_8063FA0(struct MapObject *mapObj, struct Sprite *sprite);
+void sub_8063FCC(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_Ripple(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_StepOnPuddle(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_SandPile(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_JumpOnTallGrass(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_JumpOnLongGrass(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_JumpOnShallowWater(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_JumpOnWater(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_JumpLandingDust(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_ShortGrass(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_HotSprings(struct MapObject *mapObj, struct Sprite *sprite);
+void GroundEffect_Seaweed(struct MapObject *mapObj, struct Sprite *sprite);
+
+static const u32 sReflectionFlags[2] = { 0x00000020, 0x00000010 };
+
+typedef bool8 (*MetatileFunc)(u8);
+
+static const MetatileFunc metatileFuncs[] = {
+ MetatileBehavior_IsTallGrass,
+ MetatileBehavior_IsLongGrass,
+ MetatileBehavior_IsPuddle,
+ MetatileBehavior_IsSurfableWaterOrUnderwater,
+ MetatileBehavior_IsShallowFlowingWater,
+ MetatileBehavior_IsATile,
+};
+
+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
+};
+
+bool8 (*const gUnknown_08376040[])(u8) = {
+ MetatileBehavior_IsJumpSouth,
+ MetatileBehavior_IsJumpNorth,
+ MetatileBehavior_IsJumpWest,
+ MetatileBehavior_IsJumpEast,
+};
+
+const u8 gUnknown_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 a field object.
+// This is directly the inverse of gFieldObjectPriorities_08376070.
+const u8 gFieldObjectPriorities_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 a field object.
+// This is the inverse of gFieldObjectPriorities_08376060.
+// 1 = Above player sprite
+// 2 = Below player sprite
+const u8 gFieldObjectPriorities_08376070[] = {
+ 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1,
+};
+
+void (*const gUnknown_08376080[3])(struct MapObject *mapObj, struct Sprite *sprite, u8 a) = {
+ nullsub_50,
+ DoTracksGroundEffect_Footprints,
+ DoTracksGroundEffect_BikeTireTracks,
+};
+
+// First byte is a Field Effect script id. (gFieldEffectScriptPointers)
+// Last three bytes are unknown.
+const u8 gSandFootprints_FieldEffectData[4] = { 0xD, 0x0, 0x18, 0x0 };
+
+// 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.
+const u8 gBikeTireTracks_Transitions[4][4] = {
+ 1, 2, 7, 8,
+ 1, 2, 6, 5,
+ 5, 8, 3, 4,
+ 6, 7, 3, 4,
+};
+
+void (*const gUnknown_083760A0[0x14])(struct MapObject *mapObj, struct Sprite *sprite) = {
+ GroundEffect_SpawnOnTallGrass,
+ sub_8063E94,
+ sub_8063EE0,
+ sub_8063F2C,
+ GroundEffect_WaterReflection,
+ GroundEffect_IceReflection,
+ GroundEffect_FlowingWater,
+ sub_8063FA0,
+ sub_8063FCC,
+ GroundEffect_Ripple,
+ GroundEffect_StepOnPuddle,
+ GroundEffect_SandPile,
+ GroundEffect_JumpOnTallGrass,
+ GroundEffect_JumpOnLongGrass,
+ GroundEffect_JumpOnShallowWater,
+ GroundEffect_JumpOnWater,
+ GroundEffect_JumpLandingDust,
+ GroundEffect_ShortGrass,
+ GroundEffect_HotSprings,
+ GroundEffect_Seaweed
+};
#define NUM_GROUND_EFFECTS (sizeof(gUnknown_083760A0) / sizeof(gUnknown_083760A0[0]))
@@ -65,8 +172,18 @@ void FieldObjectUpdateMetatileBehaviors(struct MapObject *mapObj)
void GetGroundEffectFlags_Reflection(struct MapObject *mapObj, u32 *flags)
{
- u32 reflectionFlags[2] = { 0x00000020, 0x00000010 };
- u8 type = FieldObjectCheckForReflectiveSurface(mapObj);
+ u32 reflectionFlags[2];
+ u32 a; u32 b;
+ u8 type;
+
+ // Declaring sReflectionFlags inside the function is a neater match than
+ // this.
+ b = sReflectionFlags[1];
+ a = sReflectionFlags[0];
+ reflectionFlags[0] = a;
+ reflectionFlags[1] = b;
+
+ type = FieldObjectCheckForReflectiveSurface(mapObj);
if (type)
{
@@ -217,25 +334,7 @@ void GetGroundEffectFlags_Seaweed(struct MapObject *mapObj, u32 *flags)
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,
- MetatileBehavior_IsATile,
- };
-
- 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)
{
@@ -632,7 +731,7 @@ void GroundEffect_SpawnOnTallGrass(struct MapObject *mapObj, struct Sprite *spri
FieldEffectStart(4);
}
-void sub_8063E94(struct MapObject *mapObj)
+void sub_8063E94(struct MapObject *mapObj, struct Sprite *sprite)
{
u8 *ptr;
@@ -651,7 +750,7 @@ void sub_8063E94(struct MapObject *mapObj)
FieldEffectStart(4);
}
-void sub_8063EE0(struct MapObject *mapObj)
+void sub_8063EE0(struct MapObject *mapObj, struct Sprite *sprite)
{
u8 *ptr;
@@ -670,7 +769,7 @@ void sub_8063EE0(struct MapObject *mapObj)
FieldEffectStart(17);
}
-void sub_8063F2C(struct MapObject *mapObj)
+void sub_8063F2C(struct MapObject *mapObj, struct Sprite *sprite)
{
u8 *ptr;
@@ -699,7 +798,7 @@ void GroundEffect_IceReflection(struct MapObject *mapObj, struct Sprite *sprite)
SetUpReflection(mapObj, sprite, 1);
}
-void GroundEffect_FlowingWater(struct MapObject *mapObj)
+void GroundEffect_FlowingWater(struct MapObject *mapObj, struct Sprite *sprite)
{
oe_exec_and_other_stuff(FLDEFF_FEET_IN_FLOWING_WATER, mapObj);
}
@@ -906,3 +1005,5 @@ void DoGroundEffects_OnFinishStep(struct MapObject *mapObj, struct Sprite *sprit
mapObj->mapobj_bit_5 = 0;
}
}
+
+