diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2018-01-06 12:47:00 -0500 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2018-01-06 12:47:00 -0500 |
commit | a7e900e31b472385fda5fab48fc3c76212a0e0c2 (patch) | |
tree | 7d15151066bac4fb47f6f6038fed797b7de82cc8 /src | |
parent | 4db981200c1d011c370a45d123c31b397b7d62cc (diff) |
StorageSystemGetNextMonIndex
Diffstat (limited to 'src')
-rw-r--r-- | src/pokemon/pokemon_storage_system.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 5cb61f365..745a27bf6 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -250,6 +250,37 @@ __attribute__((naked)) void unref_sub_8095D08(u16 *dest, u16 dest_left, u16 dest } #endif +s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode) +{ + s16 i; + s16 direction; + if (mode == 0 || mode == 2) + { + direction = 1; + } + else + { + direction = -1; + } + if (mode == 2 || mode == 3) + { + for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction) + { + if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0) + return i; + } + } + else + { + for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction) + { + if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0 && !GetBoxMonData(box + i, MON_DATA_IS_EGG)) + return i; + } + } + return -1; +} + asm(".section .text.8098898"); void sub_8098898(u8 index) { |