diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-03-11 14:21:43 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-03-11 14:21:43 -0400 |
commit | 6b4b6a54af99da1e1f6439a58285038a5fd11604 (patch) | |
tree | 1e225d62994bcd82f95070c7555b47532ddd9e1c | |
parent | 3aeb294572174d1f927286d507d15cda04e58601 (diff) |
Make sub_808BDE8 call signature more sane
-rw-r--r-- | include/pokemon_storage_system.h | 21 | ||||
-rw-r--r-- | src/pokemon_storage_system.c | 47 | ||||
-rw-r--r-- | src/pokemon_storage_system_3.c | 3 |
3 files changed, 39 insertions, 32 deletions
diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h index 3c29dd9fd..b54c0cd68 100644 --- a/include/pokemon_storage_system.h +++ b/include/pokemon_storage_system.h @@ -6,6 +6,27 @@ #define TOTAL_BOXES_COUNT 14 #define IN_BOX_COUNT 30 +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 +}; + u8 *GetBoxNamePtr(u8 boxNumber); struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 monPosition); void SetBoxMonNickAt(u8 boxId, u8 monPosition, const u8 *newNick); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index b81cf20c6..80003930b 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -3,27 +3,6 @@ #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; @@ -92,13 +71,13 @@ u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst) return 0; } -void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src) +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) +void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon * dst) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) *dst = gPokemonStoragePtr->boxes[boxId][boxPosition]; @@ -123,13 +102,13 @@ void ZeroBoxMonAt(u8 boxId, u8 boxPosition) ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]); } -void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst) +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) +struct BoxPokemon * GetBoxedMonPtr(u8 boxId, u8 boxPosition) { if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT) return &gPokemonStoragePtr->boxes[boxId][boxPosition]; @@ -159,17 +138,21 @@ void SetBoxWallpaper(u8 boxId, u8 wallpaperId) gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId; } -s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3) +s16 sub_808BDE8(struct BoxPokemon * boxMons, s8 currIndex, u8 maxIndex, u8 flags) { + // flags: + // bit 0: Allow eggs + // bit 1: Search backwards s16 i; - s16 adder = -1; - - if (arg3 < 2) + s16 adder; + if (flags == 0 || flags == 1) adder = 1; + else + adder = -1; - if (arg3 == 1 || arg3 == 3) + if (flags == 1 || flags == 3) { - for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + for (i = currIndex + adder; i >= 0 && i <= maxIndex; i += adder) { if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE) return i; @@ -177,7 +160,7 @@ s16 sub_808BDE8(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3) } else { - for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder) + for (i = currIndex + adder; i >= 0 && i <= maxIndex; i += adder) { if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE && !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG)) diff --git a/src/pokemon_storage_system_3.c b/src/pokemon_storage_system_3.c new file mode 100644 index 000000000..4dec36edd --- /dev/null +++ b/src/pokemon_storage_system_3.c @@ -0,0 +1,3 @@ +#include "global.h" +#include "gflib.h" + |