From ad1bf8218655d37869f94e10176c3c6e1ffe4fe9 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 27 Mar 2025 14:24:06 +0100 Subject: [PATCH] remove tile_types.c --- include/dungeon_map_access.h | 11 ++ include/tile_types.h | 17 --- ld_script.txt | 3 +- src/code_800F034.c | 10 +- src/code_8040094_1.c | 2 +- src/code_8042B34.c | 1 - src/code_80450F8.c | 1 - src/code_8069E0C.c | 1 - src/code_806CD90.c | 1 - src/code_8075708.c | 1 - src/code_807CD9C.c | 1 - src/code_8097F40.c | 3 +- src/dungeon_ai.c | 1 - src/dungeon_ai_targeting.c | 1 - src/dungeon_generation.c | 1 - src/dungeon_main.c | 1 - src/dungeon_map_access.c | 242 +++++++++++++++++++++++++++++++++- src/dungeon_menu_items.c | 1 - src/dungeon_menu_moves.c | 1 - src/dungeon_menu_team.c | 1 - src/dungeon_misc.c | 1 - src/move_actions.c | 1 - src/move_checks.c | 1 - src/move_effects_target.c | 1 - src/status_actions.c | 1 - src/tile_types.c | 246 ----------------------------------- 26 files changed, 258 insertions(+), 294 deletions(-) delete mode 100644 include/tile_types.h delete mode 100644 src/tile_types.c diff --git a/include/dungeon_map_access.h b/include/dungeon_map_access.h index 36fc0440e..7a5cdf39f 100644 --- a/include/dungeon_map_access.h +++ b/include/dungeon_map_access.h @@ -24,4 +24,15 @@ void sub_804AA60(void); void sub_804AAAC(void); void sub_804AAD4(void); +#define DUNGEON_WATER_TYPE_NONE 0 +#define DUNGEON_WATER_TYPE_LAVA 1 +#define DUNGEON_WATER_TYPE_WATER 2 + +extern const u8 gDungeonWaterType[76]; + +bool8 sub_804AD34(DungeonPos *pos); +void sub_804AE84(DungeonPos *pos); +bool8 IsTileGround(Tile *tile); +bool8 IsWaterTileset(void); + #endif // GUARD_DUNGEON_MAP_ACCESS_H diff --git a/include/tile_types.h b/include/tile_types.h deleted file mode 100644 index fda2acf81..000000000 --- a/include/tile_types.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GUARD_TILE_TYPES_H -#define GUARD_TILE_TYPES_H - -#include "structs/map.h" - -#define DUNGEON_WATER_TYPE_NONE 0 -#define DUNGEON_WATER_TYPE_LAVA 1 -#define DUNGEON_WATER_TYPE_WATER 2 - -extern const u8 gDungeonWaterType[76]; - -bool8 sub_804AD34(DungeonPos *pos); -void sub_804AE84(DungeonPos *pos); -bool8 IsTileGround(Tile *tile); -bool8 IsWaterTileset(); - -#endif // GUARD_TILE_TYPES_H diff --git a/ld_script.txt b/ld_script.txt index aad75d9ce..a2f8a0473 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -218,7 +218,6 @@ SECTIONS { src/code_8048480.o(.text); src/dungeon_ai_item_weight.o(.text); src/dungeon_map_access.o(.text); - src/tile_types.o(.text); src/dungeon_generation.o(.text); src/dungeon_message.o(.text); src/dungeon_move.o(.text); @@ -583,7 +582,7 @@ SECTIONS { src/code_8048480.o(.rodata); src/friend_area.o(.rodata); data/data_810AC60.o(.rodata); - src/tile_types.o(.rodata); + src/dungeon_map_access.o(.rodata); src/exclusive_pokemon.o(.rodata); src/rescue_team_info.o(.rodata); src/strings.o(.rodata); diff --git a/src/code_800F034.c b/src/code_800F034.c index 559fa596f..61c6b3761 100644 --- a/src/code_800F034.c +++ b/src/code_800F034.c @@ -18,10 +18,8 @@ struct unkStruct_203B0D4 extern struct unkStruct_203B0D4 *gUnknown_203B0D4; -ALIGNED(4) static const u8 gUnknown_80CE77C[] = "efob%03d"; -ALIGNED(4) static const u8 gUnknown_80CE788[] = "efbg%03d"; - -void sub_800F034(void) { +void sub_800F034(void) +{ s32 index; if(gUnknown_203B0D4 == NULL) { @@ -121,10 +119,10 @@ OpenedFile * sub_800F1C0(u32 animType, s32 effectID) case 1: case 2: case 3: - sprintf(fileName,gUnknown_80CE77C,effectID); // efob + sprintf(fileName,"efob%03d",effectID); break; case 4: - sprintf(fileName,gUnknown_80CE788,effectID); // efbg + sprintf(fileName,"efbg%03d",effectID); break; } diff --git a/src/code_8040094_1.c b/src/code_8040094_1.c index 0b5f33dc7..ee8017efd 100644 --- a/src/code_8040094_1.c +++ b/src/code_8040094_1.c @@ -18,8 +18,8 @@ #include "dungeon_random.h" #include "dungeon_util.h" #include "sprite.h" -#include "tile_types.h" #include "weather.h" +#include "dungeon_map_access.h" struct UnkStruct_8040094 { diff --git a/src/code_8042B34.c b/src/code_8042B34.c index 561a67977..f0b9cbbfc 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -47,7 +47,6 @@ #include "sprite.h" #include "text_1.h" #include "text_3.h" -#include "tile_types.h" #include "weather.h" extern void sub_800F15C(s32); diff --git a/src/code_80450F8.c b/src/code_80450F8.c index 6428ade4a..69430dc86 100644 --- a/src/code_80450F8.c +++ b/src/code_80450F8.c @@ -5,7 +5,6 @@ #include "dungeon_map_access.h" #include "dungeon_range.h" #include "dungeon_util.h" -#include "tile_types.h" #include "pokemon.h" #include "code_805D8C8.h" diff --git a/src/code_8069E0C.c b/src/code_8069E0C.c index 41866d6d0..fde3417df 100644 --- a/src/code_8069E0C.c +++ b/src/code_8069E0C.c @@ -39,7 +39,6 @@ #include "random.h" #include "sprite.h" #include "status_checks_1.h" -#include "tile_types.h" #include "weather.h" extern void sub_8042900(Entity *r0); diff --git a/src/code_806CD90.c b/src/code_806CD90.c index 4a47fb793..d7e481b8e 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -33,7 +33,6 @@ #include "sprite.h" #include "status.h" #include "text_util.h" -#include "tile_types.h" extern u8 gUnknown_202F221; diff --git a/src/code_8075708.c b/src/code_8075708.c index c3371fb58..d49284c8b 100644 --- a/src/code_8075708.c +++ b/src/code_8075708.c @@ -13,7 +13,6 @@ #include "dungeon_util.h" #include "dungeon_visibility.h" #include "structs/str_dungeon.h" -#include "tile_types.h" #include "position_util.h" #include "trap.h" diff --git a/src/code_807CD9C.c b/src/code_807CD9C.c index 85ef2cc49..6222534a8 100644 --- a/src/code_807CD9C.c +++ b/src/code_807CD9C.c @@ -21,7 +21,6 @@ #include "moves.h" #include "move_util.h" #include "code_8041AD0.h" -#include "tile_types.h" #include "code_803E668.h" #include "weather.h" #include "dungeon_config.h" diff --git a/src/code_8097F40.c b/src/code_8097F40.c index 8951a0b99..320ab3314 100644 --- a/src/code_8097F40.c +++ b/src/code_8097F40.c @@ -1,6 +1,5 @@ #include "global.h" - -#include "tile_types.h" +#include "dungeon_map_access.h" bool8 IsWaterDungeon(u32 r0) { diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index fd2847195..69b3f8696 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -34,7 +34,6 @@ #include "structs/map.h" #include "structs/str_dungeon.h" #include "dungeon_misc.h" -#include "tile_types.h" extern char *gPtrCouldntBeUsedMessage; extern char *gPtrItsaMonsterHouseMessage; diff --git a/src/dungeon_ai_targeting.c b/src/dungeon_ai_targeting.c index ab8563072..ed1aa34f9 100644 --- a/src/dungeon_ai_targeting.c +++ b/src/dungeon_ai_targeting.c @@ -18,7 +18,6 @@ #include "dungeon_random.h" #include "dungeon_util.h" #include "structs/map.h" -#include "tile_types.h" extern void ShowVisualFlags(Entity *r0); diff --git a/src/dungeon_generation.c b/src/dungeon_generation.c index a382f6dca..d4dccfd32 100644 --- a/src/dungeon_generation.c +++ b/src/dungeon_generation.c @@ -2,7 +2,6 @@ #include "def_filearchives.h" #include "dungeon_generation.h" #include "file_system.h" -#include "tile_types.h" #include "dungeon_map_access.h" #include "dungeon_message.h" #include "dungeon_random.h" diff --git a/src/dungeon_main.c b/src/dungeon_main.c index ee40d17df..287b99ee2 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -56,7 +56,6 @@ #include "sprite.h" #include "status_checks_1.h" #include "string_format.h" -#include "tile_types.h" #include "trap.h" #include "weather.h" diff --git a/src/dungeon_map_access.c b/src/dungeon_map_access.c index ad16366b5..5fe862946 100644 --- a/src/dungeon_map_access.c +++ b/src/dungeon_map_access.c @@ -1,4 +1,5 @@ #include "global.h" +#include "dungeon_map_access.h" #include "constants/walkable_tile.h" #include "structs/str_dungeon.h" #include "code_8042B34.h" @@ -9,14 +10,13 @@ #include "dungeon_engine.h" #include "dungeon_leader.h" #include "dungeon_map.h" -#include "dungeon_map_access.h" #include "dungeon_movement.h" #include "dungeon_util.h" #include "dungeon_visibility.h" #include "game_options.h" #include "random.h" #include "text_1.h" -#include "tile_types.h" +#include "code_806CD90.h" extern const Tile gOtherOobTile; extern const Tile gWaterOobTile; @@ -30,6 +30,8 @@ extern u8 gUnknown_8108EC0[]; extern const s16 gUnknown_80F6A4A[]; extern const s16 gUnknown_80F6C06[]; +extern void sub_8042A14(DungeonPos *); + EWRAM_DATA OpenedFile *gDungeonPaletteFile = {0}; EWRAM_DATA unkStruct_202EE8C gUnknown_202EE8C[32] = {0}; EWRAM_DATA OpenedFile *gUnknown_202F18C = {0}; @@ -37,6 +39,85 @@ EWRAM_DATA Tile gOutOfBoundsTileData = {0}; EWRAM_INIT const Tile *gCurTilesetOobTile = {NULL}; +const u8 gDungeonWaterType[76] = { + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_WATER, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_WATER, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_LAVA, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_LAVA, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_LAVA, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_LAVA, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, + DUNGEON_WATER_TYPE_NONE, +}; + const Tile *GetTile(s32 x, s32 y) { if (x >= 0 && y >= 0 && x < DUNGEON_MAX_SIZE_X && y < DUNGEON_MAX_SIZE_Y) @@ -1025,3 +1106,160 @@ void sub_804AC20(DungeonPos *pos) } } } + +bool8 PosHasItem(DungeonPos *pos) +{ + const Tile *tile; + Entity *entity; + + tile = GetTile(pos->x,pos->y); + entity = tile->object; + if ((entity != NULL) && (GetEntityType(entity) == ENTITY_ITEM)) { + return TRUE; + } + return FALSE; +} + +Entity *GetMonsterAtPos(DungeonPos *pos) +{ + const Tile *tile; + Entity *entity; + + tile = GetTile(pos->x,pos->y); + entity = tile->monster; + if ((entity != NULL) && (entity->type == ENTITY_MONSTER)) { + return entity; + } + return NULL; +} + +bool8 sub_804AD34(DungeonPos *pos) +{ + Tile *tile; + s32 x; + Entity * entity; + s32 y; + bool8 iVar8; + s32 index; + + iVar8 = 0; + tile = GetTileMut(pos->x,pos->y); + if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) + if(!(tile->terrainType & (TERRAIN_TYPE_UNBREAKABLE | TERRAIN_TYPE_IMPASSABLE_WALL))){ + iVar8 = 1; + tile->terrainType = (tile->terrainType & ~(TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL)) | TERRAIN_TYPE_NORMAL; + + for(y = -1; y < 2; y++) + { + for(x = -1; x < 2; x++) + { + sub_80498A8(x + pos->x, y + pos->y); + sub_8049BB0(x + pos->x, y + pos->y); + ShowDungeonMapAtPos(x + pos->x, y + pos->y); + } + } + } + if (iVar8 != 0) { + for(index = 0; index < DUNGEON_MAX_POKEMON; index++) + { + entity = gDungeon->activePokemon[index]; + if (EntityIsValid(entity)) { + sub_806CF98(entity); + } + } + sub_8049ED4(); + sub_8042A14(pos); + } + return iVar8; +} + +bool8 sub_804AE08(DungeonPos *pos) +{ + Tile *tile; + s32 x; + s32 y; + bool8 uVar6; + + uVar6 = FALSE; + tile = GetTileMut(pos->x,pos->y); + + if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) + if(!(tile->terrainType & (TERRAIN_TYPE_UNBREAKABLE | TERRAIN_TYPE_IMPASSABLE_WALL))) { + uVar6 = TRUE; + tile->terrainType = (tile->terrainType & ~(TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL)) | TERRAIN_TYPE_NORMAL; + tile->spawnOrVisibilityFlags = tile->spawnOrVisibilityFlags | 0x10; + + for(y = -1; y < 2; y++) + { + for(x = -1; x < 2; x++) + { + sub_8049BB0(x + pos->x, y + pos->y); + } + } + } + return uVar6; +} + +void sub_804AE84(DungeonPos *pos) +{ + Tile *tile; + s32 x; + Entity * entity; + s32 index; + s32 y; + + tile = GetTileMut(pos->x,pos->y); + if ((tile->spawnOrVisibilityFlags & 0x10) != 0) { + tile->spawnOrVisibilityFlags &= 0xffef; + + for(y = -1; y < 2; y++) + { + for(x = -1; x < 2; x++) + { + sub_80498A8(x + pos->x, y + pos->y); + ShowDungeonMapAtPos(x + pos->x, y + pos->y); + } + } + + for(index = 0; index < DUNGEON_MAX_POKEMON; index++) + { + entity = gDungeon->activePokemon[index]; + if (EntityIsValid(entity)) { + sub_806CF98(entity); + } + } + sub_8049ED4(); + sub_8042A14(pos); + } +} + +bool8 IsTileGround(Tile *tile) +{ + bool8 isGround = FALSE; + if (IsWaterTileset()) + { + if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) + { + isGround = TRUE; + } + } + else if ((tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) != TERRAIN_TYPE_SECONDARY || + gDungeonWaterType[gDungeon->tileset] == DUNGEON_WATER_TYPE_LAVA) + { + isGround = TRUE; + } + return isGround; +} + +bool8 IsWaterTileset(void) +{ + if (gDungeon->tileset == 0 || + gDungeon->tileset == 0x31 || + gDungeon->tileset == 0x20 || + gDungeon->tileset == 0x21 || + gDungeon->tileset == 0x36) + { + return TRUE; + } + return FALSE; +} diff --git a/src/dungeon_menu_items.c b/src/dungeon_menu_items.c index 24dcc021b..b94088058 100644 --- a/src/dungeon_menu_items.c +++ b/src/dungeon_menu_items.c @@ -24,7 +24,6 @@ #include "status_checks_1.h" #include "dungeon_items.h" #include "dungeon_leader.h" -#include "tile_types.h" #include "menu_input.h" #include "text_1.h" #include "code_8044CC8.h" diff --git a/src/dungeon_menu_moves.c b/src/dungeon_menu_moves.c index 1124678d1..49cb43936 100644 --- a/src/dungeon_menu_moves.c +++ b/src/dungeon_menu_moves.c @@ -29,7 +29,6 @@ #include "text_1.h" #include "text_2.h" #include "text_3.h" -#include "tile_types.h" extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index a0edd4650..c1498b963 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -45,7 +45,6 @@ #include "status_checks_1.h" #include "string_format.h" #include "text_2.h" -#include "tile_types.h" #include "weather.h" extern bool8 sub_8048A68(Entity *param_1,Item *item); diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index 29bfba921..921f66bf8 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -38,7 +38,6 @@ #include "dungeon_config.h" #include "game_options.h" #include "weather.h" -#include "tile_types.h" #include "dungeon_capabilities.h" #include "text_util.h" #include "dungeon_random.h" diff --git a/src/move_actions.c b/src/move_actions.c index c1e561fba..cd37e3416 100644 --- a/src/move_actions.c +++ b/src/move_actions.c @@ -30,7 +30,6 @@ #include "structs/dungeon_entity.h" #include "structs/map.h" #include "structs/str_dungeon.h" -#include "tile_types.h" #include "weather.h" #include "dungeon_config.h" #include "dungeon_misc.h" diff --git a/src/move_checks.c b/src/move_checks.c index e6e846c64..539972c35 100644 --- a/src/move_checks.c +++ b/src/move_checks.c @@ -17,7 +17,6 @@ #include "status_actions.h" #include "status_checks_1.h" #include "text_util.h" -#include "tile_types.h" #include "trap.h" #include "weather.h" #include "dungeon_config.h" diff --git a/src/move_effects_target.c b/src/move_effects_target.c index f2efd6080..0cc18e0d2 100644 --- a/src/move_effects_target.c +++ b/src/move_effects_target.c @@ -33,7 +33,6 @@ #include "structs/map.h" #include "structs/str_dungeon.h" #include "dungeon_misc.h" -#include "tile_types.h" #include "dungeon_config.h" extern u8 *gUnknown_80FB380[]; diff --git a/src/status_actions.c b/src/status_actions.c index d702569e7..f81308616 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -31,7 +31,6 @@ #include "structs/map.h" #include "structs/str_dungeon.h" #include "text_util.h" -#include "tile_types.h" #include "trap.h" #include "weather.h" #include "dungeon_config.h" diff --git a/src/tile_types.c b/src/tile_types.c deleted file mode 100644 index de3da2c1c..000000000 --- a/src/tile_types.c +++ /dev/null @@ -1,246 +0,0 @@ -#include "global.h" -#include "tile_types.h" -#include "code_806CD90.h" -#include "structs/str_dungeon.h" -#include "dungeon_map.h" -#include "dungeon_map_access.h" -#include "dungeon_util.h" - -const u8 gDungeonWaterType[76] = { - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_WATER, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_WATER, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_LAVA, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_LAVA, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_LAVA, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_LAVA, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, - DUNGEON_WATER_TYPE_NONE, -}; - -extern void sub_8049BB0(s32, s32); -void sub_8042A14(DungeonPos *); - -bool8 PosHasItem(DungeonPos *pos) -{ - const Tile *tile; - Entity *entity; - - tile = GetTile(pos->x,pos->y); - entity = tile->object; - if ((entity != NULL) && (GetEntityType(entity) == ENTITY_ITEM)) { - return TRUE; - } - return FALSE; -} - -Entity *GetMonsterAtPos(DungeonPos *pos) -{ - const Tile *tile; - Entity *entity; - - tile = GetTile(pos->x,pos->y); - entity = tile->monster; - if ((entity != NULL) && (entity->type == ENTITY_MONSTER)) { - return entity; - } - return NULL; -} - -bool8 sub_804AD34(DungeonPos *pos) -{ - Tile *tile; - s32 x; - Entity * entity; - s32 y; - bool8 iVar8; - s32 index; - - iVar8 = 0; - tile = GetTileMut(pos->x,pos->y); - if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) - if(!(tile->terrainType & (TERRAIN_TYPE_UNBREAKABLE | TERRAIN_TYPE_IMPASSABLE_WALL))){ - iVar8 = 1; - tile->terrainType = (tile->terrainType & ~(TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL)) | TERRAIN_TYPE_NORMAL; - - for(y = -1; y < 2; y++) - { - for(x = -1; x < 2; x++) - { - sub_80498A8(x + pos->x, y + pos->y); - sub_8049BB0(x + pos->x, y + pos->y); - ShowDungeonMapAtPos(x + pos->x, y + pos->y); - } - } - } - if (iVar8 != 0) { - for(index = 0; index < DUNGEON_MAX_POKEMON; index++) - { - entity = gDungeon->activePokemon[index]; - if (EntityIsValid(entity)) { - sub_806CF98(entity); - } - } - sub_8049ED4(); - sub_8042A14(pos); - } - return iVar8; -} - -bool8 sub_804AE08(DungeonPos *pos) -{ - Tile *tile; - s32 x; - s32 y; - bool8 uVar6; - - uVar6 = FALSE; - tile = GetTileMut(pos->x,pos->y); - - if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) - if(!(tile->terrainType & (TERRAIN_TYPE_UNBREAKABLE | TERRAIN_TYPE_IMPASSABLE_WALL))) { - uVar6 = TRUE; - tile->terrainType = (tile->terrainType & ~(TERRAIN_TYPE_SECONDARY | TERRAIN_TYPE_NORMAL)) | TERRAIN_TYPE_NORMAL; - tile->spawnOrVisibilityFlags = tile->spawnOrVisibilityFlags | 0x10; - - for(y = -1; y < 2; y++) - { - for(x = -1; x < 2; x++) - { - sub_8049BB0(x + pos->x, y + pos->y); - } - } - } - return uVar6; -} - -void sub_804AE84(DungeonPos *pos) -{ - Tile *tile; - s32 x; - Entity * entity; - s32 index; - s32 y; - - tile = GetTileMut(pos->x,pos->y); - if ((tile->spawnOrVisibilityFlags & 0x10) != 0) { - tile->spawnOrVisibilityFlags &= 0xffef; - - for(y = -1; y < 2; y++) - { - for(x = -1; x < 2; x++) - { - sub_80498A8(x + pos->x, y + pos->y); - ShowDungeonMapAtPos(x + pos->x, y + pos->y); - } - } - - for(index = 0; index < DUNGEON_MAX_POKEMON; index++) - { - entity = gDungeon->activePokemon[index]; - if (EntityIsValid(entity)) { - sub_806CF98(entity); - } - } - sub_8049ED4(); - sub_8042A14(pos); - } -} - -bool8 IsTileGround(Tile *tile) -{ - bool8 isGround = FALSE; - if (IsWaterTileset()) - { - if (!(tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) - { - isGround = TRUE; - } - } - else if ((tile->terrainType & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) != TERRAIN_TYPE_SECONDARY || - gDungeonWaterType[gDungeon->tileset] == DUNGEON_WATER_TYPE_LAVA) - { - isGround = TRUE; - } - return isGround; -} - -bool8 IsWaterTileset() -{ - if (gDungeon->tileset == 0 || - gDungeon->tileset == 0x31 || - gDungeon->tileset == 0x20 || - gDungeon->tileset == 0x21 || - gDungeon->tileset == 0x36) - { - return TRUE; - } - return FALSE; -}