summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcus Huderle <huderlem@gmail.com>2018-04-11 17:08:57 -0700
committerGitHub <noreply@github.com>2018-04-11 17:08:57 -0700
commitba6f60e4674785e4442232d0dd55bf13b9dab228 (patch)
tree5016ead4eb1c91971e5e753c326e39edfc3b3714 /src
parent49a7fe02416b0e5b2287c2fd4dbc979bc711457d (diff)
parent84c89b879501f9a3dbff024e0cd6b01dbacbdabe (diff)
Merge pull request #593 from huderlem/fieldeffects
Document some field effects
Diffstat (limited to 'src')
-rw-r--r--src/battle/battle_transition.c3
-rw-r--r--src/braille_puzzles.c9
-rw-r--r--src/debug/start_menu_debug.c9
-rw-r--r--src/event_object_movement.c3
-rw-r--r--src/field_effect.c53
-rw-r--r--src/field_effect_helpers.c3
-rw-r--r--src/field_player_avatar.c3
-rw-r--r--src/fldeff_cut.c143
-rw-r--r--src/fldeff_decoration.c3
-rw-r--r--src/fldeff_flash.c6
-rw-r--r--src/fldeff_secret_base_pc.c3
-rw-r--r--src/fldeff_secretpower.c212
-rw-r--r--src/fldeff_strength.c17
-rw-r--r--src/fldeff_sweetscent.c34
-rw-r--r--src/fldeff_teleport.c24
-rw-r--r--src/pokemon_menu.c37
-rw-r--r--src/rom6.c31
-rw-r--r--src/secret_base.c44
-rw-r--r--src/trainer_see.c1
19 files changed, 336 insertions, 302 deletions
diff --git a/src/battle/battle_transition.c b/src/battle/battle_transition.c
index a94974b27..d5035a862 100644
--- a/src/battle/battle_transition.c
+++ b/src/battle/battle_transition.c
@@ -10,11 +10,12 @@
#include "random.h"
#include "sprite.h"
#include "sound.h"
-#include "constants/songs.h"
#include "trainer.h"
#include "field_camera.h"
#include "ewram.h"
#include "scanline_effect.h"
+#include "constants/songs.h"
+#include "constants/field_effects.h"
void ScanlineEffect_Clear(void);
diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c
index f11fb5fb3..e7132a313 100644
--- a/src/braille_puzzles.c
+++ b/src/braille_puzzles.c
@@ -4,18 +4,19 @@
#include "field_camera.h"
#include "field_effect.h"
#include "fieldmap.h"
-#include "constants/flags.h"
#include "main.h"
-#include "constants/maps.h"
#include "map_obj_lock.h"
#include "menu.h"
#include "rom6.h"
#include "script.h"
-#include "constants/songs.h"
#include "sound.h"
-#include "constants/species.h"
#include "task.h"
#include "text.h"
+#include "constants/field_effects.h"
+#include "constants/flags.h"
+#include "constants/maps.h"
+#include "constants/songs.h"
+#include "constants/species.h"
extern u8 gPlayerPartyCount;
extern u8 gLastFieldPokeMenuOpened;
diff --git a/src/debug/start_menu_debug.c b/src/debug/start_menu_debug.c
index 549842c6a..b16b15a0a 100644
--- a/src/debug/start_menu_debug.c
+++ b/src/debug/start_menu_debug.c
@@ -34,12 +34,10 @@
#include "wild_encounter.h"
#include "battle_setup.h"
#include "safari_zone.h"
-#include "fldeff_cut.h"
#include "fldeff_flash.h"
#include "rom6.h"
#include "fldeff_strength.h"
#include "pokemon_menu.h"
-#include "fldeff_secretpower.h"
#include "data2.h"
#include "item.h"
#include "reset_rtc_screen.h"
@@ -49,6 +47,9 @@
#include "gba/m4a_internal.h"
#include "berry_blender.h"
+extern void Debug_SetUpFieldMove_Cut(void);
+extern void Debug_SetUpFieldMove_SecretPower(void);
+
void debug_sub_8076BB4(u8);
void debug_sub_8077CF4(u8 x, u8 y);
u8 DebugMenu_807706C(void);
@@ -1305,7 +1306,7 @@ u8 DebugMenu_Safari(void)
bool8 DebugMenu_8077BB4(void)
{
- debug_sub_80AFEE4();
+ Debug_SetUpFieldMove_Cut();
return TRUE;
}
@@ -1336,7 +1337,7 @@ bool8 DebugMenu_8077BE4(void)
bool8 DebugMenu_8077BF4(void)
{
- debug_sub_80D93F4();
+ Debug_SetUpFieldMove_SecretPower();
return TRUE;
}
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index 3fb611433..6883c82c1 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -12,9 +12,10 @@
#include "overworld.h"
#include "sprite.h"
#include "metatile_behavior.h"
+#include "trainer_see.h"
+#include "constants/field_effects.h"
#include "constants/maps.h"
#include "constants/map_objects.h"
-#include "trainer_see.h"
// this file was known as evobjmv.c in Game Freak's original source
diff --git a/src/field_effect.c b/src/field_effect.c
index ae0acf1a0..876df601c 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -3,6 +3,7 @@
#include "script.h"
#include "trig.h"
#include "main.h"
+#include "field_effect_helpers.h"
#include "field_weather.h"
#include "decompress.h"
#include "sprite.h"
@@ -12,7 +13,6 @@
#include "overworld.h"
#include "task.h"
#include "sound.h"
-#include "constants/songs.h"
#include "decoration.h"
#include "field_player_avatar.h"
#include "event_object_movement.h"
@@ -22,8 +22,9 @@
#include "field_fadetransition.h"
#include "fieldmap.h"
#include "util.h"
-#include "field_effect_helpers.h"
#include "pokemon_storage_system.h"
+#include "constants/field_effects.h"
+#include "constants/songs.h"
#define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))}
@@ -2080,27 +2081,31 @@ void sub_8087AC8(struct Task *task)
mapObject->mapobj_bit_13 ^= 1;
}
-void sub_8087BBC(u8);
-void mapldr_08085D88(void);
+static void ExecuteTeleportFieldEffectTask(u8);
+static void TeleportFieldEffectTask1(struct Task*);
+static void TeleportFieldEffectTask2(struct Task*);
+static void TeleportFieldEffectTask3(struct Task*);
+static void TeleportFieldEffectTask4(struct Task*);
+static void mapldr_08085D88(void);
-void sub_8087BA8(void)
+void CreateTeleportFieldEffectTask(void)
{
- CreateTask(sub_8087BBC, 0);
+ CreateTask(ExecuteTeleportFieldEffectTask, 0);
}
-void (*const gUnknown_0839F390[])(struct Task *) = {
- sub_8087BEC,
- sub_8087C14,
- sub_8087CA4,
- sub_8087D78
+static void (*const sTeleportFieldEffectTasks[])(struct Task *) = {
+ TeleportFieldEffectTask1,
+ TeleportFieldEffectTask2,
+ TeleportFieldEffectTask3,
+ TeleportFieldEffectTask4
};
-void sub_8087BBC(u8 taskId)
+static void ExecuteTeleportFieldEffectTask(u8 taskId)
{
- gUnknown_0839F390[gTasks[taskId].data[0]](&gTasks[taskId]);
+ sTeleportFieldEffectTasks[gTasks[taskId].data[0]](&gTasks[taskId]);
}
-void sub_8087BEC(struct Task *task)
+static void TeleportFieldEffectTask1(struct Task *task)
{
ScriptContext2_Enable();
FreezeMapObjects();
@@ -2109,13 +2114,13 @@ void sub_8087BEC(struct Task *task)
task->data[0]++;
}
-void sub_8087C14(struct Task *task)
+static void TeleportFieldEffectTask2(struct Task *task)
{
- u8 unknown_0839F380[5] = {1, 3, 4, 2, 1};
+ u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH};
struct MapObject *mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
if (task->data[1] == 0 || (--task->data[1]) == 0)
{
- FieldObjectTurn(mapObject, unknown_0839F380[mapObject->mapobj_unk_18]);
+ FieldObjectTurn(mapObject, spinDirections[mapObject->mapobj_unk_18]);
task->data[1] = 8;
task->data[2]++;
}
@@ -2129,15 +2134,15 @@ void sub_8087C14(struct Task *task)
}
}
-void sub_8087CA4(struct Task *task)
+static void TeleportFieldEffectTask3(struct Task *task)
{
- u8 unknown_0839F380[5] = {1, 3, 4, 2, 1};
+ u8 spinDirections[5] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH};
struct MapObject *mapObject = &gMapObjects[gPlayerAvatar.mapObjectId];
struct Sprite *sprite = &gSprites[gPlayerAvatar.spriteId];
if ((--task->data[1]) <= 0)
{
task->data[1] = 4;
- FieldObjectTurn(mapObject, unknown_0839F380[mapObject->mapobj_unk_18]);
+ FieldObjectTurn(mapObject, spinDirections[mapObject->mapobj_unk_18]);
}
sprite->pos1.y -= task->data[3];
task->data[4] += task->data[3];
@@ -2157,7 +2162,7 @@ void sub_8087CA4(struct Task *task)
}
}
-void sub_8087D78(struct Task *task)
+static void TeleportFieldEffectTask4(struct Task *task)
{
if (!gPaletteFade.active && sub_8054034() == TRUE)
{
@@ -2165,13 +2170,13 @@ void sub_8087D78(struct Task *task)
warp_in();
SetMainCallback2(CB2_LoadMap);
gFieldCallback = mapldr_08085D88;
- DestroyTask(FindTaskIdByFunc(sub_8087BBC));
+ DestroyTask(FindTaskIdByFunc(ExecuteTeleportFieldEffectTask));
}
}
void sub_8087E1C(u8);
-void mapldr_08085D88(void)
+static void mapldr_08085D88(void)
{
Overworld_PlaySpecialMapMusic();
pal_fill_for_map_transition();
@@ -3002,7 +3007,7 @@ void sub_8088D94(struct Task *task)
{
task->data[0]++;
task->data[2] = 16;
- SetPlayerAvatarTransitionFlags(0x01);
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
FieldObjectSetSpecialAnim(&gMapObjects[gPlayerAvatar.mapObjectId], 0x02);
}
}
diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c
index 216f39d62..be7bcec27 100644
--- a/src/field_effect_helpers.c
+++ b/src/field_effect_helpers.c
@@ -2,13 +2,14 @@
#include "sprite.h"
#include "fieldmap.h"
#include "metatile_behavior.h"
-#include "constants/songs.h"
#include "sound.h"
#include "event_object_movement.h"
#include "field_camera.h"
#include "field_weather.h"
#include "field_effect.h"
#include "field_effect_helpers.h"
+#include "constants/field_effects.h"
+#include "constants/songs.h"
static void sub_81269E0(struct Sprite *);
static void npc_pal_op(struct MapObject *mapObject, struct Sprite *sprite);
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index 1552381b2..3970cb824 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -7,7 +7,6 @@
#include "event_object_movement.h"
#include "fieldmap.h"
#include "main.h"
-#include "constants/map_objects.h"
#include "menu.h"
#include "metatile_behavior.h"
#include "new_game.h"
@@ -22,6 +21,8 @@
#include "task.h"
#include "tv.h"
#include "wild_encounter.h"
+#include "constants/field_effects.h"
+#include "constants/map_objects.h"
EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {0};
diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c
index c8f942fe5..bea376645 100644
--- a/src/fldeff_cut.c
+++ b/src/fldeff_cut.c
@@ -1,5 +1,4 @@
#include "global.h"
-#include "fldeff_cut.h"
#include "field_camera.h"
#include "field_effect.h"
#include "event_object_movement.h"
@@ -12,18 +11,20 @@
#include "overworld.h"
#include "rom6.h"
#include "script.h"
-#include "constants/songs.h"
#include "sound.h"
#include "sprite.h"
#include "task.h"
#include "trig.h"
#include "ewram.h"
+#include "constants/field_effects.h"
+#include "constants/map_objects.h"
+#include "constants/songs.h"
extern void (*gFieldCallback)(void);
-extern void (*gUnknown_03005CE4)(void);
+extern void (*gPostMenuFieldCallback)(void);
extern u8 gLastFieldPokeMenuOpened;
-extern const u8 S_UseCut[];
+extern const u8 DoCutFieldEffectScript[];
const struct OamData gOamData_CutGrass =
{
@@ -60,7 +61,17 @@ const struct SpriteFrameImage gSpriteImageTable_CutGrass[] =
const struct SpritePalette gFieldEffectObjectPaletteInfo6 = {gFieldEffectObjectPalette6, 0x1000};
-static void sub_80A2A48(struct Sprite *);
+static void FieldCallback_CutTree(void);
+static void FieldCallback_CutGrass(void);
+static void StartCutTreeFieldEffect(void);
+static void StartCutGrassFieldEffect(void);
+static void SetCutGrassMetatile(s16, s16);
+static void SetCutGrassMetatiles(s16, s16);
+static void CutGrassSpriteCallback1(struct Sprite *);
+static void CutGrassSpriteCallback2(struct Sprite *);
+static void CutGrassSpriteCallbackEnd(struct Sprite *);
+
+
static const struct SpriteTemplate gSpriteTemplate_CutGrass =
{
.tileTag = 0xFFFF,
@@ -69,44 +80,45 @@ static const struct SpriteTemplate gSpriteTemplate_CutGrass =
.anims = gSpriteAnimTable_CutGrass,
.images = gSpriteImageTable_CutGrass,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_80A2A48,
+ .callback = CutGrassSpriteCallback1,
};
#if DEBUG
-void debug_sub_80AFEE4(void)
+void Debug_SetUpFieldMove_Cut(void)
{
s16 x, y;
u8 i, j;
u8 metatile;
- if (npc_before_player_of_type(0x52) == TRUE)
+ if (SetLastTalkedObjectInFrontOfPlayer(MAP_OBJ_GFX_CUTTABLE_TREE) == TRUE)
{
gLastFieldPokeMenuOpened = 0;
- sub_80A2634();
+ FieldCallback_CutTree();
return;
}
- PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y);
+ PlayerGetDestCoords(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
for (i = 0; i < 3; i++)
{
- y = i - 1 + gUnknown_0203923C.y;
+ y = i - 1 + gPlayerFacingPosition.y;
for (j = 0; j < 3; j++)
{
- x = j - 1 + gUnknown_0203923C.x;
- if (MapGridGetZCoordAt(x, y) == gUnknown_0203923C.height)
+ x = j - 1 + gPlayerFacingPosition.x;
+ if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
{
metatile = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsPokeGrass(metatile) == TRUE
|| MetatileBehavior_IsAshGrass(metatile) == TRUE)
{
gLastFieldPokeMenuOpened = 0;
- sub_80A25E8();
+ FieldCallback_CutGrass();
return;
}
}
}
}
+
ScriptContext2_Disable();
}
@@ -118,39 +130,43 @@ bool8 SetUpFieldMove_Cut(void)
u8 i, j;
u8 tileBehavior;
- if(npc_before_player_of_type(0x52) == TRUE) // is in front of tree?
+ if (SetLastTalkedObjectInFrontOfPlayer(MAP_OBJ_GFX_CUTTABLE_TREE) == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_80A2634;
+ // Standing in front of cuttable tree.
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_CutTree;
return TRUE;
}
- else // is in ash or grass to cut?
+ else
{
- PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y);
- for(i = 0; i < 3; i++)
+ PlayerGetDestCoords(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
+ for (i = 0; i < 3; i++)
{
- y = i - 1 + gUnknown_0203923C.y;
- for(j = 0; j < 3; j++)
+ y = i - 1 + gPlayerFacingPosition.y;
+ for (j = 0; j < 3; j++)
{
- x = j - 1 + gUnknown_0203923C.x;
- if(MapGridGetZCoordAt(x, y) == gUnknown_0203923C.height)
+ x = j - 1 + gPlayerFacingPosition.x;
+ if(MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
{
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if(MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE
|| MetatileBehavior_IsAshGrass(tileBehavior) == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_80A25E8;
+ // Standing in front of grass.
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_CutGrass;
return TRUE;
}
}
}
}
- return FALSE; // do not use cut
+
+ // Not a valid location to use Cut.
+ return FALSE;
}
}
-void sub_80A25E8(void)
+static void FieldCallback_CutGrass(void)
{
FieldEffectStart(FLDEFF_USE_CUT_ON_GRASS);
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
@@ -160,29 +176,29 @@ bool8 FldEff_UseCutOnGrass(void)
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (u32)sub_80A2684 >> 16;
- gTasks[taskId].data[9] = (u32)sub_80A2684;
+ gTasks[taskId].data[8] = (u32)StartCutGrassFieldEffect >> 16;
+ gTasks[taskId].data[9] = (u32)StartCutGrassFieldEffect;
IncrementGameStat(GAME_STAT_USED_CUT);
return FALSE;
}
-void sub_80A2634(void)
+static void FieldCallback_CutTree(void)
{
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
- ScriptContext1_SetupScript(S_UseCut);
+ ScriptContext1_SetupScript(DoCutFieldEffectScript);
}
bool8 FldEff_UseCutOnTree(void)
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (u32)sub_80A2B00 >> 16;
- gTasks[taskId].data[9] = (u32)sub_80A2B00;
+ gTasks[taskId].data[8] = (u32)StartCutTreeFieldEffect >> 16;
+ gTasks[taskId].data[9] = (u32)StartCutTreeFieldEffect;
IncrementGameStat(GAME_STAT_USED_CUT);
return FALSE;
}
-void sub_80A2684(void)
+static void StartCutGrassFieldEffect(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_CUT_ON_GRASS);
FieldEffectStart(FLDEFF_CUT_GRASS);
@@ -192,41 +208,42 @@ bool8 FldEff_CutGrass(void)
{
s16 x, y;
u8 tileBehavior;
- u8 i, j; // not in for loop?
+ u8 i, j;
- for(i = 0, PlaySE(SE_W015), PlayerGetDestCoords(&gUnknown_0203923C.x, &gUnknown_0203923C.y); i < 3; i++)
+ for (i = 0, PlaySE(SE_W015), PlayerGetDestCoords(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y); i < 3; i++)
{
- y = i - 1 + gUnknown_0203923C.y;
- for(j = 0; j < 3; j++)
+ y = i - 1 + gPlayerFacingPosition.y;
+ for (j = 0; j < 3; j++)
{
- x = j - 1 + gUnknown_0203923C.x;
- if(MapGridGetZCoordAt(x, y) == (s8)gUnknown_0203923C.height)
+ x = j - 1 + gPlayerFacingPosition.x;
+ if (MapGridGetZCoordAt(x, y) == (s8)gPlayerFacingPosition.height)
{
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
- if(MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE)
+ if (MetatileBehavior_IsCuttableGrass(tileBehavior) == TRUE)
{
- sub_80A27A8(x, y);
+ SetCutGrassMetatile(x, y);
sub_805BCC0(x, y);
}
}
}
}
- sub_80A28F4(gUnknown_0203923C.x - 1, gUnknown_0203923C.y - 2);
+
+ SetCutGrassMetatiles(gPlayerFacingPosition.x - 1, gPlayerFacingPosition.y - 2);
DrawWholeMapView();
// populate sprite ID array
- for(i = 0; i < 8; i++)
+ for (i = 0; i < 8; i++)
{
eCutGrassSpriteArray[i] = CreateSprite((struct SpriteTemplate *)&gSpriteTemplate_CutGrass,
gSprites[gPlayerAvatar.spriteId].oam.x + 8, gSprites[gPlayerAvatar.spriteId].oam.y + 20, 0);
gSprites[eCutGrassSpriteArray[i]].data[2] = 32 * i;
}
+
return 0;
}
// set map grid metatile depending on x, y
-// TODO: enum for metatile IDs
-void sub_80A27A8(s16 x, s16 y)
+static void SetCutGrassMetatile(s16 x, s16 y)
{
int metatileId = MapGridGetMetatileIdAt(x, y);
@@ -266,7 +283,7 @@ void sub_80A27A8(s16 x, s16 y)
}
}
-s32 sub_80A28A0(s16 x, s16 y)
+static s32 sub_80A28A0(s16 x, s16 y)
{
u16 metatileId = MapGridGetMetatileIdAt(x, y);
@@ -282,18 +299,18 @@ s32 sub_80A28A0(s16 x, s16 y)
return 0;
}
-void sub_80A28F4(s16 x, s16 y)
+static void SetCutGrassMetatiles(s16 x, s16 y)
{
s16 i;
u16 lowerY = y + 3;
- for(i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++)
{
u16 currentX = x + i;
s16 currentXsigned = x + i;
- if(MapGridGetMetatileIdAt(currentXsigned, y) == 21)
+ if (MapGridGetMetatileIdAt(currentXsigned, y) == 21)
{
- switch((u8)sub_80A28A0(currentXsigned, y + 1))
+ switch ((u8)sub_80A28A0(currentXsigned, y + 1))
{
case 1:
MapGridSetMetatileIdAt(currentXsigned, y + 1, 0x208);
@@ -309,29 +326,29 @@ void sub_80A28F4(s16 x, s16 y)
break;
}
}
- if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY) == 1)
+ if (MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY) == 1)
{
- if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x208)
+ if (MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x208)
MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x1);
- if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x281)
+ if (MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x281)
MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x279);
- if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x282)
+ if (MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x282)
MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x27A);
- if(MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x283)
+ if (MapGridGetMetatileIdAt((s16)currentX, (s16)lowerY + 1) == 0x283)
MapGridSetMetatileIdAt((s16)currentX, (s16)lowerY + 1, 0x27B);
}
}
}
-static void sub_80A2A48(struct Sprite *sprite)
+static void CutGrassSpriteCallback1(struct Sprite *sprite)
{
sprite->data[0] = 8;
sprite->data[1] = 0;
sprite->data[3] = 0;
- sprite->callback = (void *)objc_8097BBC;
+ sprite->callback = CutGrassSpriteCallback2;
}
-void objc_8097BBC(struct Sprite *sprite)
+static void CutGrassSpriteCallback2(struct Sprite *sprite)
{
u16 tempdata;
u16 tempdata2;
@@ -347,10 +364,10 @@ void objc_8097BBC(struct Sprite *sprite)
if((s16)tempdata != 28) // done rotating the grass, execute clean up function
sprite->data[1]++;
else
- sprite->callback = (void *)sub_80A2AB8;
+ sprite->callback = CutGrassSpriteCallbackEnd;
}
-void sub_80A2AB8(void)
+static void CutGrassSpriteCallbackEnd(struct Sprite *sprite)
{
u8 i;
@@ -361,7 +378,7 @@ void sub_80A2AB8(void)
ScriptContext2_Disable();
}
-void sub_80A2B00(void)
+static void StartCutTreeFieldEffect(void)
{
PlaySE(SE_W015);
FieldEffectActiveListRemove(FLDEFF_USE_CUT_ON_TREE);
diff --git a/src/fldeff_decoration.c b/src/fldeff_decoration.c
index 1859fc00b..467e7bca4 100644
--- a/src/fldeff_decoration.c
+++ b/src/fldeff_decoration.c
@@ -6,12 +6,13 @@
#include "field_player_avatar.h"
#include "fieldmap.h"
#include "script.h"
-#include "constants/songs.h"
#include "sound.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "text.h"
+#include "constants/field_effects.h"
+#include "constants/songs.h"
extern const u8 gSpriteImage_83D21EC[];
extern const u8 gSpriteImage_83D22EC[];
diff --git a/src/fldeff_flash.c b/src/fldeff_flash.c
index 30ddd0f6c..a9f64a2d1 100644
--- a/src/fldeff_flash.c
+++ b/src/fldeff_flash.c
@@ -22,7 +22,7 @@ struct FlashStruct
};
extern u8 gLastFieldPokeMenuOpened;
-extern void (*gUnknown_03005CE4)(void);
+extern void (*gPostMenuFieldCallback)(void);
extern u8 gUnknown_081B694A[];
@@ -87,8 +87,8 @@ bool8 SetUpFieldMove_Flash(void)
{
if (gMapHeader.cave == TRUE && !FlagGet(FLAG_SYS_USE_FLASH))
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_810CBFC;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_810CBFC;
return TRUE;
}
diff --git a/src/fldeff_secret_base_pc.c b/src/fldeff_secret_base_pc.c
index 394c4bc56..f9898c444 100644
--- a/src/fldeff_secret_base_pc.c
+++ b/src/fldeff_secret_base_pc.c
@@ -5,9 +5,10 @@
#include "field_player_avatar.h"
#include "fieldmap.h"
#include "script.h"
-#include "constants/songs.h"
#include "sound.h"
#include "task.h"
+#include "constants/field_effects.h"
+#include "constants/songs.h"
static void Task_SecretBasePCTurnOn(u8);
diff --git a/src/fldeff_secretpower.c b/src/fldeff_secretpower.c
index d1df03d84..e58a1e82f 100644
--- a/src/fldeff_secretpower.c
+++ b/src/fldeff_secretpower.c
@@ -10,12 +10,13 @@
#include "rom6.h"
#include "script.h"
#include "secret_base.h"
-#include "constants/songs.h"
#include "sound.h"
+#include "constants/field_effects.h"
+#include "constants/songs.h"
-extern u8 gUnknown_081A2CE6[];
-extern u8 gUnknown_081A2D3E[];
-extern u8 gUnknown_081A2D96[];
+extern u8 DoSecretBaseCaveFieldEffectScript[];
+extern u8 DoSecretBaseTreeFieldEffectScript[];
+extern u8 DoSecretBaseShrubFieldEffectScript[];
const u8 gSpriteImage_83D198C[] = INCBIN_U8("graphics/unknown_sprites/83D259C/0.4bpp");
const u8 gSpriteImage_83D1A0C[] = INCBIN_U8("graphics/unknown_sprites/83D259C/1.4bpp");
@@ -162,8 +163,8 @@ const struct SpriteFrameImage gSpriteImageTable_83D25EC[] =
{gSpriteImage_83D1E4C, 0x80},
};
-void sub_80C644C(struct Sprite *);
-const struct SpriteTemplate gSpriteTemplate_83D2614 =
+static void CaveEntranceSpriteCallback1(struct Sprite *);
+static const struct SpriteTemplate sSpriteTemplate_CaveEntrance =
{
.tileTag = 0xFFFF,
.paletteTag = 4099,
@@ -171,11 +172,11 @@ const struct SpriteTemplate gSpriteTemplate_83D2614 =
.anims = gSpriteAnimTable_83D2584,
.images = gSpriteImageTable_83D259C,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_80C644C,
+ .callback = CaveEntranceSpriteCallback1,
};
-void sub_80C6598(struct Sprite *);
-const struct SpriteTemplate gSpriteTemplate_83D262C =
+static void TreeEntranceSpriteCallback1(struct Sprite *);
+const struct SpriteTemplate sSpriteTemplate_TreeEntrance =
{
.tileTag = 0xFFFF,
.paletteTag = 4104,
@@ -183,11 +184,11 @@ const struct SpriteTemplate gSpriteTemplate_83D262C =
.anims = gSpriteAnimTable_83D2588,
.images = gSpriteImageTable_83D25C4,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_80C6598,
+ .callback = TreeEntranceSpriteCallback1,
};
-void sub_80C66BC(struct Sprite *);
-const struct SpriteTemplate gSpriteTemplate_83D2644 =
+static void ShrubEntranceSpriteCallback1(struct Sprite *);
+const struct SpriteTemplate sSpriteTemplate_ShrubEntrance =
{
.tileTag = 0xFFFF,
.paletteTag = 4104,
@@ -195,48 +196,48 @@ const struct SpriteTemplate gSpriteTemplate_83D2644 =
.anims = gSpriteAnimTable_83D2598,
.images = gSpriteImageTable_83D25EC,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_80C66BC,
+ .callback = ShrubEntranceSpriteCallback1,
};
const struct SpritePalette gFieldEffectObjectPaletteInfo7 = {gFieldEffectObjectPalette7, 0x1003};
const struct SpritePalette gFieldEffectObjectPaletteInfo8 = {gFieldEffectObjectPalette8, 0x1008};
-void sub_80C639C(void);
-void sub_80C63E8(void);
-void sub_80C6468(struct Sprite *);
-void sub_80C6498(struct Sprite *);
-void sub_80C64A8(void);
-void sub_80C64F4(void);
-void sub_80C65C4(struct Sprite *);
-void sub_80C65FC(struct Sprite *);
-void sub_80C660C(void);
-void sub_80C6658(void);
-void sub_80C66D8(struct Sprite *sprite);
-void sub_80C6708(struct Sprite *sprite);
-
-void sub_80C6264(void)
-{
- sub_80BBFD8(&gUnknown_0203923C, gMapHeader.events);
- sub_80BB5E4();
+static void FieldCallback_SecretBaseCave(void);
+static void StartSecretBaseCaveFieldEffect(void);
+static void CaveEntranceSpriteCallback2(struct Sprite *);
+static void CaveEntranceSpriteCallbackEnd(struct Sprite *);
+static void FieldCallback_SecretBaseTree(void);
+static void StartSecretBaseTreeFieldEffect(void);
+static void TreeEntranceSpriteCallback2(struct Sprite *);
+static void TreeEntranceSpriteCallbackEnd(struct Sprite *);
+static void FieldCallback_SecretBaseShrub(void);
+static void StartSecretBaseShrubFieldEffect(void);
+static void ShrubEntranceSpriteCallback2(struct Sprite *sprite);
+static void ShrubEntranceSpriteCallbackEnd(struct Sprite *sprite);
+
+static void SetCurrentSecretBase(void)
+{
+ SetCurrentSecretBaseFromPosition(&gPlayerFacingPosition, gMapHeader.events);
+ SetCurrentSecretBaseVar();
}
-void sub_80C6280(void)
+static void AdjustSecretPowerSpritePixelOffsets(void)
{
switch (gFieldEffectArguments[1])
{
- case 1:
+ case DIR_SOUTH:
gFieldEffectArguments[5] = 8;
gFieldEffectArguments[6] = 40;
break;
- case 2:
+ case DIR_NORTH:
gFieldEffectArguments[5] = 8;
gFieldEffectArguments[6] = 8;
break;
- case 3:
+ case DIR_WEST:
gFieldEffectArguments[5] = -8;
gFieldEffectArguments[6] = 24;
break;
- case 4:
+ case DIR_EAST:
gFieldEffectArguments[5] = 24;
gFieldEffectArguments[6] = 24;
break;
@@ -245,37 +246,37 @@ void sub_80C6280(void)
#if DEBUG
-void debug_sub_80D93F4(void)
+void Debug_SetUpFieldMove_SecretPower(void)
{
u8 metatile;
- sub_80BB63C();
+ CheckPlayerHasSecretBase();
- if (gSpecialVar_Result == 1 || player_get_direction_lower_nybble() != 2)
+ if (gSpecialVar_Result == 1 || player_get_direction_lower_nybble() != DIR_NORTH)
{
ScriptContext2_Disable();
return;
}
- GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203923C.x, &gUnknown_0203923C.y);
- metatile = MapGridGetMetatileBehaviorAt(gUnknown_0203923C.x, gUnknown_0203923C.y);
+ GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
+ metatile = MapGridGetMetatileBehaviorAt(gPlayerFacingPosition.x, gPlayerFacingPosition.y);
if (MetatileBehavior_IsSecretBaseCave(metatile) == TRUE)
{
- sub_80C6264();
+ SetCurrentSecretBase();
gLastFieldPokeMenuOpened = 0;
- sub_80C639C();
+ FieldCallback_SecretBaseCave();
}
else if (MetatileBehavior_IsSecretBaseTree(metatile) == TRUE)
{
- sub_80C6264();
+ SetCurrentSecretBase();
gLastFieldPokeMenuOpened = 0;
- sub_80C64A8();
+ FieldCallback_SecretBaseTree();
}
else if (MetatileBehavior_IsSecretBaseShrub(metatile) == TRUE)
{
- sub_80C6264();
+ SetCurrentSecretBase();
gLastFieldPokeMenuOpened = 0;
- sub_80C660C();
+ FieldCallback_SecretBaseShrub();
}
else
{
@@ -289,58 +290,57 @@ bool8 SetUpFieldMove_SecretPower(void)
{
u8 behavior;
- sub_80BB63C();
-
+ CheckPlayerHasSecretBase();
if (gSpecialVar_Result == 1 || player_get_direction_lower_nybble() != DIR_NORTH)
return FALSE;
- GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203923C.x, &gUnknown_0203923C.y);
- behavior = MapGridGetMetatileBehaviorAt(gUnknown_0203923C.x, gUnknown_0203923C.y);
+ GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
+ behavior = MapGridGetMetatileBehaviorAt(gPlayerFacingPosition.x, gPlayerFacingPosition.y);
if (MetatileBehavior_IsSecretBaseCave(behavior) == TRUE)
{
- sub_80C6264();
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_80C639C;
+ SetCurrentSecretBase();
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_SecretBaseCave;
return TRUE;
}
if (MetatileBehavior_IsSecretBaseTree(behavior) == TRUE)
{
- sub_80C6264();
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_80C64A8;
+ SetCurrentSecretBase();
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_SecretBaseTree;
return TRUE;
}
if (MetatileBehavior_IsSecretBaseShrub(behavior) == TRUE)
{
- sub_80C6264();
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_80C660C;
+ SetCurrentSecretBase();
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_SecretBaseShrub;
return TRUE;
}
return FALSE;
}
-void sub_80C639C(void)
+static void FieldCallback_SecretBaseCave(void)
{
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
- ScriptContext1_SetupScript(gUnknown_081A2CE6);
+ ScriptContext1_SetupScript(DoSecretBaseCaveFieldEffectScript);
}
bool8 FldEff_UseSecretPowerCave(void)
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (uintptr_t)sub_80C63E8 >> 16;
- gTasks[taskId].data[9] = (uintptr_t)sub_80C63E8;
+ gTasks[taskId].data[8] = (uintptr_t)StartSecretBaseCaveFieldEffect >> 16;
+ gTasks[taskId].data[9] = (uintptr_t)StartSecretBaseCaveFieldEffect;
return FALSE;
}
-void sub_80C63E8(void)
+static void StartSecretBaseCaveFieldEffect(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_SECRET_POWER_CAVE);
FieldEffectStart(FLDEFF_SECRET_POWER_CAVE);
@@ -348,60 +348,60 @@ void sub_80C63E8(void)
bool8 FldEff_SecretPowerCave(void)
{
- sub_80C6280();
+ AdjustSecretPowerSpritePixelOffsets();
CreateSprite(
- &gSpriteTemplate_83D2614,
+ &sSpriteTemplate_CaveEntrance,
gSprites[gPlayerAvatar.spriteId].oam.x + gFieldEffectArguments[5],
gSprites[gPlayerAvatar.spriteId].oam.y + gFieldEffectArguments[6],
148);
return FALSE;
}
-void sub_80C644C(struct Sprite *sprite)
+static void CaveEntranceSpriteCallback1(struct Sprite *sprite)
{
PlaySE(SE_W088);
sprite->data[0] = 0;
- sprite->callback = sub_80C6468;
+ sprite->callback = CaveEntranceSpriteCallback2;
}
-void sub_80C6468(struct Sprite *sprite)
+static void CaveEntranceSpriteCallback2(struct Sprite *sprite)
{
if (sprite->data[0] < 40)
{
sprite->data[0]++;
- if (sprite->data[0] == 20 )
- sub_80BB800();
+ if (sprite->data[0] == 20)
+ SetOpenedSecretBaseMetatile();
}
else
{
sprite->data[0] = 0;
- sprite->callback = sub_80C6498;
+ sprite->callback = CaveEntranceSpriteCallbackEnd;
}
}
-void sub_80C6498(struct Sprite *sprite)
+static void CaveEntranceSpriteCallbackEnd(struct Sprite *sprite)
{
FieldEffectStop(sprite, FLDEFF_SECRET_POWER_CAVE);
EnableBothScriptContexts();
}
-void sub_80C64A8(void)
+static void FieldCallback_SecretBaseTree(void)
{
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
- ScriptContext1_SetupScript(gUnknown_081A2D3E);
+ ScriptContext1_SetupScript(DoSecretBaseTreeFieldEffectScript);
}
bool8 FldEff_UseSecretPowerTree(void)
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (uintptr_t)sub_80C64F4 >> 16;
- gTasks[taskId].data[9] = (uintptr_t)sub_80C64F4;
+ gTasks[taskId].data[8] = (uintptr_t)StartSecretBaseTreeFieldEffect >> 16;
+ gTasks[taskId].data[9] = (uintptr_t)StartSecretBaseTreeFieldEffect;
return FALSE;
}
-void sub_80C64F4(void)
+static void StartSecretBaseTreeFieldEffect(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_SECRET_POWER_TREE);
FieldEffectStart(FLDEFF_SECRET_POWER_TREE);
@@ -409,77 +409,72 @@ void sub_80C64F4(void)
bool8 FldEff_SecretPowerTree(void)
{
- s16 behavior = MapGridGetMetatileBehaviorAt(gUnknown_0203923C.x, gUnknown_0203923C.y) & 0xFFF;
+ s16 behavior = MapGridGetMetatileBehaviorAt(gPlayerFacingPosition.x, gPlayerFacingPosition.y) & 0xFFF;
if (behavior == MB_SECRET_BASE_SPOT_TREE_1)
- {
gFieldEffectArguments[7] = 0;
- }
if (behavior == MB_SECRET_BASE_SPOT_TREE_2)
- {
gFieldEffectArguments[7] = 2;
- }
-
- sub_80C6280();
+ AdjustSecretPowerSpritePixelOffsets();
CreateSprite(
- &gSpriteTemplate_83D262C,
+ &sSpriteTemplate_TreeEntrance,
gSprites[gPlayerAvatar.spriteId].oam.x + gFieldEffectArguments[5],
gSprites[gPlayerAvatar.spriteId].oam.y + gFieldEffectArguments[6],
148);
if (gFieldEffectArguments[7] == 1 || gFieldEffectArguments[7] == 3)
- sub_80BB800();
+ SetOpenedSecretBaseMetatile();
return FALSE;
}
-void sub_80C6598(struct Sprite *sprite)
+static void TreeEntranceSpriteCallback1(struct Sprite *sprite)
{
PlaySE(SE_W010);
sprite->animNum = gFieldEffectArguments[7];
sprite->data[0] = 0;
- sprite->callback = sub_80C65C4;
+ sprite->callback = TreeEntranceSpriteCallback2;
}
-void sub_80C65C4(struct Sprite *sprite)
+static void TreeEntranceSpriteCallback2(struct Sprite *sprite)
{
sprite->data[0]++;
if (sprite->data[0] >= 40)
{
if (gFieldEffectArguments[7] == 0 || gFieldEffectArguments[7] == 2)
- sub_80BB800();
+ SetOpenedSecretBaseMetatile();
+
sprite->data[0] = 0;
- sprite->callback = sub_80C65FC;
+ sprite->callback = TreeEntranceSpriteCallbackEnd;
}
}
-
-void sub_80C65FC(struct Sprite *sprite)
+static void TreeEntranceSpriteCallbackEnd(struct Sprite *sprite)
{
FieldEffectStop(sprite, FLDEFF_SECRET_POWER_TREE);
EnableBothScriptContexts();
}
-void sub_80C660C(void)
+static void FieldCallback_SecretBaseShrub(void)
{
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
- ScriptContext1_SetupScript(gUnknown_081A2D96);
+ ScriptContext1_SetupScript(DoSecretBaseShrubFieldEffectScript);
}
bool8 FldEff_UseSecretPowerShrub(void)
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (uintptr_t)sub_80C6658 >> 16;
- gTasks[taskId].data[9] = (uintptr_t)sub_80C6658;
+ gTasks[taskId].data[8] = (uintptr_t)StartSecretBaseShrubFieldEffect >> 16;
+ gTasks[taskId].data[9] = (uintptr_t)StartSecretBaseShrubFieldEffect;
return FALSE;
}
-void sub_80C6658(void)
+static void StartSecretBaseShrubFieldEffect(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_SECRET_POWER_SHRUB);
FieldEffectStart(FLDEFF_SECRET_POWER_SHRUB);
@@ -487,39 +482,38 @@ void sub_80C6658(void)
bool8 FldEff_SecretPowerShrub(void)
{
- sub_80C6280();
+ AdjustSecretPowerSpritePixelOffsets();
CreateSprite(
- &gSpriteTemplate_83D2644,
+ &sSpriteTemplate_ShrubEntrance,
gSprites[gPlayerAvatar.spriteId].oam.x + gFieldEffectArguments[5],
gSprites[gPlayerAvatar.spriteId].oam.y + gFieldEffectArguments[6],
148);
return FALSE;
}
-void sub_80C66BC(struct Sprite *sprite)
+static void ShrubEntranceSpriteCallback1(struct Sprite *sprite)
{
PlaySE(SE_W077);
sprite->data[0] = 0;
- sprite->callback = sub_80C66D8;
+ sprite->callback = ShrubEntranceSpriteCallback2;
}
-void sub_80C66D8(struct Sprite *sprite)
+static void ShrubEntranceSpriteCallback2(struct Sprite *sprite)
{
if (sprite->data[0] < 40)
{
sprite->data[0]++;
- if (sprite->data[0] == 20 )
- sub_80BB800();
+ if (sprite->data[0] == 20)
+ SetOpenedSecretBaseMetatile();
}
else
{
sprite->data[0] = 0;
- sprite->callback = sub_80C6708;
+ sprite->callback = ShrubEntranceSpriteCallbackEnd;
}
}
-
-void sub_80C6708(struct Sprite *sprite)
+static void ShrubEntranceSpriteCallbackEnd(struct Sprite *sprite)
{
FieldEffectStop(sprite, FLDEFF_SECRET_POWER_SHRUB);
EnableBothScriptContexts();
diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c
index 9f9cd4013..9f1f3a670 100644
--- a/src/fldeff_strength.c
+++ b/src/fldeff_strength.c
@@ -1,5 +1,4 @@
#include "global.h"
-#include "constants/map_objects.h"
#include "braille_puzzles.h"
#include "field_effect.h"
#include "party_menu.h"
@@ -9,6 +8,8 @@
#include "script.h"
#include "task.h"
#include "text.h"
+#include "constants/field_effects.h"
+#include "constants/map_objects.h"
static void sub_811AA18(void);
static void sub_811AA38(void);
@@ -17,7 +18,7 @@ static void sub_811AA9C(void);
extern u8 gLastFieldPokeMenuOpened;
extern u16 gSpecialVar_Result;
extern void (*gFieldCallback)(void);
-extern void (*gUnknown_03005CE4)(void);
+extern void (*gPostMenuFieldCallback)(void);
extern u8 S_UseStrength[];
@@ -30,7 +31,7 @@ void debug_sub_8130318(void)
gSpecialVar_Result = 0;
sub_811AA38();
}
- else if (npc_before_player_of_type(MAP_OBJ_GFX_PUSHABLE_BOULDER) == TRUE)
+ else if (SetLastTalkedObjectInFrontOfPlayer(MAP_OBJ_GFX_PUSHABLE_BOULDER) == TRUE)
{
gLastFieldPokeMenuOpened = 0;
gSpecialVar_Result = 0;
@@ -48,16 +49,16 @@ bool8 SetUpFieldMove_Strength(void)
if (ShouldDoBrailleStrengthEffect())
{
gSpecialVar_Result = gLastFieldPokeMenuOpened;
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_811AA38;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_811AA38;
}
else
{
- if (npc_before_player_of_type(87) != TRUE)
+ if (SetLastTalkedObjectInFrontOfPlayer(MAP_OBJ_GFX_PUSHABLE_BOULDER) != TRUE)
return 0;
gSpecialVar_Result = gLastFieldPokeMenuOpened;
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_811AA18;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_811AA18;
}
return TRUE;
diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c
index b9dbf619d..c6e3211b8 100644
--- a/src/fldeff_sweetscent.c
+++ b/src/fldeff_sweetscent.c
@@ -9,26 +9,28 @@
#include "sprite.h"
#include "task.h"
#include "wild_encounter.h"
+#include "constants/field_effects.h"
+#include "constants/songs.h"
-static void sub_812BFD4(void);
-static void sub_812C01C(void);
-static void sub_812C084(u8);
-static void sub_812C118(u8);
+static void FieldCallback_SweetScent(void);
+static void StartSweetScentFieldEffect(void);
+static void TrySweetScentEncounter(u8);
+static void FailSweetScentEncounter(u8);
extern u8 gLastFieldPokeMenuOpened;
extern void (*gFieldCallback)(void);
-extern void (*gUnknown_03005CE4)(void);
+extern void (*gPostMenuFieldCallback)(void);
extern u8 SweetScentNothingHereScript[];
bool8 SetUpFieldMove_SweetScent(void)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_812BFD4;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_SweetScent;
return TRUE;
}
-static void sub_812BFD4(void)
+static void FieldCallback_SweetScent(void)
{
FieldEffectStart(FLDEFF_SWEET_SCENT);
gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
@@ -38,23 +40,23 @@ bool8 FldEff_SweetScent()
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (u32)sub_812C01C >> 16;
- gTasks[taskId].data[9] = (u32)sub_812C01C;
+ gTasks[taskId].data[8] = (u32)StartSweetScentFieldEffect >> 16;
+ gTasks[taskId].data[9] = (u32)StartSweetScentFieldEffect;
return FALSE;
}
-static void sub_812C01C(void)
+static void StartSweetScentFieldEffect(void)
{
u8 taskId;
- PlaySE(0xEC);
+ PlaySE(SE_W230);
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, 0x1F);
- taskId = CreateTask(sub_812C084, 0);
+ taskId = CreateTask(TrySweetScentEncounter, 0);
gTasks[taskId].data[0] = 0;
FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT);
}
-static void sub_812C084(u8 taskId)
+static void TrySweetScentEncounter(u8 taskId)
{
if (!gPaletteFade.active)
{
@@ -67,7 +69,7 @@ static void sub_812C084(u8 taskId)
}
else
{
- gTasks[taskId].func = sub_812C118;
+ gTasks[taskId].func = FailSweetScentEncounter;
BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, 0x1F);
}
}
@@ -78,7 +80,7 @@ static void sub_812C084(u8 taskId)
}
}
-static void sub_812C118(u8 taskId)
+static void FailSweetScentEncounter(u8 taskId)
{
if (!gPaletteFade.active)
{
diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c
index af48fb414..9f72c6383 100644
--- a/src/fldeff_teleport.c
+++ b/src/fldeff_teleport.c
@@ -1,29 +1,33 @@
#include "global.h"
-#include "fldeff_teleport.h"
#include "field_effect.h"
#include "field_player_avatar.h"
#include "pokemon_menu.h"
#include "overworld.h"
#include "rom6.h"
#include "task.h"
+#include "constants/field_effects.h"
extern void (*gFieldCallback)(void);
extern u8 gLastFieldPokeMenuOpened;
-extern void (*gUnknown_03005CE4)(void);
+extern void (*gPostMenuFieldCallback)(void);
+
+static void FieldCallback_Teleport(void);
+static void StartTeleportFieldEffect(void);
+
bool8 SetUpFieldMove_Teleport(void)
{
if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = hm_teleport_run_dp02scr;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = FieldCallback_Teleport;
return TRUE;
}
return FALSE;
}
-void hm_teleport_run_dp02scr(void)
+static void FieldCallback_Teleport(void)
{
Overworld_ResetStateAfterTeleport();
FieldEffectStart(FLDEFF_USE_TELEPORT);
@@ -33,14 +37,14 @@ void hm_teleport_run_dp02scr(void)
bool8 FldEff_UseTeleport(void)
{
u8 taskId = oei_task_add();
- gTasks[taskId].data[8] = (u32)sub_814A404 >> 16;
- gTasks[taskId].data[9] = (u32)sub_814A404;
- SetPlayerAvatarTransitionFlags(1);
+ gTasks[taskId].data[8] = (u32)StartTeleportFieldEffect >> 16;
+ gTasks[taskId].data[9] = (u32)StartTeleportFieldEffect;
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
return 0;
}
-void sub_814A404(void)
+static void StartTeleportFieldEffect(void)
{
FieldEffectActiveListRemove(FLDEFF_USE_TELEPORT);
- sub_8087BA8();
+ CreateTeleportFieldEffectTask();
}
diff --git a/src/pokemon_menu.c b/src/pokemon_menu.c
index 60757b7d4..46909435a 100644
--- a/src/pokemon_menu.c
+++ b/src/pokemon_menu.c
@@ -6,13 +6,11 @@
#include "palette.h"
#include "menu.h"
#include "mail_data.h"
-#include "constants/songs.h"
#include "sound.h"
#include "main.h"
#include "overworld.h"
#include "menu_helpers.h"
#include "pokemon_summary_screen.h"
-#include "constants/moves.h"
#include "data2.h"
#include "strings.h"
#include "item_use.h"
@@ -32,6 +30,9 @@
#include "player_pc.h"
#include "ewram.h"
#include "script.h"
+#include "constants/field_effects.h"
+#include "constants/moves.h"
+#include "constants/songs.h"
/*
Pokemon menu:
@@ -84,7 +85,7 @@ static void sub_808A848(u8 taskID);
static void sub_808AAF0(u8 taskID);
static void sub_808ABF4(u8 taskID);
static void sub_808AB34(u8 taskID);
-static void sub_808ABA8(u8 taskID);
+static void FieldCallback_AfterFadeInFromMenu(u8 taskID);
static void sub_808B224(u8 taskID);
static void sub_808B2EC(u8 taskID);
static void sub_808B2B4(u8 taskID);
@@ -118,7 +119,7 @@ EWRAM_DATA static u8 sPokeMenuOptionsOrder[8] = {0}; // 4 possible field moves a
// iwram common
u8 gLastFieldPokeMenuOpened;
-void (*gUnknown_03005CE4)(void);
+void (*gPostMenuFieldCallback)(void);
// const data
@@ -780,18 +781,18 @@ static void sub_808AB34(u8 taskID)
#undef tFieldMoveId
-void FieldCallback_Teleport(void)
+void FieldCallback_PrepareFadeInFromMenu(void)
{
pal_fill_black();
- CreateTask(sub_808ABA8, 8);
+ CreateTask(FieldCallback_AfterFadeInFromMenu, 8);
}
-static void sub_808ABA8(u8 taskID)
+static void FieldCallback_AfterFadeInFromMenu(u8 taskID)
{
if (IsWeatherNotFadingIn() == TRUE)
{
gFieldEffectArguments[0] = GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_SPECIES);
- gUnknown_03005CE4();
+ gPostMenuFieldCallback();
DestroyTask(taskID);
}
}
@@ -815,8 +816,8 @@ static bool8 SetUpFieldMove_Surf(void)
{
if (PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_808AC2C;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_808AC2C;
return TRUE;
}
else
@@ -833,14 +834,14 @@ static bool8 SetUpFieldMove_Fly(void)
{
if (ShouldDoBrailleFlyEffect())
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = DoBrailleFlyEffect;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = DoBrailleFlyEffect;
return TRUE;
}
if (Overworld_MapTypeAllowsTeleportAndFly(gMapHeader.mapType) == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_808AC8C;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_808AC8C;
return TRUE;
}
return FALSE;
@@ -885,8 +886,8 @@ static bool8 SetUpFieldMove_Dive(void)
gFieldEffectArguments[1] = sub_8068F18();
if (gFieldEffectArguments[1])
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_808ADAC;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_808ADAC;
return TRUE;
}
else
@@ -907,8 +908,8 @@ static bool8 SetUpFieldMove_Waterfall(void)
if (MetatileBehavior_IsWaterfall(MapGridGetMetatileBehaviorAt(x, y)) == TRUE
&& IsPlayerSurfingNorth() == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_808AE08;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_808AE08;
return TRUE;
}
else
diff --git a/src/rom6.c b/src/rom6.c
index ffd01fdb9..24c2de6d2 100644
--- a/src/rom6.c
+++ b/src/rom6.c
@@ -13,14 +13,15 @@
#include "sound.h"
#include "sprite.h"
#include "task.h"
+#include "constants/field_effects.h"
extern u16 gSpecialVar_LastTalked;
extern void (*gFieldCallback)(void);
extern u8 gLastFieldPokeMenuOpened;
-extern void (*gUnknown_03005CE4)(void);
+extern void (*gPostMenuFieldCallback)(void);
extern u8 S_UseRockSmash[];
-EWRAM_DATA struct MapPosition gUnknown_0203923C = {0};
+EWRAM_DATA struct MapPosition gPlayerFacingPosition = {0};
static void task08_080C9820(u8);
static void sub_810B3DC(u8);
@@ -31,14 +32,14 @@ static void sub_810B58C(void);
static void sub_810B5D8(void);
static void sub_810B634(void);
-bool8 npc_before_player_of_type(u8 a)
+bool8 SetLastTalkedObjectInFrontOfPlayer(u8 graphicsId)
{
u8 mapObjId;
- GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203923C.x, &gUnknown_0203923C.y);
- gUnknown_0203923C.height = PlayerGetZCoord();
- mapObjId = GetFieldObjectIdByXYZ(gUnknown_0203923C.x, gUnknown_0203923C.y, gUnknown_0203923C.height);
- if (gMapObjects[mapObjId].graphicsId != a)
+ GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
+ gPlayerFacingPosition.height = PlayerGetZCoord();
+ mapObjId = GetFieldObjectIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height);
+ if (gMapObjects[mapObjId].graphicsId != graphicsId)
{
return FALSE;
}
@@ -51,7 +52,7 @@ bool8 npc_before_player_of_type(u8 a)
u8 oei_task_add(void)
{
- GetXYCoordsOneStepInFrontOfPlayer(&gUnknown_0203923C.x, &gUnknown_0203923C.y);
+ GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
return CreateTask(task08_080C9820, 8);
}
@@ -120,7 +121,7 @@ static void sub_810B4CC(u8 taskId)
#if DEBUG
void debug_sub_8120968(void)
{
- if (npc_before_player_of_type(MAP_OBJ_GFX_BREAKABLE_ROCK) == TRUE)
+ if (SetLastTalkedObjectInFrontOfPlayer(MAP_OBJ_GFX_BREAKABLE_ROCK) == TRUE)
{
gLastFieldPokeMenuOpened = 0;
sub_810B53C();
@@ -134,10 +135,10 @@ void debug_sub_8120968(void)
bool8 SetUpFieldMove_RockSmash(void)
{
- if (npc_before_player_of_type(0x56) == TRUE)
+ if (SetLastTalkedObjectInFrontOfPlayer(MAP_OBJ_GFX_BREAKABLE_ROCK) == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_810B53C;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_810B53C;
return TRUE;
}
else
@@ -173,8 +174,8 @@ int SetUpFieldMove_Dig(void)
{
if (CanUseEscapeRopeOnCurrMap() == TRUE)
{
- gFieldCallback = FieldCallback_Teleport;
- gUnknown_03005CE4 = sub_810B5D8;
+ gFieldCallback = FieldCallback_PrepareFadeInFromMenu;
+ gPostMenuFieldCallback = sub_810B5D8;
return TRUE;
}
else
@@ -197,7 +198,7 @@ int FldEff_UseDig(void)
gTasks[taskId].data[8] = (u32)sub_810B634 >> 16;
gTasks[taskId].data[9] = (u32)sub_810B634;
if (!ShouldDoBrailleDigEffect())
- SetPlayerAvatarTransitionFlags(1);
+ SetPlayerAvatarTransitionFlags(PLAYER_AVATAR_FLAG_ON_FOOT);
return 0;
}
diff --git a/src/secret_base.c b/src/secret_base.c
index 3c4028dca..cf66db03b 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -52,7 +52,7 @@ static void Task_SecretBasePC_Registry(u8 taskId);
extern u8 gUnknown_0815F399[];
extern u8 gUnknown_0815F49A[];
-EWRAM_DATA u8 gUnknown_020387DC = 0;
+EWRAM_DATA u8 gCurrentSecretBaseId = 0;
const struct
{
@@ -172,17 +172,17 @@ void ResetSecretBases(void)
void sub_80BB5D0(void)
{
- gUnknown_020387DC = gSpecialVar_0x8004;
+ gCurrentSecretBaseId = gSpecialVar_0x8004;
}
-void sub_80BB5E4(void)
+void SetCurrentSecretBaseVar(void)
{
u16 i;
gSpecialVar_Result = 0;
for (i = 0; i < MAX_SECRET_BASES; i++)
{
- if (gUnknown_020387DC == gSaveBlock1.secretBases[i].secretBaseId)
+ if (gCurrentSecretBaseId == gSaveBlock1.secretBases[i].secretBaseId)
{
gSpecialVar_Result = 1;
VarSet(VAR_CURRENT_SECRET_BASE, i);
@@ -191,7 +191,7 @@ void sub_80BB5E4(void)
}
}
-void sub_80BB63C(void)
+void CheckPlayerHasSecretBase(void)
{
if (gSaveBlock1.secretBases[0].secretBaseId)
gSpecialVar_Result = 1;
@@ -255,7 +255,7 @@ void sub_80BB764(s16 *arg1, s16 *arg2, u16 arg3)
}
}
-void sub_80BB800(void)
+void SetOpenedSecretBaseMetatile(void)
{
s16 x, y;
s16 tile_id;
@@ -300,7 +300,7 @@ void sub_80BB8CC(void)
u8 nameLength;
u16 idx;
- gSaveBlock1.secretBases[0].secretBaseId = gUnknown_020387DC;
+ gSaveBlock1.secretBases[0].secretBaseId = gCurrentSecretBaseId;
for (idx=0; idx<4; idx++)
gSaveBlock1.secretBases[0].trainerId[idx] = gSaveBlock2.playerTrainerId[idx];
VarSet(VAR_CURRENT_SECRET_BASE, 0);
@@ -342,7 +342,7 @@ void sub_80BB970(struct MapEvents *events)
void sub_80BBA14(void)
{
- s8 idx = 4 * (gUnknown_020387DC / 10);
+ s8 idx = 4 * (gCurrentSecretBaseId / 10);
warp1_set_2(MAP_GROUP(SECRET_BASE_RED_CAVE1), gUnknown_083D1374[idx], gUnknown_083D1374[idx + 1]);
}
@@ -414,7 +414,7 @@ void sub_80BBBEC(u8 taskid)
if (!gPaletteFade.active)
{
- idx = 4 * (gUnknown_020387DC / 10);
+ idx = 4 * (gCurrentSecretBaseId / 10);
Overworld_SetWarpDestination(gSaveBlock1.location.mapGroup, gSaveBlock1.location.mapNum, -1, gUnknown_083D1374[idx + 2], gUnknown_083D1374[idx + 3]);
warp_in();
gFieldCallback = sub_80BBB90;
@@ -533,16 +533,16 @@ void sub_80BBFA4(void)
VarSet(VAR_OBJ_GFX_ID_F, gUnknown_083D13EC[sub_80BCCA4(curBase)]);
}
-void sub_80BBFD8(struct MapPosition *position, struct MapEvents *events)
+void SetCurrentSecretBaseFromPosition(struct MapPosition *position, struct MapEvents *events)
{
- s16 bgevtidx;
+ s16 i;
- for (bgevtidx = 0; bgevtidx < events->bgEventCount; bgevtidx++)
+ for (i = 0; i < events->bgEventCount; i++)
{
- if (events->bgEvents[bgevtidx].kind == 8 && position->x == events->bgEvents[bgevtidx].x + 7
- && position->y == events->bgEvents[bgevtidx].y + 7)
+ if (events->bgEvents[i].kind == 8 && position->x == events->bgEvents[i].x + 7
+ && position->y == events->bgEvents[i].y + 7)
{
- gUnknown_020387DC = events->bgEvents[bgevtidx].bgUnion.secretBaseId;
+ gCurrentSecretBaseId = events->bgEvents[i].bgUnion.secretBaseId;
break;
}
}
@@ -550,15 +550,15 @@ void sub_80BBFD8(struct MapPosition *position, struct MapEvents *events)
void sub_80BC038(struct MapPosition *position, struct MapEvents *events)
{
- sub_80BBFD8(position, events);
- sub_80BB5E4();
+ SetCurrentSecretBaseFromPosition(position, events);
+ SetCurrentSecretBaseVar();
ScriptContext1_SetupScript(gUnknown_081A2E14);
}
bool8 sub_80BC050(void)
{
sub_80BB5D0();
- sub_80BB5E4();
+ SetCurrentSecretBaseVar();
if (gSpecialVar_Result == 1)
return FALSE;
return TRUE;
@@ -595,7 +595,7 @@ void sub_80BC0F8(void)
void sub_80BC114(void)
{
- if (gSaveBlock1.secretBases[0].secretBaseId != gUnknown_020387DC)
+ if (gSaveBlock1.secretBases[0].secretBaseId != gCurrentSecretBaseId)
gSpecialVar_Result = 1;
else
gSpecialVar_Result = 0;
@@ -632,7 +632,7 @@ u8 *sub_80BC190(u8 *dest, u8 arg1)
u8 *GetSecretBaseMapName(u8 *dest)
{
- gUnknown_020387DC = gSaveBlock1.secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].secretBaseId;
+ gCurrentSecretBaseId = gSaveBlock1.secretBases[VarGet(VAR_CURRENT_SECRET_BASE)].secretBaseId;
return sub_80BC190(dest, VarGet(VAR_CURRENT_SECRET_BASE));
}
@@ -922,7 +922,7 @@ u8 sub_80BC538(void)
void sub_80BC56C(void)
{
- if (sub_80BC268(sub_80BC14C(gUnknown_020387DC)) == TRUE)
+ if (sub_80BC268(sub_80BC14C(gCurrentSecretBaseId)) == TRUE)
gSpecialVar_Result = 1;
else if (sub_80BC538() > 9)
gSpecialVar_Result = 2;
@@ -932,7 +932,7 @@ void sub_80BC56C(void)
void sub_80BC5BC(void)
{
- gSaveBlock1.secretBases[sub_80BC14C(gUnknown_020387DC)].sbr_field_1_6 ^= 1;
+ gSaveBlock1.secretBases[sub_80BC14C(gCurrentSecretBaseId)].sbr_field_1_6 ^= 1;
FlagSet(FLAG_DECORATION_16);
}
diff --git a/src/trainer_see.c b/src/trainer_see.c
index 2913a0a5a..f79d6b9e4 100644
--- a/src/trainer_see.c
+++ b/src/trainer_see.c
@@ -8,6 +8,7 @@
#include "sprite.h"
#include "task.h"
#include "util.h"
+#include "constants/field_effects.h"
static bool8 CheckTrainer(u8);
static void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3);