summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-01-15 20:34:56 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2018-01-15 20:34:56 -0500
commit7a2eef97c35e4672bd17bfca86a6ea19d22a3eba (patch)
tree7e805b0687e1033c955b408532349445aae61a6b
parent7b45766d0765d42d7326a7f6cdb21a54d386117e (diff)
sub_809B960
-rw-r--r--asm/pokemon_storage_system.s277
-rw-r--r--include/pokemon_storage_system.h6
-rw-r--r--src/pokemon/pokemon_storage_system_4.c65
3 files changed, 68 insertions, 280 deletions
diff --git a/asm/pokemon_storage_system.s b/asm/pokemon_storage_system.s
index 7fa65b32a..d8305b190 100644
--- a/asm/pokemon_storage_system.s
+++ b/asm/pokemon_storage_system.s
@@ -5,283 +5,6 @@
.text
- thumb_func_start sub_809B960
-sub_809B960: @ 809B960
- push {r4-r7,lr}
- mov r7, r10
- mov r6, r9
- mov r5, r8
- push {r5-r7}
- ldr r0, _0809B988 @ =gPokemonStorageSystemPtr
- ldr r2, [r0]
- ldr r3, _0809B98C @ =0x0000267d
- adds r1, r2, r3
- ldrb r1, [r1]
- mov r12, r0
- cmp r1, 0
- beq _0809B994
- ldr r7, _0809B990 @ =0x0000267c
- adds r0, r2, r7
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- b _0809BB5C
- .align 2, 0
-_0809B988: .4byte gPokemonStorageSystemPtr
-_0809B98C: .4byte 0x0000267d
-_0809B990: .4byte 0x0000267c
-_0809B994:
- ldr r1, _0809B9A4 @ =0x00002684
- adds r0, r2, r1
- ldrh r0, [r0]
- cmp r0, 0
- beq _0809B9A8
- cmp r0, 0x1
- beq _0809BA84
- b _0809BB58
- .align 2, 0
-_0809B9A4: .4byte 0x00002684
-_0809B9A8:
- movs r5, 0
- movs r6, 0
-_0809B9AC:
- mov r2, r12
- ldr r4, [r2]
- ldr r3, _0809BA28 @ =0x00002682
- adds r0, r4, r3
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- cmp r0, 0xE
- bne _0809B9CC
- ldr r7, _0809BA2C @ =0x00002683
- adds r0, r4, r7
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- cmp r0, r5
- beq _0809BA02
-_0809B9CC:
- movs r0, 0x64
- muls r0, r5
- ldr r1, _0809BA30 @ =gPlayerParty
- adds r0, r1
- ldr r1, _0809BA34 @ =0x00002686
- adds r2, r4, r1
- movs r1, 0x50
- bl GetMonData
- lsls r0, 16
- lsrs r3, r0, 16
- movs r0, 0x1
- ands r0, r3
- cmp r0, 0
- beq _0809B9F0
- ldr r2, _0809BA38 @ =0x0000267e
- adds r0, r4, r2
- strb r6, [r0]
-_0809B9F0:
- movs r0, 0x2
- ands r3, r0
- ldr r7, _0809BA3C @ =gPokemonStorageSystemPtr
- mov r12, r7
- cmp r3, 0
- beq _0809BA02
- ldr r1, _0809BA40 @ =0x0000267f
- adds r0, r4, r1
- strb r6, [r0]
-_0809BA02:
- adds r0, r5, 0x1
- lsls r0, 16
- lsrs r5, r0, 16
- cmp r5, 0x5
- bls _0809B9AC
- mov r3, r12
- ldr r2, [r3]
- ldr r7, _0809BA38 @ =0x0000267e
- adds r0, r2, r7
- ldrh r0, [r0]
- cmp r0, 0
- bne _0809BA4C
- ldr r1, _0809BA44 @ =0x0000267d
- adds r0, r2, r1
- movs r1, 0x1
- strb r1, [r0]
- ldr r3, _0809BA48 @ =0x0000267c
- b _0809BB54
- .align 2, 0
-_0809BA28: .4byte 0x00002682
-_0809BA2C: .4byte 0x00002683
-_0809BA30: .4byte gPlayerParty
-_0809BA34: .4byte 0x00002686
-_0809BA38: .4byte 0x0000267e
-_0809BA3C: .4byte gPokemonStorageSystemPtr
-_0809BA40: .4byte 0x0000267f
-_0809BA44: .4byte 0x0000267d
-_0809BA48: .4byte 0x0000267c
-_0809BA4C:
- movs r7, 0x9A
- lsls r7, 6
- adds r0, r2, r7
- movs r1, 0
- strb r1, [r0]
- ldr r3, _0809BA68 @ =0x00002681
- adds r0, r2, r3
- strb r1, [r0]
- adds r7, 0x4
- adds r1, r2, r7
- ldrh r0, [r1]
- adds r0, 0x1
- strh r0, [r1]
- b _0809BB58
- .align 2, 0
-_0809BA68: .4byte 0x00002681
-_0809BA6C:
- ldr r1, _0809BA7C @ =0x0000267d
- adds r0, r2, r1
- movs r1, 0x1
- strb r1, [r0]
- ldr r7, _0809BA80 @ =0x0000267c
- adds r0, r2, r7
- strb r3, [r0]
- b _0809BB3C
- .align 2, 0
-_0809BA7C: .4byte 0x0000267d
-_0809BA80: .4byte 0x0000267c
-_0809BA84:
- movs r5, 0
- mov r9, r12
- adds r4, r2, 0
- movs r0, 0x9A
- lsls r0, 6
- adds r6, r4, r0
- ldr r1, _0809BB6C @ =0x0000267f
- adds r1, r4
- mov r8, r1
- ldr r2, _0809BB70 @ =0x0000ffff
- mov r10, r2
-_0809BA9A:
- movs r0, 0
- ldrsb r0, [r6, r0]
- lsls r1, r0, 2
- adds r1, r0
- lsls r0, r1, 4
- subs r0, r1
- lsls r0, 5
- ldr r3, _0809BB74 @ =0x00002681
- adds r1, r4, r3
- movs r2, 0
- ldrsb r2, [r1, r2]
- lsls r1, r2, 2
- adds r1, r2
- lsls r1, 4
- ldr r2, _0809BB78 @ =gPokemonStorage + 0x4
- adds r1, r2
- adds r0, r1
- movs r1, 0x50
- ldr r7, _0809BB7C @ =0x00002686
- adds r2, r4, r7
- bl GetBoxMonData
- lsls r0, 16
- lsrs r3, r0, 16
- cmp r3, 0
- beq _0809BB00
- ldr r1, _0809BB80 @ =0x00002682
- adds r0, r4, r1
- ldrh r0, [r0]
- ldrh r2, [r6]
- mov r1, r10
- ands r1, r0
- mov r0, r10
- ands r0, r2
- cmp r1, r0
- beq _0809BB00
- movs r0, 0x1
- ands r0, r3
- cmp r0, 0
- beq _0809BAF2
- ldr r2, _0809BB84 @ =0x0000267e
- adds r1, r4, r2
- movs r0, 0
- strb r0, [r1]
-_0809BAF2:
- movs r0, 0x2
- ands r3, r0
- cmp r3, 0
- beq _0809BB00
- movs r0, 0
- mov r3, r8
- strb r0, [r3]
-_0809BB00:
- mov r7, r9
- ldr r2, [r7]
- ldr r0, _0809BB74 @ =0x00002681
- adds r1, r2, r0
- ldrb r0, [r1]
- adds r0, 0x1
- movs r3, 0
- strb r0, [r1]
- lsls r0, 24
- asrs r0, 24
- ldr r7, _0809BB88 @ =gPokemonStorageSystemPtr
- mov r12, r7
- cmp r0, 0x1D
- ble _0809BB32
- strb r3, [r1]
- movs r0, 0x9A
- lsls r0, 6
- adds r1, r2, r0
- ldrb r0, [r1]
- adds r0, 0x1
- strb r0, [r1]
- lsls r0, 24
- asrs r0, 24
- cmp r0, 0xD
- bgt _0809BA6C
-_0809BB32:
- adds r0, r5, 0x1
- lsls r0, 16
- lsrs r5, r0, 16
- cmp r5, 0x4
- bls _0809BA9A
-_0809BB3C:
- mov r1, r12
- ldr r2, [r1]
- ldr r3, _0809BB84 @ =0x0000267e
- adds r0, r2, r3
- ldrh r0, [r0]
- cmp r0, 0
- bne _0809BB58
- ldr r7, _0809BB8C @ =0x0000267d
- adds r0, r2, r7
- movs r1, 0x1
- strb r1, [r0]
- subs r3, 0x2
-_0809BB54:
- adds r0, r2, r3
- strb r1, [r0]
-_0809BB58:
- movs r0, 0x1
- negs r0, r0
-_0809BB5C:
- pop {r3-r5}
- mov r8, r3
- mov r9, r4
- mov r10, r5
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0809BB6C: .4byte 0x0000267f
-_0809BB70: .4byte 0x0000ffff
-_0809BB74: .4byte 0x00002681
-_0809BB78: .4byte gPokemonStorage + 0x4
-_0809BB7C: .4byte 0x00002686
-_0809BB80: .4byte 0x00002682
-_0809BB84: .4byte 0x0000267e
-_0809BB88: .4byte gPokemonStorageSystemPtr
-_0809BB8C: .4byte 0x0000267d
- thumb_func_end sub_809B960
-
thumb_func_start sub_809BB90
sub_809BB90: @ 809BB90
push {lr}
diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h
index b0aa8cb47..8e50cc8d0 100644
--- a/include/pokemon_storage_system.h
+++ b/include/pokemon_storage_system.h
@@ -183,12 +183,12 @@ struct PokemonStorageSystemData {
struct UnkPSSStruct_2002370 unk_2370;
struct Pokemon unk_25b4;
struct Pokemon unk_2618;
- s8 unk_267c;
+ u8 unk_267c;
u8 unk_267d;
u8 unk_267e;
u8 unk_267f;
- u8 unk_2680;
- u8 unk_2681;
+ s8 unk_2680;
+ s8 unk_2681;
s8 unk_2682;
s8 unk_2683;
u16 unk_2684;
diff --git a/src/pokemon/pokemon_storage_system_4.c b/src/pokemon/pokemon_storage_system_4.c
index a0a6fa145..2469d42b1 100644
--- a/src/pokemon/pokemon_storage_system_4.c
+++ b/src/pokemon/pokemon_storage_system_4.c
@@ -1721,3 +1721,68 @@ void sub_809B7D4(void)
}
gPokemonStorageSystemPtr->unk_2684 = 0;
}
+
+s8 sub_809B960(void)
+{
+ u16 i;
+ u16 knownMoves;
+
+ if (gPokemonStorageSystemPtr->unk_267d)
+ return gPokemonStorageSystemPtr->unk_267c;
+ switch (gPokemonStorageSystemPtr->unk_2684)
+ {
+ case 0:
+ for (i = 0; i < PARTY_SIZE; i++)
+ {
+ if (gPokemonStorageSystemPtr->unk_2682 != 14 || gPokemonStorageSystemPtr->unk_2683 != i)
+ {
+ knownMoves = GetMonData(gPlayerParty + i, MON_DATA_KNOWN_MOVES, gPokemonStorageSystemPtr->unk_2686);
+ if (knownMoves & 1)
+ gPokemonStorageSystemPtr->unk_267e = 0;
+ if (knownMoves & 2)
+ gPokemonStorageSystemPtr->unk_267f = 0;
+ }
+ }
+ if (gPokemonStorageSystemPtr->unk_267e == 0 && gPokemonStorageSystemPtr->unk_267f == 0)
+ {
+ gPokemonStorageSystemPtr->unk_267d = 1;
+ gPokemonStorageSystemPtr->unk_267c = 1;
+ }
+ else
+ {
+ gPokemonStorageSystemPtr->unk_2680 = 0;
+ gPokemonStorageSystemPtr->unk_2681 = 0;
+ gPokemonStorageSystemPtr->unk_2684++;
+ }
+ break;
+ case 1:
+ for (i = 0; i < 5; i++)
+ {
+ knownMoves = GetBoxMonData(gPokemonStorage.boxes[gPokemonStorageSystemPtr->unk_2680] + gPokemonStorageSystemPtr->unk_2681, MON_DATA_KNOWN_MOVES, gPokemonStorageSystemPtr->unk_2686);
+ if (knownMoves && (gPokemonStorageSystemPtr->unk_2682 != gPokemonStorageSystemPtr->unk_2680 || gPokemonStorageSystemPtr->unk_2683 != gPokemonStorageSystemPtr->unk_2681))
+ {
+ if (knownMoves & 1)
+ gPokemonStorageSystemPtr->unk_267e = 0;
+ if (knownMoves & 2)
+ gPokemonStorageSystemPtr->unk_267f = 0;
+ }
+ if (++gPokemonStorageSystemPtr->unk_2681 >= 30)
+ {
+ gPokemonStorageSystemPtr->unk_2681 = 0;
+ if (++gPokemonStorageSystemPtr->unk_2680 >= 14)
+ {
+ gPokemonStorageSystemPtr->unk_267d = 1;
+ gPokemonStorageSystemPtr->unk_267c = 0;
+ break;
+ }
+ }
+ }
+ if (gPokemonStorageSystemPtr->unk_267e == 0 && gPokemonStorageSystemPtr->unk_267f == 0)
+ {
+ gPokemonStorageSystemPtr->unk_267d = 1;
+ gPokemonStorageSystemPtr->unk_267c = 1;
+ }
+ break;
+ }
+ return -1;
+}