diff options
author | Marcus Huderle <huderlem@gmail.com> | 2018-12-15 18:06:42 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-15 18:06:42 -0600 |
commit | fb9a365dc6ddfebde03ac1ea3e770b30dbb5dbf2 (patch) | |
tree | 0960d1d78a4c4b758008cf7fbcab8048d1c371de | |
parent | 1ca3656d74faf8565e0f61b31a1cd3ab22a44706 (diff) | |
parent | 1d09216e4b776ed03daa83c66fd6600bc43f8d25 (diff) |
Merge pull request #448 from Meowsy/pokedex-documentation
Pokedex Documentation
-rw-r--r-- | asm/trade.s | 16 | ||||
-rw-r--r-- | include/global.h | 2 | ||||
-rw-r--r-- | include/pokedex.h | 11 | ||||
-rw-r--r-- | include/pokemon.h | 2 | ||||
-rw-r--r-- | src/birch_pc.c | 14 | ||||
-rw-r--r-- | src/credits.c | 12 | ||||
-rw-r--r-- | src/event_data.c | 3 | ||||
-rw-r--r-- | src/pokedex.c | 164 | ||||
-rw-r--r-- | src/pokemon.c | 18 | ||||
-rwxr-xr-x | src/script_pokemon_util_80F87D8.c | 4 | ||||
-rw-r--r-- | src/tv.c | 4 |
11 files changed, 127 insertions, 123 deletions
diff --git a/asm/trade.s b/asm/trade.s index 341aa0869..a583e4319 100644 --- a/asm/trade.s +++ b/asm/trade.s @@ -3590,7 +3590,7 @@ _08079138: cmp r0, 0 bne _08079158 adds r0, r4, 0 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _08079164 _08079158: @@ -6160,7 +6160,7 @@ _0807A62E: _0807A64C: lsls r0, r1, 16 lsrs r0, 16 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _0807A65C movs r0, 0x2 @@ -6200,7 +6200,7 @@ _0807A65C: _0807A6A0: lsls r0, r1, 16 lsrs r0, 16 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 beq _0807A6D2 _0807A6AC: @@ -6471,7 +6471,7 @@ _0807A87C: b _0807A8C0 _0807A88E: adds r0, r7, 0 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _0807A89C _0807A898: @@ -6479,7 +6479,7 @@ _0807A898: b _0807A8C0 _0807A89C: mov r0, r8 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _0807A8AA movs r0, 0x5 @@ -6489,7 +6489,7 @@ _0807A8AA: cmp r0, 0 bne _0807A8BE adds r0, r7, 0 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _0807A8BE movs r0, 0x7 @@ -6533,7 +6533,7 @@ sub_807A8D0: @ 807A8D0 b _0807A910 _0807A900: adds r0, r6, 0 - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _0807A90E _0807A90A: @@ -6645,7 +6645,7 @@ _0807A9B4: mov r1, sp adds r4, r1, r0 ldrh r0, [r4] - bl sub_806E3F8 + bl IsSpeciesInHoennDex cmp r0, 0 bne _0807A9E0 movs r0, 0x2 diff --git a/include/global.h b/include/global.h index 3aee597de..e3792ac56 100644 --- a/include/global.h +++ b/include/global.h @@ -236,7 +236,7 @@ struct Time struct Pokedex { /*0x00*/ u8 order; - /*0x01*/ u8 unknown1; + /*0x01*/ u8 mode; /*0x02*/ u8 nationalMagic; // must equal 0xDA in order to have National mode /*0x03*/ u8 unknown2; /*0x04*/ u32 unownPersonality; // set when you first see Unown diff --git a/include/pokedex.h b/include/pokedex.h index 3f90e9508..b6d323fd3 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -4,6 +4,15 @@ extern u8 gUnknown_030060B0; extern void (*gUnknown_030060B4)(void); +#define HOENN_DEX_COUNT 202 +#define NATIONAL_DEX_COUNT 386 + +enum +{ + DEX_MODE_HOENN, + DEX_MODE_NATIONAL +}; + enum { FLAG_GET_SEEN, @@ -31,6 +40,6 @@ u16 GetNationalPokedexCount(u8); u16 GetHoennPokedexCount(u8); u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality); s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); -u16 sub_80C0E9C(u16, s16, s16, u16); +u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16); #endif // GUARD_POKEDEX_H diff --git a/include/pokemon.h b/include/pokemon.h index 1d9fbf0ee..94dae089f 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -566,7 +566,7 @@ u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves); u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves); u8 GetNumberOfRelearnableMoves(struct Pokemon *mon); u16 SpeciesToPokedexNum(u16 species); -bool32 sub_806E3F8(u16 species); +bool32 IsSpeciesInHoennDex(u16 species); void ClearBattleMonForms(void); u16 GetBattleBGM(void); void PlayBattleBGM(void); diff --git a/src/birch_pc.c b/src/birch_pc.c index 3148832be..5179b1920 100644 --- a/src/birch_pc.c +++ b/src/birch_pc.c @@ -66,20 +66,20 @@ const u8 *GetPokedexRatingText(u16 count) return gBirchDexRatingText_LessThan200; if (count == 200) { - if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) - || GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200. + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), FLAG_GET_CAUGHT) + || GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), FLAG_GET_CAUGHT)) // Jirachi or Deoxys is not counted towards the dex completion. If either of these flags are enabled, it means the actual count is less than 200. return gBirchDexRatingText_LessThan200; return gBirchDexRatingText_DexCompleted; } - if (count == 201) + if (count == HOENN_DEX_COUNT - 1) { - if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), 1) - && GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), 1)) // If both of these flags are enabled, it means the actual count is less than 200. + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_JIRACHI), FLAG_GET_CAUGHT) + && GetSetPokedexFlag(SpeciesToNationalPokedexNum(SPECIES_DEOXYS), FLAG_GET_CAUGHT)) // If both of these flags are enabled, it means the actual count is less than 200. return gBirchDexRatingText_LessThan200; return gBirchDexRatingText_DexCompleted; } - if (count == 202) - return gBirchDexRatingText_DexCompleted; // Hoenn dex is considered complete, even though the hoenn dex count is 210. + if (count == HOENN_DEX_COUNT) + return gBirchDexRatingText_DexCompleted; return gBirchDexRatingText_LessThan10; } diff --git a/src/credits.c b/src/credits.c index 02b01c072..67ab97481 100644 --- a/src/credits.c +++ b/src/credits.c @@ -135,7 +135,7 @@ struct Unk201C000 u16 unk90; u16 unk92; u16 unk94; - u16 unk96[386]; + u16 unk96[NATIONAL_DEX_COUNT]; u16 unk39A; u16 unk39C[7]; }; @@ -2254,12 +2254,12 @@ static void sub_8177050(struct Sprite *sprite) } } -static u8 sub_8177224(u16 species, s16 x, s16 y, u16 position) +static u8 sub_8177224(u16 nationalDexNum, s16 x, s16 y, u16 position) { u8 spriteId; u8 spriteId2; - spriteId = sub_80C0E9C(species, x, y, position); + spriteId = CreateMonSpriteFromNationalDexNumber(nationalDexNum, x, y, position); gSprites[spriteId].oam.priority = 1; gSprites[spriteId].data[1] = position + 1; gSprites[spriteId].invisible = TRUE; @@ -2297,16 +2297,16 @@ static void sub_8177388(void) u16 dexNum; u16 j; - for (dexNum = 1, j = 0; dexNum < 386; dexNum++) + for (dexNum = 1, j = 0; dexNum < NATIONAL_DEX_COUNT; dexNum++) { - if (GetSetPokedexFlag(dexNum, 1)) + if (GetSetPokedexFlag(dexNum, FLAG_GET_CAUGHT)) { gUnknown_0203BCE8->unk96[j] = dexNum; j++; } } - for (dexNum = j; dexNum < 386; dexNum++) + for (dexNum = j; dexNum < NATIONAL_DEX_COUNT; dexNum++) gUnknown_0203BCE8->unk96[dexNum] = 0; gUnknown_0203BCE8->unk39A = j; diff --git a/src/event_data.c b/src/event_data.c index 8a998fe26..f6a1cde78 100644 --- a/src/event_data.c +++ b/src/event_data.c @@ -1,5 +1,6 @@ #include "global.h" #include "event_data.h" +#include "pokedex.h" #define TEMP_FLAGS_SIZE 0x4 #define TEMP_UPPER_FLAGS_SIZE 0x8 @@ -67,7 +68,7 @@ void EnableNationalPokedex(void) gSaveBlock2Ptr->pokedex.nationalMagic = 0xDA; *nationalDexVar = 0x302; FlagSet(FLAG_SYS_NATIONAL_DEX); - gSaveBlock2Ptr->pokedex.unknown1 = 1; + gSaveBlock2Ptr->pokedex.mode = DEX_MODE_NATIONAL; gSaveBlock2Ptr->pokedex.order = 0; sub_80BB358(); } diff --git a/src/pokedex.c b/src/pokedex.c index e6198fd4f..ef8905bb6 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -75,9 +75,6 @@ struct UnknownStruct4 u8 unk9; }; -#define HOENN_DEX_COUNT 202 -#define NATIONAL_DEX_COUNT 386 - extern struct MusicPlayerInfo gMPlayInfo_BGM; struct PokedexListItem @@ -132,12 +129,6 @@ struct PokedexView enum { - DEX_MODE_HOENN, - DEX_MODE_NATIONAL -}; - -enum -{ AREA_SCREEN, CRY_SCREEN, SIZE_SCREEN, @@ -176,7 +167,7 @@ u16 sub_80BD69C(u16, u16); void sub_80BD8D0(void); bool8 sub_80BD930(void); u8 sub_80BDA40(void); -u16 sub_80BDA8C(u16); +u16 GetPokemonSpriteToDisplay(u16); u32 sub_80BDACC(u16, s16, s16); static void CreateInterfaceSprites(u8); void sub_80BE470(struct Sprite *sprite); @@ -1237,7 +1228,7 @@ void ResetPokedex(void) gUnknown_02039B50 = 0; gUnknown_02039B52 = 64; gUnknown_030060B0 = 0; - gSaveBlock2Ptr->pokedex.unknown1 = 0; + gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; gSaveBlock2Ptr->pokedex.order = 0; gSaveBlock2Ptr->pokedex.nationalMagic = 0; gSaveBlock2Ptr->pokedex.unknown2 = 0; @@ -1289,7 +1280,7 @@ static void ResetPokedexView(struct PokedexView *pokedexView) pokedexView->unk618 = 0; pokedexView->seenCount = 0; pokedexView->ownCount = 0; - for (i = 0; i <= 3; i++) + for (i = 0; i < 4; i++) pokedexView->unk61E[i] |= 0xFFFF; pokedexView->unk628 = 0; pokedexView->unk62A = 0; @@ -1348,7 +1339,7 @@ void CB2_Pokedex(void) sPokedexView = AllocZeroed(sizeof(struct PokedexView)); ResetPokedexView(sPokedexView); CreateTask(sub_80BB78C, 0); - sPokedexView->dexMode = gSaveBlock2Ptr->pokedex.unknown1; + sPokedexView->dexMode = gSaveBlock2Ptr->pokedex.mode; if (!IsNationalPokedexEnabled()) sPokedexView->dexMode = DEX_MODE_HOENN; sPokedexView->dexOrder = gSaveBlock2Ptr->pokedex.order; @@ -1571,9 +1562,9 @@ void sub_80BBDE8(u8 taskId) { if (!gPaletteFade.active) { - gSaveBlock2Ptr->pokedex.unknown1 = sPokedexView->dexMode; + gSaveBlock2Ptr->pokedex.mode = sPokedexView->dexMode; if (!IsNationalPokedexEnabled()) - gSaveBlock2Ptr->pokedex.unknown1 = DEX_MODE_HOENN; + gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; gSaveBlock2Ptr->pokedex.order = sPokedexView->dexOrder; sub_80BDA40(); sub_80BC890(); @@ -1898,6 +1889,9 @@ void sub_80BC890(void) void sub_80BC8D4(u8 dexMode, u8 sortMode) { u16 vars[3]; //I have no idea why three regular variables are stored in an array, but whatever. +#define temp_dexCount vars[0] +#define temp_isHoennDex vars[1] +#define temp_dexNum vars[2] s16 i; sPokedexView->pokemonListCount = 0; @@ -1906,19 +1900,19 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) { default: case DEX_MODE_HOENN: - vars[0] = HOENN_DEX_COUNT; - vars[1] = 1; + temp_dexCount = HOENN_DEX_COUNT; + temp_isHoennDex = TRUE; break; case DEX_MODE_NATIONAL: if (IsNationalPokedexEnabled()) { - vars[0] = NATIONAL_DEX_COUNT; - vars[1] = 0; + temp_dexCount = NATIONAL_DEX_COUNT; + temp_isHoennDex = FALSE; } else { - vars[0] = HOENN_DEX_COUNT; - vars[1] = 1; + temp_dexCount = HOENN_DEX_COUNT; + temp_isHoennDex = TRUE; } break; } @@ -1926,14 +1920,14 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) switch (sortMode) { case 0: - if (vars[1]) + if (temp_isHoennDex) { - for (i = 0; i < vars[0]; i++) + for (i = 0; i < temp_dexCount; i++) { - vars[2] = HoennToNationalOrder(i + 1); - sPokedexView->pokedexList[i].dexNum = vars[2]; - sPokedexView->pokedexList[i].seen = GetSetPokedexFlag(vars[2], 0); - sPokedexView->pokedexList[i].owned = GetSetPokedexFlag(vars[2], 1); + temp_dexNum = HoennToNationalOrder(i + 1); + sPokedexView->pokedexList[i].dexNum = temp_dexNum; + sPokedexView->pokedexList[i].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN); + sPokedexView->pokedexList[i].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); if (sPokedexView->pokedexList[i].seen) sPokedexView->pokemonListCount = i + 1; } @@ -1944,17 +1938,17 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) s16 r5; r10 = r5 = i = 0; - for (i = 0; i < vars[0]; i++) + for (i = 0; i < temp_dexCount; i++) { - vars[2] = i + 1; - if (GetSetPokedexFlag(vars[2], 0)) + temp_dexNum = i + 1; + if (GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN)) r10 = 1; if (r10) { asm(""); //Needed to match for some reason - sPokedexView->pokedexList[r5].dexNum = vars[2]; - sPokedexView->pokedexList[r5].seen = GetSetPokedexFlag(vars[2], 0); - sPokedexView->pokedexList[r5].owned = GetSetPokedexFlag(vars[2], 1); + sPokedexView->pokedexList[r5].dexNum = temp_dexNum; + sPokedexView->pokedexList[r5].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN); + sPokedexView->pokedexList[r5].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); if (sPokedexView->pokedexList[r5].seen) sPokedexView->pokemonListCount = r5 + 1; r5++; @@ -1965,13 +1959,13 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) case 1: for (i = 0; i < POKEMON_SLOTS_NUMBER - 1; i++) { - vars[2] = gPokedexOrder_Alphabetical[i]; + temp_dexNum = gPokedexOrder_Alphabetical[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 0)) + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN)) { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = vars[2]; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = 1; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = GetSetPokedexFlag(vars[2], 1); + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); sPokedexView->pokemonListCount++; } } @@ -1979,13 +1973,13 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) case 2: for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) { - vars[2] = gPokedexOrder_Weight[i]; + temp_dexNum = gPokedexOrder_Weight[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = vars[2]; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = 1; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = 1; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; sPokedexView->pokemonListCount++; } } @@ -1993,27 +1987,27 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) case 3: for (i = 0; i < NATIONAL_DEX_COUNT; i++) { - vars[2] = gPokedexOrder_Weight[i]; + temp_dexNum = gPokedexOrder_Weight[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = vars[2]; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = 1; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = 1; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; sPokedexView->pokemonListCount++; } } break; case 4: - for (i = NATIONAL_DEX_COUNT - 1; i >=0; i--) + for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) { - vars[2] = gPokedexOrder_Height[i]; + temp_dexNum = gPokedexOrder_Height[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = vars[2]; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = 1; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = 1; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; sPokedexView->pokemonListCount++; } } @@ -2021,13 +2015,13 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) case 5: for (i = 0; i < NATIONAL_DEX_COUNT; i++) { - vars[2] = gPokedexOrder_Height[i]; + temp_dexNum = gPokedexOrder_Height[i]; - if (NationalToHoennOrder(vars[2]) <= vars[0] && GetSetPokedexFlag(vars[2], 1)) + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = vars[2]; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = 1; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = 1; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; sPokedexView->pokemonListCount++; } } @@ -2037,8 +2031,8 @@ void sub_80BC8D4(u8 dexMode, u8 sortMode) for (i = sPokedexView->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) { sPokedexView->pokedexList[i].dexNum |= 0xFFFF; - sPokedexView->pokedexList[i].seen = 0; - sPokedexView->pokedexList[i].owned = 0; + sPokedexView->pokedexList[i].seen = FALSE; + sPokedexView->pokedexList[i].owned = FALSE; } } @@ -2192,7 +2186,7 @@ static void CreateInitialPokemonSprites(u16 selectedMon, u16 b) sPokedexView->unk61E[i] = 0xFFFF; sPokedexView->selectedMonSpriteId = 0xFFFF; - unk = sub_80BDA8C(selectedMon - 1); + unk = GetPokemonSpriteToDisplay(selectedMon - 1); if (unk != 0xFFFF) { spriteId = sub_80BDACC(unk, 0x60, 0x50); @@ -2200,7 +2194,7 @@ static void CreateInitialPokemonSprites(u16 selectedMon, u16 b) gSprites[spriteId].data[5] = -32; } - unk = sub_80BDA8C(selectedMon); + unk = GetPokemonSpriteToDisplay(selectedMon); if (unk != 0xFFFF) { spriteId = sub_80BDACC(unk, 0x60, 0x50); @@ -2208,7 +2202,7 @@ static void CreateInitialPokemonSprites(u16 selectedMon, u16 b) gSprites[spriteId].data[5] = 0; } - unk = sub_80BDA8C(selectedMon + 1); + unk = GetPokemonSpriteToDisplay(selectedMon + 1); if (unk != 0xFFFF) { spriteId = sub_80BDACC(unk, 0x60, 0x50); @@ -2274,7 +2268,7 @@ static void CreateNewPokemonSprite(u8 direction, u16 selectedMon) switch (direction) { case 1: // up - unk = sub_80BDA8C(selectedMon - 1); + unk = GetPokemonSpriteToDisplay(selectedMon - 1); if (unk != 0xFFFF) { spriteId = sub_80BDACC(unk, 0x60, 0x50); @@ -2287,7 +2281,7 @@ static void CreateNewPokemonSprite(u8 direction, u16 selectedMon) sPokedexView->unk630 = 15; break; case 2: // down - unk = sub_80BDA8C(selectedMon + 1); + unk = GetPokemonSpriteToDisplay(selectedMon + 1); if (unk != 0xFFFF) { spriteId = sub_80BDACC(unk, 0x60, 0x50); @@ -2449,12 +2443,12 @@ u8 sub_80BDA40(void) return FALSE; } -u16 sub_80BDA8C(u16 a1) +u16 GetPokemonSpriteToDisplay(u16 species) { - if (a1 >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[a1].dexNum == 0xFFFF) + if (species >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[species].dexNum == 0xFFFF) return 0xFFFF; - else if (sPokedexView->pokedexList[a1].seen) - return sPokedexView->pokedexList[a1].dexNum; + else if (sPokedexView->pokedexList[species].seen) + return sPokedexView->pokedexList[species].dexNum; else return 0; } @@ -2467,7 +2461,7 @@ u32 sub_80BDACC(u16 num, s16 x, s16 y) { if (sPokedexView->unk61E[i] == 0xFFFF) { - u8 spriteId = sub_80C0E9C(num, x, y, i); + u8 spriteId = CreateMonSpriteFromNationalDexNumber(num, x, y, i); gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.priority = 3; @@ -2963,7 +2957,7 @@ void sub_80BEA24(u8 taskId) case 5: if (gTasks[taskId].data[1] == 0) { - gTasks[taskId].data[4] = (u16)sub_80C0E9C(sPokedexListItem->dexNum, 0x30, 0x38, 0); + gTasks[taskId].data[4] = (u16)CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); gSprites[gTasks[taskId].data[4]].oam.priority = 0; } gMain.state++; @@ -3251,7 +3245,7 @@ void sub_80BF250(u8 taskId) gMain.state++; break; case 5: - gTasks[taskId].data[4] = sub_80C0E9C(sPokedexListItem->dexNum, 48, 56, 0); + gTasks[taskId].data[4] = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); gSprites[gTasks[taskId].data[4]].oam.priority = 0; gDexCryScreenState = 0; gMain.state++; @@ -3459,7 +3453,7 @@ void sub_80BF82C(u8 taskId) gMain.state++; break; case 6: - spriteId = sub_80C0E9C(sPokedexListItem->dexNum, 88, 56, 1); + spriteId = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 88, 56, 1); gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.matrixNum = 2; gSprites[spriteId].oam.priority = 0; @@ -3790,7 +3784,7 @@ void sub_80BFE38(u8 taskId) gTasks[taskId].data[0]++; break; case 4: - spriteId = sub_80C0E9C(dexNum, 0x30, 0x38, 0); + spriteId = CreateMonSpriteFromNationalDexNumber(dexNum, 48, 56, 0); gSprites[spriteId].oam.priority = 0; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); SetVBlankCallback(gUnknown_030060B4); @@ -4348,7 +4342,7 @@ u16 GetHoennPokedexCount(u8 caseID) u16 count = 0; u16 i; - for (i = 0; i < 202; i++) + for (i = 0; i < HOENN_DEX_COUNT; i++) { switch (caseID) { @@ -4417,17 +4411,17 @@ u16 sub_80C0944(void) for (i = 0; i < 150; i++) { - if (GetSetPokedexFlag(i + 1, 1) == 0) + if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) return 0; } for (i = 151; i < 248; i++) { - if (GetSetPokedexFlag(i + 1, 1) == 0) + if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) return 0; } for (i = 251; i < 384; i++) { - if (GetSetPokedexFlag(i + 1, 1) == 0) + if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) return 0; } return 1; @@ -4643,10 +4637,10 @@ u32 sub_80C0E68(u16 a) } } -u16 sub_80C0E9C(u16 num, s16 x, s16 y, u16 paletteSlot) +u16 CreateMonSpriteFromNationalDexNumber(u16 nationalNum, s16 x, s16 y, u16 paletteSlot) { - num = NationalPokedexNumToSpecies(num); - return CreateMonPicSprite_HandleDeoxys(num, 8, sub_80C0E68(num), TRUE, x, y, paletteSlot, 0xFFFF); + nationalNum = NationalPokedexNumToSpecies(nationalNum); + return CreateMonPicSprite_HandleDeoxys(nationalNum, 8, sub_80C0E68(nationalNum), TRUE, x, y, paletteSlot, 0xFFFF); } u16 sub_80C0EF8(u16 species, s16 x, s16 y, s8 paletteSlot) @@ -4980,10 +4974,10 @@ void sub_80C170C(u8 taskId) sPokedexView->unk62A = 0x40; gUnknown_02039B50 = 0; sPokedexView->unk610 = 0; - gSaveBlock2Ptr->pokedex.unknown1 = sub_80C2318(taskId, 5); + gSaveBlock2Ptr->pokedex.mode = sub_80C2318(taskId, 5); if (!IsNationalPokedexEnabled()) - gSaveBlock2Ptr->pokedex.unknown1 = 0; - sPokedexView->unk614 = gSaveBlock2Ptr->pokedex.unknown1; + gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; + sPokedexView->unk614 = gSaveBlock2Ptr->pokedex.mode; gSaveBlock2Ptr->pokedex.order = sub_80C2318(taskId, 4); sPokedexView->unk618 = gSaveBlock2Ptr->pokedex.order; PlaySE(SE_PC_OFF); diff --git a/src/pokemon.c b/src/pokemon.c index de3eaba75..14b4ea388 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -5858,10 +5858,10 @@ u16 HoennPokedexNumToSpecies(u16 hoennNum) species = 0; - while (species < 411 && gSpeciesToHoennPokedexNum[species] != hoennNum) + while (species < (NUM_SPECIES - 1) && gSpeciesToHoennPokedexNum[species] != hoennNum) species++; - if (species == 411) + if (species == NUM_SPECIES - 1) return 0; return species + 1; @@ -5876,10 +5876,10 @@ u16 NationalPokedexNumToSpecies(u16 nationalNum) species = 0; - while (species < 411 && gSpeciesToNationalPokedexNum[species] != nationalNum) + while (species < (NUM_SPECIES - 1) && gSpeciesToNationalPokedexNum[species] != nationalNum) species++; - if (species == 411) + if (species == NUM_SPECIES - 1) return 0; return species + 1; @@ -5894,10 +5894,10 @@ u16 NationalToHoennOrder(u16 nationalNum) hoennNum = 0; - while (hoennNum < 411 && gHoennToNationalOrder[hoennNum] != nationalNum) + while (hoennNum < (NUM_SPECIES - 1) && gHoennToNationalOrder[hoennNum] != nationalNum) hoennNum++; - if (hoennNum == 411) + if (hoennNum == NUM_SPECIES - 1) return 0; return hoennNum + 1; @@ -6578,15 +6578,15 @@ u16 SpeciesToPokedexNum(u16 species) else { species = SpeciesToHoennPokedexNum(species); - if (species <= 202) + if (species <= HOENN_DEX_COUNT) return species; return 0xFFFF; } } -bool32 sub_806E3F8(u16 species) +bool32 IsSpeciesInHoennDex(u16 species) { - if (SpeciesToHoennPokedexNum(species) > 202) + if (SpeciesToHoennPokedexNum(species) > HOENN_DEX_COUNT) return FALSE; else return TRUE; diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c index f2d5b5cb6..fc5a06024 100755 --- a/src/script_pokemon_util_80F87D8.c +++ b/src/script_pokemon_util_80F87D8.c @@ -563,8 +563,8 @@ u8 ScriptGiveMon(u16 species, u8 level, u16 item, u32 unused1, u32 unused2, u8 u { case 0: case 1: - GetSetPokedexFlag(nationalDexNum, 2); - GetSetPokedexFlag(nationalDexNum, 3); + GetSetPokedexFlag(nationalDexNum, FLAG_SET_SEEN); + GetSetPokedexFlag(nationalDexNum, FLAG_SET_CAUGHT); break; } return sentToPc; @@ -3229,7 +3229,7 @@ u16 TV_GetSomeOtherSpeciesAlreadySeenByPlayer(u16 passedSpecies) species = (Random() % (NUM_SPECIES - 1)) + 1; initSpecies = species; - while (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), 0) != 1 || species == passedSpecies) + while (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_SEEN) != TRUE || species == passedSpecies) { if (species == 1) { @@ -4376,7 +4376,7 @@ void SetTvShowInactive(u8 showIdx) static void sub_80F0B24(u16 species, u8 showIdx) { - if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), 0) == 0) + if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_SEEN)) { gSaveBlock1Ptr->tvShows[showIdx].common.active = FALSE; } |