diff --git a/asm/link.s b/asm/link.s index b25568209..38629bff9 100644 --- a/asm/link.s +++ b/asm/link.s @@ -7,44 +7,6 @@ // RFU; bss indicates that no file boundary exists here - thumb_func_start sub_800BEC0 -sub_800BEC0: @ 800BEC0 - push {r4,lr} - bl rfu_REQBN_softReset_and_checkID - adds r4, r0, 0 - ldr r0, =0x00008001 - cmp r4, r0 - bne _0800BED4 - ldr r1, =gUnknown_03004140 - movs r0, 0x1 - strb r0, [r1, 0x8] -_0800BED4: - ldr r0, =gUnknown_03004140 - ldrb r2, [r0, 0x4] - adds r1, r0, 0 - cmp r2, 0x17 - beq _0800BEE8 - cmp r2, 0x1 - beq _0800BEE8 - movs r0, 0 - strb r0, [r1, 0x5] - strb r0, [r1, 0x4] -_0800BEE8: - movs r0, 0 - strb r0, [r1, 0x7] - strb r0, [r1, 0xD] - strb r0, [r1, 0x1] - strb r0, [r1] - movs r0, 0xFF - strb r0, [r1, 0x6] - bl sub_800D610 - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_800BEC0 - thumb_func_start rfu_REQ_sendData_wrapper rfu_REQ_sendData_wrapper: @ 800BF0C push {lr} diff --git a/include/librfu.h b/include/librfu.h index 0cf781d73..609fffea2 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -108,3 +108,4 @@ extern struct RfuStruct *gRfuState; void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam); void rfu_REQ_stopMode(void); void rfu_waitREQComplete(void); +u32 rfu_REQBN_softReset_and_checkID(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index 62cff87b9..a395119fa 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,8 +3,24 @@ // Exported type declarations +struct UnkRfuStruct_1 { + u8 unk_00; + u8 unk_01; + u8 unk_02; + u8 unk_03; + u8 unk_04; + u8 unk_05; + u8 unk_06; + u8 unk_07; + u8 unk_08; + u8 filler_09[4]; + u8 unk_0d; +}; + // Exported RAM declarations +extern struct UnkRfuStruct_1 gUnknown_03004140; + // Exported ROM declarations u32 sub_800BEC0(void); void sub_800E700(void); diff --git a/src/link.c b/src/link.c index aa9e0a65d..645fcc182 100644 --- a/src/link.c +++ b/src/link.c @@ -143,12 +143,14 @@ static u16 LinkTestCalcBlockChecksum(const u16 *src, u16 size); static void LinkTest_prnthex(u32 pos, u8 a0, u8 a1, u8 a2); static void LinkCB_RequestPlayerDataExchange(void); static void Task_PrintTestData(u8 taskId); + static void sub_800AC80(void); static void sub_800ACAC(void); static void sub_800AD5C(void); static void sub_800AD88(void); static void sub_800AE30(void); static void sub_800AE5C(void); + static void CheckErrorStatus(void); static void CB2_PrintErrorMessage(void); static bool8 IsSioMultiMaster(void); @@ -159,6 +161,7 @@ static void CheckMasterOrSlave(void); static void InitTimer(void); static void EnqueueSendCmd(u16 *sendCmd); static void DequeueRecvCmds(u16 (*recvCmds)[CMD_LENGTH]); + static void StartTransfer(void); static bool8 DoHandshake(void); static void DoRecv(void); @@ -166,6 +169,8 @@ static void DoSend(void); static void StopTimer(void); static void SendRecvDone(void); +void sub_800D610(void); + // .rodata ALIGNED(4) const u16 gWirelessLinkDisplayPal[] = INCBIN_U16("graphics/interface/wireless_link_display.gbapal"); @@ -2436,3 +2441,29 @@ void ResetRecvBuffer(void) } } } + +// rfu + +u32 sub_800BEC0(void) +{ + u32 r4; + u8 r2; + + r4 = rfu_REQBN_softReset_and_checkID(); + if (r4 == 0x8001) + { + gUnknown_03004140.unk_08 = 1; + } + if (gUnknown_03004140.unk_04 != 0x17 && gUnknown_03004140.unk_04 != 0x01) + { + gUnknown_03004140.unk_05 = 0; + gUnknown_03004140.unk_04 = 0; + } + gUnknown_03004140.unk_07 = 0; + gUnknown_03004140.unk_0d = 0; + gUnknown_03004140.unk_01 = 0; + gUnknown_03004140.unk_00 = 0; + gUnknown_03004140.unk_06 = -1; + sub_800D610(); + return r4; +} diff --git a/src/link_rfu.c b/src/link_rfu.c index 43169a275..f654b9430 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -1,9 +1,13 @@ // Includes #include "global.h" +#include "link.h" +#include "link_rfu.h" // Static type declarations +struct UnkRfuStruct_1 gUnknown_03004140; + // Static RAM declarations IWRAM_DATA u8 gUnknown_03000D78[8]; IWRAM_DATA u8 gUnknown_03000D80[16];