2018-12-08 21:42:36 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "cable_club.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "fieldmap.h"
|
|
|
|
#include "field_camera.h"
|
|
|
|
#include "field_door.h"
|
|
|
|
#include "field_effect.h"
|
|
|
|
#include "event_object_movement.h"
|
|
|
|
#include "field_player_avatar.h"
|
2018-12-08 22:05:11 +01:00
|
|
|
#include "field_screen_effect.h"
|
2018-12-08 21:42:36 +01:00
|
|
|
#include "field_special_scene.h"
|
|
|
|
#include "field_weather.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "link.h"
|
|
|
|
#include "link_rfu.h"
|
|
|
|
#include "load_save.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "menu.h"
|
2018-12-25 18:02:41 +01:00
|
|
|
#include "mirage_tower.h"
|
2018-12-08 21:42:36 +01:00
|
|
|
#include "event_obj_lock.h"
|
|
|
|
#include "metatile_behavior.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "overworld.h"
|
|
|
|
#include "scanline_effect.h"
|
|
|
|
#include "script.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "start_menu.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "constants/event_object_movement_constants.h"
|
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "constants/rgb.h"
|
2019-03-02 04:32:50 +01:00
|
|
|
#include "trainer_hill.h"
|
|
|
|
#include "event_obj_lock.h"
|
2019-03-02 08:44:02 +01:00
|
|
|
#include "fldeff.h"
|
2018-12-08 21:42:36 +01:00
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
extern const u16 gOrbEffectBackgroundLayerFlags[];
|
2018-12-08 21:42:36 +01:00
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
// This file's functions.
|
|
|
|
static void sub_8080B9C(u8);
|
|
|
|
static void task_map_chg_seq_0807E20C(u8);
|
|
|
|
static void task_map_chg_seq_0807E2CC(u8);
|
|
|
|
static void task0A_fade_n_map_maybe(u8);
|
|
|
|
static void sub_808115C(u8);
|
|
|
|
static void palette_bg_faded_fill_white(void);
|
|
|
|
static void sub_80AF438(u8);
|
2019-03-03 08:50:40 +01:00
|
|
|
static bool32 WaitForWeatherFadeIn(void);
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task0A_mpl_807E31C(u8 taskId);
|
|
|
|
static void sub_80AFA0C(u8 taskId);
|
|
|
|
static void sub_80AFA88(u8 taskId);
|
2019-10-07 02:04:30 +02:00
|
|
|
static void Task_EnableScriptAfterMusicFade(u8 taskId);
|
2018-12-08 22:05:11 +01:00
|
|
|
|
|
|
|
// const
|
2018-12-08 21:42:36 +01:00
|
|
|
const u16 sFlashLevelPixelRadii[] = { 200, 72, 64, 56, 48, 40, 32, 24, 0 };
|
|
|
|
const s32 gMaxFlashLevel = 8;
|
|
|
|
|
|
|
|
const struct ScanlineEffectParams sFlashEffectParams =
|
|
|
|
{
|
|
|
|
(void *)REG_ADDR_WIN0H,
|
|
|
|
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
|
|
|
|
1
|
|
|
|
};
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
// code
|
|
|
|
static void palette_bg_faded_fill_white(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
CpuFastFill16(RGB_WHITE, gPlttBufferFaded, PLTT_SIZE);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void palette_bg_faded_fill_black(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
CpuFastFill16(RGB_BLACK, gPlttBufferFaded, PLTT_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pal_fill_for_maplights(void)
|
|
|
|
{
|
|
|
|
u8 previousMapType = GetLastUsedWarpMapType();
|
2018-12-27 23:30:47 +01:00
|
|
|
switch (GetMapPairFadeFromType(previousMapType, GetCurrentMapType()))
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
palette_bg_faded_fill_black();
|
|
|
|
FadeScreen(FADE_FROM_BLACK, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
palette_bg_faded_fill_white();
|
|
|
|
FadeScreen(FADE_FROM_WHITE, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF08C(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
palette_bg_faded_fill_white();
|
|
|
|
FadeScreen(FADE_FROM_WHITE, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pal_fill_black(void)
|
|
|
|
{
|
|
|
|
palette_bg_faded_fill_black();
|
|
|
|
FadeScreen(FADE_FROM_BLACK, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WarpFadeScreen(void)
|
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
u8 currentMapType = GetCurrentMapType();
|
2018-12-08 21:42:36 +01:00
|
|
|
switch (GetMapPairFadeToType(currentMapType, GetDestinationWarpMapHeader()->mapType))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
FadeScreen(FADE_TO_WHITE, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF0F4(u8 arg)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
sub_808C0A8(!arg);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task0A_nop_for_a_while(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() == TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF128(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_black();
|
|
|
|
CreateTask(task0A_nop_for_a_while, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskID)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() == TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
DestroyTask(taskID);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-03 08:50:40 +01:00
|
|
|
void FieldCallback_ReturnToEventScript2(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_black();
|
|
|
|
CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF188(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
pal_fill_black();
|
|
|
|
CreateTask(task0A_asap_script_env_2_enable_and_set_ctx_running, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task_mpl_807DD60(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
task->data[1] = sub_80B3050();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (gTasks[task->data[1]].isActive != TRUE)
|
|
|
|
{
|
|
|
|
pal_fill_for_maplights();
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() == TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF214(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
palette_bg_faded_fill_black();
|
|
|
|
CreateTask(task_mpl_807DD60, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF234(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_800ADF8();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-31 09:22:21 +01:00
|
|
|
if (!IsLinkTaskFinished())
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (++task->data[1] > 1800)
|
|
|
|
sub_8011170(0x6000);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pal_fill_for_maplights();
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() == TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
sub_8009F18();
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF2B4(u8 taskId)
|
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_800ADF8();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-31 09:22:21 +01:00
|
|
|
if (IsLinkTaskFinished())
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
sub_8009F18();
|
2019-02-10 09:54:50 +01:00
|
|
|
ResetAllMultiplayerState();
|
2018-12-08 21:42:36 +01:00
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF314(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
palette_bg_faded_fill_black();
|
|
|
|
CreateTask(sub_80AF234, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF334(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s16 x, y;
|
|
|
|
u8 behavior;
|
|
|
|
TaskFunc func;
|
|
|
|
|
|
|
|
PlayerGetDestCoords(&x, &y);
|
|
|
|
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
|
|
|
if (MetatileBehavior_IsDoor(behavior) == TRUE)
|
|
|
|
func = sub_80AF438;
|
|
|
|
else if (MetatileBehavior_IsNonAnimDoor(behavior) == TRUE)
|
|
|
|
func = task_map_chg_seq_0807E20C;
|
|
|
|
else
|
|
|
|
func = task_map_chg_seq_0807E2CC;
|
|
|
|
CreateTask(func, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mapldr_default(void)
|
|
|
|
{
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_for_maplights();
|
|
|
|
sub_80AF334();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF3B0(void)
|
|
|
|
{
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
sub_80AF08C();
|
|
|
|
sub_80AF334();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF3C8(void)
|
|
|
|
{
|
|
|
|
if (!sub_81D6534())
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_black();
|
|
|
|
sub_80AF334();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF3E8(void)
|
|
|
|
{
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_for_maplights();
|
|
|
|
PlaySE(SE_TK_WARPOUT);
|
|
|
|
CreateTask(task0A_mpl_807E31C, 10);
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF40C(void)
|
|
|
|
{
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_for_maplights();
|
|
|
|
PlaySE(SE_TK_WARPOUT);
|
|
|
|
CreateTask(task_map_chg_seq_0807E2CC, 10);
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
sub_8085540(0xE);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF438(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
s16 *x = &task->data[2];
|
|
|
|
s16 *y = &task->data[3];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_80AF0F4(0);
|
|
|
|
FreezeEventObjects();
|
|
|
|
PlayerGetDestCoords(x, y);
|
|
|
|
FieldSetDoorOpened(*x, *y);
|
|
|
|
task->data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn())
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
u8 eventObjId;
|
|
|
|
sub_80AF0F4(1);
|
|
|
|
eventObjId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0);
|
|
|
|
EventObjectSetHeldMovement(&gEventObjects[eventObjId], MOVEMENT_ACTION_WALK_NORMAL_DOWN);
|
|
|
|
task->data[0] = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (walkrun_is_standing_still())
|
|
|
|
{
|
|
|
|
u8 eventObjId;
|
|
|
|
task->data[1] = FieldAnimateDoorClose(*x, *y);
|
|
|
|
eventObjId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0);
|
|
|
|
EventObjectClearHeldMovementIfFinished(&gEventObjects[eventObjId]);
|
|
|
|
task->data[0] = 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
|
|
|
|
{
|
|
|
|
UnfreezeEventObjects();
|
|
|
|
task->data[0] = 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task_map_chg_seq_0807E20C(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
s16 *x = &task->data[2];
|
|
|
|
s16 *y = &task->data[3];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_80AF0F4(0);
|
|
|
|
FreezeEventObjects();
|
|
|
|
PlayerGetDestCoords(x, y);
|
|
|
|
task->data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn())
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
u8 eventObjId;
|
|
|
|
sub_80AF0F4(1);
|
|
|
|
eventObjId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0);
|
|
|
|
EventObjectSetHeldMovement(&gEventObjects[eventObjId], GetWalkNormalMovementAction(GetPlayerFacingDirection()));
|
|
|
|
task->data[0] = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (walkrun_is_standing_still())
|
|
|
|
{
|
|
|
|
UnfreezeEventObjects();
|
|
|
|
task->data[0] = 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task_map_chg_seq_0807E2CC(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FreezeEventObjects();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn())
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
UnfreezeEventObjects();
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF660(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() == TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
CreateTask(sub_809FA34, 80);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF688(void)
|
|
|
|
{
|
|
|
|
pal_fill_black();
|
|
|
|
CreateTask(sub_80AF660, 0x50);
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
bool8 sub_80AF6A4(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
sub_809FA18();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task_mpl_807E3C8(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() == 1)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
ScriptUnfreezeEventObjects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF6D4(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
pal_fill_black();
|
|
|
|
CreateTask(task_mpl_807E3C8, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF6F0(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
Overworld_PlaySpecialMapMusic();
|
|
|
|
pal_fill_black();
|
|
|
|
CreateTask(task_mpl_807E3C8, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static bool32 PaletteFadeActive(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
return gPaletteFade.active;
|
|
|
|
}
|
|
|
|
|
2019-03-03 08:50:40 +01:00
|
|
|
static bool32 WaitForWeatherFadeIn(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (IsWeatherNotFadingIn() == TRUE)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-28 22:11:15 +01:00
|
|
|
void DoWarp(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-12-08 21:42:36 +01:00
|
|
|
PlaySE(SE_KAIDAN);
|
|
|
|
gFieldCallback = mapldr_default;
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-28 22:11:15 +01:00
|
|
|
void DoDiveWarp(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-12-08 21:42:36 +01:00
|
|
|
gFieldCallback = mapldr_default;
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF79C(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
FadeScreen(FADE_TO_WHITE, 8);
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-12-08 21:42:36 +01:00
|
|
|
gFieldCallback = sub_80AF3B0;
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-28 22:11:15 +01:00
|
|
|
void DoDoorWarp(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
gFieldCallback = mapldr_default;
|
|
|
|
CreateTask(sub_80AFA88, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-28 22:11:15 +01:00
|
|
|
void DoFallWarp(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2018-12-28 22:11:15 +01:00
|
|
|
DoDiveWarp();
|
2018-12-08 21:42:36 +01:00
|
|
|
gFieldCallback = sub_80B6B68;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF80C(u8 metatileBehavior)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
sub_80B6E4C(metatileBehavior, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF828(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
sub_80B75D8(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF838(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
sub_80B7A74(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF848(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
|
|
|
PlaySE(SE_TK_WARPIN);
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
gFieldCallback = sub_80AF3E8;
|
|
|
|
}
|
|
|
|
|
2019-10-15 11:00:08 +02:00
|
|
|
void DoMossdeepGymWarp(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
sub_8085540(1);
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
SaveEventObjects();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
|
|
|
PlaySE(SE_TK_WARPIN);
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
gFieldCallback = sub_80AF40C;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF8B8(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
WarpFadeScreen();
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
gFieldCallback = sub_80FB768;
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AF8E0(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!PaletteFadeActive() && BGMusicStopped())
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
WarpIntoMap();
|
|
|
|
SetMainCallback2(sub_8086074);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80AF948(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
|
|
|
PlaySE(SE_KAIDAN);
|
|
|
|
CreateTask(sub_80AF8E0, 10);
|
|
|
|
}
|
|
|
|
|
2019-02-11 02:42:50 +01:00
|
|
|
static void Task_ReturnToWorldFromLinkRoom(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
switch (data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearLinkCallback_2();
|
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
PlaySE(SE_KAIDAN);
|
|
|
|
data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!PaletteFadeActive() && BGMusicStopped())
|
|
|
|
{
|
|
|
|
sub_800AC34();
|
|
|
|
data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!gReceivedRemoteLinkPlayers)
|
|
|
|
{
|
|
|
|
WarpIntoMap();
|
|
|
|
SetMainCallback2(CB2_LoadMap);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 10:14:09 +02:00
|
|
|
void ReturnFromLinkRoom(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-02-11 02:42:50 +01:00
|
|
|
CreateTask(Task_ReturnToWorldFromLinkRoom, 10);
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AFA0C(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FreezeEventObjects();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!PaletteFadeActive())
|
|
|
|
{
|
|
|
|
if (task->data[1] == 0)
|
|
|
|
{
|
2018-12-25 18:02:41 +01:00
|
|
|
ClearMirageTowerPulseBlendEffect();
|
2018-12-08 21:42:36 +01:00
|
|
|
task->data[1] = 1;
|
|
|
|
}
|
|
|
|
if (BGMusicStopped())
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
WarpIntoMap();
|
|
|
|
SetMainCallback2(CB2_LoadMap);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AFA88(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
s16 *x = &task->data[2];
|
|
|
|
s16 *y = &task->data[3];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FreezeEventObjects();
|
|
|
|
PlayerGetDestCoords(x, y);
|
|
|
|
PlaySE(GetDoorSoundEffect(*x, *y - 1));
|
|
|
|
task->data[1] = FieldAnimateDoorOpen(*x, *y - 1);
|
|
|
|
task->data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
|
|
|
|
{
|
|
|
|
u8 eventObjId;
|
|
|
|
eventObjId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0);
|
|
|
|
EventObjectClearHeldMovementIfActive(&gEventObjects[eventObjId]);
|
|
|
|
eventObjId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0);
|
|
|
|
EventObjectSetHeldMovement(&gEventObjects[eventObjId], MOVEMENT_ACTION_WALK_NORMAL_UP);
|
|
|
|
task->data[0] = 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (walkrun_is_standing_still())
|
|
|
|
{
|
|
|
|
u8 eventObjId;
|
|
|
|
task->data[1] = FieldAnimateDoorClose(*x, *y - 1);
|
|
|
|
eventObjId = GetEventObjectIdByLocalIdAndMap(0xFF, 0, 0);
|
|
|
|
EventObjectClearHeldMovementIfFinished(&gEventObjects[eventObjId]);
|
|
|
|
sub_80AF0F4(0);
|
|
|
|
task->data[0] = 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (task->data[1] < 0 || gTasks[task->data[1]].isActive != TRUE)
|
|
|
|
{
|
|
|
|
task->data[0] = 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-12-08 21:42:36 +01:00
|
|
|
task->data[0] = 0;
|
|
|
|
task->func = sub_80AFA0C;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task0A_fade_n_map_maybe(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FreezeEventObjects();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!PaletteFadeActive() && BGMusicStopped())
|
|
|
|
{
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
WarpIntoMap();
|
|
|
|
SetMainCallback2(sub_8086024);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-11 03:54:00 +01:00
|
|
|
void DoContestHallWarp(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
TryFadeOutOldMapMusic();
|
|
|
|
WarpFadeScreen();
|
2019-02-23 04:20:42 +01:00
|
|
|
PlayRainStoppingSoundEffect();
|
2018-12-08 21:42:36 +01:00
|
|
|
PlaySE(SE_KAIDAN);
|
|
|
|
gFieldCallback = sub_80AF3C8;
|
|
|
|
CreateTask(task0A_fade_n_map_maybe, 10);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void SetFlashScanlineEffectWindowBoundary(u16 *dest, u32 y, s32 left, s32 right)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (y <= 160)
|
|
|
|
{
|
|
|
|
if (left < 0)
|
|
|
|
left = 0;
|
|
|
|
if (left > 255)
|
|
|
|
left = 255;
|
|
|
|
if (right < 0)
|
|
|
|
right = 0;
|
|
|
|
if (right > 255)
|
|
|
|
right = 255;
|
|
|
|
dest[y] = (left << 8) | right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void SetFlashScanlineEffectWindowBoundaries(u16 *dest, s32 centerX, s32 centerY, s32 radius)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s32 r = radius;
|
|
|
|
s32 v2 = radius;
|
|
|
|
s32 v3 = 0;
|
|
|
|
while (r >= v3)
|
|
|
|
{
|
|
|
|
SetFlashScanlineEffectWindowBoundary(dest, centerY - v3, centerX - r, centerX + r);
|
|
|
|
SetFlashScanlineEffectWindowBoundary(dest, centerY + v3, centerX - r, centerX + r);
|
|
|
|
SetFlashScanlineEffectWindowBoundary(dest, centerY - r, centerX - v3, centerX + v3);
|
|
|
|
SetFlashScanlineEffectWindowBoundary(dest, centerY + r, centerX - v3, centerX + v3);
|
|
|
|
v2 -= (v3 * 2) - 1;
|
|
|
|
v3++;
|
|
|
|
if (v2 < 0)
|
|
|
|
{
|
|
|
|
v2 += 2 * (r - 1);
|
|
|
|
r--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
static void SetOrbFlashScanlineEffectWindowBoundary(u16 *dest, u32 y, s32 left, s32 right)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (y <= 160)
|
|
|
|
{
|
|
|
|
if (left < 0)
|
|
|
|
left = 0;
|
|
|
|
if (left > 240)
|
|
|
|
left = 240;
|
|
|
|
if (right < 0)
|
|
|
|
right = 0;
|
|
|
|
if (right > 240)
|
|
|
|
right = 240;
|
|
|
|
dest[y] = (left << 8) | right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
static void SetOrbFlashScanlineEffectWindowBoundaries(u16 *dest, s32 centerX, s32 centerY, s32 radius)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s32 r = radius;
|
|
|
|
s32 v2 = radius;
|
|
|
|
s32 v3 = 0;
|
|
|
|
while (r >= v3)
|
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
SetOrbFlashScanlineEffectWindowBoundary(dest, centerY - v3, centerX - r, centerX + r);
|
|
|
|
SetOrbFlashScanlineEffectWindowBoundary(dest, centerY + v3, centerX - r, centerX + r);
|
|
|
|
SetOrbFlashScanlineEffectWindowBoundary(dest, centerY - r, centerX - v3, centerX + v3);
|
|
|
|
SetOrbFlashScanlineEffectWindowBoundary(dest, centerY + r, centerX - v3, centerX + v3);
|
2018-12-08 21:42:36 +01:00
|
|
|
v2 -= (v3 * 2) - 1;
|
|
|
|
v3++;
|
|
|
|
if (v2 < 0)
|
|
|
|
{
|
|
|
|
v2 += 2 * (r - 1);
|
|
|
|
r--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define tFlashCenterX data[1]
|
|
|
|
#define tFlashCenterY data[2]
|
|
|
|
#define tCurFlashRadius data[3]
|
|
|
|
#define tDestFlashRadius data[4]
|
|
|
|
#define tFlashRadiusDelta data[5]
|
|
|
|
#define tClearScanlineEffect data[6]
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void UpdateFlashLevelEffect(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
switch (data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
|
|
|
|
data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
SetFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
|
|
|
|
data[0] = 0;
|
|
|
|
tCurFlashRadius += tFlashRadiusDelta;
|
|
|
|
if (tCurFlashRadius > tDestFlashRadius)
|
|
|
|
{
|
|
|
|
if (tClearScanlineEffect == 1)
|
|
|
|
{
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
data[0] = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ScanlineEffect_Clear();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
static void UpdateOrbFlashEffect(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
switch (data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
2019-11-01 08:41:55 +01:00
|
|
|
SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
|
2018-12-08 21:42:36 +01:00
|
|
|
data[0] = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-11-01 08:41:55 +01:00
|
|
|
SetOrbFlashScanlineEffectWindowBoundaries(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], tFlashCenterX, tFlashCenterY, tCurFlashRadius);
|
2018-12-08 21:42:36 +01:00
|
|
|
data[0] = 0;
|
|
|
|
tCurFlashRadius += tFlashRadiusDelta;
|
|
|
|
if (tCurFlashRadius > tDestFlashRadius)
|
|
|
|
{
|
|
|
|
if (tClearScanlineEffect == 1)
|
|
|
|
{
|
|
|
|
ScanlineEffect_Stop();
|
|
|
|
data[0] = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ScanlineEffect_Clear();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AFF90(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (!FuncIsActiveTask(UpdateFlashLevelEffect))
|
|
|
|
{
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80AFFB8(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (!FuncIsActiveTask(sub_80AFF90))
|
|
|
|
CreateTask(sub_80AFF90, 80);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static u8 sub_80AFFDC(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
u8 taskId = CreateTask(UpdateFlashLevelEffect, 80);
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
tCurFlashRadius = initialFlashRadius;
|
|
|
|
tDestFlashRadius = destFlashRadius;
|
|
|
|
tFlashCenterX = centerX;
|
|
|
|
tFlashCenterY = centerY;
|
|
|
|
tClearScanlineEffect = clearScanlineEffect;
|
|
|
|
|
|
|
|
if (initialFlashRadius < destFlashRadius)
|
|
|
|
tFlashRadiusDelta = delta;
|
|
|
|
else
|
|
|
|
tFlashRadiusDelta = -delta;
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static u8 sub_80B003C(s32 centerX, s32 centerY, s32 initialFlashRadius, s32 destFlashRadius, s32 clearScanlineEffect, u8 delta)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
u8 taskId = CreateTask(UpdateOrbFlashEffect, 80);
|
2018-12-08 21:42:36 +01:00
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
tCurFlashRadius = initialFlashRadius;
|
|
|
|
tDestFlashRadius = destFlashRadius;
|
|
|
|
tFlashCenterX = centerX;
|
|
|
|
tFlashCenterY = centerY;
|
|
|
|
tClearScanlineEffect = clearScanlineEffect;
|
|
|
|
|
|
|
|
if (initialFlashRadius < destFlashRadius)
|
|
|
|
tFlashRadiusDelta = delta;
|
|
|
|
else
|
|
|
|
tFlashRadiusDelta = -delta;
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef tCurFlashRadius
|
|
|
|
#undef tDestFlashRadius
|
|
|
|
#undef tFlashRadiusDelta
|
|
|
|
#undef tClearScanlineEffect
|
|
|
|
|
2019-10-11 23:25:07 +02:00
|
|
|
void AnimateFlash(u8 flashLevel)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
u8 curFlashLevel = Overworld_GetFlashLevel();
|
|
|
|
u8 value = 0;
|
|
|
|
if (!flashLevel)
|
|
|
|
value = 1;
|
|
|
|
sub_80AFFDC(120, 80, sFlashLevelPixelRadii[curFlashLevel], sFlashLevelPixelRadii[flashLevel], value, 1);
|
|
|
|
sub_80AFFB8();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteFlashScanlineEffectBuffer(u8 flashLevel)
|
|
|
|
{
|
|
|
|
if (flashLevel)
|
|
|
|
{
|
|
|
|
SetFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], 120, 80, sFlashLevelPixelRadii[flashLevel]);
|
|
|
|
CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-07 03:01:29 +01:00
|
|
|
void WriteBattlePyramidViewScanlineEffectBuffer(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-02-07 03:01:29 +01:00
|
|
|
SetFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], 120, 80, gSaveBlock2Ptr->frontier.pyramidLightRadius);
|
2018-12-08 21:42:36 +01:00
|
|
|
CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480);
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void task0A_mpl_807E31C(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
switch (gTasks[taskId].data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FreezeEventObjects();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
sub_808D194();
|
|
|
|
gTasks[taskId].data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2019-03-03 08:50:40 +01:00
|
|
|
if (WaitForWeatherFadeIn() && sub_808D1B4() != TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
UnfreezeEventObjects();
|
|
|
|
ScriptContext2_Disable();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-08 22:05:11 +01:00
|
|
|
static void sub_80B01BC(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
|
|
|
switch (task->data[0])
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
FreezeEventObjects();
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
PlaySE(SE_TK_WARPIN);
|
|
|
|
sub_808D1C8();
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!sub_808D1E8())
|
|
|
|
{
|
|
|
|
WarpFadeScreen();
|
|
|
|
task->data[0]++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!PaletteFadeActive() && BGMusicStopped())
|
|
|
|
task->data[0]++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
WarpIntoMap();
|
|
|
|
SetMainCallback2(CB2_LoadMap);
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80B0244(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
CreateTask(sub_80AFA0C, 10);
|
|
|
|
gFieldCallback = sub_80AF3E8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sub_80B0268(void)
|
|
|
|
{
|
|
|
|
ScriptContext2_Enable();
|
|
|
|
gFieldCallback = mapldr_default;
|
|
|
|
CreateTask(sub_80B01BC, 10);
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
static void LoadOrbEffectPalette(bool8 blueOrb)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u16 color[1];
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
if (!blueOrb)
|
2018-12-09 12:16:01 +01:00
|
|
|
color[0] = RGB_RED;
|
2018-12-08 21:42:36 +01:00
|
|
|
else
|
2018-12-09 12:16:01 +01:00
|
|
|
color[0] = RGB_BLUE;
|
2018-12-08 21:42:36 +01:00
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
LoadPalette(color, 0xF0 + i, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
static bool8 sub_80B02C8(u16 shakeDir)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
u8 lo = REG_BLDALPHA & 0xFF;
|
|
|
|
u8 hi = REG_BLDALPHA >> 8;
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
if (shakeDir != 0)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (lo)
|
|
|
|
{
|
|
|
|
lo--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hi < 0x10)
|
|
|
|
{
|
|
|
|
hi++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 12:16:01 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(lo, hi));
|
2018-12-08 21:42:36 +01:00
|
|
|
|
|
|
|
if (lo == 0 && hi == 0x10)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
#define tState data[0]
|
|
|
|
#define tBlueOrb data[1]
|
|
|
|
#define tCenterX data[2]
|
|
|
|
#define tCenterY data[3]
|
|
|
|
#define tShakeDelay data[4]
|
|
|
|
#define tShakeDir data[5]
|
|
|
|
#define tDispCnt data[6]
|
|
|
|
#define tBldCnt data[7]
|
|
|
|
#define tBldAlpha data[8]
|
|
|
|
#define tWinIn data[9]
|
|
|
|
#define tWinOut data[10]
|
|
|
|
|
|
|
|
static void Task_OrbEffect(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
switch (tState)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2019-11-01 08:41:55 +01:00
|
|
|
tDispCnt = REG_DISPCNT;
|
|
|
|
tBldCnt = REG_BLDCNT;
|
|
|
|
tBldAlpha = REG_BLDALPHA;
|
|
|
|
tWinIn = REG_WININ;
|
|
|
|
tWinOut = REG_WINOUT;
|
2018-12-08 21:42:36 +01:00
|
|
|
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON);
|
2019-11-01 08:41:55 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_BLDCNT, gOrbEffectBackgroundLayerFlags[0]);
|
2018-12-09 12:16:01 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 7));
|
|
|
|
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR);
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ);
|
2019-10-26 03:55:01 +02:00
|
|
|
SetBgTilemapPalette(0, 0, 0, 0x1E, 0x14, 0xF);
|
2018-12-08 21:42:36 +01:00
|
|
|
schedule_bg_copy_tilemap_to_vram(0);
|
2019-11-01 08:41:55 +01:00
|
|
|
SetOrbFlashScanlineEffectWindowBoundaries(&gScanlineEffectRegBuffers[0][0], tCenterX, tCenterY, 1);
|
2018-12-08 21:42:36 +01:00
|
|
|
CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480);
|
|
|
|
ScanlineEffect_SetParams(sFlashEffectParams);
|
2019-11-01 08:41:55 +01:00
|
|
|
tState = 1;
|
2018-12-08 21:42:36 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2019-04-08 00:31:01 +02:00
|
|
|
sub_8199DF0(0, PIXEL_FILL(1), 0, 1);
|
2019-11-01 08:41:55 +01:00
|
|
|
LoadOrbEffectPalette(tBlueOrb);
|
|
|
|
sub_80B003C(tCenterX, tCenterY, 1, 160, 1, 2);
|
|
|
|
tState = 2;
|
2018-12-08 21:42:36 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2019-11-01 08:41:55 +01:00
|
|
|
if (!FuncIsActiveTask(UpdateOrbFlashEffect))
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
EnableBothScriptContexts();
|
2019-11-01 08:41:55 +01:00
|
|
|
tState = 3;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
InstallCameraPanAheadCallback();
|
|
|
|
SetCameraPanningCallback(NULL);
|
2019-11-01 08:41:55 +01:00
|
|
|
tShakeDir = 0;
|
|
|
|
tShakeDelay = 4;
|
|
|
|
tState = 4;
|
2018-12-08 21:42:36 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2019-11-01 08:41:55 +01:00
|
|
|
if (--tShakeDelay == 0)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
s32 panning;
|
2019-11-01 08:41:55 +01:00
|
|
|
tShakeDelay = 4;
|
|
|
|
tShakeDir ^= 1;
|
|
|
|
if (tShakeDir)
|
2018-12-08 21:42:36 +01:00
|
|
|
panning = 4;
|
|
|
|
else
|
|
|
|
panning = -4;
|
|
|
|
SetCameraPanning(0, panning);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
InstallCameraPanAheadCallback();
|
2019-11-01 08:41:55 +01:00
|
|
|
tShakeDelay = 8;
|
|
|
|
tState = 7;
|
2018-12-08 21:42:36 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2019-11-01 08:41:55 +01:00
|
|
|
if (--tShakeDelay == 0)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
tShakeDelay = 8;
|
|
|
|
tShakeDir ^= 1;
|
|
|
|
if (sub_80B02C8(tShakeDir) == TRUE)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
tState = 5;
|
2019-04-08 00:31:01 +02:00
|
|
|
sub_8199DF0(0, PIXEL_FILL(0), 0, 1);
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
SetGpuReg(REG_OFFSET_WIN0H, 255);
|
2019-11-01 08:41:55 +01:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, tDispCnt);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, tBldCnt);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, tBldAlpha);
|
|
|
|
SetGpuReg(REG_OFFSET_WININ, tWinIn);
|
|
|
|
SetGpuReg(REG_OFFSET_WINOUT, tWinOut);
|
2018-12-08 21:42:36 +01:00
|
|
|
EnableBothScriptContexts();
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
void DoOrbEffect(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
u8 taskId = CreateTask(Task_OrbEffect, 80);
|
2018-12-08 21:42:36 +01:00
|
|
|
s16 *data = gTasks[taskId].data;
|
|
|
|
|
|
|
|
if (gSpecialVar_Result == 0)
|
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
tBlueOrb = FALSE;
|
|
|
|
tCenterX = 104;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
else if (gSpecialVar_Result == 1)
|
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
tBlueOrb = TRUE;
|
|
|
|
tCenterX = 136;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
else if (gSpecialVar_Result == 2)
|
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
tBlueOrb = FALSE;
|
|
|
|
tCenterX = 120;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
tBlueOrb = TRUE;
|
|
|
|
tCenterX = 120;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
tCenterY = 80;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
void FadeOutOrbEffect(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
2019-11-01 08:41:55 +01:00
|
|
|
u8 taskId = FindTaskIdByFunc(Task_OrbEffect);
|
|
|
|
gTasks[taskId].tState = 6;
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
|
2019-11-01 08:41:55 +01:00
|
|
|
#undef tState
|
|
|
|
#undef tBlueOrb
|
|
|
|
#undef tCenterX
|
|
|
|
#undef tCenterY
|
|
|
|
#undef tShakeDelay
|
|
|
|
#undef tShakeDir
|
|
|
|
#undef tDispCnt
|
|
|
|
#undef tBldCnt
|
|
|
|
#undef tBldAlpha
|
|
|
|
#undef tWinIn
|
|
|
|
#undef tWinOut
|
|
|
|
|
2019-10-07 02:04:30 +02:00
|
|
|
void Script_FadeOutMapMusic(void)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
Overworld_FadeOutMapMusic();
|
2019-10-07 02:04:30 +02:00
|
|
|
CreateTask(Task_EnableScriptAfterMusicFade, 80);
|
2018-12-08 21:42:36 +01:00
|
|
|
}
|
|
|
|
|
2019-10-07 02:04:30 +02:00
|
|
|
static void Task_EnableScriptAfterMusicFade(u8 taskId)
|
2018-12-08 21:42:36 +01:00
|
|
|
{
|
|
|
|
if (BGMusicStopped() == TRUE)
|
|
|
|
{
|
|
|
|
DestroyTask(taskId);
|
|
|
|
EnableBothScriptContexts();
|
|
|
|
}
|
|
|
|
}
|