summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-01-15 19:32:02 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2018-01-15 19:32:02 -0500
commit7b45766d0765d42d7326a7f6cdb21a54d386117e (patch)
tree47d6aa11680310160389cf126061024c16dfddbe
parent08a108f432325d6501f3c6473a6d43265af0d5b7 (diff)
through sub_809B7D4
-rw-r--r--asm/pokemon_storage_system.s397
-rw-r--r--include/pokemon_storage_system.h18
-rw-r--r--src/pokemon/pokemon_2.c3
-rw-r--r--src/pokemon/pokemon_storage_system_4.c119
4 files changed, 138 insertions, 399 deletions
diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s
index e47abfda0..7fa65b32a 100644
--- a/asm/pokemon_storage_system.s
+++ b/asm/pokemon_storage_system.s
@@ -5,403 +5,6 @@
.text
- thumb_func_start sub_809B62C
-sub_809B62C: @ 809B62C
- push {r4-r6,lr}
- lsls r0, 24
- lsrs r6, r0, 24
- adds r0, r6, 0
- bl GetIndexOfFirstEmptySpaceInBoxN
- lsls r0, 16
- lsrs r4, r0, 16
- asrs r0, 16
- movs r1, 0x1
- negs r1, r1
- cmp r0, r1
- bne _0809B64A
- movs r0, 0
- b _0809B6AC
-_0809B64A:
- ldr r5, _0809B668 @ =gUnknown_020384E6
- ldrb r0, [r5]
- cmp r0, 0
- beq _0809B66C
- lsls r4, 24
- lsrs r1, r4, 24
- adds r0, r6, 0
- bl diegohint2
- bl sub_8099480
- movs r0, 0
- strb r0, [r5]
- b _0809B686
- .align 2, 0
-_0809B668: .4byte gUnknown_020384E6
-_0809B66C:
- ldr r5, _0809B6B4 @ =gUnknown_020384E5
- ldrb r1, [r5]
- movs r0, 0xE
- bl sub_809B44C
- lsls r4, 24
- lsrs r1, r4, 24
- adds r0, r6, 0
- bl diegohint2
- ldrb r0, [r5]
- bl sub_8099520
-_0809B686:
- bl get_preferred_box
- lsls r0, 24
- lsrs r0, 24
- cmp r6, r0
- bne _0809B698
- lsrs r0, r4, 24
- bl sub_8098D20
-_0809B698:
- ldr r0, _0809B6B8 @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- movs r1, 0x8E
- lsls r1, 5
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0x1
- bl StartSpriteAnim
- movs r0, 0x1
-_0809B6AC:
- pop {r4-r6}
- pop {r1}
- bx r1
- .align 2, 0
-_0809B6B4: .4byte gUnknown_020384E5
-_0809B6B8: .4byte gPokemonStorageSystemPtr
- thumb_func_end sub_809B62C
-
- thumb_func_start sub_809B6BC
-sub_809B6BC: @ 809B6BC
- push {lr}
- ldr r0, _0809B6D8 @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- movs r1, 0x8E
- lsls r1, 5
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0
- bl StartSpriteAnim
- bl sub_809BF74
- pop {r0}
- bx r0
- .align 2, 0
-_0809B6D8: .4byte gPokemonStorageSystemPtr
- thumb_func_end sub_809B6BC
-
- thumb_func_start sub_809B6DC
-sub_809B6DC: @ 809B6DC
- push {lr}
- ldr r0, _0809B6EC @ =gUnknown_020384E6
- ldrb r0, [r0]
- cmp r0, 0
- beq _0809B6F0
- movs r2, 0x2
- b _0809B700
- .align 2, 0
-_0809B6EC: .4byte gUnknown_020384E6
-_0809B6F0:
- ldr r0, _0809B720 @ =gUnknown_020384E4
- movs r1, 0
- ldrsb r1, [r0, r1]
- movs r2, 0x1
- eors r1, r2
- negs r0, r1
- orrs r0, r1
- lsrs r2, r0, 31
-_0809B700:
- ldr r0, _0809B724 @ =gUnknown_020384E5
- ldrb r1, [r0]
- adds r0, r2, 0
- bl sub_809981C
- ldr r0, _0809B728 @ =gPokemonStorageSystemPtr
- ldr r1, [r0]
- ldr r2, _0809B72C @ =0x000026e4
- adds r0, r1, r2
- ldr r2, _0809B730 @ =0x000011fa
- adds r1, r2
- bl StringCopy
- pop {r0}
- bx r0
- .align 2, 0
-_0809B720: .4byte gUnknown_020384E4
-_0809B724: .4byte gUnknown_020384E5
-_0809B728: .4byte gPokemonStorageSystemPtr
-_0809B72C: .4byte 0x000026e4
-_0809B730: .4byte 0x000011fa
- thumb_func_end sub_809B6DC
-
- thumb_func_start sub_809B734
-sub_809B734: @ 809B734
- push {lr}
- bl sub_80998D8
- lsls r0, 24
- cmp r0, 0
- beq _0809B744
- movs r0, 0x1
- b _0809B758
-_0809B744:
- ldr r0, _0809B75C @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- movs r1, 0x8E
- lsls r1, 5
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0
- bl StartSpriteAnim
- movs r0, 0
-_0809B758:
- pop {r1}
- bx r1
- .align 2, 0
-_0809B75C: .4byte gPokemonStorageSystemPtr
- thumb_func_end sub_809B734
-
- thumb_func_start sub_809B760
-sub_809B760: @ 809B760
- push {lr}
- bl sub_8099920
- ldr r1, _0809B774 @ =gUnknown_020384E6
- ldrb r0, [r1]
- cmp r0, 0
- beq _0809B778
- movs r0, 0
- strb r0, [r1]
- b _0809B79E
- .align 2, 0
-_0809B774: .4byte gUnknown_020384E6
-_0809B778:
- ldr r0, _0809B788 @ =gUnknown_020384E4
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- cmp r0, 0x1
- bne _0809B78C
- movs r2, 0xE
- b _0809B794
- .align 2, 0
-_0809B788: .4byte gUnknown_020384E4
-_0809B78C:
- bl get_preferred_box
- lsls r0, 24
- lsrs r2, r0, 24
-_0809B794:
- ldr r0, _0809B7A8 @ =gUnknown_020384E5
- ldrb r1, [r0]
- adds r0, r2, 0
- bl sub_809B548
-_0809B79E:
- bl sub_809BF74
- pop {r0}
- bx r0
- .align 2, 0
-_0809B7A8: .4byte gUnknown_020384E5
- thumb_func_end sub_809B760
-
- thumb_func_start sub_809B7AC
-sub_809B7AC: @ 809B7AC
- push {lr}
- ldr r0, _0809B7CC @ =gUnknown_020384E6
- ldrb r0, [r0]
- cmp r0, 0
- beq _0809B7C8
- ldr r0, _0809B7D0 @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- movs r1, 0x8E
- lsls r1, 5
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0x3
- bl StartSpriteAnim
-_0809B7C8:
- pop {r0}
- bx r0
- .align 2, 0
-_0809B7CC: .4byte gUnknown_020384E6
-_0809B7D0: .4byte gPokemonStorageSystemPtr
- thumb_func_end sub_809B7AC
-
- thumb_func_start sub_809B7D4
-sub_809B7D4: @ 809B7D4
- push {r4-r6,lr}
- ldr r0, _0809B804 @ =gUnknown_020384E6
- ldrb r0, [r0]
- cmp r0, 0
- beq _0809B81C
- ldr r0, _0809B808 @ =gPokemonStorageSystemPtr
- ldr r4, [r0]
- ldr r1, _0809B80C @ =0x00002618
- adds r0, r4, r1
- ldr r2, _0809B810 @ =0x000025b4
- adds r1, r4, r2
- movs r2, 0x64
- bl memcpy
- ldr r0, _0809B814 @ =0x00002682
- adds r1, r4, r0
- movs r0, 0xFF
- strb r0, [r1]
- ldr r1, _0809B818 @ =0x00002683
- adds r4, r1
- movs r0, 0x1
- negs r0, r0
- strb r0, [r4]
- b _0809B8A6
- .align 2, 0
-_0809B804: .4byte gUnknown_020384E6
-_0809B808: .4byte gPokemonStorageSystemPtr
-_0809B80C: .4byte 0x00002618
-_0809B810: .4byte 0x000025b4
-_0809B814: .4byte 0x00002682
-_0809B818: .4byte 0x00002683
-_0809B81C:
- ldr r0, _0809B84C @ =gUnknown_020384E4
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- cmp r0, 0x1
- bne _0809B864
- ldr r0, _0809B850 @ =gPokemonStorageSystemPtr
- ldr r4, [r0]
- ldr r2, _0809B854 @ =0x00002618
- adds r0, r4, r2
- ldr r3, _0809B858 @ =gPlayerParty
- ldr r1, _0809B85C @ =gUnknown_020384E5
- movs r2, 0
- ldrsb r2, [r1, r2]
- movs r1, 0x64
- muls r1, r2
- adds r1, r3
- movs r2, 0x64
- bl memcpy
- ldr r0, _0809B860 @ =0x00002682
- adds r4, r0
- movs r0, 0xE
- b _0809B896
- .align 2, 0
-_0809B84C: .4byte gUnknown_020384E4
-_0809B850: .4byte gPokemonStorageSystemPtr
-_0809B854: .4byte 0x00002618
-_0809B858: .4byte gPlayerParty
-_0809B85C: .4byte gUnknown_020384E5
-_0809B860: .4byte 0x00002682
-_0809B864:
- ldr r5, _0809B8FC @ =gPokemonStorage
- ldrb r0, [r5]
- lsls r1, r0, 2
- adds r1, r0
- lsls r0, r1, 4
- subs r0, r1
- lsls r0, 5
- ldr r1, _0809B900 @ =gUnknown_020384E5
- movs r2, 0
- ldrsb r2, [r1, r2]
- lsls r1, r2, 2
- adds r1, r2
- lsls r1, 4
- adds r2, r5, 0x4
- adds r1, r2
- adds r0, r1
- ldr r1, _0809B904 @ =gPokemonStorageSystemPtr
- ldr r4, [r1]
- ldr r2, _0809B908 @ =0x00002618
- adds r1, r4, r2
- bl ExpandBoxMon
- ldrb r0, [r5]
- ldr r1, _0809B90C @ =0x00002682
- adds r4, r1
-_0809B896:
- strb r0, [r4]
- ldr r0, _0809B904 @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- ldr r1, _0809B900 @ =gUnknown_020384E5
- ldrb r1, [r1]
- ldr r2, _0809B910 @ =0x00002683
- adds r0, r2
- strb r1, [r0]
-_0809B8A6:
- ldr r0, _0809B904 @ =gPokemonStorageSystemPtr
- ldr r6, [r0]
- ldr r0, _0809B914 @ =0x0000267e
- adds r4, r6, r0
- movs r0, 0
- strb r0, [r4]
- ldr r1, _0809B918 @ =0x0000267f
- adds r5, r6, r1
- strb r0, [r5]
- ldr r0, _0809B91C @ =0x00002686
- adds r2, r6, r0
- movs r0, 0x39
- strh r0, [r2]
- ldr r0, _0809B920 @ =0x00002688
- adds r1, r6, r0
- ldr r0, _0809B924 @ =0x00000123
- strh r0, [r1]
- ldr r0, _0809B928 @ =0x0000268a
- adds r1, r6, r0
- ldr r0, _0809B92C @ =0x00000163
- strh r0, [r1]
- ldr r1, _0809B908 @ =0x00002618
- adds r0, r6, r1
- movs r1, 0x50
- bl GetMonData
- lsls r0, 16
- lsrs r1, r0, 16
- movs r2, 0x1
- ands r1, r2
- strb r1, [r4]
- lsrs r0, 17
- movs r1, 0x1
- ands r0, r1
- strb r0, [r5]
- ldrh r0, [r4]
- cmp r0, 0
- beq _0809B934
- ldr r2, _0809B930 @ =0x0000267d
- adds r1, r6, r2
- movs r0, 0
- strb r0, [r1]
- b _0809B940
- .align 2, 0
-_0809B8FC: .4byte gPokemonStorage
-_0809B900: .4byte gUnknown_020384E5
-_0809B904: .4byte gPokemonStorageSystemPtr
-_0809B908: .4byte 0x00002618
-_0809B90C: .4byte 0x00002682
-_0809B910: .4byte 0x00002683
-_0809B914: .4byte 0x0000267e
-_0809B918: .4byte 0x0000267f
-_0809B91C: .4byte 0x00002686
-_0809B920: .4byte 0x00002688
-_0809B924: .4byte 0x00000123
-_0809B928: .4byte 0x0000268a
-_0809B92C: .4byte 0x00000163
-_0809B930: .4byte 0x0000267d
-_0809B934:
- ldr r2, _0809B954 @ =0x0000267d
- adds r0, r6, r2
- strb r1, [r0]
- subs r2, 0x1
- adds r0, r6, r2
- strb r1, [r0]
-_0809B940:
- ldr r0, _0809B958 @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- ldr r1, _0809B95C @ =0x00002684
- adds r0, r1
- movs r1, 0
- strh r1, [r0]
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2, 0
-_0809B954: .4byte 0x0000267d
-_0809B958: .4byte gPokemonStorageSystemPtr
-_0809B95C: .4byte 0x00002684
- thumb_func_end sub_809B7D4
-
thumb_func_start sub_809B960
sub_809B960: @ 809B960
push {r4-r7,lr}
diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h
index 7960213ae..b0aa8cb47 100644
--- a/include/pokemon_storage_system.h
+++ b/include/pokemon_storage_system.h
@@ -183,7 +183,16 @@ struct PokemonStorageSystemData {
struct UnkPSSStruct_2002370 unk_2370;
struct Pokemon unk_25b4;
struct Pokemon unk_2618;
- u8 filler_267c[0x10];
+ s8 unk_267c;
+ u8 unk_267d;
+ u8 unk_267e;
+ u8 unk_267f;
+ u8 unk_2680;
+ u8 unk_2681;
+ s8 unk_2682;
+ s8 unk_2683;
+ u16 unk_2684;
+ u16 unk_2686[3];
u8 unk_268c;
u8 unk_268d;
u8 unk_268e;
@@ -206,6 +215,7 @@ extern struct UnkPSSStruct_2002370 *gUnknown_02038478;
extern struct PokemonStorageSystemData *const gPokemonStorageSystemPtr;
extern u8 *const gUnknown_083B6DB8;
+s16 GetIndexOfFirstEmptySpaceInBoxN(u8 boxId);
u8 CountPokemonInBoxN(u8 boxId);
void sub_8096264(struct UnkPSSStruct_2002370 *a0, u16 tileTag, u16 palTag, u8 a3);
void sub_809634C(u8 curBox);
@@ -219,16 +229,22 @@ void ResetPSSMonIconSprites(void);
void SpawnBoxIconSprites(u8 boxId);
u8 get_preferred_box(void);
void sub_8098BF0(void);
+void sub_8098D20(u8 monId);
bool8 sub_80990AC(void);
void sub_8099200(bool8 a0);
void sub_8099310(void);
bool8 sub_8099374(void);
+void sub_8099480(void);
void sub_80994A8(s16 a0);
+void sub_8099520(u8 a0);
void sub_809954C(void);
void sub_8099584(u8 a0, u8 a1);
void sub_809960C(u8 a0, u8 a1);
void sub_80996B0(u8 a0, u8 a1);
bool8 sub_809971C(void);
+void sub_809981C(u8 mode, u8 idx);
+bool8 sub_80998D8(void);
+void sub_8099920(void);
void sub_8099958(void);
bool8 sub_8099990(void);
struct Sprite *sub_809A9A0(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority);
diff --git a/src/pokemon/pokemon_2.c b/src/pokemon/pokemon_2.c
index b941ed2ab..7fd1aa7b2 100644
--- a/src/pokemon/pokemon_2.c
+++ b/src/pokemon/pokemon_2.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "constants/hold_effects.h"
+#include "constants/moves.h"
#include "battle.h"
#include "battle_util.h"
#include "data2.h"
@@ -569,7 +570,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
u16 *moves = (u16 *)data;
s32 i = 0;
- while (moves[i] != 355)
+ while (moves[i] != NUM_MOVES)
{
u16 move = moves[i];
if (substruct1->moves[0] == move
diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c
index 73d71fa0e..a0a6fa145 100644
--- a/src/pokemon/pokemon_storage_system_4.c
+++ b/src/pokemon/pokemon_storage_system_4.c
@@ -1,8 +1,10 @@
// Includes
#include "global.h"
+#include "constants/moves.h"
#include "constants/species.h"
#include "palette.h"
+#include "string_util.h"
#include "text.h"
#include "menu.h"
#include "pokemon_storage_system.h"
@@ -1602,3 +1604,120 @@ void diegohint1(u8 a0, u8 a1)
gUnknown_020384E7 = a0;
gUnknown_020384E8 = a1;
}
+
+bool8 sub_809B62C(u8 boxId)
+{
+ s16 monIdx = GetIndexOfFirstEmptySpaceInBoxN(boxId);
+ if (monIdx == -1)
+ return FALSE;
+ if (gUnknown_020384E6)
+ {
+ diegohint2(boxId, monIdx);
+ sub_8099480();
+ gUnknown_020384E6 = 0;
+ }
+ else
+ {
+ sub_809B44C(14, gUnknown_020384E5);
+ diegohint2(boxId, monIdx);
+ sub_8099520(gUnknown_020384E5);
+ }
+ if (boxId == get_preferred_box())
+ sub_8098D20(monIdx);
+ StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 1);
+ return TRUE;
+}
+
+void sub_809B6BC(void)
+{
+ StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0);
+ sub_809BF74();
+}
+
+void sub_809B6DC(void)
+{
+ u8 mode;
+
+ if (gUnknown_020384E6)
+ mode = 2;
+ else if (gUnknown_020384E4 == 1)
+ mode = 0;
+ else
+ mode = 1;
+ sub_809981C(mode, gUnknown_020384E5);
+ StringCopy(gPokemonStorageSystemPtr->unk_26e4, gPokemonStorageSystemPtr->unk_11fa);
+}
+
+bool8 sub_809B734(void)
+{
+ if (!sub_80998D8())
+ {
+ StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 0);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void sub_809B760(void)
+{
+ sub_8099920();
+ if (gUnknown_020384E6)
+ gUnknown_020384E6 = 0;
+ else
+ {
+ u8 boxId;
+ if (gUnknown_020384E4 == 1)
+ boxId = 14;
+ else
+ boxId = get_preferred_box();
+ sub_809B548(boxId, gUnknown_020384E5);
+ }
+ sub_809BF74();
+}
+
+void sub_809B7AC(void)
+{
+ if (gUnknown_020384E6)
+ StartSpriteAnim(gPokemonStorageSystemPtr->unk_11c0, 3);
+}
+
+void sub_809B7D4(void)
+{
+ u16 knownMoves;
+ if (gUnknown_020384E6)
+ {
+ gPokemonStorageSystemPtr->unk_2618 = gPokemonStorageSystemPtr->unk_25b4;
+ gPokemonStorageSystemPtr->unk_2682 = -1;
+ gPokemonStorageSystemPtr->unk_2683 = -1;
+ }
+ else
+ {
+ if (gUnknown_020384E4 == 1)
+ {
+ gPokemonStorageSystemPtr->unk_2618 = gPlayerParty[gUnknown_020384E5];
+ gPokemonStorageSystemPtr->unk_2682 = 14;
+ }
+ else
+ {
+ ExpandBoxMon(gPokemonStorage.boxes[gPokemonStorage.currentBox] + gUnknown_020384E5, &gPokemonStorageSystemPtr->unk_2618);
+ gPokemonStorageSystemPtr->unk_2682 = gPokemonStorage.currentBox;
+ }
+ gPokemonStorageSystemPtr->unk_2683 = gUnknown_020384E5;
+ }
+ gPokemonStorageSystemPtr->unk_267e = 0;
+ gPokemonStorageSystemPtr->unk_267f = 0;
+ gPokemonStorageSystemPtr->unk_2686[0] = MOVE_SURF;
+ gPokemonStorageSystemPtr->unk_2686[1] = MOVE_DIVE;
+ gPokemonStorageSystemPtr->unk_2686[2] = NUM_MOVES;
+ knownMoves = GetMonData(&gPokemonStorageSystemPtr->unk_2618, MON_DATA_KNOWN_MOVES, gPokemonStorageSystemPtr->unk_2686);
+ gPokemonStorageSystemPtr->unk_267e = knownMoves & 1;
+ gPokemonStorageSystemPtr->unk_267f = (knownMoves >> 1) & 1;
+ if (gPokemonStorageSystemPtr->unk_267e || gPokemonStorageSystemPtr->unk_267f)
+ gPokemonStorageSystemPtr->unk_267d = 0;
+ else
+ {
+ gPokemonStorageSystemPtr->unk_267d = 1;
+ gPokemonStorageSystemPtr->unk_267c = 1;
+ }
+ gPokemonStorageSystemPtr->unk_2684 = 0;
+}