diff --git a/include/config/save.h b/include/config/save.h index a6d4abd5fc..cbaf144e8a 100644 --- a/include/config/save.h +++ b/include/config/save.h @@ -4,22 +4,22 @@ // free saveblock 1 defines #define FREE_EXTRA_SEEN_FLAGS FALSE // Free up unused Pokédex seen flags (52 bytes). #define FREE_TRAINER_HILL FALSE // Frees up Trainer Hill data (28 bytes). WARNING THIS HAS BEEN SHOWN TO BREAK MULTI BATTLES -#define FREE_MYSTERY_EVENT_BUFFERS FALSE //frees up mystery event and ramScript. roughly 1880 bytes Needed by FREE_BATTLE_TOWER_E_READER +#define FREE_MYSTERY_EVENT_BUFFERS FALSE //frees up mystery event and ramScript. roughly 1880 bytes Needs FREE_BATTLE_TOWER_E_READER #define FREE_MATCH_CALL FALSE // Frees up match call and rematch data. (104 bytes). #define FREE_UNION_ROOM_CHAT FALSE // Frees up union room chat (212 bytes). #define FREE_ENIGMA_BERRY FALSE // Frees up E-Reader Enigma Berry data (52 bytes). #define FREE_LINK_BATTLE_RECORDS FALSE // Frees up link battle record data (88 bytes). // saveblock1 total: 1846 bytes //free saveblock 2 defines -#define FREE_BATTLE_TOWER_E_READER FALSE //frees up battle tower e reader trainer data. 188 bytes. WARNING THIS HAS BEEN SHOWN TO BREAK THE POKÉ MARTS' QUESTIONNAIRE +#define FREE_BATTLE_TOWER_E_READER FALSE // Frees up Battle Tower E-Reader data (188 bytes). WARNING THIS HAS BEEN SHOWN TO BREAK THE POKÉ MARTS' QUESTIONNAIRE #define FREE_POKEMON_JUMP FALSE // Frees up Pokémon Jump data (16 bytes). #define FREE_RECORD_MIXING_HALL_RECORDS FALSE // Frees up hall records for record mixing (1032 bytes). // saveblock2 total: 1236 bytes //grand total: 3082 -#if (FREE_MYSTERY_EVENT_BUFFERS == FALSE) && (FREE_BATTLE_TOWER_E_READER == TRUE) -#error "FREE_MYSTERY_EVENT_BUFFERS must be enabled for FREE_BATTLE_TOWER_E_READER to work" +#if (FREE_MYSTERY_EVENT_BUFFERS == TRUE) && (FREE_BATTLE_TOWER_E_READER == FALSE) +#error "FREE_BATTLE_TOWER_E_READER must be enabled for FREE_MYSTERY_EVENT_BUFFERS to work" #endif #endif // GUARD_CONFIG_DECAP_H diff --git a/src/battle_tower.c b/src/battle_tower.c index d8f65786ed..44506298d7 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -76,7 +76,9 @@ static void FillFactoryFrontierTrainerParty(u16 trainerId, u8 firstMonId); static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId); static u8 GetFrontierTrainerFixedIvs(u16 trainerId); static void FillPartnerParty(u16 trainerId); +#if FREE_BATTLE_TOWER_E_READER == FALSE static void SetEReaderTrainerChecksum(struct BattleTowerEReaderTrainer *ereaderTrainer); +#endif //FREE_BATTLE_TOWER_E_READER static u8 SetTentPtrsGetLevel(void); const u16 gBattleFrontierHeldItems[] = @@ -2957,16 +2959,16 @@ void ValidateEReaderTrainer(void) #endif //FREE_BATTLE_TOWER_E_READER } +#if FREE_BATTLE_TOWER_E_READER == FALSE static void SetEReaderTrainerChecksum(struct BattleTowerEReaderTrainer *ereaderTrainer) { -#if FREE_BATTLE_TOWER_E_READER == FALSE s32 i; ereaderTrainer->checksum = 0; for (i = 0; i < (sizeof(struct BattleTowerEReaderTrainer) - 4) / 4; i++) // - 4, because of the last field being the checksum itself. ereaderTrainer->checksum += ((u32 *)ereaderTrainer)[i]; -#endif //FREE_BATTLE_TOWER_E_READER } +#endif //FREE_BATTLE_TOWER_E_READER void ClearEReaderTrainer(struct BattleTowerEReaderTrainer *ereaderTrainer) { diff --git a/src/mystery_gift.c b/src/mystery_gift.c index 504059ec9c..d14d2f8e41 100755 --- a/src/mystery_gift.c +++ b/src/mystery_gift.c @@ -13,14 +13,18 @@ static EWRAM_DATA bool32 sStatsEnabled = FALSE; +#if FREE_BATTLE_TOWER_E_READER == FALSE static void ClearSavedWonderNewsMetadata(void); +#endif //FREE_BATTLE_TOWER_E_READER static void ClearSavedWonderNews(void); +#if FREE_BATTLE_TOWER_E_READER == FALSE static void ClearSavedWonderCard(void); static bool32 ValidateWonderNews(const struct WonderNews *); static bool32 ValidateWonderCard(const struct WonderCard *); static void ClearSavedWonderCardMetadata(void); static void ClearSavedTrainerIds(void); static void IncrementCardStatForNewTrainer(u32, u32, u32 *, int); +#endif //FREE_BATTLE_TOWER_E_READER #define CALC_CRC(data) CalcCRC16WithTable((void *)&(data), sizeof(data)) @@ -37,6 +41,8 @@ struct WonderNews *GetSavedWonderNews(void) { #if FREE_BATTLE_TOWER_E_READER == FALSE return &gSaveBlock1Ptr->mysteryGift.news; +#else + return NULL; #endif //FREE_BATTLE_TOWER_E_READER } @@ -44,6 +50,8 @@ struct WonderCard *GetSavedWonderCard(void) { #if FREE_BATTLE_TOWER_E_READER == FALSE return &gSaveBlock1Ptr->mysteryGift.card; +#else + return NULL; #endif //FREE_BATTLE_TOWER_E_READER } @@ -51,6 +59,8 @@ struct WonderCardMetadata *GetSavedWonderCardMetadata(void) { #if FREE_BATTLE_TOWER_E_READER == FALSE return &gSaveBlock1Ptr->mysteryGift.cardMetadata; +#else + return NULL; #endif //FREE_BATTLE_TOWER_E_READER } @@ -58,6 +68,8 @@ struct WonderNewsMetadata *GetSavedWonderNewsMetadata(void) { #if FREE_BATTLE_TOWER_E_READER == FALSE return &gSaveBlock1Ptr->mysteryGift.newsMetadata; +#else + return NULL; #endif //FREE_BATTLE_TOWER_E_READER } @@ -65,6 +77,8 @@ u16 *GetQuestionnaireWordsPtr(void) { #if FREE_BATTLE_TOWER_E_READER == FALSE return gSaveBlock1Ptr->mysteryGift.questionnaireWords; +#else + return NULL; #endif //FREE_BATTLE_TOWER_E_READER } @@ -103,6 +117,7 @@ bool32 ValidateSavedWonderNews(void) #endif //FREE_BATTLE_TOWER_E_READER } +#if FREE_BATTLE_TOWER_E_READER == FALSE static bool32 ValidateWonderNews(const struct WonderNews *news) { if (news->id == 0) @@ -110,6 +125,7 @@ static bool32 ValidateWonderNews(const struct WonderNews *news) return TRUE; } +#endif //FREE_BATTLE_TOWER_E_READER bool32 IsSendingSavedWonderNewsAllowed(void) { @@ -132,13 +148,13 @@ static void ClearSavedWonderNews(void) #endif //FREE_BATTLE_TOWER_E_READER } +#if FREE_BATTLE_TOWER_E_READER == FALSE static void ClearSavedWonderNewsMetadata(void) { -#if FREE_BATTLE_TOWER_E_READER == FALSE CpuFill32(0, GetSavedWonderNewsMetadata(), sizeof(gSaveBlock1Ptr->mysteryGift.newsMetadata)); WonderNews_Reset(); -#endif //FREE_BATTLE_TOWER_E_READER } +#endif //FREE_BATTLE_TOWER_E_READER bool32 IsWonderNewsSameAsSaved(const u8 *news) { @@ -207,6 +223,7 @@ bool32 ValidateSavedWonderCard(void) #endif //FREE_BATTLE_TOWER_E_READER } +#if FREE_BATTLE_TOWER_E_READER == FALSE static bool32 ValidateWonderCard(const struct WonderCard *card) { if (card->flagId == 0) @@ -224,6 +241,7 @@ static bool32 ValidateWonderCard(const struct WonderCard *card) return TRUE; } +#endif //FREE_BATTLE_TOWER_E_READER bool32 IsSendingSavedWonderCardAllowed(void) { @@ -238,21 +256,19 @@ bool32 IsSendingSavedWonderCardAllowed(void) #endif //FREE_BATTLE_TOWER_E_READER } +#if FREE_BATTLE_TOWER_E_READER == FALSE static void ClearSavedWonderCard(void) { -#if FREE_BATTLE_TOWER_E_READER == FALSE CpuFill32(0, &gSaveBlock1Ptr->mysteryGift.card, sizeof(gSaveBlock1Ptr->mysteryGift.card)); gSaveBlock1Ptr->mysteryGift.cardCrc = 0; -#endif //FREE_BATTLE_TOWER_E_READER } static void ClearSavedWonderCardMetadata(void) { -#if FREE_BATTLE_TOWER_E_READER == FALSE CpuFill32(0, GetSavedWonderCardMetadata(), sizeof(gSaveBlock1Ptr->mysteryGift.cardMetadata)); gSaveBlock1Ptr->mysteryGift.cardMetadataCrc = 0; -#endif //FREE_BATTLE_TOWER_E_READER } +#endif //FREE_BATTLE_TOWER_E_READER u16 GetWonderCardFlagID(void) { @@ -342,6 +358,7 @@ static bool32 IsStampInMetadata(const struct WonderCardMetadata *metadata, const return FALSE; } +#if FREE_BATTLE_TOWER_E_READER == FALSE static bool32 ValidateStamp(const u16 *stamp) { if (stamp[STAMP_ID] == 0) @@ -359,16 +376,13 @@ static int GetNumStampsInSavedCard(void) if (!ValidateSavedWonderCard()) return 0; -#if FREE_BATTLE_TOWER_E_READER == FALSE card = &gSaveBlock1Ptr->mysteryGift.card; if (card->type != CARD_TYPE_STAMP) return 0; return GetNumStampsInMetadata(&gSaveBlock1Ptr->mysteryGift.cardMetadata, card->maxStamps); -#else - return 0; -#endif //FREE_BATTLE_TOWER_E_READER } +#endif //FREE_BATTLE_TOWER_E_READER bool32 MysteryGift_TrySaveStamp(const u16 *stamp) { @@ -543,9 +557,9 @@ u16 MysteryGift_GetCardStatFromLinkData(const struct MysteryGiftLinkGameData *da } } +#if FREE_BATTLE_TOWER_E_READER == FALSE static void IncrementCardStat(u32 statType) { -#if FREE_BATTLE_TOWER_E_READER == FALSE struct WonderCard *card = &gSaveBlock1Ptr->mysteryGift.card; if (card->type == CARD_TYPE_LINK_STAT) { @@ -575,8 +589,8 @@ static void IncrementCardStat(u32 statType) *stat = MAX_WONDER_CARD_STAT; } } -#endif //FREE_BATTLE_TOWER_E_READER } +#endif //FREE_BATTLE_TOWER_E_READER u16 MysteryGift_GetCardStat(u32 stat) { @@ -690,11 +704,10 @@ void MysteryGift_TryIncrementStat(u32 stat, u32 trainerId) #endif //FREE_BATTLE_TOWER_E_READER } +#if FREE_BATTLE_TOWER_E_READER == FALSE static void ClearSavedTrainerIds(void) { -#if FREE_BATTLE_TOWER_E_READER == FALSE CpuFill32(0, gSaveBlock1Ptr->mysteryGift.trainerIds, sizeof(gSaveBlock1Ptr->mysteryGift.trainerIds)); -#endif //FREE_BATTLE_TOWER_E_READER } // Returns TRUE if it's a new trainer id, FALSE if an existing one. @@ -734,3 +747,4 @@ static void IncrementCardStatForNewTrainer(u32 stat, u32 trainerId, u32 *trainer if (RecordTrainerId(trainerId, trainerIds, size)) IncrementCardStat(stat); } +#endif //FREE_BATTLE_TOWER_E_READER