Decompiled sub_81C7170.

This commit is contained in:
Phlosioneer 2019-02-12 00:51:54 -05:00
parent 6466d0bea8
commit fb705e6047
2 changed files with 34 additions and 62 deletions

View File

@ -5,66 +5,6 @@
.text
thumb_func_start sub_81C7170
sub_81C7170: @ 81C7170
push {r4-r7,lr}
lsls r0, 24
lsrs r5, r0, 24
adds r0, r5, 0
movs r1, 0x1
bl GetWordTaskArg
adds r6, r0, 0
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r4, r0, r1
movs r7, 0
_081C718C:
movs r1, 0
ldrsh r0, [r4, r1]
bl _call_via_r6
cmp r0, 0x4
bhi _081C71D6
lsls r0, 2
ldr r1, =_081C71AC
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081C71AC:
.4byte _081C71C6
.4byte _081C71C0
.4byte _081C71DE
.4byte _081C71DA
.4byte _081C71CE
_081C71C0:
ldrh r0, [r4]
adds r0, 0x1
b _081C71D8
_081C71C6:
ldrh r0, [r4]
adds r0, 0x1
strh r0, [r4]
b _081C71DE
_081C71CE:
adds r0, r5, 0
bl DestroyTask
b _081C71DE
_081C71D6:
subs r0, 0x5
_081C71D8:
strh r0, [r4]
_081C71DA:
cmp r7, 0
beq _081C718C
_081C71DE:
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_81C7170
thumb_func_start sub_81C71E4
sub_81C71E4: @ 81C71E4
push {r4,r5,lr}

View File

@ -66,7 +66,7 @@ extern u8 gUnknown_0203CF3C;
extern void sub_81C7170(u8 a0);
extern void sub_81C71E4(u8 a0);
u32 sub_81C7078(s32 a0, u32 a1)
u32 sub_81C7078(u32 (*a0)(u32), u32 a1)
{
u16 taskId;
@ -75,7 +75,7 @@ u32 sub_81C7078(s32 a0, u32 a1)
else
taskId = CreateTask(sub_81C71E4, a1);
SetWordTaskArg(taskId, 1, a0);
SetWordTaskArg(taskId, 1, (u32)a0);
gTasks[taskId].data[3] = gUnknown_0203CF3C;
return ((gUnknown_0203CF3C++) << 16) | taskId;
@ -112,4 +112,36 @@ bool32 sub_81C7124(u32 a0)
}
}
return FALSE;
}
void sub_81C7170(u8 taskId)
{
s16 *dataPtr;
u32 (*func)(u32);
bool32 exitLoop;
func = (u32 (*)(u32))GetWordTaskArg(taskId, 1);
dataPtr = gTasks[taskId].data;
exitLoop = FALSE;
while (!exitLoop) {
u32 v1 =((u32 (*)(u32))func)(dataPtr[0]);
switch (v1) {
case 1:
dataPtr[0] = dataPtr[0] + 1;
break;
case 0:
dataPtr[0]++;
return;
case 4:
DestroyTask(taskId);
return;
default:
dataPtr[0] = v1 - 5;
break;
case 3:
break;
case 2:
return;
}
}
}