summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/code_8027C84.s4
-rw-r--r--asm/code_803B050.s4
-rw-r--r--asm/code_8057824.s20
-rw-r--r--asm/code_8097670.s4
-rw-r--r--asm/friend_area_action_menu.s6
-rw-r--r--asm/friend_list_menu.s34
-rw-r--r--asm/pokemon.s129
-rw-r--r--asm/pokemon_1.s72
-rw-r--r--asm/pokemon_2.s1117
-rw-r--r--asm/pokemon_3.s65
-rw-r--r--include/file_system.h1
-rw-r--r--include/item.h1
-rw-r--r--include/pokemon.h128
-rwxr-xr-xld_script.txt2
-rw-r--r--src/code_80958E8.c6
-rw-r--r--src/debug_menu_1.c2
-rw-r--r--src/debug_menu_2.c2
-rw-r--r--src/friend_area_action_menu_1.c4
-rw-r--r--src/items.c16
-rw-r--r--src/pokemon.c6
-rw-r--r--src/pokemon_1.c200
-rw-r--r--src/pokemon_3.c189
-rw-r--r--src/pokemon_mid.c687
-rw-r--r--tools/scaninc/scaninc.cpp256
-rw-r--r--tools/scaninc/source_file.cpp260
25 files changed, 1291 insertions, 1924 deletions
diff --git a/asm/code_8027C84.s b/asm/code_8027C84.s
index 5057e00..c9fdacd 100644
--- a/asm/code_8027C84.s
+++ b/asm/code_8027C84.s
@@ -320,7 +320,7 @@ _08027ED8:
movs r2, 0x8
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
movs r0, 0x6
bl sub_8027184
b _08027F82
@@ -371,7 +371,7 @@ _08027F52:
movs r2, 0x8
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
movs r0, 0x7
bl sub_8027184
b _08027F82
diff --git a/asm/code_803B050.s b/asm/code_803B050.s
index c9ff87c..1b59946 100644
--- a/asm/code_803B050.s
+++ b/asm/code_803B050.s
@@ -2062,7 +2062,7 @@ sub_803C0DC:
push {lr}
lsls r0, 16
asrs r0, 16
- bl sub_808E770
+ bl GetBaseSpecies
lsls r0, 16
asrs r2, r0, 16
ldr r1, _0803C0F0
@@ -2100,7 +2100,7 @@ sub_803C110:
cmp r0, 0
beq _0803C180
adds r0, r4, 0
- bl sub_808E770
+ bl GetBaseSpecies
lsls r0, 16
asrs r0, 16
cmp r4, r0
diff --git a/asm/code_8057824.s b/asm/code_8057824.s
index 8cf0799..b715023 100644
--- a/asm/code_8057824.s
+++ b/asm/code_8057824.s
@@ -33850,7 +33850,7 @@ _08068922:
mov r9, r0
adds r0, r2, r0
mov r1, r10
- bl sub_808DE30
+ bl xxx_pokemonstruct_index_to_unk_808DE30
ldr r0, _08068A68
ldr r0, [r0]
ldr r1, _08068A6C
@@ -34079,7 +34079,7 @@ _08068B08:
adds r0, r4, 0
adds r1, r6, 0
ldr r2, _08068B74
- bl sub_808DE50
+ bl xxx_pokemonstruct_to_unk_808DE50
ldrh r0, [r4]
movs r1, 0x1
movs r2, 0
@@ -34293,7 +34293,7 @@ _08068CDC:
movs r3, 0xA
ldrsh r0, [r4, r3]
adds r1, r4, 0
- bl sub_808DF2C
+ bl xxx_unk_to_pokemonstruct_index_808DF2C
b _08068CFE
_08068CE8:
ldr r0, [sp, 0x220]
@@ -34401,7 +34401,7 @@ _08068D6A:
adds r0, r1
str r0, [r4]
adds r1, r5, 0
- bl sub_808DF44
+ bl xxx_unk_to_pokemonstruct_808DF44
ldr r2, [r4]
ldrh r0, [r2]
movs r3, 0x80
@@ -34997,7 +34997,7 @@ _08069228:
movs r2, 0xA
ldrsh r0, [r4, r2]
adds r1, r4, 0
- bl sub_808DF2C
+ bl xxx_unk_to_pokemonstruct_index_808DF2C
_0806926E:
bl sub_8044210
lsls r0, 24
@@ -35196,7 +35196,7 @@ _080693CC:
movs r2, 0xA
ldrsh r0, [r4, r2]
adds r1, r4, 0
- bl sub_808DF2C
+ bl xxx_unk_to_pokemonstruct_index_808DF2C
_0806940E:
bl sub_8044210
lsls r0, 24
@@ -38134,7 +38134,7 @@ sub_806AA0C:
cmp r0, 0
beq _0806AA40
adds r0, r4, 0
- bl sub_808E770
+ bl GetBaseSpecies
lsls r0, 16
movs r1, 0xCF
lsls r1, 17
@@ -40078,7 +40078,7 @@ sub_806B8CC:
str r0, [r1]
_0806B906:
adds r0, r4, 0
- bl sub_808E770
+ bl GetBaseSpecies
lsls r0, 16
asrs r1, r0, 16
movs r0, 0xCF
@@ -40598,7 +40598,7 @@ _0806BD20:
_0806BD24:
movs r4, 0x2
ldrsh r0, [r6, r4]
- bl sub_808E770
+ bl GetBaseSpecies
lsls r0, 16
movs r1, 0xCF
lsls r1, 17
@@ -40613,7 +40613,7 @@ _0806BD24:
_0806BD42:
movs r2, 0x2
ldrsh r0, [r6, r2]
- bl sub_808E770
+ bl GetBaseSpecies
lsls r0, 16
asrs r0, 16
cmp r0, 0x97
diff --git a/asm/code_8097670.s b/asm/code_8097670.s
index 288edc3..d84260c 100644
--- a/asm/code_8097670.s
+++ b/asm/code_8097670.s
@@ -10,7 +10,7 @@ sub_80978C8:
push {lr}
lsls r0, 16
asrs r0, 16
- bl sub_808E858
+ bl GetBaseSpeciesNoUnown
lsls r0, 16
asrs r3, r0, 16
ldr r0, _080978FC
@@ -42,7 +42,7 @@ sub_8097900:
push {lr}
lsls r0, 16
asrs r0, 16
- bl sub_808E858
+ bl GetBaseSpeciesNoUnown
lsls r0, 16
asrs r3, r0, 16
ldr r0, _08097938
diff --git a/asm/friend_area_action_menu.s b/asm/friend_area_action_menu.s
index f984e29..3c0a469 100644
--- a/asm/friend_area_action_menu.s
+++ b/asm/friend_area_action_menu.s
@@ -512,7 +512,7 @@ _0802782C:
movs r2, 0x8
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D7DC
+ bl PeekPokemonItem
movs r0, 0x3
bl sub_8027184
b _080278AE
@@ -538,7 +538,7 @@ _08027868:
movs r2, 0x8
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D7DC
+ bl PeekPokemonItem
movs r0, 0x4
bl sub_8027184
b _080278AE
@@ -707,7 +707,7 @@ _080279F0:
movs r2, 0x8
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
bl nullsub_104
_08027A0E:
movs r0, 0x2
diff --git a/asm/friend_list_menu.s b/asm/friend_list_menu.s
index caa5a02..9c9a903 100644
--- a/asm/friend_list_menu.s
+++ b/asm/friend_list_menu.s
@@ -3722,7 +3722,7 @@ _08020BD0:
ldr r0, [r0, 0x10]
movs r1, 0x8
ldrsh r0, [r0, r1]
- bl sub_808E858
+ bl GetBaseSpeciesNoUnown
lsls r0, 16
movs r1, 0xCF
lsls r1, 17
@@ -5591,7 +5591,7 @@ _08021A8E:
cmp r1, r0
bne _08021AC4
adds r0, r5, 0
- bl sub_808E858
+ bl GetBaseSpeciesNoUnown
lsls r0, 16
asrs r0, 16
cmp r5, r0
@@ -5686,7 +5686,7 @@ sub_8021B58:
push {r4,r5,lr}
lsls r0, 16
asrs r0, 16
- bl sub_808E858
+ bl GetBaseSpeciesNoUnown
lsls r0, 16
asrs r4, r0, 16
movs r2, 0
@@ -9086,7 +9086,7 @@ _080236B0:
cmp r0, 0
beq _080236E2
adds r0, r4, 0
- bl sub_808E858
+ bl GetBaseSpeciesNoUnown
lsls r0, 16
asrs r0, 16
cmp r4, r0
@@ -10802,7 +10802,7 @@ _080243A8:
ldrsh r0, [r5, r1]
movs r2, 0
ldrsh r1, [r4, r2]
- bl sub_808D864
+ bl ComparePokemonNames
lsls r0, 24
cmp r0, 0
beq _080243C6
@@ -11170,7 +11170,7 @@ sub_802465C:
bl sub_808D33C
ldr r1, [r5]
str r0, [r1, 0xC]
- bl sub_808D824
+ bl IsPokemonRenamed
ldr r1, [r5]
strb r0, [r1, 0x10]
ldr r0, [r5]
@@ -12590,7 +12590,7 @@ sub_8025204:
ldr r4, _0802522C
ldr r0, [r4]
ldr r0, [r0, 0xC]
- bl sub_808D824
+ bl IsPokemonRenamed
ldr r1, [r4]
strb r0, [r1, 0x10]
movs r0, 0x3
@@ -13351,7 +13351,7 @@ _08025810:
cmp r1, r0
bne _08025840
adds r0, r7, 0
- bl sub_808D824
+ bl IsPokemonRenamed
lsls r0, 24
cmp r0, 0
beq _08025840
@@ -13620,7 +13620,7 @@ _08025A0C:
movs r2, 0xE
ldrsh r0, [r1, r2]
adds r1, 0x18
- bl sub_808D7DC
+ bl PeekPokemonItem
movs r0, 0x3
bl sub_8025434
b _08025A7E
@@ -13643,7 +13643,7 @@ _08025A40:
movs r2, 0xE
ldrsh r0, [r1, r2]
adds r1, 0x18
- bl sub_808D7DC
+ bl PeekPokemonItem
movs r0, 0x4
bl sub_8025434
b _08025A7E
@@ -13751,7 +13751,7 @@ _08025B40:
movs r2, 0xE
ldrsh r0, [r1, r2]
adds r1, 0x18
- bl sub_808D800
+ bl GivePokemonItem
bl nullsub_104
movs r0, 0xA
bl sub_8025434
@@ -13990,7 +13990,7 @@ _08025D24:
movs r2, 0xE
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
bl sub_801A928
bl nullsub_104
adds r0, r6, 0
@@ -14930,7 +14930,7 @@ sub_80264CC:
movs r3, 0xA
ldrsh r0, [r1, r3]
adds r1, 0x14
- bl sub_808D7DC
+ bl PeekPokemonItem
mov r1, r8
ldrh r0, [r1]
lsrs r0, 1
@@ -15577,7 +15577,7 @@ _08026A28:
movs r2, 0xA
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
bl nullsub_104
movs r0, 0x11
bl sub_8026074
@@ -15893,7 +15893,7 @@ _08026C84:
movs r2, 0xA
ldrsh r0, [r1, r2]
adds r1, 0x10
- bl sub_808D800
+ bl GivePokemonItem
bl sub_801A928
bl nullsub_104
adds r0, r6, 0
@@ -16306,7 +16306,7 @@ _08026FC4:
movs r2, 0xA
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
movs r0, 0xA
bl sub_8026074
b _0802706E
@@ -16357,7 +16357,7 @@ _0802703E:
movs r2, 0xA
ldrsh r0, [r1, r2]
adds r1, 0x14
- bl sub_808D800
+ bl GivePokemonItem
movs r0, 0xB
bl sub_8026074
b _0802706E
diff --git a/asm/pokemon.s b/asm/pokemon.s
index 4f14847..5fc8e9e 100644
--- a/asm/pokemon.s
+++ b/asm/pokemon.s
@@ -1316,133 +1316,4 @@ _0808D7CE:
bx r1
thumb_func_end sub_808D750
- thumb_func_start sub_808D7DC
-sub_808D7DC:
- lsls r0, 16
- asrs r0, 16
- ldr r3, _0808D7FC
- movs r2, 0x58
- muls r2, r0
- ldr r0, [r3]
- adds r0, r2
- adds r2, r0, 0
- adds r2, 0x28
- ldrb r2, [r2]
- strb r2, [r1]
- adds r0, 0x29
- ldrb r0, [r0]
- strb r0, [r1, 0x1]
- bx lr
- .align 2, 0
-_0808D7FC: .4byte gRecruitedPokemonRef
- thumb_func_end sub_808D7DC
-
- thumb_func_start sub_808D800
-sub_808D800:
- lsls r0, 16
- asrs r0, 16
- ldr r3, _0808D820
- movs r2, 0x58
- muls r2, r0
- ldr r0, [r3]
- adds r0, r2
- ldrb r3, [r1]
- adds r2, r0, 0
- adds r2, 0x28
- strb r3, [r2]
- ldrb r1, [r1, 0x1]
- adds r0, 0x29
- strb r1, [r0]
- bx lr
- .align 2, 0
-_0808D820: .4byte gRecruitedPokemonRef
- thumb_func_end sub_808D800
-
- thumb_func_start sub_808D824
-sub_808D824:
- push {r4,lr}
- sub sp, 0x14
- adds r4, r0, 0
- movs r1, 0x8
- ldrsh r0, [r4, r1]
- bl GetMonSpecies
- adds r1, r0, 0
- mov r0, sp
- bl CopyStringtoBuffer
- movs r2, 0
- adds r4, 0x4C
-_0808D83E:
- adds r0, r4, r2
- mov r3, sp
- adds r1, r3, r2
- ldrb r0, [r0]
- ldrb r1, [r1]
- cmp r0, r1
- beq _0808D850
- movs r0, 0
- b _0808D85C
-_0808D850:
- cmp r0, 0
- beq _0808D85A
- adds r2, 0x1
- cmp r2, 0x9
- ble _0808D83E
-_0808D85A:
- movs r0, 0x1
-_0808D85C:
- add sp, 0x14
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_808D824
-
- thumb_func_start sub_808D864
-sub_808D864:
- push {r4-r7,lr}
- lsls r0, 16
- asrs r0, 16
- lsls r1, 16
- asrs r1, 16
- ldr r2, _0808D8A0
- movs r3, 0x58
- muls r0, r3
- ldr r2, [r2]
- adds r0, r2, r0
- adds r6, r0, 0
- adds r6, 0x4C
- adds r0, r1, 0
- muls r0, r3
- adds r2, r0
- adds r5, r2, 0
- adds r5, 0x4C
- movs r7, 0
-_0808D888:
- ldrb r0, [r6]
- bl ReturnIntFromChar
- adds r4, r0, 0
- ldrb r0, [r5]
- bl ReturnIntFromChar
- cmp r4, r0
- ble _0808D8A4
- movs r0, 0x1
- b _0808D8B4
- .align 2, 0
-_0808D8A0: .4byte gRecruitedPokemonRef
-_0808D8A4:
- cmp r4, r0
- blt _0808D8B2
- adds r6, 0x1
- adds r5, 0x1
- adds r7, 0x1
- cmp r7, 0x9
- ble _0808D888
-_0808D8B2:
- movs r0, 0
-_0808D8B4:
- pop {r4-r7}
- pop {r1}
- bx r1
- thumb_func_end sub_808D864
-
-
.align 2,0
diff --git a/asm/pokemon_1.s b/asm/pokemon_1.s
deleted file mode 100644
index 5417b8e..0000000
--- a/asm/pokemon_1.s
+++ /dev/null
@@ -1,72 +0,0 @@
- .include "constants/gba_constants.inc"
- .include "asm/macros.inc"
-
- .syntax unified
-
- .text
-
- thumb_func_start sub_808DA44
-sub_808DA44:
- push {r4-r6,lr}
- sub sp, 0x30
- lsls r0, 16
- asrs r4, r0, 16
- lsls r1, 24
- lsrs r2, r1, 24
- cmp r2, 0xC
- bls _0808DAA0
- mov r1, sp
- ldr r0, _0808DA98
- ldm r0!, {r3,r5,r6}
- stm r1!, {r3,r5,r6}
- ldm r0!, {r3,r5,r6}
- stm r1!, {r3,r5,r6}
- ldm r0!, {r3,r5,r6}
- stm r1!, {r3,r5,r6}
- ldm r0!, {r3,r5,r6}
- stm r1!, {r3,r5,r6}
- mov r0, sp
- movs r1, 0
- ldrsh r0, [r0, r1]
- cmp r0, 0
- beq _0808DA92
- mov r1, sp
- add r3, sp, 0x48
-_0808DA76:
- movs r5, 0
- ldrsh r0, [r1, r5]
- cmp r0, r4
- bne _0808DA84
- ldr r0, [r1, 0x4]
- cmp r0, r2
- beq _0808DA9C
-_0808DA84:
- adds r1, 0x8
- cmp r1, r3
- bgt _0808DA92
- movs r6, 0
- ldrsh r0, [r1, r6]
- cmp r0, 0
- bne _0808DA76
-_0808DA92:
- movs r0, 0
- b _0808DAA6
- .align 2, 0
-_0808DA98: .4byte gUnknown_8107654
-_0808DA9C:
- movs r0, 0x1
- b _0808DAA6
-_0808DAA0:
- ldr r0, _0808DAB0
- adds r0, r2, r0
- ldrb r0, [r0]
-_0808DAA6:
- add sp, 0x30
- pop {r4-r6}
- pop {r1}
- bx r1
- .align 2, 0
-_0808DAB0: .4byte gUnknown_8107645
- thumb_func_end sub_808DA44
-
- .align 2,0
diff --git a/asm/pokemon_2.s b/asm/pokemon_2.s
index f2e7742..cf8c39d 100644
--- a/asm/pokemon_2.s
+++ b/asm/pokemon_2.s
@@ -4,786 +4,7 @@
.syntax unified
.text
-
- thumb_func_start sub_808DE50
-sub_808DE50:
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- sub sp, 0x8
- adds r5, r0, 0
- adds r6, r1, 0
- adds r4, r2, 0
- ldrh r0, [r6]
- strh r0, [r5]
- ldrb r0, [r6, 0x3]
- strb r0, [r5, 0x3]
- ldrh r0, [r6, 0x14]
- strh r0, [r5, 0x8]
- ldr r0, [r6, 0x20]
- str r0, [r5, 0x4C]
- adds r0, r5, 0
- adds r0, 0x54
- bl sub_808E6F4
- ldr r0, [r6, 0x4]
- str r0, [r5, 0x4]
- ldrb r0, [r6, 0x2]
- strb r0, [r5, 0x2]
- strh r4, [r5, 0xA]
- ldrh r0, [r6, 0x8]
- strh r0, [r5, 0xE]
- adds r0, r6, 0
- adds r0, 0x24
- ldrb r1, [r0]
- adds r0, r5, 0
- adds r0, 0x50
- strb r1, [r0]
- ldrh r0, [r6, 0x16]
- strh r0, [r5, 0x12]
- strh r0, [r5, 0x10]
- add r0, sp, 0x4
- mov r8, r0
- adds r2, r6, 0
- adds r2, 0x18
- adds r1, r5, 0
- adds r1, 0x14
- movs r3, 0x1
-_0808DEA4:
- ldrb r0, [r2]
- strb r0, [r1]
- ldrb r0, [r2, 0x2]
- strb r0, [r1, 0x2]
- adds r2, 0x1
- adds r1, 0x1
- subs r3, 0x1
- cmp r3, 0
- bge _0808DEA4
- ldr r0, [r6, 0x1C]
- str r0, [r5, 0x18]
- adds r0, r5, 0
- adds r0, 0x1C
- adds r1, r6, 0
- adds r1, 0x2C
- bl sub_8093F50
- movs r3, 0
- movs r0, 0x28
- adds r0, r6
- mov r12, r0
- adds r2, r5, 0
- adds r2, 0x40
- adds r7, r5, 0
- adds r7, 0x58
- adds r4, r6, 0
- adds r4, 0x4C
-_0808DEDA:
- adds r0, r7, r3
- adds r1, r4, r3
- ldrb r1, [r1]
- strb r1, [r0]
- adds r3, 0x1
- cmp r3, 0x9
- ble _0808DEDA
- mov r0, r12
- ldrb r1, [r0]
- negs r0, r1
- orrs r0, r1
- lsrs r0, 31
- cmp r0, 0
- beq _0808DF00
- adds r0, r2, 0
- mov r1, r12
- bl HeldItemToSlot
- b _0808DF06
-_0808DF00:
- strb r0, [r2, 0x2]
- strb r0, [r2, 0x1]
- strb r0, [r2]
-_0808DF06:
- mov r0, sp
- movs r1, 0x64
- bl sub_80943A0
- ldr r0, [sp]
- str r0, [r5, 0x44]
- mov r0, r8
- movs r1, 0x64
- bl sub_80943A0
- ldr r0, [sp, 0x4]
- str r0, [r5, 0x48]
- add sp, 0x8
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end sub_808DE50
-
- thumb_func_start sub_808DF2C
-sub_808DF2C:
- push {lr}
- ldr r3, _0808DF40
- movs r2, 0x58
- muls r2, r0
- ldr r0, [r3]
- adds r0, r2
- bl sub_808DF44
- pop {r0}
- bx r0
- .align 2, 0
-_0808DF40: .4byte gRecruitedPokemonRef
- thumb_func_end sub_808DF2C
-
- thumb_func_start sub_808DF44
-sub_808DF44:
- push {r4-r7,lr}
- adds r5, r0, 0
- adds r4, r1, 0
- ldrh r0, [r4]
- strh r0, [r5]
- ldrb r0, [r4, 0x3]
- strb r0, [r5, 0x3]
- ldrh r0, [r4, 0x8]
- strh r0, [r5, 0x14]
- ldr r0, [r4, 0x4C]
- str r0, [r5, 0x20]
- ldr r0, [r4, 0x4]
- str r0, [r5, 0x4]
- ldrb r0, [r4, 0x2]
- strb r0, [r5, 0x2]
- ldrh r0, [r4, 0xE]
- strh r0, [r5, 0x8]
- adds r0, r4, 0
- adds r0, 0x50
- ldrb r1, [r0]
- adds r0, r5, 0
- adds r0, 0x24
- strb r1, [r0]
- ldrh r0, [r4, 0x12]
- strh r0, [r5, 0x16]
- adds r2, r4, 0
- adds r2, 0x14
- adds r1, r5, 0
- adds r1, 0x18
- movs r3, 0x1
-_0808DF80:
- ldrb r0, [r2]
- strb r0, [r1]
- ldrb r0, [r2, 0x2]
- strb r0, [r1, 0x2]
- adds r2, 0x1
- adds r1, 0x1
- subs r3, 0x1
- cmp r3, 0
- bge _0808DF80
- ldr r0, [r4, 0x18]
- str r0, [r5, 0x1C]
- adds r0, r5, 0
- adds r0, 0x2C
- adds r1, r4, 0
- adds r1, 0x1C
- bl sub_8093FA8
- movs r3, 0
- adds r7, r4, 0
- adds r7, 0x40
- adds r6, r5, 0
- adds r6, 0x28
- adds r5, 0x4C
- adds r2, r4, 0
- adds r2, 0x58
-_0808DFB2:
- adds r0, r5, r3
- adds r1, r2, r3
- ldrb r1, [r1]
- strb r1, [r0]
- adds r3, 0x1
- cmp r3, 0x9
- ble _0808DFB2
- ldrb r0, [r7]
- movs r1, 0x1
- ands r1, r0
- cmp r1, 0
- beq _0808DFD4
- adds r0, r6, 0
- adds r1, r7, 0
- bl SlotToHeldItem
- b _0808DFD6
-_0808DFD4:
- strb r1, [r6]
-_0808DFD6:
- pop {r4-r7}
- pop {r0}
- bx r0
- thumb_func_end sub_808DF44
-
- thumb_func_start sub_808DFDC
-sub_808DFDC:
- push {lr}
- ldr r3, _0808E000
- movs r2, 0x58
- muls r2, r0
- ldr r0, [r3]
- adds r3, r0, r2
- adds r1, 0x40
- ldrb r0, [r1]
- movs r2, 0x1
- ands r2, r0
- cmp r2, 0
- beq _0808E004
- adds r0, r3, 0
- adds r0, 0x28
- bl SlotToHeldItem
- b _0808E00A
- .align 2, 0
-_0808E000: .4byte gRecruitedPokemonRef
-_0808E004:
- adds r0, r3, 0
- adds r0, 0x28
- strb r2, [r0]
-_0808E00A:
- pop {r0}
- bx r0
- thumb_func_end sub_808DFDC
-
- thumb_func_start GetPokemonLevelData
-GetPokemonLevelData:
- push {r4-r6,lr}
- sub sp, 0xC
- adds r6, r0, 0
- adds r5, r2, 0
- lsls r1, 16
- asrs r2, r1, 16
- ldr r1, _0808E06C
- movs r3, 0
- ldrsh r0, [r1, r3]
- cmp r0, r2
- beq _0808E04A
- strh r2, [r1]
- ldr r1, _0808E070
- mov r0, sp
- bl sprintf
- ldr r1, _0808E074
- mov r0, sp
- bl OpenFileAndGetFileDataPtr
- adds r4, r0, 0
- ldr r0, _0808E078
- movs r1, 0
- adds r2, r4, 0
- bl DecompressATFile
- adds r0, r4, 0
- bl CloseFile
-_0808E04A:
- subs r5, 0x1
- cmp r5, 0
- bge _0808E052
- movs r5, 0
-_0808E052:
- ldr r0, _0808E078
- lsls r1, r5, 1
- adds r1, r5
- lsls r1, 2
- adds r2, r6, 0
- adds r1, r0
- ldm r1!, {r0,r3,r4}
- stm r2!, {r0,r3,r4}
- add sp, 0xC
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2, 0
-_0808E06C: .4byte gLevelCurrentPokeId
-_0808E070: .4byte gUnknown_810768C
-_0808E074: .4byte gSystemFileArchive
-_0808E078: .4byte gLevelCurrentData
- thumb_func_end GetPokemonLevelData
-
- thumb_func_start sub_808E07C
-sub_808E07C:
- push {r4,lr}
- adds r2, r0, 0
- adds r4, r1, 0
- ldrb r1, [r2]
- adds r2, 0x1
- movs r0, 0x80
- ands r0, r1
- cmp r0, 0
- beq _0808E094
- ldrb r3, [r2]
- adds r2, 0x1
- b _0808E098
-_0808E094:
- adds r3, r1, 0
- movs r1, 0
-_0808E098:
- movs r0, 0x7F
- ands r3, r0
- ands r1, r0
- lsls r0, r1, 7
- orrs r0, r3
- strh r0, [r4]
- adds r0, r2, 0
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_808E07C
-
- thumb_func_start sub_808E0AC
-sub_808E0AC:
- push {r4-r7,lr}
- mov r7, r10
- mov r6, r9
- mov r5, r8
- push {r5-r7}
- sub sp, 0x4
- adds r6, r0, 0
- mov r8, r2
- adds r5, r3, 0
- lsls r1, 16
- asrs r1, 16
- adds r2, r1, 0
- movs r7, 0
- ldr r0, _0808E0DC
- cmp r1, r0
- beq _0808E0D8
- cmp r1, 0
- beq _0808E0D8
- movs r0, 0xD2
- lsls r0, 1
- cmp r1, r0
- bne _0808E0E0
-_0808E0D8:
- movs r0, 0
- b _0808E170
- .align 2, 0
-_0808E0DC: .4byte 0x000001a5
-_0808E0E0:
- adds r0, r2, 0
- bl sub_8092B18
- adds r1, r0, 0
- mov r4, sp
- movs r0, 0x88
- lsls r0, 1
- mov r10, r0
- movs r3, 0xB1
- lsls r3, 1
- mov r9, r3
- b _0808E156
-_0808E0F8:
- cmp r0, r8
- bne _0808E156
- movs r2, 0x1
- ldrh r0, [r4]
- cmp r0, 0xEE
- bne _0808E110
- ldr r0, _0808E180
- movs r3, 0
- ldrsh r0, [r0, r3]
- cmp r5, r0
- bge _0808E110
- movs r2, 0
-_0808E110:
- ldrh r0, [r4]
- cmp r0, 0xEF
- bne _0808E122
- ldr r0, _0808E184
- movs r3, 0
- ldrsh r0, [r0, r3]
- cmp r5, r0
- bge _0808E122
- movs r2, 0
-_0808E122:
- ldrh r0, [r4]
- cmp r0, r10
- bne _0808E134
- ldr r0, _0808E188
- movs r3, 0
- ldrsh r0, [r0, r3]
- cmp r5, r0
- bge _0808E134
- movs r2, 0
-_0808E134:
- ldrh r0, [r4]
- cmp r0, r9
- bne _0808E146
- ldr r0, _0808E18C
- movs r3, 0
- ldrsh r0, [r0, r3]
- cmp r5, r0
- bge _0808E146
- movs r2, 0
-_0808E146:
- cmp r2, 0
- beq _0808E156
- cmp r7, 0xF
- bgt _0808E156
- ldrh r0, [r4]
- strh r0, [r6]
- adds r6, 0x2
- adds r7, 0x1
-_0808E156:
- ldrb r0, [r1]
- cmp r0, 0
- beq _0808E16E
- adds r0, r1, 0
- mov r1, sp
- bl sub_808E07C
- adds r1, r0, 0
- ldrb r0, [r1]
- adds r1, 0x1
- cmp r0, r8
- ble _0808E0F8
-_0808E16E:
- adds r0, r7, 0
-_0808E170:
- add sp, 0x4
- pop {r3-r5}
- mov r8, r3
- mov r9, r4
- mov r10, r5
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0808E180: .4byte gUnknown_810ACB8
-_0808E184: .4byte gUnknown_810ACBA
-_0808E188: .4byte gUnknown_810ACBC
-_0808E18C: .4byte gUnknown_810ACBE
- thumb_func_end sub_808E0AC
-
- thumb_func_start sub_808E190
-sub_808E190:
- push {r4,r5,lr}
- sub sp, 0x4
- lsls r0, 16
- lsrs r5, r0, 16
- lsls r1, 16
- asrs r4, r1, 16
- ldr r0, _0808E1B8
- cmp r4, r0
- beq _0808E20C
- cmp r4, 0
- beq _0808E20C
- movs r0, 0xD2
- lsls r0, 1
- cmp r4, r0
- beq _0808E20C
- movs r0, 0xB0
- lsls r0, 1
- cmp r5, r0
- bne _0808E1C0
- b _0808E20C
- .align 2, 0
-_0808E1B8: .4byte 0x000001a5
-_0808E1BC:
- movs r0, 0x1
- b _0808E20E
-_0808E1C0:
- adds r0, r4, 0
- bl sub_8092B18
- adds r1, r0, 0
- b _0808E1DE
-_0808E1CA:
- adds r0, r1, 0
- mov r1, sp
- bl sub_808E07C
- adds r1, r0, 0
- adds r1, 0x1
- mov r0, sp
- ldrh r0, [r0]
- cmp r5, r0
- beq _0808E1BC
-_0808E1DE:
- ldrb r0, [r1]
- cmp r0, 0
- bne _0808E1CA
- adds r0, r4, 0
- bl sub_8092B54
- adds r1, r0, 0
- ldrb r0, [r1]
- cmp r0, 0
- beq _0808E20C
- mov r4, sp
- adds r4, 0x2
-_0808E1F6:
- adds r0, r1, 0
- adds r1, r4, 0
- bl sub_808E07C
- adds r1, r0, 0
- ldrh r0, [r4]
- cmp r0, r5
- beq _0808E1BC
- ldrb r0, [r1]
- cmp r0, 0
- bne _0808E1F6
-_0808E20C:
- movs r0, 0
-_0808E20E:
- add sp, 0x4
- pop {r4,r5}
- pop {r1}
- bx r1
- thumb_func_end sub_808E190
-
- thumb_func_start sub_808E218
-sub_808E218:
- push {r4-r7,lr}
- mov r7, r10
- mov r6, r9
- mov r5, r8
- push {r5-r7}
- sub sp, 0x1C
- mov r10, r0
- mov r8, r1
- movs r0, 0
- mov r9, r0
- movs r0, 0xCF
- lsls r0, 2
- add r0, r10
- mov r1, r9
- str r1, [r0]
- mov r2, r8
- movs r3, 0x8
- ldrsh r1, [r2, r3]
- ldr r0, _0808E254
- cmp r1, r0
- beq _0808E24E
- cmp r1, 0
- beq _0808E24E
- movs r0, 0xD2
- lsls r0, 1
- cmp r1, r0
- bne _0808E258
-_0808E24E:
- movs r0, 0
- b _0808E396
- .align 2, 0
-_0808E254: .4byte 0x000001a5
-_0808E258:
- mov r0, r8
- mov r1, sp
- bl sub_808E3B8
- str r0, [sp, 0x10]
- movs r5, 0
- cmp r9, r0
- blt _0808E26A
- b _0808E38A
-_0808E26A:
- lsls r4, r5, 2
- mov r1, sp
- adds r0, r1, r4
- movs r2, 0
- ldrsh r0, [r0, r2]
- bl sub_8092B18
- adds r6, r0, 0
- str r4, [sp, 0x18]
- adds r5, 0x1
- str r5, [sp, 0x14]
- b _0808E35E
-_0808E282:
- movs r0, 0xCE
- lsls r0, 1
- cmp r9, r0
- bgt _0808E35E
- movs r7, 0x1
- ldrh r0, [r4]
- cmp r0, 0xEE
- bne _0808E2A4
- ldr r0, _0808E3A8
- mov r3, r8
- movs r4, 0x14
- ldrsh r1, [r3, r4]
- movs r2, 0
- ldrsh r0, [r0, r2]
- cmp r1, r0
- bge _0808E2A4
- movs r7, 0
-_0808E2A4:
- mov r3, r12
- ldrh r0, [r3]
- cmp r0, 0xEF
- bne _0808E2BE
- ldr r0, _0808E3AC
- mov r4, r8
- movs r2, 0x14
- ldrsh r1, [r4, r2]
- movs r3, 0
- ldrsh r0, [r0, r3]
- cmp r1, r0
- bge _0808E2BE
- movs r7, 0
-_0808E2BE:
- mov r4, r12
- ldrh r1, [r4]
- movs r0, 0x88
- lsls r0, 1
- cmp r1, r0
- bne _0808E2DC
- ldr r0, _0808E3B0
- mov r2, r8
- movs r3, 0x14
- ldrsh r1, [r2, r3]
- movs r4, 0
- ldrsh r0, [r0, r4]
- cmp r1, r0
- bge _0808E2DC
- movs r7, 0
-_0808E2DC:
- mov r0, r12
- ldrh r1, [r0]
- movs r0, 0xB1
- lsls r0, 1
- cmp r1, r0
- bne _0808E2FA
- ldr r0, _0808E3B4
- mov r2, r8
- movs r3, 0x14
- ldrsh r1, [r2, r3]
- movs r4, 0
- ldrsh r0, [r0, r4]
- cmp r1, r0
- bge _0808E2FA
- movs r7, 0
-_0808E2FA:
- movs r4, 0x1
- mov r5, r12
- mov r2, r8
- adds r2, 0x2C
- movs r3, 0x3
-_0808E304:
- ldrb r1, [r2]
- adds r0, r4, 0
- ands r0, r1
- cmp r0, 0
- beq _0808E318
- ldrh r0, [r2, 0x2]
- ldrh r1, [r5]
- cmp r0, r1
- bne _0808E318
- movs r7, 0
-_0808E318:
- adds r2, 0x8
- subs r3, 0x1
- cmp r3, 0
- bge _0808E304
- cmp r7, 0
- beq _0808E35E
- movs r2, 0
- cmp r2, r9
- bge _0808E34A
- mov r3, r10
- ldrh r0, [r3]
- mov r4, r12
- ldrh r4, [r4]
- cmp r0, r4
- beq _0808E34A
- mov r3, r12
- mov r1, r10
-_0808E33A:
- adds r1, 0x2
- adds r2, 0x1
- cmp r2, r9
- bge _0808E34A
- ldrh r0, [r1]
- ldrh r4, [r3]
- cmp r0, r4
- bne _0808E33A
-_0808E34A:
- cmp r2, r9
- bne _0808E35E
- mov r1, r9
- lsls r0, r1, 1
- add r0, r10
- mov r2, r12
- ldrh r1, [r2]
- strh r1, [r0]
- movs r3, 0x1
- add r9, r3
-_0808E35E:
- ldrb r0, [r6]
- cmp r0, 0
- beq _0808E380
- add r4, sp, 0xC
- adds r0, r6, 0
- adds r1, r4, 0
- bl sub_808E07C
- adds r6, r0, 0
- ldrb r0, [r6]
- adds r6, 0x1
- ldr r1, [sp, 0x18]
- add r1, sp
- ldrb r1, [r1, 0x2]
- mov r12, r4
- cmp r0, r1
- ble _0808E282
-_0808E380:
- ldr r5, [sp, 0x14]
- ldr r4, [sp, 0x10]
- cmp r5, r4
- bge _0808E38A
- b _0808E26A
-_0808E38A:
- movs r0, 0xCF
- lsls r0, 2
- add r0, r10
- mov r1, r9
- str r1, [r0]
- mov r0, r9
-_0808E396:
- add sp, 0x1C
- pop {r3-r5}
- mov r8, r3
- mov r9, r4
- mov r10, r5
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0808E3A8: .4byte gUnknown_810ACB8
-_0808E3AC: .4byte gUnknown_810ACBA
-_0808E3B0: .4byte gUnknown_810ACBC
-_0808E3B4: .4byte gUnknown_810ACBE
- thumb_func_end sub_808E218
-
- thumb_func_start sub_808E3B8
-sub_808E3B8:
- push {r4-r7,lr}
- ldrh r2, [r0, 0x8]
- strh r2, [r1]
- ldrb r2, [r0, 0x3]
- strb r2, [r1, 0x2]
- movs r7, 0x1
- movs r3, 0x8
- ldrsh r2, [r0, r3]
- movs r6, 0
- adds r5, r0, 0
- adds r5, 0xC
- adds r4, r1, 0x4
- b _0808E3E0
-_0808E3D2:
- strh r2, [r4]
- ldrb r0, [r5]
- strb r0, [r4, 0x2]
- adds r4, 0x4
- adds r7, 0x1
- adds r5, 0x4
- adds r6, 0x1
-_0808E3E0:
- cmp r6, 0x1
- bgt _0808E3F8
- ldrb r0, [r5]
- cmp r0, 0
- beq _0808E3F8
- adds r0, r2, 0
- bl GetPokemonEvolveFrom
- lsls r0, 16
- asrs r2, r0, 16
- cmp r2, 0
- bne _0808E3D2
-_0808E3F8:
- adds r0, r7, 0
- pop {r4-r7}
- pop {r1}
- bx r1
- thumb_func_end sub_808E3B8
-
+
thumb_func_start sub_808E400
sub_808E400:
push {r4-r7,lr}
@@ -1095,339 +316,5 @@ _0808E65C: .4byte 0x00000fff
_0808E660: .4byte 0x0000fffe
_0808E664: .4byte 0x0000fffd
thumb_func_end sub_808E53C
-
- thumb_func_start sub_808E668
-sub_808E668:
- push {r4,r5,lr}
- adds r4, r1, 0
- adds r5, r2, 0
- lsls r0, 16
- asrs r1, r0, 16
- ldr r2, _0808E6E0
- adds r0, r2
- lsrs r0, 16
- cmp r0, 0x1
- bls _0808E6D6
- adds r0, r1, 0
- bl GetShadowSize
- lsls r0, 24
- lsrs r0, 24
- movs r3, 0
- ldrsh r2, [r4, r3]
- movs r3, 0x10
- ldrsh r1, [r5, r3]
- adds r2, r1
- movs r1, 0x2
- ldrsh r3, [r4, r1]
- movs r4, 0x12
- ldrsh r1, [r5, r4]
- adds r3, r1
- ldr r4, _0808E6E4
- lsls r1, r0, 2
- adds r1, r4
- ldr r1, [r1]
- adds r2, r1
- subs r3, 0x4
- ldr r1, _0808E6E8
- ands r2, r1
- lsls r0, 3
- ldr r1, _0808E6EC
- adds r0, r1
- ldrh r4, [r0, 0x2]
- movs r1, 0xFE
- lsls r1, 8
- ands r1, r4
- orrs r1, r2
- strh r1, [r0, 0x2]
- ldr r1, _0808E6F0
- ands r3, r1
- lsls r3, 4
- ldrh r2, [r0, 0x6]
- movs r1, 0xF
- ands r1, r2
- orrs r1, r3
- strh r1, [r0, 0x6]
- movs r1, 0
- movs r2, 0
- movs r3, 0
- bl AddSprite
-_0808E6D6:
- movs r0, 0x1
- pop {r4,r5}
- pop {r1}
- bx r1
- .align 2, 0
-_0808E6E0: .4byte 0xffce0000
-_0808E6E4: .4byte gUnknown_81076C4
-_0808E6E8: .4byte 0x000001ff
-_0808E6EC: .4byte gUnknown_202F3E8
-_0808E6F0: .4byte 0x00000fff
- thumb_func_end sub_808E668
-
- thumb_func_start sub_808E6F4
-sub_808E6F4:
- push {r4,r5,lr}
- adds r5, r0, 0
- movs r0, 0xA
- bl RandomCapped
- ldr r1, _0808E70C
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- strh r0, [r5]
- movs r4, 0
- b _0808E712
- .align 2, 0
-_0808E70C: .4byte gUnknown_810AC90
-_0808E710:
- adds r4, 0x1
-_0808E712:
- cmp r4, 0x63
- bgt _0808E724
- movs r0, 0x12
- bl RandomCapped
- strb r0, [r5, 0x2]
- lsls r0, 24
- cmp r0, 0
- beq _0808E710
-_0808E724:
- cmp r4, 0x64
- bne _0808E72C
- movs r0, 0x2
- strb r0, [r5, 0x2]
-_0808E72C:
- pop {r4,r5}
- pop {r0}
- bx r0
- thumb_func_end sub_808E6F4
-
- thumb_func_start HasRecruitedMon
-HasRecruitedMon:
- push {r4-r6,lr}
- lsls r0, 16
- asrs r4, r0, 16
- movs r3, 0
- ldr r0, _0808E75C
- ldr r2, [r0]
- movs r6, 0x1
- movs r5, 0xCE
- lsls r5, 1
-_0808E746:
- ldrb r1, [r2]
- adds r0, r6, 0
- ands r0, r1
- cmp r0, 0
- beq _0808E760
- movs r1, 0x8
- ldrsh r0, [r2, r1]
- cmp r0, r4
- bne _0808E760
- movs r0, 0x1
- b _0808E76A
- .align 2, 0
-_0808E75C: .4byte gRecruitedPokemonRef
-_0808E760:
- adds r2, 0x58
- adds r3, 0x1
- cmp r3, r5
- ble _0808E746
- movs r0, 0
-_0808E76A:
- pop {r4-r6}
- pop {r1}
- bx r1
- thumb_func_end HasRecruitedMon
-
- thumb_func_start sub_808E770
-sub_808E770:
- push {lr}
- lsls r0, 16
- asrs r1, r0, 16
- ldr r0, _0808E788
- cmp r1, r0
- beq _0808E792
- movs r0, 0xBD
- lsls r0, 1
- cmp r1, r0
- bne _0808E78C
- subs r0, 0x2
- b _0808E854
- .align 2, 0
-_0808E788: .4byte 0x00000179
-_0808E78C:
- ldr r0, _0808E798
- cmp r1, r0
- bne _0808E79C
-_0808E792:
- movs r0, 0xBC
- lsls r0, 1
- b _0808E854
- .align 2, 0
-_0808E798: .4byte 0x0000017b
-_0808E79C:
- cmp r1, 0xCA
- beq _0808E80E
- cmp r1, 0xCB
- beq _0808E80E
- cmp r1, 0xCC
- beq _0808E80E
- cmp r1, 0xCD
- beq _0808E80E
- cmp r1, 0xCE
- beq _0808E80E
- cmp r1, 0xCF
- beq _0808E80E
- cmp r1, 0xD0
- beq _0808E80E
- cmp r1, 0xD1
- beq _0808E80E
- cmp r1, 0xD2
- beq _0808E80E
- cmp r1, 0xD3
- beq _0808E80E
- cmp r1, 0xD4
- beq _0808E80E
- cmp r1, 0xD5
- beq _0808E80E
- cmp r1, 0xD6
- beq _0808E80E
- cmp r1, 0xD7
- beq _0808E80E
- cmp r1, 0xD8
- beq _0808E80E
- cmp r1, 0xD9
- beq _0808E80E
- cmp r1, 0xDA
- beq _0808E80E
- cmp r1, 0xDB
- beq _0808E80E
- cmp r1, 0xDC
- beq _0808E80E
- cmp r1, 0xDD
- beq _0808E80E
- cmp r1, 0xDE
- beq _0808E80E
- cmp r1, 0xDF
- beq _0808E80E
- cmp r1, 0xE0
- beq _0808E80E
- cmp r1, 0xE1
- beq _0808E80E
- cmp r1, 0xE2
- beq _0808E80E
- ldr r0, _0808E814
- cmp r1, r0
- beq _0808E80E
- movs r0, 0xD0
- lsls r0, 1
- cmp r1, r0
- bne _0808E818
-_0808E80E:
- movs r0, 0xC9
- b _0808E854
- .align 2, 0
-_0808E814: .4byte 0x0000019f
-_0808E818:
- ldr r0, _0808E82C
- cmp r1, r0
- beq _0808E836
- movs r0, 0xD1
- lsls r0, 1
- cmp r1, r0
- bne _0808E830
- subs r0, 0x4
- b _0808E854
- .align 2, 0
-_0808E82C: .4byte 0x000001a1
-_0808E830:
- ldr r0, _0808E83C
- cmp r1, r0
- bne _0808E840
-_0808E836:
- movs r0, 0xCF
- lsls r0, 1
- b _0808E854
- .align 2, 0
-_0808E83C: .4byte 0x000001a3
-_0808E840:
- ldr r0, _0808E84C
- cmp r1, r0
- beq _0808E850
- adds r0, r1, 0
- b _0808E854
- .align 2, 0
-_0808E84C: .4byte 0x000001a7
-_0808E850:
- movs r0, 0xCE
- lsls r0, 1
-_0808E854:
- pop {r1}
- bx r1
- thumb_func_end sub_808E770
-
- thumb_func_start sub_808E858
-sub_808E858:
- push {lr}
- lsls r0, 16
- asrs r1, r0, 16
- adds r2, r1, 0
- ldr r0, _0808E874
- cmp r1, r0
- beq _0808E87E
- movs r0, 0xBD
- lsls r0, 1
- cmp r1, r0
- bne _0808E878
- subs r0, 0x2
- b _0808E8C4
- .align 2, 0
-_0808E874: .4byte 0x00000179
-_0808E878:
- ldr r0, _0808E884
- cmp r1, r0
- bne _0808E888
-_0808E87E:
- movs r0, 0xBC
- lsls r0, 1
- b _0808E8C4
- .align 2, 0
-_0808E884: .4byte 0x0000017b
-_0808E888:
- ldr r0, _0808E89C
- cmp r1, r0
- beq _0808E8A6
- movs r0, 0xD1
- lsls r0, 1
- cmp r1, r0
- bne _0808E8A0
- subs r0, 0x4
- b _0808E8C4
- .align 2, 0
-_0808E89C: .4byte 0x000001a1
-_0808E8A0:
- ldr r0, _0808E8AC
- cmp r1, r0
- bne _0808E8B0
-_0808E8A6:
- movs r0, 0xCF
- lsls r0, 1
- b _0808E8C4
- .align 2, 0
-_0808E8AC: .4byte 0x000001a3
-_0808E8B0:
- ldr r0, _0808E8BC
- cmp r2, r0
- beq _0808E8C0
- adds r0, r2, 0
- b _0808E8C4
- .align 2, 0
-_0808E8BC: .4byte 0x000001a7
-_0808E8C0:
- movs r0, 0xCE
- lsls r0, 1
-_0808E8C4:
- pop {r1}
- bx r1
- thumb_func_end sub_808E858
-
+
.align 2, 0 @ Don't pad with nop.
diff --git a/asm/pokemon_3.s b/asm/pokemon_3.s
index e3647fc..f0308d7 100644
--- a/asm/pokemon_3.s
+++ b/asm/pokemon_3.s
@@ -5,71 +5,6 @@
.text
- thumb_func_start sub_808ED00
-sub_808ED00:
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- sub sp, 0x10
- mov r0, sp
- bl sub_808D580
- adds r6, r0, 0
- movs r4, 0
- cmp r4, r6
- bge _0808ED44
- movs r0, 0x58
- mov r8, r0
- mov r7, sp
- movs r5, 0
- adds r4, r6, 0
-_0808ED20:
- ldr r0, _0808ED70
- ldr r1, [r0]
- adds r0, r1, r5
- ldr r2, _0808ED74
- adds r0, r2
- ldm r7!, {r2}
- mov r3, r8
- muls r3, r2
- adds r2, r3, 0
- adds r1, r2
- movs r2, 0x58
- bl memcpy
- adds r5, 0x58
- subs r4, 0x1
- cmp r4, 0
- bne _0808ED20
- adds r4, r6, 0
-_0808ED44:
- cmp r4, 0x3
- bgt _0808ED64
- ldr r5, _0808ED70
- ldr r3, _0808ED74
- movs r2, 0
- movs r0, 0x58
- adds r1, r4, 0
- muls r1, r0
-_0808ED54:
- ldr r0, [r5]
- adds r0, r1
- adds r0, r3
- strh r2, [r0]
- adds r1, 0x58
- adds r4, 0x1
- cmp r4, 0x3
- ble _0808ED54
-_0808ED64:
- add sp, 0x10
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r0}
- bx r0
- .align 2, 0
-_0808ED70: .4byte gRecruitedPokemonRef
-_0808ED74: .4byte 0x00008f88
- thumb_func_end sub_808ED00
-
thumb_func_start SaveRecruitedPokemon
SaveRecruitedPokemon:
push {r4-r7,lr}
diff --git a/include/file_system.h b/include/file_system.h
index 6d93b88..4219c47 100644
--- a/include/file_system.h
+++ b/include/file_system.h
@@ -36,6 +36,7 @@ struct OpenedFile *OpenFile(const char *filename, const struct FileArchive *arc)
u8 *GetFileDataPtr(struct OpenedFile *openedFile, int unused);
struct OpenedFile *OpenFileAndGetFileDataPtr(const char *filename, const struct FileArchive *arc);
struct OpenedFile *Call_OpenFileAndGetFileDataPtr(const char *filename, const struct FileArchive *arc);
+u32 DecompressATFile(char *result, s32 resultLength, struct OpenedFile *file);
void CloseFile(struct OpenedFile *openedFile);
#endif //GUARD_FILE_SYSTEM_H
diff --git a/include/item.h b/include/item.h
index 579c5c7..421eb89 100644
--- a/include/item.h
+++ b/include/item.h
@@ -362,6 +362,7 @@ bool8 xxx_insert_unk230_80919FC(u8);
u32 xxx_count_non_empty_inv_unk250_8091A48();
void sub_8091BB4(u8);
void sub_8090F58(void*, u8 *, struct ItemSlot *, struct unkStruct_8090F58*);
+void SlotToHeldItem(struct HeldItem *held,struct ItemSlot *slot);
// some sort of weird memcpy's?
// not sure what the second argument should be typed as
diff --git a/include/pokemon.h b/include/pokemon.h
index 23a1311..9e3a667 100644
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -5,34 +5,58 @@
#include "item.h"
+#define OFFENSE_NRM 0
+#define OFFENSE_SP 1
+
+struct Offense {
+ /* 0x18: att */
+ /* 0x19: spatt */
+ /* 0x1a: def */
+ /* 0x1b: spdef */
+
+ u8 att[2];
+ u8 def[2];
+};
+
+struct unkPokeSubStruct_4 {
+ u8 unk4;
+ u8 unk5;
+ u16 fill6;
+};
+
+struct unkPokeSubStruct_2C
+{
+ u8 unk0;
+ u8 fill1;
+ u16 unk2;
+ u32 fill4;
+};
+
+struct unkPokeSubStruct_C
+{
+ u8 unk0;
+ u8 fill1[3];
+};
+
struct PokemonStruct
{
// size: 0x58
u16 unk0; // recruited??
u8 unk2;
- u8 unk3;
- u8 unk4;
- u8 unk5;
- u8 fill6[0x8 - 0x6];
+ u8 unkHasNextStage; // set to a random value?
+ struct unkPokeSubStruct_4 unk4;
/* 0x8 */ s16 speciesNum; // species #
u8 fillA[0xC - 0xA];
- u8 unkC;
- u8 fillD[0x10 - 0xD];
- u8 unk10;
- u8 fill11[0x14 - 0x11];
+ struct unkPokeSubStruct_C unkC[2];
/* 0x14 */ s16 IQ;
/* 0x16 */ u16 pokeHP; // HP
- /* 0x18 */ u8 pokeAtt; // attack
- /* 0x19 */ u8 pokeSPAtt; // sp attack
- /* 0x1A */ u8 pokeDef; // def
- /* 0x1B */ u8 pokeSPDef; // spdef
+ /* 0x18 */ struct Offense offense;
u32 unk1C;
- u8 unk20[4];
+ u32 unk20;
u8 unk24;
u8 fill25[3];
struct HeldItem heldItem;
- u8 unk2C[4];
- u8 fill30[0x4C - 0x30];
+ struct unkPokeSubStruct_2C unk2C[4];
/* 0x4C */ u8 name[0xA];
};
@@ -43,22 +67,11 @@ struct PokemonStruct2
u8 fill[0x62];
};
-struct PokemonStruct3
-{
- // size: 0x58
- u16 unk0;
- u16 unk2;
- u16 unk4;
- u16 unk6;
- u16 unk8;
- u8 fill[0x4E];
-};
-
struct unkStruct_203B45C
{
/* 0x0 */ struct PokemonStruct pokemon[NUM_SPECIES];
/* 0x8DF8 */ struct PokemonStruct2 pokemon2[4];
- /* 0x8F88 */ struct PokemonStruct3 pokemon3[4];
+ /* 0x8F88 */ struct PokemonStruct team[4];
};
struct EvolveStruct1
@@ -117,6 +130,64 @@ struct gPokemon
/* 0x42 */ s16 alphabetParent[2]; // alphabetNo and parentNo
};
+
+struct unkStruct_808E6F4
+{
+ s16 unk0;
+ u8 unk2;
+};
+
+struct EvolveStage
+{
+ s16 speciesNum;
+ u8 unkHasNextStage;
+};
+
+struct unkStruct_808DE50
+{
+ u16 unk0; // corresponds to unk0 inPokemonStruct
+ u8 unk2; // unk2
+ u8 unkHasNextStage; // unk3
+ struct unkPokeSubStruct_4 unk4; // unk4
+ u16 IQ; // IQ (other offset)
+ u16 unkA;
+ u16 unkC;
+ s16 speciesNum; // speciesNum (other offset)
+ u16 unk10; // pokeHP
+ u16 unk12; // pokeHP
+ struct Offense offense; // offense (other offset)
+ u32 unk18; // unk1C
+ struct unkPokeSubStruct_2C unk1C[4]; // unk2C
+ u8 fill3c[4];
+ /* 40 */ struct ItemSlot itemSlot; // heldItem
+ u32 unk44; // some struct
+ u32 unk48; // some struct (same type as 44)
+ u32 unk4C; // unk20
+ u8 unk50; // unk24
+ u8 fill51[3];
+ struct unkStruct_808E6F4 unk54;
+ u8 name[10]; // name (other offset)
+};
+
+struct LevelData
+{
+ // only size is known
+ u32 unk0[3];
+};
+
+struct unkStruct_808E218_arg
+{
+ u16 unk0[NUM_SPECIES];
+ u32 count;
+};
+
+struct unkStruct_808E218
+{
+ // leveldata? (same size)
+ struct unkStruct_808E6F4 unk0[3];
+};
+
+
void LoadMonsterParameters(void);
struct unkStruct_203B45C *GetRecruitedPokemon(void);
void InitializeRecruitedPokemon(void);
@@ -157,5 +228,8 @@ bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 r1);
struct OpenedFile *OpenPokemonDialogueSpriteFile(s16 index);
struct OpenedFile *GetDialogueSpriteDataPtr(s16 index);
s32 GetUnownIndex(s16 index);
+void sub_808E6F4(struct unkStruct_808E6F4* a1);
+s32 GetEvolutionSequence(struct PokemonStruct* pokemon, struct EvolveStage* a2);
+void xxx_pokemonstruct_to_unk_808DE50(struct unkStruct_808DE50* r0, struct PokemonStruct *r1, s32 r2);
#endif // GUARD_POKEMON_H
diff --git a/ld_script.txt b/ld_script.txt
index 2196068..b1ecd0e 100755
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -189,8 +189,6 @@ SECTIONS {
src/pokemon.o(.text);
asm/pokemon.o(.text);
src/pokemon_mid.o(.text);
- asm/pokemon_1.o(.text);
- src/pokemon_1.o(.text);
asm/pokemon_2.o(.text);
src/pokemon_3.o(.text);
asm/pokemon_3.o(.text);
diff --git a/src/code_80958E8.c b/src/code_80958E8.c
index a6ff84a..cd9fa20 100644
--- a/src/code_80958E8.c
+++ b/src/code_80958E8.c
@@ -32,7 +32,7 @@ struct unkStruct_203B490
extern bool8 sub_809095C(u8);
extern s32 sub_8090298(u8);
extern bool8 sub_809017C(u8 *);
-extern s16 sub_808E770(s16);
+extern s16 GetBaseSpecies(s16);
extern bool8 sub_8092040(u8);
extern u8 sub_803C1D0(u8 *, u8);
extern bool8 IsNotMoneyOrUsedTMItem(u8);
@@ -127,14 +127,14 @@ bool8 ValidateWonderMail(struct WonderMail *data)
return FALSE;
if(data->clientPoke > SPECIES_RAYQUAZA_CUTSCENE)
return FALSE;
- if(data->clientPoke != sub_808E770(data->clientPoke))
+ if(data->clientPoke != GetBaseSpecies(data->clientPoke))
return FALSE;
if(sub_803C0DC(data->clientPoke) == 0)
return FALSE;
if(data->targetPoke > SPECIES_RAYQUAZA_CUTSCENE)
return FALSE;
- if(data->targetPoke != sub_808E770(data->targetPoke))
+ if(data->targetPoke != GetBaseSpecies(data->targetPoke))
return FALSE;
if(sub_803C0DC(data->targetPoke) == 0)
return FALSE;
diff --git a/src/debug_menu_1.c b/src/debug_menu_1.c
index 0104c07..4386c87 100644
--- a/src/debug_menu_1.c
+++ b/src/debug_menu_1.c
@@ -56,7 +56,7 @@ void sub_803AFE8(void)
default:
break;
case 3:
- gUnknown_203B3F8->pokemon->unk3 = gUnknown_203B3F8->unk60;
+ gUnknown_203B3F8->pokemon->unkHasNextStage = gUnknown_203B3F8->unk60;
// Fallthrough is needed to match
case 2:
sub_803ACD0(2);
diff --git a/src/debug_menu_2.c b/src/debug_menu_2.c
index 158f540..dbcb60e 100644
--- a/src/debug_menu_2.c
+++ b/src/debug_menu_2.c
@@ -155,7 +155,7 @@ void sub_803AD88(void)
gUnknown_203B3F8->unk70 = 3;
gUnknown_203B3F8->unk68 = 1;
gUnknown_203B3F8->unk6C = 0x64;
- gUnknown_203B3F8->unk64 = gUnknown_203B3F8->pokemon->unk3;
+ gUnknown_203B3F8->unk64 = gUnknown_203B3F8->pokemon->unkHasNextStage;
gUnknown_203B3F8->unk74 = 3;
gUnknown_203B3F8->unk78 = &gUnknown_203B3F8->unkE0[3];
gUnknown_203B3F8->unk7C = 0x2C;
diff --git a/src/friend_area_action_menu_1.c b/src/friend_area_action_menu_1.c
index 5315996..f35bcfa 100644
--- a/src/friend_area_action_menu_1.c
+++ b/src/friend_area_action_menu_1.c
@@ -24,7 +24,7 @@ extern void nullsub_104();
extern void sub_8091274(u8 *);
extern void sub_801A928();
extern void sub_8099690(u32);
-extern void sub_808D800(s16, struct HeldItem *);
+extern void GivePokemonItem(s16, struct HeldItem *);
extern u32 sub_801A8AC();
extern u32 sub_801A6E8(u32);
@@ -96,7 +96,7 @@ void sub_8027BD8(void)
if (gUnknown_203B2BC->unk14 != 0) {
sub_8091274(&gUnknown_203B2BC->unk14);
}
- sub_808D800(gUnknown_203B2BC->unk8,&gUnknown_203B2BC->unk10);
+ GivePokemonItem(gUnknown_203B2BC->unk8,&gUnknown_203B2BC->unk10);
sub_801A928();
nullsub_104();
sub_8027184(2);
diff --git a/src/items.c b/src/items.c
index fb0304f..337e622 100644
--- a/src/items.c
+++ b/src/items.c
@@ -879,8 +879,8 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
a4->unk2 = boost_flags;
boost_flags = a4->unk2;
if (a4->unk2 & 1) {
- if (pokemon->pokeAtt < 255) {
- pokemon->pokeAtt++;
+ if (pokemon->offense.att[OFFENSE_NRM] < 255) {
+ pokemon->offense.att[OFFENSE_NRM]++;
}
else {
// fix operand order
@@ -890,24 +890,24 @@ void GetGummiItemStatBoost(struct PokemonStruct* pokemon, u8 itemIndex, u8 a3, s
}
}
if (a4->unk2 & 2) {
- if (pokemon->pokeSPAtt < 255) {
- pokemon->pokeSPAtt++;
+ if (pokemon->offense.att[OFFENSE_SP] < 255) {
+ pokemon->offense.att[OFFENSE_SP]++;
}
else {
a4->unk2 &= ~2;
}
}
if (a4->unk2 & 4) {
- if (pokemon->pokeDef < 255) {
- pokemon->pokeDef++;
+ if (pokemon->offense.def[OFFENSE_NRM] < 255) {
+ pokemon->offense.def[OFFENSE_NRM]++;
}
else {
a4->unk2 &= ~4;
}
}
if (a4->unk2 & 8) {
- if (pokemon->pokeSPDef < 255) {
- pokemon->pokeSPDef++;
+ if (pokemon->offense.def[OFFENSE_SP] < 255) {
+ pokemon->offense.def[OFFENSE_SP] ++;
}
else {
a4->unk2 &= ~8;
diff --git a/src/pokemon.c b/src/pokemon.c
index 263e482..a9ca120 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -2,6 +2,7 @@
#include "pokemon.h"
#include "file_system.h"
+
extern struct FileArchive gSystemFileArchive;
extern const char gUnknown_81075F4;
EWRAM_DATA struct gPokemon *gMonsterParameters;
@@ -10,6 +11,7 @@ EWRAM_DATA struct unkStruct_203B45C gRecruitedPokemon;
extern struct unkStruct_203B45C *gRecruitedPokemonRef;
EWRAM_DATA u16 gLevelCurrentPokeId;
+
void LoadMonsterParameters(void)
{
gRecruitedPokemonRef = &gRecruitedPokemon;
@@ -39,7 +41,7 @@ void InitializeRecruitedPokemon(void)
for(iVar3 = 0; iVar3 < 4; iVar3++)
{
- gRecruitedPokemonRef->pokemon3[iVar3].unk8 = 0;
- gRecruitedPokemonRef->pokemon3[iVar3].unk0 = 0;
+ gRecruitedPokemonRef->team[iVar3].speciesNum = 0;
+ gRecruitedPokemonRef->team[iVar3].unk0 = 0;
}
}
diff --git a/src/pokemon_1.c b/src/pokemon_1.c
deleted file mode 100644
index 8966ce7..0000000
--- a/src/pokemon_1.c
+++ /dev/null
@@ -1,200 +0,0 @@
-#include "global.h"
-#include "pokemon.h"
-#include "file_system.h"
-
-extern int sprintf(char *, const char *, ...);
-
-extern struct gPokemon *gMonsterParameters;
-extern struct FileArchive gMonsterFileArchive;
-extern const char gUnknown_8107684[];
-extern struct unkStruct_203B45C *gRecruitedPokemonRef;
-
-extern void sub_808DE50(void* r0, struct PokemonStruct *r1, u32 r2, u32 r3);
-
-
-u8 *GetCategoryString(s16 index)
-{
- return gMonsterParameters[index].category;
-}
-
-u8 GetPokemonSize(s16 index)
-{
- return gMonsterParameters[index].size;
-}
-
-u8 GetShadowSize(s16 index)
-{
- return gMonsterParameters[index].shadow_size;
-}
-
-s32 GetMoveSpeed(s16 index)
-{
- return gMonsterParameters[index].move_speed;
-}
-
-u8 GetWalkableTiles(s16 index)
-{
- return gMonsterParameters[index].walkable_tiles;
-}
-
-u8 GetUnk1B(s16 index)
-{
- return ((u8)(gMonsterParameters[index].unk1B) << 25) >> 24;
-}
-
-bool8 GetIsMoving(s16 index)
-{
- return gMonsterParameters[index].isMoving;
-}
-
-u8 GetUnk1D(s16 index)
-{
- return gMonsterParameters[index].unk1D;
-}
-
-u16 GetLowKickDmg(s16 index)
-{
- return gMonsterParameters[index].lowkick_dmg;
-}
-
-u16 GetSizeOrbDmg(s16 index)
-{
- return gMonsterParameters[index].sizeorb_dmg;
-}
-
-u8 GetFriendArea(s16 index)
-{
- return gMonsterParameters[index].friend_area;
-}
-
-u16 GetBaseHP(s16 index)
-{
- return gMonsterParameters[index].base_hp;
-}
-
-bool8 GetUnk33(s16 index)
-{
- return gMonsterParameters[index].unk33;
-}
-
-u8 GetUnk12(s16 index)
-{
- return gMonsterParameters[index].unk12;
-}
-
-s16 GetPokemonEvolveFrom(s16 index)
-{
- return gMonsterParameters[index].pre.evolve_from;
-}
-
-u16 GetPokemonAttSpatt(s16 index, u32 r1)
-{
- return gMonsterParameters[index].base_att_spatt[r1];
-}
-
-u16 GetPokemonDefSpdef(s16 index, u32 r1)
-{
- return gMonsterParameters[index].base_def_spdef[r1];
-}
-
-u8 GetPokemonType(s32 index, u32 typeIndex)
-{
- s16 newIndex = index;
- return gMonsterParameters[newIndex].types[typeIndex];
-}
-
-u8 GetPokemonAbility(s16 index, u32 abilityIndex)
-{
- return gMonsterParameters[index].abilities[abilityIndex];
-}
-
-s16 GetDexInternalNo(s16 index, u32 r1)
-{
- return gMonsterParameters[index].dexInternal[r1];
-}
-
-s16 GetBaseRecruit(s16 index)
-{
- return gMonsterParameters[index].base_recruit;
-}
-
-s16 GetAlphabetParentNo(s16 index, s32 r1)
-{
- return gMonsterParameters[index].alphabetParent[r1];
-}
-
-
-s16 GetInternalNo(s16 index)
-{
- return gMonsterParameters[index].dexInternal[1];
-}
-
-s32 CalculateEXPGain(s16 index, s32 level)
-{
- s32 baseEXP = gMonsterParameters[index].base_exp;
- return baseEXP + (baseEXP * (level - 1)) / 10;
-}
-
-s16 GetPokemonEvolveConditions(s16 index, struct unkEvolve *r1)
-{
- struct EvolveStruct1 temp2;
- struct EvolveNeeds temp1;
- temp1 = gMonsterParameters[index].need;
- temp2 = gMonsterParameters[index].pre;
- r1->conditions = temp2;
- r1->needs = temp1;
- // The return value is not used anywhere, but necessary for the function to match.
- return index;
-}
-
-u8 GetPokemonOverworldPalette(s16 index, u32 r1)
-{
- // Had to have this cast to match
- u32 temp;
- temp = index;
- if (r1 != 0)
- {
- return 10;
- }
- else
- {
- return gMonsterParameters[temp].overworld_palette;
- }
-}
-
-struct OpenedFile *OpenPokemonDialogueSpriteFile(s16 index)
-{
- // Looks like this loads the dialogue sprite for the pokemon
-
- char buffer[0xC];
- if(gMonsterParameters[index].dialogue_sprites == 0)
- {
- return NULL;
- }
- sprintf(buffer, gUnknown_8107684, index); // "kao%03d"
- return OpenFile(buffer, &gMonsterFileArchive);
-}
-
-struct OpenedFile *GetDialogueSpriteDataPtr(s16 index)
-{
- // Looks like this loads the dialogue sprite for the pokemon
-
- char buffer[0xC];
- if(gMonsterParameters[index].dialogue_sprites == 0)
- {
- return NULL;
- }
- sprintf(buffer, gUnknown_8107684, index); // "kao%03d"
- return OpenFileAndGetFileDataPtr(buffer, &gMonsterFileArchive);
-}
-
-bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 r1)
-{
- // checking to see if dialogue sprite is available??
- return (gMonsterParameters[index].dialogue_sprites >> r1) & 1;
-}
-
-void sub_808DE30(void* r0, u32 r1)
-{
- sub_808DE50(r0, &gRecruitedPokemonRef->pokemon[r1], r1, r1 * sizeof(struct PokemonStruct));
-}
diff --git a/src/pokemon_3.c b/src/pokemon_3.c
index 62e60d8..72005ed 100644
--- a/src/pokemon_3.c
+++ b/src/pokemon_3.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "pokemon.h"
+#include "random.h"
extern u32 gIQSkillNames[];
extern u32 gIQSkillDescriptions[];
@@ -10,6 +11,7 @@ extern u8 gUnknown_810A36B[];
extern s16 gUnknown_810A378[];
extern s32 gUnknown_810A390[];
extern u32 gUnknown_81076E4[];
+extern struct unkStruct_203B45C *gRecruitedPokemonRef;
struct unkStruct_808E9EC
{
@@ -22,15 +24,185 @@ struct unkStruct_808E9EC
u8 unk12;
u8 unk13;
};
+extern u32 gUnknown_81076C4[];
+struct unkStruct_202F3E8
+{
+ u16 unk0;
+ u16 unk2;
+ u16 unk4;
+ u16 unk6;
+};
+
+extern struct unkStruct_202F3E8 gUnknown_202F3E8[];
extern s16 gUnknown_810AC60; // 0xC
extern s16 gUnknown_810AC62; // 0xC
extern s16 gUnknown_810AC68; // 0x8
extern s16 gUnknown_810AC64; // 0x8
extern s16 gUnknown_810AC66; // 0x8
+// 2, 4, 6, 7, 8, 9, 0xA, 0xD, 0xF, 0x11
+extern s32 gUnknown_810AC90[10];
+
extern bool8 sub_808ECD0(u8 *, u32);
extern void sub_808EC30(u8 *, u32);
+extern void AddSprite(u16 *, u32, u32, u32);
+
+
+bool8 sub_808E668(s16 a1, s16* a2, s16* a3)
+{
+ u32 shifted = a1 << 16;
+
+ if (((shifted - 0x320000) >> 16) > 1) {
+ u8 shadow_size = GetShadowSize(a1);
+ u32 unk2, unk6;
+ struct unkStruct_202F3E8* arg0;
+
+ unk2 = a2[0] + a3[8];
+ unk6 = a2[1] + a3[9];
+ unk2 += gUnknown_81076C4[shadow_size];
+ unk6 -= 4;
+ unk2 &= 0x1ff;
+
+ arg0 = &gUnknown_202F3E8[shadow_size];
+ arg0->unk2 = (arg0->unk2 & 0xfe00) | unk2;
+ unk6 &= 0xfff;
+ unk6 <<= 4;
+ arg0->unk6 = (arg0->unk6 & 0xf) | unk6;
+ AddSprite((u16*)arg0, 0, 0, 0);
+ }
+ return 1;
+}
+
+
+void sub_808E6F4(struct unkStruct_808E6F4* a1)
+{
+ s32 i;
+
+ a1->unk0 = gUnknown_810AC90[RandomCapped(10)];
+ for (i = 0; i < 100; i++) {
+ a1->unk2 = RandomCapped(18);
+ if ( a1->unk2 )
+ break;
+ }
+ if ( i == 100 )
+ a1->unk2 = 2;
+}
+
+bool8 HasRecruitedMon(s16 species_) {
+ s32 species = species_;
+ s32 i = 0;
+ struct PokemonStruct *pokemon = gRecruitedPokemonRef->pokemon;
+
+ for (i = 0; i < 413; i++) {
+ if (((u8)pokemon->unk0 & 1)) {
+ if(pokemon->speciesNum == species)
+ return TRUE;
+ }
+ pokemon++;
+ }
+ return FALSE;
+}
+
+s32 GetBaseSpecies(s16 index) {
+ if (index == SPECIES_CASTFORM_SNOWY)
+ return SPECIES_CASTFORM;
+ if (index == SPECIES_CASTFORM_SUNNY)
+ return SPECIES_CASTFORM;
+ if (index == SPECIES_CASTFORM_RAINY)
+ return SPECIES_CASTFORM;
+ if(index == SPECIES_UNOWN_B)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_C)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_D)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_E)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_F)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_G)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_H)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_I)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_J)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_K)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_L)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_M)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_N)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_O)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_P)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_Q)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_R)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_S)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_T)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_U)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_V)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_W)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_X)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_Y)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_Z)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_EMARK)
+ return SPECIES_UNOWN;
+ if(index == SPECIES_UNOWN_QMARK)
+ return SPECIES_UNOWN;
+ if (index == SPECIES_DEOXYS_ATTACK)
+ return SPECIES_DEOXYS_NORMAL;
+ if (index == SPECIES_DEOXYS_DEFENSE)
+ return SPECIES_DEOXYS_NORMAL;
+ if (index == SPECIES_DEOXYS_SPEED)
+ return SPECIES_DEOXYS_NORMAL;
+ if (index == SPECIES_RAYQUAZA_CUTSCENE)
+ return SPECIES_RAYQUAZA;
+
+ return index;
+}
+
+s32 GetBaseSpeciesNoUnown(s16 index) {
+ register s32 a1_ asm("r2") = index;
+ if (index == SPECIES_CASTFORM_SNOWY) {
+ return SPECIES_CASTFORM;
+ }
+ if (index == SPECIES_CASTFORM_SUNNY) {
+ return SPECIES_CASTFORM;
+ }
+ if (index == SPECIES_CASTFORM_RAINY) {
+ return SPECIES_CASTFORM;
+ }
+ if (index == SPECIES_DEOXYS_ATTACK) {
+ return SPECIES_DEOXYS_NORMAL;
+ }
+ if (index == SPECIES_DEOXYS_DEFENSE) {
+ return SPECIES_DEOXYS_NORMAL;
+ }
+ if (index == SPECIES_DEOXYS_SPEED) {
+ return SPECIES_DEOXYS_NORMAL;
+ }
+ // these last 2 use r2 instead of just r0
+ if (a1_ == SPECIES_RAYQUAZA_CUTSCENE) {
+ return SPECIES_RAYQUAZA;
+ }
+ return a1_;
+}
s32 GetUnownIndex(s16 index)
{
@@ -452,3 +624,20 @@ u32 sub_808ECFC(void)
{
return 0;
}
+
+extern s32 sub_808D580(s32*);
+
+void sub_808ED00() {
+ s32 team[4];
+ s32 i;
+ s32 length = sub_808D580(team);
+
+ for (i = 0; i < length; i++) {
+ gRecruitedPokemonRef->team[i] = gRecruitedPokemonRef->pokemon[team[i]];
+ }
+
+ for (; i < 4; i++) {
+ gRecruitedPokemonRef->team[i].unk0 = 0;
+ }
+}
+
diff --git a/src/pokemon_mid.c b/src/pokemon_mid.c
index d297ca0..56d49fe 100644
--- a/src/pokemon_mid.c
+++ b/src/pokemon_mid.c
@@ -1,5 +1,7 @@
#include "global.h"
#include "pokemon.h"
+#include "item.h"
+#include "file_system.h"
extern struct gPokemon *gMonsterParameters;
extern const char gUnknown_8107600[];
@@ -8,12 +10,124 @@ extern const char gUnownLetters[];
extern const char gUnknown_8107630[];
extern const char gUnknown_8107638[];
extern const char gUnknown_810763C[];
+extern const char gUnknown_810768C[]; // lvmp%03d\0
+extern struct FileArchive gSystemFileArchive;
+extern s16 gUnknown_810ACB8; // 0x14d
+extern s16 gUnknown_810ACBA; // 0x14d
+extern s16 gUnknown_810ACBC; // 0x14d
+extern s16 gUnknown_810ACBE; // 0x14d
+
+// wram data:
+extern u16 gLevelCurrentPokeId;
+extern struct LevelData gLevelCurrentData[];
+
extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *r2, ...);
-extern s16 sub_808E770(u32);
+extern s16 GetBaseSpecies(u32);
extern void sub_80922B4(u8 *, u8 *, s32);
+extern int sprintf(char *, const char *, ...);
+extern u32 ReturnIntFromChar(u8 r0);
+extern void CopyStringtoBuffer(char *r0, char *r1);
+extern void sub_8093F50(void*, void*);
+extern void sub_80943A0(void*, s32);
+extern void xxx_unk_to_pokemonstruct_808DF44(struct PokemonStruct*, struct unkStruct_808DE50*);
+extern u8* sub_8092B18(s16);
+extern u8* sub_808E07C(u8* a1, u16* a2);
+extern u8* sub_8092B54(s32);
-extern void ExpandPlaceholdersBuffer(u8 *buffer, const char *r2, ...);
+struct unkStruct_8107654 {
+ s16 unk0;
+ s16 fill2;
+ s32 unk4;
+};
+
+extern u8 gUnknown_8107645[12];
+extern struct unkStruct_8107654 gUnknown_8107654[6];
+extern struct gPokemon *gMonsterParameters;
+extern struct FileArchive gMonsterFileArchive;
+extern const char gUnknown_8107684[];
+extern struct unkStruct_203B45C *gRecruitedPokemonRef;
+
+// bool8 sub_808D750(s16 index_) {
+// s32 i;
+// register s32 index asm("r8") = index_;
+// s32 count = 0;
+// s32 size_count = 0;
+
+// for (i = 0; i < 413; i++) {
+// register struct PokemonStruct* pokemon = &i[gRecruitedPokemonRef->pokemon];
+// register u16 unk0 = pokemon->unk0;
+// if ((unk0 & 1) && ((pokemon->unk0 >> 1) & 1)) {
+// size_count += GetPokemonSize(pokemon->speciesNum);
+// count++;
+// }
+// }
+
+// if (count < 4) {
+// struct PokemonStruct* pokemon;
+
+// pokemon = &gRecruitedPokemonRef->pokemon[index];
+
+// size_count += GetPokemonSize(pokemon->speciesNum);
+// if (size_count < 7) {
+// return TRUE;
+// }
+// }
+// return FALSE;
+// }
+
+
+void PeekPokemonItem(s16 index_, struct HeldItem* item) {
+ s32 index = index_;
+ struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[index];
+ item->itemIndex = pokemon->heldItem.itemIndex;
+ item->numItems = pokemon->heldItem.numItems;
+}
+
+void GivePokemonItem(s16 index_, struct HeldItem* item) {
+ s32 index = index_;
+ struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[index];
+ pokemon->heldItem.itemIndex = item->itemIndex;
+ pokemon->heldItem.numItems = item->numItems;
+}
+
+bool8 IsPokemonRenamed(struct PokemonStruct* pokemon) {
+ char species_name[20];
+ char* species = GetMonSpecies(pokemon->speciesNum);
+ s32 i;
+ CopyStringtoBuffer(species_name, species);
+ for (i = 0; i < 10; i++) {
+ if (pokemon->name[i] != species_name[i]) {
+ return FALSE;
+ }
+ if (!pokemon->name[i]) {
+ return TRUE;
+ }
+ }
+ return TRUE;
+}
+
+bool8 ComparePokemonNames(s16 a1, s16 a2) {
+ s32 index1 = a1;
+ s32 index2 = a2;
+ u8* name1 = gRecruitedPokemonRef->pokemon[index1].name;
+ u8* name2 = gRecruitedPokemonRef->pokemon[index2].name;
+
+ s32 i;
+ for (i = 0; i < 10; i++) {
+ s32 c1 = ReturnIntFromChar(*name1);
+ s32 c2 = ReturnIntFromChar(*name2);
+ if (c1 > c2) {
+ return TRUE;
+ }
+ if (c1 < c2) {
+ return FALSE;
+ }
+ name1++;
+ name2++;
+ }
+ return FALSE;
+}
void CopySpeciesNametoBuffer(u8 * buffer, s16 index)
{
@@ -40,7 +154,7 @@ void sub_808D930(u8 *buffer, s16 index)
const char *preload;
newIndex = index;
- if (sub_808E770(newIndex) == SPECIES_UNOWN) {
+ if (GetBaseSpecies(newIndex) == SPECIES_UNOWN) {
preload = gUnknown_8107630; // %s%c
unownString = GetMonSpecies(SPECIES_UNOWN);
unownIndex = GetUnownIndex(newIndex);
@@ -90,3 +204,570 @@ void sub_808DA34(u8 *buffer, struct PokemonStruct *pokemon)
{
sub_80922B4(buffer, pokemon->name, 10);
}
+
+bool8 sub_808DA44(s32 a1_, u32 a2_)
+{
+ // this is the dumbest thing ever, but just making a1 a s16 and
+ // a2 a u8 did weird stuff with shifting...
+ s32 a1 = (s16)a1_;
+ u32 a2 = (u8)a2_;
+ if (a2 > 0xc) {
+ s32 i;
+ struct unkStruct_8107654 data[6];
+ memcpy(data, gUnknown_8107654, 6 * sizeof(struct unkStruct_8107654));
+
+ for (i = 0; i < 10 && data[i].unk0; i++) {
+ if (data[i].unk0 == a1 && data[i].unk4 == a2) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+ else {
+ return gUnknown_8107645[a2];
+ }
+}
+
+u8 *GetCategoryString(s16 index)
+{
+ return gMonsterParameters[index].category;
+}
+
+u8 GetPokemonSize(s16 index)
+{
+ return gMonsterParameters[index].size;
+}
+
+u8 GetShadowSize(s16 index)
+{
+ return gMonsterParameters[index].shadow_size;
+}
+
+s32 GetMoveSpeed(s16 index)
+{
+ return gMonsterParameters[index].move_speed;
+}
+
+u8 GetWalkableTiles(s16 index)
+{
+ return gMonsterParameters[index].walkable_tiles;
+}
+
+u8 GetUnk1B(s16 index)
+{
+ return ((u8)(gMonsterParameters[index].unk1B) << 25) >> 24;
+}
+
+bool8 GetIsMoving(s16 index)
+{
+ return gMonsterParameters[index].isMoving;
+}
+
+u8 GetUnk1D(s16 index)
+{
+ return gMonsterParameters[index].unk1D;
+}
+
+u16 GetLowKickDmg(s16 index)
+{
+ return gMonsterParameters[index].lowkick_dmg;
+}
+
+u16 GetSizeOrbDmg(s16 index)
+{
+ return gMonsterParameters[index].sizeorb_dmg;
+}
+
+u8 GetFriendArea(s16 index)
+{
+ return gMonsterParameters[index].friend_area;
+}
+
+u16 GetBaseHP(s16 index)
+{
+ return gMonsterParameters[index].base_hp;
+}
+
+bool8 GetUnk33(s16 index)
+{
+ return gMonsterParameters[index].unk33;
+}
+
+u8 GetUnk12(s16 index)
+{
+ return gMonsterParameters[index].unk12;
+}
+
+s16 GetPokemonEvolveFrom(s16 index)
+{
+ return gMonsterParameters[index].pre.evolve_from;
+}
+
+u16 GetPokemonAttSpatt(s16 index, u32 r1)
+{
+ return gMonsterParameters[index].base_att_spatt[r1];
+}
+
+u16 GetPokemonDefSpdef(s16 index, u32 r1)
+{
+ return gMonsterParameters[index].base_def_spdef[r1];
+}
+
+u8 GetPokemonType(s32 index, u32 typeIndex)
+{
+ s16 newIndex = index;
+ return gMonsterParameters[newIndex].types[typeIndex];
+}
+
+u8 GetPokemonAbility(s16 index, u32 abilityIndex)
+{
+ return gMonsterParameters[index].abilities[abilityIndex];
+}
+
+s16 GetDexInternalNo(s16 index, u32 r1)
+{
+ return gMonsterParameters[index].dexInternal[r1];
+}
+
+s16 GetBaseRecruit(s16 index)
+{
+ return gMonsterParameters[index].base_recruit;
+}
+
+s16 GetAlphabetParentNo(s16 index, s32 r1)
+{
+ return gMonsterParameters[index].alphabetParent[r1];
+}
+
+
+s16 GetInternalNo(s16 index)
+{
+ return gMonsterParameters[index].dexInternal[1];
+}
+
+s32 CalculateEXPGain(s16 index, s32 level)
+{
+ s32 baseEXP = gMonsterParameters[index].base_exp;
+ return baseEXP + (baseEXP * (level - 1)) / 10;
+}
+
+s16 GetPokemonEvolveConditions(s16 index, struct unkEvolve *r1)
+{
+ struct EvolveStruct1 temp2;
+ struct EvolveNeeds temp1;
+ temp1 = gMonsterParameters[index].need;
+ temp2 = gMonsterParameters[index].pre;
+ r1->conditions = temp2;
+ r1->needs = temp1;
+ // The return value is not used anywhere, but necessary for the function to match.
+ return index;
+}
+
+u8 GetPokemonOverworldPalette(s16 index, u32 r1)
+{
+ // Had to have this cast to match
+ u32 temp;
+ temp = index;
+ if (r1 != 0)
+ {
+ return 10;
+ }
+ else
+ {
+ return gMonsterParameters[temp].overworld_palette;
+ }
+}
+
+struct OpenedFile *OpenPokemonDialogueSpriteFile(s16 index)
+{
+ // Looks like this loads the dialogue sprite for the pokemon
+
+ char buffer[0xC];
+ if(gMonsterParameters[index].dialogue_sprites == 0)
+ {
+ return NULL;
+ }
+ sprintf(buffer, gUnknown_8107684, index); // "kao%03d"
+ return OpenFile(buffer, &gMonsterFileArchive);
+}
+
+struct OpenedFile *GetDialogueSpriteDataPtr(s16 index)
+{
+ // Looks like this loads the dialogue sprite for the pokemon
+
+ char buffer[0xC];
+ if(gMonsterParameters[index].dialogue_sprites == 0)
+ {
+ return NULL;
+ }
+ sprintf(buffer, gUnknown_8107684, index); // "kao%03d"
+ return OpenFileAndGetFileDataPtr(buffer, &gMonsterFileArchive);
+}
+
+bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 r1)
+{
+ // checking to see if dialogue sprite is available??
+ return (gMonsterParameters[index].dialogue_sprites >> r1) & 1;
+}
+
+void xxx_pokemonstruct_index_to_unk_808DE30(void* r0, u32 r1)
+{
+ xxx_pokemonstruct_to_unk_808DE50(r0, &gRecruitedPokemonRef->pokemon[r1], r1);
+}
+
+void xxx_pokemonstruct_to_unk_808DE50(struct unkStruct_808DE50 * a1, struct PokemonStruct *pokemon, s32 a3)
+{
+ s32 i;
+ struct HeldItem* held;
+ struct ItemSlot* slot;
+ u32 somestruct_80943A0;
+ u32 somestruct2_80943A0;
+
+ a1->unk0 = pokemon->unk0;
+ a1->unkHasNextStage = pokemon->unkHasNextStage;
+ a1->IQ = pokemon->IQ;
+ a1->unk4C = pokemon->unk20;
+ sub_808E6F4(&a1->unk54);
+ a1->unk4 = pokemon->unk4;
+ a1->unk2 = pokemon->unk2;
+ a1->unkA = a3;
+ a1->speciesNum = pokemon->speciesNum;
+ a1->unk50 = pokemon->unk24;
+ a1->unk12 = pokemon->pokeHP;
+ a1->unk10 = pokemon->pokeHP;
+
+ for (i = 0; i < 2; i++) {
+ a1->offense.att[i] = pokemon->offense.att[i];
+ a1->offense.def[i] = pokemon->offense.def[i];
+ }
+
+ a1->unk18 = pokemon->unk1C;
+ sub_8093F50(&a1->unk1C, &pokemon->unk2C);
+
+ for (i = 0; i < 10; i++) {
+ a1->name[i] = pokemon->name[i];
+ }
+
+ held = &pokemon->heldItem;
+ slot = &a1->itemSlot;
+
+ if ((u32)(-held->itemIndex | held->itemIndex) >> 31) {
+ HeldItemToSlot(slot, held);
+ }
+ else {
+ slot->itemIndex = 0;
+ slot->numItems = 0;
+ slot->unk0 = 0;
+ }
+ sub_80943A0(&somestruct_80943A0, 100);
+ a1->unk44 = somestruct_80943A0;
+ sub_80943A0(&somestruct2_80943A0, 100);
+ a1->unk48 = somestruct2_80943A0;
+}
+
+void xxx_unk_to_pokemonstruct_index_808DF2C(s32 a1, struct unkStruct_808DE50* a2)
+{
+ xxx_unk_to_pokemonstruct_808DF44(&a1[gRecruitedPokemonRef->pokemon], a2);
+}
+
+extern void sub_8093FA8(struct unkPokeSubStruct_2C*, struct unkPokeSubStruct_2C*);
+
+
+void xxx_unk_to_pokemonstruct_808DF44(struct PokemonStruct* pokemon, struct unkStruct_808DE50* a2)
+{
+ s32 i;
+
+ pokemon->unk0 = a2->unk0;
+ pokemon->unkHasNextStage = a2->unkHasNextStage;
+ pokemon->IQ = a2->IQ;
+ pokemon->unk20 = a2->unk4C;
+ pokemon->unk4 = a2->unk4;
+ pokemon->unk2 = a2->unk2;
+ pokemon->speciesNum = a2->speciesNum;
+ pokemon->unk24 = a2->unk50;
+ pokemon->pokeHP = a2->unk12;
+
+ for (i = 0; i < 2; i++) {
+ pokemon->offense.att[i] = a2->offense.att[i];
+ pokemon->offense.def[i] = a2->offense.def[i];
+ }
+
+ pokemon->unk1C = a2->unk18;
+ sub_8093FA8(pokemon->unk2C, a2->unk1C);
+
+ for (i = 0; i < 10; i++) {
+ pokemon->name[i] = a2->name[i];
+ }
+
+ if (a2->itemSlot.unk0 & 1) {
+ SlotToHeldItem(&pokemon->heldItem, &a2->itemSlot);
+ }
+ else {
+ pokemon->heldItem.itemIndex = 0;
+ }
+}
+
+void sub_808DFDC(s32 a1, struct unkStruct_808DE50* a2)
+{
+ // transfer item from unk to pokemon at index
+ struct PokemonStruct* pokemon = &gRecruitedPokemonRef->pokemon[a1];
+ if (a2->itemSlot.unk0 & 1) {
+ SlotToHeldItem(&pokemon->heldItem, &a2->itemSlot);
+ }
+ else {
+ pokemon->heldItem.itemIndex = 0;
+ }
+}
+
+void GetPokemonLevelData(struct LevelData* a1, s16 _id, s32 a3)
+{
+ u8 buffer[12];
+ s32 id = _id;
+
+ if ((s16)gLevelCurrentPokeId != id)
+ {
+ struct OpenedFile *file;
+
+ gLevelCurrentPokeId = id;
+ // lvmp%03d\0
+ sprintf(buffer, gUnknown_810768C, id);
+ file = OpenFileAndGetFileDataPtr(buffer, &gSystemFileArchive);
+ DecompressATFile((char*)gLevelCurrentData, 0, file);
+ CloseFile(file);
+ }
+ a3 -= 1;
+ if ( a3 < 0 )
+ a3 = 0;
+
+ *a1 = gLevelCurrentData[a3];
+}
+
+u8* sub_808E07C(u8* a1, u16* a2)
+{
+ u32 r1 = *a1++;
+ u32 r3;
+ if (r1 & 0x80) {
+ r3 = *a1++;
+ }
+ else {
+ r3 = r1;
+ r1 = 0;
+ }
+#ifdef NONMATCHING
+ // wrong order
+ r1 &= 0x7f;
+ r3 &= 0x7f;
+ *a2 = (r1 << 7) | r3;
+#else
+ {
+ register u32 mask asm("r0") = 0x7f;
+ r3 &= mask;
+ r1 &= mask;
+ *a2 = (r1 << 7) | r3;
+ }
+#endif
+ return a1;
+}
+
+s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 a4)
+{
+ u8* stream;
+ u16 result; // struct?
+ s32 count;
+ register s32 _species asm("r2"); // weird regalloc
+
+ _species = (s16)species;
+ count = 0;
+
+ if (species == SPECIES_DECOY) return 0;
+ if (species == SPECIES_NONE) return 0;
+ if (species == SPECIES_MUNCHLAX) return 0;
+ // get stream
+ stream = sub_8092B18(_species);
+
+ while (*stream)
+ {
+ u8 v12;
+
+ // read from stream
+ stream = sub_808E07C(stream, &result);
+ v12 = *stream++;
+
+ if (v12 > a3)
+ break;
+ if (v12 == a3) {
+ bool8 cond = 1;
+ // I don't think these are species IDs
+ // the pokemon they would correspond to are pretty random if they are
+ // shuckle, heracross, pupitar, vibrava
+ if ((result == 238) && (a4 < gUnknown_810ACB8)) cond = 0;
+ if ((result == 239) && (a4 < gUnknown_810ACBA)) cond = 0;
+ if ((result == 272) && (a4 < gUnknown_810ACBC)) cond = 0;
+ if ((result == 354) && (a4 < gUnknown_810ACBE)) cond = 0;
+
+ if (cond) {
+ if (count < 16) {
+ *a1++ = result;
+ ++count;
+ }
+ }
+ }
+ }
+ return count;
+}
+
+bool8 sub_808E190(u16 a1, s16 _species)
+{
+ u16 result;
+ u16 result2;
+ s32 species = _species; // r4
+ u8* ptr;
+
+ if (species == SPECIES_DECOY) return 0;
+ if (species == SPECIES_NONE) return 0;
+ if (species == SPECIES_MUNCHLAX) return 0;
+ if (a1 == 352) return 0;
+
+ ptr = sub_8092B18(species);
+ while (*ptr) {
+ ptr = sub_808E07C(ptr, &result);
+ ptr++;
+ if (a1 == result) {
+ return 1;
+ }
+ }
+
+ ptr = sub_8092B54(species);
+ while (*ptr) {
+ ptr = sub_808E07C(ptr, &result2);
+ if (result2 == a1) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+s32 sub_808E218(struct unkStruct_808E218_arg* a1, struct PokemonStruct* pokemon)
+{
+ s32 i;
+ s32 count;
+ struct EvolveStage evolve_sequence[3];
+ s32 sequence_length;
+
+ count = 0;
+ a1->count = 0;
+ if (pokemon->speciesNum == SPECIES_DECOY) return 0;
+ if (pokemon->speciesNum == SPECIES_NONE) return 0;
+ if (pokemon->speciesNum == SPECIES_MUNCHLAX) return 0;
+
+ sequence_length = GetEvolutionSequence(pokemon, evolve_sequence);
+ for (i = 0; i < sequence_length; i++) {
+ u8* ptr;
+ u16 result;
+
+ ptr = sub_8092B18(evolve_sequence[i].speciesNum);
+ while (*ptr) {
+ s32 value;
+ ptr = sub_808E07C(ptr, &result);
+ value = *ptr++;
+
+ if (value > evolve_sequence[i].unkHasNextStage) {
+ break;
+ }
+
+ if (count < NUM_SPECIES) {
+ s32 j;
+ bool8 cond = 1;
+ // I don't think these are species IDs
+ // the pokemon they would correspond to are pretty random if they are
+ // shuckle, heracross, pupitar, vibrava
+ if ((result == 238) && (pokemon->IQ < gUnknown_810ACB8)) cond = 0;
+ if ((result == 239) && (pokemon->IQ < gUnknown_810ACBA)) cond = 0;
+ if ((result == 272) && (pokemon->IQ < gUnknown_810ACBC)) cond = 0;
+ if ((result == 354) && (pokemon->IQ < gUnknown_810ACBE)) cond = 0;
+
+ for (j = 0; j < 4; j++) {
+ if ((pokemon->unk2C[j].unk0 & 1) && pokemon->unk2C[j].unk2 == result) {
+ cond = 0;
+ }
+ }
+
+ if (cond) {
+ s32 k;
+ for (k = 0; k < count && a1->unk0[k] != result; k++) {}
+
+ if (k == count) {
+ a1->unk0[count++] = result;
+ }
+ }
+ }
+ }
+ }
+
+ a1->count = count;
+ return count;
+}
+
+
+s32 GetEvolutionSequence(struct PokemonStruct* pokemon, struct EvolveStage* a2)
+{
+#ifdef NONMATCHING
+ s32 count;
+ s32 species;
+ s32 i;
+
+ a2[0].specesNum = pokemon->speciesNum;
+ a2[0].unkHasNextStage = pokemon->unkHasNextStage;
+
+ count = 1;
+ species = pokemon->speciesNum;
+ i = 0;
+
+ for (; i < 2; i++) {
+ if (!pokemon->unkC[i].unk0) {
+ break;
+ }
+ species = GetPokemonEvolveFrom(species);
+ if (!species) {
+ break;
+ }
+ a2[1 + i].speciesNum = species;
+ a2[1 + i].unkHasNextStage = pokemon->unkC[i].unk0;
+ // wrong increment order:
+ count++;
+ }
+ return count;
+#else
+ s32 count;
+ s32 species;
+ s32 i;
+ struct EvolveStage* stage;
+ struct unkPokeSubStruct_C* has_next_stage;
+
+ a2[0].speciesNum = pokemon->speciesNum;
+ a2[0].unkHasNextStage = pokemon->unkHasNextStage;
+
+ count = 1;
+ species = pokemon->speciesNum;
+ i = 0;
+ has_next_stage = pokemon->unkC;
+ stage = &a2[1];
+
+ for (; i < 2; i++) {
+ if (!has_next_stage->unk0) {
+ break;
+ }
+ species = GetPokemonEvolveFrom(species);
+ if (!species) {
+ break;
+ }
+ stage->speciesNum = species;
+ stage->unkHasNextStage = has_next_stage->unk0;
+ stage++;
+ count++;
+ has_next_stage++;
+ }
+ return count;
+#endif
+} \ No newline at end of file
diff --git a/tools/scaninc/scaninc.cpp b/tools/scaninc/scaninc.cpp
index a91b872..a3e40c5 100644
--- a/tools/scaninc/scaninc.cpp
+++ b/tools/scaninc/scaninc.cpp
@@ -1,128 +1,128 @@
-// Copyright(c) 2015-2017 YamaArashi
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <cstdio>
-#include <cstdlib>
-#include <list>
-#include <queue>
-#include <set>
-#include <string>
-#include "scaninc.h"
-#include "source_file.h"
-
-bool CanOpenFile(std::string path)
-{
- FILE *fp = std::fopen(path.c_str(), "rb");
-
- if (fp == NULL)
- return false;
-
- std::fclose(fp);
- return true;
-}
-
-const char *const USAGE = "Usage: scaninc [-I INCLUDE_PATH] FILE_PATH\n";
-
-int main(int argc, char **argv)
-{
- std::queue<std::string> filesToProcess;
- std::set<std::string> dependencies;
-
- std::vector<std::string> includeDirs;
-
- argc--;
- argv++;
-
- while (argc > 1)
- {
- std::string arg(argv[0]);
- if (arg.substr(0, 2) == "-I")
- {
- std::string includeDir = arg.substr(2);
- if (includeDir.empty())
- {
- argc--;
- argv++;
- includeDir = std::string(argv[0]);
- }
- if (!includeDir.empty() && includeDir.back() != '/')
- {
- includeDir += '/';
- }
- includeDirs.push_back(includeDir);
- }
- else
- {
- FATAL_ERROR(USAGE);
- }
- argc--;
- argv++;
- }
-
- if (argc != 1) {
- FATAL_ERROR(USAGE);
- }
-
- std::string initialPath(argv[0]);
-
- filesToProcess.push(initialPath);
-
- while (!filesToProcess.empty())
- {
- std::string filePath = filesToProcess.front();
- SourceFile file(filePath);
- filesToProcess.pop();
-
- includeDirs.push_back(file.GetSrcDir());
- for (auto incbin : file.GetIncbins())
- {
- dependencies.insert(incbin);
- }
- for (auto include : file.GetIncludes())
- {
- bool exists = false;
- std::string path("");
- for (auto includeDir : includeDirs)
- {
- path = includeDir + include;
- if (CanOpenFile(path))
- {
- exists = true;
- break;
- }
- }
- if (!exists && file.FileType() == SourceFileType::Asm)
- {
- path = include;
- }
- bool inserted = dependencies.insert(path).second;
- if (inserted && exists)
- {
- filesToProcess.push(path);
- }
- }
- includeDirs.pop_back();
- }
-
- for (const std::string &path : dependencies)
- {
- std::printf("%s\n", path.c_str());
- }
-}
+// Copyright(c) 2015-2017 YamaArashi
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <cstdio>
+#include <cstdlib>
+#include <list>
+#include <queue>
+#include <set>
+#include <string>
+#include "scaninc.h"
+#include "source_file.h"
+
+bool CanOpenFile(std::string path)
+{
+ FILE *fp = std::fopen(path.c_str(), "rb");
+
+ if (fp == NULL)
+ return false;
+
+ std::fclose(fp);
+ return true;
+}
+
+const char *const USAGE = "Usage: scaninc [-I INCLUDE_PATH] FILE_PATH\n";
+
+int main(int argc, char **argv)
+{
+ std::queue<std::string> filesToProcess;
+ std::set<std::string> dependencies;
+
+ std::vector<std::string> includeDirs;
+
+ argc--;
+ argv++;
+
+ while (argc > 1)
+ {
+ std::string arg(argv[0]);
+ if (arg.substr(0, 2) == "-I")
+ {
+ std::string includeDir = arg.substr(2);
+ if (includeDir.empty())
+ {
+ argc--;
+ argv++;
+ includeDir = std::string(argv[0]);
+ }
+ if (!includeDir.empty() && includeDir.back() != '/')
+ {
+ includeDir += '/';
+ }
+ includeDirs.push_back(includeDir);
+ }
+ else
+ {
+ FATAL_ERROR(USAGE);
+ }
+ argc--;
+ argv++;
+ }
+
+ if (argc != 1) {
+ FATAL_ERROR(USAGE);
+ }
+
+ std::string initialPath(argv[0]);
+
+ filesToProcess.push(initialPath);
+
+ while (!filesToProcess.empty())
+ {
+ std::string filePath = filesToProcess.front();
+ SourceFile file(filePath);
+ filesToProcess.pop();
+
+ includeDirs.push_back(file.GetSrcDir());
+ for (auto incbin : file.GetIncbins())
+ {
+ dependencies.insert(incbin);
+ }
+ for (auto include : file.GetIncludes())
+ {
+ bool exists = false;
+ std::string path("");
+ for (auto includeDir : includeDirs)
+ {
+ path = includeDir + include;
+ if (CanOpenFile(path))
+ {
+ exists = true;
+ break;
+ }
+ }
+ if (!exists && file.FileType() == SourceFileType::Asm)
+ {
+ path = include;
+ }
+ bool inserted = dependencies.insert(path).second;
+ if (inserted && exists)
+ {
+ filesToProcess.push(path);
+ }
+ }
+ includeDirs.pop_back();
+ }
+
+ for (const std::string &path : dependencies)
+ {
+ std::printf("%s\n", path.c_str());
+ }
+}
diff --git a/tools/scaninc/source_file.cpp b/tools/scaninc/source_file.cpp
index 255c818..df31282 100644
--- a/tools/scaninc/source_file.cpp
+++ b/tools/scaninc/source_file.cpp
@@ -1,130 +1,130 @@
-// Copyright(c) 2019 Phlosioneer
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include <new>
-#include "source_file.h"
-
-
-SourceFileType GetFileType(std::string& path)
-{
- std::size_t pos = path.find_last_of('.');
-
- if (pos == std::string::npos)
- FATAL_ERROR("no file extension in path \"%s\"\n", path.c_str());
-
- std::string extension = path.substr(pos + 1);
-
- if (extension == "c")
- return SourceFileType::Cpp;
- else if (extension == "s")
- return SourceFileType::Asm;
- else if (extension == "h")
- return SourceFileType::Header;
- else if (extension == "inc")
- return SourceFileType::Inc;
- else
- FATAL_ERROR("Unrecognized extension \"%s\"\n", extension.c_str());
-
- // Unreachable
- return SourceFileType::Cpp;
-}
-
-std::string GetDir(std::string& path)
-{
- std::size_t slash = path.rfind('/');
-
- if (slash != std::string::npos)
- return path.substr(0, slash + 1);
- else
- return std::string("");
-}
-
-SourceFile::SourceFile(std::string path)
-{
- m_file_type = GetFileType(path);
-
- m_src_dir = GetDir(path);
-
- if (m_file_type == SourceFileType::Cpp
- || m_file_type == SourceFileType::Header)
- {
- new (&m_source_file.c_file) CFile(path);
- m_source_file.c_file.FindIncbins();
- }
- else
- {
- AsmFile file(path);
- std::set<std::string> incbins;
- std::set<std::string> includes;
-
- IncDirectiveType incDirectiveType;
- std::string outputPath;
-
- while ((incDirectiveType = file.ReadUntilIncDirective(outputPath)) != IncDirectiveType::None)
- {
- if (incDirectiveType == IncDirectiveType::Include)
- includes.insert(outputPath);
- else
- incbins.insert(outputPath);
- }
-
- new (&m_source_file.asm_wrapper) SourceFile::InnerUnion::AsmWrapper{incbins, includes};
- }
-}
-
-SourceFileType SourceFile::FileType()
-{
- return m_file_type;
-}
-
-SourceFile::~SourceFile()
-{
- if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
- {
- m_source_file.c_file.~CFile();
- }
- else
- {
- m_source_file.asm_wrapper.asm_incbins.~set();
- m_source_file.asm_wrapper.asm_includes.~set();
- }
-}
-
-const std::set<std::string>& SourceFile::GetIncbins()
-{
- if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
- return m_source_file.c_file.GetIncbins();
- else
- return m_source_file.asm_wrapper.asm_incbins;
-}
-
-const std::set<std::string>& SourceFile::GetIncludes()
-{
- if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
- return m_source_file.c_file.GetIncludes();
- else
- return m_source_file.asm_wrapper.asm_includes;
-}
-
-std::string& SourceFile::GetSrcDir()
-{
- return m_src_dir;
-}
-
+// Copyright(c) 2019 Phlosioneer
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#include <new>
+#include "source_file.h"
+
+
+SourceFileType GetFileType(std::string& path)
+{
+ std::size_t pos = path.find_last_of('.');
+
+ if (pos == std::string::npos)
+ FATAL_ERROR("no file extension in path \"%s\"\n", path.c_str());
+
+ std::string extension = path.substr(pos + 1);
+
+ if (extension == "c")
+ return SourceFileType::Cpp;
+ else if (extension == "s")
+ return SourceFileType::Asm;
+ else if (extension == "h")
+ return SourceFileType::Header;
+ else if (extension == "inc")
+ return SourceFileType::Inc;
+ else
+ FATAL_ERROR("Unrecognized extension \"%s\"\n", extension.c_str());
+
+ // Unreachable
+ return SourceFileType::Cpp;
+}
+
+std::string GetDir(std::string& path)
+{
+ std::size_t slash = path.rfind('/');
+
+ if (slash != std::string::npos)
+ return path.substr(0, slash + 1);
+ else
+ return std::string("");
+}
+
+SourceFile::SourceFile(std::string path)
+{
+ m_file_type = GetFileType(path);
+
+ m_src_dir = GetDir(path);
+
+ if (m_file_type == SourceFileType::Cpp
+ || m_file_type == SourceFileType::Header)
+ {
+ new (&m_source_file.c_file) CFile(path);
+ m_source_file.c_file.FindIncbins();
+ }
+ else
+ {
+ AsmFile file(path);
+ std::set<std::string> incbins;
+ std::set<std::string> includes;
+
+ IncDirectiveType incDirectiveType;
+ std::string outputPath;
+
+ while ((incDirectiveType = file.ReadUntilIncDirective(outputPath)) != IncDirectiveType::None)
+ {
+ if (incDirectiveType == IncDirectiveType::Include)
+ includes.insert(outputPath);
+ else
+ incbins.insert(outputPath);
+ }
+
+ new (&m_source_file.asm_wrapper) SourceFile::InnerUnion::AsmWrapper{incbins, includes};
+ }
+}
+
+SourceFileType SourceFile::FileType()
+{
+ return m_file_type;
+}
+
+SourceFile::~SourceFile()
+{
+ if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
+ {
+ m_source_file.c_file.~CFile();
+ }
+ else
+ {
+ m_source_file.asm_wrapper.asm_incbins.~set();
+ m_source_file.asm_wrapper.asm_includes.~set();
+ }
+}
+
+const std::set<std::string>& SourceFile::GetIncbins()
+{
+ if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
+ return m_source_file.c_file.GetIncbins();
+ else
+ return m_source_file.asm_wrapper.asm_incbins;
+}
+
+const std::set<std::string>& SourceFile::GetIncludes()
+{
+ if (m_file_type == SourceFileType::Cpp || m_file_type == SourceFileType::Header)
+ return m_source_file.c_file.GetIncludes();
+ else
+ return m_source_file.asm_wrapper.asm_includes;
+}
+
+std::string& SourceFile::GetSrcDir()
+{
+ return m_src_dir;
+}
+