2018-01-07 17:50:13 -06:00
# include "global.h"
2018-11-14 00:01:50 +00:00
# include "event_data.h"
2018-01-07 17:50:13 -06:00
# include "field_door.h"
# include "field_camera.h"
# include "fieldmap.h"
# include "metatile_behavior.h"
2018-11-14 00:01:50 +00:00
# include "task.h"
# include "constants/songs.h"
2020-01-20 19:36:17 -05:00
# include "constants/metatile_labels.h"
# define DOOR_SOUND_NORMAL 0
# define DOOR_SOUND_SLIDING 1
# define DOOR_SOUND_ARENA 2
struct DoorGraphics
{
u16 metatileNum ;
u8 sound ;
u8 size ;
const void * tiles ;
2022-05-17 17:13:29 -04:00
const void * palettes ;
2020-01-20 19:36:17 -05:00
} ;
struct DoorAnimFrame
{
u8 time ;
u16 offset ;
} ;
2018-01-07 17:50:13 -06:00
2019-12-14 03:58:20 -05:00
static bool8 ShouldUseMultiCorridorDoor ( void ) ;
2018-01-07 18:58:52 -06:00
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Littleroot [ ] = INCBIN_U8 ( " graphics/door_anims/littleroot.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette1 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BirchsLab [ ] = INCBIN_U8 ( " graphics/door_anims/birchs_lab.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette2 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_FallarborLightRoof [ ] = INCBIN_U8 ( " graphics/door_anims/fallarbor_light_roof.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette3 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Lilycove [ ] = INCBIN_U8 ( " graphics/door_anims/lilycove.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette4 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_LilycoveWooden [ ] = INCBIN_U8 ( " graphics/door_anims/lilycove_wooden.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette5 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_General [ ] = INCBIN_U8 ( " graphics/door_anims/general.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette6 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_PokeCenter [ ] = INCBIN_U8 ( " graphics/door_anims/poke_center.4bpp " ) ;
static const u8 sDoorAnimTiles_Gym [ ] = INCBIN_U8 ( " graphics/door_anims/gym.4bpp " ) ;
static const u8 sDoorAnimTiles_PokeMart [ ] = INCBIN_U8 ( " graphics/door_anims/poke_mart.4bpp " ) ;
static const u8 sDoorAnimTiles_RustboroTan [ ] = INCBIN_U8 ( " graphics/door_anims/rustboro_tan.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette7 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_RustboroGray [ ] = INCBIN_U8 ( " graphics/door_anims/rustboro_gray.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette8 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Oldale [ ] = INCBIN_U8 ( " graphics/door_anims/oldale.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u8 sFiller1 [ 0x5900 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_UnusedTops [ ] = INCBIN_U8 ( " graphics/door_anims/unused_top.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u8 sFiller2 [ 0x140 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_UnusedBottoms [ ] = INCBIN_U8 ( " graphics/door_anims/unused_bottom.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette11 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Mauville [ ] = INCBIN_U8 ( " graphics/door_anims/mauville.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette12 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Verdanturf [ ] = INCBIN_U8 ( " graphics/door_anims/verdanturf.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette13 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Slateport [ ] = INCBIN_U8 ( " graphics/door_anims/slateport.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette14 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Dewford [ ] = INCBIN_U8 ( " graphics/door_anims/dewford.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette15 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Contest [ ] = INCBIN_U8 ( " graphics/door_anims/contest.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette16 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Mossdeep [ ] = INCBIN_U8 ( " graphics/door_anims/mossdeep.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette17 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_SootopolisPeakedRoof [ ] = INCBIN_U8 ( " graphics/door_anims/sootopolis_peaked_roof.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette18 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Sootopolis [ ] = INCBIN_U8 ( " graphics/door_anims/sootopolis.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette19 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_PokemonLeague [ ] = INCBIN_U8 ( " graphics/door_anims/pokemon_league.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette20 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_Pacifidlog [ ] = INCBIN_U8 ( " graphics/door_anims/pacifidlog.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette21 [ 16 ] = { } ;
2022-05-17 18:38:21 -04:00
static const u8 sDoorAnimTiles_PetalburgGym [ ] = INCBIN_U8 ( " graphics/door_anims/petalburg_gym.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette22 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_CyclingRoad [ ] = INCBIN_U8 ( " graphics/door_anims/cycling_road.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette23 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_LilycoveDeptStore [ ] = INCBIN_U8 ( " graphics/door_anims/lilycove_dept_store.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette24 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_SafariZone [ ] = INCBIN_U8 ( " graphics/door_anims/safari_zone.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette25 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_MossdeepSpaceCenter [ ] = INCBIN_U8 ( " graphics/door_anims/mossdeep_space_center.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette26 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_CableClub [ ] = INCBIN_U8 ( " graphics/door_anims/cable_club.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette27 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_AbandonedShip [ ] = INCBIN_U8 ( " graphics/door_anims/abandoned_ship.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette28 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_FallarborDarkRoof [ ] = INCBIN_U8 ( " graphics/door_anims/fallarbor_dark_roof.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette29 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_AbandonedShipRoom [ ] = INCBIN_U8 ( " graphics/door_anims/abandoned_ship_room.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette30 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_LilycoveDeptStoreElevator [ ] = INCBIN_U8 ( " graphics/door_anims/lilycove_dept_store_elevator.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette31 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleTowerOld [ ] = INCBIN_U8 ( " graphics/door_anims/battle_tower_old.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette32 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleTowerElevator [ ] = INCBIN_U8 ( " graphics/door_anims/battle_tower_elevator.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette33 [ 16 ] = { } ;
2022-05-18 12:41:46 -04:00
static const u8 sDoorAnimTiles_UnusedBattleFrontier [ ] = INCBIN_U8 ( " graphics/door_anims/unused_battle_frontier.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette34 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleDome [ ] = INCBIN_U8 ( " graphics/door_anims/battle_dome.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette35 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleFactory [ ] = INCBIN_U8 ( " graphics/door_anims/battle_factory.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette36 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleTower [ ] = INCBIN_U8 ( " graphics/door_anims/battle_tower.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette37 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleArena [ ] = INCBIN_U8 ( " graphics/door_anims/battle_arena.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette38 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleArenaLobby [ ] = INCBIN_U8 ( " graphics/door_anims/battle_arena_lobby.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette39 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleDomeLobby [ ] = INCBIN_U8 ( " graphics/door_anims/battle_dome_lobby.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette40 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattlePalaceLobby [ ] = INCBIN_U8 ( " graphics/door_anims/battle_palace_lobby.4bpp " ) ;
static const u8 sDoorAnimTiles_BattleTent [ ] = INCBIN_U8 ( " graphics/door_anims/battle_tent.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette41 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleDomeCorridor [ ] = INCBIN_U8 ( " graphics/door_anims/battle_dome_corridor.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette42 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleTowerMultiCorridor [ ] = INCBIN_U8 ( " graphics/door_anims/battle_tower_multi_corridor.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette43 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleFrontier [ ] = INCBIN_U8 ( " graphics/door_anims/battle_frontier.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette44 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleFrontierSliding [ ] = INCBIN_U8 ( " graphics/door_anims/battle_frontier_sliding.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette45 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleDomePreBattleRoom [ ] = INCBIN_U8 ( " graphics/door_anims/battle_dome_pre_battle_room.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette46 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_BattleTentInterior [ ] = INCBIN_U8 ( " graphics/door_anims/battle_tent_interior.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette47 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_TrainerHillLobbyElevator [ ] = INCBIN_U8 ( " graphics/door_anims/trainer_hill_lobby_elevator.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette48 [ 16 ] = { } ;
2020-01-21 01:22:17 -05:00
static const u8 sDoorAnimTiles_TrainerHillRoofElevator [ ] = INCBIN_U8 ( " graphics/door_anims/trainer_hill_roof_elevator.4bpp " ) ;
2020-01-21 08:46:26 -05:00
static const u16 sDoorNullPalette49 [ 16 ] = { } ;
2018-01-07 17:50:13 -06:00
2020-01-20 19:36:17 -05:00
static const struct DoorAnimFrame sDoorOpenAnimFrames [ ] =
2018-01-07 17:50:13 -06:00
{
{ 4 , - 1 } ,
{ 4 , 0 } ,
{ 4 , 0x100 } ,
{ 4 , 0x200 } ,
{ 0 , 0 } ,
} ;
2020-01-20 19:36:17 -05:00
static const struct DoorAnimFrame sDoorCloseAnimFrames [ ] =
2018-01-07 17:50:13 -06:00
{
{ 4 , 0x200 } ,
{ 4 , 0x100 } ,
{ 4 , 0 } ,
{ 4 , - 1 } ,
{ 0 , 0 } ,
} ;
2020-01-20 19:36:17 -05:00
static const struct DoorAnimFrame sBigDoorOpenAnimFrames [ ] =
2018-01-07 17:50:13 -06:00
{
{ 4 , - 1 } ,
{ 4 , 0 } ,
{ 4 , 0x200 } ,
{ 4 , 0x400 } ,
{ 0 , 0 } ,
} ;
2020-01-20 19:36:17 -05:00
static const struct DoorAnimFrame sBigDoorCloseAnimFrames [ ] =
2018-01-07 17:50:13 -06:00
{
{ 4 , 0x400 } ,
{ 4 , 0x200 } ,
{ 4 , 0 } ,
{ 4 , - 1 } ,
{ 0 , 0 } ,
} ;
2020-01-20 19:36:17 -05:00
static const u8 sDoorAnimPalettes_General [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_PokeCenter [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_Gym [ ] = { 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 } ;
static const u8 sDoorAnimPalettes_PokeMart [ ] = { 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_Littleroot [ ] = { 10 , 10 , 6 , 6 , 6 , 6 , 6 , 6 } ;
static const u8 sDoorAnimPalettes_BirchsLab [ ] = { 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 } ;
static const u8 sDoorAnimPalettes_RustboroTan [ ] = { 11 , 11 , 11 , 11 , 11 , 11 , 11 , 11 } ;
static const u8 sDoorAnimPalettes_RustboroGray [ ] = { 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 } ;
static const u8 sDoorAnimPalettes_FallarborLightRoof [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_Lilycove [ ] = { 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 } ;
static const u8 sDoorAnimPalettes_Oldale [ ] = { 10 , 10 , 9 , 9 , 9 , 9 , 9 , 9 } ;
static const u8 sDoorAnimPalettes_Mossdeep [ ] = { 9 , 9 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_PokemonLeague [ ] = { 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 } ;
static const u8 sDoorAnimPalettes_Pacifidlog [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 } ;
static const u8 sDoorAnimPalettes_SootopolisPeakedRoof [ ] = { 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 } ;
static const u8 sDoorAnimPalettes_Sootopolis [ ] = { 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 } ;
static const u8 sDoorAnimPalettes_Dewford [ ] = { 0 , 0 , 5 , 5 , 5 , 5 , 5 , 5 } ;
static const u8 sDoorAnimPalettes_Slateport [ ] = { 6 , 6 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_Mauville [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_Verdanturf [ ] = { 6 , 6 , 5 , 5 , 5 , 5 , 5 , 5 } ;
static const u8 sDoorAnimPalettes_LilycoveWooden [ ] = { 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 } ;
static const u8 sDoorAnimPalettes_Contest [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
2022-05-17 18:38:21 -04:00
static const u8 sDoorAnimPalettes_PetalburgGym [ ] = { 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 } ;
2020-01-20 19:36:17 -05:00
static const u8 sDoorAnimPalettes_CyclingRoad [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_LilycoveDeptStore [ ] = { 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 } ;
static const u8 sDoorAnimPalettes_SafariZone [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 } ;
static const u8 sDoorAnimPalettes_MossdeepSpaceCenter [ ] = { 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 } ;
static const u8 sDoorAnimPalettes_CableClub [ ] = { 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 } ;
static const u8 sDoorAnimPalettes_AbandonedShip [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_FallarborDarkRoof [ ] = { 11 , 11 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_AbandonedShipRoom [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_LilycoveDeptStoreElevator [ ] = { 6 , 6 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_BattleTowerOld [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 } ;
static const u8 sDoorAnimPalettes_BattleTowerElevator [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
2022-05-18 12:41:46 -04:00
static const u8 sDoorAnimPalettes_UnusedBattleFrontier [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 } ;
2020-01-20 19:36:17 -05:00
static const u8 sDoorAnimPalettes_BattleDome [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_BattleFactory [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 } ;
static const u8 sDoorAnimPalettes_BattleTower [ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ;
static const u8 sDoorAnimPalettes_BattleArena [ ] = { 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 } ;
static const u8 sDoorAnimPalettes_BattleArenaLobby [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_BattleDomeLobby [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_BattlePalaceLobby [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_BattleTent [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_BattleDomeCorridor [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_BattleTowerMultiCorridor [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_Unused [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_BattleFrontier [ ] = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 } ;
static const u8 sDoorAnimPalettes_BattleDomePreBattleRoom [ ] = { 9 , 9 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_BattleTentInterior [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 } ;
static const u8 sDoorAnimPalettes_TrainerHillLobbyElevator [ ] = { 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const u8 sDoorAnimPalettes_TrainerHillRoofElevator [ ] = { 9 , 9 , 7 , 7 , 7 , 7 , 7 , 7 } ;
static const struct DoorGraphics sDoorAnimGraphicsTable [ ] =
{
{ METATILE_General_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_General , sDoorAnimPalettes_General } ,
{ METATILE_General_Door_PokeCenter , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_PokeCenter , sDoorAnimPalettes_PokeCenter } ,
{ METATILE_General_Door_Gym , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_Gym , sDoorAnimPalettes_Gym } ,
{ METATILE_General_Door_PokeMart , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_PokeMart , sDoorAnimPalettes_PokeMart } ,
{ METATILE_Petalburg_Door_Littleroot , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Littleroot , sDoorAnimPalettes_Littleroot } ,
{ METATILE_Petalburg_Door_BirchsLab , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_BirchsLab , sDoorAnimPalettes_BirchsLab } ,
{ METATILE_Rustboro_Door_Tan , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_RustboroTan , sDoorAnimPalettes_RustboroTan } ,
{ METATILE_Rustboro_Door_Gray , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_RustboroGray , sDoorAnimPalettes_RustboroGray } ,
{ METATILE_Fallarbor_Door_LightRoof , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_FallarborLightRoof , sDoorAnimPalettes_FallarborLightRoof } ,
{ METATILE_Petalburg_Door_Oldale , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Oldale , sDoorAnimPalettes_Oldale } ,
{ METATILE_Mauville_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Mauville , sDoorAnimPalettes_Mauville } ,
{ METATILE_Mauville_Door_Verdanturf , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Verdanturf , sDoorAnimPalettes_Verdanturf } ,
{ METATILE_Slateport_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Slateport , sDoorAnimPalettes_Slateport } ,
{ METATILE_Dewford_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Dewford , sDoorAnimPalettes_Dewford } ,
{ METATILE_General_Door_Contest , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_Contest , sDoorAnimPalettes_Contest } ,
{ METATILE_Lilycove_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Lilycove , sDoorAnimPalettes_Lilycove } ,
{ METATILE_Lilycove_Door_Wooden , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_LilycoveWooden , sDoorAnimPalettes_LilycoveWooden } ,
{ METATILE_Mossdeep_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Mossdeep , sDoorAnimPalettes_Mossdeep } ,
{ METATILE_Sootopolis_Door_PeakedRoof , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_SootopolisPeakedRoof , sDoorAnimPalettes_SootopolisPeakedRoof } ,
{ METATILE_Sootopolis_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Sootopolis , sDoorAnimPalettes_Sootopolis } ,
{ METATILE_EverGrande_Door_PokemonLeague , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_PokemonLeague , sDoorAnimPalettes_PokemonLeague } ,
{ METATILE_Pacifidlog_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_Pacifidlog , sDoorAnimPalettes_Pacifidlog } ,
2022-05-17 18:38:21 -04:00
{ METATILE_PetalburgGym_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_PetalburgGym , sDoorAnimPalettes_PetalburgGym } ,
2020-01-20 19:36:17 -05:00
{ METATILE_Mauville_Door_CyclingRoad , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_CyclingRoad , sDoorAnimPalettes_CyclingRoad } ,
{ METATILE_Lilycove_Door_DeptStore , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_LilycoveDeptStore , sDoorAnimPalettes_LilycoveDeptStore } ,
{ METATILE_Lilycove_Door_SafariZone , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_SafariZone , sDoorAnimPalettes_SafariZone } ,
{ METATILE_Mossdeep_Door_SpaceCenter , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_MossdeepSpaceCenter , sDoorAnimPalettes_MossdeepSpaceCenter } ,
{ METATILE_PokemonCenter_Door_CableClub , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_CableClub , sDoorAnimPalettes_CableClub } ,
{ METATILE_InsideShip_IntactDoor_Bottom_Unlocked , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_AbandonedShip , sDoorAnimPalettes_AbandonedShip } ,
{ METATILE_Fallarbor_Door_DarkRoof , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_FallarborDarkRoof , sDoorAnimPalettes_FallarborDarkRoof } ,
{ METATILE_InsideShip_IntactDoor_Bottom_Interior , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_AbandonedShipRoom , sDoorAnimPalettes_AbandonedShipRoom } ,
{ METATILE_Shop_Door_Elevator , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_LilycoveDeptStoreElevator , sDoorAnimPalettes_LilycoveDeptStoreElevator } ,
{ METATILE_Dewford_Door_BattleTower , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTowerOld , sDoorAnimPalettes_BattleTowerOld } ,
{ METATILE_BattleFrontier_Door_Elevator , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTowerElevator , sDoorAnimPalettes_BattleTowerElevator } ,
2022-05-18 12:41:46 -04:00
// The metatile for this door doesn't seem to correspond to a door in any Emerald tileset. Given the surrounding door animations, it was likely cut from the Battle Frontier.
// From the palettes array we know it uses palette 9, and the door's shadow looks correct using either the Battle Tent or Battle Frontier Outside's 9th palette.
{ 0x3B0 , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_UnusedBattleFrontier , sDoorAnimPalettes_UnusedBattleFrontier } ,
2020-01-20 19:36:17 -05:00
{ METATILE_BattleFrontierOutsideWest_Door_BattleDome , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleDome , sDoorAnimPalettes_BattleDome } ,
{ METATILE_BattleFrontierOutsideWest_Door_BattleFactory , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleFactory , sDoorAnimPalettes_BattleFactory } ,
{ METATILE_BattleFrontierOutsideEast_Door_BattleTower , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTower , sDoorAnimPalettes_BattleTower } ,
{ METATILE_BattleFrontierOutsideEast_Door_BattleArena , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_BattleArena , sDoorAnimPalettes_BattleArena } ,
{ METATILE_BattleArena_Door , DOOR_SOUND_ARENA , 1 , sDoorAnimTiles_BattleArenaLobby , sDoorAnimPalettes_BattleArenaLobby } ,
{ METATILE_BattleDome_Door_Lobby , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleDomeLobby , sDoorAnimPalettes_BattleDomeLobby } ,
{ METATILE_BattlePalace_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_BattlePalaceLobby , sDoorAnimPalettes_BattlePalaceLobby } ,
{ METATILE_Slateport_Door_BattleTent , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTent , sDoorAnimPalettes_BattleTent } ,
{ METATILE_Mauville_Door_BattleTent , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTent , sDoorAnimPalettes_BattleTent } ,
{ METATILE_Fallarbor_Door_BattleTent , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTent , sDoorAnimPalettes_BattleTent } ,
{ METATILE_BattleDome_Door_Corridor , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleDomeCorridor , sDoorAnimPalettes_BattleDomeCorridor } ,
{ METATILE_BattleFrontier_Door_MultiCorridor , DOOR_SOUND_SLIDING , 2 , sDoorAnimTiles_BattleTowerMultiCorridor , sDoorAnimPalettes_BattleTowerMultiCorridor } ,
{ METATILE_BattleFrontierOutsideWest_Door , DOOR_SOUND_NORMAL , 1 , sDoorAnimTiles_BattleFrontier , sDoorAnimPalettes_BattleFrontier } ,
{ METATILE_BattleFrontierOutsideWest_Door_Sliding , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleFrontierSliding , sDoorAnimPalettes_BattleFrontier } ,
{ METATILE_BattleDome_Door_PreBattleRoom , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleDomePreBattleRoom , sDoorAnimPalettes_BattleDomePreBattleRoom } ,
{ METATILE_BattleTent_Door , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_BattleTentInterior , sDoorAnimPalettes_BattleTentInterior } ,
{ METATILE_TrainerHill_Door_Elevator_Lobby , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_TrainerHillLobbyElevator , sDoorAnimPalettes_TrainerHillLobbyElevator } ,
{ METATILE_TrainerHill_Door_Elevator_Roof , DOOR_SOUND_SLIDING , 1 , sDoorAnimTiles_TrainerHillRoofElevator , sDoorAnimPalettes_TrainerHillRoofElevator } ,
{ } ,
2018-01-07 17:50:13 -06:00
} ;
2022-05-18 12:41:46 -04:00
// NOTE: The tiles of a door's animation must be copied to VRAM because they are not already part of any given tileset.
// This means that if there are any pre-existing tiles in this copied region that are visible when the door
// animation is played they will be overwritten.
2022-05-17 17:13:29 -04:00
# define DOOR_TILE_START_SIZE1 (NUM_TILES_TOTAL - 8)
# define DOOR_TILE_START_SIZE2 (NUM_TILES_TOTAL - 16)
2018-01-07 17:50:13 -06:00
static void CopyDoorTilesToVram ( const struct DoorGraphics * gfx , const struct DoorAnimFrame * frame )
{
if ( gfx - > size = = 2 )
2022-05-17 17:13:29 -04:00
CpuFastCopy ( gfx - > tiles + frame - > offset , ( void * ) ( VRAM + TILE_OFFSET_4BPP ( DOOR_TILE_START_SIZE2 ) ) , 16 * TILE_SIZE_4BPP ) ;
2018-01-07 17:50:13 -06:00
else
2022-05-17 17:13:29 -04:00
CpuFastCopy ( gfx - > tiles + frame - > offset , ( void * ) ( VRAM + TILE_OFFSET_4BPP ( DOOR_TILE_START_SIZE1 ) ) , 8 * TILE_SIZE_4BPP ) ;
2018-01-07 17:50:13 -06:00
}
2022-05-17 17:13:29 -04:00
static void BuildDoorTiles ( u16 * tiles , u16 tileNum , const u8 * paletteNums )
2018-01-07 17:50:13 -06:00
{
int i ;
2022-05-17 17:13:29 -04:00
u16 tile ;
2018-01-07 17:50:13 -06:00
2022-05-17 17:13:29 -04:00
// Only the first 4 tiles of each metatile (bottom layer) actually use the door tiles
2018-01-07 17:50:13 -06:00
for ( i = 0 ; i < 4 ; i + + )
{
2022-05-17 17:13:29 -04:00
tile = * ( paletteNums + + ) < < 12 ;
tiles [ i ] = tile | ( tileNum + i ) ;
2018-01-07 17:50:13 -06:00
}
2022-05-17 17:13:29 -04:00
// The remaining layers are left as tile 0 (with the same palette)
2018-01-07 17:50:13 -06:00
for ( ; i < 8 ; i + + )
{
2022-05-17 17:13:29 -04:00
tile = * ( paletteNums + + ) < < 12 ;
tiles [ i ] = tile ;
2018-01-07 17:50:13 -06:00
}
}
2022-05-17 17:13:29 -04:00
static void DrawCurrentDoorAnimFrame ( const struct DoorGraphics * gfx , u32 x , u32 y , const u8 * paletteNums )
2018-01-07 17:50:13 -06:00
{
2022-05-17 17:13:29 -04:00
u16 tiles [ 24 ] ;
2021-08-24 19:59:32 -03:00
2018-01-07 17:50:13 -06:00
if ( gfx - > size = = 2 )
{
2022-05-17 17:13:29 -04:00
// Top left metatile
BuildDoorTiles ( & tiles [ 8 ] , DOOR_TILE_START_SIZE2 + 0 , & paletteNums [ 0 ] ) ;
DrawDoorMetatileAt ( x , y - 1 , & tiles [ 8 ] ) ;
// Bottom left metatile
BuildDoorTiles ( & tiles [ 8 ] , DOOR_TILE_START_SIZE2 + 4 , & paletteNums [ 4 ] ) ;
DrawDoorMetatileAt ( x , y , & tiles [ 8 ] ) ;
// Top right metatile
BuildDoorTiles ( & tiles [ 8 ] , DOOR_TILE_START_SIZE2 + 8 , & paletteNums [ 0 ] ) ;
DrawDoorMetatileAt ( x + 1 , y - 1 , & tiles [ 8 ] ) ;
// Bottom right metatile
BuildDoorTiles ( & tiles [ 8 ] , DOOR_TILE_START_SIZE2 + 12 , & paletteNums [ 4 ] ) ;
DrawDoorMetatileAt ( x + 1 , y , & tiles [ 8 ] ) ;
2018-01-07 17:50:13 -06:00
}
else
{
2022-05-17 17:13:29 -04:00
// Top metatile
BuildDoorTiles ( & tiles [ 0 ] , DOOR_TILE_START_SIZE1 + 0 , & paletteNums [ 0 ] ) ;
DrawDoorMetatileAt ( x , y - 1 , & tiles [ 0 ] ) ;
// Bottom metatile
BuildDoorTiles ( & tiles [ 0 ] , DOOR_TILE_START_SIZE1 + 4 , & paletteNums [ 4 ] ) ;
DrawDoorMetatileAt ( x , y , & tiles [ 0 ] ) ;
2018-01-07 17:50:13 -06:00
}
}
static void DrawClosedDoorTiles ( const struct DoorGraphics * gfx , u32 x , u32 y )
{
CurrentMapDrawMetatileAt ( x , y - 1 ) ;
CurrentMapDrawMetatileAt ( x , y ) ;
if ( gfx - > size = = 2 )
{
CurrentMapDrawMetatileAt ( x + 1 , y - 1 ) ;
CurrentMapDrawMetatileAt ( x + 1 , y ) ;
}
}
static void DrawDoor ( const struct DoorGraphics * gfx , const struct DoorAnimFrame * frame , u32 x , u32 y )
{
if ( frame - > offset = = 0xFFFF )
{
DrawClosedDoorTiles ( gfx , x , y ) ;
2019-12-14 03:58:20 -05:00
if ( ShouldUseMultiCorridorDoor ( ) )
2021-10-09 12:12:18 -04:00
DrawClosedDoorTiles ( gfx , gSpecialVar_0x8004 + MAP_OFFSET , gSpecialVar_0x8005 + MAP_OFFSET ) ;
2018-01-07 17:50:13 -06:00
}
else
{
CopyDoorTilesToVram ( gfx , frame ) ;
2022-05-17 17:13:29 -04:00
DrawCurrentDoorAnimFrame ( gfx , x , y , gfx - > palettes ) ;
2019-12-14 03:58:20 -05:00
if ( ShouldUseMultiCorridorDoor ( ) )
2022-05-17 17:13:29 -04:00
DrawCurrentDoorAnimFrame ( gfx , gSpecialVar_0x8004 + MAP_OFFSET , gSpecialVar_0x8005 + MAP_OFFSET , gfx - > palettes ) ;
2018-01-07 17:50:13 -06:00
}
}
2021-03-21 01:22:42 -04:00
# define tFramesHi data[0]
# define tFramesLo data[1]
# define tGfxHi data[2]
# define tGfxLo data[3]
# define tFrameId data[4]
# define tCounter data[5]
# define tX data[6]
# define tY data[7]
2018-01-07 17:50:13 -06:00
2021-03-21 01:22:42 -04:00
// Draws a single frame of the door animation, or skips drawing to wait between frames.
// Returns FALSE when the final frame has been reached
static bool32 AnimateDoorFrame ( struct DoorGraphics * gfx , struct DoorAnimFrame * frames , s16 * data )
2018-01-07 17:50:13 -06:00
{
2021-03-21 01:22:42 -04:00
if ( tCounter = = 0 )
DrawDoor ( gfx , & frames [ tFrameId ] , tX , tY ) ;
if ( tCounter = = frames [ tFrameId ] . time )
2018-01-07 17:50:13 -06:00
{
2021-03-21 01:22:42 -04:00
tCounter = 0 ;
tFrameId + + ;
if ( frames [ tFrameId ] . time = = 0 )
2018-01-07 17:50:13 -06:00
return FALSE ;
else
return TRUE ;
}
2021-03-21 01:22:42 -04:00
tCounter + + ;
2018-01-07 17:50:13 -06:00
return TRUE ;
}
static void Task_AnimateDoor ( u8 taskId )
{
2021-03-21 01:22:42 -04:00
u16 * data = gTasks [ taskId ] . data ;
struct DoorAnimFrame * frames = ( struct DoorAnimFrame * ) ( tFramesHi < < 16 | tFramesLo ) ;
struct DoorGraphics * gfx = ( struct DoorGraphics * ) ( tGfxHi < < 16 | tGfxLo ) ;
2018-01-07 17:50:13 -06:00
2021-03-21 01:22:42 -04:00
if ( AnimateDoorFrame ( gfx , frames , data ) = = FALSE )
2018-01-07 17:50:13 -06:00
DestroyTask ( taskId ) ;
}
static const struct DoorAnimFrame * GetLastDoorFrame ( const struct DoorAnimFrame * frame , const void * unused )
{
while ( frame - > time ! = 0 )
frame + + ;
return frame - 1 ;
}
static const struct DoorGraphics * GetDoorGraphics ( const struct DoorGraphics * gfx , u16 metatileNum )
{
while ( gfx - > tiles ! = NULL )
{
if ( gfx - > metatileNum = = metatileNum )
return gfx ;
gfx + + ;
}
return NULL ;
}
static s8 StartDoorAnimationTask ( const struct DoorGraphics * gfx , const struct DoorAnimFrame * frames , u32 x , u32 y )
{
if ( FuncIsActiveTask ( Task_AnimateDoor ) = = TRUE )
return - 1 ;
else
{
u8 taskId = CreateTask ( Task_AnimateDoor , 0x50 ) ;
2021-03-21 01:22:42 -04:00
s16 * data = gTasks [ taskId ] . data ;
2018-01-07 17:50:13 -06:00
2021-03-21 01:22:42 -04:00
tX = x ;
tY = y ;
2018-01-07 17:50:13 -06:00
2021-03-21 01:22:42 -04:00
tFramesLo = ( u32 ) frames ;
tFramesHi = ( u32 ) frames > > 16 ;
2018-01-07 17:50:13 -06:00
2021-03-21 01:22:42 -04:00
tGfxLo = ( u32 ) gfx ;
tGfxHi = ( u32 ) gfx > > 16 ;
2018-01-07 17:50:13 -06:00
return taskId ;
}
}
static void DrawClosedDoor ( const struct DoorGraphics * gfx , u32 x , u32 y )
{
DrawClosedDoorTiles ( gfx , x , y ) ;
}
static void DrawOpenedDoor ( const struct DoorGraphics * gfx , u32 x , u32 y )
{
gfx = GetDoorGraphics ( gfx , MapGridGetMetatileIdAt ( x , y ) ) ;
if ( gfx ! = NULL )
2020-01-20 19:36:17 -05:00
DrawDoor ( gfx , GetLastDoorFrame ( sDoorOpenAnimFrames , sDoorOpenAnimFrames ) , x , y ) ;
2018-01-07 17:50:13 -06:00
}
static s8 StartDoorOpenAnimation ( const struct DoorGraphics * gfx , u32 x , u32 y )
{
gfx = GetDoorGraphics ( gfx , MapGridGetMetatileIdAt ( x , y ) ) ;
if ( gfx = = NULL )
{
return - 1 ;
}
else
{
if ( gfx - > size = = 2 )
2020-01-20 19:36:17 -05:00
return StartDoorAnimationTask ( gfx , sBigDoorOpenAnimFrames , x , y ) ;
2018-01-07 17:50:13 -06:00
else
2020-01-20 19:36:17 -05:00
return StartDoorAnimationTask ( gfx , sDoorOpenAnimFrames , x , y ) ;
2018-01-07 17:50:13 -06:00
}
}
static s8 StartDoorCloseAnimation ( const struct DoorGraphics * gfx , u32 x , u32 y )
{
gfx = GetDoorGraphics ( gfx , MapGridGetMetatileIdAt ( x , y ) ) ;
if ( gfx = = NULL )
return - 1 ;
else
2020-01-20 19:36:17 -05:00
return StartDoorAnimationTask ( gfx , sDoorCloseAnimFrames , x , y ) ;
2018-01-07 17:50:13 -06:00
}
2020-01-20 19:36:17 -05:00
static s8 GetDoorSoundType ( const struct DoorGraphics * gfx , u32 x , u32 y )
2018-01-07 17:50:13 -06:00
{
gfx = GetDoorGraphics ( gfx , MapGridGetMetatileIdAt ( x , y ) ) ;
if ( gfx = = NULL )
return - 1 ;
else
return gfx - > sound ;
}
2020-01-20 19:36:17 -05:00
// Unused. Debug? Same as FieldAnimateDoorOpen but doesnt return or check if metatile is actually a door
static void Debug_FieldAnimateDoorOpen ( u32 x , u32 y )
2018-01-07 17:50:13 -06:00
{
2020-01-20 19:36:17 -05:00
StartDoorOpenAnimation ( sDoorAnimGraphicsTable , x , y ) ;
2018-01-07 17:50:13 -06:00
}
void FieldSetDoorOpened ( u32 x , u32 y )
{
if ( MetatileBehavior_IsDoor ( MapGridGetMetatileBehaviorAt ( x , y ) ) )
2020-01-20 19:36:17 -05:00
DrawOpenedDoor ( sDoorAnimGraphicsTable , x , y ) ;
2018-01-07 17:50:13 -06:00
}
void FieldSetDoorClosed ( u32 x , u32 y )
{
if ( MetatileBehavior_IsDoor ( MapGridGetMetatileBehaviorAt ( x , y ) ) )
2020-01-20 19:36:17 -05:00
DrawClosedDoor ( sDoorAnimGraphicsTable , x , y ) ;
2018-01-07 17:50:13 -06:00
}
s8 FieldAnimateDoorClose ( u32 x , u32 y )
{
if ( ! MetatileBehavior_IsDoor ( MapGridGetMetatileBehaviorAt ( x , y ) ) )
return - 1 ;
else
2020-01-20 19:36:17 -05:00
return StartDoorCloseAnimation ( sDoorAnimGraphicsTable , x , y ) ;
2018-01-07 17:50:13 -06:00
}
s8 FieldAnimateDoorOpen ( u32 x , u32 y )
{
if ( ! MetatileBehavior_IsDoor ( MapGridGetMetatileBehaviorAt ( x , y ) ) )
return - 1 ;
else
2020-01-20 19:36:17 -05:00
return StartDoorOpenAnimation ( sDoorAnimGraphicsTable , x , y ) ;
2018-01-07 17:50:13 -06:00
}
bool8 FieldIsDoorAnimationRunning ( void )
{
return FuncIsActiveTask ( Task_AnimateDoor ) ;
}
u32 GetDoorSoundEffect ( u32 x , u32 y )
{
2020-01-20 19:36:17 -05:00
int sound = GetDoorSoundType ( sDoorAnimGraphicsTable , x , y ) ;
2021-08-24 19:59:32 -03:00
2020-01-20 19:36:17 -05:00
if ( sound = = DOOR_SOUND_NORMAL )
2018-01-07 17:50:13 -06:00
return SE_DOOR ;
2020-01-20 19:36:17 -05:00
else if ( sound = = DOOR_SOUND_SLIDING )
2020-08-20 18:02:00 -04:00
return SE_SLIDING_DOOR ;
2020-01-20 19:36:17 -05:00
else if ( sound = = DOOR_SOUND_ARENA )
2020-08-20 18:02:00 -04:00
return SE_REPEL ;
2018-01-07 17:50:13 -06:00
else
return SE_DOOR ;
}
2019-12-14 03:58:20 -05:00
// Opens the Battle Tower multi partner's door in sync with the player's door
static bool8 ShouldUseMultiCorridorDoor ( void )
2018-01-07 17:50:13 -06:00
{
2019-12-14 03:58:20 -05:00
if ( FlagGet ( FLAG_ENABLE_MULTI_CORRIDOR_DOOR ) )
2018-01-07 17:50:13 -06:00
{
2021-08-24 19:59:32 -03:00
if ( gSaveBlock1Ptr - > location . mapGroup = = MAP_GROUP ( BATTLE_FRONTIER_BATTLE_TOWER_MULTI_CORRIDOR )
2019-12-14 03:58:20 -05:00
& & gSaveBlock1Ptr - > location . mapNum = = MAP_NUM ( BATTLE_FRONTIER_BATTLE_TOWER_MULTI_CORRIDOR ) )
2018-01-07 17:50:13 -06:00
{
return TRUE ;
}
}
return FALSE ;
}