Decompile more easy_chat.c

This commit is contained in:
Marcus Huderle 2019-02-25 14:03:13 -06:00
parent a589d4a630
commit 7ea05431a5
7 changed files with 420 additions and 916 deletions

View File

@ -5,918 +5,6 @@
.text .text
thumb_func_start sub_811E948
sub_811E948: @ 811E948
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x14
bl sub_811E8E4
mov r8, r0
cmp r0, 0x3
beq _0811E9FA
ldr r3, =0xffffff00
ldr r0, [sp, 0xC]
ands r0, r3
movs r1, 0x3
orrs r0, r1
ldr r2, =0xffff00ff
ands r0, r2
adds r1, 0xFD
orrs r0, r1
ldr r1, =0xff00ffff
ands r0, r1
movs r1, 0xB0
lsls r1, 12
orrs r0, r1
ldr r1, =0x00ffffff
ands r0, r1
movs r1, 0xE0
lsls r1, 21
orrs r0, r1
str r0, [sp, 0xC]
ldr r0, [sp, 0x10]
ands r0, r3
movs r1, 0x2
orrs r0, r1
ands r0, r2
movs r1, 0xB0
lsls r1, 4
orrs r0, r1
ldr r1, =0x0000ffff
ands r0, r1
movs r1, 0xD0
lsls r1, 14
orrs r0, r1
str r0, [sp, 0x10]
add r0, sp, 0xC
bl AddWindow
lsls r0, 16
lsrs r7, r0, 16
lsls r4, r7, 24
lsrs r0, r4, 24
movs r1, 0x11
bl FillWindowPixelBuffer
movs r6, 0
mov r0, r8
lsls r1, r0, 4
ldr r0, =gUnknown_08597E6C
adds r5, r1, r0
ldr r1, =gUnknown_08597E60
mov r10, r1
mov r9, r4
_0811E9C6:
ldr r2, [r5]
lsls r4, r7, 24
cmp r2, 0
beq _0811E9EC
mov r1, r8
lsls r0, r1, 2
adds r0, r6, r0
add r0, r10
ldrb r3, [r0]
movs r0, 0x1
str r0, [sp]
movs r0, 0
str r0, [sp, 0x4]
str r0, [sp, 0x8]
mov r1, r9
lsrs r0, r1, 24
movs r1, 0x1
bl sub_811D028
_0811E9EC:
adds r5, 0x4
adds r6, 0x1
cmp r6, 0x3
ble _0811E9C6
lsrs r0, r4, 24
bl PutWindowTilemap
_0811E9FA:
add sp, 0x14
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_811E948
thumb_func_start sub_811EA28
sub_811EA28: @ 811EA28
push {lr}
lsls r0, 24
lsrs r0, 24
adds r1, r0, 0
cmp r0, 0x14
beq _0811EA4E
cmp r0, 0x14
bgt _0811EA48
cmp r0, 0x11
blt _0811EA66
ldr r0, =0x00000864 @ = FLAG_SYS_GAME_CLEAR
bl FlagGet
b _0811EA60
.pool
_0811EA48:
cmp r1, 0x15
beq _0811EA5C
b _0811EA66
_0811EA4E:
ldr r0, =0x00000866
bl FlagGet
b _0811EA60
.pool
_0811EA5C:
bl sub_811F0F8
_0811EA60:
lsls r0, 24
lsrs r0, 24
b _0811EA68
_0811EA66:
movs r0, 0x1
_0811EA68:
pop {r1}
bx r1
thumb_func_end sub_811EA28
thumb_func_start EasyChat_GetNumWordsInGroup
EasyChat_GetNumWordsInGroup: @ 811EA6C
push {r4,lr}
lsls r0, 24
lsrs r0, 24
adds r4, r0, 0
cmp r0, 0
bne _0811EA84
movs r0, 0
bl GetNationalPokedexCount
lsls r0, 16
lsrs r0, 16
b _0811EA9A
_0811EA84:
bl sub_811EA28
lsls r0, 24
cmp r0, 0
bne _0811EA92
movs r0, 0
b _0811EA9A
_0811EA92:
ldr r0, =gEasyChatGroups
lsls r1, r4, 3
adds r1, r0
ldrh r0, [r1, 0x6]
_0811EA9A:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end EasyChat_GetNumWordsInGroup
thumb_func_start sub_811EAA4
sub_811EAA4: @ 811EAA4
push {r4,r5,lr}
lsls r2, r0, 16
lsrs r1, r2, 16
ldr r0, =0x0000ffff
cmp r1, r0
beq _0811EB04
lsrs r3, r2, 25
ldr r5, =0x000001ff
ands r5, r1
cmp r3, 0x15
bhi _0811EB08
ldr r0, =gEasyChatGroups
lsls r2, r3, 3
adds r1, r2, r0
ldrh r4, [r1, 0x4]
cmp r3, 0x13
bgt _0811EADC
cmp r3, 0x12
bge _0811EAE0
cmp r3, 0
beq _0811EAE0
b _0811EB00
.pool
_0811EADC:
cmp r3, 0x15
bne _0811EB00
_0811EAE0:
adds r0, r2, r0
ldr r2, [r0]
movs r1, 0
cmp r1, r4
bcs _0811EB08
_0811EAEA:
lsls r0, r1, 1
adds r0, r2
ldrh r0, [r0]
cmp r5, r0
beq _0811EB04
adds r0, r1, 0x1
lsls r0, 16
lsrs r1, r0, 16
cmp r1, r4
bcc _0811EAEA
b _0811EB08
_0811EB00:
cmp r5, r4
bcs _0811EB08
_0811EB04:
movs r0, 0
b _0811EB0A
_0811EB08:
movs r0, 0x1
_0811EB0A:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_811EAA4
thumb_func_start ECWord_CheckIfOutsideOfValidRange
ECWord_CheckIfOutsideOfValidRange: @ 811EB10
push {lr}
lsls r0, 16
lsrs r2, r0, 25
lsls r0, 7
lsrs r3, r0, 23
cmp r2, 0x15
bhi _0811EB5C
cmp r2, 0x13
bgt _0811EB2C
cmp r2, 0x12
bge _0811EB3C
cmp r2, 0
beq _0811EB30
b _0811EB48
_0811EB2C:
cmp r2, 0x15
bne _0811EB48
_0811EB30:
ldr r0, =gUnknown_085F5490
ldrh r0, [r0]
b _0811EB50
.pool
_0811EB3C:
ldr r0, =gUnknown_085FA1D4
ldrh r0, [r0]
b _0811EB50
.pool
_0811EB48:
ldr r1, =gEasyChatGroups
lsls r0, r2, 3
adds r0, r1
ldrh r0, [r0, 0x4]
_0811EB50:
cmp r0, r3
bls _0811EB5C
movs r0, 0
b _0811EB5E
.pool
_0811EB5C:
movs r0, 0x1
_0811EB5E:
pop {r1}
bx r1
thumb_func_end ECWord_CheckIfOutsideOfValidRange
thumb_func_start GetEasyChatWord
@ char *GetEasyChatWord(u8 groupId, u16 wordId)
GetEasyChatWord: @ 811EB64
push {lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 16
lsrs r2, r1, 16
cmp r0, 0x13
bgt _0811EB7C
cmp r0, 0x12
bge _0811EB90
cmp r0, 0
beq _0811EB80
b _0811EBA0
_0811EB7C:
cmp r0, 0x15
bne _0811EBA0
_0811EB80:
movs r0, 0xB
muls r0, r2
ldr r1, =gSpeciesNames
adds r0, r1
b _0811EBB2
.pool
_0811EB90:
movs r0, 0xD
muls r0, r2
ldr r1, =gMoveNames
adds r0, r1
b _0811EBB2
.pool
_0811EBA0:
ldr r1, =gEasyChatGroups
lsls r0, 3
adds r0, r1
ldr r1, [r0]
lsls r0, r2, 1
adds r0, r2
lsls r0, 2
adds r0, r1
ldr r0, [r0]
_0811EBB2:
pop {r1}
bx r1
.pool
thumb_func_end GetEasyChatWord
thumb_func_start CopyEasyChatWord
@ char *CopyEasyChatWord(char *dest, u16 groupIdWordIdPair)
CopyEasyChatWord: @ 811EBBC
push {r4-r6,lr}
adds r5, r0, 0
lsls r6, r1, 16
lsrs r0, r6, 16
adds r4, r0, 0
bl sub_811EAA4
lsls r0, 24
cmp r0, 0
beq _0811EBD8
ldr r1, =gText_ThreeQuestionMarks
b _0811EBEA
.pool
_0811EBD8:
ldr r0, =0x0000ffff
cmp r4, r0
beq _0811EBFC
ldr r1, =0x000001ff
ands r1, r4
lsrs r0, r6, 25
bl GetEasyChatWord
adds r1, r0, 0
_0811EBEA:
adds r0, r5, 0
bl StringCopy
b _0811EC02
.pool
_0811EBFC:
movs r0, 0xFF
strb r0, [r5]
adds r0, r5, 0
_0811EC02:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end CopyEasyChatWord
thumb_func_start ConvertEasyChatWordsToString
ConvertEasyChatWordsToString: @ 811EC08
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x4
adds r4, r0, 0
adds r5, r1, 0
lsls r2, 16
lsls r3, 16
lsrs r3, 16
mov r9, r3
ldr r0, =0xffff0000
adds r2, r0
lsrs r7, r2, 16
movs r0, 0
cmp r0, r9
bcs _0811EC78
_0811EC2A:
movs r6, 0
adds r0, 0x1
mov r8, r0
cmp r6, r7
bcs _0811EC5C
ldr r2, =0x0000ffff
_0811EC36:
ldrh r1, [r5]
adds r0, r4, 0
str r2, [sp]
bl CopyEasyChatWord
adds r4, r0, 0
ldrh r0, [r5]
ldr r2, [sp]
cmp r0, r2
beq _0811EC50
movs r0, 0
strb r0, [r4]
adds r4, 0x1
_0811EC50:
adds r5, 0x2
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
cmp r6, r7
bcc _0811EC36
_0811EC5C:
ldrh r1, [r5]
adds r5, 0x2
adds r0, r4, 0
bl CopyEasyChatWord
adds r4, r0, 0
movs r0, 0xFE
strb r0, [r4]
adds r4, 0x1
mov r1, r8
lsls r0, r1, 16
lsrs r0, 16
cmp r0, r9
bcc _0811EC2A
_0811EC78:
subs r4, 0x1
movs r0, 0xFF
strb r0, [r4]
adds r0, r4, 0
add sp, 0x4
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end ConvertEasyChatWordsToString
thumb_func_start sub_811EC98
sub_811EC98: @ 811EC98
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
adds r4, r0, 0
adds r5, r1, 0
lsls r2, 16
lsrs r2, 16
mov r8, r2
lsls r3, 16
lsrs r3, 16
str r3, [sp]
mov r7, r8
movs r0, 0
str r0, [sp, 0x4]
subs r0, r7, 0x1
lsls r0, 16
lsrs r0, 16
mov r8, r0
movs r0, 0
cmp r0, r3
bcs _0811ED62
_0811ECC8:
adds r3, r5, 0
movs r2, 0
movs r1, 0
adds r0, 0x1
mov r10, r0
cmp r2, r7
bcs _0811ECEE
ldr r6, =0x0000ffff
_0811ECD8:
lsls r0, r1, 1
adds r0, r3
ldrh r0, [r0]
cmp r0, r6
beq _0811ECE4
movs r2, 0x1
_0811ECE4:
adds r0, r1, 0x1
lsls r0, 16
lsrs r1, r0, 16
cmp r1, r7
bcc _0811ECD8
_0811ECEE:
cmp r2, 0
bne _0811ECFC
lsls r0, r7, 1
adds r5, r0
b _0811ED56
.pool
_0811ECFC:
movs r6, 0
ldr r1, [sp, 0x4]
adds r1, 0x1
mov r9, r1
cmp r6, r8
bcs _0811ED30
ldr r2, =0x0000ffff
_0811ED0A:
ldrh r1, [r5]
adds r0, r4, 0
str r2, [sp, 0x8]
bl CopyEasyChatWord
adds r4, r0, 0
ldrh r0, [r5]
ldr r2, [sp, 0x8]
cmp r0, r2
beq _0811ED24
movs r0, 0
strb r0, [r4]
adds r4, 0x1
_0811ED24:
adds r5, 0x2
adds r0, r6, 0x1
lsls r0, 16
lsrs r6, r0, 16
cmp r6, r8
bcc _0811ED0A
_0811ED30:
ldrh r1, [r5]
adds r5, 0x2
adds r0, r4, 0
bl CopyEasyChatWord
adds r4, r0, 0
ldr r0, [sp, 0x4]
cmp r0, 0
bne _0811ED4C
movs r0, 0xFE
b _0811ED4E
.pool
_0811ED4C:
movs r0, 0xFA
_0811ED4E:
strb r0, [r4]
adds r4, 0x1
mov r1, r9
str r1, [sp, 0x4]
_0811ED56:
mov r1, r10
lsls r0, r1, 16
lsrs r0, 16
ldr r1, [sp]
cmp r0, r1
bcc _0811ECC8
_0811ED62:
subs r4, 0x1
movs r0, 0xFF
strb r0, [r4]
adds r0, r4, 0
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_811EC98
thumb_func_start sub_811ED7C
sub_811ED7C: @ 811ED7C
push {r4,r5,lr}
lsls r5, r0, 16
lsrs r0, r5, 16
adds r4, r0, 0
ldr r0, =0x0000ffff
cmp r4, r0
bne _0811ED94
movs r0, 0
b _0811EDBA
.pool
_0811ED94:
adds r0, r4, 0
bl sub_811EAA4
lsls r0, 24
cmp r0, 0
bne _0811EDB0
ldr r1, =0x000001ff
ands r1, r4
lsrs r0, r5, 25
bl GetEasyChatWord
b _0811EDB2
.pool
_0811EDB0:
ldr r0, =gText_ThreeQuestionMarks
_0811EDB2:
bl StringLength
lsls r0, 16
lsrs r0, 16
_0811EDBA:
pop {r4,r5}
pop {r1}
bx r1
.pool
thumb_func_end sub_811ED7C
thumb_func_start sub_811EDC4
sub_811EDC4: @ 811EDC4
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
adds r6, r0, 0
lsls r1, 24
lsrs r1, 24
lsls r2, 24
lsrs r2, 24
mov r8, r2
lsls r3, 16
lsrs r3, 16
mov r10, r3
movs r7, 0
cmp r7, r8
bcs _0811EE26
subs r0, r1, 0x1
lsls r0, 16
mov r9, r0
_0811EDEE:
mov r0, r9
lsrs r4, r0, 16
movs r5, 0
cmp r5, r1
bcs _0811EE14
_0811EDF8:
ldrh r0, [r6]
adds r6, 0x2
str r1, [sp]
bl sub_811ED7C
adds r0, r4, r0
lsls r0, 16
lsrs r4, r0, 16
adds r0, r5, 0x1
lsls r0, 24
lsrs r5, r0, 24
ldr r1, [sp]
cmp r5, r1
bcc _0811EDF8
_0811EE14:
cmp r4, r10
bls _0811EE1C
movs r0, 0x1
b _0811EE28
_0811EE1C:
adds r0, r7, 0x1
lsls r0, 24
lsrs r7, r0, 24
cmp r7, r8
bcc _0811EDEE
_0811EE26:
movs r0, 0
_0811EE28:
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_811EDC4
thumb_func_start sub_811EE38
sub_811EE38: @ 811EE38
push {r4,lr}
lsls r0, 16
lsrs r4, r0, 16
bl Random
ldr r2, =gEasyChatGroups
lsls r1, r4, 3
adds r1, r2
lsls r0, 16
lsrs r0, 16
ldrh r1, [r1, 0x4]
bl __umodsi3
lsls r0, 16
lsrs r2, r0, 16
cmp r4, 0
beq _0811EE66
cmp r4, 0x15
beq _0811EE66
cmp r4, 0x12
beq _0811EE66
cmp r4, 0x13
bne _0811EE74
_0811EE66:
ldr r1, =gEasyChatGroups
lsls r0, r4, 3
adds r0, r1
ldr r1, [r0]
lsls r0, r2, 1
adds r0, r1
ldrh r2, [r0]
_0811EE74:
movs r0, 0x7F
ands r0, r4
lsls r0, 9
ldr r1, =0x000001ff
ands r2, r1
orrs r0, r2
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_811EE38
thumb_func_start sub_811EE90
sub_811EE90: @ 811EE90
push {r4,lr}
lsls r0, 16
lsrs r0, 16
adds r4, r0, 0
lsls r0, r4, 24
lsrs r0, 24
bl sub_811EA28
lsls r0, 24
cmp r0, 0
bne _0811EEB0
ldr r0, =0x0000ffff
b _0811EEC4
.pool
_0811EEB0:
cmp r4, 0
beq _0811EEBC
adds r0, r4, 0
bl sub_811EE38
b _0811EEC0
_0811EEBC:
bl sub_811F108
_0811EEC0:
lsls r0, 16
lsrs r0, 16
_0811EEC4:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_811EE90
thumb_func_start sub_811EECC
sub_811EECC: @ 811EECC
push {r4,r5,lr}
ldr r0, =gSpecialVar_0x8004
ldrh r0, [r0]
cmp r0, 0x1
beq _0811EF04
cmp r0, 0x1
bgt _0811EEE4
cmp r0, 0
beq _0811EEEE
b _0811EF58
.pool
_0811EEE4:
cmp r0, 0x2
beq _0811EF2C
cmp r0, 0x3
beq _0811EF3C
b _0811EF58
_0811EEEE:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00002bb0
adds r5, r0, r1
movs r2, 0x2
b _0811EF46
.pool
_0811EF04:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00002bbc
adds r5, r0, r1
adds r0, r5, 0
movs r1, 0x3
movs r2, 0x2
movs r3, 0x12
bl sub_811EDC4
lsls r0, 24
cmp r0, 0
beq _0811EF44
movs r2, 0x2
movs r3, 0x3
b _0811EF48
.pool
_0811EF2C:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00002bc8
b _0811EF42
.pool
_0811EF3C:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, =0x00002bd4
_0811EF42:
adds r5, r0, r1
_0811EF44:
movs r2, 0x3
_0811EF46:
movs r3, 0x2
_0811EF48:
ldr r4, =gStringVar4
adds r0, r4, 0
adds r1, r5, 0
bl ConvertEasyChatWordsToString
adds r0, r4, 0
bl ShowFieldAutoScrollMessage
_0811EF58:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_811EECC
thumb_func_start sub_811EF6C
sub_811EF6C: @ 811EF6C
push {lr}
bl Random
movs r1, 0x1
ands r1, r0
movs r0, 0xC
cmp r1, 0
beq _0811EF7E
movs r0, 0xD
_0811EF7E:
bl sub_811EE90
adds r1, r0, 0
lsls r1, 16
lsrs r1, 16
ldr r0, =gStringVar2
bl CopyEasyChatWord
pop {r0}
bx r0
.pool
thumb_func_end sub_811EF6C
thumb_func_start sub_811EF98
sub_811EF98: @ 811EF98
lsls r0, 24
lsrs r2, r0, 27
movs r1, 0xE0
lsls r1, 19
ands r1, r0
lsrs r1, 24
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r3, =0x00002e20
adds r0, r3
adds r0, r2
ldrb r0, [r0]
asrs r0, r1
movs r1, 0x1
ands r0, r1
bx lr
.pool
thumb_func_end sub_811EF98
thumb_func_start sub_811EFC0
sub_811EFC0: @ 811EFC0
push {lr}
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0x20
bhi _0811EFE4
lsrs r3, r0, 27
movs r2, 0x7
ands r2, r1
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
ldr r0, =0x00002e20
adds r1, r0
adds r1, r3
movs r0, 0x1
lsls r0, r2
ldrb r2, [r1]
orrs r0, r2
strb r0, [r1]
_0811EFE4:
pop {r0}
bx r0
.pool
thumb_func_end sub_811EFC0
thumb_func_start sub_811EFF0
sub_811EFF0: @ 811EFF0
push {r4,r5,lr}
movs r4, 0
movs r5, 0
_0811EFF6:
adds r0, r4, 0
bl sub_811EF98
lsls r0, 24
cmp r0, 0
beq _0811F008
adds r0, r5, 0x1
lsls r0, 24
lsrs r5, r0, 24
_0811F008:
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x20
bls _0811EFF6
adds r0, r5, 0
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_811EFF0
thumb_func_start sub_811F01C thumb_func_start sub_811F01C
sub_811F01C: @ 811F01C sub_811F01C: @ 811F01C
push {r4-r6,lr} push {r4-r6,lr}

View File

@ -39,6 +39,7 @@ struct BardSong
// Exported ROM declarations // Exported ROM declarations
extern const u16 gUnknown_085F5490; extern const u16 gUnknown_085F5490;
extern const u16 gUnknown_085FA1D4;
const struct BardSound *GetWordSounds(u16 word); const struct BardSound *GetWordSounds(u16 word);
void GetWordPhonemes(struct BardSong *song, u16 word); void GetWordPhonemes(struct BardSong *song, u16 word);

View File

@ -23,6 +23,7 @@
#define EC_GROUP_MOVE_2 0x13 #define EC_GROUP_MOVE_2 0x13
#define EC_GROUP_TRENDY_SAYING 0x14 #define EC_GROUP_TRENDY_SAYING 0x14
#define EC_GROUP_POKEMON_2 0x15 #define EC_GROUP_POKEMON_2 0x15
#define EC_NUM_GROUPS 0x16
// TRAINER // TRAINER
#define EC_WORD_I_CHOOSE_YOU (EC_GROUP_TRAINER << 9) | 0x0 #define EC_WORD_I_CHOOSE_YOU (EC_GROUP_TRAINER << 9) | 0x0
@ -1075,5 +1076,6 @@
#define EC_GROUP(word) ((word) >> 9) #define EC_GROUP(word) ((word) >> 9)
#define EC_INDEX(word) ((word) & 0x1FF) #define EC_INDEX(word) ((word) & 0x1FF)
#define EC_WORD(group, index) ((((group) & 0x7F) << 9) | ((index) & 0x1FF))
#endif // GUARD_CONSTANTS_EASY_CHAT_H #endif // GUARD_CONSTANTS_EASY_CHAT_H

View File

@ -8,11 +8,11 @@ void easy_chat_input_maybe(void);
u8 * CopyEasyChatWord(u8 *dest, u16 word); u8 * CopyEasyChatWord(u8 *dest, u16 word);
bool32 sub_811F8D8(u16 word); bool32 sub_811F8D8(u16 word);
void InitializeEasyChatWordArray(u16 *words, u16 length); void InitializeEasyChatWordArray(u16 *words, u16 length);
void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 length2); u8 *ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows);
bool8 ECWord_CheckIfOutsideOfValidRange(u16 word); bool8 ECWord_CheckIfOutsideOfValidRange(u16 word);
u16 sub_811EE38(u16 group); u16 sub_811EE38(u16 group);
u16 sub_811F01C(void); u16 sub_811F01C(void);
bool16 EasyChat_GetNumWordsInGroup(u8); u16 EasyChat_GetNumWordsInGroup(u8);
u16 sub_811EE90(u16); u16 sub_811EE90(u16);
void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam); void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam);

View File

@ -2430,5 +2430,6 @@ extern const u8 gText_CombineTwoWordsOrPhrases3[];
extern const u8 gText_OnlyOnePhrase[]; extern const u8 gText_OnlyOnePhrase[];
extern const u8 gText_YouCannotQuitHere[]; extern const u8 gText_YouCannotQuitHere[];
extern const u8 gText_SectionMustBeCompleted[]; extern const u8 gText_SectionMustBeCompleted[];
extern const u8 gText_ThreeQuestionMarks[];
#endif // GUARD_STRINGS_H #endif // GUARD_STRINGS_H

View File

@ -2,13 +2,16 @@
// Includes // Includes
#include "global.h" #include "global.h"
#include "alloc.h" #include "alloc.h"
#include "bard_music.h"
#include "bg.h" #include "bg.h"
#include "data2.h"
#include "decompress.h" #include "decompress.h"
#include "dewford_trend.h" #include "dewford_trend.h"
#include "dynamic_placeholder_text_util.h" #include "dynamic_placeholder_text_util.h"
#include "easy_chat.h" #include "easy_chat.h"
#include "event_data.h" #include "event_data.h"
#include "event_object_movement.h" #include "event_object_movement.h"
#include "field_message_box.h"
#include "field_weather.h" #include "field_weather.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "graphics.h" #include "graphics.h"
@ -18,12 +21,15 @@
#include "menu.h" #include "menu.h"
#include "overworld.h" #include "overworld.h"
#include "palette.h" #include "palette.h"
#include "pokedex.h"
#include "random.h"
#include "sound.h" #include "sound.h"
#include "string_util.h" #include "string_util.h"
#include "strings.h" #include "strings.h"
#include "task.h" #include "task.h"
#include "text_window.h" #include "text_window.h"
#include "window.h" #include "window.h"
#include "constants/easy_chat.h"
#include "constants/event_objects.h" #include "constants/event_objects.h"
#include "constants/flags.h" #include "constants/flags.h"
#include "constants/songs.h" #include "constants/songs.h"
@ -115,6 +121,26 @@ struct Unk08597C30
u8 unk3; u8 unk3;
}; };
struct EasyChatWordInfo
{
const u8 *text;
int alphabeticalOrder;
int enabled;
};
typedef union
{
const u16 *valueList;
const struct EasyChatWordInfo *words;
} EasyChatGroupWordData;
struct EasyChatGroup
{
EasyChatGroupWordData wordData;
u16 numWords;
u16 numEnabledWords;
};
EWRAM_DATA struct EasyChatScreen *gEasyChatScreen = NULL; EWRAM_DATA struct EasyChatScreen *gEasyChatScreen = NULL;
EWRAM_DATA struct Unk203A11C *gUnknown_0203A11C = 0; EWRAM_DATA struct Unk203A11C *gUnknown_0203A11C = 0;
EWRAM_DATA void *gUnknown_0203A120 = 0; EWRAM_DATA void *gUnknown_0203A120 = 0;
@ -203,7 +229,7 @@ static void sub_811CF04(void);
static void sub_811D60C(void); static void sub_811D60C(void);
static void sub_811D424(u16 *); static void sub_811D424(u16 *);
static void sub_811D230(void); static void sub_811D230(void);
void sub_811E948(void); static void sub_811E948(void);
static void sub_811CFCC(void); static void sub_811CFCC(void);
static void sub_811D0BC(void); static void sub_811D0BC(void);
static void sub_811D2C8(void); static void sub_811D2C8(void);
@ -293,6 +319,8 @@ static void sub_811E0EC(s8, s8);
static void sub_811E1A4(s8, s8); static void sub_811E1A4(s8, s8);
static void sub_811E2DC(struct Sprite *); static void sub_811E2DC(struct Sprite *);
static void sub_811E34C(u8, u8); static void sub_811E34C(u8, u8);
bool8 sub_811F0F8(void);
u16 sub_811F108(void);
u8 *CopyEasyChatWordPadded(u8 *, u16, u16); u8 *CopyEasyChatWordPadded(u8 *, u16, u16);
extern const struct { extern const struct {
@ -326,6 +354,8 @@ extern const struct SpriteTemplate gUnknown_08597E48;
extern const struct SpriteTemplate gUnknown_08597E30; extern const struct SpriteTemplate gUnknown_08597E30;
extern const u8 gUnknown_08597D08[]; extern const u8 gUnknown_08597D08[];
extern const u8 gUnknown_08597E60[][4]; extern const u8 gUnknown_08597E60[][4];
extern const u8 *const gUnknown_08597E6C[][4];
extern const struct EasyChatGroup gEasyChatGroups[];
void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam) void sub_811A20C(u8 kind, u16 *words, MainCallback callback, u8 sizeParam)
{ {
@ -4373,3 +4403,385 @@ static int sub_811E920(int arg0)
else else
return 0; return 0;
} }
static void sub_811E948(void)
{
int i;
u16 windowId;
struct WindowTemplate template;
int var0 = sub_811E8E4();
if (var0 == 3)
return;
template.bg = 3;
template.tilemapLeft = 1;
template.tilemapTop = 11;
template.width = 28;
template.height = 2;
template.paletteNum = 11;
template.baseBlock = 0x34;
windowId = AddWindow(&template);
FillWindowPixelBuffer(windowId, 0x11);
for (i = 0; i < 4; i++)
{
const u8 *str = gUnknown_08597E6C[var0][i];
if (str)
{
int x = gUnknown_08597E60[var0][i];
sub_811D028(windowId, 1, str, x, 1, 0, NULL);
}
}
PutWindowTilemap(windowId);
}
bool8 sub_811EA28(u8 groupId)
{
switch (groupId)
{
case EC_GROUP_TRENDY_SAYING:
return FlagGet(FLAG_SYS_HIPSTER_MEET);
case EC_GROUP_EVENTS:
case EC_GROUP_MOVE_1:
case EC_GROUP_MOVE_2:
return FlagGet(FLAG_SYS_GAME_CLEAR);
case EC_GROUP_POKEMON_2:
return sub_811F0F8();
default:
return TRUE;
}
}
u16 EasyChat_GetNumWordsInGroup(u8 groupId)
{
if (groupId == EC_GROUP_POKEMON)
return GetNationalPokedexCount(FLAG_GET_SEEN);
if (sub_811EA28(groupId))
return gEasyChatGroups[groupId].numEnabledWords;
return 0;
}
bool8 sub_811EAA4(u16 easyChatWord)
{
u16 i;
u8 groupId;
u32 index;
u16 numWords;
const u16 *list;
if (easyChatWord == 0xFFFF)
return FALSE;
groupId = EC_GROUP(easyChatWord);
index = EC_INDEX(easyChatWord);
if (groupId >= EC_NUM_GROUPS)
return TRUE;
numWords = gEasyChatGroups[groupId].numWords;
switch (groupId)
{
case EC_GROUP_POKEMON:
case EC_GROUP_POKEMON_2:
case EC_GROUP_MOVE_1:
case EC_GROUP_MOVE_2:
list = gEasyChatGroups[groupId].wordData.valueList;
for (i = 0; i < numWords; i++)
{
if (index == list[i])
return FALSE;
}
return TRUE;
default:
if (index >= numWords)
return TRUE;
else
return FALSE;
}
}
bool8 ECWord_CheckIfOutsideOfValidRange(u16 easyChatWord)
{
int numWordsInGroup;
u8 groupId = EC_GROUP(easyChatWord);
u32 index = EC_INDEX(easyChatWord);
if (groupId >= EC_NUM_GROUPS)
return TRUE;
switch (groupId)
{
case EC_GROUP_POKEMON:
case EC_GROUP_POKEMON_2:
numWordsInGroup = gUnknown_085F5490;
break;
case EC_GROUP_MOVE_1:
case EC_GROUP_MOVE_2:
numWordsInGroup = gUnknown_085FA1D4;
break;
default:
numWordsInGroup = gEasyChatGroups[groupId].numWords;
break;
}
if (numWordsInGroup <= index)
return TRUE;
else
return FALSE;
}
const u8 *GetEasyChatWord(u8 groupId, u16 index)
{
switch (groupId)
{
case EC_GROUP_POKEMON:
case EC_GROUP_POKEMON_2:
return gSpeciesNames[index];
case EC_GROUP_MOVE_1:
case EC_GROUP_MOVE_2:
return gMoveNames[index];
default:
return gEasyChatGroups[groupId].wordData.words[index].text;
}
}
u8 *CopyEasyChatWord(u8 *dest, u16 easyChatWord)
{
u8 *resultStr;
if (sub_811EAA4(easyChatWord))
{
resultStr = StringCopy(dest, gText_ThreeQuestionMarks);
}
else if (easyChatWord != 0xFFFF)
{
u16 index = EC_INDEX(easyChatWord);
u8 groupId = EC_GROUP(easyChatWord);
resultStr = StringCopy(dest, GetEasyChatWord(groupId, index));
}
else
{
*dest = EOS;
resultStr = dest;
}
return resultStr;
}
u8 *ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 columns, u16 rows)
{
u16 i, j;
u16 numColumns = columns - 1;
for (i = 0; i < rows; i++)
{
for (j = 0; j < numColumns; j++)
{
dest = CopyEasyChatWord(dest, *src);
if (*src != 0xFFFF)
{
*dest = CHAR_SPACE;
dest++;
}
src++;
}
dest = CopyEasyChatWord(dest, *(src++));
*dest = CHAR_NEWLINE;
dest++;
}
dest--;
*dest = EOS;
return dest;
}
u8 *unref_sub_811EC98(u8 *dest, const u16 *src, u16 columns, u16 rows)
{
u16 i, j, k;
u16 numColumns;
int var0, var1;
numColumns = columns;
var1 = 0;
columns--;
for (i = 0; i < rows; i++)
{
const u16 *var2 = src;
var0 = 0;
for (j = 0; j < numColumns; j++)
{
if (var2[j] != 0xFFFF)
var0 = 1;
}
if (!var0)
{
src += numColumns;
continue;
}
for (k = 0; k < columns; k++)
{
dest = CopyEasyChatWord(dest, *src);
if (*src != 0xFFFF)
{
*dest = CHAR_SPACE;
dest++;
}
src++;
}
dest = CopyEasyChatWord(dest, *(src++));
if (var1 == 0)
*dest = CHAR_NEWLINE;
else
*dest = CHAR_PROMPT_SCROLL;
dest++;
var1++;
}
dest--;
*dest = EOS;
return dest;
}
static u16 GetEasyChatWordStringLength(u16 easyChatWord)
{
if (easyChatWord == 0xFFFF)
return 0;
if (sub_811EAA4(easyChatWord))
{
return StringLength(gText_ThreeQuestionMarks);
}
else
{
u16 index = EC_INDEX(easyChatWord);
u8 groupId = EC_GROUP(easyChatWord);
return StringLength(GetEasyChatWord(groupId, index));
}
}
bool8 sub_811EDC4(const u16 *easyChatWords, u8 arg1, u8 arg2, u16 arg3)
{
u8 i, j;
for (i = 0; i < arg2; i++)
{
u16 totalLength = arg1 - 1;
for (j = 0; j < arg1; j++)
totalLength += GetEasyChatWordStringLength(*(easyChatWords++));
if (totalLength > arg3)
return TRUE;
}
return FALSE;
}
u16 sub_811EE38(u16 groupId)
{
u16 index = Random() % gEasyChatGroups[groupId].numWords;
if (groupId == EC_GROUP_POKEMON
|| groupId == EC_GROUP_POKEMON_2
|| groupId == EC_GROUP_MOVE_1
|| groupId == EC_GROUP_MOVE_2)
{
index = gEasyChatGroups[groupId].wordData.valueList[index];
}
return EC_WORD(groupId, index);
}
u16 sub_811EE90(u16 groupId)
{
if (!sub_811EA28(groupId))
return 0xFFFF;
if (groupId == EC_GROUP_POKEMON)
return sub_811F108();
return sub_811EE38(groupId);
}
void sub_811EECC(void)
{
u16 *easyChatWords;
int columns, rows;
switch (gSpecialVar_0x8004)
{
case 0:
easyChatWords = gSaveBlock1Ptr->unk2BB0;
columns = 2;
rows = 2;
break;
case 1:
easyChatWords = gSaveBlock1Ptr->unk2BBC;
if (sub_811EDC4(gSaveBlock1Ptr->unk2BBC, 3, 2, 18))
{
columns = 2;
rows = 3;
}
else
{
columns = 3;
rows = 2;
}
break;
case 2:
easyChatWords = gSaveBlock1Ptr->unk2BC8;
columns = 3;
rows = 2;
break;
case 3:
easyChatWords = gSaveBlock1Ptr->unk2BD4;
columns = 3;
rows = 2;
break;
default:
return;
}
ConvertEasyChatWordsToString(gStringVar4, easyChatWords, columns, rows);
ShowFieldAutoScrollMessage(gStringVar4);
}
void sub_811EF6C(void)
{
int groupId = Random() & 1 ? EC_GROUP_HOBBIES : EC_GROUP_LIFESTYLE;
u16 easyChatWord = sub_811EE90(groupId);
CopyEasyChatWord(gStringVar2, easyChatWord);
}
u8 sub_811EF98(u8 additionalPhraseId)
{
int byteOffset = additionalPhraseId / 8;
int shift = additionalPhraseId & 0x7;
return (gSaveBlock1Ptr->additionalPhrases[byteOffset] >> shift) & 1;
}
void sub_811EFC0(u8 additionalPhraseId)
{
if (additionalPhraseId < 33)
{
int byteOffset = additionalPhraseId / 8;
int shift = additionalPhraseId & 0x7;
gSaveBlock1Ptr->additionalPhrases[byteOffset] |= 1 << shift;
}
}
u8 sub_811EFF0(void)
{
u8 i;
u8 numAdditionalPhrasesUnlocked;
for (i = 0, numAdditionalPhrasesUnlocked = 0; i < 33; i++)
{
if (sub_811EF98(i))
numAdditionalPhrasesUnlocked++;
}
return numAdditionalPhrasesUnlocked;
}

View File

@ -102,7 +102,7 @@ struct MailRead
/*0x021d*/ u8 language; /*0x021d*/ u8 language;
/*0x021e*/ bool8 playerIsSender; /*0x021e*/ bool8 playerIsSender;
/*0x0220*/ u8 * (*parserSingle)(u8 *dest, u16 word); /*0x0220*/ u8 * (*parserSingle)(u8 *dest, u16 word);
/*0x0224*/ void (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2); /*0x0224*/ u8 * (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2);
/*0x0228*/ const struct MailLayout *layout; /*0x0228*/ const struct MailLayout *layout;
/*0x022c*/ u8 bg1TilemapBuffer[0x1000]; /*0x022c*/ u8 bg1TilemapBuffer[0x1000];
/*0x122c*/ u8 bg2TilemapBuffer[0x1000]; /*0x122c*/ u8 bg2TilemapBuffer[0x1000];