summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/code_8040094.c5
-rw-r--r--src/code_80521D0_1.c6
-rw-r--r--src/code_8057824_1.c2
-rw-r--r--src/dungeon_ai_attack.c6
-rw-r--r--src/dungeon_ai_attack_1.c2
-rw-r--r--src/dungeon_ai_item_weight.c2
-rw-r--r--src/dungeon_ai_items.c2
-rw-r--r--src/dungeon_ai_movement.c4
-rw-r--r--src/dungeon_capabilities_1.c4
-rw-r--r--src/dungeon_map_access.c20
-rw-r--r--src/dungeon_range.c2
-rw-r--r--src/dungeon_util.c10
-rw-r--r--src/status_checker.c6
13 files changed, 40 insertions, 31 deletions
diff --git a/src/code_8040094.c b/src/code_8040094.c
index c0e7eac..f7374e3 100644
--- a/src/code_8040094.c
+++ b/src/code_8040094.c
@@ -3,6 +3,7 @@
#include "code_80521D0.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
+#include "dungeon_map_access.h"
#include "file_system.h"
#include "play_time.h"
@@ -26,8 +27,6 @@ extern void sub_8040A84();
extern const char *gUnknown_80FD040; // It became brighter on the floor
-extern struct MapTile *GetMapEntity(u32, u32);
-
// Luminous Orb???
void HandleLuminousOrbAction(struct DungeonEntity *param_1)
{
@@ -41,7 +40,7 @@ void HandleLuminousOrbAction(struct DungeonEntity *param_1)
{
for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++)
{
- mapTile = GetMapEntity(XCoord, YCoord);
+ mapTile = GetMapTile_2(XCoord, YCoord);
mapTile->unk4 = mapTile->unk4 | 1;
}
}
diff --git a/src/code_80521D0_1.c b/src/code_80521D0_1.c
index 2b23a14..53f5586 100644
--- a/src/code_80521D0_1.c
+++ b/src/code_80521D0_1.c
@@ -3,6 +3,7 @@
#include "constants/friend_area.h"
#include "dungeon_global_data.h"
#include "dungeon_entity.h"
+#include "dungeon_map_access.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "friend_area.h"
@@ -138,7 +139,6 @@ extern void sub_8049ED4();
extern void sub_8040A84();
extern void sub_8086A54(struct DungeonEntity *);
-extern struct MapTile *GetMapEntity(u32, u32);
extern void sub_806BFC0(struct DungeonEntityData *, u32);
void sub_808BBA8(struct DungeonEntity *param_1)
@@ -207,7 +207,7 @@ void sub_808BCE4(void)
{
struct MapTile *puVar1;
- puVar1 = GetMapEntity(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
+ puVar1 = GetMapTile_2(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1->tileType &= ~(TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
puVar1->tileType |= TILE_TYPE_MAP_EDGE;
puVar1->tileType &= ~TILE_TYPE_STAIRS;
@@ -221,7 +221,7 @@ void sub_808BD38(void)
{
struct MapTile *puVar1;
- puVar1 = GetMapEntity(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
+ puVar1 = GetMapTile_2(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
puVar1->tileType &= ~(TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
puVar1->tileType |= TILE_TYPE_FLOOR;
puVar1->tileType &= ~TILE_TYPE_MAP_EDGE;
diff --git a/src/code_8057824_1.c b/src/code_8057824_1.c
index f3a7db2..0d48f71 100644
--- a/src/code_8057824_1.c
+++ b/src/code_8057824_1.c
@@ -3318,7 +3318,7 @@ void sub_808B1CC(u8 r0)
"\tldrsh r0, [r0, r2]\n"
"\tmovs r3, 0x2\n"
"\tldrsh r1, [r5, r3]\n"
- "\tbl GetMapEntity\n"
+ "\tbl GetMapTile_2\n"
"\tldrh r2, [r0]\n"
"\tmovs r3, 0x80\n"
"\tlsls r3, 2\n"
diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c
index a275081..092bab5 100644
--- a/src/dungeon_ai_attack.c
+++ b/src/dungeon_ai_attack.c
@@ -377,7 +377,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
// Double assignment to fix a regswap.
s16 rangeTargetingFlags = rangeTargetingFlags2 = targetingFlags & 0xF0;
- struct MapTile *adjacentTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
+ struct MapTile *adjacentTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
pokemon->posWorld.y + gAdjacentTileOffsets[i].y);
struct DungeonEntity *adjacentPokemon = adjacentTile->pokemon;
if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) == ENTITY_POKEMON)
@@ -411,7 +411,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
{
for (i = 0; i < NUM_DIRECTIONS; i++)
{
- struct MapTile *targetTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
+ struct MapTile *targetTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[i].x,
pokemon->posWorld.y + gAdjacentTileOffsets[i].y);
if (CanAttackInFront(pokemon, i))
{
@@ -425,7 +425,7 @@ s32 FindMoveTarget(struct MoveTargetResults *moveTargetResults, struct DungeonEn
continue;
}
}
- targetTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[i].x * 2,
+ targetTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[i].x * 2,
pokemon->posWorld.y + gAdjacentTileOffsets[i].y * 2);
targetPokemon = targetTile->pokemon;
if (targetPokemon != NULL && GetEntityType(targetPokemon) == ENTITY_POKEMON)
diff --git a/src/dungeon_ai_attack_1.c b/src/dungeon_ai_attack_1.c
index 8a186ea..641bc8c 100644
--- a/src/dungeon_ai_attack_1.c
+++ b/src/dungeon_ai_attack_1.c
@@ -57,7 +57,7 @@ bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity
break;
}
while (0); // Extra label needed to swap branch locations in ASM.
- mapTile = GetMapTileAtPosition(currentPosX, currentPosY);
+ mapTile = GetMapTile_1(currentPosX, currentPosY);
if (!(mapTile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
{
break;
diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c
index 5006970..08652b2 100644
--- a/src/dungeon_ai_item_weight.c
+++ b/src/dungeon_ai_item_weight.c
@@ -448,7 +448,7 @@ bool8 CanTargetAdjacentPokemon(struct DungeonEntity *pokemon)
s32 facingDir;
for (facingDir = 0; facingDir < NUM_DIRECTIONS; facingDir++)
{
- struct MapTile *mapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x, pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
+ struct MapTile *mapTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x, pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
struct DungeonEntity *adjacentPokemon = mapTile->pokemon;
if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) != ENTITY_NONE &&
CanTarget(pokemon, adjacentPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c
index 183d143..52aacc4 100644
--- a/src/dungeon_ai_items.c
+++ b/src/dungeon_ai_items.c
@@ -158,7 +158,7 @@ void DecideUseItem(struct DungeonEntity *pokemon)
else if (toolboxIndex == 0)
{
// This seems unused. toolboxIndex can never be 0.
- struct MapTile *mapTile = GetMapTileAtPosition(pokemon->posWorld.x, pokemon->posWorld.y);
+ struct MapTile *mapTile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
struct DungeonEntity *mapObject = mapTile->mapObject;
if (mapObject != null)
{
diff --git a/src/dungeon_ai_movement.c b/src/dungeon_ai_movement.c
index 5fa6d87..49609d7 100644
--- a/src/dungeon_ai_movement.c
+++ b/src/dungeon_ai_movement.c
@@ -49,7 +49,7 @@ u32 sub_8075818(struct DungeonEntity *entity)
entityData = entity->entityData;
if(EntityExists(entity))
{
- tile = GetMapEntityForDungeonEntity(entity);
+ tile = GetMapTileForDungeonEntity_2(entity);
if(HasIQSkill(entity, IQ_SKILL_SUPER_MOBILE))
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)))
return 1;
@@ -136,7 +136,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
{
if(!gDungeonGlobalData->monsterHouseActive)
{
- if((GetMapEntityForDungeonEntity(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
+ if((GetMapTileForDungeonEntity_2(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
{
// It's a monster house!
SendMessage(GetLeaderEntity(), gPtrItsaMonsterHouseMessage);
diff --git a/src/dungeon_capabilities_1.c b/src/dungeon_capabilities_1.c
index e6ec6fa..605f9e9 100644
--- a/src/dungeon_capabilities_1.c
+++ b/src/dungeon_capabilities_1.c
@@ -89,7 +89,7 @@ bool8 CannotAttack(struct DungeonEntity *pokemon, bool8 skipSleep)
bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir)
{
u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);
- struct MapTile *currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
+ struct MapTile *currentMapTile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[facingDir].x,
pokemon->posWorld.y + gAdjacentTileOffsets[facingDir].y);
if (currentMapTile->tileType & TILE_TYPE_MAP_EDGE || currentMapTile->pokemon != NULL)
{
@@ -118,7 +118,7 @@ bool8 CanMoveInDirection(struct DungeonEntity *pokemon, u32 facingDir)
}
}
}
- currentMapTile = GetMapTileAtPosition(pokemon->posWorld.x, pokemon->posWorld.y);
+ currentMapTile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
if (!(currentMapTile->canMoveAdjacent[crossableTerrain] & gDirectionBitMasks[facingDir & DIRECTION_MASK]))
{
return FALSE;
diff --git a/src/dungeon_map_access.c b/src/dungeon_map_access.c
index 43e0e4d..9ffa633 100644
--- a/src/dungeon_map_access.c
+++ b/src/dungeon_map_access.c
@@ -3,13 +3,25 @@
#include "dungeon_global_data.h"
-extern struct MapTile *gUnknown_203B430;
+extern struct unkStruct_202F190 gUnknown_202F190;
+extern struct unkStruct_202F190 *gUnknown_203B430;
-struct MapTile* GetMapTileAtPosition(s32 x, s32 y)
+struct MapTile* GetMapTile_1(s32 x, s32 y)
{
if (x >= 0 && y >= 0 && x < DUNGEON_MAX_SIZE_X && y < DUNGEON_MAX_SIZE_Y)
{
- return gDungeonGlobalData->mapEntityPointers[y][x];
+ return gDungeonGlobalData->mapTilePointers[y][x];
}
- return gUnknown_203B430;
+ return (struct MapTile*) gUnknown_203B430->unk0;
+}
+
+struct MapTile* GetMapTile_2(s32 x, s32 y)
+{
+ if (x < 0 || y < 0 || x >= DUNGEON_MAX_SIZE_X || y >= DUNGEON_MAX_SIZE_Y)
+ {
+ struct MapTile* tile = (struct MapTile*) gUnknown_202F190.unk0;
+ gUnknown_202F190 = *gUnknown_203B430;
+ return tile;
+ }
+ return gDungeonGlobalData->mapTilePointers[y][x];
}
diff --git a/src/dungeon_range.c b/src/dungeon_range.c
index facd71d..00b827d 100644
--- a/src/dungeon_range.c
+++ b/src/dungeon_range.c
@@ -14,7 +14,7 @@ bool8 InSameRoom_2(struct Position *pos1, struct Position *pos2)
{
visibility = 2;
}
- tile1 = GetMapTileAtPosition(pos1->x, pos1->y);
+ tile1 = GetMapTile_1(pos1->x, pos1->y);
pos1RoomIndex = tile1->roomIndex;
if (pos1RoomIndex == CORRIDOR_ROOM_INDEX)
{
diff --git a/src/dungeon_util.c b/src/dungeon_util.c
index c5b5695..1d443c0 100644
--- a/src/dungeon_util.c
+++ b/src/dungeon_util.c
@@ -14,8 +14,6 @@ const struct Position gAdjacentTileOffsets[] = {
{-1, 1}
};
-extern struct MapTile* GetMapEntity(s16, s16);
-
bool8 EntityExists(struct DungeonEntity *entity)
{
if (!entity)
@@ -55,12 +53,12 @@ struct DungeonEntityData* sub_8045110(struct DungeonEntity *entity)
return entity->entityData;
}
-struct MapTile* GetMapTileForDungeonEntity(struct DungeonEntity *entity)
+struct MapTile* GetMapTileForDungeonEntity_1(struct DungeonEntity *entity)
{
- return GetMapTileAtPosition(entity->posWorld.x, entity->posWorld.y);
+ return GetMapTile_1(entity->posWorld.x, entity->posWorld.y);
}
-struct MapTile* GetMapEntityForDungeonEntity(struct DungeonEntity *entity)
+struct MapTile* GetMapTileForDungeonEntity_2(struct DungeonEntity *entity)
{
- return GetMapEntity(entity->posWorld.x, entity->posWorld.y);
+ return GetMapTile_2(entity->posWorld.x, entity->posWorld.y);
}
diff --git a/src/status_checker.c b/src/status_checker.c
index 379082f..7fbfc51 100644
--- a/src/status_checker.c
+++ b/src/status_checker.c
@@ -348,14 +348,14 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
break;
case MOVE_DIVE:
- if (IsTileGround(GetMapEntityForDungeonEntity(pokemon)))
+ if (IsTileGround(GetMapTileForDungeonEntity_2(pokemon)))
{
return FALSE;
}
break;
case MOVE_DIG:
{
- struct MapTile *tile = GetMapEntityForDungeonEntity(pokemon);
+ struct MapTile *tile = GetMapTileForDungeonEntity_2(pokemon);
if (!IsTileGround(tile) || (tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_LIQUID)) != TILE_TYPE_FLOOR)
{
return FALSE;
@@ -364,7 +364,7 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo
}
case MOVE_TRAP_BUSTER:
{
- struct DungeonEntity *mapObject = GetMapEntityForDungeonEntity(pokemon)->mapObject;
+ struct DungeonEntity *mapObject = GetMapTileForDungeonEntity_2(pokemon)->mapObject;
if (mapObject == NULL || GetEntityType(mapObject) != ENTITY_TRAP)
{
return FALSE;