diff options
author | Seth Barberee <seth.barberee@gmail.com> | 2021-11-15 11:02:26 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-15 11:02:26 -0800 |
commit | bfaa55f2fe3d557570260f6b4956e39c3b0f1218 (patch) | |
tree | 77611afc222d74c9a68a5577df3ce9916d9b3b97 /src | |
parent | 0ea22237c933523f66d7468a953c5a5057b3a899 (diff) |
Label and doc iq skills and tactics info (#75)
* label/doc iq skills/tactics info
* decomp a few more dungeon_util and label some funcs
* doc the IQSkills field
Diffstat (limited to 'src')
-rw-r--r-- | src/code_8086A3C.c | 4 | ||||
-rw-r--r-- | src/debug_menu_mid.c | 117 | ||||
-rw-r--r-- | src/dungeon_pokemon_attributes_1.c | 28 | ||||
-rw-r--r-- | src/dungeon_util.c | 53 | ||||
-rw-r--r-- | src/pokemon.c | 4 | ||||
-rw-r--r-- | src/pokemon_3.c | 144 | ||||
-rw-r--r-- | src/pokemon_mid.c | 4 |
7 files changed, 270 insertions, 84 deletions
diff --git a/src/code_8086A3C.c b/src/code_8086A3C.c index 63c2d44..67fd08d 100644 --- a/src/code_8086A3C.c +++ b/src/code_8086A3C.c @@ -7,7 +7,7 @@ extern struct DungeonGlobalData *gDungeonGlobalData; extern void sub_807191C(struct DungeonEntity *); extern struct DungeonEntity *sub_8085480(void); extern struct DungeonEntity *sub_8085680(u32); -extern void sub_808EC94(u8 *param_1, u8 param_2); +extern void SetDefaultIQSkills(u8 *param_1, u8 param_2); extern void sub_8097FF8(void); extern u8 sub_8044B28(void); extern u8 HasRecruitedMon(u32); @@ -56,7 +56,7 @@ void SetupBossFightHP(struct DungeonEntity *param_1, s32 newHP, u16 param_3) } gDungeonGlobalData->unk66A = param_3; - sub_808EC94(iVar2->IQSkillsSelected,iVar2->isBoss); + SetDefaultIQSkills(iVar2->IQSkillsSelected,iVar2->isBoss); sub_807191C(param_1); } diff --git a/src/debug_menu_mid.c b/src/debug_menu_mid.c index bc67ef6..2d4907b 100644 --- a/src/debug_menu_mid.c +++ b/src/debug_menu_mid.c @@ -35,7 +35,7 @@ struct unkStruct_203B3F4 { // size: 0xFC u32 state; - u8 unk4; + u8 friendArea; u8 fill5[0x8 - 5]; u32 unk8; struct MenuItem menuItems[8]; @@ -56,7 +56,7 @@ extern struct UnkTextStruct2 gUnknown_80E7E64; extern const char gDebug_NumberText; extern struct UnkTextStruct2 gUnknown_80E7E8C; extern struct UnkTextStruct2 gUnknown_80E7EA4; - +extern bool8 *gFriendAreas; extern const char *gUnknown_80D4970[]; @@ -83,8 +83,16 @@ extern void sub_8021354(u32); extern void sub_8021494(); extern void sub_803AA34(); extern void sub_8021774(u8,u32, u32); - - +extern u8 gDebug_CloseText[]; +extern u8 gDebug_OpenText[]; +extern void UnlockFriendArea(u8); +extern void sub_809249C(u8, u32); +extern void sub_8021830(void); +extern u32 sub_80217EC(void); +extern u8 sub_803ABC8(void); +extern u32 sub_8021274(u32); +extern u8 sub_802132C(void); +extern void sub_80213A0(void); extern void sub_803AAC4(); extern void sub_803AB34(); extern void sub_803ABAC(); @@ -402,9 +410,108 @@ void sub_803A9AC(void) sub_8012D60(&gUnknown_203B3F4->unk4C,gUnknown_203B3F4->menuItems,0,0,gUnknown_203B3F4->unk8,2); break; case 3: - sub_8021774(gUnknown_203B3F4->unk4,1,0); + sub_8021774(gUnknown_203B3F4->friendArea,1,0); break; case 4: break; } } + +void sub_803AA34(void) +{ + s32 iVar4; + u8 *FriendAreas; + + + iVar4 = 0; + + // So dumb that it matches... + FriendAreas = gFriendAreas; + + if(FriendAreas[gUnknown_203B3F4->friendArea]) + { + gUnknown_203B3F4->menuItems[0].text = gDebug_CloseText; + if(sub_803ABC8()) + gUnknown_203B3F4->menuItems[0].menuAction = 3; + else + gUnknown_203B3F4->menuItems[0].menuAction = -1; + } + else + { + gUnknown_203B3F4->menuItems[0].text = gDebug_OpenText; + gUnknown_203B3F4->menuItems[0].menuAction = 2; + } + + iVar4++; + gUnknown_203B3F4->menuItems[iVar4].text = *gUnknown_80D4970; + gUnknown_203B3F4->menuItems[iVar4].menuAction = 4; + + iVar4++; + gUnknown_203B3F4->menuItems[iVar4].text = NULL; + gUnknown_203B3F4->menuItems[iVar4].menuAction = 1; + + gUnknown_203B3F4->unk8 = gUnknown_203B3F4->menuItems[0].menuAction; +} + +void sub_803AAC4(void) +{ + switch(sub_8021274(1)) + { + case 0: + case 1: + break; + case 3: + gUnknown_203B3F4->friendArea = sub_802132C(); + sub_803A924(2); + break; + case 4: + gUnknown_203B3F4->friendArea = sub_802132C(); + sub_803A924(3); + break; + case 2: + sub_80213A0(); + sub_803A924(4); + break; + } +} + +void sub_803AB34(void) +{ + s32 temp; + temp = 0; + sub_8021274(0); + if(!sub_8012FD8(&gUnknown_203B3F4->unk4C)) + sub_8013114(&gUnknown_203B3F4->unk4C, &temp); + switch(temp) + { + case 2: + UnlockFriendArea(gUnknown_203B3F4->friendArea); + sub_803A924(1); + break; + case 3: + sub_809249C(gUnknown_203B3F4->friendArea, 1); + sub_803A924(1); + break; + case 4: + sub_803A924(3); + break; + case 1: + sub_803A924(1); + break; + } +} + +void sub_803ABAC(void) +{ + switch(sub_80217EC()) + { + case 2: + case 3: + sub_8021830(); + sub_803A924(1); + break; + case 0: + case 1: + break; + } +} diff --git a/src/dungeon_pokemon_attributes_1.c b/src/dungeon_pokemon_attributes_1.c index b0a670a..ac865a9 100644 --- a/src/dungeon_pokemon_attributes_1.c +++ b/src/dungeon_pokemon_attributes_1.c @@ -1,8 +1,26 @@ #include "global.h" #include "dungeon_pokemon_attributes_1.h" +#include "constants/status.h" #include "constants/tactic.h" +extern bool8 IsIQSkillSet(u8 *, u32); +extern u8 HasItem(struct DungeonEntity *, u32); + +bool8 sub_8071884(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; @@ -13,3 +31,13 @@ bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic) } 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); +} diff --git a/src/dungeon_util.c b/src/dungeon_util.c index 60b796f..94cd327 100644 --- a/src/dungeon_util.c +++ b/src/dungeon_util.c @@ -1,6 +1,19 @@ #include "global.h" #include "dungeon_util.h" +extern struct MapTile* GetMapTileAtPosition(s16, s16); + +struct unk8049590 +{ + u16 unk0; + u16 fill2; + u16 unk4; + u16 unk6; + u8 unk8; +}; + +extern struct unk8049590 *sub_8049590(s16, s16); + bool8 EntityExists(struct DungeonEntity *entity) { if (!entity) @@ -9,3 +22,43 @@ bool8 EntityExists(struct DungeonEntity *entity) } return entity->entityType != ENTITY_NONE; } + +u32 GetEntityType(struct DungeonEntity *entity) +{ + return entity->entityType; +} + +u8 GetEntityRoomIndex(struct DungeonEntity *entity) +{ + return entity->roomIndex; +} + +struct DungeonEntityData *sub_8045104(struct DungeonEntity *entity) +{ + return entity->entityData; +} + +struct ItemSlot *GetItemData(struct DungeonEntity *entity) +{ + return (struct ItemSlot *)entity->entityData; +} + +struct DungeonEntityData *sub_804510C(struct DungeonEntity *entity) +{ + return entity->entityData; +} + +struct DungeonEntityData *sub_8045110(struct DungeonEntity *entity) +{ + return entity->entityData; +} + +struct MapTile *sub_8045114(struct DungeonEntity *entity) +{ + return GetMapTileAtPosition(entity->posWorldX, entity->posWorldY); +} + +struct unk8049590 *sub_8045128(struct DungeonEntity *entity) +{ + return sub_8049590(entity->posWorldX, entity->posWorldY); +} diff --git a/src/pokemon.c b/src/pokemon.c index 4e28437..cca7d02 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -73,14 +73,14 @@ void InitializeRecruitedPokemon(void) // pokemon.IQ = 1; // pokemon.unkC[0].unk0 = 0; // pokemon.unkC[1].unk0 = 0; -// sub_808EC94((u8*)&pokemon.unk20, 0); +// SetDefaultIQSkills((u8*)&pokemon.IQSkills, 0); // pokemon.speciesNum = species; // pokemon.heldItem.itemIndex = 0; // pokemon.heldItem.numItems = 0; // pokemon.unk1C = 0; // pokemon.unk24 = 0; // pokemon.unk4.unk5 = 0; -// sub_808E490(pokemon.unk2C, species); +// sub_808E490(pokemon.moves, species); // // mostly incorrect below this: // if (!a3) { diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 5f4b833..beaa4a3 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1,6 +1,8 @@ #include "global.h" #include "pokemon.h" #include "random.h" +#include "constants/iq_skill.h" +#include "constants/tactic.h" extern u32 gIQSkillNames[]; extern u32 gIQSkillDescriptions[]; @@ -8,9 +10,9 @@ extern u32 gTacticsDescriptions[]; extern u8 *gTactics[]; extern u8 gUnknown_810A36B[]; -extern s16 gUnknown_810A378[]; -extern s32 gUnknown_810A390[]; -extern u32 gUnknown_81076E4[]; +extern s16 gReqTacticLvls[]; +extern s32 gReqIQSkillPts[]; +extern u32 gIQSkillGroups[]; struct unkStruct_808E9EC { @@ -43,8 +45,8 @@ extern s16 gUnknown_810AC66; // 0x8 // 2, 4, 6, 7, 8, 9, 0xA, 0xD, 0xF, 0x11 extern s32 gUnknown_810AC90[10]; -extern bool8 sub_808ECD0(u8 *, u32); -extern void sub_808EC30(u8 *, u32); +extern bool8 IsIQSkillSet(u8 *, u32); +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*); @@ -484,84 +486,79 @@ u8 sub_808EAFC(u8 r0) return gUnknown_810A36B[r0]; } -void sub_808EB0C(u8 *r0, s32 r1) +void sub_808EB0C(u8 *r0, s32 pokeLevel) { - s32 counter; - s32 storage; - u32 index; - storage = 0; - index = 0; - for(counter = 0; counter <= 0xB; counter++) + s32 tactic; + s32 availTactics; + + availTactics = 0; + for(tactic = TACTIC_LETS_GO_TOGETHER; tactic < NUM_TACTICS; tactic++) { - if(gUnknown_810A378[index] <= r1) + if(gReqTacticLvls[tactic] <= pokeLevel) { - r0[storage] = counter; - storage++; + r0[availTactics] = tactic; + availTactics++; } - index++; } - if(storage > 0xB) + if(availTactics > TACTIC_UNUSED) { return; } - while(storage <= 0xB) + while(availTactics < NUM_TACTICS) { - r0[storage] = 0xB; - storage++; + r0[availTactics] = TACTIC_UNUSED; + availTactics++; } } -void sub_808EB48(u8 *r0, s32 r1) +void sub_808EB48(u8 *r0, s32 pokeLevel) { - s32 counter; + s32 tactic; - for(counter = 0; counter <= 0xB; counter++) + for(tactic = TACTIC_LETS_GO_TOGETHER; tactic < NUM_TACTICS; tactic++) { - if(gUnknown_810A378[counter] <= r1) + if(gReqTacticLvls[tactic] <= pokeLevel) { - r0[counter] = TRUE; + r0[tactic] = TRUE; } else { - r0[counter] = FALSE; + r0[tactic] = FALSE; } } } -bool8 sub_808EB7C(s32 r0, u8 r1) +bool8 HasIQForSkill(s32 pokeIQ, u8 IQSkillIndex) { - if(r1 == 0) + if(IQSkillIndex == 0) { return FALSE; } - return gUnknown_810A390[r1] <= r0; + return gReqIQSkillPts[IQSkillIndex] <= pokeIQ; } -s32 sub_808EBA8(u8 param_1[], s32 param_2) +s32 GetNumAvailableIQSkills(u8 *param_1, s32 pokeIQ) { s32 counter_2; s32 counter_1; - u8 cast_u8; - s32 index; - - index = 0; + u8 iqSkill_u8; + s32 availIQSkills; + + availIQSkills = 0; - for(counter_1 = 1; counter_1 < 0x18; counter_1++) { - cast_u8 = counter_1; // force this cast to be in a reg - if (sub_808EB7C(param_2, cast_u8)) { - param_1[index] = cast_u8; - index++; + for(counter_1 = IQ_SKILL_TYPE_ADVANTAGE_MASTER; counter_1 < NUM_IQ_SKILLS; counter_1++) { + iqSkill_u8 = counter_1; // force this cast to be in a reg + if (HasIQForSkill(pokeIQ, iqSkill_u8)) { + param_1[availIQSkills] = iqSkill_u8; + availIQSkills++; } } - counter_2 = index; // set counter to where the first loop ended - - while (counter_2 < 0x18) { + for (counter_2 = availIQSkills; counter_2 < NUM_IQ_SKILLS; counter_2++) { param_1[counter_2] = 0; - counter_2++; } - return index; + return availIQSkills; } void sub_808EBF4(u8 *param_1, u32 param_2) @@ -569,67 +566,68 @@ void sub_808EBF4(u8 *param_1, u32 param_2) int iVar2; // a mask? iVar2 = 1 << (param_2); - if (sub_808ECD0(param_1,iVar2)) { + if (IsIQSkillSet(param_1, iVar2)) { param_1[0] = param_1[0] & ~iVar2; param_1[1] = param_1[1] & ~(iVar2 >> 8); param_1[2] = param_1[2] & ~(iVar2 >> 0x10); } else { - sub_808EC30(param_1,param_2); + SetIQSkill(param_1, param_2); } } -void sub_808EC30(u8 *param_1, u32 param_2) +void SetIQSkill(u8 *param_1, u32 skillIndex) { s32 iVar1; - s32 counter; - s32 iVar4; + s32 iqSkill; + s32 iqSkillGroup; s32 iVar5; - counter = 0; - iVar4 = gUnknown_81076E4[param_2]; - do { - if (iVar4 == gUnknown_81076E4[counter]) { - iVar1 = 1 << (counter); + for (iqSkill = 0, iqSkillGroup = gIQSkillGroups[skillIndex]; iqSkill < NUM_IQ_SKILLS; iqSkill++) + { + // Turn off each IQ Skill that's in the same group as the chosen skill + if (iqSkillGroup == gIQSkillGroups[iqSkill]) { + iVar1 = 1 << (iqSkill); param_1[0] = param_1[0] & ~iVar1; param_1[1] = param_1[1] & ~(iVar1 >> 8); param_1[2] = param_1[2] & ~(iVar1 >> 0x10); } - counter++; - } while (counter < 0x18); + } - iVar5 = 1 << (param_2); - param_1[0] = iVar5 | param_1[0]; - param_1[1] = (iVar5 >> 8) | param_1[1]; - param_1[2] = (iVar5 >> 0x10) | param_1[2]; + iVar5 = 1 << (skillIndex); + param_1[0] |= iVar5; + param_1[1] |= (iVar5 >> 8); + param_1[2] |= (iVar5 >> 0x10); } -void sub_808EC94(u8 *param_1, u8 param_2) +void SetDefaultIQSkills(u8 *param_1, bool8 enableSelfCurer) { param_1[0] = 0; param_1[1] = 0; param_1[2] = 0; - sub_808EC30(param_1, 2); - sub_808EC30(param_1, 3); - sub_808EC30(param_1, 0x16); - if (param_2 != 0) { - sub_808EC30(param_1, 0x12); + SetIQSkill(param_1, IQ_SKILL_ITEM_CATCHER); + SetIQSkill(param_1, IQ_SKILL_COURSE_CHECKER); + SetIQSkill(param_1, IQ_SKILL_ITEM_MASTER); + + // Flag is usually enabled for Boss fights.. + if (enableSelfCurer) { + SetIQSkill(param_1, IQ_SKILL_SELF_CURER); } } -bool8 sub_808ECD0(u8 *param_1, u32 param_2) +bool8 IsIQSkillSet(u8 *param_1, u32 param_2) { if ((((param_1[0] & param_2) == 0) && ((param_1[1] & param_2 >> 8) == 0)) && ((param_1[2] & param_2 >> 0x10) == 0)) { - return 0; + return FALSE; } else { - return 1; + return TRUE; } } @@ -765,7 +763,7 @@ void SavePokemonStruct(struct unkStruct_8094924* a1, struct PokemonStruct* pokem SaveIntegerBits(a1, &pokemon->offense.def[0], 8); SaveIntegerBits(a1, &pokemon->offense.def[1], 8); SaveIntegerBits(a1, &pokemon->unk1C, 24); - SaveIntegerBits(a1, &pokemon->unk20, 24); + SaveIntegerBits(a1, &pokemon->IQSkills, 24); SaveIntegerBits(a1, &pokemon->unk24, 4); SaveHeldItem(a1, &pokemon->heldItem); SavePokemonMoves(a1, pokemon->moves); @@ -792,7 +790,7 @@ void RestorePokemonStruct(struct unkStruct_8094924* a1, struct PokemonStruct* po RestoreIntegerBits(a1, &pokemon->offense.def[0], 8); RestoreIntegerBits(a1, &pokemon->offense.def[1], 8); RestoreIntegerBits(a1, &pokemon->unk1C, 24); - RestoreIntegerBits(a1, &pokemon->unk20, 24); + RestoreIntegerBits(a1, &pokemon->IQSkills, 24); RestoreIntegerBits(a1, &pokemon->unk24, 4); RestoreHeldItem(a1, &pokemon->heldItem); RestorePokemonMoves(a1, pokemon->moves); @@ -833,7 +831,7 @@ s32 SavePokemonStruct2(u8* a1, s32 size) SaveItemSlot(&backup, &pokemon2->itemSlot); sub_809449C(&backup, &pokemon2->unk44); sub_809449C(&backup, &pokemon2->unk48); - SaveIntegerBits(&backup, &pokemon2->unk4C, 24); + SaveIntegerBits(&backup, &pokemon2->IQSkills, 24); SaveIntegerBits(&backup, &pokemon2->unk50, 4); sub_808F448(&backup, &pokemon2->unk54); SaveIntegerBits(&backup, &pokemon2->name, 80); @@ -881,7 +879,7 @@ s32 RestorePokemonStruct2(u8* a1, s32 size) RestoreItemSlot(&backup, &pokemon2->itemSlot); sub_809447C(&backup, &pokemon2->unk44); sub_809447C(&backup, &pokemon2->unk48); - RestoreIntegerBits(&backup, &pokemon2->unk4C, 24); + RestoreIntegerBits(&backup, &pokemon2->IQSkills, 24); RestoreIntegerBits(&backup, &pokemon2->unk50, 4); sub_808F428(&backup, &pokemon2->unk54); RestoreIntegerBits(&backup, &pokemon2->name, 80); diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c index 94387b2..38eb0d4 100644 --- a/src/pokemon_mid.c +++ b/src/pokemon_mid.c @@ -526,7 +526,7 @@ void xxx_pokemonstruct_to_pokemon2_808DE50(struct PokemonStruct2 * a1, struct Po a1->unk0 = pokemon->unk0; a1->unkHasNextStage = pokemon->unkHasNextStage; a1->IQ = pokemon->IQ; - a1->unk4C = pokemon->unk20; + a1->IQSkills = pokemon->IQSkills; sub_808E6F4(&a1->unk54); a1->unk4 = pokemon->unk4; a1->unk2 = pokemon->unk2; @@ -580,7 +580,7 @@ void xxx_pokemon2_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct pokemon->unk0 = a2->unk0; pokemon->unkHasNextStage = a2->unkHasNextStage; pokemon->IQ = a2->IQ; - pokemon->unk20 = a2->unk4C; + pokemon->IQSkills = a2->IQSkills; pokemon->unk4 = a2->unk4; pokemon->unk2 = a2->unk2; pokemon->speciesNum = a2->speciesNum; |