From a7e900e31b472385fda5fab48fc3c76212a0e0c2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 6 Jan 2018 12:47:00 -0500 Subject: StorageSystemGetNextMonIndex --- src/pokemon/pokemon_storage_system.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src') 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) { -- cgit v1.2.3