diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2018-01-06 10:49:52 -0500 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2018-01-06 10:49:52 -0500 |
commit | e4a84faabf3f4e2f005e55a88babce7e8ae49c58 (patch) | |
tree | 5ba51555a660ba2ba37a777049a647cae1c5ba68 | |
parent | 818dfa314e1658ab797af686fedd464c9fda6557 (diff) |
through unref_sub_8095C60
-rw-r--r-- | asm/pokemon_storage_system.s | 241 | ||||
-rw-r--r-- | include/decoration.h | 5 | ||||
-rw-r--r-- | include/pokemon.h | 8 | ||||
-rw-r--r-- | ld_script.txt | 3 | ||||
-rw-r--r-- | src/field/choose_party.c | 3 | ||||
-rw-r--r-- | src/field/field_effect.c | 1 | ||||
-rw-r--r-- | src/pokemon/pokemon_storage_system.c | 88 |
7 files changed, 97 insertions, 252 deletions
diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index 69c6d9e4f..211481692 100644 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -5,247 +5,6 @@ .text - thumb_func_start sub_8095ADC -sub_8095ADC: @ 8095ADC - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - movs r4, 0 - movs r5, 0 - lsls r1, r0, 2 - adds r1, r0 - lsls r0, r1, 4 - subs r0, r1 - lsls r6, r0, 5 -_08095AF0: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 4 - ldr r1, _08095B20 @ =gPokemonStorage + 0x4 - adds r0, r1 - adds r0, r6, r0 - movs r1, 0xB - bl GetBoxMonData - cmp r0, 0 - beq _08095B0C - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 -_08095B0C: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x1D - bls _08095AF0 - lsls r0, r5, 24 - lsrs r0, 24 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08095B20: .4byte gPokemonStorage + 0x4 - thumb_func_end sub_8095ADC - - thumb_func_start sub_8095B24 -sub_8095B24: @ 8095B24 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - movs r4, 0 - lsls r1, r0, 2 - adds r1, r0 - lsls r0, r1, 4 - subs r0, r1 - lsls r5, r0, 5 -_08095B36: - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 4 - ldr r1, _08095B54 @ =gPokemonStorage + 0x4 - adds r0, r1 - adds r0, r5, r0 - movs r1, 0xB - bl GetBoxMonData - cmp r0, 0 - bne _08095B58 - lsls r0, r4, 16 - asrs r0, 16 - b _08095B66 - .align 2, 0 -_08095B54: .4byte gPokemonStorage + 0x4 -_08095B58: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x1D - bls _08095B36 - movs r0, 0x1 - negs r0, r0 -_08095B66: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8095B24 - - thumb_func_start GetNumValidDaycarePartyMons -GetNumValidDaycarePartyMons: @ 8095B6C - push {r4-r6,lr} - movs r5, 0 - movs r6, 0 -_08095B72: - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, _08095BB0 @ =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08095B9A - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _08095B9A - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_08095B9A: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x5 - bls _08095B72 - lsls r0, r6, 24 - lsrs r0, 24 - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 -_08095BB0: .4byte gPlayerParty - thumb_func_end GetNumValidDaycarePartyMons - - thumb_func_start CountAlivePartyMonsExceptOne -CountAlivePartyMonsExceptOne: @ 8095BB4 - push {r4-r7,lr} - lsls r0, 24 - movs r5, 0 - movs r6, 0 - lsrs r7, r0, 24 -_08095BBE: - cmp r5, r7 - beq _08095BF6 - movs r0, 0x64 - adds r1, r5, 0 - muls r1, r0 - ldr r0, _08095C0C @ =gPlayerParty - adds r4, r1, r0 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08095BF6 - adds r0, r4, 0 - movs r1, 0x2D - bl GetMonData - cmp r0, 0 - bne _08095BF6 - adds r0, r4, 0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08095BF6 - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_08095BF6: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x5 - bls _08095BBE - lsls r0, r6, 24 - lsrs r0, 24 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_08095C0C: .4byte gPlayerParty - thumb_func_end CountAlivePartyMonsExceptOne - - thumb_func_start CountAlivePartyMonsExceptSelectedOne -CountAlivePartyMonsExceptSelectedOne: @ 8095C10 - push {lr} - ldr r0, _08095C24 @ =gSpecialVar_0x8004 - ldrb r0, [r0] - bl CountAlivePartyMonsExceptOne - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .align 2, 0 -_08095C24: .4byte gSpecialVar_0x8004 - thumb_func_end CountAlivePartyMonsExceptSelectedOne - - thumb_func_start StorageSystemGetPartySize -StorageSystemGetPartySize: @ 8095C28 - push {r4,r5,lr} - movs r4, 0 - movs r5, 0 -_08095C2E: - movs r0, 0x64 - muls r0, r4 - ldr r1, _08095C5C @ =gPlayerParty - adds r0, r1 - movs r1, 0xB - bl GetMonData - cmp r0, 0 - beq _08095C46 - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 -_08095C46: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x5 - bls _08095C2E - lsls r0, r5, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - .align 2, 0 -_08095C5C: .4byte gPlayerParty - thumb_func_end StorageSystemGetPartySize - - thumb_func_start unref_sub_8095C60 -unref_sub_8095C60: @ 8095C60 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r4, r2, 16 - lsrs r4, 16 - bl StringCopy - adds r1, r0, 0 - adds r5, r4 - cmp r1, r5 - bcs _08095C7E - movs r0, 0 -_08095C76: - strb r0, [r1] - adds r1, 0x1 - cmp r1, r5 - bcc _08095C76 -_08095C7E: - movs r0, 0xFF - strb r0, [r1] - adds r0, r1, 0 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end unref_sub_8095C60 - thumb_func_start sub_8095C8C sub_8095C8C: @ 8095C8C push {r4-r7,lr} diff --git a/include/decoration.h b/include/decoration.h index 972e82faf..3d619a598 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -127,10 +127,6 @@ extern u8 gUnknown_020388F5; extern u8 gUnknown_020388F6; extern u8 gUnknown_020388D6[16]; extern u8 gUnknown_020388E6[12]; -extern u16 gSpecialVar_0x8004; -extern u16 gSpecialVar_0x8005; -extern u16 gSpecialVar_0x8006; -extern u16 gSpecialVar_0x8007; extern u16 gUnknown_020391A4; extern u16 gUnknown_020391A6; extern u8 gUnknown_020391A8; @@ -161,7 +157,6 @@ extern const struct YesNoFuncTable gUnknown_083ECAA0; extern u8 sub_8134194(u8); // src/decoration_inventory extern bool8 sub_81341D4(void); // src/decoration_inventory extern void sub_8134104(u8); // src/decoration_inventory -extern bool8 sub_807D770(void); extern void sub_8109DAC(u8); // src/trader extern void ReshowPlayerPC(u8); // src/player_pc void Task_SecretBasePC_Decoration(u8); diff --git a/include/pokemon.h b/include/pokemon.h index a1c30f1f3..89599d994 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -418,10 +418,10 @@ struct BattleMove struct PokemonStorage { - /*0x00*/ u8 currentBox; - /*0x01*/ struct BoxPokemon boxes[14][30]; - u8 boxNames[14][9]; - u8 unkArray[14]; + /*0x0000*/ u8 currentBox; + /*0x0004*/ struct BoxPokemon boxes[14][30]; + /*0x8344*/ u8 boxNames[14][9]; + /*0x83c2*/ u8 unkArray[14]; }; struct SpindaSpot diff --git a/ld_script.txt b/ld_script.txt index 5bfc8b171..d0256f397 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -128,8 +128,9 @@ SECTIONS { src/engine/save_menu_util.o(.text); src/battle/battle_party_menu.o(.text); asm/unk_text_8095904.o(.text); - asm/pokemon_storage_system.o(.text); src/pokemon/pokemon_storage_system.o(.text); + asm/pokemon_storage_system.o(.text); + src/pokemon/pokemon_storage_system.o(.text.8098898); asm/pokemon_storage_system.o(.text_8098A38); src/pokemon/pokemon_icon.o(.text); src/pokemon/pokemon_summary_screen.o(.text); diff --git a/src/field/choose_party.c b/src/field/choose_party.c index d278eda4a..52763b911 100644 --- a/src/field/choose_party.c +++ b/src/field/choose_party.c @@ -1,5 +1,5 @@ #include "global.h" -#include "decoration.h" +#include "event_data.h" #include "field_fadetransition.h" #include "main.h" #include "menu.h" @@ -7,6 +7,7 @@ #include "palette.h" #include "party_menu.h" #include "pokemon_menu.h" +#include "field_weather.h" #include "pokemon.h" #include "pokemon_summary_screen.h" #include "overworld.h" diff --git a/src/field/field_effect.c b/src/field/field_effect.c index 1e2aaa4ed..1fe238901 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -25,6 +25,7 @@ #include "field_map_obj.h" #include "util.h" #include "field_effect_helpers.h" +#include "pokemon_storage_system.h" #define subsprite_table(ptr) {.subsprites = ptr, .subspriteCount = (sizeof ptr) / (sizeof(struct Subsprite))} diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index 4a68b846a..2ea7161cf 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -2,6 +2,7 @@ #include "pokemon_storage_system.h" #include "menu.h" #include "string_util.h" +#include "event_data.h" #include "ewram.h" struct StorageAction { @@ -13,6 +14,93 @@ extern const struct StorageAction gUnknown_083B6DF4[]; EWRAM_DATA struct PokemonStorage gPokemonStorage = {0}; +u8 sub_8095ADC(u8 boxId) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < 30; i++) + { + if (GetBoxMonData(gPokemonStorage.boxes[boxId] + i, MON_DATA_SPECIES) != 0) + count++; + } + return count; +} + +s16 sub_8095B24(u8 boxId) +{ + u16 i; + + for (i = 0; i < 30; i++) + { + if (GetBoxMonData(gPokemonStorage.boxes[boxId] + i, MON_DATA_SPECIES) == 0) + return i; + } + return -1; +} + +u8 GetNumValidDaycarePartyMons(void) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + struct Pokemon *pokemon = gPlayerParty + i; + if (GetMonData(pokemon, MON_DATA_SPECIES) != 0 && !GetMonData(pokemon, MON_DATA_IS_EGG)) + count++; + } + return count; +} + +u8 CountAlivePartyMonsExceptOne(u8 toSkip) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (i != toSkip) + { + struct Pokemon *pokemon = gPlayerParty + i; + if (GetMonData(pokemon, MON_DATA_SPECIES) != 0 && !GetMonData(pokemon, MON_DATA_IS_EGG) && GetMonData(pokemon, MON_DATA_HP) != 0) + count++; + } + } + return count; +} + +u8 CountAlivePartyMonsExceptSelectedOne(void) +{ + return CountAlivePartyMonsExceptOne(gSpecialVar_0x8004); +} + +u8 StorageSystemGetPartySize(void) +{ + u16 i; + u16 count; + + for (i = 0, count = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != 0) + count++; + } + return count; +} + +u8 *unref_sub_8095C60(u8 *dest, const u8 *src, u16 pad) +{ + u8 *_dest = StringCopy(dest, src); + while (_dest < dest + pad) + { + *_dest++ = CHAR_SPACE; + } + *_dest = EOS; + return _dest; +} + +asm(".section .text.8098898"); + void sub_8098898(u8 index) { u8 *ptr; |