From 765ad80884338edfa752dcee450f62742b94d547 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 4 Dec 2017 20:06:03 -0500 Subject: [PATCH] through sub_800E700 --- asm/link_rfu.s | 51 ---------------------------------------------- include/librfu.h | 2 ++ include/link.h | 1 + include/link_rfu.h | 4 +++- src/link_rfu.c | 26 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 52 deletions(-) diff --git a/asm/link_rfu.s b/asm/link_rfu.s index 5be4b05f2..0a93e630f 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,57 +5,6 @@ .text - thumb_func_start sub_800E6D0 -sub_800E6D0: @ 800E6D0 - push {r4-r6,lr} - ldr r4, =gIntrTable - ldr r5, [r4, 0x4] - ldr r6, [r4, 0x8] - bl sub_800E700 - bl rfu_REQ_stopMode - bl rfu_waitREQComplete - ldr r1, =0x04000208 - movs r0, 0 - strh r0, [r1] - str r5, [r4, 0x4] - str r6, [r4, 0x8] - movs r0, 0x1 - strh r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800E6D0 - - thumb_func_start sub_800E700 -sub_800E700: @ 800E700 - push {r4,lr} - ldr r0, =gUnknown_03004140+0x50 - ldr r1, =0x00000e64 - ldr r4, =gIntrTable + 0x4 - adds r2, r4, 0 - movs r3, 0x1 - bl rfu_initializeAPI - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - bne _0800E732 - ldr r0, =gLinkType - strh r1, [r0] - bl sub_800AAF4 - movs r0, 0 - bl sub_80111B0 - bl sub_800E604 - adds r1, r4, 0x4 - movs r0, 0x3 - bl rfu_setTimerInterrupt -_0800E732: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_800E700 - thumb_func_start sub_800E748 sub_800E748: @ 800E748 push {r4,r5,lr} diff --git a/include/librfu.h b/include/librfu.h index 1f22133b9..e1e6d5f80 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -211,3 +211,5 @@ bool16 rfu_UNI_PARENT_getDRAC_ACK(u8 *a0); void rfu_REQ_disconnect(u8 who); void rfu_changeSendTarget(u8 a0, u8 who, u8 a2); void rfu_NI_stopReceivingData(u8 who); +u16 rfu_initializeAPI(u32 *unk0, u16 unk1, IntrFunc *interrupt, bool8 copyInterruptToRam); +void rfu_setTimerInterrupt(u8 which, IntrFunc *intr); diff --git a/include/link.h b/include/link.h index 32fadc5ea..c01f24d27 100644 --- a/include/link.h +++ b/include/link.h @@ -247,6 +247,7 @@ void sub_800A418(void); void SetSuppressLinkErrorMessage(bool8 flag); void sub_800B524(struct LinkPlayer *linkPlayer); u8 GetSioMultiSI(void); +void sub_800AAF4(void); extern u16 gLinkPartnersHeldKeys[6]; extern u32 gLinkDebugSeed; diff --git a/include/link_rfu.h b/include/link_rfu.h index f43f3dd12..6a55bb536 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -78,7 +78,9 @@ struct UnkRfuStruct_1 { /* 0x03c */ struct UnkLinkRfuStruct_02022B2C *unk_3c; /* 0x040 */ void (*unk_40)(u8, u8); /* 0x044 */ void (*unk_44)(u16); - /* 0x048 */ u8 filler_48[0xe78]; + /* 0x048 */ u8 filler_48[8]; + /* 0x050 */ u32 unk_50[0x399]; + /* 0xeb4 */ u8 filler_e64[12]; }; struct UnkRfuStruct_2_Sub_6c { diff --git a/src/link_rfu.c b/src/link_rfu.c index 3eb74a100..32080bf29 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -48,6 +48,7 @@ void sub_800D630(void); bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void sub_800FCC4(struct UnkRfuStruct_2_Sub_6c *data); bool32 sub_8010454(u16 a0); +void sub_80111B0(bool32 a0); u8 sub_8011A74(void); u8 sub_8012224(void); @@ -2355,3 +2356,28 @@ void sub_800E604(void) CpuFill16(0, gRecvCmds, sizeof gRecvCmds); CpuFill16(0, gLinkPlayers, sizeof gLinkPlayers) } + +void sub_800E6D0(void) +{ + IntrFunc serialIntr = gIntrTable[1]; + IntrFunc timerIntr = gIntrTable[2]; + sub_800E700(); + rfu_REQ_stopMode(); + rfu_waitREQComplete(); + REG_IME = 0; + gIntrTable[1] = serialIntr; + gIntrTable[2] = timerIntr; + REG_IME = INTR_FLAG_VBLANK; +} + +void sub_800E700(void) +{ + if (!rfu_initializeAPI(gUnknown_03004140.unk_50, sizeof gUnknown_03004140.unk_50, gIntrTable + 1, TRUE)) + { + gLinkType = 0; + sub_800AAF4(); + sub_80111B0(0); + sub_800E604(); + rfu_setTimerInterrupt(3, gIntrTable + 2); + } +}