Document teleporter and escalator anim
This commit is contained in:
+5
-5
@@ -2629,7 +2629,7 @@ sub_80847F8: @ 80847F8
|
||||
bl FreezeObjectEvents
|
||||
bl CameraObjectReset2
|
||||
ldrb r0, [r4, 0xA]
|
||||
bl sub_809C448
|
||||
bl StartEscalator
|
||||
movs r0, 0x1
|
||||
bl sub_81128BC
|
||||
ldrh r0, [r4, 0x8]
|
||||
@@ -2859,7 +2859,7 @@ sub_80849A0: @ 80849A0
|
||||
lsrs r0, 24
|
||||
cmp r0, 0x1
|
||||
bne _080849DC
|
||||
bl sub_809C460
|
||||
bl StopEscalator
|
||||
bl WarpIntoMap
|
||||
ldr r1, _080849E4 @ =gFieldCallback
|
||||
ldr r0, _080849E8 @ =sub_80849F4
|
||||
@@ -2984,7 +2984,7 @@ _08084AC4:
|
||||
movs r1, 0
|
||||
_08084AC6:
|
||||
adds r0, r1, 0
|
||||
bl sub_809C448
|
||||
bl StartEscalator
|
||||
movs r0, 0x1
|
||||
add sp, 0x4
|
||||
pop {r4,r5}
|
||||
@@ -3163,11 +3163,11 @@ _08084C14: .4byte gSprites
|
||||
sub_8084C18: @ 8084C18
|
||||
push {r4,lr}
|
||||
adds r4, r0, 0
|
||||
bl sub_809C474
|
||||
bl IsEscalatorMoving
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
bne _08084C34
|
||||
bl sub_809C460
|
||||
bl StopEscalator
|
||||
ldrh r0, [r4, 0x8]
|
||||
adds r0, 0x1
|
||||
strh r0, [r4, 0x8]
|
||||
|
||||
@@ -177,7 +177,7 @@ Route25_SeaCottage_EventScript_RunCellSeparator:: @ 81706FA
|
||||
playse SE_PIN
|
||||
waitse
|
||||
setvar VAR_0x8004, 0
|
||||
special sub_809C4A8
|
||||
special AnimateTeleporterHousing
|
||||
delay 10
|
||||
call Route25_SeaCottage_EventScript_PlayTeleporterBeepSE
|
||||
call Route25_SeaCottage_EventScript_PlayTeleporterBeepSE
|
||||
@@ -187,9 +187,9 @@ Route25_SeaCottage_EventScript_RunCellSeparator:: @ 81706FA
|
||||
call Route25_SeaCottage_EventScript_PlayTeleporterBeepSE
|
||||
call Route25_SeaCottage_EventScript_PlayTeleporterBeepSE
|
||||
setvar VAR_0x8004, 1
|
||||
special sub_809C4A8
|
||||
special AnimateTeleporterHousing
|
||||
playse SE_TK_WARPIN
|
||||
special sub_809C5FC
|
||||
special AnimateTeleporterCable
|
||||
waitse
|
||||
call Route25_SeaCottage_EventScript_PlayTeleporterBeepSE
|
||||
call Route25_SeaCottage_EventScript_PlayTeleporterBeepSE
|
||||
|
||||
+2
-2
@@ -445,9 +445,9 @@ gSpecials:: @ 815FD60
|
||||
def_special Special_BrailleCursorToggle
|
||||
def_special Script_ResetUnionRoomTrade
|
||||
def_special Special_PlayerPartyContainsSpeciesWithPlayerID
|
||||
def_special sub_809C4A8
|
||||
def_special AnimateTeleporterHousing
|
||||
def_special IsDodrioInParty
|
||||
def_special sub_809C5FC
|
||||
def_special AnimateTeleporterCable
|
||||
def_special Special_InitElevatorFloorSelectMenuPos
|
||||
def_special Special_ComputeLoreleiDollCollection
|
||||
def_special Special_LoopWingFlapSound
|
||||
|
||||
@@ -6,7 +6,30 @@
|
||||
|
||||
// gTileset_Mart
|
||||
#define METATILE_Mart_CounterMid_Top 0x2BF
|
||||
#define METATILE_Mart_CounterMid_Bottom 0x2C0
|
||||
#define METATILE_Mart_CounterMid_Bottom 0x2C0
|
||||
|
||||
// gTileset_PokemonCenter
|
||||
#define METATILE_PokemonCenter_Escalator_Top_Normal 0x2E4
|
||||
#define METATILE_PokemonCenter_Escalator_Top_Transition1 0x317
|
||||
#define METATILE_PokemonCenter_Escalator_Top_Transition2 0x315
|
||||
#define METATILE_PokemonCenter_Escalator_TopNext_Normal 0x2E3
|
||||
#define METATILE_PokemonCenter_Escalator_TopNext_Transition1 0x316
|
||||
#define METATILE_PokemonCenter_Escalator_TopNext_Transition2 0x314
|
||||
#define METATILE_PokemonCenter_Escalator_TopNextRail_Normal 0x2EB
|
||||
#define METATILE_PokemonCenter_Escalator_TopNextRail_Transition1 0x31E
|
||||
#define METATILE_PokemonCenter_Escalator_TopNextRail_Transition2 0x31C
|
||||
#define METATILE_PokemonCenter_Escalator_Bottom_Normal 0x2D9
|
||||
#define METATILE_PokemonCenter_Escalator_Bottom_Transition1 0x313
|
||||
#define METATILE_PokemonCenter_Escalator_Bottom_Transition2 0x311
|
||||
#define METATILE_PokemonCenter_Escalator_BottomRail_Normal 0x2D1
|
||||
#define METATILE_PokemonCenter_Escalator_BottomRail_Transition1 0x30B
|
||||
#define METATILE_PokemonCenter_Escalator_BottomRail_Transition2 0x309
|
||||
#define METATILE_PokemonCenter_Escalator_BottomNext_Normal 0x2D8
|
||||
#define METATILE_PokemonCenter_Escalator_BottomNext_Transition1 0x312
|
||||
#define METATILE_PokemonCenter_Escalator_BottomNext_Transition2 0x310
|
||||
#define METATILE_PokemonCenter_Escalator_BottomNextRail_Normal 0x2D0
|
||||
#define METATILE_PokemonCenter_Escalator_BottomNextRail_Transition1 0x30A
|
||||
#define METATILE_PokemonCenter_Escalator_BottomNextRail_Transition2 0x308
|
||||
|
||||
// gTileset_VermilionGym
|
||||
#define METATILE_VermilionGym_Floor 0x281
|
||||
@@ -39,6 +62,18 @@
|
||||
#define METATILE_VermilionGym_Beam_Node_BottomRight_Edge_HalfOn 0x2C6
|
||||
#define METATILE_VermilionGym_Beam_Node_BottomRight_HalfOn 0x2C7
|
||||
|
||||
// gTileset_SeaCottage
|
||||
#define METATILE_SeaCottage_Teleporter_Light_Green 0x28A
|
||||
#define METATILE_SeaCottage_Teleporter_Light_Yellow 0x2B5
|
||||
#define METATILE_SeaCottage_Teleporter_Light_Red 0x2B6
|
||||
#define METATILE_SeaCottage_Teleporter_Cable_Top 0x285
|
||||
#define METATILE_SeaCottage_Teleporter_Cable_Bottom 0x2B4
|
||||
#define METATILE_SeaCottage_Teleporter_CableBall_Top 0x2B9
|
||||
#define METATILE_SeaCottage_Teleporter_CableBall_Bottom 0x2BA
|
||||
#define METATILE_SeaCottage_Teleporter_Door 0x296
|
||||
#define METATILE_SeaCottage_Teleporter_Door_HalfGlowing 0x2B7
|
||||
#define METATILE_SeaCottage_Teleporter_Door_FullGlowing 0x2B8
|
||||
|
||||
// gTileset_GameCorner
|
||||
#define METATILE_GameCorner_Floor_ShadeFull 0x292
|
||||
#define METATILE_GameCorner_Floor_StairsTop 0x29D
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#define OBJECT_EVENTS_COUNT 16
|
||||
|
||||
#define METATILE_COLLISION_MASK 0x0C00
|
||||
|
||||
enum
|
||||
{
|
||||
CONNECTION_SOUTH = 1,
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef GUARD_SEA_COTTAGE_SPECIAL_ANIM_H
|
||||
#define GUARD_SEA_COTTAGE_SPECIAL_ANIM_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
void sub_809C448(u8 a0);
|
||||
void sub_809C460(void);
|
||||
bool8 sub_809C474(void);
|
||||
void sub_809C4A8(void);
|
||||
void sub_809C5FC(void);
|
||||
|
||||
#endif // GUARD_SEA_COTTAGE_SPECIAL_ANIM_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef GUARD_SPECIAL_FIELD_ANIM_H
|
||||
#define GUARD_SPECIAL_FIELD_ANIM_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
void StartEscalator(u8 a0);
|
||||
void StopEscalator(void);
|
||||
bool8 IsEscalatorMoving(void);
|
||||
|
||||
#endif // GUARD_SPECIAL_FIELD_ANIM_H
|
||||
+2
-2
@@ -138,7 +138,7 @@ SECTIONS {
|
||||
src/battle_anim_mon_movement.o(.text);
|
||||
src/item.o(.text);
|
||||
src/shop.o(.text);
|
||||
src/sea_cottage_special_anim.o(.text);
|
||||
src/special_field_anim.o(.text);
|
||||
src/berry.o(.text);
|
||||
src/script_menu.o(.text);
|
||||
asm/naming_screen.o(.text);
|
||||
@@ -455,7 +455,7 @@ SECTIONS {
|
||||
src/battle_anim_mon_movement.o(.rodata);
|
||||
src/item.o(.rodata);
|
||||
src/shop.o(.rodata);
|
||||
src/sea_cottage_special_anim.o(.rodata);
|
||||
src/special_field_anim.o(.rodata);
|
||||
src/berry.o(.rodata);
|
||||
src/script_menu.o(.rodata);
|
||||
data/naming_screen.o(.rodata);
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "event_data.h"
|
||||
#include "task.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "fieldmap.h"
|
||||
#include "field_camera.h"
|
||||
|
||||
static EWRAM_DATA u8 gUnknown_2039984 = 0;
|
||||
|
||||
static void sub_809C1D8(u8 taskId, const s16 *a1, u16 a2);
|
||||
static void sub_809C334(u8 taskId);
|
||||
static void sub_809C500(u8 taskId);
|
||||
static void sub_809C640(u8 taskId);
|
||||
|
||||
static const u16 gUnknown_83DF0D4[] = {0x0308, 0x030a, 0x02d0};
|
||||
static const u16 gUnknown_83DF0DA[] = {0x0309, 0x030b, 0x02d1};
|
||||
static const u16 gUnknown_83DF0E0[] = {0x0310, 0x0312, 0x02d8};
|
||||
static const u16 gUnknown_83DF0E6[] = {0x0311, 0x0313, 0x02d9};
|
||||
static const u16 gUnknown_83DF0EC[] = {0x02e3, 0x0316, 0x0314};
|
||||
static const u16 gUnknown_83DF0F2[] = {0x02e4, 0x0317, 0x0315};
|
||||
static const u16 gUnknown_83DF0F8[] = {0x02eb, 0x031e, 0x031c};
|
||||
|
||||
// Functions
|
||||
static void sub_809C1D8(u8 taskId, const s16 *a1, u16 a2)
|
||||
{
|
||||
s16 r5, r3, r4;
|
||||
s16 i, j;
|
||||
|
||||
r5 = gTasks[taskId].data[4] - 1;
|
||||
r3 = gTasks[taskId].data[5] - 1;
|
||||
r4 = gTasks[taskId].data[1];
|
||||
|
||||
if (gTasks[taskId].data[2] == 0)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
s32 id = MapGridGetMetatileIdAt(r5 + j, r3 + i);
|
||||
|
||||
if (a1[r4] == (s16)id)
|
||||
{
|
||||
if (r4 != 2)
|
||||
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[r4 + 1]);
|
||||
else
|
||||
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
s32 id = MapGridGetMetatileIdAt(r5 + j, r3 + i);
|
||||
|
||||
if (a1[2 - r4] == (s16)id)
|
||||
{
|
||||
if (r4 != 2)
|
||||
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[1 - r4]);
|
||||
else
|
||||
MapGridSetMetatileIdAt(r5 + j, r3 + i, a2 | a1[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809C334(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
u16 v1;
|
||||
|
||||
data[3] = 1;
|
||||
switch (data[0])
|
||||
{
|
||||
case 0:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0D4, 0);
|
||||
break;
|
||||
case 1:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0DA, 0);
|
||||
break;
|
||||
case 2:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0E0, 0xC00);
|
||||
break;
|
||||
case 3:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0E6, 0);
|
||||
break;
|
||||
case 4:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0EC, 0xC00);
|
||||
break;
|
||||
case 5:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0F2, 0);
|
||||
break;
|
||||
case 6:
|
||||
sub_809C1D8(taskId, gUnknown_83DF0F8, 0);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
data[0] = (data[0] + 1) & 7;
|
||||
v1 = data[0] & 7;
|
||||
if (v1 == 0)
|
||||
{
|
||||
DrawWholeMapView();
|
||||
data[1] = (data[1] + 1) % 3;
|
||||
data[3] = v1;
|
||||
}
|
||||
}
|
||||
|
||||
static u8 sub_809C3FC(u16 a0)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = CreateTask(sub_809C334, 0);
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&data[4], &data[5]);
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = a0;
|
||||
sub_809C334(taskId);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
void sub_809C448(u8 a0)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
taskId = sub_809C3FC(a0);
|
||||
gUnknown_2039984 = taskId;
|
||||
}
|
||||
|
||||
void sub_809C460(void)
|
||||
{
|
||||
DestroyTask(gUnknown_2039984);
|
||||
}
|
||||
|
||||
bool8 sub_809C474(void)
|
||||
{
|
||||
if (gTasks[gUnknown_2039984].data[3] == 0)
|
||||
{
|
||||
if (gTasks[gUnknown_2039984].data[1] != 2)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// special 0x1b5 - creates a tile animaiton one block left two-four up the player
|
||||
void sub_809C4A8(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = CreateTask(sub_809C500, 0);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
gTasks[taskId].data[1] = 0;
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&data[2], &data[3]);
|
||||
if (gSpecialVar_0x8004 == 0)
|
||||
{
|
||||
gTasks[taskId].data[2] += 6;
|
||||
gTasks[taskId].data[3] -= 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].data[2]--;
|
||||
gTasks[taskId].data[3] -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_809C500(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (data[0] == 0)
|
||||
{
|
||||
if ((data[1] & 1) == 0)
|
||||
{
|
||||
MapGridSetMetatileIdAt(data[2], data[3], 0xEB5);
|
||||
MapGridSetMetatileIdAt(data[2], data[3] + 2, 0xEB7);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapGridSetMetatileIdAt(data[2], data[3], 0xEB6);
|
||||
MapGridSetMetatileIdAt(data[2], data[3] + 2, 0xEB8);
|
||||
}
|
||||
CurrentMapDrawMetatileAt(data[2], data[3]);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3] + 2);
|
||||
}
|
||||
|
||||
data[0]++;
|
||||
if (data[0] != 0x10)
|
||||
return;
|
||||
|
||||
data[0] = 0;
|
||||
data[1]++;
|
||||
if (data[1] != 0xD)
|
||||
return;
|
||||
|
||||
MapGridSetMetatileIdAt(data[2], data[3], 0xE8A);
|
||||
MapGridSetMetatileIdAt(data[2], data[3] + 2, 0xE96);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3]);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3] + 2);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
// special 0x1B7 - creates a tile animation two-six blocks right from the top-left corner of the screen
|
||||
void sub_809C5FC(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = CreateTask(sub_809C640, 0);
|
||||
gTasks[taskId].data[0] = 0;
|
||||
gTasks[taskId].data[1] = 0;
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&data[2], &data[3]);
|
||||
gTasks[taskId].data[2] += 4;
|
||||
gTasks[taskId].data[3] -= 5;
|
||||
}
|
||||
|
||||
static void sub_809C640(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (data[0] == 0)
|
||||
{
|
||||
if (data[1] != 0)
|
||||
{
|
||||
MapGridSetMetatileIdAt(data[2], data[3], 0xE85);
|
||||
MapGridSetMetatileIdAt(data[2], data[3] + 1, 0xEB4);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3]);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3] + 1);
|
||||
if (data[1] == 4)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
return;
|
||||
}
|
||||
|
||||
data[2]--;
|
||||
}
|
||||
MapGridSetMetatileIdAt(data[2], data[3], 0xEB9);
|
||||
MapGridSetMetatileIdAt(data[2], data[3] + 1, 0xEBA);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3]);
|
||||
CurrentMapDrawMetatileAt(data[2], data[3] + 1);
|
||||
}
|
||||
|
||||
data[0]++;
|
||||
if (data[0] == 4)
|
||||
{
|
||||
data[0] = 0;
|
||||
data[1]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
#include "global.h"
|
||||
#include "event_data.h"
|
||||
#include "task.h"
|
||||
#include "field_player_avatar.h"
|
||||
#include "fieldmap.h"
|
||||
#include "field_camera.h"
|
||||
#include "constants/metatile_labels.h"
|
||||
|
||||
static EWRAM_DATA u8 sEscalatorTaskId = 0;
|
||||
|
||||
static void SetEscalatorMetatile(u8 taskId, const s16 *metatileIds, u16 metatileMasks);
|
||||
static void Task_DrawEscalator(u8 taskId);
|
||||
static void Task_DrawTeleporterHousing(u8 taskId);
|
||||
static void Task_DrawTeleporterCable(u8 taskId);
|
||||
|
||||
#define ESCALATOR_STAGES 3
|
||||
#define LAST_ESCALATOR_STAGE (ESCALATOR_STAGES - 1)
|
||||
|
||||
static const u16 sEscalatorMetatiles_BottomNextRail[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_BottomNextRail_Transition2,
|
||||
METATILE_PokemonCenter_Escalator_BottomNextRail_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_BottomNextRail_Normal
|
||||
};
|
||||
|
||||
static const u16 sEscalatorMetatiles_BottomRail[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_BottomRail_Transition2,
|
||||
METATILE_PokemonCenter_Escalator_BottomRail_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_BottomRail_Normal
|
||||
};
|
||||
|
||||
static const u16 sEscalatorMetatiles_BottomNext[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_BottomNext_Transition2,
|
||||
METATILE_PokemonCenter_Escalator_BottomNext_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_BottomNext_Normal
|
||||
};
|
||||
|
||||
static const u16 sEscalatorMetatiles_Bottom[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_Bottom_Transition2,
|
||||
METATILE_PokemonCenter_Escalator_Bottom_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_Bottom_Normal
|
||||
};
|
||||
|
||||
static const u16 sEscalatorMetatiles_TopNext[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_TopNext_Normal,
|
||||
METATILE_PokemonCenter_Escalator_TopNext_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_TopNext_Transition2
|
||||
};
|
||||
|
||||
static const u16 sEscalatorMetatiles_Top[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_Top_Normal,
|
||||
METATILE_PokemonCenter_Escalator_Top_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_Top_Transition2
|
||||
};
|
||||
|
||||
static const u16 sEscalatorMetatiles_TopNextRail[ESCALATOR_STAGES] =
|
||||
{
|
||||
METATILE_PokemonCenter_Escalator_TopNextRail_Normal,
|
||||
METATILE_PokemonCenter_Escalator_TopNextRail_Transition1,
|
||||
METATILE_PokemonCenter_Escalator_TopNextRail_Transition2
|
||||
};
|
||||
|
||||
#define tState data[0]
|
||||
#define tTransitionStage data[1]
|
||||
#define tGoingUp data[2]
|
||||
#define tDrawingEscalator data[3]
|
||||
#define tPlayerX data[4]
|
||||
#define tPlayerY data[5]
|
||||
|
||||
static void SetEscalatorMetatile(u8 taskId, const s16 *metatileIds, u16 metatileMasks)
|
||||
{
|
||||
s16 x, y, transitionStage;
|
||||
s16 i, j;
|
||||
|
||||
x = gTasks[taskId].tPlayerX - 1;
|
||||
y = gTasks[taskId].tPlayerY - 1;
|
||||
transitionStage = gTasks[taskId].tTransitionStage;
|
||||
|
||||
// Check all the escalator sections and only progress the selected one to the next stage
|
||||
if (!gTasks[taskId].tGoingUp)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
s32 id = MapGridGetMetatileIdAt(x + j, y + i);
|
||||
|
||||
if (metatileIds[transitionStage] == (s16)id)
|
||||
{
|
||||
if (transitionStage != LAST_ESCALATOR_STAGE)
|
||||
MapGridSetMetatileIdAt(x + j, y + i, metatileMasks | metatileIds[transitionStage + 1]);
|
||||
else
|
||||
MapGridSetMetatileIdAt(x + j, y + i, metatileMasks | metatileIds[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
s32 id = MapGridGetMetatileIdAt(x + j, y + i);
|
||||
|
||||
if (metatileIds[LAST_ESCALATOR_STAGE - transitionStage] == (s16)id)
|
||||
{
|
||||
if (transitionStage != LAST_ESCALATOR_STAGE)
|
||||
MapGridSetMetatileIdAt(x + j, y + i, metatileMasks | metatileIds[1 - transitionStage]);
|
||||
else
|
||||
MapGridSetMetatileIdAt(x + j, y + i, metatileMasks | metatileIds[LAST_ESCALATOR_STAGE]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_DrawEscalator(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
u16 state;
|
||||
|
||||
tDrawingEscalator = TRUE;
|
||||
|
||||
// Set tile for each section of the escalator in sequence for current transition stage
|
||||
switch (tState)
|
||||
{
|
||||
case 0:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_BottomNextRail, 0);
|
||||
break;
|
||||
case 1:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_BottomRail, 0);
|
||||
break;
|
||||
case 2:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_BottomNext, METATILE_COLLISION_MASK);
|
||||
break;
|
||||
case 3:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_Bottom, 0);
|
||||
break;
|
||||
case 4:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_TopNext, METATILE_COLLISION_MASK);
|
||||
break;
|
||||
case 5:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_Top, 0);
|
||||
break;
|
||||
case 6:
|
||||
SetEscalatorMetatile(taskId, sEscalatorMetatiles_TopNextRail, 0);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
tState = (tState + 1) & 7;
|
||||
state = tState & 7;
|
||||
|
||||
// If all sections of the escalator have been set, draw map and progress to next stage
|
||||
if (state == 0)
|
||||
{
|
||||
DrawWholeMapView();
|
||||
tTransitionStage = (tTransitionStage + 1) % ESCALATOR_STAGES;
|
||||
tDrawingEscalator = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static u8 CreateEscalatorTask(bool16 goingUp)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = CreateTask(Task_DrawEscalator, 0);
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&tPlayerX, &tPlayerY);
|
||||
tState = 0;
|
||||
tTransitionStage = 0;
|
||||
tGoingUp = goingUp;
|
||||
Task_DrawEscalator(taskId);
|
||||
return taskId;
|
||||
}
|
||||
|
||||
void StartEscalator(bool8 goingUp)
|
||||
{
|
||||
u8 taskId;
|
||||
|
||||
taskId = CreateEscalatorTask(goingUp);
|
||||
sEscalatorTaskId = taskId;
|
||||
}
|
||||
|
||||
void StopEscalator(void)
|
||||
{
|
||||
DestroyTask(sEscalatorTaskId);
|
||||
}
|
||||
|
||||
bool8 IsEscalatorMoving(void)
|
||||
{
|
||||
if (gTasks[sEscalatorTaskId].tDrawingEscalator == FALSE)
|
||||
{
|
||||
if (gTasks[sEscalatorTaskId].tTransitionStage != LAST_ESCALATOR_STAGE)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
#undef tState
|
||||
#undef tTransitionStage
|
||||
#undef tGoingUp
|
||||
#undef tDrawingEscalator
|
||||
#undef tPlayerX
|
||||
#undef tPlayerY
|
||||
|
||||
#define tTimer data[0]
|
||||
#define tState data[1]
|
||||
#define tX data[2]
|
||||
#define tY data[3]
|
||||
|
||||
void AnimateTeleporterHousing(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = CreateTask(Task_DrawTeleporterHousing, 0);
|
||||
gTasks[taskId].tTimer = 0;
|
||||
gTasks[taskId].tState = 0;
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&tX, &tY);
|
||||
|
||||
// Set the coords of whichever teleporter is being animated
|
||||
// 0 for the right teleporter, 1 for the left teleporter
|
||||
if (gSpecialVar_0x8004 == 0)
|
||||
{
|
||||
gTasks[taskId].tX += 6;
|
||||
gTasks[taskId].tY -= 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
gTasks[taskId].tX -= 1;
|
||||
gTasks[taskId].tY -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
static void Task_DrawTeleporterHousing(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (tTimer == 0)
|
||||
{
|
||||
// Alternate the teleporter light / brightness of the teleporter door
|
||||
if ((tState & 1) == 0)
|
||||
{
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Yellow | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door_HalfGlowing | METATILE_COLLISION_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Red | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door_FullGlowing | METATILE_COLLISION_MASK);
|
||||
}
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 2);
|
||||
}
|
||||
|
||||
tTimer++;
|
||||
if (tTimer != 16)
|
||||
return;
|
||||
|
||||
tTimer = 0;
|
||||
tState++;
|
||||
if (tState != 13)
|
||||
return;
|
||||
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Light_Green | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 2, METATILE_SeaCottage_Teleporter_Door | METATILE_COLLISION_MASK);
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 2);
|
||||
DestroyTask(taskId);
|
||||
}
|
||||
|
||||
void AnimateTeleporterCable(void)
|
||||
{
|
||||
u8 taskId;
|
||||
s16 *data;
|
||||
|
||||
taskId = CreateTask(Task_DrawTeleporterCable, 0);
|
||||
gTasks[taskId].tTimer = 0;
|
||||
gTasks[taskId].tState = 0;
|
||||
data = gTasks[taskId].data;
|
||||
PlayerGetDestCoords(&tX, &tY);
|
||||
gTasks[taskId].tX += 4;
|
||||
gTasks[taskId].tY -= 5;
|
||||
}
|
||||
|
||||
static void Task_DrawTeleporterCable(u8 taskId)
|
||||
{
|
||||
s16 *data = gTasks[taskId].data;
|
||||
|
||||
if (tTimer == 0)
|
||||
{
|
||||
if (tState != 0)
|
||||
{
|
||||
// Set default cable tiles to clear the ball
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_Cable_Top | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 1, METATILE_SeaCottage_Teleporter_Cable_Bottom | METATILE_COLLISION_MASK);
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 1);
|
||||
|
||||
// End after drawing 4 times (length of the cable)
|
||||
if (tState == 4)
|
||||
{
|
||||
DestroyTask(taskId);
|
||||
return;
|
||||
}
|
||||
|
||||
tX--;
|
||||
}
|
||||
|
||||
// Draw the cable ball
|
||||
MapGridSetMetatileIdAt(tX, tY, METATILE_SeaCottage_Teleporter_CableBall_Top | METATILE_COLLISION_MASK);
|
||||
MapGridSetMetatileIdAt(tX, tY + 1, METATILE_SeaCottage_Teleporter_CableBall_Bottom | METATILE_COLLISION_MASK);
|
||||
CurrentMapDrawMetatileAt(tX, tY);
|
||||
CurrentMapDrawMetatileAt(tX, tY + 1);
|
||||
}
|
||||
|
||||
tTimer++;
|
||||
if (tTimer == 4)
|
||||
{
|
||||
tTimer = 0;
|
||||
tState++;
|
||||
}
|
||||
}
|
||||
|
||||
#undef tTimer
|
||||
#undef tState
|
||||
#undef tX
|
||||
#undef tY
|
||||
+1
-1
@@ -235,7 +235,7 @@ gBagPockets: @ 203988C
|
||||
.align 2
|
||||
.include "src/shop.o"
|
||||
.align 2
|
||||
.include "src/sea_cottage_special_anim.o"
|
||||
.include "src/special_field_anim.o"
|
||||
.align 2
|
||||
.include "src/script_menu.o"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user