sub_800C36C

This commit is contained in:
PikalaxALT 2017-11-19 10:20:44 -05:00
parent d6d315d817
commit 03ce7b042a
4 changed files with 94 additions and 233 deletions

View File

@ -5,238 +5,6 @@
.text .text
thumb_func_start sub_800C36C
sub_800C36C: @ 800C36C
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x4
lsls r0, 16
lsrs r0, 16
movs r1, 0
mov r8, r1
mov r5, sp
adds r5, 0x1
mov r4, sp
adds r4, 0x2
mov r1, sp
adds r2, r5, 0
adds r3, r4, 0
bl rfu_REQBN_watchLink
mov r0, sp
ldrb r0, [r0]
adds r7, r4, 0
cmp r0, 0
beq _0800C43E
ldr r1, =gUnknown_03004140
mov r0, sp
ldrb r0, [r0]
strh r0, [r1, 0x14]
ldrb r0, [r5]
strh r0, [r1, 0x16]
ldrb r0, [r1, 0x9]
adds r6, r1, 0
cmp r0, 0
beq _0800C426
movs r0, 0x1
strb r0, [r6, 0xA]
ldrb r0, [r6, 0x6]
cmp r0, 0
bne _0800C3C2
ldrb r0, [r5]
cmp r0, 0
bne _0800C3C2
movs r0, 0x4
strb r0, [r6, 0xA]
_0800C3C2:
ldrb r0, [r6, 0xA]
cmp r0, 0x1
bne _0800C40C
movs r2, 0
mov r4, sp
movs r5, 0x1
mov r12, r6
mov r3, r12
adds r3, 0x30
movs r6, 0x34
add r6, r12
mov r9, r6
_0800C3DA:
ldrb r0, [r4]
asrs r0, r2
ands r0, r5
cmp r0, 0
beq _0800C3F8
adds r0, r5, 0
lsls r0, r2
ldrb r1, [r3]
orrs r0, r1
strb r0, [r3]
lsls r0, r2, 1
add r0, r9
mov r6, r12
ldrh r1, [r6, 0x32]
strh r1, [r0]
_0800C3F8:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x3
bls _0800C3DA
movs r0, 0x31
b _0800C41E
.pool
_0800C40C:
movs r0, 0
strb r0, [r6, 0xA]
mov r0, sp
ldrb r0, [r0]
bl sub_800D334
movs r0, 0x1
mov r8, r0
movs r0, 0x33
_0800C41E:
movs r1, 0x1
bl sub_800D30C
b _0800C43A
_0800C426:
mov r0, sp
ldrb r0, [r0]
bl sub_800D334
movs r1, 0x1
mov r8, r1
movs r0, 0x30
movs r1, 0x2
bl sub_800D30C
_0800C43A:
bl sub_800D610
_0800C43E:
ldr r0, =gUnknown_03007890
ldr r0, [r0]
ldrb r0, [r0]
cmp r0, 0x1
bne _0800C518
ldrb r0, [r7]
cmp r0, 0
beq _0800C49C
movs r2, 0
ldr r6, =gUnknown_03004140
movs r3, 0x1
adds r4, r6, 0
adds r4, 0x34
adds r6, 0x30
adds r5, r7, 0
_0800C45C:
ldrb r0, [r6]
asrs r0, r2
ands r0, r3
cmp r0, 0
beq _0800C478
ldrb r0, [r5]
asrs r0, r2
ands r0, r3
cmp r0, 0
beq _0800C478
lsls r0, r2, 1
adds r0, r4
movs r1, 0
strh r1, [r0]
_0800C478:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x3
bls _0800C45C
ldr r3, =gUnknown_03004140
adds r2, r3, 0
adds r2, 0x30
ldrb r1, [r7]
ldrb r0, [r2]
bics r0, r1
strb r0, [r2]
ldrb r0, [r7]
strh r0, [r3, 0x14]
movs r0, 0x32
movs r1, 0x1
bl sub_800D30C
_0800C49C:
ldr r0, =gUnknown_03004140
adds r3, r0, 0
adds r3, 0x30
ldrb r1, [r3]
adds r6, r0, 0
cmp r1, 0
beq _0800C514
movs r4, 0
movs r2, 0
movs r5, 0x1
_0800C4B0:
ldrb r0, [r3]
asrs r0, r2
ands r0, r5
cmp r0, 0
beq _0800C4E2
lsls r1, r2, 1
adds r0, r6, 0
adds r0, 0x34
adds r1, r0
ldrh r0, [r1]
cmp r0, 0
beq _0800C4E2
subs r0, 0x1
strh r0, [r1]
lsls r0, 16
cmp r0, 0
bne _0800C4E2
adds r0, r5, 0
lsls r0, r2
ldrb r1, [r3]
bics r1, r0
strb r1, [r3]
orrs r4, r0
lsls r0, r4, 24
lsrs r4, r0, 24
_0800C4E2:
adds r0, r2, 0x1
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0x3
bls _0800C4B0
cmp r4, 0
beq _0800C506
adds r0, r4, 0
bl sub_800D334
movs r6, 0x1
mov r8, r6
ldr r0, =gUnknown_03004140
strh r4, [r0, 0x14]
movs r0, 0x33
movs r1, 0x1
bl sub_800D30C
_0800C506:
ldr r0, =gUnknown_03004140
adds r1, r0, 0
adds r1, 0x30
ldrb r1, [r1]
adds r6, r0, 0
cmp r1, 0
bne _0800C518
_0800C514:
movs r0, 0
strb r0, [r6, 0xA]
_0800C518:
mov r0, r8
add sp, 0x4
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.pool
thumb_func_end sub_800C36C
thumb_func_start rfu_syncVBlank_ thumb_func_start rfu_syncVBlank_
rfu_syncVBlank_: @ 800C530 rfu_syncVBlank_: @ 800C530
push {lr} push {lr}

View File

@ -157,3 +157,4 @@ void rfu_REQ_sendData(u8);
void rfu_setMSCCallback(void (*func)(u16)); void rfu_setMSCCallback(void (*func)(u16));
void rfu_setREQCallback(void (*func)(u16, u16)); void rfu_setREQCallback(void (*func)(u16, u16));
bool8 rfu_getMasterSlave(void); bool8 rfu_getMasterSlave(void);
void rfu_REQBN_watchLink(u16 a0, u8 *a1, u8 *a2, u8 *a3);

View File

@ -52,7 +52,7 @@ struct UnkRfuStruct_1 {
/* 0x012 */ u8 unk_12; /* 0x012 */ u8 unk_12;
// aligned // aligned
/* 0x014 */ u16 unk_14; /* 0x014 */ u16 unk_14;
/* 0x016 */ u8 filler_16[2]; /* 0x016 */ u16 unk_16;
/* 0x018 */ u16 unk_18; /* 0x018 */ u16 unk_18;
/* 0x01a */ u16 unk_1a; /* 0x01a */ u16 unk_1a;
/* 0x01c */ u8 filler_1c[2]; /* 0x01c */ u8 filler_1c[2];

View File

@ -350,3 +350,95 @@ void sub_800C27C(bool8 a0)
} }
} }
} }
bool8 sub_800C36C(u16 a0)
{
bool8 retVal;
u8 i;
u8 sp0;
u8 sp1;
u8 sp2;
u8 flags;
retVal = FALSE;
rfu_REQBN_watchLink(a0, &sp0, &sp1, &sp2);
if (sp0)
{
gUnknown_03004140.unk_14 = sp0;
gUnknown_03004140.unk_16 = sp1;
if (gUnknown_03004140.unk_09)
{
gUnknown_03004140.unk_0a = 1;
if (gUnknown_03004140.unk_06 == 0 && sp1 == 0)
{
gUnknown_03004140.unk_0a = 4;
}
if (gUnknown_03004140.unk_0a == 1)
{
for (i = 0; i < 4; i++)
{
if ((sp0 >> i) & 1)
{
gUnknown_03004140.unk_30 |= (1 << i);
gUnknown_03004140.unk_34[i] = gUnknown_03004140.unk_32;
}
}
sub_800D30C(0x31, 0x01);
}
else
{
gUnknown_03004140.unk_0a = 0;
sub_800D334(sp0);
retVal = TRUE;
sub_800D30C(0x33, 0x01);
}
}
else
{
sub_800D334(sp0);
retVal = TRUE;
sub_800D30C(0x30, 0x02);
}
sub_800D610();
}
if (gUnknown_03007890->unk_00 == 1)
{
if (sp2)
{
for (i = 0; i < 4; i++)
{
if ((gUnknown_03004140.unk_30 >> i) & 1 && (sp2 >> i) & 1)
{
gUnknown_03004140.unk_34[i] = 0;
}
}
gUnknown_03004140.unk_30 &= ~sp2;
gUnknown_03004140.unk_14 = sp2;
sub_800D30C(0x32, 0x01);
}
if (gUnknown_03004140.unk_30)
{
flags = 0;
for (i = 0; i < 4; i++)
{
if ((gUnknown_03004140.unk_30 >> i) & 1 && gUnknown_03004140.unk_34[i] && --gUnknown_03004140.unk_34[i] == 0)
{
gUnknown_03004140.unk_30 &= ~(1 << i);
flags |= (1 << i);
}
}
if (flags)
{
sub_800D334(flags);
retVal = TRUE;
gUnknown_03004140.unk_14 = flags;
sub_800D30C(0x33, 0x01);
}
}
if (!gUnknown_03004140.unk_30)
{
gUnknown_03004140.unk_0a = 0;
}
}
return retVal;
}