summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/field_effect.s186
-rw-r--r--include/field_screen_effect.h1
-rw-r--r--include/overworld.h1
-rw-r--r--src/field_effect.c84
-rw-r--r--src/party_menu.c11
5 files changed, 87 insertions, 196 deletions
diff --git a/asm/field_effect.s b/asm/field_effect.s
index ab3c8063d..10b068904 100644
--- a/asm/field_effect.s
+++ b/asm/field_effect.s
@@ -5,192 +5,6 @@
.text
- thumb_func_start ReturnToFieldFromFlyMapSelect
-ReturnToFieldFromFlyMapSelect: @ 80842C8
- push {lr}
- ldr r0, _080842DC @ =CB2_ReturnToField
- bl SetMainCallback2
- ldr r1, _080842E0 @ =gFieldCallback
- ldr r0, _080842E4 @ =FieldCallback_Fly
- str r0, [r1]
- pop {r0}
- bx r0
- .align 2, 0
-_080842DC: .4byte CB2_ReturnToField
-_080842E0: .4byte gFieldCallback
-_080842E4: .4byte FieldCallback_Fly
- thumb_func_end ReturnToFieldFromFlyMapSelect
-
- thumb_func_start FieldCallback_Fly
-FieldCallback_Fly: @ 80842E8
- push {lr}
- bl FadeInFromBlack
- ldr r0, _08084308 @ =Task_FlyOut
- movs r1, 0
- bl CreateTask
- bl ScriptContext2_Enable
- bl FreezeObjectEvents
- ldr r1, _0808430C @ =gFieldCallback
- movs r0, 0
- str r0, [r1]
- pop {r0}
- bx r0
- .align 2, 0
-_08084308: .4byte Task_FlyOut
-_0808430C: .4byte gFieldCallback
- thumb_func_end FieldCallback_Fly
-
- thumb_func_start Task_FlyOut
-Task_FlyOut: @ 8084310
- push {r4-r6,lr}
- lsls r0, 24
- lsrs r5, r0, 24
- lsls r0, r5, 2
- adds r0, r5
- lsls r0, 3
- ldr r1, _0808437C @ =gTasks
- adds r4, r0, r1
- movs r0, 0x8
- ldrsh r6, [r4, r0]
- cmp r6, 0
- bne _08084350
- bl IsWeatherNotFadingIn
- lsls r0, 24
- cmp r0, 0
- beq _08084376
- bl GetCursorSelectionMonId
- ldr r1, _08084380 @ =gFieldEffectArguments
- lsls r0, 24
- lsrs r0, 24
- str r0, [r1]
- cmp r0, 0x5
- ble _08084344
- str r6, [r1]
-_08084344:
- movs r0, 0x1F
- bl FieldEffectStart
- ldrh r0, [r4, 0x8]
- adds r0, 0x1
- strh r0, [r4, 0x8]
-_08084350:
- movs r0, 0x1F
- bl FieldEffectActiveListContains
- lsls r0, 24
- cmp r0, 0
- bne _08084376
- bl Overworld_ResetStateAfterFly
- bl WarpIntoMap
- ldr r0, _08084384 @ =CB2_LoadMap
- bl SetMainCallback2
- ldr r1, _08084388 @ =gFieldCallback
- ldr r0, _0808438C @ =FieldCallback_FlyArrive
- str r0, [r1]
- adds r0, r5, 0
- bl DestroyTask
-_08084376:
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2, 0
-_0808437C: .4byte gTasks
-_08084380: .4byte gFieldEffectArguments
-_08084384: .4byte CB2_LoadMap
-_08084388: .4byte gFieldCallback
-_0808438C: .4byte FieldCallback_FlyArrive
- thumb_func_end Task_FlyOut
-
- thumb_func_start FieldCallback_FlyArrive
-FieldCallback_FlyArrive: @ 8084390
- push {r4,lr}
- bl Overworld_PlaySpecialMapMusic
- bl FadeInFromBlack
- ldr r0, _080843E8 @ =Task_FlyIn
- movs r1, 0
- bl CreateTask
- ldr r4, _080843EC @ =gObjectEvents
- ldr r3, _080843F0 @ =gPlayerAvatar
- ldrb r1, [r3, 0x5]
- lsls r0, r1, 3
- adds r0, r1
- lsls r0, 2
- adds r0, r4
- ldrb r1, [r0, 0x1]
- movs r2, 0x20
- orrs r1, r2
- strb r1, [r0, 0x1]
- ldrb r1, [r3]
- movs r0, 0x8
- ands r0, r1
- cmp r0, 0
- beq _080843D2
- ldrb r1, [r3, 0x5]
- lsls r0, r1, 3
- adds r0, r1
- lsls r0, 2
- adds r0, r4
- movs r1, 0x3
- bl ObjectEventTurn
-_080843D2:
- bl ScriptContext2_Enable
- bl FreezeObjectEvents
- ldr r1, _080843F4 @ =gFieldCallback
- movs r0, 0
- str r0, [r1]
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_080843E8: .4byte Task_FlyIn
-_080843EC: .4byte gObjectEvents
-_080843F0: .4byte gPlayerAvatar
-_080843F4: .4byte gFieldCallback
- thumb_func_end FieldCallback_FlyArrive
-
- thumb_func_start Task_FlyIn
-Task_FlyIn: @ 80843F8
- push {r4,r5,lr}
- lsls r0, 24
- lsrs r0, 24
- adds r5, r0, 0
- lsls r0, r5, 2
- adds r0, r5
- lsls r0, 3
- ldr r1, _0808444C @ =gTasks
- adds r4, r0, r1
- movs r1, 0x8
- ldrsh r0, [r4, r1]
- cmp r0, 0
- bne _0808442A
- ldr r0, _08084450 @ =gPaletteFade
- ldrb r1, [r0, 0x7]
- movs r0, 0x80
- ands r0, r1
- cmp r0, 0
- bne _08084444
- movs r0, 0x20
- bl FieldEffectStart
- ldrh r0, [r4, 0x8]
- adds r0, 0x1
- strh r0, [r4, 0x8]
-_0808442A:
- movs r0, 0x20
- bl FieldEffectActiveListContains
- lsls r0, 24
- cmp r0, 0
- bne _08084444
- bl ScriptContext2_Disable
- bl UnfreezeObjectEvents
- adds r0, r5, 0
- bl DestroyTask
-_08084444:
- pop {r4,r5}
- pop {r0}
- bx r0
- .align 2, 0
-_0808444C: .4byte gTasks
-_08084450: .4byte gPaletteFade
- thumb_func_end Task_FlyIn
-
thumb_func_start FieldCB_FallWarpExit
FieldCB_FallWarpExit: @ 8084454
push {lr}
diff --git a/include/field_screen_effect.h b/include/field_screen_effect.h
index 2537ca94d..aee7dc5a7 100644
--- a/include/field_screen_effect.h
+++ b/include/field_screen_effect.h
@@ -9,7 +9,6 @@ void sub_80B0244(void);
void sub_807E3EC(void);
void DoOutwardBarnDoorWipe(void);
void Task_BarnDoorWipe(u8 taskId);
-void FadeInFromBlack(void);
void sub_807F5F0(void);
#endif // GUARD_FIELD_SCREEN_EFFECT_H
diff --git a/include/overworld.h b/include/overworld.h
index a1cd888a9..ac50f9c80 100644
--- a/include/overworld.h
+++ b/include/overworld.h
@@ -177,6 +177,7 @@ void sub_805546C(u8 a0);
bool32 sub_80582E0(void);
bool32 sub_8058274(void);
u8 GetCurrentMapBattleScene(void);
+void Overworld_ResetStateAfterFly(void);
extern u16 gHeldKeyCodeToSend;
diff --git a/src/field_effect.c b/src/field_effect.c
index b7498d316..9a30088c1 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -2,11 +2,15 @@
#include "gflib.h"
#include "data.h"
#include "decompress.h"
+#include "event_object_movement.h"
#include "field_effect.h"
#include "field_effect_scripts.h"
+#include "field_fadetransition.h"
#include "field_weather.h"
#include "overworld.h"
+#include "party_menu.h"
#include "quest_log.h"
+#include "script.h"
#include "task.h"
#include "trainer_pokemon_sprites.h"
#include "constants/songs.h"
@@ -982,3 +986,83 @@ void SpriteCB_HallOfFameMonitor(struct Sprite * sprite)
if (sprite->animEnded)
FieldEffectFreeGraphicsResources(sprite);
}
+
+void FieldCallback_Fly(void);
+void Task_FlyOut(u8 taskId);
+void FieldCallback_FlyArrive(void);
+void Task_FlyIn(u8 taskId);
+
+void ReturnToFieldFromFlyMapSelect(void)
+{
+ SetMainCallback2(CB2_ReturnToField);
+ gFieldCallback = FieldCallback_Fly;
+}
+
+void FieldCallback_Fly(void)
+{
+ FadeInFromBlack();
+ CreateTask(Task_FlyOut, 0);
+ ScriptContext2_Enable();
+ FreezeObjectEvents();
+ gFieldCallback = NULL;
+}
+
+void Task_FlyOut(u8 taskId)
+{
+ struct Task * task;
+ task = &gTasks[taskId];
+ if (task->data[0] == 0)
+ {
+ if (!IsWeatherNotFadingIn())
+ return;
+ gFieldEffectArguments[0] = GetCursorSelectionMonId();
+ if ((int)gFieldEffectArguments[0] >= PARTY_SIZE)
+ gFieldEffectArguments[0] = 0;
+ FieldEffectStart(FLDEFF_USE_FLY);
+ task->data[0]++;
+ }
+ if (!FieldEffectActiveListContains(FLDEFF_USE_FLY))
+ {
+ Overworld_ResetStateAfterFly();
+ WarpIntoMap();
+ SetMainCallback2(CB2_LoadMap);
+ gFieldCallback = FieldCallback_FlyArrive;
+ DestroyTask(taskId);
+ }
+}
+
+void FieldCallback_FlyArrive(void)
+{
+ Overworld_PlaySpecialMapMusic();
+ FadeInFromBlack();
+ CreateTask(Task_FlyIn, 0);
+ gObjectEvents[gPlayerAvatar.objectEventId].invisible = TRUE;
+ if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
+ {
+ ObjectEventTurn(&gObjectEvents[gPlayerAvatar.objectEventId], DIR_WEST);
+ }
+ ScriptContext2_Enable();
+ FreezeObjectEvents();
+ gFieldCallback = NULL;
+}
+
+void Task_FlyIn(u8 taskId)
+{
+ struct Task *task;
+ task = &gTasks[taskId];
+ if (task->data[0] == 0)
+ {
+ if (gPaletteFade.active)
+ {
+ return;
+ }
+ FieldEffectStart(FLDEFF_FLY_IN);
+ task->data[0]++;
+ }
+ if (!FieldEffectActiveListContains(FLDEFF_FLY_IN))
+ {
+ ScriptContext2_Disable();
+ UnfreezeObjectEvents();
+ DestroyTask(taskId);
+ }
+}
diff --git a/src/party_menu.c b/src/party_menu.c
index d28abea8c..626ce70f8 100644
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "gflib.h"
#include "battle.h"
#include "battle_anim.h"
#include "battle_controllers.h"
@@ -7,7 +7,6 @@
#include "battle_interface.h"
#include "battle_tower.h"
#include "berry_pouch.h"
-#include "bg.h"
#include "data.h"
#include "decompress.h"
#include "easy_chat.h"
@@ -15,11 +14,10 @@
#include "evolution_scene.h"
#include "field_effect.h"
#include "field_player_avatar.h"
-#include "field_screen_effect.h"
+#include "field_fadetransition.h"
#include "field_weather.h"
#include "fieldmap.h"
#include "fldeff.h"
-#include "gpu_regs.h"
#include "graphics.h"
#include "help_system.h"
#include "item.h"
@@ -36,7 +34,6 @@
#include "new_menu_helpers.h"
#include "metatile_behavior.h"
#include "overworld.h"
-#include "palette.h"
#include "party_menu.h"
#include "player_pc.h"
#include "pokedex.h"
@@ -50,19 +47,15 @@
#include "reshow_battle_screen.h"
#include "scanline_effect.h"
#include "script.h"
-#include "sound.h"
-#include "sprite.h"
#include "start_menu.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "teachy_tv.h"
-#include "text.h"
#include "text_window.h"
#include "tm_case.h"
#include "trade.h"
#include "union_room.h"
-#include "window.h"
#include "constants/battle.h"
#include "constants/easy_chat.h"
#include "constants/field_effects.h"