summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/pokemon_storage_system.s226
-rw-r--r--include/pokemon_storage_system.h22
-rw-r--r--ld_script.txt1
-rw-r--r--src/pokemon/pokemon_storage_system_4.c71
-rw-r--r--src/pokemon/pokemon_storage_system_6.c14
5 files changed, 106 insertions, 228 deletions
diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s
index 41987f841..e66901961 100644
--- a/asm/pokemon_storage_system.s
+++ b/asm/pokemon_storage_system.s
@@ -5,232 +5,6 @@
.text
- thumb_func_start sub_8099BF8
-sub_8099BF8: @ 8099BF8
- push {r4,lr}
- sub sp, 0x4
- adds r4, r0, 0
- lsls r4, 24
- lsrs r4, 24
- ldr r0, _08099C50 @ =gPokemonStorageSystemPtr
- ldr r0, [r0]
- ldr r1, _08099C54 @ =0x000008ba
- adds r2, r0, r1
- movs r1, 0
- strb r1, [r2]
- ldr r2, _08099C58 @ =0x000008b4
- adds r0, r2
- strh r1, [r0]
- str r1, [sp]
- ldr r1, _08099C5C @ =0x040000d4
- mov r0, sp
- str r0, [r1]
- ldr r0, _08099C60 @ =0x0600d000
- str r0, [r1, 0x4]
- ldr r0, _08099C64 @ =0x85000400
- str r0, [r1, 0x8]
- ldr r0, [r1, 0x8]
- adds r0, r4, 0
- movs r1, 0
- bl sub_8099EB0
- adds r0, r4, 0
- bl sub_809A23C
- bl sub_809A6DC
- adds r0, r4, 0
- bl SpawnBoxIconSprites
- ldr r1, _08099C68 @ =REG_BG2CNT
- ldr r2, _08099C6C @ =0x00005a0a
- adds r0, r2, 0
- strh r0, [r1]
- add sp, 0x4
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_08099C50: .4byte gPokemonStorageSystemPtr
-_08099C54: .4byte 0x000008ba
-_08099C58: .4byte 0x000008b4
-_08099C5C: .4byte 0x040000d4
-_08099C60: .4byte 0x0600d000
-_08099C64: .4byte 0x85000400
-_08099C68: .4byte REG_BG2CNT
-_08099C6C: .4byte 0x00005a0a
- thumb_func_end sub_8099BF8
-
- thumb_func_start sub_8099C70
-sub_8099C70: @ 8099C70
- push {r4,r5,lr}
- lsls r0, 24
- lsrs r0, 24
- adds r5, r0, 0
- bl sub_8099D90
- lsls r0, 24
- asrs r4, r0, 24
- adds r0, r5, 0
- adds r1, r4, 0
- bl sub_8099EB0
- ldr r0, _08099D10 @ =gPokemonStorageSystemPtr
- ldr r2, [r0]
- lsls r0, r4, 1
- adds r0, r4
- lsls r0, 1
- ldr r3, _08099D14 @ =0x000008b6
- adds r1, r2, r3
- strh r0, [r1]
- ldr r0, _08099D18 @ =0x000008b8
- adds r1, r2, r0
- movs r0, 0x20
- strh r0, [r1]
- ldr r1, _08099D1C @ =0x000008bb
- adds r0, r2, r1
- strb r5, [r0]
- movs r1, 0
- cmp r4, 0
- bgt _08099CAE
- movs r1, 0x5
-_08099CAE:
- ldr r3, _08099D20 @ =0x000008bc
- adds r0, r2, r3
- strh r1, [r0]
- ldr r1, _08099D24 @ =0x000008be
- adds r0, r2, r1
- strh r4, [r0]
- movs r1, 0x38
- cmp r4, 0
- ble _08099CC6
- movs r3, 0x84
- lsls r3, 1
- adds r1, r3, 0
-_08099CC6:
- movs r3, 0x8C
- lsls r3, 4
- adds r0, r2, r3
- strh r1, [r0]
- movs r1, 0
- cmp r4, 0
- bgt _08099CD6
- movs r1, 0x5
-_08099CD6:
- ldr r3, _08099D28 @ =0x000008c2
- adds r0, r2, r3
- strh r1, [r0]
- ldr r1, _08099D2C @ =0x000008c4
- adds r0, r2, r1
- strh r4, [r0]
- adds r3, 0x4
- adds r1, r2, r3
- movs r0, 0
- strh r0, [r1]
- ldr r0, _08099D30 @ =0x000008c8
- adds r1, r2, r0
- movs r0, 0x2
- strh r0, [r1]
- adds r0, r5, 0
- adds r1, r4, 0
- bl sub_809900C
- adds r0, r5, 0
- adds r1, r4, 0
- bl sub_809A3D0
- adds r0, r4, 0
- bl sub_809A774
- pop {r4,r5}
- pop {r0}
- bx r0
- .align 2, 0
-_08099D10: .4byte gPokemonStorageSystemPtr
-_08099D14: .4byte 0x000008b6
-_08099D18: .4byte 0x000008b8
-_08099D1C: .4byte 0x000008bb
-_08099D20: .4byte 0x000008bc
-_08099D24: .4byte 0x000008be
-_08099D28: .4byte 0x000008c2
-_08099D2C: .4byte 0x000008c4
-_08099D30: .4byte 0x000008c8
- thumb_func_end sub_8099C70
-
- thumb_func_start sub_8099D34
-sub_8099D34: @ 8099D34
- push {r4,lr}
- bl sub_80990AC
- lsls r0, 24
- lsrs r2, r0, 24
- ldr r0, _08099D78 @ =gPokemonStorageSystemPtr
- ldr r1, [r0]
- ldr r0, _08099D7C @ =0x000008b8
- adds r3, r1, r0
- ldrh r0, [r3]
- cmp r0, 0
- beq _08099D88
- ldr r4, _08099D80 @ =0x000008b4
- adds r2, r1, r4
- adds r4, 0x2
- adds r0, r1, r4
- ldrh r0, [r0]
- ldrh r1, [r2]
- adds r0, r1
- ldr r1, _08099D84 @ =0x000001ff
- ands r0, r1
- strh r0, [r2]
- ldrh r0, [r3]
- subs r0, 0x1
- strh r0, [r3]
- lsls r0, 16
- cmp r0, 0
- bne _08099D74
- bl sub_809A598
- bl sub_809A810
-_08099D74:
- movs r0, 0x1
- b _08099D8A
- .align 2, 0
-_08099D78: .4byte gPokemonStorageSystemPtr
-_08099D7C: .4byte 0x000008b8
-_08099D80: .4byte 0x000008b4
-_08099D84: .4byte 0x000001ff
-_08099D88:
- adds r0, r2, 0
-_08099D8A:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_8099D34
-
- thumb_func_start sub_8099D90
-sub_8099D90: @ 8099D90
- push {r4,lr}
- lsls r0, 24
- lsrs r4, r0, 24
- bl get_preferred_box
- lsls r0, 24
- lsrs r1, r0, 24
- movs r2, 0
- cmp r1, r4
- beq _08099DBA
-_08099DA4:
- adds r0, r1, 0x1
- lsls r0, 24
- lsrs r1, r0, 24
- cmp r1, 0xD
- bls _08099DB0
- movs r1, 0
-_08099DB0:
- adds r0, r2, 0x1
- lsls r0, 24
- lsrs r2, r0, 24
- cmp r1, r4
- bne _08099DA4
-_08099DBA:
- movs r0, 0x1
- negs r0, r0
- cmp r2, 0x6
- bhi _08099DC4
- movs r0, 0x1
-_08099DC4:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_8099D90
-
thumb_func_start sub_8099DCC
sub_8099DCC: @ 8099DCC
push {r4,lr}
diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h
index 129202934..09b3be60f 100644
--- a/include/pokemon_storage_system.h
+++ b/include/pokemon_storage_system.h
@@ -99,11 +99,26 @@ struct PokemonStorageSystemData {
bool8 unk_08b1;
s16 unk_08b2;
u16 unk_08b4;
- u8 filler_08b6[0x4a6];
+ u16 unk_08b6;
+ u16 unk_08b8;
+ u8 unk_08ba;
+ u8 unk_08bb;
+ u16 unk_08bc;
+ u16 unk_08be;
+ u16 unk_08c0;
+ u16 unk_08c2;
+ u16 unk_08c4;
+ u16 unk_08c6;
+ u16 unk_08c8;
+ u8 unk_08ca[0x400];
+ u8 unk_0cca;
+ u16 unk_0ccc[0x20];
+ u8 filler_0d0c[0x50];
u16 unk_0d5c;
s16 unk_0d5e;
s16 unk_0d60;
- u8 filler_0d62[0x2d2];
+ u8 unk_0d62[0x2d0];
+ u8 unk_1032;
struct Sprite *unk_1034;
struct Sprite *unk_1038[6]; // party
struct Sprite *unk_1050[30]; // box
@@ -177,6 +192,9 @@ void sub_80961A8(void);
void task_intro_29(u8 whichMenu);
void ResetPokemonStorageSystem(void);
void ResetPSSMonIconSprites(void);
+void SpawnBoxIconSprites(u8 boxId);
+u8 get_preferred_box(void);
+bool8 sub_80990AC(void);
void sub_8099200(bool8 a0);
void sub_8099310(void);
bool8 sub_8099374(void);
diff --git a/ld_script.txt b/ld_script.txt
index f14352a4e..e1d28736e 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -133,6 +133,7 @@ SECTIONS {
src/pokemon/pokemon_storage_system_3.o(.text);
src/pokemon/pokemon_storage_system_4.o(.text);
src/pokemon/pokemon_storage_system_5.o(.text);
+ src/pokemon/pokemon_storage_system_6.o(.text);
asm/pokemon_storage_system.o(.text);
src/pokemon/pokemon_icon.o(.text);
src/pokemon/pokemon_summary_screen.o(.text);
diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c
index f7a008db2..697292d5c 100644
--- a/src/pokemon/pokemon_storage_system_4.c
+++ b/src/pokemon/pokemon_storage_system_4.c
@@ -18,6 +18,77 @@ EWRAM_DATA u16 gUnknown_020384EA = 0;
// Static ROM declarations
+void sub_809900C(u8 boxId, s8 a1);
+s8 sub_8099D90(u8 boxId);
+void sub_8099EB0(u8 boxId, s8 a1);
+void sub_809A23C(u8 boxId);
+void sub_809A3D0(u8 boxId, s8 a1);
+void sub_809A598(void);
+void sub_809A6DC(void);
+void sub_809A774(s8 a0);
+void sub_809A810(void);
+
// .rodata
// .text
+
+void sub_8099BF8(u8 boxId)
+{
+ gPokemonStorageSystemPtr->unk_08ba = 0;
+ gPokemonStorageSystemPtr->unk_08b4 = 0;
+ DmaFill32(3, 0, BG_SCREEN_ADDR(26), 0x1000);
+ sub_8099EB0(boxId, 0);
+ sub_809A23C(boxId);
+ sub_809A6DC();
+ SpawnBoxIconSprites(boxId);
+ REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_TXT512x256;
+}
+
+void sub_8099C70(u8 whichBox)
+{
+ s8 r4 = sub_8099D90(whichBox);
+ sub_8099EB0(whichBox, r4);
+ gPokemonStorageSystemPtr->unk_08b6 = r4 * 6;
+ gPokemonStorageSystemPtr->unk_08b8 = 0x20;
+ gPokemonStorageSystemPtr->unk_08bb = whichBox;
+ gPokemonStorageSystemPtr->unk_08bc = r4 > 0 ? 0 : 5;
+ gPokemonStorageSystemPtr->unk_08be = r4;
+ gPokemonStorageSystemPtr->unk_08c0 = r4 > 0 ? 0x108 : 0x38;
+ gPokemonStorageSystemPtr->unk_08c2 = r4 > 0 ? 0 : 5;
+ gPokemonStorageSystemPtr->unk_08c4 = r4;
+ gPokemonStorageSystemPtr->unk_08c6 = 0;
+ gPokemonStorageSystemPtr->unk_08c8 = 2;
+ sub_809900C(whichBox, r4);
+ sub_809A3D0(whichBox, r4);
+ sub_809A774(r4);
+}
+
+bool8 sub_8099D34(void)
+{
+ bool8 retVal = sub_80990AC();
+ if (gPokemonStorageSystemPtr->unk_08b8 != 0)
+ {
+ gPokemonStorageSystemPtr->unk_08b4 += gPokemonStorageSystemPtr->unk_08b6;
+ gPokemonStorageSystemPtr->unk_08b4 &= 0x1ff;
+ if (--gPokemonStorageSystemPtr->unk_08b8 == 0)
+ {
+ sub_809A598();
+ sub_809A810();
+ }
+ return TRUE;
+ }
+ return retVal;
+}
+
+s8 sub_8099D90(u8 boxId)
+{
+ u8 curBox = get_preferred_box();
+ u8 i;
+
+ for (i = 0; curBox != boxId; i++)
+ {
+ if (++curBox >= 14)
+ curBox = 0;
+ }
+ return i <= 6 ? 1 : -1;
+}
diff --git a/src/pokemon/pokemon_storage_system_6.c b/src/pokemon/pokemon_storage_system_6.c
new file mode 100644
index 000000000..a781c1ed2
--- /dev/null
+++ b/src/pokemon/pokemon_storage_system_6.c
@@ -0,0 +1,14 @@
+
+// Includes
+#include "global.h"
+#include "pokemon_storage_system.h"
+
+// Static type declarations
+
+// Static RAM declarations
+
+// Static ROM declarations
+
+// .rodata
+
+// .text