Decompile union_room_chat through sub_8020118

This commit is contained in:
Marcus Huderle 2019-03-28 20:20:52 -05:00
parent 8b8cc7a475
commit 519426f4e6
5 changed files with 134 additions and 325 deletions

View File

@ -5,322 +5,6 @@
.text
thumb_func_start sub_801FF18
sub_801FF18: @ 801FF18
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x1C
adds r7, r0, 0
lsls r1, 16
lsrs r1, 16
mov r9, r1
ldr r1, =0xffffff00
ldr r3, [sp, 0x14]
ands r3, r1
ldr r2, =0xffff00ff
ands r3, r2
movs r0, 0x80
lsls r0, 4
orrs r3, r0
ldr r0, =0xff00ffff
ands r3, r0
movs r0, 0x80
lsls r0, 13
orrs r3, r0
ldr r5, =0x00ffffff
ands r3, r5
movs r0, 0xA8
lsls r0, 21
orrs r3, r0
str r3, [sp, 0x14]
ldr r0, [sp, 0x18]
ands r0, r1
movs r1, 0x4
orrs r0, r1
ands r0, r2
movs r1, 0xE0
lsls r1, 4
orrs r0, r1
ldr r1, =0x0000ffff
ands r0, r1
movs r1, 0xD4
lsls r1, 15
orrs r0, r1
str r0, [sp, 0x18]
ldr r1, =gUnknown_082F2D40
lsls r0, r7, 1
adds r0, r7
lsls r0, 2
adds r4, r0, r1
ldrb r0, [r4, 0xA]
cmp r0, 0
beq _0801FF98
lsls r0, r3, 16
movs r1, 0xF9
lsls r1, 24
adds r0, r1
lsrs r0, 16
ands r2, r3
orrs r2, r0
lsrs r1, r2, 24
adds r1, 0x7
lsls r1, 24
adds r0, r5, 0
ands r0, r2
orrs r0, r1
str r0, [sp, 0x14]
_0801FF98:
add r0, sp, 0x14
bl AddWindow
ldr r5, =gUnknown_02022C88
ldr r1, [r5]
strh r0, [r1, 0x1E]
ldrh r0, [r1, 0x1E]
mov r8, r0
cmp r0, 0xFF
beq _08020082
ldrb r0, [r4, 0x9]
cmp r0, 0
beq _0801FFE0
adds r0, r1, 0
adds r0, 0x22
ldr r1, [r4]
bl DynamicPlaceholderTextUtil_ExpandPlaceholders
ldr r0, [r5]
adds r6, r0, 0
adds r6, 0x22
b _0801FFE2
.pool
_0801FFE0:
ldr r6, [r4]
_0801FFE2:
mov r0, r9
lsls r1, r0, 8
movs r0, 0
movs r2, 0
bl ChangeBgY
mov r1, r8
lsls r0, r1, 24
lsrs r5, r0, 24
adds r0, r5, 0
movs r1, 0x11
bl FillWindowPixelBuffer
adds r0, r5, 0
bl PutWindowTilemap
ldr r1, =gUnknown_082F2D40
lsls r0, r7, 1
adds r0, r7
lsls r0, 2
adds r4, r0, r1
ldrb r0, [r4, 0x4]
cmp r0, 0x1
bne _08020050
adds r0, r5, 0
movs r1, 0xA
movs r2, 0x2
bl sub_80989E0
ldrb r3, [r4, 0x5]
adds r3, 0x8
lsls r3, 24
lsrs r3, 24
ldrb r0, [r4, 0x6]
adds r0, 0x8
lsls r0, 24
lsrs r0, 24
str r0, [sp]
movs r0, 0xFF
str r0, [sp, 0x4]
movs r0, 0
str r0, [sp, 0x8]
ldrb r0, [r4, 0x7]
str r0, [sp, 0xC]
ldrb r0, [r4, 0x8]
str r0, [sp, 0x10]
adds r0, r5, 0
movs r1, 0x1
adds r2, r6, 0
bl AddTextPrinterParameterized5
b _0802007A
.pool
_08020050:
adds r0, r5, 0
movs r1, 0xA
movs r2, 0x2
bl sub_8098858
ldrb r3, [r4, 0x5]
ldrb r0, [r4, 0x6]
str r0, [sp]
movs r0, 0xFF
str r0, [sp, 0x4]
movs r0, 0
str r0, [sp, 0x8]
ldrb r0, [r4, 0x7]
str r0, [sp, 0xC]
ldrb r0, [r4, 0x8]
str r0, [sp, 0x10]
adds r0, r5, 0
movs r1, 0x1
adds r2, r6, 0
bl AddTextPrinterParameterized5
_0802007A:
ldr r0, =gUnknown_02022C88
ldr r0, [r0]
mov r1, r8
strh r1, [r0, 0x1E]
_08020082:
add sp, 0x1C
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_801FF18
thumb_func_start sub_8020094
sub_8020094: @ 8020094
push {r4,lr}
ldr r4, =gUnknown_02022C88
ldr r0, [r4]
ldrh r0, [r0, 0x1E]
cmp r0, 0xFF
beq _080200B2
lsls r0, 24
lsrs r0, 24
movs r1, 0
bl ClearStdWindowAndFrameToTransparent
ldr r0, [r4]
ldrb r0, [r0, 0x1E]
bl ClearWindowTilemap
_080200B2:
movs r0, 0
movs r1, 0
movs r2, 0
bl ChangeBgY
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_8020094
thumb_func_start sub_80200C8
sub_80200C8: @ 80200C8
push {r4,lr}
ldr r4, =gUnknown_02022C88
ldr r0, [r4]
ldrh r0, [r0, 0x1E]
cmp r0, 0xFF
beq _080200E2
lsls r0, 24
lsrs r0, 24
bl RemoveWindow
ldr r1, [r4]
movs r0, 0xFF
strh r0, [r1, 0x1E]
_080200E2:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_80200C8
thumb_func_start sub_80200EC
sub_80200EC: @ 80200EC
push {lr}
sub sp, 0x8
adds r3, r0, 0
lsls r2, 24
lsrs r2, 24
lsls r3, 19
lsrs r3, 16
lsls r1, 19
lsrs r1, 16
str r1, [sp]
movs r0, 0xE
str r0, [sp, 0x4]
movs r0, 0x1
adds r1, r2, 0
adds r2, r3, 0
movs r3, 0x1
bl FillWindowPixelRect
add sp, 0x8
pop {r0}
bx r0
thumb_func_end sub_80200EC
thumb_func_start sub_8020118
sub_8020118: @ 8020118
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x34
mov r10, r1
ldr r1, [sp, 0x54]
lsls r0, 16
lsrs r5, r0, 16
mov r9, r5
lsls r2, 24
lsrs r4, r2, 24
mov r8, r4
lsls r3, 24
lsrs r7, r3, 24
lsls r1, 24
lsrs r6, r1, 24
cmp r4, 0
beq _08020154
bl sub_801F198
adds r1, r0, 0
subs r1, r5
lsls r1, 16
lsrs r1, 16
adds r0, r5, 0
adds r2, r4, 0
bl sub_80200EC
_08020154:
add r0, sp, 0xC
mov r1, r8
strb r1, [r0]
strb r7, [r0, 0x1]
strb r6, [r0, 0x2]
add r4, sp, 0x10
movs r0, 0xFC
strb r0, [r4]
movs r0, 0x14
strb r0, [r4, 0x1]
movs r0, 0x8
strb r0, [r4, 0x2]
mov r0, sp
adds r0, 0x13
mov r1, r10
bl StringCopy
mov r0, r9
lsls r2, r0, 27
lsrs r2, 24
add r1, sp, 0xC
str r1, [sp]
movs r0, 0x1
negs r0, r0
str r0, [sp, 0x4]
str r4, [sp, 0x8]
movs r0, 0x1
movs r1, 0x2
movs r3, 0x1
bl AddTextPrinterParameterized3
add sp, 0x34
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_8020118
thumb_func_start sub_80201A4
sub_80201A4: @ 80201A4
push {r4-r7,lr}

View File

@ -424,7 +424,7 @@ PLAY_SE = FC 10
CLEAR = FC 11
SKIP = FC 12
CLEAR_TO = FC 13
UNKNOWN_14 = FC 14
MIN_LETTER_SPACING = FC 14
JPN = FC 15
ENG = FC 16
PAUSE_MUSIC = FC 17

View File

@ -100,7 +100,7 @@
#define EXT_CTRL_CODE_CLEAR 0x11
//
#define EXT_CTRL_CODE_CLEAR_TO 0x13
//
#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14
#define EXT_CTRL_CODE_JPN 0x15
#define EXT_CTRL_CODE_ENG 0x16

View File

@ -1615,7 +1615,7 @@ u16 RenderText(struct TextPrinter *textPrinter)
}
}
return 2;
case 20:
case EXT_CTRL_CODE_MIN_LETTER_SPACING:
textPrinter->minLetterSpacing = *textPrinter->printerTemplate.currentChar++;
return 2;
case EXT_CTRL_CODE_JPN:

View File

@ -66,7 +66,8 @@ struct UnionRoomChat2
u16 unk1A;
u16 unk1C;
u16 unk1E;
u8 filler20[0x2148];
u8 filler20[0x2];
u8 unk22[0x2146];
};
struct Unk82F2C98
@ -75,6 +76,18 @@ struct Unk82F2C98
bool32 (* unk4)(u8 *);
};
struct Unk82F2D40
{
const u8 *unk0;
u8 unk4;
u8 unk5;
u8 unk6;
u8 unk7;
u8 unk8;
u8 unk9;
u8 unkA;
};
static void sub_801DDD0(struct UnionRoomChat *);
static void c2_081284E0(void);
static void sub_801DF20(void);
@ -143,14 +156,14 @@ void sub_80201A4(void);
bool32 sub_8020368(void);
void sub_802093C(void);
void sub_8020B80(void);
void sub_801FF18(int, u16);
static void sub_801FF18(int, u16);
static void sub_801FDDC(u8, u8, u8);
void sub_8020094(void);
static void sub_8020094(void);
static void sub_801FEBC(void);
void sub_80200C8(void);
static void sub_80200C8(void);
static void sub_801FEE4(void);
void sub_80200EC(u16, u16, u8);
void sub_8020118(u16, u8 *, u8, u8, u16);
static void sub_80200EC(u16, u16, u8);
static void sub_8020118(u16, u8 *, u8, u8, u8);
void sub_80209AC(int);
void sub_8020420(u16, u8 *, u8);
void sub_80209E0(void);
@ -164,6 +177,7 @@ extern const u8 gUnknown_082F2AA8[];
extern const struct BgTemplate gUnknown_082F2C60[4];
extern const struct WindowTemplate gUnknown_082F2C70[];
extern const struct Unk82F2C98 gUnknown_082F2C98[];
extern const struct Unk82F2D40 gUnknown_082F2D40[];
void sub_801DD98(void)
@ -2052,3 +2066,114 @@ static s8 sub_801FF08(void)
{
return Menu_ProcessInput();
}
static void sub_801FF18(int arg0, u16 arg1)
{
const u8 *str;
int windowId;
struct WindowTemplate template;
template.bg = 0;
template.tilemapLeft = 8;
template.tilemapTop = 16;
template.width = 21;
template.height = 4;
template.paletteNum = 14;
template.baseBlock = 0x6A;
if (gUnknown_082F2D40[arg0].unkA)
{
template.tilemapLeft -= 7;
template.width += 7;
}
gUnknown_02022C88->unk1E = AddWindow(&template);
windowId = gUnknown_02022C88->unk1E;
if (gUnknown_02022C88->unk1E == 0xFF)
return;
if (gUnknown_082F2D40[arg0].unk9)
{
DynamicPlaceholderTextUtil_ExpandPlaceholders(gUnknown_02022C88->unk22, gUnknown_082F2D40[arg0].unk0);
str = gUnknown_02022C88->unk22;
}
else
{
str = gUnknown_082F2D40[arg0].unk0;
}
ChangeBgY(0, arg1 * 256, 0);
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
PutWindowTilemap(windowId);
if (gUnknown_082F2D40[arg0].unk4 == 1)
{
sub_80989E0(windowId, 0xA, 2);
AddTextPrinterParameterized5(
windowId,
1,
str,
gUnknown_082F2D40[arg0].unk5 + 8,
gUnknown_082F2D40[arg0].unk6 + 8,
TEXT_SPEED_FF,
NULL,
gUnknown_082F2D40[arg0].unk7,
gUnknown_082F2D40[arg0].unk8);
}
else
{
sub_8098858(windowId, 0xA, 2);
AddTextPrinterParameterized5(
windowId,
1,
str,
gUnknown_082F2D40[arg0].unk5,
gUnknown_082F2D40[arg0].unk6,
TEXT_SPEED_FF,
NULL,
gUnknown_082F2D40[arg0].unk7,
gUnknown_082F2D40[arg0].unk8);
}
gUnknown_02022C88->unk1E = windowId;
}
static void sub_8020094(void)
{
if (gUnknown_02022C88->unk1E != 0xFF)
{
ClearStdWindowAndFrameToTransparent(gUnknown_02022C88->unk1E, FALSE);
ClearWindowTilemap(gUnknown_02022C88->unk1E);
}
ChangeBgY(0, 0, 0);
}
static void sub_80200C8(void)
{
if (gUnknown_02022C88->unk1E != 0xFF)
{
RemoveWindow(gUnknown_02022C88->unk1E);
gUnknown_02022C88->unk1E = 0xFF;
}
}
static void sub_80200EC(u16 x, u16 width, u8 fillValue)
{
FillWindowPixelRect(1, fillValue, x * 8, 1, width * 8, 14);
}
static void sub_8020118(u16 x, u8 *str, u8 fillValue, u8 arg3, u8 arg4)
{
u8 *str2;
u8 sp[38];
if (fillValue)
sub_80200EC(x, sub_801F198() - x, fillValue);
sp[0] = fillValue;
sp[1] = arg3;
sp[2] = arg4;
str2 = &sp[4];
str2[0] = EXT_CTRL_CODE_BEGIN;
str2[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
str2[2] = 8;
StringCopy(&str2[3], str);
AddTextPrinterParameterized3(1, 2, x * 8, 1, sp, TEXT_SPEED_FF, str2);
}