From 00dcc05516dbf34f282f6440ca9eeb907688f6d2 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 14 May 2019 11:54:58 +0200 Subject: [PATCH] Add new dex flags --- include/global.h | 30 ++++++++++++++---------------- src/new_game.c | 4 ++-- src/pokedex.c | 40 ++++++++++------------------------------ 3 files changed, 26 insertions(+), 48 deletions(-) diff --git a/include/global.h b/include/global.h index 8b61164f6e..93aa3825e7 100644 --- a/include/global.h +++ b/include/global.h @@ -57,7 +57,7 @@ #define PARTY_SIZE 6 -#define POKEMON_SLOTS_NUMBER 412 +#define POKEMON_SLOTS_NUMBER 808 #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) >= (b) ? (a) : (b)) @@ -154,8 +154,7 @@ struct Pokedex /*0x04*/ u32 unownPersonality; // set when you first see Unown /*0x08*/ u32 spindaPersonality; // set when you first see Spinda /*0x0C*/ u32 unknown3; - /*0x10*/ u8 owned[DEX_FLAGS_NO]; - /*0x44*/ u8 seen[DEX_FLAGS_NO]; + /*0x10*/ u8 filler[0x68]; // Previously Dex Flags, feel free to remove. }; struct PokemonJumpResults // possibly used in the game itself? @@ -909,7 +908,7 @@ struct SaveBlock1 /*0x690*/ struct ItemSlot bagPocket_TMHM[BAG_TMHM_COUNT]; /*0x790*/ struct ItemSlot bagPocket_Berries[BAG_BERRIES_COUNT]; /*0x848*/ struct Pokeblock pokeblocks[POKEBLOCKS_COUNT]; - /*0x988*/ u8 seen1[DEX_FLAGS_NO]; + /*0x988*/ u8 filler1[0x34]; // Previously Dex Flags, feel free to remove. /*0x9BC*/ u16 berryBlenderRecords[3]; /*0x9C2*/ u8 field_9C2[6]; /*0x9C8*/ u16 trainerRematchStepCounter; @@ -960,18 +959,17 @@ struct SaveBlock1 /*0x31DC*/ struct Roamer roamer; /*0x31F8*/ struct EnigmaBerry enigmaBerry; /*0x322C*/ struct MEventBuffers unk_322C; - /*0x3598*/ u8 field_3598[0x180]; - /*0x3718*/ u32 trainerHillTimes[4]; - /*0x3728*/ struct RamScript ramScript; - /*0x3B14*/ struct RecordMixingGift recordMixingGift; - /*0x3B24*/ u8 seen2[DEX_FLAGS_NO]; - /*0x3B58*/ LilycoveLady lilycoveLady; - /*0x3B98*/ struct TrainerNameRecord trainerNameRecords[20]; - /*0x3C88*/ u8 unk3C88[10][21]; - /*0x3D5A*/ u8 filler3D5A[0xA]; - /*0x3D64*/ struct SaveTrainerHill trainerHill; - /*0x3D70*/ struct WaldaPhrase waldaPhrase; - // sizeof: 0x3D88 + /*0x3???*/ u8 dexSeen[DEX_FLAGS_NO]; + /*0x3???*/ u8 dexCaught[DEX_FLAGS_NO]; + /*0x3???*/ u32 trainerHillTimes[4]; + /*0x3???*/ struct RamScript ramScript; + /*0x3???*/ struct RecordMixingGift recordMixingGift; + /*0x3???*/ LilycoveLady lilycoveLady; + /*0x3???*/ struct TrainerNameRecord trainerNameRecords[20]; + /*0x3???*/ u8 unk3C88[10][21]; + /*0x3???*/ struct SaveTrainerHill trainerHill; + /*0x3???*/ struct WaldaPhrase waldaPhrase; + // sizeof: 0x3??? }; extern struct SaveBlock1* gSaveBlock1Ptr; diff --git a/src/new_game.c b/src/new_game.c index 7a0c668a4d..6394e730e7 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -106,8 +106,8 @@ static void SetDefaultOptions(void) static void ClearPokedexFlags(void) { gUnusedPokedexU8 = 0; - memset(&gSaveBlock2Ptr->pokedex.owned, 0, sizeof(gSaveBlock2Ptr->pokedex.owned)); - memset(&gSaveBlock2Ptr->pokedex.seen, 0, sizeof(gSaveBlock2Ptr->pokedex.seen)); + memset(&gSaveBlock1Ptr->dexCaught, 0, sizeof(gSaveBlock1Ptr->dexCaught)); + memset(&gSaveBlock1Ptr->dexSeen, 0, sizeof(gSaveBlock1Ptr->dexSeen)); } void ClearAllContestWinnerPics(void) diff --git a/src/pokedex.c b/src/pokedex.c index f9a2df76d5..9f36278c39 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1237,10 +1237,8 @@ void ResetPokedex(void) DisableNationalPokedex(); for (i = 0; i < DEX_FLAGS_NO; i++) { - gSaveBlock2Ptr->pokedex.owned[i] = 0; - gSaveBlock2Ptr->pokedex.seen[i] = 0; - gSaveBlock1Ptr->seen1[i] = 0; - gSaveBlock1Ptr->seen2[i] = 0; + gSaveBlock1Ptr->dexCaught[i] = 0; + gSaveBlock1Ptr->dexSeen[i] = 0; } } @@ -4260,48 +4258,30 @@ u16 GetPokedexHeightWeight(u16 dexNum, u8 data) s8 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID) { - u8 index; - u8 bit; - u8 mask; - s8 retVal; + u32 index, bit, mask; + s8 retVal = 0; nationalDexNo--; index = nationalDexNo / 8; bit = nationalDexNo % 8; mask = 1 << bit; - retVal = 0; + switch (caseID) { case FLAG_GET_SEEN: - if (gSaveBlock2Ptr->pokedex.seen[index] & mask) - { - if ((gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) - && (gSaveBlock2Ptr->pokedex.seen[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) - retVal = 1; - else - retVal = 0; - } + retVal = ((gSaveBlock1Ptr->dexSeen[index] & mask) != 0); break; case FLAG_GET_CAUGHT: - if (gSaveBlock2Ptr->pokedex.owned[index] & mask) - { - if ((gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock2Ptr->pokedex.seen[index] & mask) - && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen1[index] & mask) - && (gSaveBlock2Ptr->pokedex.owned[index] & mask) == (gSaveBlock1Ptr->seen2[index] & mask)) - retVal = 1; - else - retVal = 0; - } + retVal = ((gSaveBlock1Ptr->dexCaught[index] & mask) != 0); break; case FLAG_SET_SEEN: - gSaveBlock2Ptr->pokedex.seen[index] |= mask; - gSaveBlock1Ptr->seen1[index] |= mask; - gSaveBlock1Ptr->seen2[index] |= mask; + gSaveBlock1Ptr->dexSeen[index] |= mask; break; case FLAG_SET_CAUGHT: - gSaveBlock2Ptr->pokedex.owned[index] |= mask; + gSaveBlock1Ptr->dexCaught[index] |= mask; break; } + return retVal; }