From 614ab538006f6a5df1de007f3e8343de35cf0cad Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sun, 18 Dec 2016 23:59:06 -0800 Subject: begin decompiling field_ground_effect.c --- src/field_ground_effect.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/field_ground_effect.c (limited to 'src/field_ground_effect.c') diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c new file mode 100644 index 000000000..e4742d384 --- /dev/null +++ b/src/field_ground_effect.c @@ -0,0 +1,63 @@ +#include "global.h" +#include "asm_fieldmap.h" + +void FieldObjectUpdateMetatileBehaviors(struct MapObject *); +void GetGroundEffectFlags_Reflection(struct MapObject *, u32 *); +void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject *, u32 *); +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_ShallowFlowingWater(struct MapObject *, u32 *); +void GetGroundEffectFlags_Puddle(struct MapObject *, u32 *); +void GetGroundEffectFlags_Ripple(struct MapObject *, u32 *); +void GetGroundEffectFlags_ShortGrass(struct MapObject *, u32 *); +void GetGroundEffectFlags_HotSprings(struct MapObject *, u32 *); +void GetGroundEffectFlags_Seaweed(struct MapObject *, u32 *); +void GetGroundEffectFlags_JumpLanding(struct MapObject *, u32 *); + +void GetAllGroundEffectFlags_OnSpawn(struct MapObject *mapObj, u32 *flags) +{ + FieldObjectUpdateMetatileBehaviors(mapObj); + GetGroundEffectFlags_Reflection(mapObj, flags); + GetGroundEffectFlags_TallGrassOnSpawn(mapObj, flags); + GetGroundEffectFlags_LongGrassOnSpawn(mapObj, flags); + GetGroundEffectFlags_SandHeap(mapObj, flags); + GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags); + GetGroundEffectFlags_ShortGrass(mapObj, flags); + GetGroundEffectFlags_HotSprings(mapObj, flags); +} + +void GetAllGroundEffectFlags_OnBeginStep(struct MapObject *mapObj, u32 *flags) +{ + FieldObjectUpdateMetatileBehaviors(mapObj); + GetGroundEffectFlags_Reflection(mapObj, flags); + GetGroundEffectFlags_TallGrassOnBeginStep(mapObj, flags); + GetGroundEffectFlags_LongGrassOnBeginStep(mapObj, flags); + GetGroundEffectFlags_Tracks(mapObj, flags); + GetGroundEffectFlags_SandHeap(mapObj, flags); + GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags); + GetGroundEffectFlags_Puddle(mapObj, flags); + GetGroundEffectFlags_ShortGrass(mapObj, flags); + GetGroundEffectFlags_HotSprings(mapObj, flags); +} + +void GetAllGroundEffectFlags_OnFinishStep(struct MapObject *mapObj, u32 *flags) +{ + FieldObjectUpdateMetatileBehaviors(mapObj); + GetGroundEffectFlags_ShallowFlowingWater(mapObj, flags); + GetGroundEffectFlags_SandHeap(mapObj, flags); + GetGroundEffectFlags_Puddle(mapObj, flags); + GetGroundEffectFlags_Ripple(mapObj, flags); + GetGroundEffectFlags_ShortGrass(mapObj, flags); + GetGroundEffectFlags_HotSprings(mapObj, flags); + GetGroundEffectFlags_Seaweed(mapObj, flags); + GetGroundEffectFlags_JumpLanding(mapObj, flags); +} + +void FieldObjectUpdateMetatileBehaviors(struct MapObject *mapObj) +{ + mapObj->mapobj_unk_1F = MapGridGetMetatileBehaviorAt(mapObj->coords3.x, mapObj->coords3.y); + mapObj->mapobj_unk_1E = MapGridGetMetatileBehaviorAt(mapObj->coords2.x, mapObj->coords2.y); +} -- cgit v1.2.3 From 805b2241b191cc33015a6d7cbb8a413050ea974a Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 19 Dec 2016 17:32:23 -0800 Subject: decompile GetGroundEffectFlags_Reflection --- src/field_ground_effect.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/field_ground_effect.c') diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c index e4742d384..358697339 100644 --- a/src/field_ground_effect.c +++ b/src/field_ground_effect.c @@ -1,6 +1,8 @@ #include "global.h" #include "asm_fieldmap.h" +extern u32 gUnknown_08376008[]; + void FieldObjectUpdateMetatileBehaviors(struct MapObject *); void GetGroundEffectFlags_Reflection(struct MapObject *, u32 *); void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject *, u32 *); @@ -16,6 +18,7 @@ void GetGroundEffectFlags_ShortGrass(struct MapObject *, u32 *); void GetGroundEffectFlags_HotSprings(struct MapObject *, u32 *); void GetGroundEffectFlags_Seaweed(struct MapObject *, u32 *); void GetGroundEffectFlags_JumpLanding(struct MapObject *, u32 *); +u8 FieldObjectCheckForReflectiveSurface(struct MapObject *); void GetAllGroundEffectFlags_OnSpawn(struct MapObject *mapObj, u32 *flags) { @@ -61,3 +64,25 @@ void FieldObjectUpdateMetatileBehaviors(struct MapObject *mapObj) mapObj->mapobj_unk_1F = MapGridGetMetatileBehaviorAt(mapObj->coords3.x, mapObj->coords3.y); mapObj->mapobj_unk_1E = MapGridGetMetatileBehaviorAt(mapObj->coords2.x, mapObj->coords2.y); } + +void GetGroundEffectFlags_Reflection(struct MapObject *mapObj, u32 *flags) +{ + u32 reflectionFlags[2] = { 0x00000020, 0x00000010 }; + u8 type; + + type = FieldObjectCheckForReflectiveSurface(mapObj); + + if (type) + { + if (!mapObj->mapobj_bit_17) + { + mapObj->mapobj_bit_17 = 0; + mapObj->mapobj_bit_17 = 1; + *flags |= reflectionFlags[type - 1]; + } + } + else + { + mapObj->mapobj_bit_17 = 0; + } +} -- cgit v1.2.3 From d6c8fad0ba67d581178a91cb2af2db09fc5e0bd1 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Mon, 19 Dec 2016 19:13:16 -0800 Subject: decompile ground effect flags functions --- src/field_ground_effect.c | 182 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 175 insertions(+), 7 deletions(-) (limited to 'src/field_ground_effect.c') 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; + } + } + } +} -- cgit v1.2.3 From 370c7f78539698902907f262721fe60e606c774d Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Wed, 4 Jan 2017 17:31:44 -0500 Subject: more labels (#159) * labels for tv.c and tv.s * match function prologue a little bit better * whoops * label and document lottery_corner.c * gSoftResetDisabled * add labels for main_menu.c * labels for metatile_behavior.c --- src/field_ground_effect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/field_ground_effect.c') diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c index 42cf5d676..1aea8f52e 100644 --- a/src/field_ground_effect.c +++ b/src/field_ground_effect.c @@ -227,7 +227,7 @@ void GetGroundEffectFlags_JumpLanding(struct MapObject *mapObj, u32 *flags) MetatileBehavior_IsPuddle, MetatileBehavior_IsSurfableWaterOrUnderwater, MetatileBehavior_IsShallowFlowingWater, - sub_8056D9C, + MetatileBehavior_IsATile, }; static const u32 jumpLandingFlags[] = -- cgit v1.2.3 From 4d2b22a899c11dfcacfec6889968ab01655a3fe3 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 26 May 2017 14:53:51 +0200 Subject: Add headers --- src/field_ground_effect.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'src/field_ground_effect.c') diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c index 1aea8f52e..357ba2df9 100644 --- a/src/field_ground_effect.c +++ b/src/field_ground_effect.c @@ -1,26 +1,10 @@ +#include "fieldmap.h" #include "global.h" -#include "asm_fieldmap.h" +#include "field_ground_effect.h" #include "metatile_behavior.h" extern u32 gUnknown_08376008[]; -void FieldObjectUpdateMetatileBehaviors(struct MapObject *); -void GetGroundEffectFlags_Reflection(struct MapObject *, u32 *); -void GetGroundEffectFlags_TallGrassOnSpawn(struct MapObject *, u32 *); -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_SandPile(struct MapObject *, u32 *); -void GetGroundEffectFlags_ShallowFlowingWater(struct MapObject *, u32 *); -void GetGroundEffectFlags_Puddle(struct MapObject *, u32 *); -void GetGroundEffectFlags_Ripple(struct MapObject *, u32 *); -void GetGroundEffectFlags_ShortGrass(struct MapObject *, u32 *); -void GetGroundEffectFlags_HotSprings(struct MapObject *, u32 *); -void GetGroundEffectFlags_Seaweed(struct MapObject *, u32 *); -void GetGroundEffectFlags_JumpLanding(struct MapObject *, u32 *); -u8 FieldObjectCheckForReflectiveSurface(struct MapObject *); - void GetAllGroundEffectFlags_OnSpawn(struct MapObject *mapObj, u32 *flags) { FieldObjectUpdateMetatileBehaviors(mapObj); -- cgit v1.2.3 From f26daa3d6954d2db3a7c44b79d319a7a084462c2 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 26 May 2017 15:01:42 +0200 Subject: Sort includes --- src/field_ground_effect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/field_ground_effect.c') diff --git a/src/field_ground_effect.c b/src/field_ground_effect.c index 357ba2df9..42862d0ff 100644 --- a/src/field_ground_effect.c +++ b/src/field_ground_effect.c @@ -1,6 +1,6 @@ -#include "fieldmap.h" #include "global.h" #include "field_ground_effect.h" +#include "fieldmap.h" #include "metatile_behavior.h" extern u32 gUnknown_08376008[]; -- cgit v1.2.3