diff options
-rw-r--r-- | asm/pokemon_storage_system.s | 284 | ||||
-rw-r--r-- | include/pokemon_storage_system.h | 8 | ||||
-rw-r--r-- | src/pokemon/pokemon_storage_system_2.c | 2 | ||||
-rw-r--r-- | src/pokemon/pokemon_storage_system_4.c | 75 |
4 files changed, 82 insertions, 287 deletions
diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s index d8305b190..dc3c9a339 100644 --- a/asm/pokemon_storage_system.s +++ b/asm/pokemon_storage_system.s @@ -5,290 +5,6 @@ .text - thumb_func_start sub_809BB90 -sub_809BB90: @ 809BB90 - push {lr} - ldr r0, _0809BBB0 @ =gUnknown_020384E6 - ldrb r0, [r0] - cmp r0, 0 - beq _0809BBAA - ldr r0, _0809BBB4 @ =gUnknown_02038480 - ldr r1, _0809BBB8 @ =gPokemonStorageSystemPtr - ldr r1, [r1] - ldr r2, _0809BBBC @ =0x000025b4 - adds r1, r2 - movs r2, 0x64 - bl memcpy -_0809BBAA: - pop {r0} - bx r0 - .align 2, 0 -_0809BBB0: .4byte gUnknown_020384E6 -_0809BBB4: .4byte gUnknown_02038480 -_0809BBB8: .4byte gPokemonStorageSystemPtr -_0809BBBC: .4byte 0x000025b4 - thumb_func_end sub_809BB90 - - thumb_func_start sub_809BBC0 -sub_809BBC0: @ 809BBC0 - push {lr} - ldr r0, _0809BBE4 @ =gUnknown_020384E6 - ldrb r0, [r0] - cmp r0, 0 - beq _0809BC08 - ldr r0, _0809BBE8 @ =gUnknown_020384E7 - ldrb r0, [r0] - cmp r0, 0xE - bne _0809BBF8 - ldr r0, _0809BBEC @ =gPokemonStorageSystemPtr - ldr r0, [r0] - ldr r1, _0809BBF0 @ =0x000025b4 - adds r0, r1 - ldr r1, _0809BBF4 @ =gUnknown_02038480 - movs r2, 0x64 - bl memcpy - b _0809BC08 - .align 2, 0 -_0809BBE4: .4byte gUnknown_020384E6 -_0809BBE8: .4byte gUnknown_020384E7 -_0809BBEC: .4byte gPokemonStorageSystemPtr -_0809BBF0: .4byte 0x000025b4 -_0809BBF4: .4byte gUnknown_02038480 -_0809BBF8: - ldr r0, _0809BC0C @ =gPokemonStorageSystemPtr - ldr r0, [r0] - ldr r1, _0809BC10 @ =0x000025b4 - adds r0, r1 - ldr r1, _0809BC14 @ =gUnknown_02038480 - movs r2, 0x50 - bl memcpy -_0809BC08: - pop {r0} - bx r0 - .align 2, 0 -_0809BC0C: .4byte gPokemonStorageSystemPtr -_0809BC10: .4byte 0x000025b4 -_0809BC14: .4byte gUnknown_02038480 - thumb_func_end sub_809BBC0 - - thumb_func_start sub_809BC18 -sub_809BC18: @ 809BC18 - push {r4,r5,lr} - ldr r0, _0809BC48 @ =gUnknown_020384E6 - ldrb r5, [r0] - cmp r5, 0 - beq _0809BC64 - bl sub_809BB90 - ldr r0, _0809BC4C @ =gPokemonStorageSystemPtr - ldr r2, [r0] - ldr r0, _0809BC50 @ =0x00002690 - adds r1, r2, r0 - ldr r0, _0809BC54 @ =gUnknown_02038480 - str r0, [r1] - ldr r1, _0809BC58 @ =0x0000268d - adds r0, r2, r1 - movs r1, 0 - strb r1, [r0] - ldr r3, _0809BC5C @ =0x0000268c - adds r0, r2, r3 - strb r1, [r0] - ldr r0, _0809BC60 @ =0x0000268e - adds r2, r0 - strb r1, [r2] - b _0809BCF2 - .align 2, 0 -_0809BC48: .4byte gUnknown_020384E6 -_0809BC4C: .4byte gPokemonStorageSystemPtr -_0809BC50: .4byte 0x00002690 -_0809BC54: .4byte gUnknown_02038480 -_0809BC58: .4byte 0x0000268d -_0809BC5C: .4byte 0x0000268c -_0809BC60: .4byte 0x0000268e -_0809BC64: - ldr r0, _0809BC9C @ =gUnknown_020384E4 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0x1 - bne _0809BCBC - ldr r0, _0809BCA0 @ =gPokemonStorageSystemPtr - ldr r4, [r0] - ldr r2, _0809BCA4 @ =0x00002690 - adds r1, r4, r2 - ldr r0, _0809BCA8 @ =gPlayerParty - str r0, [r1] - ldr r0, _0809BCAC @ =gUnknown_020384E5 - ldrb r1, [r0] - ldr r3, _0809BCB0 @ =0x0000268d - adds r0, r4, r3 - strb r1, [r0] - bl StorageSystemGetPartySize - subs r0, 0x1 - ldr r2, _0809BCB4 @ =0x0000268c - adds r1, r4, r2 - strb r0, [r1] - ldr r3, _0809BCB8 @ =0x0000268e - adds r4, r3 - strb r5, [r4] - b _0809BCF2 - .align 2, 0 -_0809BC9C: .4byte gUnknown_020384E4 -_0809BCA0: .4byte gPokemonStorageSystemPtr -_0809BCA4: .4byte 0x00002690 -_0809BCA8: .4byte gPlayerParty -_0809BCAC: .4byte gUnknown_020384E5 -_0809BCB0: .4byte 0x0000268d -_0809BCB4: .4byte 0x0000268c -_0809BCB8: .4byte 0x0000268e -_0809BCBC: - ldr r0, _0809BCF8 @ =gPokemonStorageSystemPtr - ldr r3, [r0] - ldr r0, _0809BCFC @ =0x00002690 - adds r4, r3, r0 - ldr r2, _0809BD00 @ =gPokemonStorage - ldrb r0, [r2] - lsls r1, r0, 2 - adds r1, r0 - lsls r0, r1, 4 - subs r0, r1 - lsls r0, 5 - adds r2, 0x4 - adds r0, r2 - str r0, [r4] - ldr r0, _0809BD04 @ =gUnknown_020384E5 - ldrb r1, [r0] - ldr r2, _0809BD08 @ =0x0000268d - adds r0, r3, r2 - strb r1, [r0] - ldr r0, _0809BD0C @ =0x0000268c - adds r1, r3, r0 - movs r0, 0x1D - strb r0, [r1] - ldr r1, _0809BD10 @ =0x0000268e - adds r3, r1 - movs r0, 0x5 - strb r0, [r3] -_0809BCF2: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_0809BCF8: .4byte gPokemonStorageSystemPtr -_0809BCFC: .4byte 0x00002690 -_0809BD00: .4byte gPokemonStorage -_0809BD04: .4byte gUnknown_020384E5 -_0809BD08: .4byte 0x0000268d -_0809BD0C: .4byte 0x0000268c -_0809BD10: .4byte 0x0000268e - thumb_func_end sub_809BC18 - - thumb_func_start sub_809BD14 -sub_809BD14: @ 809BD14 - push {lr} - ldr r0, _0809BD24 @ =gUnknown_020384E6 - ldrb r0, [r0] - cmp r0, 0 - beq _0809BD28 - bl sub_809BBC0 - b _0809BD30 - .align 2, 0 -_0809BD24: .4byte gUnknown_020384E6 -_0809BD28: - ldr r0, _0809BD34 @ =gUnknown_020384E5 - ldr r1, _0809BD38 @ =gSharedMem + 0x18000 - ldrb r1, [r1, 0x9] - strb r1, [r0] -_0809BD30: - pop {r0} - bx r0 - .align 2, 0 -_0809BD34: .4byte gUnknown_020384E5 -_0809BD38: .4byte gSharedMem + 0x18000 - thumb_func_end sub_809BD14 - - thumb_func_start party_compaction -party_compaction: @ 809BD3C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r7, _0809BD88 @ =0x0000ffff - movs r6, 0 - movs r5, 0 - movs r0, 0x64 - mov r9, r0 - ldr r1, _0809BD8C @ =gPlayerParty - mov r8, r1 - subs r0, 0x65 - mov r10, r0 -_0809BD58: - mov r0, r9 - muls r0, r6 - mov r1, r8 - adds r4, r0, r1 - adds r0, r4, 0 - movs r1, 0xB - bl GetMonData - lsls r0, 16 - cmp r0, 0 - beq _0809BD90 - cmp r6, r5 - beq _0809BD80 - mov r0, r9 - muls r0, r5 - add r0, r8 - adds r1, r4, 0 - movs r2, 0x64 - bl memcpy -_0809BD80: - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - b _0809BD9A - .align 2, 0 -_0809BD88: .4byte 0x0000ffff -_0809BD8C: .4byte gPlayerParty -_0809BD90: - lsls r0, r7, 16 - asrs r0, 16 - cmp r0, r10 - bne _0809BD9A - adds r7, r6, 0 -_0809BD9A: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - cmp r6, 0x5 - bls _0809BD58 - lsls r7, 16 - cmp r5, 0x5 - bhi _0809BDC2 - movs r6, 0x64 - ldr r4, _0809BDD4 @ =gPlayerParty -_0809BDAE: - adds r0, r5, 0 - muls r0, r6 - adds r0, r4 - bl ZeroMonData - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x5 - bls _0809BDAE -_0809BDC2: - asrs r0, r7, 16 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 -_0809BDD4: .4byte gPlayerParty - thumb_func_end party_compaction - thumb_func_start sub_809BDD8 sub_809BDD8: @ 809BDD8 push {r4,lr} diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h index 8e50cc8d0..f8d288ff0 100644 --- a/include/pokemon_storage_system.h +++ b/include/pokemon_storage_system.h @@ -196,7 +196,10 @@ struct PokemonStorageSystemData { u8 unk_268c; u8 unk_268d; u8 unk_268e; - struct Pokemon *unk_2690; + union { + struct Pokemon *pokemon; + struct BoxPokemon *box; + } unk_2690; u8 unk_2694[18]; u8 unk_26a6[62]; u8 unk_26e4[0x16]; @@ -215,6 +218,7 @@ extern struct UnkPSSStruct_2002370 *gUnknown_02038478; extern struct PokemonStorageSystemData *const gPokemonStorageSystemPtr; extern u8 *const gUnknown_083B6DB8; +u8 StorageSystemGetPartySize(void); s16 GetIndexOfFirstEmptySpaceInBoxN(u8 boxId); u8 CountPokemonInBoxN(u8 boxId); void sub_8096264(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3); @@ -277,7 +281,7 @@ void sub_809BB90(void); void sub_809BBC0(void); void sub_809BC18(void); void sub_809BD14(void); -void party_compaction(void); +s16 party_compaction(void); void sub_809BDD8(u8 markings); bool8 sub_809BE80(void); bool8 sub_809BEBC(void); diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index 4657ed158..512bde5db 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -343,7 +343,7 @@ void sub_8096B5C(void) switch (gPokemonStorageSystemPtr->unk_0006) { case 0: - ShowPokemonSummaryScreen(gPokemonStorageSystemPtr->unk_2690, gPokemonStorageSystemPtr->unk_268d, gPokemonStorageSystemPtr->unk_268c, sub_80969A0, gPokemonStorageSystemPtr->unk_268e); + ShowPokemonSummaryScreen(gPokemonStorageSystemPtr->unk_2690.pokemon, gPokemonStorageSystemPtr->unk_268d, gPokemonStorageSystemPtr->unk_268c, sub_80969A0, gPokemonStorageSystemPtr->unk_268e); break; case 1: DoNamingScreen(1, gPokemonStorage.boxNames[gPokemonStorage.currentBox], 0, 0, 0, sub_80969A0); diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c index 2469d42b1..40de7d634 100644 --- a/src/pokemon/pokemon_storage_system_4.c +++ b/src/pokemon/pokemon_storage_system_4.c @@ -1,12 +1,14 @@ // Includes #include "global.h" +#include "ewram.h" #include "constants/moves.h" #include "constants/species.h" #include "palette.h" #include "string_util.h" #include "text.h" #include "menu.h" +#include "pokemon_summary_screen.h" #include "pokemon_storage_system.h" // Static type declarations @@ -1786,3 +1788,76 @@ s8 sub_809B960(void) } return -1; } + +void sub_809BB90(void) +{ + if (gUnknown_020384E6) + gUnknown_02038480 = gPokemonStorageSystemPtr->unk_25b4; +} + +void sub_809BBC0(void) +{ + if (gUnknown_020384E6) + { + if (gUnknown_020384E7 == 14) + gPokemonStorageSystemPtr->unk_25b4 = gUnknown_02038480; + else + gPokemonStorageSystemPtr->unk_25b4.box = gUnknown_02038480.box; + } +} + +void sub_809BC18(void) +{ + if (gUnknown_020384E6) + { + sub_809BB90(); + gPokemonStorageSystemPtr->unk_2690.pokemon = &gUnknown_02038480; + gPokemonStorageSystemPtr->unk_268d = 0; + gPokemonStorageSystemPtr->unk_268c = 0; + gPokemonStorageSystemPtr->unk_268e = 0; + } + else if (gUnknown_020384E4 == 1) + { + gPokemonStorageSystemPtr->unk_2690.pokemon = gPlayerParty; + gPokemonStorageSystemPtr->unk_268d = gUnknown_020384E5; + gPokemonStorageSystemPtr->unk_268c = StorageSystemGetPartySize() - 1; + gPokemonStorageSystemPtr->unk_268e = 0; + } + else + { + gPokemonStorageSystemPtr->unk_2690.box = gPokemonStorage.boxes[gPokemonStorage.currentBox]; + gPokemonStorageSystemPtr->unk_268d = gUnknown_020384E5; + gPokemonStorageSystemPtr->unk_268c = 30 - 1; + gPokemonStorageSystemPtr->unk_268e = 5; + } +} + +void sub_809BD14(void) +{ + if (gUnknown_020384E6) + sub_809BBC0(); + else + gUnknown_020384E5 = pssData.monIndex; +} + +s16 party_compaction(void) +{ + s16 retVal = -1; + u16 i; + u16 last; + + for (i = 0, last = 0; i < PARTY_SIZE; i++) + { + if ((u16)GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != SPECIES_NONE) + { + if (i != last) + gPlayerParty[last] = gPlayerParty[i]; + last++; + } + else if (retVal == -1) + retVal = i; + } + for (; last < PARTY_SIZE; last++) + ZeroMonData(gPlayerParty + last); + return retVal; +} |