summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/easy_chat.s444
-rw-r--r--include/asm.inc.h3
-rw-r--r--include/easy_chat.h32
-rw-r--r--include/global.h9
-rw-r--r--ld_script.txt1
-rw-r--r--src/dewford_trend.c7
-rw-r--r--src/easy_chat.c262
7 files changed, 306 insertions, 452 deletions
diff --git a/asm/easy_chat.s b/asm/easy_chat.s
index 8000e9029..b8bfaac18 100644
--- a/asm/easy_chat.s
+++ b/asm/easy_chat.s
@@ -11193,448 +11193,4 @@ _080EB724: .4byte 0xffff0000
_080EB728: .4byte 0x0000ffff
thumb_func_end sub_80EB6FC
- thumb_func_start sub_80EB72C
-sub_80EB72C: @ 80EB72C
- push {r4,lr}
- lsls r0, 16
- lsrs r4, r0, 16
- bl Random
- lsls r0, 16
- lsrs r0, 16
- ldr r1, _080EB778 @ =gEasyChatGroupSizes
- adds r1, r4, r1
- ldrb r1, [r1]
- bl __modsi3
- lsls r0, 16
- lsrs r2, r0, 16
- cmp r4, 0
- beq _080EB758
- cmp r4, 0x15
- beq _080EB758
- cmp r4, 0x12
- beq _080EB758
- cmp r4, 0x13
- bne _080EB766
-_080EB758:
- ldr r1, _080EB77C @ =gEasyChatGroupWords
- lsls r0, r4, 2
- adds r0, r1
- ldr r1, [r0]
- lsls r0, r2, 1
- adds r0, r1
- ldrh r2, [r0]
-_080EB766:
- movs r0, 0x7F
- ands r0, r4
- lsls r0, 9
- ldr r1, _080EB780 @ =0x000001ff
- ands r2, r1
- orrs r0, r2
- pop {r4}
- pop {r1}
- bx r1
- .align 2, 0
-_080EB778: .4byte gEasyChatGroupSizes
-_080EB77C: .4byte gEasyChatGroupWords
-_080EB780: .4byte 0x000001ff
- thumb_func_end sub_80EB72C
-
- thumb_func_start sub_80EB784
-sub_80EB784: @ 80EB784
- push {r4,lr}
- lsls r0, 16
- lsrs r4, r0, 16
- lsls r0, r4, 24
- lsrs r0, 24
- bl sub_80EAD7C
- lsls r0, 24
- cmp r0, 0
- bne _080EB7A0
- ldr r0, _080EB79C @ =0x0000ffff
- b _080EB7BE
- .align 2, 0
-_080EB79C: .4byte 0x0000ffff
-_080EB7A0:
- cmp r4, 0
- beq _080EB7AE
- cmp r4, 0x14
- bne _080EB7B4
- bl sub_80EB960
- b _080EB7BA
-_080EB7AE:
- bl sub_80EB9D8
- b _080EB7BA
-_080EB7B4:
- adds r0, r4, 0
- bl sub_80EB72C
-_080EB7BA:
- lsls r0, 16
- lsrs r0, 16
-_080EB7BE:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_80EB784
-
- thumb_func_start sub_80EB7C4
-sub_80EB7C4: @ 80EB7C4
- push {r4,r5,lr}
- ldr r0, _080EB7D8 @ =gSpecialVar_0x8004
- ldrh r0, [r0]
- cmp r0, 0x1
- beq _080EB7F0
- cmp r0, 0x1
- bgt _080EB7DC
- cmp r0, 0
- beq _080EB7E6
- b _080EB82E
- .align 2, 0
-_080EB7D8: .4byte gSpecialVar_0x8004
-_080EB7DC:
- cmp r0, 0x2
- beq _080EB810
- cmp r0, 0x3
- beq _080EB818
- b _080EB82E
-_080EB7E6:
- ldr r5, _080EB7EC @ =gSaveBlock1 + 0x2B1C
- movs r2, 0x2
- b _080EB81C
- .align 2, 0
-_080EB7EC: .4byte gSaveBlock1 + 0x2B1C
-_080EB7F0:
- ldr r5, _080EB80C @ =gSaveBlock1 + 0x2B28
- adds r0, r5, 0
- movs r1, 0x3
- movs r2, 0x2
- movs r3, 0x14
- bl sub_80EB680
- lsls r0, 24
- cmp r0, 0
- beq _080EB81A
- movs r2, 0x2
- movs r3, 0x3
- b _080EB81E
- .align 2, 0
-_080EB80C: .4byte gSaveBlock1 + 0x2B28
-_080EB810:
- ldr r5, _080EB814 @ =gSaveBlock1 + 0x2B34
- b _080EB81A
- .align 2, 0
-_080EB814: .4byte gSaveBlock1 + 0x2B34
-_080EB818:
- ldr r5, _080EB834 @ =gSaveBlock1 + 0x2B40
-_080EB81A:
- movs r2, 0x3
-_080EB81C:
- movs r3, 0x2
-_080EB81E:
- ldr r4, _080EB838 @ =gStringVar4
- adds r0, r4, 0
- adds r1, r5, 0
- bl ConvertEasyChatWordsToString
- adds r0, r4, 0
- bl ShowFieldAutoScrollMessage
-_080EB82E:
- pop {r4,r5}
- pop {r0}
- bx r0
- .align 2, 0
-_080EB834: .4byte gSaveBlock1 + 0x2B40
-_080EB838: .4byte gStringVar4
- thumb_func_end sub_80EB7C4
-
- thumb_func_start sub_80EB83C
-sub_80EB83C: @ 80EB83C
- push {lr}
- bl Random
- movs r1, 0x1
- ands r1, r0
- movs r0, 0xC
- cmp r1, 0
- beq _080EB84E
- movs r0, 0xD
-_080EB84E:
- bl sub_80EB784
- adds r1, r0, 0
- lsls r1, 16
- lsrs r1, 16
- ldr r0, _080EB864 @ =gStringVar2
- bl sub_80EB3FC
- pop {r0}
- bx r0
- .align 2, 0
-_080EB864: .4byte gStringVar2
- thumb_func_end sub_80EB83C
-
- thumb_func_start sub_80EB868
-sub_80EB868: @ 80EB868
- lsls r0, 24
- lsrs r2, r0, 27
- movs r1, 0xE0
- lsls r1, 19
- ands r1, r0
- lsrs r1, 24
- ldr r0, _080EB888 @ =gSaveBlock1
- ldr r3, _080EB88C @ =0x00002d8c
- adds r0, r3
- adds r2, r0
- ldrb r0, [r2]
- asrs r0, r1
- movs r1, 0x1
- ands r0, r1
- bx lr
- .align 2, 0
-_080EB888: .4byte gSaveBlock1
-_080EB88C: .4byte 0x00002d8c
- thumb_func_end sub_80EB868
-
- thumb_func_start sub_80EB890
-sub_80EB890: @ 80EB890
- push {lr}
- lsls r0, 24
- lsrs r3, r0, 24
- cmp r3, 0x20
- bhi _080EB8B2
- lsrs r2, r0, 27
- movs r1, 0x7
- ands r1, r3
- ldr r0, _080EB8B8 @ =gSaveBlock1
- ldr r3, _080EB8BC @ =0x00002d8c
- adds r0, r3
- adds r2, r0
- movs r0, 0x1
- lsls r0, r1
- ldrb r1, [r2]
- orrs r0, r1
- strb r0, [r2]
-_080EB8B2:
- pop {r0}
- bx r0
- .align 2, 0
-_080EB8B8: .4byte gSaveBlock1
-_080EB8BC: .4byte 0x00002d8c
- thumb_func_end sub_80EB890
-
- thumb_func_start sub_80EB8C0
-sub_80EB8C0: @ 80EB8C0
- push {r4,r5,lr}
- movs r4, 0
- movs r5, 0
-_080EB8C6:
- adds r0, r4, 0
- bl sub_80EB868
- lsls r0, 24
- cmp r0, 0
- beq _080EB8D8
- adds r0, r5, 0x1
- lsls r0, 24
- lsrs r5, r0, 24
-_080EB8D8:
- adds r0, r4, 0x1
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0x20
- bls _080EB8C6
- adds r0, r5, 0
- pop {r4,r5}
- pop {r1}
- bx r1
- thumb_func_end sub_80EB8C0
-
- thumb_func_start sub_80EB8EC
-sub_80EB8EC: @ 80EB8EC
- push {r4-r6,lr}
- bl sub_80EB8C0
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0x21
- bne _080EB918
- b _080EB952
-_080EB8FC:
- adds r0, r5, 0
- bl sub_80EB890
- ldr r0, _080EB914 @ =0x000001ff
- ands r4, r0
- movs r1, 0xA0
- lsls r1, 6
- adds r0, r1, 0
- orrs r4, r0
- adds r0, r4, 0
- b _080EB954
- .align 2, 0
-_080EB914: .4byte 0x000001ff
-_080EB918:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0x21
- subs r1, r4
- bl __modsi3
- lsls r0, 16
- lsrs r6, r0, 16
- movs r4, 0
-_080EB92E:
- lsls r0, r4, 24
- lsrs r5, r0, 24
- adds r0, r5, 0
- bl sub_80EB868
- lsls r0, 24
- cmp r0, 0
- bne _080EB948
- cmp r6, 0
- beq _080EB8FC
- subs r0, r6, 0x1
- lsls r0, 16
- lsrs r6, r0, 16
-_080EB948:
- adds r0, r4, 0x1
- lsls r0, 16
- lsrs r4, r0, 16
- cmp r4, 0x20
- bls _080EB92E
-_080EB952:
- ldr r0, _080EB95C @ =0x0000ffff
-_080EB954:
- pop {r4-r6}
- pop {r1}
- bx r1
- .align 2, 0
-_080EB95C: .4byte 0x0000ffff
- thumb_func_end sub_80EB8EC
-
- thumb_func_start sub_80EB960
-sub_80EB960: @ 80EB960
- push {r4,r5,lr}
- bl sub_80EB8C0
- lsls r0, 24
- lsrs r5, r0, 24
- cmp r5, 0
- bne _080EB984
- b _080EB9BA
-_080EB970:
- ldr r0, _080EB980 @ =0x000001ff
- ands r4, r0
- movs r1, 0xA0
- lsls r1, 6
- adds r0, r1, 0
- orrs r4, r0
- adds r0, r4, 0
- b _080EB9BC
- .align 2, 0
-_080EB980: .4byte 0x000001ff
-_080EB984:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- adds r1, r5, 0
- bl __umodsi3
- lsls r0, 16
- lsrs r5, r0, 16
- movs r4, 0
-_080EB998:
- lsls r0, r4, 24
- lsrs r0, 24
- bl sub_80EB868
- lsls r0, 24
- cmp r0, 0
- beq _080EB9B0
- cmp r5, 0
- beq _080EB970
- subs r0, r5, 0x1
- lsls r0, 16
- lsrs r5, r0, 16
-_080EB9B0:
- adds r0, r4, 0x1
- lsls r0, 16
- lsrs r4, r0, 16
- cmp r4, 0x20
- bls _080EB998
-_080EB9BA:
- ldr r0, _080EB9C4 @ =0x0000ffff
-_080EB9BC:
- pop {r4,r5}
- pop {r1}
- bx r1
- .align 2, 0
-_080EB9C4: .4byte 0x0000ffff
- thumb_func_end sub_80EB960
-
- thumb_func_start sub_80EB9C8
-sub_80EB9C8: @ 80EB9C8
- push {lr}
- bl IsNationalPokedexEnabled
- lsls r0, 24
- lsrs r0, 24
- pop {r1}
- bx r1
- thumb_func_end sub_80EB9C8
-
- thumb_func_start sub_80EB9D8
-sub_80EB9D8: @ 80EB9D8
- push {r4-r7,lr}
- movs r0, 0
- bl sub_80EAE88
- lsls r0, 16
- lsrs r4, r0, 16
- cmp r4, 0
- bne _080EB9F8
- b _080EBA46
-_080EB9EA:
- ldrh r1, [r5]
- ldr r0, _080EB9F4 @ =0x000001ff
- ands r0, r1
- b _080EBA48
- .align 2, 0
-_080EB9F4: .4byte 0x000001ff
-_080EB9F8:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- adds r1, r4, 0
- bl __umodsi3
- lsls r0, 16
- lsrs r4, r0, 16
- ldr r0, _080EBA50 @ =gEasyChatGroupWords
- ldr r5, [r0]
- movs r6, 0
- ldr r0, _080EBA54 @ =gEasyChatGroupSizes
- ldrb r0, [r0]
- cmp r6, r0
- bcs _080EBA46
- adds r7, r0, 0
-_080EBA1A:
- ldrh r0, [r5]
- bl SpeciesToNationalPokedexNum
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0
- bl sub_8090D90
- lsls r0, 24
- cmp r0, 0
- beq _080EBA3A
- cmp r4, 0
- beq _080EB9EA
- subs r0, r4, 0x1
- lsls r0, 16
- lsrs r4, r0, 16
-_080EBA3A:
- adds r5, 0x2
- adds r0, r6, 0x1
- lsls r0, 16
- lsrs r6, r0, 16
- cmp r6, r7
- bcc _080EBA1A
-_080EBA46:
- ldr r0, _080EBA58 @ =0x0000ffff
-_080EBA48:
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_080EBA50: .4byte gEasyChatGroupWords
-_080EBA54: .4byte gEasyChatGroupSizes
-_080EBA58: .4byte 0x0000ffff
- thumb_func_end sub_80EB9D8
-
.align 2, 0 @ Don't pad with nop.
diff --git a/include/asm.inc.h b/include/asm.inc.h
index 430664517..da5c02113 100644
--- a/include/asm.inc.h
+++ b/include/asm.inc.h
@@ -321,9 +321,8 @@ void sub_80C8F34(u8);
// asm/easy_chat.o
void sub_80E6764(void);
-void sub_80EB3FC(u8 *, u16);
+u8* sub_80EB3FC(u8 *, u16);
u8 ConvertEasyChatWordsToString(u8 *dst, u16 *words, u16, u16);
-u16 sub_80EB72C(u16);
// asm/pokenav.o
void sub_80EBA5C(void);
diff --git a/include/easy_chat.h b/include/easy_chat.h
new file mode 100644
index 000000000..ee5ac4138
--- /dev/null
+++ b/include/easy_chat.h
@@ -0,0 +1,32 @@
+#ifndef GUARD_EASYCHAT_H
+#define GUARD_EASYCHAT_H
+
+enum {
+ EC_GROUP_POKEMON,
+ EC_GROUP_TRAINER,
+ EC_GROUP_STATUS,
+ EC_GROUP_BATTLE,
+ EC_GROUP_GREETINGS,
+ EC_GROUP_PEOPLE,
+ EC_GROUP_VOICES,
+ EC_GROUP_SPEECH,
+ EC_GROUP_ENDINGS,
+ EC_GROUP_FEELINGS,
+ EC_GROUP_CONDITIONS,
+ EC_GROUP_ACTIONS,
+ EC_GROUP_LIFESTYLE,
+ EC_GROUP_HOBBIES,
+ EC_GROUP_TIME,
+ EC_GROUP_MISC,
+ EC_GROUP_ADJECTIVES,
+ EC_GROUP_EVENTS,
+ EC_GROUP_MOVE_1,
+ EC_GROUP_MOVE_2,
+ EC_GROUP_TRENDY_SAYING,
+ EC_GROUP_POKEMON_2,
+};
+
+
+u16 sub_80EB72C(u16 group);
+
+#endif // GUARD_EASYCHAT_H
diff --git a/include/global.h b/include/global.h
index 4d9c837fa..5de9f48d3 100644
--- a/include/global.h
+++ b/include/global.h
@@ -386,10 +386,13 @@ struct SaveBlock1 /* 0x02025734 */
/*0x2B0D*/ u8 outbreakPokemonProbability;
/*0x2B0E*/ u16 outbreakUnk5;
/*0x2B10*/ u8 filler_2B0E[0xC];
- /*0x2B1C*/ u16 unk2B1C[4];
- /*0x2B24*/ u8 filler_2B24[0x28];
+ /*0x2B1C*/ u16 unk2B1C[6];
+ /*0x2B28*/ u16 unk2B28[6];
+ /*0x2B34*/ u16 unk2B34[6];
+ /*0x2B40*/ u16 unk2B40[6];
/*0x2B4C*/ struct MailStruct mail[16];
- /*0x2D8C*/ u8 filler_2D8C[0x8];
+ /*0x2D8C*/ u8 unk2D8C[4];
+ /*0x2D90*/ u8 filler_2D90[0x4];
/*0x2D94*/ OldMan oldMan;
/*0x2DC0*/ u8 unk_2DC0[0x14];
/*0x2DD4*/ struct EasyChatPair easyChatPairs[5]; //Dewford trend [0] and some other stuff
diff --git a/ld_script.txt b/ld_script.txt
index cc083b1d3..6209a3584 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -190,6 +190,7 @@ SECTIONS {
asm/battle_anim_80CA710.o(.text);
src/bike.o(.text);
asm/easy_chat.o(.text);
+ src/easy_chat.o(.text);
asm/pokenav.o(.text);
asm/mon_markings.o(.text);
src/mauville_old_man.o(.text);
diff --git a/src/dewford_trend.c b/src/dewford_trend.c
index 55314b1c6..b90100d90 100644
--- a/src/dewford_trend.c
+++ b/src/dewford_trend.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "dewford_trend.h"
#include "asm.h"
+#include "easy_chat.h"
#include "event_data.h"
#include "link.h"
#include "rng.h"
@@ -24,12 +25,12 @@ void sub_80FA17C(void)
for (i = 0; i < 5; i++)
{
- gSaveBlock1.easyChatPairs[i].words[0] = sub_80EB72C(10);
+ gSaveBlock1.easyChatPairs[i].words[0] = sub_80EB72C(EC_GROUP_CONDITIONS);
if (Random() & 1)
- gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(12);
+ gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(EC_GROUP_LIFESTYLE);
else
- gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(13);
+ gSaveBlock1.easyChatPairs[i].words[1] = sub_80EB72C(EC_GROUP_HOBBIES);
gSaveBlock1.easyChatPairs[i].unk1_6 = Random() & 1;
sub_80FA740(&gSaveBlock1.easyChatPairs[i]);
diff --git a/src/easy_chat.c b/src/easy_chat.c
new file mode 100644
index 000000000..380fe6e4d
--- /dev/null
+++ b/src/easy_chat.c
@@ -0,0 +1,262 @@
+#include "global.h"
+#include "easy_chat.h"
+#include "asm.h"
+#include "event_data.h"
+#include "field_message_box.h"
+#include "pokedex.h"
+#include "rng.h"
+#include "text.h"
+
+u8 sub_80EB8C0(void);
+u8 sub_80EB868(u8);
+u16 sub_80EAE88(u8);
+void sub_80EB890(u8);
+u16 sub_80EB784(u16 group);
+u8 sub_80EAD7C(u8 group);
+u8 sub_80EB680(u16 *, u16, u16, u16);
+static u16 sub_80EB9D8(void);
+static u16 sub_80EB960(void);
+u16 sub_80EB72C(u16);
+
+extern void *gEasyChatGroupWords[];
+extern const u8 gEasyChatGroupSizes[];
+
+extern u16 gSpecialVar_0x8004;
+
+u16 sub_80EB72C(u16 group) {
+ u16 local1;
+
+ local1 = Random() % gEasyChatGroupSizes[group];
+
+ if (group == EC_GROUP_POKEMON ||
+ group == EC_GROUP_POKEMON_2 ||
+ group == EC_GROUP_MOVE_1 ||
+ group == EC_GROUP_MOVE_2)
+ {
+ local1 = ((u16 *) gEasyChatGroupWords[group])[local1];
+ }
+
+
+ return ((group & 0x7F) << 9) | (local1 & 0x1FF);
+}
+
+u16 sub_80EB784(u16 group) {
+ if (!sub_80EAD7C(group))
+ {
+ return -1;
+ }
+
+ if (group != EC_GROUP_POKEMON)
+ {
+ if (group == EC_GROUP_TRENDY_SAYING)
+ {
+ return sub_80EB960();
+ }
+ }
+ else
+ {
+ return sub_80EB9D8();
+ }
+
+ return sub_80EB72C(group);
+}
+
+void sub_80EB7C4(void) {
+ u16 *words;
+ u16 arg1, arg2;
+
+
+ switch (gSpecialVar_0x8004)
+ {
+ case 0:
+ words = gSaveBlock1.unk2B1C;
+ arg1 = 2;
+ arg2 = 2;
+ break;
+
+ case 1:
+ words = gSaveBlock1.unk2B28;
+ if (sub_80EB680(gSaveBlock1.unk2B28, 3, 2, 20))
+ {
+ arg1 = 2;
+ arg2 = 3;
+ }
+ else
+ {
+ arg1 = 3;
+ arg2 = 2;
+ }
+ break;
+
+ case 2:
+ words = gSaveBlock1.unk2B34;
+ arg1 = 3;
+ arg2 = 2;
+ break;
+
+ case 3:
+ words = gSaveBlock1.unk2B40;
+ arg1 = 3;
+ arg2 = 2;
+ break;
+
+ default:
+ return;
+ }
+
+ ConvertEasyChatWordsToString(gStringVar4, words, arg1, arg2);
+ ShowFieldAutoScrollMessage(gStringVar4);
+}
+
+void sub_80EB83C(void) {
+ u16 group, local2;
+
+ if (Random() & 1)
+ {
+ group = EC_GROUP_HOBBIES;
+ }
+ else
+ {
+ group = EC_GROUP_LIFESTYLE;
+ }
+
+ local2 = sub_80EB784(group);
+ sub_80EB3FC(gStringVar2, local2);
+}
+
+u8 sub_80EB868(u8 arg0) {
+ int offset;
+ int index;
+
+ index = arg0 / 8;
+ offset = arg0 & 7;
+ return (gSaveBlock1.unk2D8C[index] >> offset) & 1;
+}
+
+void sub_80EB890(u8 arg0) {
+ int offset;
+ int index;
+
+ if (arg0 > 32)
+ {
+ return;
+ }
+
+ index = arg0 / 8;
+ offset = arg0 & 7;
+ gSaveBlock1.unk2D8C[index] |= 1 << offset;
+}
+
+u8 sub_80EB8C0(void) {
+ u8 i, retval;
+
+ i = 0;
+ retval = 0;
+ for (; i < 33; i++)
+ {
+ if (sub_80EB868(i))
+ {
+ retval += 1;
+ }
+ }
+
+ return retval;
+}
+
+u16 sub_80EB8EC(void) {
+ u16 i;
+ u16 local1, local2;
+
+ local1 = sub_80EB8C0();
+ if (local1 == 33)
+ {
+ return -1;
+ }
+
+ local2 = Random() % (33 - local1);
+
+ for (i = 0; i <= 0x20; i++)
+ {
+ if (sub_80EB868(i) == 0)
+ {
+ if (local2 == 0)
+ {
+ sub_80EB890(i);
+ return (i & 0x1FF) | 0x2800;
+ }
+
+ local2--;
+ }
+ }
+
+ return -1;
+}
+
+static u16 sub_80EB960(void) {
+ u16 i;
+ u16 local1;
+
+ local1 = sub_80EB8C0();
+ if (local1 == 0)
+ {
+ return -1;
+ }
+
+ local1 = Random() % local1;
+
+ for (i = 0; i <= 0x20; i++)
+ {
+ if (sub_80EB868(i))
+ {
+ if (local1 == 0)
+ {
+ return (i & 0x1FF) | 0x2800;
+ }
+
+ local1--;
+ }
+ }
+
+ return -1;
+}
+
+u8 sub_80EB9C8(void) {
+ return IsNationalPokedexEnabled();
+}
+
+static u16 sub_80EB9D8(void) {
+ u16 *speciesList;
+ u16 local1;
+ u16 i;
+
+ local1 = sub_80EAE88(0);
+
+ if (local1 == 0)
+ {
+ return -1;
+ }
+
+ local1 = Random() % local1;
+ speciesList = (u16 *) gEasyChatGroupWords[EC_GROUP_POKEMON];
+
+ for (i = 0; i < gEasyChatGroupSizes[EC_GROUP_POKEMON]; i++)
+ {
+ const u16 dexNum = SpeciesToNationalPokedexNum(*speciesList);
+
+ const u8 local2 = sub_8090D90(dexNum, 0);
+
+ if (local2)
+ {
+ if (local1 == 0)
+ {
+ return *speciesList & 0x1FF;
+ }
+
+ local1--;
+ }
+
+ speciesList++;
+ }
+
+ return -1;
+}