Decomped GetMapTileAtPosition()

This commit is contained in:
AnonymousRandomPerson
2021-12-18 00:22:03 -05:00
parent c033aea36e
commit 0369264407
18 changed files with 18545 additions and 18549 deletions

View File

@@ -2523,7 +2523,7 @@ sub_80414C0:
cmp r0, 0x9C
bne _080414DC
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
bl IsTileWater
lsls r0, 24
cmp r0, 0
@@ -2533,7 +2533,7 @@ _080414DC:
cmp r0, 0x8
bne _080414F6
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1

File diff suppressed because it is too large Load Diff

18473
asm/code_8049590.s Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -909,7 +909,7 @@ sub_8057788:
movs r0, 0
mov r9, r0
adds r0, r4, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r5, r0, 0
bl IsTileWater
lsls r0, 24

View File

@@ -4061,7 +4061,7 @@ DiveMoveAction:
adds r5, r2, 0
mov r8, r3
movs r6, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
bl IsTileWater
lsls r0, 24
cmp r0, 0
@@ -9264,7 +9264,7 @@ TrapbustOrbAction:
movs r0, 0
str r0, [sp, 0x10]
adds r0, r1, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r4, r0, 0
bl IsBossBattle
lsls r0, 24
@@ -10680,12 +10680,12 @@ _0805CCD0:
b _0805CDC2
_0805CCD8:
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
bl IsTileWater
b _0805CDEC
_0805CCE4:
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r4, r0, 0
bl IsTileWater
lsls r0, 24
@@ -10703,7 +10703,7 @@ _0805CD04:
b _0805CB6E
_0805CD06:
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldr r0, [r0, 0x14]
cmp r0, 0
bne _0805CD14
@@ -14663,7 +14663,7 @@ _0805EE42:
b _0805EF52
_0805EE4E:
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r4, r0, 0
adds r0, r5, 0
movs r1, 0xD
@@ -34665,7 +34665,7 @@ sub_8068F80:
cmp r5, 0
beq _08068FCC
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r0, [r0]
lsrs r0, 5
movs r1, 0x1
@@ -34703,7 +34703,7 @@ sub_8068FE0:
asrs r1, 16
mov r9, r1
ldr r7, [r0, 0x70]
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r4, r0, 0
ldr r0, [sp, 0x74]
cmp r0, 0
@@ -37559,7 +37559,7 @@ sub_806A5B8:
b _0806A6D2
_0806A5CE:
adds r0, r6, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r0, [r0]
movs r1, 0x3
ands r1, r0

View File

@@ -142,7 +142,7 @@ _0806CF94: .4byte 0x000135cc
sub_806CF98:
push {r4-r7,lr}
adds r4, r0, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r0, [r0]
movs r5, 0x3
ands r5, r0
@@ -1123,7 +1123,7 @@ _0806D760:
cmp r0, 0
beq _0806D796
adds r0, r7, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
mov r8, r0
movs r0, 0x14
movs r1, 0x18

View File

@@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start TargetThrownItem
TargetThrownItem:
push {r4-r7,lr}
@@ -240,7 +240,7 @@ sub_8073D14:
sub sp, 0xB0
adds r6, r0, 0
ldr r4, [r6, 0x70]
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldr r5, [r0, 0x14]
cmp r5, 0
bne _08073D30
@@ -3443,7 +3443,7 @@ sub_8075708:
cmp r0, 0
beq _0807580C
adds r0, r4, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r5, r0, 0
adds r0, r4, 0
movs r1, 0xD

View File

@@ -860,7 +860,7 @@ _08076292:
_08076298: .4byte gUnknown_80FCE84
_0807629C:
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -1542,7 +1542,7 @@ _08076814:
_0807682C: .4byte gUnknown_80FCE00
_08076830:
adds r0, r5, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r1, [r0]
movs r0, 0x3
ands r0, r1
@@ -9836,7 +9836,7 @@ sub_807AB38:
_0807AB54:
adds r0, r2, 0
str r2, [sp, 0x1A4]
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r1, [r0]
movs r0, 0x40
ands r0, r1
@@ -10300,7 +10300,7 @@ CanTakeItem:
cmp r0, 0
bne _0807AF50
adds r0, r4, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
adds r6, r0, 0
ldr r4, [r6, 0x14]
cmp r4, 0
@@ -18171,7 +18171,7 @@ _0807EC46:
ldrb r0, [r0]
str r0, [sp, 0x8]
adds r0, r7, 0
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r0, [r0]
lsrs r0, 5
mov r10, r0
@@ -18594,7 +18594,7 @@ sub_807EF84:
cmp r4, 0
beq _0807EFE2
bl GetLeaderEntity
bl sub_8045128
bl GetMapEntityForDungeonEntity
ldrh r1, [r0]
movs r0, 0x20
ands r0, r1

View File

@@ -7,8 +7,8 @@
#include "map.h"
#include "position.h"
#define DUNGEON_MAX_SIZE_X 55
#define DUNGEON_MAX_SIZE_Y 31
#define DUNGEON_MAX_SIZE_X 56
#define DUNGEON_MAX_SIZE_Y 32
#define DUNGEON_MAX_WILD_POKEMON 16
#define DUNGEON_MAX_POKEMON MAX_TEAM_MEMBERS + DUNGEON_MAX_WILD_POKEMON
@@ -54,8 +54,8 @@ struct DungeonGlobalData
u8 fill3A10[0x3A14 - 0x3A10];
/* 0x3A14 */ s16 bossBattleIndex;
u8 fill3A16[0x3A18 - 0x3A16];
/* 0x3A18 */ struct MapTile mapTiles[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y];
u8 fill54BC[0xE23C - 0xD9F0];
/* 0x3A18 */ struct MapTile mapTiles[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fillE218[0xE23C - 0xE218];
s16 unkE23C;
s16 unkE23E;
u8 fillE240[0xE264 - 0xE240];
@@ -71,10 +71,10 @@ struct DungeonGlobalData
/* 0xE277 */ u8 mudSportTurnsLeft;
/* 0xE278 */ u8 waterSportTurnsLeft;
u8 fillE279[0xE8C0 - 0xE279];
/* 0xE8C0 */ u32 mapEntityPointers[DUNGEON_MAX_SIZE_X * DUNGEON_MAX_SIZE_Y];
u8 fill10364[0x104C4 - 0x10364];
/* 0xE8C0 */ struct MapTile* mapEntityPointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fill104C0[0x104C4 - 0x104C0];
/* 0x104C4 */ struct MapRoom roomData[MAX_ROOM_COUNT];
u8 fill10604[0x10844 - 0x10764];
u8 fill10764[0x10844 - 0x10764];
/* 0x10844 */ u16 numRoomExits[MAX_ROOM_COUNT];
u8 fill10874[0x10884 - 0x10874];
/* 0x10884 */ struct Position roomExits[MAX_ROOM_COUNT][32]; // Arrays of room exits for each room.

View File

@@ -0,0 +1,9 @@
#ifndef GUARD_DUNGEON_MAP_ACCESS_H
#define GUARD_DUNGEON_MAP_ACCESS_H
#include "map.h"
// 0x4954C
struct MapTile* GetMapTileAtPosition(s32 x, s32 y);
#endif

View File

@@ -11,6 +11,6 @@ u32 GetEntityType(struct DungeonEntity *entity);
struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity);
// 0x45108
struct ItemSlot *GetItemData(struct DungeonEntity *entity);
struct MapTile *sub_8045128(struct DungeonEntity *entity);
struct MapTile *GetMapEntityForDungeonEntity(struct DungeonEntity *entity);
#endif

View File

@@ -194,6 +194,8 @@ SECTIONS {
asm/code_8045A00.o(.text);
src/code_8048480.o(.text);
asm/code_8048480.o(.text);
src/dungeon_map_access.o(.text);
asm/code_8049590.o(.text);
src/code_80521D0.o(.text);
asm/code_80521D0.o(.text);
src/charge_move.o(.text);

View File

@@ -35,9 +35,9 @@ void HandleLuminousOrbAction(u32 param_1)
gDungeonGlobalData->unk1820B = 1;
for(YCoord = 0; YCoord <= DUNGEON_MAX_SIZE_Y; YCoord++)
for(YCoord = 0; YCoord < DUNGEON_MAX_SIZE_Y; YCoord++)
{
for(XCoord = 0; XCoord <= DUNGEON_MAX_SIZE_X; XCoord++)
for(XCoord = 0; XCoord < DUNGEON_MAX_SIZE_X; XCoord++)
{
mapTile = GetMapEntity(XCoord, YCoord);
mapTile->unk4 = mapTile->unk4 | 1;

View File

@@ -11,6 +11,7 @@
#include "dungeon_capabilities_1.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_random.h"
#include "dungeon_random_1.h"
@@ -31,7 +32,6 @@ enum ItemTargetFlag
};
extern s32 CalculateFacingDir(struct Position*, struct Position*);
extern struct MapTile* GetMapTileAtPosition(s16, s16);
extern u32 EvaluateItem(struct DungeonEntity*, struct ItemSlot*, u8);
extern bool8 ToolboxEnabled(struct DungeonEntityData*);
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);

15
src/dungeon_map_access.c Normal file
View File

@@ -0,0 +1,15 @@
#include "global.h"
#include "dungeon_map_access.h"
#include "dungeon_global_data.h"
extern struct MapTile *gUnknown_203B430;
struct MapTile* GetMapTileAtPosition(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 gUnknown_203B430;
}

View File

@@ -49,7 +49,7 @@ u32 sub_8075818(struct DungeonEntity *entity)
entityData = entity->entityData;
if(EntityExists(entity))
{
tile = sub_8045128(entity);
tile = GetMapEntityForDungeonEntity(entity);
if(HasIQSkill(entity, IQ_SKILL_SUPER_MOBILE))
if(!(tile->tileType & (TILE_TYPE_FLOOR | TILE_TYPE_UNK_1)))
return 1;
@@ -136,7 +136,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
{
if(!gDungeonGlobalData->monsterHouseActive)
{
if((sub_8045128(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
if((GetMapEntityForDungeonEntity(pokemon)->tileType & TILE_TYPE_MONSTER_HOUSE))
{
// It's a monster house!
SendMessage(GetLeaderEntity(), gPtrItsaMonsterHouseMessage);

View File

@@ -2,10 +2,9 @@
#include "dungeon_range.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "map.h"
extern struct MapTile* GetMapTileAtPosition(s16, s16);
bool8 InSameRoom_2(struct Position *pos1, struct Position *pos2)
{
u8 pos1RoomIndex;

View File

@@ -1,7 +1,8 @@
#include "global.h"
#include "dungeon_util.h"
extern struct MapTile* GetMapTileAtPosition(s16, s16);
#include "dungeon_map_access.h"
extern struct MapTile* GetMapEntity(s16, s16);
bool8 EntityExists(struct DungeonEntity *entity)
@@ -23,32 +24,32 @@ u8 GetEntityRoomIndex(struct DungeonEntity *entity)
return entity->roomIndex;
}
struct DungeonEntityData *GetTrapData(struct DungeonEntity *entity)
struct DungeonEntityData* GetTrapData(struct DungeonEntity *entity)
{
return entity->entityData;
}
struct ItemSlot *GetItemData(struct DungeonEntity *entity)
struct ItemSlot* GetItemData(struct DungeonEntity *entity)
{
return (struct ItemSlot *)entity->entityData;
}
struct DungeonEntityData *sub_804510C(struct DungeonEntity *entity)
struct DungeonEntityData* sub_804510C(struct DungeonEntity *entity)
{
return entity->entityData;
}
struct DungeonEntityData *sub_8045110(struct DungeonEntity *entity)
struct DungeonEntityData* sub_8045110(struct DungeonEntity *entity)
{
return entity->entityData;
}
struct MapTile *sub_8045114(struct DungeonEntity *entity)
struct MapTile* GetMapTileForDungeonEntity(struct DungeonEntity *entity)
{
return GetMapTileAtPosition(entity->posWorld.x, entity->posWorld.y);
}
struct MapTile *sub_8045128(struct DungeonEntity *entity)
struct MapTile* GetMapEntityForDungeonEntity(struct DungeonEntity *entity)
{
return GetMapEntity(entity->posWorld.x, entity->posWorld.y);
}