diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/field_specials.c | 4 | ||||
-rw-r--r-- | src/pokemon.c | 2 | ||||
-rw-r--r-- | src/pokemon_storage_system.c | 189 | ||||
-rw-r--r-- | src/quest_log.c | 8 |
4 files changed, 196 insertions, 7 deletions
diff --git a/src/field_specials.c b/src/field_specials.c index 5be7a4d1c..aa95f87a0 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -442,7 +442,7 @@ bool8 IsThereRoomInAnyBoxForMorePokemon(void) { for (j = 0; j < IN_BOX_COUNT; j++) { - if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE) + if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE) return TRUE; } } @@ -1642,7 +1642,7 @@ void ChangeBoxPokemonNickname(void) static void ChangeBoxPokemonNickname_CB(void) { - SetBoxMonNickFromAnyBox(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2); + SetBoxMonNickAt(gSpecialVar_MonBoxId, gSpecialVar_MonBoxPos, gStringVar2); CB2_ReturnToFieldContinueScriptPlayMapMusic(); } diff --git a/src/pokemon.c b/src/pokemon.c index f1f7834b1..641c7cb0f 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3806,7 +3806,7 @@ static bool8 IsPokemonStorageFull(void) for (i = 0; i < 14; i++) for (j = 0; j < 30; j++) - if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SPECIES) == SPECIES_NONE) + if (GetBoxMonDataAt(i, j, MON_DATA_SPECIES) == SPECIES_NONE) return FALSE; return TRUE; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c new file mode 100644 index 000000000..b81cf20c6 --- /dev/null +++ b/src/pokemon_storage_system.c @@ -0,0 +1,189 @@ +#include "global.h" +#include "gflib.h" +#include "pokemon_storage_system.h" +#include "constants/species.h" + +enum +{ + WALLPAPER_FOREST, + WALLPAPER_CITY, + WALLPAPER_DESERT, + WALLPAPER_SAVANNA, + WALLPAPER_CRAG, + WALLPAPER_VOLCANO, + WALLPAPER_SNOW, + WALLPAPER_CAVE, + WALLPAPER_BEACH, + WALLPAPER_SEAFLOOR, + WALLPAPER_RIVER, + WALLPAPER_SKY, + WALLPAPER_POLKADOT, + WALLPAPER_POKECENTER, + WALLPAPER_MACHINE, + WALLPAPER_PLAIN, + WALLPAPER_COUNT +}; + +void BackupPokemonStorage(struct PokemonStorage * dest) +{ + *dest = *gPokemonStoragePtr; +} + +void RestorePokemonStorage(struct PokemonStorage * src) +{ + *gPokemonStoragePtr = *src; +} + +// Functions here are general utility functions. +u8 StorageGetCurrentBox(void) +{ + return gPokemonStoragePtr->currentBox; +} + +void SetCurrentBox(u8 boxId) +{ + if (boxId < TOTAL_BOXES_COUNT) + gPokemonStoragePtr->currentBox = boxId; +} + +u32 GetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request); + else + return 0; +} + +void SetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, const void *value) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, value); +} + +u32 GetCurrentBoxMonData(u8 boxPosition, s32 request) +{ + return GetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request); +} + +void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value) +{ + SetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request, value); +} + +void GetBoxMonNickAt(u8 boxId, u8 boxPosition, u8 *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, dst); + else + *dst = EOS; +} + +void SetBoxMonNickAt(u8 boxId, u8 boxPosition, const u8 *nick) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, nick); +} + +u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, dst); + else + return 0; +} + +void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + gPokemonStoragePtr->boxes[boxId][boxPosition] = *src; +} + +void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + *dst = gPokemonStoragePtr->boxes[boxId][boxPosition]; +} + +void CreateBoxMonAt(u8 boxId, u8 boxPosition, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 personality, u8 otIDType, u32 otID) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + { + CreateBoxMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], + species, + level, + fixedIV, + hasFixedPersonality, personality, + otIDType, otID); + } +} + +void ZeroBoxMonAt(u8 boxId, u8 boxPosition) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]); +} + +void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + BoxMonToMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], dst); +} + +struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition) +{ + if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) + return &gPokemonStoragePtr->boxes[boxId][boxPosition]; + else + return NULL; +} + +u8 *GetBoxNamePtr(u8 boxId) +{ + if (boxId < TOTAL_BOXES_COUNT) + return gPokemonStoragePtr->boxNames[boxId]; + else + return NULL; +} + +u8 GetBoxWallpaper(u8 boxId) +{ + if (boxId < TOTAL_BOXES_COUNT) + return gPokemonStoragePtr->boxWallpapers[boxId]; + else + return 0; +} + +void SetBoxWallpaper(u8 boxId, u8 wallpaperId) +{ + if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPER_COUNT) + gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; +} + +s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3) +{ + s16 i; + s16 adder = -1; + + if (arg3 < 2) + adder = 1; + + if (arg3 == 1 || arg3 == 3) + { + for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + { + if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE) + return i; + } + } + else + { + for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + { + if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE + && !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG)) + return i; + } + } + + return -1; +} diff --git a/src/quest_log.c b/src/quest_log.c index 91c07223e..bc8e67a6b 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -752,7 +752,7 @@ void sub_8111438(void) { for (r3 = 0; r3 < 5; r3++) { - sub_808BCB4(0, r3); + ZeroBoxMonAt(0, r3); } for (r3 = r5; r3 < r9->sanePartyCount; r3++) { @@ -767,9 +767,9 @@ void sub_8111438(void) { for (r6 = 0; r6 < 30; r6++) { - if (GetBoxMonDataFromAnyBox(r3, r6, MON_DATA_SANITY_HAS_SPECIES)) + if (GetBoxMonDataAt(r3, r6, MON_DATA_SANITY_HAS_SPECIES)) { - sub_808BCB4(r3, r6); + ZeroBoxMonAt(r3, r6); r5--; if (r5 == r9->saneBoxesCount) break; @@ -832,7 +832,7 @@ static u16 QuestLog_GetSaneBoxCount(void) { for (j = 0; j < IN_BOX_COUNT; j++) { - if (GetBoxMonDataFromAnyBox(i, j, MON_DATA_SANITY_HAS_SPECIES)) + if (GetBoxMonDataAt(i, j, MON_DATA_SANITY_HAS_SPECIES)) count++; } } |