Decomped HasType()

This commit is contained in:
AnonymousRandomPerson
2022-02-13 23:13:47 -05:00
parent 3bbb6035e7
commit 2a2a0805b4
22 changed files with 204 additions and 242 deletions

View File

@@ -1,37 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start HasType
HasType:
push {lr}
lsls r1, 24
lsrs r1, 24
adds r3, r1, 0
ldr r0, [r0, 0x70]
adds r2, r0, 0
cmp r1, 0
beq _0807187A
adds r0, 0x5C
ldrb r0, [r0]
cmp r0, r1
beq _0807187E
adds r0, r2, 0
adds r0, 0x5D
ldrb r0, [r0]
cmp r0, r3
beq _0807187E
_0807187A:
movs r0, 0
b _08071880
_0807187E:
movs r0, 0x1
_08071880:
pop {r1}
bx r1
thumb_func_end HasType
.align 2, 0

View File

@@ -5,5 +5,21 @@
// 0x71824
bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability);
// 0x71858
bool8 HasType(struct DungeonEntity *pokemon, u8 type);
// 0x71884
bool8 CanSeeInvisible(struct DungeonEntity *pokemon);
// 0x718AC
bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic);
// 0x718D8
bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill);
void LoadIQSkills(struct DungeonEntity *pokemon);
bool8 CanSeeTeammate(struct DungeonEntity * pokemon);
u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove);
// 0x71A44
s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove);
bool8 ToolboxEnabled(struct DungeonEntityData *pokemon);
#endif

View File

@@ -1,21 +0,0 @@
#ifndef GUARD_DUNGEON_POKEMON_ATTRIBUTES_1_H
#define GUARD_DUNGEON_POKEMON_ATTRIBUTES_1_H
#include "dungeon_entity.h"
// 0x71884
bool8 CanSeeInvisible(struct DungeonEntity *pokemon);
// 0x718AC
bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic);
// 0x718D8
bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill);
void LoadIQSkills(struct DungeonEntity *pokemon);
bool8 CanSeeTeammate(struct DungeonEntity * pokemon);
u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove);
// 0x71A44
s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove);
bool8 ToolboxEnabled(struct DungeonEntityData *pokemon);
#endif

View File

@@ -7,8 +7,10 @@
void InitPokemonMove(struct PokemonMove *move, u16 moveID);
// 0x92AE0
s16 GetMoveTargetingFlags(struct PokemonMove *move, u32 isAI);
u8 GetMoveType(struct PokemonMove *move);
// 0x92B90
u8 GetMoveWeight(struct PokemonMove *move);
s32 GetMovePower(struct PokemonMove *move);
// 0x92BF4
u32 GetMoveMaxPP(struct PokemonMove *move);
// 0x92C54

View File

@@ -1,6 +1,8 @@
#ifndef GUARD_POKEMON_3_H
#define GUARD_POKEMON_3_H
bool8 HasIQForSkill(s32 pokeIQ, u8 IQSkillIndex);
void SetIQSkill(u8 *param_1, u32 skillIndex);
bool8 IsIQSkillSet(u8 *IQSkillsEnabled, u32 IQSkill);
#endif

View File

@@ -226,8 +226,6 @@ SECTIONS {
src/dungeon_ai_1.o(.text);
asm/code_807167C.o(.text);
src/dungeon_pokemon_attributes.o(.text);
asm/code_8071858.o(.text);
src/dungeon_pokemon_attributes_1.o(.text);
asm/code_80718D8.o(.text);
src/dungeon_ai_items.o(.text);
asm/code_8073CF0.o(.text);
@@ -410,7 +408,7 @@ SECTIONS {
data/data_80F4DB4.o(.rodata);
src/dungeon_ai_attack.o(.rodata);
data/data_80F4E2C.o(.rodata);
src/dungeon_pokemon_attributes_1.o(.rodata);
src/dungeon_pokemon_attributes.o(.rodata);
data/data_80F59C8.o(.rodata);
src/charge_move.o(.rodata);
data/data_8106A4C.o(.rodata);

View File

@@ -1,7 +1,9 @@
#include "global.h"
#include "constants/direction.h"
#include "constants/type.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "constants/direction.h"
#include "dungeon_pokemon_attributes.h"
struct unkStruct_80420E8
{
@@ -16,7 +18,6 @@ extern void sub_804151C(struct DungeonEntity *r0, u32 r1, u8 r2);
extern void sub_80416E0(struct DungeonEntity *r0, u32, u32);
extern u8 sub_8042768(struct DungeonEntity *r0);
extern void sub_806CDD4(struct DungeonEntity *r0, u8, u32);
extern u8 HasType(struct DungeonEntity *r0, u8);
extern u32 sub_806F62C(u32);
extern void PlaySoundEffect(u32);
extern u8 sub_803F428(struct DungeonEntity *r0);
@@ -343,10 +344,10 @@ void sub_8041DD8(struct DungeonEntity *r0, s16 r1)
u32 temp;
temp = r1;
if(HasType(r0, 0xE) != 0)
if(HasType(r0, TYPE_GHOST) != 0)
sub_804151C(r0, temp, 1);
else
sub_804151C(r0, 0xE, 1);
sub_804151C(r0, TYPE_GHOST, 1);
}
void nullsub_89(void)

View File

@@ -2,6 +2,7 @@
#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "constants/move.h"
#include "moves.h"
extern u32 gUnknown_80FCF74;
extern u32 gUnknown_80FCF80;
@@ -30,7 +31,6 @@ extern void sub_806F370(struct DungeonEntity *r0, struct DungeonEntity *r1, u32,
extern u32 gUnknown_80FD018;
extern s16 sub_8057600(void*, u32);
extern u32 GetMoveType(void*);
bool32 sub_8057824(struct DungeonEntity *param_1, struct DungeonEntity *param_2)
{

View File

@@ -4,7 +4,6 @@
#include "constants/ability.h"
#include "constants/tactic.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_util.h"
extern void CheckRunAwayVisualFlag(struct DungeonEntity *, bool8 showRunAwayEffect);

View File

@@ -3,7 +3,7 @@
#include "constants/status.h"
#include "constants/targeting.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
const u8 gTargetingData[3][2][2][2] = {
{

View File

@@ -16,7 +16,6 @@
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_random.h"
#include "dungeon_random_1.h"
#include "dungeon_util.h"

View File

@@ -4,7 +4,7 @@
#include "constants/iq_skill.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
bool8 IsTargetStraightAhead(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, s32 facingDir, s32 maxRange)

View File

@@ -5,7 +5,7 @@
#include "constants/targeting.h"
#include "dungeon_ai_1.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "moves.h"
#include "number_util.h"

View File

@@ -15,7 +15,7 @@
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_random_1.h"
#include "dungeon_util.h"

View File

@@ -12,7 +12,7 @@
#include "dungeon_ai_items.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "dungeon_util_1.h"

View File

@@ -11,7 +11,7 @@
#include "dungeon_items.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "map.h"

View File

@@ -1,15 +1,27 @@
#include "global.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "constants/ability.h"
#include "constants/dungeon.h"
#include "constants/iq_skill.h"
#include "constants/move_id.h"
#include "constants/status.h"
#include "constants/tactic.h"
#include "constants/type.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
#include "dungeon_util.h"
#include "dungeon_visibility.h"
#include "moves.h"
#include "pokemon.h"
#include "pokemon_3.h"
const s16 gItemMasterMinWildLevel[] = {16};
extern u8 gAvailablePokemonNames[];
extern u32 gUnknown_80FC31C;
extern u32 gUnknown_80FCEFC;
extern u32 gUnknown_80FC2FC;
extern bool8 sub_805744C(struct DungeonEntity *, struct PokemonMove *, u32);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void sub_80522F4(struct DungeonEntity *r1, struct DungeonEntity *r2, u32);
@@ -90,3 +102,158 @@ bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability)
return FALSE;
}
}
bool8 HasType(struct DungeonEntity *pokemon, u8 type)
{
struct DungeonEntityData *pokemonData = pokemonData = pokemon->entityData;
if (type == TYPE_NONE)
{
return FALSE;
}
if (pokemonData->type1 == type)
{
return TRUE;
}
if (pokemonData->type2 == type)
{
return TRUE;
}
return FALSE;
}
bool8 CanSeeInvisible(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->eyesightStatus != EYESIGHT_STATUS_EYEDROPS)
{
if (!HasItem(pokemon, ITEM_ID_GOGGLE_SPECS))
return FALSE;
else
return TRUE;
}
else
return TRUE;
}
bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->isLeader)
{
bool8 isGoTheOtherWay = tactic == TACTIC_GO_THE_OTHER_WAY;
return isGoTheOtherWay;
}
return pokemonData->tactic == tactic;
}
bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill)
{
return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill);
}
bool8 HasIQSkillPair(struct DungeonEntity *pokemon, u8 IQSkill1, u8 IQSkill2)
{
return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill1 | 1 << IQSkill2);
}
void LoadIQSkills(struct DungeonEntity *pokemon)
{
u8 *iVar2;
s32 IQSkill;
struct DungeonEntityData *pokemonData;
pokemonData = pokemon->entityData;
if (pokemonData->isEnemy) {
iVar2 = pokemonData->IQSkillsEnabled;
SetIQSkill(iVar2, IQ_SKILL_STATUS_CHECKER);
SetIQSkill(iVar2, IQ_SKILL_PP_CHECKER);
SetIQSkill(iVar2, IQ_SKILL_ITEM_CATCHER);
if (pokemonData->isBoss)
SetIQSkill(iVar2, IQ_SKILL_SELF_CURER);
if (pokemonData->level >= *gItemMasterMinWildLevel)
SetIQSkill(iVar2, IQ_SKILL_ITEM_MASTER);
pokemonData->tactic = TACTIC_GO_AFTER_FOES;
}
else {
pokemonData->IQSkillsEnabled[0] = 0;
pokemonData->IQSkillsEnabled[1] = 0;
pokemonData->IQSkillsEnabled[2] = 0;
for(IQSkill = IQ_SKILL_TYPE_ADVANTAGE_MASTER; IQSkill < NUM_IQ_SKILLS; IQSkill++)
{
if (HasIQForSkill(pokemonData->IQ,IQSkill) &&
IsIQSkillSet(pokemonData->IQSkillsSelected, 1 << IQSkill))
{
SetIQSkill(pokemonData->IQSkillsEnabled,IQSkill);
}
}
}
}
bool8 CanSeeTeammate(struct DungeonEntity * pokemon)
{
struct DungeonEntity *teamMember;
s32 memberIdx;
if (pokemon->entityData->isEnemy) {
return FALSE;
}
else
{
for(memberIdx = 0; memberIdx < MAX_TEAM_MEMBERS; memberIdx++)
{
teamMember = gDungeonGlobalData->teamPokemon[memberIdx];
if (EntityExists(pokemon) && (pokemon != teamMember) && (CanSee(pokemon,teamMember)))
{
return TRUE;
}
}
return FALSE;
}
}
u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove)
{
if (pokeMove->moveID == MOVE_HIDDEN_POWER)
return pokemon->entityData->hiddenPowerType;
else
return GetMoveType(pokeMove);
}
s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove)
{
if(pokeMove->moveID == MOVE_HIDDEN_POWER)
return (pokemon->entityData->hiddenPowerPower + pokeMove->powerBoost);
else
return (GetMovePower(pokeMove) + pokeMove->powerBoost);
}
bool8 ToolboxEnabled(struct DungeonEntityData *pokemon)
{
if(!IsToolboxEnabled(pokemon->entityID))
return FALSE;
return TRUE;
}
static inline bool8 sub_8071A8C_sub(struct DungeonEntityData *pokemonData)
{
if(pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON ||
pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE)
return TRUE;
else
return FALSE;
}
bool8 sub_8071A8C(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData;
if(EntityExists(pokemon))
{
pokemonData = pokemon->entityData;
if(pokemonData->clientType != CLIENT_TYPE_CLIENT)
{
if(!sub_8071A8C_sub(pokemonData))
return TRUE;
}
}
return FALSE;
}

View File

@@ -1,161 +0,0 @@
#include "global.h"
#include "dungeon_pokemon_attributes_1.h"
#include "constants/dungeon.h"
#include "constants/iq_skill.h"
#include "constants/move_id.h"
#include "constants/status.h"
#include "constants/tactic.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
#include "dungeon_util.h"
#include "pokemon.h"
#include "pokemon_3.h"
const s16 gItemMasterMinWildLevel[] = {16};
extern bool8 IsIQSkillSet(u8 *, u32);
extern void SetIQSkill(u8 *param_1, u32 skillIndex);
extern bool8 HasIQForSkill(s32 pokeIQ, u8 IQSkillIndex);
extern bool8 CanSee(struct DungeonEntity *, struct DungeonEntity *);
extern u8 GetMoveType(struct PokemonMove *move);
extern s32 GetMovePower(struct PokemonMove *move);
bool8 CanSeeInvisible(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->eyesightStatus != EYESIGHT_STATUS_EYEDROPS)
{
if (!HasItem(pokemon, ITEM_ID_GOGGLE_SPECS))
return FALSE;
else
return TRUE;
}
else
return TRUE;
}
bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->isLeader)
{
bool8 isGoTheOtherWay = tactic == TACTIC_GO_THE_OTHER_WAY;
return isGoTheOtherWay;
}
return pokemonData->tactic == tactic;
}
bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill)
{
return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill);
}
bool8 HasIQSkillPair(struct DungeonEntity *pokemon, u8 IQSkill1, u8 IQSkill2)
{
return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill1 | 1 << IQSkill2);
}
void LoadIQSkills(struct DungeonEntity *pokemon)
{
u8 *iVar2;
s32 IQSkill;
struct DungeonEntityData *pokemonData;
pokemonData = pokemon->entityData;
if (pokemonData->isEnemy) {
iVar2 = pokemonData->IQSkillsEnabled;
SetIQSkill(iVar2, IQ_SKILL_STATUS_CHECKER);
SetIQSkill(iVar2, IQ_SKILL_PP_CHECKER);
SetIQSkill(iVar2, IQ_SKILL_ITEM_CATCHER);
if (pokemonData->isBoss)
SetIQSkill(iVar2, IQ_SKILL_SELF_CURER);
if (pokemonData->level >= *gItemMasterMinWildLevel)
SetIQSkill(iVar2, IQ_SKILL_ITEM_MASTER);
pokemonData->tactic = TACTIC_GO_AFTER_FOES;
}
else {
pokemonData->IQSkillsEnabled[0] = 0;
pokemonData->IQSkillsEnabled[1] = 0;
pokemonData->IQSkillsEnabled[2] = 0;
for(IQSkill = IQ_SKILL_TYPE_ADVANTAGE_MASTER; IQSkill < NUM_IQ_SKILLS; IQSkill++)
{
if (HasIQForSkill(pokemonData->IQ,IQSkill) &&
IsIQSkillSet(pokemonData->IQSkillsSelected, 1 << IQSkill))
{
SetIQSkill(pokemonData->IQSkillsEnabled,IQSkill);
}
}
}
}
bool8 CanSeeTeammate(struct DungeonEntity * pokemon)
{
struct DungeonEntity *teamMember;
s32 memberIdx;
if (pokemon->entityData->isEnemy) {
return FALSE;
}
else
{
for(memberIdx = 0; memberIdx < MAX_TEAM_MEMBERS; memberIdx++)
{
teamMember = gDungeonGlobalData->teamPokemon[memberIdx];
if (EntityExists(pokemon) && (pokemon != teamMember) && (CanSee(pokemon,teamMember)))
{
return TRUE;
}
}
return FALSE;
}
}
u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove)
{
if (pokeMove->moveID == MOVE_HIDDEN_POWER)
return pokemon->entityData->hiddenPowerType;
else
return GetMoveType(pokeMove);
}
s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove)
{
if(pokeMove->moveID == MOVE_HIDDEN_POWER)
return (pokemon->entityData->hiddenPowerPower + pokeMove->powerBoost);
else
return (GetMovePower(pokeMove) + pokeMove->powerBoost);
}
bool8 ToolboxEnabled(struct DungeonEntityData *pokemon)
{
if(!IsToolboxEnabled(pokemon->entityID))
return FALSE;
return TRUE;
}
static inline bool8 sub_8071A8C_sub(struct DungeonEntityData *pokemonData)
{
if(pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON ||
pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE)
return TRUE;
else
return FALSE;
}
bool8 sub_8071A8C(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData;
if(EntityExists(pokemon))
{
pokemonData = pokemon->entityData;
if(pokemonData->clientType != CLIENT_TYPE_CLIENT)
{
if(!sub_8071A8C_sub(pokemonData))
return TRUE;
}
}
return FALSE;
}

View File

@@ -2,7 +2,7 @@
#include "dungeon_visibility.h"
#include "constants/status.h"
#include "dungeon_pokemon_attributes_1.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_range.h"
#include "dungeon_util.h"

View File

@@ -40,7 +40,6 @@ extern s32 sub_8090FEC(s32 a1, u8* a2, u8 a3);
extern void sub_80073B8(u32);
extern u32 sub_8097DF0(char *, struct subStruct_203B240 **);
extern void sub_80078A4(u32, u32, u32, u32, u32);
extern u32 GetMoveType(void*);
extern u8* GetUnformattedTypeString(s16);
extern void sub_80073E0(u32);
extern void xxx_format_and_draw(u32, u32, u8 *, u32, u32);

View File

@@ -47,7 +47,6 @@ extern s16 gUnknown_810AC66; // 0x8
// 2, 4, 6, 7, 8, 9, 0xA, 0xD, 0xF, 0x11
extern s32 gUnknown_810AC90[10];
extern void SetIQSkill(u8 *, u32);
extern void AddSprite(u16 *, u32, u32, u32);
extern void xxx_save_poke_sub_4_80902F4(struct unkStruct_8094924*, struct unkPokeSubStruct_4*);

View File

@@ -3,10 +3,9 @@
#include "constants/move_id.h"
#include "constants/type.h"
#include "dungeon_pokemon_attributes.h"
#include "moves.h"
extern bool8 HasType(struct DungeonEntity *pokemon, u8 type);
s16 GetMoveTargetingFlagsForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *move, u32 isAI)
{
if (move->moveID == MOVE_CURSE && !isAI && !HasType(pokemon, TYPE_GHOST))