diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/code_80958E8.c | 6 | ||||
-rw-r--r-- | src/debug_menu_1.c | 2 | ||||
-rw-r--r-- | src/debug_menu_2.c | 2 | ||||
-rw-r--r-- | src/friend_area_action_menu_1.c | 4 | ||||
-rw-r--r-- | src/items.c | 16 | ||||
-rw-r--r-- | src/pokemon.c | 6 | ||||
-rw-r--r-- | src/pokemon_1.c | 200 | ||||
-rw-r--r-- | src/pokemon_3.c | 189 | ||||
-rw-r--r-- | src/pokemon_mid.c | 687 |
9 files changed, 892 insertions, 220 deletions
diff --git a/src/code_80958E8.c b/src/code_80958E8.c index a6ff84a..cd9fa20 100644 --- a/src/code_80958E8.c +++ b/src/code_80958E8.c @@ -32,7 +32,7 @@ struct unkStruct_203B490 extern bool8 sub_809095C(u8); extern s32 sub_8090298(u8); extern bool8 sub_809017C(u8 *); -extern s16 sub_808E770(s16); +extern s16 GetBaseSpecies(s16); extern bool8 sub_8092040(u8); extern u8 sub_803C1D0(u8 *, u8); extern bool8 IsNotMoneyOrUsedTMItem(u8); @@ -127,14 +127,14 @@ bool8 ValidateWonderMail(struct WonderMail *data) return FALSE; if(data->clientPoke > SPECIES_RAYQUAZA_CUTSCENE) return FALSE; - if(data->clientPoke != sub_808E770(data->clientPoke)) + if(data->clientPoke != GetBaseSpecies(data->clientPoke)) return FALSE; if(sub_803C0DC(data->clientPoke) == 0) return FALSE; if(data->targetPoke > SPECIES_RAYQUAZA_CUTSCENE) return FALSE; - if(data->targetPoke != sub_808E770(data->targetPoke)) + if(data->targetPoke != GetBaseSpecies(data->targetPoke)) return FALSE; if(sub_803C0DC(data->targetPoke) == 0) return FALSE; diff --git a/src/debug_menu_1.c b/src/debug_menu_1.c index 0104c07..4386c87 100644 --- a/src/debug_menu_1.c +++ b/src/debug_menu_1.c @@ -56,7 +56,7 @@ void sub_803AFE8(void) default: break; case 3: - gUnknown_203B3F8->pokemon->unk3 = gUnknown_203B3F8->unk60; + gUnknown_203B3F8->pokemon->unkHasNextStage = gUnknown_203B3F8->unk60; // Fallthrough is needed to match case 2: sub_803ACD0(2); diff --git a/src/debug_menu_2.c b/src/debug_menu_2.c index 158f540..dbcb60e 100644 --- a/src/debug_menu_2.c +++ b/src/debug_menu_2.c @@ -155,7 +155,7 @@ void sub_803AD88(void) gUnknown_203B3F8->unk70 = 3; gUnknown_203B3F8->unk68 = 1; gUnknown_203B3F8->unk6C = 0x64; - gUnknown_203B3F8->unk64 = gUnknown_203B3F8->pokemon->unk3; + gUnknown_203B3F8->unk64 = gUnknown_203B3F8->pokemon->unkHasNextStage; gUnknown_203B3F8->unk74 = 3; gUnknown_203B3F8->unk78 = &gUnknown_203B3F8->unkE0[3]; gUnknown_203B3F8->unk7C = 0x2C; diff --git a/src/friend_area_action_menu_1.c b/src/friend_area_action_menu_1.c index 5315996..f35bcfa 100644 --- a/src/friend_area_action_menu_1.c +++ b/src/friend_area_action_menu_1.c @@ -24,7 +24,7 @@ extern void nullsub_104(); extern void sub_8091274(u8 *); extern void sub_801A928(); extern void sub_8099690(u32); -extern void sub_808D800(s16, struct HeldItem *); +extern void GivePokemonItem(s16, struct HeldItem *); extern u32 sub_801A8AC(); extern u32 sub_801A6E8(u32); @@ -96,7 +96,7 @@ void sub_8027BD8(void) if (gUnknown_203B2BC->unk14 != 0) { sub_8091274(&gUnknown_203B2BC->unk14); } - sub_808D800(gUnknown_203B2BC->unk8,&gUnknown_203B2BC->unk10); + GivePokemonItem(gUnknown_203B2BC->unk8,&gUnknown_203B2BC->unk10); sub_801A928(); nullsub_104(); sub_8027184(2); diff --git a/src/items.c b/src/items.c index fb0304f..337e622 100644 --- a/src/items.c +++ b/src/items.c @@ -879,8 +879,8 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s a4->unk2 = boost_flags; boost_flags = a4->unk2; if (a4->unk2 & 1) { - if (pokemon->pokeAtt < 255) { - pokemon->pokeAtt++; + if (pokemon->offense.att[OFFENSE_NRM] < 255) { + pokemon->offense.att[OFFENSE_NRM]++; } else { // fix operand order @@ -890,24 +890,24 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s } } if (a4->unk2 & 2) { - if (pokemon->pokeSPAtt < 255) { - pokemon->pokeSPAtt++; + if (pokemon->offense.att[OFFENSE_SP] < 255) { + pokemon->offense.att[OFFENSE_SP]++; } else { a4->unk2 &= ~2; } } if (a4->unk2 & 4) { - if (pokemon->pokeDef < 255) { - pokemon->pokeDef++; + if (pokemon->offense.def[OFFENSE_NRM] < 255) { + pokemon->offense.def[OFFENSE_NRM]++; } else { a4->unk2 &= ~4; } } if (a4->unk2 & 8) { - if (pokemon->pokeSPDef < 255) { - pokemon->pokeSPDef++; + if (pokemon->offense.def[OFFENSE_SP] < 255) { + pokemon->offense.def[OFFENSE_SP] ++; } else { a4->unk2 &= ~8; diff --git a/src/pokemon.c b/src/pokemon.c index 263e482..a9ca120 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2,6 +2,7 @@ #include "pokemon.h" #include "file_system.h" + extern struct FileArchive gSystemFileArchive; extern const char gUnknown_81075F4; EWRAM_DATA struct gPokemon *gMonsterParameters; @@ -10,6 +11,7 @@ EWRAM_DATA struct unkStruct_203B45C gRecruitedPokemon; extern struct unkStruct_203B45C *gRecruitedPokemonRef; EWRAM_DATA u16 gLevelCurrentPokeId; + void LoadMonsterParameters(void) { gRecruitedPokemonRef = &gRecruitedPokemon; @@ -39,7 +41,7 @@ void InitializeRecruitedPokemon(void) for(iVar3 = 0; iVar3 < 4; iVar3++) { - gRecruitedPokemonRef->pokemon3[iVar3].unk8 = 0; - gRecruitedPokemonRef->pokemon3[iVar3].unk0 = 0; + gRecruitedPokemonRef->team[iVar3].speciesNum = 0; + gRecruitedPokemonRef->team[iVar3].unk0 = 0; } } diff --git a/src/pokemon_1.c b/src/pokemon_1.c deleted file mode 100644 index 8966ce7..0000000 --- a/src/pokemon_1.c +++ /dev/null @@ -1,200 +0,0 @@ -#include "global.h" -#include "pokemon.h" -#include "file_system.h" - -extern int sprintf(char *, const char *, ...); - -extern struct gPokemon *gMonsterParameters; -extern struct FileArchive gMonsterFileArchive; -extern const char gUnknown_8107684[]; -extern struct unkStruct_203B45C *gRecruitedPokemonRef; - -extern void sub_808DE50(void* r0, struct PokemonStruct *r1, u32 r2, u32 r3); - - -u8 *GetCategoryString(s16 index) -{ - return gMonsterParameters[index].category; -} - -u8 GetPokemonSize(s16 index) -{ - return gMonsterParameters[index].size; -} - -u8 GetShadowSize(s16 index) -{ - return gMonsterParameters[index].shadow_size; -} - -s32 GetMoveSpeed(s16 index) -{ - return gMonsterParameters[index].move_speed; -} - -u8 GetWalkableTiles(s16 index) -{ - return gMonsterParameters[index].walkable_tiles; -} - -u8 GetUnk1B(s16 index) -{ - return ((u8)(gMonsterParameters[index].unk1B) << 25) >> 24; -} - -bool8 GetIsMoving(s16 index) -{ - return gMonsterParameters[index].isMoving; -} - -u8 GetUnk1D(s16 index) -{ - return gMonsterParameters[index].unk1D; -} - -u16 GetLowKickDmg(s16 index) -{ - return gMonsterParameters[index].lowkick_dmg; -} - -u16 GetSizeOrbDmg(s16 index) -{ - return gMonsterParameters[index].sizeorb_dmg; -} - -u8 GetFriendArea(s16 index) -{ - return gMonsterParameters[index].friend_area; -} - -u16 GetBaseHP(s16 index) -{ - return gMonsterParameters[index].base_hp; -} - -bool8 GetUnk33(s16 index) -{ - return gMonsterParameters[index].unk33; -} - -u8 GetUnk12(s16 index) -{ - return gMonsterParameters[index].unk12; -} - -s16 GetPokemonEvolveFrom(s16 index) -{ - return gMonsterParameters[index].pre.evolve_from; -} - -u16 GetPokemonAttSpatt(s16 index, u32 r1) -{ - return gMonsterParameters[index].base_att_spatt[r1]; -} - -u16 GetPokemonDefSpdef(s16 index, u32 r1) -{ - return gMonsterParameters[index].base_def_spdef[r1]; -} - -u8 GetPokemonType(s32 index, u32 typeIndex) -{ - s16 newIndex = index; - return gMonsterParameters[newIndex].types[typeIndex]; -} - -u8 GetPokemonAbility(s16 index, u32 abilityIndex) -{ - return gMonsterParameters[index].abilities[abilityIndex]; -} - -s16 GetDexInternalNo(s16 index, u32 r1) -{ - return gMonsterParameters[index].dexInternal[r1]; -} - -s16 GetBaseRecruit(s16 index) -{ - return gMonsterParameters[index].base_recruit; -} - -s16 GetAlphabetParentNo(s16 index, s32 r1) -{ - return gMonsterParameters[index].alphabetParent[r1]; -} - - -s16 GetInternalNo(s16 index) -{ - return gMonsterParameters[index].dexInternal[1]; -} - -s32 CalculateEXPGain(s16 index, s32 level) -{ - s32 baseEXP = gMonsterParameters[index].base_exp; - return baseEXP + (baseEXP * (level - 1)) / 10; -} - -s16 GetPokemonEvolveConditions(s16 index, struct unkEvolve *r1) -{ - struct EvolveStruct1 temp2; - struct EvolveNeeds temp1; - temp1 = gMonsterParameters[index].need; - temp2 = gMonsterParameters[index].pre; - r1->conditions = temp2; - r1->needs = temp1; - // The return value is not used anywhere, but necessary for the function to match. - return index; -} - -u8 GetPokemonOverworldPalette(s16 index, u32 r1) -{ - // Had to have this cast to match - u32 temp; - temp = index; - if (r1 != 0) - { - return 10; - } - else - { - return gMonsterParameters[temp].overworld_palette; - } -} - -struct OpenedFile *OpenPokemonDialogueSpriteFile(s16 index) -{ - // Looks like this loads the dialogue sprite for the pokemon - - char buffer[0xC]; - if(gMonsterParameters[index].dialogue_sprites == 0) - { - return NULL; - } - sprintf(buffer, gUnknown_8107684, index); // "kao%03d" - return OpenFile(buffer, &gMonsterFileArchive); -} - -struct OpenedFile *GetDialogueSpriteDataPtr(s16 index) -{ - // Looks like this loads the dialogue sprite for the pokemon - - char buffer[0xC]; - if(gMonsterParameters[index].dialogue_sprites == 0) - { - return NULL; - } - sprintf(buffer, gUnknown_8107684, index); // "kao%03d" - return OpenFileAndGetFileDataPtr(buffer, &gMonsterFileArchive); -} - -bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 r1) -{ - // checking to see if dialogue sprite is available?? - return (gMonsterParameters[index].dialogue_sprites >> r1) & 1; -} - -void sub_808DE30(void* r0, u32 r1) -{ - sub_808DE50(r0, &gRecruitedPokemonRef->pokemon[r1], r1, r1 * sizeof(struct PokemonStruct)); -} diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 62e60d8..72005ed 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1,5 +1,6 @@ #include "global.h" #include "pokemon.h" +#include "random.h" extern u32 gIQSkillNames[]; extern u32 gIQSkillDescriptions[]; @@ -10,6 +11,7 @@ extern u8 gUnknown_810A36B[]; extern s16 gUnknown_810A378[]; extern s32 gUnknown_810A390[]; extern u32 gUnknown_81076E4[]; +extern struct unkStruct_203B45C *gRecruitedPokemonRef; struct unkStruct_808E9EC { @@ -22,15 +24,185 @@ struct unkStruct_808E9EC u8 unk12; u8 unk13; }; +extern u32 gUnknown_81076C4[]; +struct unkStruct_202F3E8 +{ + u16 unk0; + u16 unk2; + u16 unk4; + u16 unk6; +}; + +extern struct unkStruct_202F3E8 gUnknown_202F3E8[]; extern s16 gUnknown_810AC60; // 0xC extern s16 gUnknown_810AC62; // 0xC extern s16 gUnknown_810AC68; // 0x8 extern s16 gUnknown_810AC64; // 0x8 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 void AddSprite(u16 *, u32, u32, u32); + + +bool8 sub_808E668(s16 a1, s16* a2, s16* a3) +{ + u32 shifted = a1 << 16; + + if (((shifted - 0x320000) >> 16) > 1) { + u8 shadow_size = GetShadowSize(a1); + u32 unk2, unk6; + struct unkStruct_202F3E8* arg0; + + unk2 = a2[0] + a3[8]; + unk6 = a2[1] + a3[9]; + unk2 += gUnknown_81076C4[shadow_size]; + unk6 -= 4; + unk2 &= 0x1ff; + + arg0 = &gUnknown_202F3E8[shadow_size]; + arg0->unk2 = (arg0->unk2 & 0xfe00) | unk2; + unk6 &= 0xfff; + unk6 <<= 4; + arg0->unk6 = (arg0->unk6 & 0xf) | unk6; + AddSprite((u16*)arg0, 0, 0, 0); + } + return 1; +} + + +void sub_808E6F4(struct unkStruct_808E6F4* a1) +{ + s32 i; + + a1->unk0 = gUnknown_810AC90[RandomCapped(10)]; + for (i = 0; i < 100; i++) { + a1->unk2 = RandomCapped(18); + if ( a1->unk2 ) + break; + } + if ( i == 100 ) + a1->unk2 = 2; +} + +bool8 HasRecruitedMon(s16 species_) { + s32 species = species_; + s32 i = 0; + struct PokemonStruct *pokemon = gRecruitedPokemonRef->pokemon; + + for (i = 0; i < 413; i++) { + if (((u8)pokemon->unk0 & 1)) { + if(pokemon->speciesNum == species) + return TRUE; + } + pokemon++; + } + return FALSE; +} + +s32 GetBaseSpecies(s16 index) { + if (index == SPECIES_CASTFORM_SNOWY) + return SPECIES_CASTFORM; + if (index == SPECIES_CASTFORM_SUNNY) + return SPECIES_CASTFORM; + if (index == SPECIES_CASTFORM_RAINY) + return SPECIES_CASTFORM; + if(index == SPECIES_UNOWN_B) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_C) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_D) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_E) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_F) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_G) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_H) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_I) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_J) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_K) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_L) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_M) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_N) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_O) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_P) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_Q) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_R) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_S) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_T) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_U) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_V) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_W) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_X) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_Y) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_Z) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_EMARK) + return SPECIES_UNOWN; + if(index == SPECIES_UNOWN_QMARK) + return SPECIES_UNOWN; + if (index == SPECIES_DEOXYS_ATTACK) + return SPECIES_DEOXYS_NORMAL; + if (index == SPECIES_DEOXYS_DEFENSE) + return SPECIES_DEOXYS_NORMAL; + if (index == SPECIES_DEOXYS_SPEED) + return SPECIES_DEOXYS_NORMAL; + if (index == SPECIES_RAYQUAZA_CUTSCENE) + return SPECIES_RAYQUAZA; + + return index; +} + +s32 GetBaseSpeciesNoUnown(s16 index) { + register s32 a1_ asm("r2") = index; + if (index == SPECIES_CASTFORM_SNOWY) { + return SPECIES_CASTFORM; + } + if (index == SPECIES_CASTFORM_SUNNY) { + return SPECIES_CASTFORM; + } + if (index == SPECIES_CASTFORM_RAINY) { + return SPECIES_CASTFORM; + } + if (index == SPECIES_DEOXYS_ATTACK) { + return SPECIES_DEOXYS_NORMAL; + } + if (index == SPECIES_DEOXYS_DEFENSE) { + return SPECIES_DEOXYS_NORMAL; + } + if (index == SPECIES_DEOXYS_SPEED) { + return SPECIES_DEOXYS_NORMAL; + } + // these last 2 use r2 instead of just r0 + if (a1_ == SPECIES_RAYQUAZA_CUTSCENE) { + return SPECIES_RAYQUAZA; + } + return a1_; +} s32 GetUnownIndex(s16 index) { @@ -452,3 +624,20 @@ u32 sub_808ECFC(void) { return 0; } + +extern s32 sub_808D580(s32*); + +void sub_808ED00() { + s32 team[4]; + s32 i; + s32 length = sub_808D580(team); + + for (i = 0; i < length; i++) { + gRecruitedPokemonRef->team[i] = gRecruitedPokemonRef->pokemon[team[i]]; + } + + for (; i < 4; i++) { + gRecruitedPokemonRef->team[i].unk0 = 0; + } +} + diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c index d297ca0..56d49fe 100644 --- a/src/pokemon_mid.c +++ b/src/pokemon_mid.c @@ -1,5 +1,7 @@ #include "global.h" #include "pokemon.h" +#include "item.h" +#include "file_system.h" extern struct gPokemon *gMonsterParameters; extern const char gUnknown_8107600[]; @@ -8,12 +10,124 @@ extern const char gUnownLetters[]; extern const char gUnknown_8107630[]; extern const char gUnknown_8107638[]; extern const char gUnknown_810763C[]; +extern const char gUnknown_810768C[]; // lvmp%03d\0 +extern struct FileArchive gSystemFileArchive; +extern s16 gUnknown_810ACB8; // 0x14d +extern s16 gUnknown_810ACBA; // 0x14d +extern s16 gUnknown_810ACBC; // 0x14d +extern s16 gUnknown_810ACBE; // 0x14d + +// wram data: +extern u16 gLevelCurrentPokeId; +extern struct LevelData gLevelCurrentData[]; + extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *r2, ...); -extern s16 sub_808E770(u32); +extern s16 GetBaseSpecies(u32); extern void sub_80922B4(u8 *, u8 *, s32); +extern int sprintf(char *, const char *, ...); +extern u32 ReturnIntFromChar(u8 r0); +extern void CopyStringtoBuffer(char *r0, char *r1); +extern void sub_8093F50(void*, void*); +extern void sub_80943A0(void*, s32); +extern void xxx_unk_to_pokemonstruct_808DF44(struct PokemonStruct*, struct unkStruct_808DE50*); +extern u8* sub_8092B18(s16); +extern u8* sub_808E07C(u8* a1, u16* a2); +extern u8* sub_8092B54(s32); -extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *r2, ...); +struct unkStruct_8107654 { + s16 unk0; + s16 fill2; + s32 unk4; +}; + +extern u8 gUnknown_8107645[12]; +extern struct unkStruct_8107654 gUnknown_8107654[6]; +extern struct gPokemon *gMonsterParameters; +extern struct FileArchive gMonsterFileArchive; +extern const char gUnknown_8107684[]; +extern struct unkStruct_203B45C *gRecruitedPokemonRef; + +// bool8 sub_808D750(s16 index_) { +// s32 i; +// register s32 index asm("r8") = index_; +// s32 count = 0; +// s32 size_count = 0; + +// for (i = 0; i < 413; i++) { +// register struct PokemonStruct* pokemon = &i[gRecruitedPokemonRef->pokemon]; +// register u16 unk0 = pokemon->unk0; +// if ((unk0 & 1) && ((pokemon->unk0 >> 1) & 1)) { +// size_count += GetPokemonSize(pokemon->speciesNum); +// count++; +// } +// } + +// if (count < 4) { +// struct PokemonStruct* pokemon; + +// pokemon = &gRecruitedPokemonRef->pokemon[index]; + +// size_count += GetPokemonSize(pokemon->speciesNum); +// if (size_count < 7) { +// return TRUE; +// } +// } +// return FALSE; +// } + + +void PeekPokemonItem(s16 index_, struct HeldItem* item) { + s32 index = index_; + struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[index]; + item->itemIndex = pokemon->heldItem.itemIndex; + item->numItems = pokemon->heldItem.numItems; +} + +void GivePokemonItem(s16 index_, struct HeldItem* item) { + s32 index = index_; + struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[index]; + pokemon->heldItem.itemIndex = item->itemIndex; + pokemon->heldItem.numItems = item->numItems; +} + +bool8 IsPokemonRenamed(struct PokemonStruct* pokemon) { + char species_name[20]; + char* species = GetMonSpecies(pokemon->speciesNum); + s32 i; + CopyStringtoBuffer(species_name, species); + for (i = 0; i < 10; i++) { + if (pokemon->name[i] != species_name[i]) { + return FALSE; + } + if (!pokemon->name[i]) { + return TRUE; + } + } + return TRUE; +} + +bool8 ComparePokemonNames(s16 a1, s16 a2) { + s32 index1 = a1; + s32 index2 = a2; + u8* name1 = gRecruitedPokemonRef->pokemon[index1].name; + u8* name2 = gRecruitedPokemonRef->pokemon[index2].name; + + s32 i; + for (i = 0; i < 10; i++) { + s32 c1 = ReturnIntFromChar(*name1); + s32 c2 = ReturnIntFromChar(*name2); + if (c1 > c2) { + return TRUE; + } + if (c1 < c2) { + return FALSE; + } + name1++; + name2++; + } + return FALSE; +} void CopySpeciesNametoBuffer(u8 * buffer, s16 index) { @@ -40,7 +154,7 @@ void sub_808D930(u8 *buffer, s16 index) const char *preload; newIndex = index; - if (sub_808E770(newIndex) == SPECIES_UNOWN) { + if (GetBaseSpecies(newIndex) == SPECIES_UNOWN) { preload = gUnknown_8107630; // %s%c unownString = GetMonSpecies(SPECIES_UNOWN); unownIndex = GetUnownIndex(newIndex); @@ -90,3 +204,570 @@ void sub_808DA34(u8 *buffer, struct PokemonStruct *pokemon) { sub_80922B4(buffer, pokemon->name, 10); } + +bool8 sub_808DA44(s32 a1_, u32 a2_) +{ + // this is the dumbest thing ever, but just making a1 a s16 and + // a2 a u8 did weird stuff with shifting... + s32 a1 = (s16)a1_; + u32 a2 = (u8)a2_; + if (a2 > 0xc) { + s32 i; + struct unkStruct_8107654 data[6]; + memcpy(data, gUnknown_8107654, 6 * sizeof(struct unkStruct_8107654)); + + for (i = 0; i < 10 && data[i].unk0; i++) { + if (data[i].unk0 == a1 && data[i].unk4 == a2) { + return 1; + } + } + return 0; + } + else { + return gUnknown_8107645[a2]; + } +} + +u8 *GetCategoryString(s16 index) +{ + return gMonsterParameters[index].category; +} + +u8 GetPokemonSize(s16 index) +{ + return gMonsterParameters[index].size; +} + +u8 GetShadowSize(s16 index) +{ + return gMonsterParameters[index].shadow_size; +} + +s32 GetMoveSpeed(s16 index) +{ + return gMonsterParameters[index].move_speed; +} + +u8 GetWalkableTiles(s16 index) +{ + return gMonsterParameters[index].walkable_tiles; +} + +u8 GetUnk1B(s16 index) +{ + return ((u8)(gMonsterParameters[index].unk1B) << 25) >> 24; +} + +bool8 GetIsMoving(s16 index) +{ + return gMonsterParameters[index].isMoving; +} + +u8 GetUnk1D(s16 index) +{ + return gMonsterParameters[index].unk1D; +} + +u16 GetLowKickDmg(s16 index) +{ + return gMonsterParameters[index].lowkick_dmg; +} + +u16 GetSizeOrbDmg(s16 index) +{ + return gMonsterParameters[index].sizeorb_dmg; +} + +u8 GetFriendArea(s16 index) +{ + return gMonsterParameters[index].friend_area; +} + +u16 GetBaseHP(s16 index) +{ + return gMonsterParameters[index].base_hp; +} + +bool8 GetUnk33(s16 index) +{ + return gMonsterParameters[index].unk33; +} + +u8 GetUnk12(s16 index) +{ + return gMonsterParameters[index].unk12; +} + +s16 GetPokemonEvolveFrom(s16 index) +{ + return gMonsterParameters[index].pre.evolve_from; +} + +u16 GetPokemonAttSpatt(s16 index, u32 r1) +{ + return gMonsterParameters[index].base_att_spatt[r1]; +} + +u16 GetPokemonDefSpdef(s16 index, u32 r1) +{ + return gMonsterParameters[index].base_def_spdef[r1]; +} + +u8 GetPokemonType(s32 index, u32 typeIndex) +{ + s16 newIndex = index; + return gMonsterParameters[newIndex].types[typeIndex]; +} + +u8 GetPokemonAbility(s16 index, u32 abilityIndex) +{ + return gMonsterParameters[index].abilities[abilityIndex]; +} + +s16 GetDexInternalNo(s16 index, u32 r1) +{ + return gMonsterParameters[index].dexInternal[r1]; +} + +s16 GetBaseRecruit(s16 index) +{ + return gMonsterParameters[index].base_recruit; +} + +s16 GetAlphabetParentNo(s16 index, s32 r1) +{ + return gMonsterParameters[index].alphabetParent[r1]; +} + + +s16 GetInternalNo(s16 index) +{ + return gMonsterParameters[index].dexInternal[1]; +} + +s32 CalculateEXPGain(s16 index, s32 level) +{ + s32 baseEXP = gMonsterParameters[index].base_exp; + return baseEXP + (baseEXP * (level - 1)) / 10; +} + +s16 GetPokemonEvolveConditions(s16 index, struct unkEvolve *r1) +{ + struct EvolveStruct1 temp2; + struct EvolveNeeds temp1; + temp1 = gMonsterParameters[index].need; + temp2 = gMonsterParameters[index].pre; + r1->conditions = temp2; + r1->needs = temp1; + // The return value is not used anywhere, but necessary for the function to match. + return index; +} + +u8 GetPokemonOverworldPalette(s16 index, u32 r1) +{ + // Had to have this cast to match + u32 temp; + temp = index; + if (r1 != 0) + { + return 10; + } + else + { + return gMonsterParameters[temp].overworld_palette; + } +} + +struct OpenedFile *OpenPokemonDialogueSpriteFile(s16 index) +{ + // Looks like this loads the dialogue sprite for the pokemon + + char buffer[0xC]; + if(gMonsterParameters[index].dialogue_sprites == 0) + { + return NULL; + } + sprintf(buffer, gUnknown_8107684, index); // "kao%03d" + return OpenFile(buffer, &gMonsterFileArchive); +} + +struct OpenedFile *GetDialogueSpriteDataPtr(s16 index) +{ + // Looks like this loads the dialogue sprite for the pokemon + + char buffer[0xC]; + if(gMonsterParameters[index].dialogue_sprites == 0) + { + return NULL; + } + sprintf(buffer, gUnknown_8107684, index); // "kao%03d" + return OpenFileAndGetFileDataPtr(buffer, &gMonsterFileArchive); +} + +bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 r1) +{ + // checking to see if dialogue sprite is available?? + return (gMonsterParameters[index].dialogue_sprites >> r1) & 1; +} + +void xxx_pokemonstruct_index_to_unk_808DE30(void* r0, u32 r1) +{ + xxx_pokemonstruct_to_unk_808DE50(r0, &gRecruitedPokemonRef->pokemon[r1], r1); +} + +void xxx_pokemonstruct_to_unk_808DE50(struct unkStruct_808DE50 * a1, struct PokemonStruct *pokemon, s32 a3) +{ + s32 i; + struct HeldItem* held; + struct ItemSlot* slot; + u32 somestruct_80943A0; + u32 somestruct2_80943A0; + + a1->unk0 = pokemon->unk0; + a1->unkHasNextStage = pokemon->unkHasNextStage; + a1->IQ = pokemon->IQ; + a1->unk4C = pokemon->unk20; + sub_808E6F4(&a1->unk54); + a1->unk4 = pokemon->unk4; + a1->unk2 = pokemon->unk2; + a1->unkA = a3; + a1->speciesNum = pokemon->speciesNum; + a1->unk50 = pokemon->unk24; + a1->unk12 = pokemon->pokeHP; + a1->unk10 = pokemon->pokeHP; + + for (i = 0; i < 2; i++) { + a1->offense.att[i] = pokemon->offense.att[i]; + a1->offense.def[i] = pokemon->offense.def[i]; + } + + a1->unk18 = pokemon->unk1C; + sub_8093F50(&a1->unk1C, &pokemon->unk2C); + + for (i = 0; i < 10; i++) { + a1->name[i] = pokemon->name[i]; + } + + held = &pokemon->heldItem; + slot = &a1->itemSlot; + + if ((u32)(-held->itemIndex | held->itemIndex) >> 31) { + HeldItemToSlot(slot, held); + } + else { + slot->itemIndex = 0; + slot->numItems = 0; + slot->unk0 = 0; + } + sub_80943A0(&somestruct_80943A0, 100); + a1->unk44 = somestruct_80943A0; + sub_80943A0(&somestruct2_80943A0, 100); + a1->unk48 = somestruct2_80943A0; +} + +void xxx_unk_to_pokemonstruct_index_808DF2C(s32 a1, struct unkStruct_808DE50* a2) +{ + xxx_unk_to_pokemonstruct_808DF44(&a1[gRecruitedPokemonRef->pokemon], a2); +} + +extern void sub_8093FA8(struct unkPokeSubStruct_2C*, struct unkPokeSubStruct_2C*); + + +void xxx_unk_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct unkStruct_808DE50* a2) +{ + s32 i; + + pokemon->unk0 = a2->unk0; + pokemon->unkHasNextStage = a2->unkHasNextStage; + pokemon->IQ = a2->IQ; + pokemon->unk20 = a2->unk4C; + pokemon->unk4 = a2->unk4; + pokemon->unk2 = a2->unk2; + pokemon->speciesNum = a2->speciesNum; + pokemon->unk24 = a2->unk50; + pokemon->pokeHP = a2->unk12; + + for (i = 0; i < 2; i++) { + pokemon->offense.att[i] = a2->offense.att[i]; + pokemon->offense.def[i] = a2->offense.def[i]; + } + + pokemon->unk1C = a2->unk18; + sub_8093FA8(pokemon->unk2C, a2->unk1C); + + for (i = 0; i < 10; i++) { + pokemon->name[i] = a2->name[i]; + } + + if (a2->itemSlot.unk0 & 1) { + SlotToHeldItem(&pokemon->heldItem, &a2->itemSlot); + } + else { + pokemon->heldItem.itemIndex = 0; + } +} + +void sub_808DFDC(s32 a1, struct unkStruct_808DE50* a2) +{ + // transfer item from unk to pokemon at index + struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[a1]; + if (a2->itemSlot.unk0 & 1) { + SlotToHeldItem(&pokemon->heldItem, &a2->itemSlot); + } + else { + pokemon->heldItem.itemIndex = 0; + } +} + +void GetPokemonLevelData(struct LevelData* a1, s16 _id, s32 a3) +{ + u8 buffer[12]; + s32 id = _id; + + if ((s16)gLevelCurrentPokeId != id) + { + struct OpenedFile *file; + + gLevelCurrentPokeId = id; + // lvmp%03d\0 + sprintf(buffer, gUnknown_810768C, id); + file = OpenFileAndGetFileDataPtr(buffer, &gSystemFileArchive); + DecompressATFile((char*)gLevelCurrentData, 0, file); + CloseFile(file); + } + a3 -= 1; + if ( a3 < 0 ) + a3 = 0; + + *a1 = gLevelCurrentData[a3]; +} + +u8* sub_808E07C(u8* a1, u16* a2) +{ + u32 r1 = *a1++; + u32 r3; + if (r1 & 0x80) { + r3 = *a1++; + } + else { + r3 = r1; + r1 = 0; + } +#ifdef NONMATCHING + // wrong order + r1 &= 0x7f; + r3 &= 0x7f; + *a2 = (r1 << 7) | r3; +#else + { + register u32 mask asm("r0") = 0x7f; + r3 &= mask; + r1 &= mask; + *a2 = (r1 << 7) | r3; + } +#endif + return a1; +} + +s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 a4) +{ + u8* stream; + u16 result; // struct? + s32 count; + register s32 _species asm("r2"); // weird regalloc + + _species = (s16)species; + count = 0; + + if (species == SPECIES_DECOY) return 0; + if (species == SPECIES_NONE) return 0; + if (species == SPECIES_MUNCHLAX) return 0; + // get stream + stream = sub_8092B18(_species); + + while (*stream) + { + u8 v12; + + // read from stream + stream = sub_808E07C(stream, &result); + v12 = *stream++; + + if (v12 > a3) + break; + if (v12 == a3) { + bool8 cond = 1; + // I don't think these are species IDs + // the pokemon they would correspond to are pretty random if they are + // shuckle, heracross, pupitar, vibrava + if ((result == 238) && (a4 < gUnknown_810ACB8)) cond = 0; + if ((result == 239) && (a4 < gUnknown_810ACBA)) cond = 0; + if ((result == 272) && (a4 < gUnknown_810ACBC)) cond = 0; + if ((result == 354) && (a4 < gUnknown_810ACBE)) cond = 0; + + if (cond) { + if (count < 16) { + *a1++ = result; + ++count; + } + } + } + } + return count; +} + +bool8 sub_808E190(u16 a1, s16 _species) +{ + u16 result; + u16 result2; + s32 species = _species; // r4 + u8* ptr; + + if (species == SPECIES_DECOY) return 0; + if (species == SPECIES_NONE) return 0; + if (species == SPECIES_MUNCHLAX) return 0; + if (a1 == 352) return 0; + + ptr = sub_8092B18(species); + while (*ptr) { + ptr = sub_808E07C(ptr, &result); + ptr++; + if (a1 == result) { + return 1; + } + } + + ptr = sub_8092B54(species); + while (*ptr) { + ptr = sub_808E07C(ptr, &result2); + if (result2 == a1) { + return 1; + } + } + return 0; +} + + +s32 sub_808E218(struct unkStruct_808E218_arg* a1, struct PokemonStruct* pokemon) +{ + s32 i; + s32 count; + struct EvolveStage evolve_sequence[3]; + s32 sequence_length; + + count = 0; + a1->count = 0; + if (pokemon->speciesNum == SPECIES_DECOY) return 0; + if (pokemon->speciesNum == SPECIES_NONE) return 0; + if (pokemon->speciesNum == SPECIES_MUNCHLAX) return 0; + + sequence_length = GetEvolutionSequence(pokemon, evolve_sequence); + for (i = 0; i < sequence_length; i++) { + u8* ptr; + u16 result; + + ptr = sub_8092B18(evolve_sequence[i].speciesNum); + while (*ptr) { + s32 value; + ptr = sub_808E07C(ptr, &result); + value = *ptr++; + + if (value > evolve_sequence[i].unkHasNextStage) { + break; + } + + if (count < NUM_SPECIES) { + s32 j; + bool8 cond = 1; + // I don't think these are species IDs + // the pokemon they would correspond to are pretty random if they are + // shuckle, heracross, pupitar, vibrava + if ((result == 238) && (pokemon->IQ < gUnknown_810ACB8)) cond = 0; + if ((result == 239) && (pokemon->IQ < gUnknown_810ACBA)) cond = 0; + if ((result == 272) && (pokemon->IQ < gUnknown_810ACBC)) cond = 0; + if ((result == 354) && (pokemon->IQ < gUnknown_810ACBE)) cond = 0; + + for (j = 0; j < 4; j++) { + if ((pokemon->unk2C[j].unk0 & 1) && pokemon->unk2C[j].unk2 == result) { + cond = 0; + } + } + + if (cond) { + s32 k; + for (k = 0; k < count && a1->unk0[k] != result; k++) {} + + if (k == count) { + a1->unk0[count++] = result; + } + } + } + } + } + + a1->count = count; + return count; +} + + +s32 GetEvolutionSequence(struct PokemonStruct* pokemon, struct EvolveStage* a2) +{ +#ifdef NONMATCHING + s32 count; + s32 species; + s32 i; + + a2[0].specesNum = pokemon->speciesNum; + a2[0].unkHasNextStage = pokemon->unkHasNextStage; + + count = 1; + species = pokemon->speciesNum; + i = 0; + + for (; i < 2; i++) { + if (!pokemon->unkC[i].unk0) { + break; + } + species = GetPokemonEvolveFrom(species); + if (!species) { + break; + } + a2[1 + i].speciesNum = species; + a2[1 + i].unkHasNextStage = pokemon->unkC[i].unk0; + // wrong increment order: + count++; + } + return count; +#else + s32 count; + s32 species; + s32 i; + struct EvolveStage* stage; + struct unkPokeSubStruct_C* has_next_stage; + + a2[0].speciesNum = pokemon->speciesNum; + a2[0].unkHasNextStage = pokemon->unkHasNextStage; + + count = 1; + species = pokemon->speciesNum; + i = 0; + has_next_stage = pokemon->unkC; + stage = &a2[1]; + + for (; i < 2; i++) { + if (!has_next_stage->unk0) { + break; + } + species = GetPokemonEvolveFrom(species); + if (!species) { + break; + } + stage->speciesNum = species; + stage->unkHasNextStage = has_next_stage->unk0; + stage++; + count++; + has_next_stage++; + } + return count; +#endif +}
\ No newline at end of file |