through sub_8010EC0

This commit is contained in:
PikalaxALT 2018-01-20 18:43:58 -05:00
parent ef412145d0
commit 1566dca0c2
5 changed files with 184 additions and 513 deletions

View File

@ -5,513 +5,6 @@
.text .text
thumb_func_start sub_8010AAC
sub_8010AAC: @ 8010AAC
push {r4-r7,lr}
sub sp, 0x4
lsls r0, 24
lsrs r6, r0, 24
ldr r3, =gUnknown_03005000
ldr r2, =gUnknown_082ED68C
ldr r1, =0x00000ce9
adds r0, r3, r1
ldrb r1, [r0]
adds r1, r2
ldr r2, =0x00000cde
adds r0, r3, r2
ldrb r1, [r1]
adds r0, r1
ldrb r4, [r0]
adds r0, r3, 0
adds r0, 0xF1
ldrb r0, [r0]
subs r0, 0x1
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bhi _08010AE8
ldr r5, =0x00000ce8
adds r1, r3, r5
movs r0, 0
strb r0, [r1]
adds r0, r6, 0
bl DestroyTask
_08010AE8:
ldr r0, =gTasks
lsls r2, r6, 2
adds r1, r2, r6
lsls r1, 3
adds r1, r0
movs r3, 0x8
ldrsh r1, [r1, r3]
adds r3, r0, 0
adds r7, r2, 0
cmp r1, 0x5
bls _08010B00
b _08010CF0
_08010B00:
lsls r0, r1, 2
ldr r1, =_08010B28
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_08010B28:
.4byte _08010B40
.4byte _08010B60
.4byte _08010B78
.4byte _08010BC0
.4byte _08010C0A
.4byte _08010C94
_08010B40:
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
beq _08010B4A
b _08010CF0
_08010B4A:
adds r0, r4, 0
bl ResetBlockReceivedFlag
movs r0, 0xF0
lsls r0, 7
bl sub_800FD14
b _08010C4A
.pool
_08010B60:
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
beq _08010B6A
b _08010CF0
_08010B6A:
adds r1, r7, r6
lsls r1, 3
adds r1, r3
b _08010C52
.pool
_08010B78:
bl GetBlockReceivedStatus
lsls r0, 24
lsrs r0, 24
asrs r0, r4
movs r1, 0x1
ands r0, r1
cmp r0, 0
bne _08010B8C
b _08010CF0
_08010B8C:
adds r0, r4, 0
bl ResetBlockReceivedFlag
lsls r2, r4, 8
ldr r0, =gBlockRecvBuffer
adds r2, r0
ldr r1, =gLinkPlayers
lsls r0, r4, 3
subs r0, r4
lsls r0, 2
adds r0, r1
adds r1, r0, 0
adds r2, 0x10
ldm r2!, {r3-r5}
stm r1!, {r3-r5}
ldm r2!, {r3-r5}
stm r1!, {r3-r5}
ldr r2, [r2]
str r2, [r1]
bl sub_800B524
b _08010C4A
.pool
_08010BC0:
ldr r5, =gBlockSendBuffer
adds r1, r5, 0
ldr r0, =gUnknown_082ED7EC
ldm r0!, {r2-r4}
stm r1!, {r2-r4}
ldrh r2, [r0]
strh r2, [r1]
ldrb r0, [r0, 0x2]
strb r0, [r1, 0x2]
ldr r1, =gUnknown_03005000
ldrb r0, [r1, 0xD]
strb r0, [r5, 0xF]
movs r2, 0
adds r4, r5, 0
adds r4, 0x10
ldr r0, =0x00000cde
adds r3, r1, r0
_08010BE2:
adds r0, r4, r2
adds r1, r2, r3
ldrb r1, [r1]
strb r1, [r0]
adds r2, 0x1
cmp r2, 0x3
ble _08010BE2
ldr r1, =gLinkPlayers
adds r0, r5, 0
adds r0, 0x14
movs r2, 0x8C
bl memcpy
ldr r0, =gTasks
adds r1, r7, r6
lsls r1, 3
adds r1, r0
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
_08010C0A:
ldr r5, =gBlockSendBuffer
ldr r1, =gUnknown_03005000
ldrb r0, [r1, 0xD]
strb r0, [r5, 0xF]
movs r2, 0
ldr r3, =gLinkPlayers
mov r12, r3
adds r4, r5, 0
adds r4, 0x10
ldr r0, =0x00000cde
adds r3, r1, r0
_08010C20:
adds r0, r4, r2
adds r1, r2, r3
ldrb r1, [r1]
strb r1, [r0]
adds r2, 0x1
cmp r2, 0x3
ble _08010C20
adds r0, r5, 0
adds r0, 0x14
mov r1, r12
movs r2, 0x8C
bl memcpy
ldr r1, =gBlockSendBuffer
movs r0, 0
movs r2, 0xA0
bl SendBlock
lsls r0, 24
cmp r0, 0
beq _08010CF0
_08010C4A:
ldr r0, =gTasks
adds r1, r7, r6
lsls r1, 3
adds r1, r0
_08010C52:
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
b _08010CF0
.pool
_08010C74:
adds r0, r3, 0
lsls r0, r2
ldr r2, =0x00000ce5
adds r1, r5, r2
strb r0, [r1]
ldrb r1, [r4]
eors r0, r1
strb r0, [r4]
ldr r4, =0x00000ce8
adds r0, r5, r4
strb r3, [r0]
b _08010CEA
.pool
_08010C94:
bl sub_800A520
lsls r0, 24
cmp r0, 0
beq _08010CF0
bl GetBlockReceivedStatus
movs r1, 0x1
ands r1, r0
cmp r1, 0
beq _08010CF0
mov r0, sp
movs r4, 0
strh r4, [r0]
ldr r1, =gBlockRecvBuffer
ldr r2, =0x0100007e
bl CpuSet
movs r0, 0
bl ResetBlockReceivedFlag
ldr r1, =gUnknown_03005000
ldr r5, =0x00000ce8
adds r0, r1, r5
strb r4, [r0]
ldr r0, =0x00000ce6
adds r3, r1, r0
ldrb r0, [r3]
cmp r0, 0
beq _08010CEA
movs r2, 0
adds r5, r1, 0
adds r4, r3, 0
ldrb r1, [r4]
movs r3, 0x1
_08010CDA:
adds r0, r1, 0
asrs r0, r2
ands r0, r3
cmp r0, 0
bne _08010C74
adds r2, 0x1
cmp r2, 0x3
ble _08010CDA
_08010CEA:
adds r0, r6, 0
bl DestroyTask
_08010CF0:
add sp, 0x4
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8010AAC
thumb_func_start sub_8010D0C
sub_8010D0C: @ 8010D0C
push {r4-r6,lr}
lsls r0, 24
lsrs r5, r0, 24
ldr r6, =gUnknown_03005000
adds r0, r6, 0
adds r0, 0xF1
ldrb r0, [r0]
subs r0, 0x1
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bhi _08010D2A
adds r0, r5, 0
bl DestroyTask
_08010D2A:
ldr r1, =gTasks
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
adds r4, r0, r1
movs r1, 0x8
ldrsh r0, [r4, r1]
cmp r0, 0x1
beq _08010D70
cmp r0, 0x1
bgt _08010D50
cmp r0, 0
beq _08010D56
b _08010DA6
.pool
_08010D50:
cmp r0, 0x2
beq _08010D82
b _08010DA6
_08010D56:
ldrb r0, [r6, 0xD]
cmp r0, 0
beq _08010DA6
bl sub_800B348
ldr r1, =gBlockSendBuffer
movs r0, 0
movs r2, 0x3C
bl SendBlock
b _08010D7A
.pool
_08010D70:
bl sub_800A520
lsls r0, 24
cmp r0, 0
beq _08010DA6
_08010D7A:
ldrh r0, [r4, 0x8]
adds r0, 0x1
strh r0, [r4, 0x8]
b _08010DA6
_08010D82:
bl GetBlockReceivedStatus
movs r4, 0x1
adds r1, r4, 0
ands r1, r0
cmp r1, 0
beq _08010DA6
ldr r0, =gBlockRecvBuffer
bl sub_8010A14
movs r0, 0
bl ResetBlockReceivedFlag
ldr r0, =gReceivedRemoteLinkPlayers
strb r4, [r0]
adds r0, r5, 0
bl DestroyTask
_08010DA6:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_8010D0C
thumb_func_start sub_8010DB4
sub_8010DB4: @ 8010DB4
push {r4-r7,lr}
ldr r0, =gUnknown_03005000
adds r1, r0, 0
adds r1, 0xEE
ldrb r1, [r1]
adds r3, r0, 0
cmp r1, 0x1
bne _08010E5C
ldr r2, =gUnknown_03004140
ldrb r0, [r2, 0x2]
cmp r0, 0
bne _08010E5C
ldr r0, =gMain
ldr r1, [r0, 0x4]
ldr r0, =sub_8018438
cmp r1, r0
beq _08010DDE
ldr r0, [r2, 0x3C]
ldrb r0, [r0, 0x4]
cmp r0, 0
beq _08010DE4
_08010DDE:
ldr r1, =gWirelessCommType
movs r0, 0x2
strb r0, [r1]
_08010DE4:
ldr r4, =CB2_LinkError
adds r0, r4, 0
bl SetMainCallback2
ldr r0, =gMain
str r4, [r0, 0x8]
ldr r5, =gUnknown_03005000
ldrh r0, [r5, 0xA]
lsls r4, r0, 16
ldrh r0, [r5, 0x10]
lsls r0, 8
orrs r4, r0
ldrh r0, [r5, 0x12]
orrs r4, r0
ldr r1, =0x000009e6
adds r0, r5, r1
ldrb r0, [r0]
adds r7, r0, 0
ldr r1, =0x00000c1a
adds r0, r5, r1
ldrb r0, [r0]
adds r6, r0, 0
bl sub_8011A74
movs r3, 0
lsls r0, 24
lsrs r0, 24
cmp r0, 0x2
bne _08010E20
movs r3, 0x1
_08010E20:
adds r0, r4, 0
adds r1, r7, 0
adds r2, r6, 0
bl sub_800AF18
adds r0, r5, 0
adds r0, 0xEE
ldrb r1, [r0]
movs r1, 0x2
strb r1, [r0]
bl CloseLink
b _08010E8E
.pool
_08010E5C:
ldr r1, =0x00000c1b
adds r0, r3, r1
ldrb r0, [r0]
cmp r0, 0x1
beq _08010E70
ldr r1, =0x000009e7
adds r0, r3, r1
ldrb r0, [r0]
cmp r0, 0x1
bne _08010E8E
_08010E70:
ldr r0, =gUnknown_03004140
ldrb r0, [r0, 0x2]
cmp r0, 0
beq _08010E7C
bl sub_800D630
_08010E7C:
movs r4, 0xE0
lsls r4, 7
movs r0, 0x1
adds r1, r4, 0
bl sub_8011A64
adds r0, r4, 0
bl sub_8011170
_08010E8E:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8010DB4
thumb_func_start rfu_REQ_recvData_then_sendData
rfu_REQ_recvData_then_sendData: @ 8010EA0
push {lr}
ldr r0, =gUnknown_03004140
ldrb r0, [r0, 0x6]
cmp r0, 0x1
bne _08010EB8
bl rfu_REQ_recvData
bl rfu_waitREQComplete
movs r0, 0
bl rfu_REQ_sendData_wrapper
_08010EB8:
pop {r0}
bx r0
.pool
thumb_func_end rfu_REQ_recvData_then_sendData
thumb_func_start sub_8010EC0
sub_8010EC0: @ 8010EC0
push {r4,r5,lr}
movs r5, 0
ldr r4, =gUnknown_03005000
ldr r1, =0x00000ccd
adds r0, r4, r1
strb r5, [r0]
bl Random2
lsls r0, 16
lsrs r0, 16
bl sub_800C54C
adds r0, r4, 0
adds r0, 0xEF
ldrb r0, [r0]
cmp r0, 0
bne _08010F14
ldrb r0, [r4, 0xC]
cmp r0, 0x1
beq _08010F02
cmp r0, 0x1
bgt _08010EFC
cmp r0, 0
beq _08010F08
b _08010F14
.pool
_08010EFC:
cmp r0, 0x2
beq _08010F10
b _08010F14
_08010F02:
bl sub_800F0F8
b _08010F14
_08010F08:
bl sub_800F4F0
adds r5, r0, 0
b _08010F14
_08010F10:
bl rfu_REQ_recvData_then_sendData
_08010F14:
adds r0, r5, 0
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8010EC0
thumb_func_start sub_8010F1C thumb_func_start sub_8010F1C
sub_8010F1C: @ 8010F1C sub_8010F1C: @ 8010F1C
push {r4,lr} push {r4,lr}

View File

@ -194,7 +194,6 @@ extern u16 gSendCmd[CMD_LENGTH];
extern struct LinkPlayer gLinkPlayers[5]; extern struct LinkPlayer gLinkPlayers[5];
extern u16 word_3002910[]; extern u16 word_3002910[];
extern bool8 gReceivedRemoteLinkPlayers; extern bool8 gReceivedRemoteLinkPlayers;
extern bool8 gWirelessCommType;
extern u32 gUnknown_020223C0; extern u32 gUnknown_020223C0;
void Task_DestroySelf(u8); void Task_DestroySelf(u8);
@ -249,6 +248,7 @@ void SetSuppressLinkErrorMessage(bool8 flag);
void sub_800B524(struct LinkPlayer *linkPlayer); void sub_800B524(struct LinkPlayer *linkPlayer);
u8 GetSioMultiSI(void); u8 GetSioMultiSI(void);
void sub_800AAF4(void); void sub_800AAF4(void);
void sub_800AF18(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06);
void sub_800B348(void); void sub_800B348(void);
void sub_800B3A4(u32 who); void sub_800B3A4(u32 who);
@ -267,7 +267,7 @@ extern u8 gUnknown_030030EC[MAX_LINK_PLAYERS];
extern u8 gUnknown_030030F0[MAX_LINK_PLAYERS]; extern u8 gUnknown_030030F0[MAX_LINK_PLAYERS];
extern u16 gUnknown_030030F4; extern u16 gUnknown_030030F4;
extern u8 gSuppressLinkErrorMessage; extern u8 gSuppressLinkErrorMessage;
extern bool8 gWirelessCommType; extern u8 gWirelessCommType;
extern bool8 gSavedLinkPlayerCount; extern bool8 gSavedLinkPlayerCount;
extern u8 gSavedMultiplayerId; extern u8 gSavedMultiplayerId;
extern struct LinkTestBGInfo gLinkTestBGInfo; extern struct LinkTestBGInfo gLinkTestBGInfo;

View File

@ -142,11 +142,14 @@ struct UnkRfuStruct_Sub_Unused {
struct UnkRfuStruct_2 { struct UnkRfuStruct_2 {
/* 0x000 */ void (*unk_00)(void); /* 0x000 */ void (*unk_00)(void);
/* 0x004 */ u16 unk_04; /* 0x004 */ u16 unk_04;
/* 0x006 */ u8 filler_06[6]; /* 0x006 */ u8 filler_06[4];
/* 0x00a */ u16 unk_0a;
/* 0x00c */ u8 unk_0c; /* 0x00c */ u8 unk_0c;
/* 0x00d */ u8 playerCount; /* 0x00d */ u8 playerCount;
/* 0x00e */ u8 unk_0e; /* 0x00e */ u8 unk_0e;
/* 0x00f */ u8 filler_0f[5]; /* 0x00f */ u8 unk_0f;
/* 0x010 */ u16 unk_10;
/* 0x012 */ u16 unk_12;
/* 0x014 */ u8 unk_14[4][14]; /* 0x014 */ u8 unk_14[4][14];
/* 0x04c */ u8 unk_4c[14]; /* 0x04c */ u8 unk_4c[14];
/* 0x05a */ u8 unk_5a; /* 0x05a */ u8 unk_5a;
@ -207,8 +210,8 @@ struct UnkRfuStruct_8010A14 {
char unk_00[15]; char unk_00[15];
u8 unk_0f; u8 unk_0f;
u8 unk_10[4]; u8 unk_10[4];
struct LinkPlayer unk_14[4]; struct LinkPlayer unk_14[5];
u8 fill_84[0x78]; u8 fill_a0[0x5c];
}; };
// Exported RAM declarations // Exported RAM declarations

12
include/rom_8011DC0.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_rom_8011DC0_H
#define GUARD_rom_8011DC0_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void sub_8018438(void);
#endif //GUARD_rom_8011DC0_H

View File

@ -13,6 +13,7 @@
#include "overworld.h" #include "overworld.h"
#include "link.h" #include "link.h"
#include "librfu.h" #include "librfu.h"
#include "rom_8011DC0.h"
#include "link_rfu.h" #include "link_rfu.h"
// Static type declarations // Static type declarations
@ -4314,3 +4315,165 @@ void sub_8010A70(void *a0)
ResetBlockReceivedFlag(0); ResetBlockReceivedFlag(0);
} }
} }
void sub_8010AAC(u8 taskId)
{
int i;
struct LinkPlayerBlock *r2;
struct UnkRfuStruct_8010A14 *r5;
u8 r4 = gUnknown_03005000.unk_cde[gUnknown_082ED68C[gUnknown_03005000.unk_ce9]];
if (gUnknown_03005000.unk_f1 == 1 || gUnknown_03005000.unk_f1 == 2)
{
gUnknown_03005000.unk_ce8 = 0;
DestroyTask(taskId);
}
switch (gTasks[taskId].data[0])
{
case 0:
if (gSendCmd[0] == 0)
{
ResetBlockReceivedFlag(r4);
sub_800FD14(0x7800);
gTasks[taskId].data[0]++;
}
break;
case 1:
if (gSendCmd[0] == 0)
gTasks[taskId].data[0]++;
break;
case 2:
if ((GetBlockReceivedStatus() >> r4) & 1)
{
ResetBlockReceivedFlag(r4);
r2 = (struct LinkPlayerBlock *)gBlockRecvBuffer[r4];
gLinkPlayers[r4] = r2->linkPlayer;
sub_800B524(gLinkPlayers + r4);
gTasks[taskId].data[0]++;
}
break;
case 3:
r5 = (struct UnkRfuStruct_8010A14 *)gBlockSendBuffer;
memcpy(r5->unk_00, gUnknown_082ED7EC, sizeof gUnknown_082ED7EC);
r5->unk_0f = gUnknown_03005000.playerCount;
for (i = 0; i < 4; i++)
r5->unk_10[i] = gUnknown_03005000.unk_cde[i];
memcpy(r5->unk_14, gLinkPlayers, sizeof gLinkPlayers);
gTasks[taskId].data[0]++;
// fallthrough
case 4:
r5 = (struct UnkRfuStruct_8010A14 *)gBlockSendBuffer;
r5->unk_0f = gUnknown_03005000.playerCount;
for (i = 0; i < 4; i++)
r5->unk_10[i] = gUnknown_03005000.unk_cde[i];
memcpy(r5->unk_14, gLinkPlayers, sizeof gLinkPlayers);
if (SendBlock(0, gBlockSendBuffer, 0xa0))
gTasks[taskId].data[0]++;
break;
case 5:
if (sub_800A520() && GetBlockReceivedStatus() & 1)
{
CpuFill16(0, gBlockRecvBuffer, sizeof(struct UnkRfuStruct_8010A14));
ResetBlockReceivedFlag(0);
gUnknown_03005000.unk_ce8 = 0;
if (gUnknown_03005000.unk_ce6)
{
for (i = 0; i < 4; i++)
{
if ((gUnknown_03005000.unk_ce6 >> i) & 1)
{
gUnknown_03005000.unk_ce5 = 1 << i;
gUnknown_03005000.unk_ce6 ^= (1 << i);
gUnknown_03005000.unk_ce8 = 1;
break;
}
}
}
DestroyTask(taskId);
}
break;
}
}
void sub_8010D0C(u8 taskId)
{
if (gUnknown_03005000.unk_f1 == 1 || gUnknown_03005000.unk_f1 == 2)
DestroyTask(taskId);
switch (gTasks[taskId].data[0])
{
case 0:
if (gUnknown_03005000.playerCount)
{
sub_800B348();
SendBlock(0, gBlockSendBuffer, sizeof(struct LinkPlayerBlock));
gTasks[taskId].data[0]++;
}
break;
case 1:
if (sub_800A520())
gTasks[taskId].data[0]++;
break;
case 2:
if (GetBlockReceivedStatus() & 1)
{
sub_8010A14((const struct UnkRfuStruct_8010A14 *)gBlockRecvBuffer);
ResetBlockReceivedFlag(0);
gReceivedRemoteLinkPlayers = 1;
DestroyTask(taskId);
}
break;
}
}
void sub_8010DB4(void)
{
if (gUnknown_03005000.unk_ee == 1 && gUnknown_03004140.unk_02 == 0)
{
if (gMain.callback2 == sub_8018438 || gUnknown_03004140.unk_3c->unk_04)
gWirelessCommType = 2;
SetMainCallback2(CB2_LinkError);
gMain.savedCallback = CB2_LinkError;
sub_800AF18((gUnknown_03005000.unk_0a << 16) | (gUnknown_03005000.unk_10 << 8) | gUnknown_03005000.unk_12, gUnknown_03005000.unk_124.unk_8c2, gUnknown_03005000.unk_9e8.unk_232, sub_8011A74() == 2);
gUnknown_03005000.unk_ee = 2;
CloseLink();
}
else if (gUnknown_03005000.unk_9e8.unk_233 == 1 || gUnknown_03005000.unk_124.unk_8c3 == 1)
{
if (gUnknown_03004140.unk_02)
sub_800D630();
sub_8011A64(1, 0x7000);
sub_8011170(0x7000);
}
}
void rfu_REQ_recvData_then_sendData(void)
{
if (gUnknown_03004140.unk_06 == 1)
{
rfu_REQ_recvData();
rfu_waitREQComplete();
rfu_REQ_sendData_wrapper(0);
}
}
bool32 sub_8010EC0(void)
{
bool32 retval = FALSE;
gUnknown_03005000.unk_ccd = 0;
sub_800C54C(Random2());
if (gUnknown_03005000.unk_ef == 0)
{
switch (gUnknown_03005000.unk_0c)
{
case 1:
sub_800F0F8();
break;
case 0:
retval = sub_800F4F0();
break;
case 2:
rfu_REQ_recvData_then_sendData();
break;
}
}
return retval;
}