Some more rom 8011dc0 work

This commit is contained in:
DizzyEggg 2018-12-02 13:59:55 +01:00
parent e17140536a
commit d137ebc7a9
4 changed files with 274 additions and 522 deletions

View File

@ -5,500 +5,9 @@
.text
thumb_func_start sub_801689C
sub_801689C: @ 801689C
push {r4,r5,lr}
adds r2, r0, 0
ldr r3, =gRecvCmds
ldrh r5, [r3, 0x12]
adds r4, r5, 0
cmp r4, 0
beq _080168D0
ldrh r0, [r3, 0x10]
movs r1, 0xFF
lsls r1, 8
ands r1, r0
movs r0, 0xBC
lsls r0, 6
cmp r1, r0
bne _080168D0
adds r0, r2, 0
adds r0, 0x9A
strh r5, [r0]
cmp r4, 0x44
bne _080168D0
ldrh r1, [r3, 0x14]
adds r0, 0x2
strh r1, [r0]
ldrh r1, [r3, 0x16]
adds r0, 0x2
strh r1, [r0]
_080168D0:
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_801689C
thumb_func_start sub_80168DC
sub_80168DC: @ 80168DC
push {r4,r5,lr}
adds r4, r0, 0
adds r5, r4, 0
adds r5, 0x9A
ldrh r0, [r5]
cmp r0, 0
beq _0801692C
ldr r0, =gStringVar4
ldr r1, =gLinkPlayers
adds r1, 0x2F
ldrb r1, [r1]
adds r2, r5, 0
adds r3, r4, 0
bl sub_8017EA0
cmp r0, 0
beq _0801692C
cmp r0, 0x1
bne _0801691C
movs r0, 0x23
strb r0, [r4, 0x14]
ldr r1, =gUnknown_02022C2C
ldrh r0, [r5]
strb r0, [r1]
movs r0, 0
b _0801692E
.pool
_0801691C:
cmp r0, 0x2
bne _0801692C
movs r0, 0x24
strb r0, [r4, 0x14]
bl sub_800AC34
movs r0, 0
b _0801692E
_0801692C:
movs r0, 0x1
_0801692E:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_80168DC
thumb_func_start sub_8016934
sub_8016934: @ 8016934
push {r4,r5,lr}
ldr r5, =gUnknown_02022C20
movs r0, 0xFF
strb r0, [r5]
ldr r0, =task00_081199FC
movs r1, 0
bl CreateTask
ldr r4, =gUnknown_02022C30
movs r0, 0x9B
lsls r0, 2
bl AllocZeroed
str r0, [r4]
ldr r1, =gUnknown_03000DA8
str r0, [r1]
movs r1, 0
strb r1, [r0, 0x14]
strb r1, [r0, 0x16]
strh r1, [r0, 0x10]
strh r1, [r0, 0x12]
movs r0, 0x1
negs r0, r0
strb r0, [r5]
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_8016934
thumb_func_start task00_081199FC
task00_081199FC: @ 801697C
push {r4-r6,lr}
sub sp, 0x20
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gUnknown_02022C30
ldr r5, [r0]
ldrb r0, [r5, 0x14]
cmp r0, 0x4
bls _08016990
b _08016AC8
_08016990:
lsls r0, 2
ldr r1, =_080169A4
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_080169A4:
.4byte _080169B8
.4byte _080169BE
.4byte _080169E0
.4byte _08016A30
.4byte _08016A94
_080169B8:
movs r0, 0x1
strb r0, [r5, 0x14]
b _08016AC8
_080169BE:
movs r0, 0xC
movs r1, 0
movs r2, 0
bl sub_8010F84
bl sub_800B488
bl OpenLink
bl sub_8011C84
movs r0, 0x1
bl sub_80111B0
movs r0, 0x2
strb r0, [r5, 0x14]
b _08016AC8
_080169E0:
movs r0, 0x70
bl AllocZeroed
str r0, [r5, 0x4]
movs r1, 0x4
bl sub_80175EC
movs r0, 0x70
bl AllocZeroed
str r0, [r5, 0xC]
movs r1, 0x4
bl sub_80175EC
movs r0, 0x80
lsls r0, 1
bl AllocZeroed
str r0, [r5]
movs r1, 0x8
bl sub_8017580
movs r0, 0x20
bl AllocZeroed
str r0, [r5, 0x8]
movs r1, 0x1
bl sub_8017580
ldr r0, [r5, 0xC]
ldr r1, [r5, 0x4]
movs r2, 0xA
bl sub_8016DF0
adds r1, r5, 0
adds r1, 0x20
strb r0, [r1]
movs r0, 0x3
strb r0, [r5, 0x14]
b _08016AC8
_08016A30:
bl sub_8016B00
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
blt _08016AC8
cmp r0, 0x2
bgt _08016AC8
ldr r0, =gUnknown_02022C20
ldrb r0, [r0]
cmp r0, 0xFF
bne _08016AC8
movs r6, 0
_08016A4A:
ldr r0, [r5]
lsls r4, r6, 5
adds r1, r0, r4
ldrb r0, [r1, 0x1A]
lsls r0, 30
lsrs r0, 30
cmp r0, 0x1
bne _08016A78
mov r0, sp
bl sub_8018404
ldr r0, [r5]
adds r0, r4
adds r0, 0x2
bl ReadAsU16
lsls r0, 16
lsrs r0, 16
mov r1, sp
bl sub_800E540
cmp r0, 0
bne _08016A84
_08016A78:
adds r6, 0x1
cmp r6, 0x7
ble _08016A4A
b _08016AC8
.pool
_08016A84:
ldr r0, =gUnknown_02022C20
mov r1, sp
bl StringCopy
b _08016AC8
.pool
_08016A94:
ldr r0, [r5, 0x8]
bl Free
ldr r0, [r5]
bl Free
ldr r0, [r5, 0xC]
bl Free
ldr r0, [r5, 0x4]
bl Free
adds r0, r5, 0
adds r0, 0x20
ldrb r0, [r0]
bl DestroyTask
ldr r0, =gUnknown_02022C30
ldr r0, [r0]
bl Free
bl sub_800EDD4
adds r0, r4, 0
bl DestroyTask
_08016AC8:
add sp, 0x20
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end task00_081199FC
thumb_func_start sp182_move_string
sp182_move_string: @ 8016AD4
push {r4,lr}
ldr r4, =gUnknown_02022C20
ldrb r0, [r4]
cmp r0, 0xFF
bne _08016AE8
movs r0, 0
b _08016AF6
.pool
_08016AE8:
ldr r0, =gStringVar1
adds r1, r4, 0
bl StringCopy
movs r0, 0xFF
strb r0, [r4]
movs r0, 0x1
_08016AF6:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sp182_move_string
thumb_func_start sub_8016B00
sub_8016B00: @ 8016B00
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
ldr r0, =gUnknown_02022C30
ldr r4, [r0]
movs r7, 0
movs r6, 0
movs r5, 0
_08016B12:
ldr r0, [r4, 0xC]
adds r0, r5
ldr r1, =gUnknown_082F045C
bl sub_8017630
lsls r0, 24
lsrs r3, r0, 24
cmp r3, 0x1
bne _08016B5C
ldr r1, [r4, 0xC]
ldr r0, [r4, 0x8]
adds r1, r5
ldm r1!, {r2,r5,r6}
stm r0!, {r2,r5,r6}
ldm r1!, {r2,r5,r6}
stm r0!, {r2,r5,r6}
ldr r1, [r4, 0x8]
movs r0, 0
strh r0, [r1, 0x18]
ldr r2, [r4, 0x8]
ldrb r1, [r2, 0x1A]
movs r5, 0x4
negs r5, r5
adds r0, r5, 0
ands r1, r0
movs r0, 0x1
orrs r1, r0
strb r1, [r2, 0x1A]
ldr r0, [r4, 0x8]
strb r3, [r0, 0x1B]
movs r0, 0x4
b _08016C90
.pool
_08016B5C:
adds r5, 0x1C
adds r6, 0x1
cmp r6, 0x3
ble _08016B12
movs r6, 0
mov r9, r6
_08016B68:
ldr r0, [r4]
mov r1, r9
lsls r5, r1, 5
adds r2, r0, r5
ldrb r0, [r2, 0x1A]
lsls r0, 30
mov r8, r5
cmp r0, 0
beq _08016C5C
ldr r1, [r4, 0x4]
adds r0, r2, 0
bl sub_80176E4
adds r6, r0, 0
cmp r6, 0xFF
beq _08016C02
ldr r0, [r4]
adds r2, r0, r5
ldrb r1, [r2, 0x1A]
lsls r0, r1, 30
lsrs r0, 30
cmp r0, 0x1
bne _08016BE0
lsls r0, r6, 3
subs r0, r6
lsls r6, r0, 2
ldr r1, [r4, 0x4]
adds r1, r6
adds r0, r2, 0
bl sub_8017678
cmp r0, 0
beq _08016BC6
ldr r1, [r4]
ldr r0, [r4, 0x4]
adds r1, r5
adds r0, r6
ldm r0!, {r2,r3,r6}
stm r1!, {r2,r3,r6}
ldm r0!, {r2,r3,r6}
stm r1!, {r2,r3,r6}
ldr r0, [r4]
adds r0, r5
movs r1, 0x40
strb r1, [r0, 0x1B]
movs r7, 0x1
b _08016BF8
_08016BC6:
ldr r0, [r4]
adds r1, r0, r5
ldrb r0, [r1, 0x1B]
cmp r0, 0
beq _08016BF8
subs r0, 0x1
strb r0, [r1, 0x1B]
ldr r0, [r4]
adds r0, r5
ldrb r0, [r0, 0x1B]
cmp r0, 0
bne _08016BF8
b _08016BF6
_08016BE0:
movs r3, 0x4
negs r3, r3
adds r0, r3, 0
ands r0, r1
movs r1, 0x1
orrs r0, r1
strb r0, [r2, 0x1A]
ldr r0, [r4]
adds r0, r5
movs r1, 0
strb r1, [r0, 0x1B]
_08016BF6:
movs r7, 0x2
_08016BF8:
ldr r0, [r4]
add r0, r8
movs r1, 0
strh r1, [r0, 0x18]
b _08016C5C
_08016C02:
ldr r0, [r4]
adds r1, r0, r5
ldrb r0, [r1, 0x1A]
lsls r2, r0, 30
lsrs r0, r2, 30
cmp r0, 0x2
beq _08016C3C
ldrh r0, [r1, 0x18]
adds r0, 0x1
strh r0, [r1, 0x18]
ldr r0, [r4]
adds r2, r0, r5
ldrh r1, [r2, 0x18]
ldr r0, =0x00000257
cmp r1, r0
bls _08016C5C
ldrb r0, [r2, 0x1A]
movs r5, 0x4
negs r5, r5
adds r1, r5, 0
ands r0, r1
movs r1, 0x2
orrs r0, r1
strb r0, [r2, 0x1A]
movs r7, 0x2
b _08016C5C
.pool
_08016C3C:
lsrs r0, r2, 30
cmp r0, 0x2
bne _08016C5C
ldrh r0, [r1, 0x18]
adds r0, 0x1
strh r0, [r1, 0x18]
ldr r0, [r4]
adds r2, r0, r5
ldrh r1, [r2, 0x18]
ldr r0, =0x00000383
cmp r1, r0
bls _08016C5C
adds r0, r2, 0
movs r1, 0x1
bl sub_8017580
_08016C5C:
mov r0, r9
adds r0, 0x1
lsls r0, 24
lsrs r0, 24
mov r9, r0
cmp r0, 0x7
bhi _08016C6C
b _08016B68
_08016C6C:
movs r5, 0
movs r6, 0x3
_08016C70:
ldr r0, [r4]
ldr r1, [r4, 0x4]
adds r1, r5
movs r2, 0x8
bl sub_8017734
lsls r0, 24
lsrs r0, 24
cmp r0, 0xFF
beq _08016C86
movs r7, 0x1
_08016C86:
adds r5, 0x1C
subs r6, 0x1
cmp r6, 0
bge _08016C70
adds r0, r7, 0
_08016C90:
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_8016B00
thumb_func_start sub_8016CA0
sub_8016CA0: @ 8016CA0

View File

@ -277,5 +277,6 @@ bool32 sub_800E540(u16 id, u8 *name);
void sub_8011DE0(u32 arg0);
u8 sub_801100C(int a0);
void sub_800EF7C(void);
bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx);
#endif //GUARD_LINK_RFU_H

View File

@ -4822,7 +4822,7 @@ void sub_8011C84(void)
gUnknown_03005000.unk_67 = CreateTask(sub_800EB44, 1);
}
u16 ReadU16(const void *ptr)
static u16 ReadU16(const void *ptr)
{
const u8 *ptr_ = ptr;
return (ptr_[1] << 8) | (ptr_[0]);

View File

@ -63,7 +63,7 @@ struct UnkStruct_x20
struct UnkStruct_Main0
{
struct UnkStruct_x20 arr[5];
struct UnkStruct_x20 arr[8];
};
struct UnkStruct_Main4
@ -153,9 +153,7 @@ struct UnkStruct_URoom
u16 field_4C[6];
u8 field_58[0x98 - 0x58];
u16 field_98;
u16 field_9A;
u16 field_9C;
u16 field_9E;
u16 field_9A[3];
struct UnkStruct_8019BA8 field_A0[8];
};
@ -182,17 +180,18 @@ struct TradeUnkStruct
};
extern struct TradeUnkStruct gUnknown_02022C40;
extern struct UnkLinkRfuStruct_02022B14Substruct gUnknown_02022C38;
extern union UnkUnion_Main gUnknown_02022C30;
extern u8 gUnknown_02022C2C;
extern u8 gUnknown_02022C2D;
extern u8 gUnknown_02022C3E;
extern u16 gUnknown_02022C3C;
extern struct UnkLinkRfuStruct_02022B14Substruct gUnknown_02022C38;
extern u8 gUnknown_02022C20[];
extern u8 gFieldLinkPlayerCount;
extern u8 gUnknown_03005DB4;
extern u8 gSelectedOrderFromParty[];
extern struct MailStruct gUnknown_020321C0[PARTY_SIZE];
extern u8 gUnknown_02032298[2];
// IWRAM vars
IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0;
@ -212,7 +211,7 @@ void sub_8014F48(u8 taskId);
void sub_80152F4(u8 taskId);
void sub_80156E0(u8 taskId);
void sub_80175EC(struct UnkStruct_Main4 *arg0, u8 count);
void sub_8017580(struct UnkStruct_Main0 *arg0, u8 count);
void sub_8017580(struct UnkStruct_x20 *arg0, u8 count);
u8 sub_8016FC0(struct UnkStruct_Main4 *arg0, u32 arg1);
u8 sub_8016FF0(struct UnkStruct_Main4 *arg0, u32 arg1);
bool8 PrintOnTextbox(u8 *textState, const u8 *str);
@ -282,7 +281,10 @@ void sub_8019E3C(void);
void sub_80173B0(void);
s32 sub_8017D04(u32 type, u32 species);
void sub_8017020(const u8 *src);
void sub_8019BA8();
void sub_8019BA8(void *);
s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3);
void sub_801697C(u8 taskId);
bool8 sub_8017630(struct UnkStruct_Shared* arg0, const struct UnkStruct_Shared* arg1);
// const rom data
extern const u8 *const gUnknown_082EDB60[][5];
@ -376,7 +378,9 @@ extern const u8 *const gUnknown_082EE82C[][4];
extern const u8 *const gUnknown_082EE24C[][2];
extern const struct UnkStruct_Shared gUnknown_082F045C[];
extern const struct UnkStruct_Shared gUnknown_082F045C;
extern const u8 *const gUnknown_082F04D8[22];
// code
void nullsub_89(void)
@ -484,7 +488,7 @@ void sub_8012780(u8 taskId)
data->field_0 = AllocZeroed(0xA0);
data->field_8 = AllocZeroed(0xA0);
sub_80175EC(data->field_4, 4);
sub_8017580(data->field_0, 5);
sub_8017580(data->field_0->arr, 5);
sub_800DF90(&data->field_0->arr[0].unk.field_0, data->field_0->arr[0].unk.playerName);
data->field_0->arr[0].field_18 = 0;
data->field_0->arr[0].field_1A_0 = 1;
@ -1008,7 +1012,7 @@ u8 sub_8013398(struct UnkStruct_Main0 *arg0)
ret = copiedCount;
for (; copiedCount < 5; copiedCount++)
{
data->field_0->arr[copiedCount].unk = gUnknown_082F045C[0];
data->field_0->arr[copiedCount].unk = gUnknown_082F045C;
data->field_0->arr[copiedCount].field_18 = 0;
data->field_0->arr[copiedCount].field_1A_0 = 0;
data->field_0->arr[copiedCount].field_1A_1 = 0;
@ -1068,7 +1072,7 @@ void sub_80134E8(u8 taskId)
break;
case 2:
sub_80175EC(data->field_4, 4);
sub_8017580(data->field_0, 16);
sub_8017580(data->field_0->arr, 16);
data->field_11 = sub_8016FC0(data->field_4, gSpecialVar_0x8004);
data->field_C = AddWindow(&gUnknown_082F00BC);
data->listWindowId = AddWindow(&gUnknown_082F0174);
@ -1370,7 +1374,7 @@ void sub_8013C7C(u8 taskId)
break;
case 2:
sub_80175EC(data->field_4, 4);
sub_8017580(data->field_0, 16);
sub_8017580(data->field_0->arr, 16);
data->field_11 = sub_8016FC0(data->field_4, 0xFF);
data->field_F = 0;
data->state = 3;
@ -1395,8 +1399,6 @@ void sub_8013C7C(u8 taskId)
}
}
extern const u8 *const gUnknown_082F04D8[22];
bool32 sub_8013D88(u32 arg0, u32 id)
{
if (id == 0xFF)
@ -1518,9 +1520,6 @@ u8 sub_8013F78(void)
return taskId;
}
extern struct MailStruct gUnknown_020321C0[PARTY_SIZE];
extern u8 gUnknown_02032298[2];
void sub_8013F90(u8 taskId)
{
u32 monId = sub_8018120(&gUnknown_02022C40, GetMultiplayerId());
@ -1784,8 +1783,6 @@ void sub_801440C(u8 taskId)
ScriptContext2_Disable();
}
extern u8 gSelectedOrderFromParty[];
void sub_8014790(u8 taskId)
{
s16 *data = gTasks[taskId].data;
@ -1934,7 +1931,7 @@ void sub_8014A40(u8 taskId)
data->field_0 = AllocZeroed(0xA0);
data->field_8 = AllocZeroed(0xA0);
sub_80175EC(data->field_4, 4);
sub_8017580(data->field_0, 5);
sub_8017580(data->field_0->arr, 5);
sub_800DF90(&data->field_0->arr[0].unk.field_0, data->field_0->arr[0].unk.playerName);
data->field_0->arr[0].field_18 = 0;
data->field_0->arr[0].field_1A_0 = 1;
@ -2143,7 +2140,7 @@ void sub_8014F48(u8 taskId)
break;
case 2:
sub_80175EC(data->field_4, 4);
sub_8017580(data->field_0, 16);
sub_8017580(data->field_0->arr, 16);
data->field_11 = sub_8016FC0(data->field_4, data->field_12 + 7);
winTemplate1 = gUnknown_082F0174;
@ -2312,7 +2309,7 @@ void sub_80152F4(u8 taskId)
break;
case 2:
sub_80175EC(data->field_4, 4);
sub_8017580(data->field_0, 16);
sub_8017580(data->field_0->arr, 16);
data->field_11 = sub_8016FF0(data->field_4, data->field_12 + 7);
if (data->field_13 != 0)
@ -2525,7 +2522,7 @@ void sub_80156E0(u8 taskId)
data->field_C = AllocZeroed(0x70);
data->field_0 = AllocZeroed(0x100);
data->field_8 = AllocZeroed(0x20);
sub_8017580(data->field_0, 8);
sub_8017580(data->field_0->arr, 8);
gUnknown_02022C2C = 0x40;
data->field_20 = sub_8016DF0(data->field_C, data->field_4, 9);
sub_8019BA8(data->field_A0);
@ -2543,7 +2540,7 @@ void sub_80156E0(u8 taskId)
sub_800B488();
OpenLink();
sub_8011C84();
sub_8017580(data->field_8, 1);
sub_8017580(&data->field_8->arr[0], 1);
sub_80175EC(data->field_4, 4);
sub_80175EC(data->field_C, 4);
gSpecialVar_Result = 0;
@ -2836,7 +2833,7 @@ void sub_80156E0(u8 taskId)
data->state = 41;
sub_800ADF8();
data->field_98 = 0;
data->field_9A = 0;
data->field_9A[0] = 0;
}
break;
case 41:
@ -2920,7 +2917,7 @@ void sub_80156E0(u8 taskId)
PlaySE(SE_PINPON);
sub_800EF7C();
data->state = 12;
data->field_9A = 0;
data->field_9A[0] = 0;
break;
case 12:
if (sub_8011A80())
@ -3020,7 +3017,7 @@ void sub_80156E0(u8 taskId)
gUnknown_02022C2C = 0x40;
sub_8015664(0x25, gStringVar4);
memset(data->field_4C, 0, sizeof(data->field_4C));
data->field_9A = 0;
data->field_9A[0] = 0;
data->field_98 = 0;
}
break;
@ -3262,3 +3259,248 @@ void var_800D_set_xB(void)
if (InUnionRoom() == TRUE)
gSpecialVar_Result = 11;
}
void sub_801689C(struct UnkStruct_URoom *arg0)
{
if (gRecvCmds[1][1] != 0 && (gRecvCmds[1][0] & 0xFF00) == 0x2F00)
{
arg0->field_9A[0] = gRecvCmds[1][1];
if (gRecvCmds[1][1] == 0x44)
{
arg0->field_9A[1] = gRecvCmds[1][2];
arg0->field_9A[2] = gRecvCmds[1][3];
}
}
}
bool32 sub_80168DC(struct UnkStruct_URoom *arg0)
{
if (arg0->field_9A[0] != 0)
{
s32 var = sub_8017EA0(gStringVar4, gLinkPlayers[1].gender, &arg0->field_9A[0], arg0);
if (var == 0)
{
return TRUE;
}
else if (var == 1)
{
arg0->state = 35;
gUnknown_02022C2C = arg0->field_9A[0];
return FALSE;
}
else if (var == 2)
{
arg0->state = 36;
sub_800AC34();
return FALSE;
}
}
return TRUE;
}
void sub_8016934(void)
{
struct UnkStruct_URoom *ptr;
gUnknown_02022C20[0] = EOS;
CreateTask(sub_801697C, 0);
gUnknown_02022C30.uRoom = gUnknown_02022C30.uRoom; // Needed to match.
gUnknown_02022C30.uRoom = ptr = AllocZeroed(0x26C);
gUnknown_03000DA8 = gUnknown_02022C30.uRoom;
ptr->state = 0;
ptr->textState = 0;
ptr->field_10 = 0;
ptr->field_12 = 0;
gUnknown_02022C20[0] = EOS;
}
void sub_801697C(u8 taskId)
{
s32 i;
u8 text[32];
struct UnkStruct_URoom *structPtr = gUnknown_02022C30.uRoom;
switch (structPtr->state)
{
case 0:
structPtr->state = 1;
break;
case 1:
sub_8010F84(0xC, 0, 0);
sub_800B488();
OpenLink();
sub_8011C84();
sub_80111B0(1);
structPtr->state = 2;
break;
case 2:
structPtr->field_4 = AllocZeroed(0x70);
sub_80175EC(structPtr->field_4, 4);
structPtr->field_C = AllocZeroed(0x70);
sub_80175EC(structPtr->field_C, 4);
structPtr->field_0 = AllocZeroed(0x100);
sub_8017580(structPtr->field_0->arr, 8);
structPtr->field_8 = AllocZeroed(0x20);
sub_8017580(&structPtr->field_8->arr[0], 1);
structPtr->field_20 = sub_8016DF0(structPtr->field_C, structPtr->field_4, 10);
structPtr->state = 3;
break;
case 3:
switch (sub_8016B00())
{
case 1:
case 2:
if (gUnknown_02022C20[0] == EOS)
{
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
{
if (structPtr->field_0->arr[i].field_1A_0 == 1)
{
sub_8018404(text, &structPtr->field_0->arr[i]);
if (sub_800E540(ReadAsU16(structPtr->field_0->arr[i].unk.field_0.unk_00.playerTrainerId), text))
{
StringCopy(gUnknown_02022C20, text);
break;
}
}
}
}
break;
case 3:
break;
}
break;
case 4:
free(structPtr->field_8);
free(structPtr->field_0);
free(structPtr->field_C);
free(structPtr->field_4);
DestroyTask(structPtr->field_20);
free(gUnknown_02022C30.uRoom);
sub_800EDD4();
DestroyTask(taskId);
break;
}
}
bool16 sp182_move_string(void)
{
if (gUnknown_02022C20[0] != EOS)
{
StringCopy(gStringVar1, gUnknown_02022C20);
gUnknown_02022C20[0] = EOS;
return TRUE;
}
else
{
return FALSE;
}
}
u8 sub_8016B00(void)
{
s32 i;
u8 j;
struct UnkStruct_URoom *structPtr = gUnknown_02022C30.uRoom;
s32 r7 = 0;
for (i = 0; i < 4; i++)
{
if (sub_8017630(&structPtr->field_C->arr[i].unk0, &gUnknown_082F045C) == TRUE)
{
structPtr->field_8->arr[0].unk = structPtr->field_C->arr[i].unk0;
structPtr->field_8->arr[0].field_18 = 0;
structPtr->field_8->arr[0].field_1A_0 = 1;
structPtr->field_8->arr[0].field_1B = 1;
return 4;
}
}
for (j = 0; j < 8; j++)
{
if (structPtr->field_0->arr[j].field_1A_0 != 0)
{
i = sub_80176E4(&structPtr->field_0->arr[j], &structPtr->field_4->arr[0]);
if (i != 0xFF)
{
if (structPtr->field_0->arr[j].field_1A_0 == 1)
{
if (sub_8017678(&structPtr->field_0->arr[j], &structPtr->field_4->arr[i]))
{
structPtr->field_0->arr[j].unk = structPtr->field_4->arr[i].unk0;
structPtr->field_0->arr[j].field_1B = 0x40;
r7 = 1;
}
else if (structPtr->field_0->arr[j].field_1B != 0)
{
structPtr->field_0->arr[j].field_1B--;
if (structPtr->field_0->arr[j].field_1B == 0)
r7 = 2;
}
}
else
{
structPtr->field_0->arr[j].field_1A_0 = 1;
structPtr->field_0->arr[j].field_1B = 0;
r7 = 2;
}
structPtr->field_0->arr[j].field_18 = 0;
}
else if (structPtr->field_0->arr[j].field_1A_0 != 2)
{
structPtr->field_0->arr[j].field_18++;
if (structPtr->field_0->arr[j].field_18 >= 600)
{
structPtr->field_0->arr[j].field_1A_0 = 2;
r7 = 2;
}
}
else if (structPtr->field_0->arr[j].field_1A_0 == 2)
{
structPtr->field_0->arr[j].field_18++;
if (structPtr->field_0->arr[j].field_18 >= 900)
{
sub_8017580(&structPtr->field_0->arr[j], 1);
}
}
}
}
for (i = 0; i < 4; i++)
{
if (sub_8017734(&structPtr->field_0->arr[0], &structPtr->field_4->arr[i].unk0, 8) != 0xFF)
r7 = 1;
}
return r7;
}
/*
void sub_8016CA0(u8 taskId)
{
s32 i, j;
struct UnkLinkRfuStruct_02022B14 sp0;
u8 text[10];
struct UnkStruct_Main4 *ptr = (void*) gTasks[taskId].data;
for (i = 0; i < 4; i++)
{
j = sub_800DE7C(&sp0, text, i);
if (!sub_8013D88(sp0.unk_0a_0, gTasks[taskId].data[4]))
sp0 = gUnknown_082F045C.field_0;
if (sp0.unk_00.unk_00_0 == 1)
sp0 = gUnknown_082F045C.field_0;
if (!j)
{
for (j = 0; j < i; j++)
{
if (sub_8017630())
}
}
else
{
}
}
}
*/