From 8a5f292618e7464340a28bb584295510e4b50b3d Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Thu, 16 Jan 2020 04:46:17 +0800 Subject: [PATCH] document symbols --- asm/librfu.s | 473 ++++++++++++++++++------------------ asm/librfu_intr.s | 40 +-- common_syms/librfu.txt | 12 +- common_syms/librfu_stwi.txt | 2 +- data/librfu_rodata.s | 6 +- include/librfu.h | 62 ++--- include/link_rfu.h | 27 ++ include/union_room.h | 2 +- src/crt0.s | 2 +- src/librfu.c | 12 +- src/librfu_rfu.c | 30 +-- src/librfu_stwi.c | 290 +++++++++++----------- src/link_rfu.c | 230 +++++++++--------- src/trade.c | 2 +- src/union_room.c | 2 +- 15 files changed, 596 insertions(+), 596 deletions(-) diff --git a/asm/librfu.s b/asm/librfu.s index 82fba2202..28cc01594 100644 --- a/asm/librfu.s +++ b/asm/librfu.s @@ -47,21 +47,21 @@ _082E3EEE: .align 2, 0 .pool _082E3EFC: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus str r4, [r0] - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic adds r0, r4, 0 adds r0, 0xB4 str r0, [r1] - ldr r1, =gUnknown_03007898 + ldr r1, =gRfuFixed adds r0, 0x28 str r0, [r1] - ldr r2, =gUnknown_03007880 + ldr r2, =gRfuSlotStatusNI movs r1, 0xDE lsls r1, 1 adds r0, r4, r1 str r0, [r2] - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI movs r3, 0xDF lsls r3, 2 adds r0, r4, r3 @@ -88,10 +88,10 @@ _082E3F28: lsrs r5, r0, 16 cmp r5, 0x3 bls _082E3F28 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r1, [r0] adds r1, 0xDC - ldr r4, =gUnknown_03007870 + ldr r4, =gRfuSlotStatusUNI ldr r0, [r4, 0xC] adds r0, 0x1C str r0, [r1] @@ -100,7 +100,7 @@ _082E3F28: bl STWI_init_all bl rfu_STC_clearAPIVariables movs r5, 0 - ldr r3, =gUnknown_03007880 + ldr r3, =gRfuSlotStatusNI movs r2, 0 _082E3F6C: lsls r1, r5, 2 @@ -121,7 +121,7 @@ _082E3F6C: movs r0, 0x2 negs r0, r0 ands r4, r0 - ldr r1, =gUnknown_03007898 + ldr r1, =gRfuFixed ldr r0, [r1] adds r2, r0, 0 adds r2, 0x8 @@ -159,7 +159,7 @@ rfu_STC_clearAPIVariables: @ 82E3FDC adds r7, r0, 0 movs r6, 0 strh r6, [r1] - ldr r5, =gUnknown_03007894 + ldr r5, =gRfuStatic ldr r1, [r5] ldrb r4, [r1] mov r0, sp @@ -174,7 +174,7 @@ rfu_STC_clearAPIVariables: @ 82E3FDC mov r0, sp adds r0, 0x2 strh r1, [r0] - ldr r4, =gUnknown_03007890 + ldr r4, =gRfuLinkStatus ldr r1, [r4] ldr r2, =0x0100005a bl CpuSet @@ -230,7 +230,7 @@ rfu_UNI_PARENT_getDRAC_ACK: @ 82E4078 adds r4, r0, 0 movs r0, 0 strb r0, [r4] - ldr r5, =gUnknown_03007890 + ldr r5, =gRfuLinkStatus ldr r0, [r5] ldrb r0, [r0] cmp r0, 0x1 @@ -284,7 +284,7 @@ rfu_setTimerInterrupt: @ 82E40C0 thumb_func_start rfu_getSTWIRecvBuffer rfu_getSTWIRecvBuffer: @ 82E40D4 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -305,7 +305,7 @@ rfu_setMSCCallback: @ 82E40E4 rfu_setREQCallback: @ 82E40F0 push {lr} adds r1, r0, 0 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] str r1, [r0] negs r0, r1 @@ -324,7 +324,7 @@ rfu_enableREQCallback: @ 82E410C lsls r0, 24 cmp r0, 0 beq _082E4124 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] ldrb r1, [r2] movs r0, 0x8 @@ -333,7 +333,7 @@ rfu_enableREQCallback: @ 82E410C .align 2, 0 .pool _082E4124: - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] ldrb r1, [r2] movs r0, 0xF7 @@ -355,7 +355,7 @@ rfu_STC_REQ_callback: @ 82E4138 lsrs r4, r1, 16 ldr r0, =rfu_CB_defaultCallback bl STWI_set_Callback_M - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] strh r4, [r0, 0x1C] ldrb r1, [r0] @@ -363,7 +363,7 @@ rfu_STC_REQ_callback: @ 82E4138 ands r0, r1 cmp r0, 0 beq _082E4166 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] ldr r2, [r0] adds r0, r5, 0 @@ -386,21 +386,21 @@ rfu_CB_defaultCallback: @ 82E4178 lsrs r3, r1, 16 cmp r0, 0xFF bne _082E41D4 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] ldrb r1, [r0] movs r0, 0x8 ands r0, r1 cmp r0, 0 beq _082E41A2 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] ldr r2, [r0] movs r0, 0xFF adds r1, r3, 0 bl _call_via_r2 _082E41A2: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r1, [r0, 0x2] ldrb r0, [r0, 0x3] @@ -422,7 +422,7 @@ _082E41C2: lsrs r4, r0, 24 cmp r4, 0x3 bls _082E41B0 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] movs r0, 0xFF strb r0, [r1] @@ -438,7 +438,7 @@ _082E41D4: rfu_waitREQComplete: @ 82E41E8 push {lr} bl STWI_poll_CommandEnd - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] ldrh r0, [r0, 0x1C] pop {r1} @@ -463,7 +463,7 @@ rfu_REQ_RFUStatus: @ 82E41FC rfu_getRFUStatus: @ 82E4210 push {r4,r5,lr} adds r4, r0, 0 - ldr r5, =gUnknown_03007898 + ldr r5, =gRfuFixed ldr r0, [r5] adds r0, 0xDC ldr r0, [r0] @@ -495,18 +495,15 @@ _082E4246: bx r1 thumb_func_end rfu_getRFUStatus - thumb_func_start sub_82E424C -sub_82E424C: @ 82E424C + thumb_func_start rfu_MBOOT_CHILD_inheritanceLinkStatus +rfu_MBOOT_CHILD_inheritanceLinkStatus: @ 82E424C push {lr} - ldr r2, =gUnknown_089A324C + ldr r2, =str_checkMbootLL ldr r3, =gDma3Requests + 0xE0 b _082E4266 .align 2, 0 .pool - thumb_func_end sub_82E424C - - thumb_func_start sub_82E425C -sub_82E425C: @ 82E425C +_082E425C: ldrb r0, [r3] adds r3, 0x1 adds r2, 0x1 @@ -515,7 +512,7 @@ sub_82E425C: @ 82E425C _082E4266: ldrb r1, [r2] cmp r1, 0 - bne sub_82E425C + bne _082E425C movs r2, 0xC0 lsls r2, 18 movs r3, 0 @@ -537,11 +534,11 @@ _082E4274: bne _082E42BC movs r0, 0xC0 lsls r0, 18 - ldr r1, =gUnknown_03007890 + ldr r1, =gRfuLinkStatus ldr r1, [r1] movs r2, 0x5A bl CpuSet - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] ldrb r1, [r2] movs r0, 0x80 @@ -556,7 +553,7 @@ _082E42BC: _082E42BE: pop {r1} bx r1 - thumb_func_end sub_82E425C + thumb_func_end rfu_MBOOT_CHILD_inheritanceLinkStatus thumb_func_start rfu_REQ_stopMode rfu_REQ_stopMode: @ 82E42C4 @@ -568,7 +565,7 @@ rfu_REQ_stopMode: @ 82E42C4 movs r0, 0x3D movs r1, 0x6 bl rfu_STC_REQ_callback - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r1, [r0] ldrh r0, [r1, 0x12] movs r0, 0x6 @@ -580,11 +577,11 @@ _082E42EC: bl AgbRFU_SoftReset bl rfu_STC_clearAPIVariables movs r0, 0x8 - bl sub_82E6D6C + bl AgbRFU_checkID ldr r1, =0x00008001 cmp r0, r1 bne _082E4350 - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r0, [r0] ldrb r0, [r0, 0xA] lsls r0, 2 @@ -673,7 +670,7 @@ _082E43AC: bl AgbRFU_SoftReset bl rfu_STC_clearAPIVariables movs r0, 0x1E - bl sub_82E6D6C + bl AgbRFU_checkID adds r2, r0, 0 cmp r2, 0 bne _082E43CA @@ -746,7 +743,7 @@ rfu_REQ_configSystem: @ 82E440C bl STWI_send_SystemConfigREQ cmp r6, 0 bne _082E444C - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] movs r0, 0x1 strh r0, [r1, 0x1A] @@ -762,7 +759,7 @@ _082E444C: lsls r0, 2 adds r1, r6, 0 bl Div - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic ldr r1, [r1] strh r0, [r1, 0x1A] strh r4, [r5] @@ -860,10 +857,10 @@ rfu_CB_configGameData: @ 82E4500 lsrs r7, r1, 16 cmp r7, 0 bne _082E458A - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r0, [r0] ldr r1, [r0, 0x24] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r6, [r0] ldrb r2, [r1, 0x4] adds r5, r6, 0 @@ -895,7 +892,7 @@ _082E454C: _082E4552: strb r0, [r1] movs r2, 0 - ldr r3, =gUnknown_03007890 + ldr r3, =gRfuLinkStatus _082E4558: ldr r0, [r3] adds r0, 0x9A @@ -910,7 +907,7 @@ _082E4558: bls _082E4558 adds r4, 0x1 movs r2, 0 - ldr r3, =gUnknown_03007890 + ldr r3, =gRfuLinkStatus _082E4574: ldr r0, [r3] adds r0, 0xA9 @@ -939,7 +936,7 @@ rfu_REQ_startSearchChild: @ 82E459C push {r4,lr} movs r1, 0 ldr r4, =rfu_CB_defaultCallback - ldr r3, =gUnknown_03007894 + ldr r3, =gRfuStatic movs r2, 0 _082E45A6: ldr r0, [r3] @@ -959,7 +956,7 @@ _082E45A6: lsrs r1, r0, 16 cmp r1, 0 bne _082E45F0 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -995,7 +992,7 @@ rfu_CB_startSearchChild: @ 82E460C adds r2, r1, 0 cmp r2, 0 bne _082E4624 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] movs r0, 0x1 strb r0, [r1, 0x9] @@ -1022,7 +1019,7 @@ rfu_STC_clearLinkStatus: @ 82E4634 mov r0, sp movs r5, 0 strh r5, [r0] - ldr r4, =gUnknown_03007890 + ldr r4, =gRfuLinkStatus ldr r1, [r4] adds r1, 0x14 ldr r2, =0x01000040 @@ -1031,7 +1028,7 @@ rfu_STC_clearLinkStatus: @ 82E4634 strb r5, [r0, 0x8] _082E465C: movs r1, 0 - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus adds r4, r2, 0 movs r3, 0 _082E4664: @@ -1098,7 +1095,7 @@ rfu_CB_pollAndEndSearchChild: @ 82E46C0 _082E46D2: cmp r4, 0x1A bne _082E4714 - ldr r5, =gUnknown_03007890 + ldr r5, =gRfuLinkStatus ldr r0, [r5] adds r0, 0x94 ldrh r0, [r0] @@ -1112,7 +1109,7 @@ _082E46D2: cmp r0, 0 bne _082E4730 ldr r1, [r5] - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -1125,7 +1122,7 @@ _082E46D2: _082E4714: cmp r4, 0x1B bne _082E4730 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] ldrb r0, [r1] cmp r0, 0xFF @@ -1134,7 +1131,7 @@ _082E4714: movs r0, 0 strh r0, [r1] _082E4728: - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] movs r0, 0 strb r0, [r1, 0x9] @@ -1154,7 +1151,7 @@ rfu_STC_readChildList: @ 82E4748 push {r4-r7,lr} mov r7, r8 push {r7} - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -1162,9 +1159,9 @@ rfu_STC_readChildList: @ 82E4748 adds r6, r0, 0x4 cmp r7, 0 beq _082E47EE - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic mov r8, r0 - ldr r1, =gUnknown_03007890 + ldr r1, =gRfuLinkStatus mov r12, r1 _082E4766: ldrb r4, [r6, 0x2] @@ -1332,12 +1329,12 @@ rfu_STC_readParentCandidateList: @ 82E4888 mov r0, sp movs r4, 0 strh r4, [r0] - ldr r5, =gUnknown_03007890 + ldr r5, =gRfuLinkStatus ldr r1, [r5] adds r1, 0x14 ldr r2, =0x01000040 bl CpuSet - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r2, [r0] @@ -1471,7 +1468,7 @@ rfu_REQ_startConnectParent: @ 82E4998 lsrs r4, r0, 16 movs r3, 0 movs r2, 0 - ldr r1, =gUnknown_03007890 + ldr r1, =gRfuLinkStatus ldr r0, [r1] ldrh r0, [r0, 0x14] cmp r0, r4 @@ -1497,7 +1494,7 @@ _082E49C4: _082E49CC: cmp r3, 0 bne _082E49F0 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] strh r4, [r0, 0x1E] ldr r0, =rfu_STC_REQ_callback @@ -1545,7 +1542,7 @@ rfu_CB_pollConnectParent: @ 82E4A14 str r1, [sp, 0x28] cmp r1, 0 bne _082E4B16 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -1559,7 +1556,7 @@ rfu_CB_pollConnectParent: @ 82E4A14 lsls r0, 17 lsls r0, r1 lsrs r2, r0, 24 - ldr r4, =gUnknown_03007890 + ldr r4, =gRfuLinkStatus ldr r3, [r4] ldrb r1, [r3, 0x2] adds r0, r2, 0 @@ -1583,7 +1580,7 @@ rfu_CB_pollConnectParent: @ 82E4A14 strb r0, [r1, 0x1] ldr r0, [r4] strb r2, [r0] - ldr r3, =gUnknown_03007894 + ldr r3, =gRfuStatic ldr r2, [r3] ldrb r1, [r2] movs r0, 0x80 @@ -1641,7 +1638,7 @@ _082E4AEA: _082E4AF4: cmp r5, 0x3 bhi _082E4B16 - ldr r4, =gUnknown_03007890 + ldr r4, =gRfuLinkStatus mov r0, r10 lsls r5, r0, 5 adds r0, r5, 0 @@ -1677,7 +1674,7 @@ rfu_getConnectParentStatus: @ 82E4B34 adds r3, r0, 0 movs r0, 0xFF strb r0, [r3] - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r2, [r0] @@ -1709,14 +1706,14 @@ rfu_REQ_endConnectParent: @ 82E4B68 ldr r0, =rfu_CB_pollConnectParent bl STWI_set_Callback_M bl STWI_send_CP_EndREQ - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r1, [r0] ldrb r0, [r1, 0x6] cmp r0, 0x3 bhi _082E4B90 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] adds r0, 0xA ldrb r1, [r1, 0x6] @@ -1734,12 +1731,12 @@ _082E4B90: rfu_syncVBlank: @ 82E4BA0 push {r4,r5,lr} bl rfu_NI_checkCommFailCounter - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0] cmp r0, 0xFF beq _082E4C78 - ldr r4, =gUnknown_03007894 + ldr r4, =gRfuStatic ldr r1, [r4] ldrb r0, [r1, 0x6] cmp r0, 0 @@ -1778,7 +1775,7 @@ _082E4BFA: cmp r3, 0 beq _082E4C10 _082E4BFE: - ldr r3, =gUnknown_03007894 + ldr r3, =gRfuStatic ldr r2, [r3] ldrb r1, [r2] movs r0, 0xFD @@ -1787,7 +1784,7 @@ _082E4BFE: .align 2, 0 .pool _082E4C10: - ldr r3, =gUnknown_03007894 + ldr r3, =gRfuStatic ldr r2, [r3] ldrb r1, [r2] movs r0, 0x2 @@ -1806,7 +1803,7 @@ _082E4C1A: movs r0, 0xFB ands r0, r1 strb r0, [r3] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r1, [r0, 0x2] ldrb r0, [r0, 0x3] @@ -1828,7 +1825,7 @@ _082E4C54: lsrs r4, r0, 24 cmp r4, 0x3 bls _082E4C42 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] movs r0, 0xFF strb r0, [r1] @@ -1874,21 +1871,21 @@ rfu_REQBN_watchLink: @ 82E4C80 ldrb r0, [r2, 0xC] ldr r2, [sp, 0x4] strb r0, [r2] - ldr r5, =gUnknown_03007890 + ldr r5, =gRfuLinkStatus ldr r0, [r5] ldrb r0, [r0] cmp r0, 0xFF bne _082E4CBE b _082E504E _082E4CBE: - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r0, [r0] ldrb r0, [r0, 0x14] cmp r0, 0 bne _082E4CCA b _082E504E _082E4CCA: - ldr r3, =gUnknown_03007894 + ldr r3, =gRfuStatic ldr r2, [r3] ldrb r1, [r2] movs r4, 0x4 @@ -1912,7 +1909,7 @@ _082E4CEE: lsrs r0, 24 cmp r0, 0x29 bne _082E4D30 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r1, [r0] @@ -1940,7 +1937,7 @@ _082E4D30: lsls r0, 1 cmp r6, r0 bne _082E4D80 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -1963,7 +1960,7 @@ _082E4D56: ands r0, r1 cmp r0, 0 beq _082E4D76 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] adds r0, 0xA adds r0, r5 @@ -1983,7 +1980,7 @@ _082E4D80: bne _082E4D88 b _082E504E _082E4D88: - ldr r4, =gUnknown_03007898 + ldr r4, =gRfuFixed ldr r0, [r4] adds r0, 0xDC ldr r0, [r0] @@ -2005,7 +2002,7 @@ _082E4D88: ldr r0, [r0] adds r2, r0, 0x4 movs r5, 0 - ldr r3, =gUnknown_03007890 + ldr r3, =gRfuLinkStatus _082E4DBC: ldr r0, [r3] adds r0, 0xA @@ -2031,7 +2028,7 @@ _082E4DE8: ldr r0, [sp, 0xC] b _082E5050 _082E4DF4: - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic ldr r0, [r1] adds r0, 0xE adds r2, r0, r5 @@ -2041,7 +2038,7 @@ _082E4DF4: beq _082E4E1A subs r0, 0x4 strb r0, [r2] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] adds r0, 0xA adds r1, r0, r5 @@ -2065,7 +2062,7 @@ _082E4E2E: ldr r2, [sp, 0x8] cmp r2, 0x1 bne _082E4F10 - ldr r4, =gUnknown_03007890 + ldr r4, =gRfuLinkStatus ldr r1, [r4] ldrb r0, [r1, 0x2] ands r0, r6 @@ -2109,7 +2106,7 @@ _082E4E84: lsls r0, 16 cmp r0, 0 bne _082E4F10 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -2128,7 +2125,7 @@ _082E4E84: .align 2, 0 .pool _082E4EB8: - ldr r2, =gUnknown_03007894 + ldr r2, =gRfuStatic ldr r1, [r2] adds r1, 0xA adds r1, r5 @@ -2173,7 +2170,7 @@ _082E4F04: _082E4F0E: strb r1, [r0] _082E4F10: - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus mov r12, r2 ldr r1, [r2] ldrb r7, [r1] @@ -2215,7 +2212,7 @@ _082E4F10: ldrb r0, [r1, 0x1] adds r0, 0x1 strb r0, [r1, 0x1] - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] adds r0, 0xA adds r0, r5 @@ -2235,7 +2232,7 @@ _082E4F7E: bne _082E5002 bl STWI_send_SlotStatusREQ bl STWI_poll_CommandEnd - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r2, [r0] @@ -2250,7 +2247,7 @@ _082E4F7E: ldrb r0, [r2, 0x2] cmp r0, r5 bne _082E4FD0 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] lsls r1, r5, 1 adds r0, 0x12 @@ -2276,7 +2273,7 @@ _082E4FD0: ldrb r0, [r2, 0x2] cmp r0, r5 bne _082E4FD0 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] lsls r1, r5, 1 adds r0, 0x12 @@ -2293,7 +2290,7 @@ _082E4FFE: lsrs r0, 24 mov r9, r0 _082E5002: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r1, [r0, 0x2] mov r2, r8 @@ -2320,7 +2317,7 @@ _082E5028: bl STWI_send_DisconnectREQ bl STWI_poll_CommandEnd _082E5038: - ldr r1, =gUnknown_03007898 + ldr r1, =gRfuFixed ldr r0, [r1] adds r0, 0xDC ldr r0, [r0] @@ -2361,13 +2358,13 @@ rfu_STC_removeLinkData: @ 82E506C lsls r0, 17 lsls r0, r7 lsrs r6, r0, 24 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] adds r0, 0xE adds r0, r7 movs r1, 0 strb r1, [r0] - ldr r1, =gUnknown_03007890 + ldr r1, =gRfuLinkStatus ldr r4, [r1] ldrb r0, [r4, 0x2] ands r0, r6 @@ -2447,7 +2444,7 @@ rfu_REQ_disconnect: @ 82E512C push {r4,lr} lsls r0, 24 lsrs r4, r0, 24 - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r1, [r2] ldrb r0, [r1, 0x2] ldrb r1, [r1, 0x3] @@ -2455,7 +2452,7 @@ rfu_REQ_disconnect: @ 82E512C ands r0, r4 cmp r0, 0 beq _082E51B0 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] strb r4, [r1, 0x5] ldr r2, [r2] @@ -2519,7 +2516,7 @@ rfu_CB_disconnect: @ 82E51BC lsrs r5, r1, 16 cmp r5, 0x3 bne _082E51F8 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0] cmp r0, 0 @@ -2531,7 +2528,7 @@ rfu_CB_disconnect: @ 82E51BC lsls r0, 16 cmp r0, 0 bne _082E51F8 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] @@ -2540,9 +2537,9 @@ rfu_CB_disconnect: @ 82E51BC bne _082E51F8 movs r5, 0 _082E51F8: - ldr r3, =gUnknown_03007894 + ldr r3, =gRfuStatic ldr r2, [r3] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] ldrb r0, [r1, 0x2] ldrb r1, [r1, 0x3] @@ -2550,7 +2547,7 @@ _082E51F8: ldrb r1, [r2, 0x5] ands r0, r1 strb r0, [r2, 0x5] - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r1, [r0] @@ -2565,7 +2562,7 @@ _082E5220: lsls r0, 17 lsls r0, r4 lsrs r0, 24 - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic ldr r1, [r1] ldrb r1, [r1, 0x5] ands r0, r1 @@ -2581,7 +2578,7 @@ _082E523C: cmp r4, 0x3 bls _082E5220 _082E5246: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r1, [r2, 0x2] ldrb r0, [r2, 0x3] @@ -2594,7 +2591,7 @@ _082E5258: adds r0, r6, 0 adds r1, r5, 0 bl rfu_STC_REQ_callback - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] ldrb r0, [r0, 0x9] cmp r0, 0 @@ -2622,7 +2619,7 @@ rfu_REQ_CHILD_startConnectRecovery: @ 82E529C push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] strb r5, [r0, 0x5] movs r4, 0 @@ -2646,7 +2643,7 @@ _082E52B6: _082E52CA: adds r0, r2, 0 bl STWI_set_Callback_M - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] lsls r0, r4, 5 adds r0, r1, r0 @@ -2686,20 +2683,20 @@ rfu_CB_CHILD_pollConnectRecovery: @ 82E530C lsrs r7, r1, 16 cmp r7, 0 bne _082E5390 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] ldrb r0, [r0, 0x4] cmp r0, 0 bne _082E5390 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] ldrb r1, [r1, 0x5] adds r6, r0, 0 cmp r1, 0 beq _082E5390 - ldr r1, =gUnknown_03007890 + ldr r1, =gRfuLinkStatus ldr r0, [r1] strb r7, [r0] movs r4, 0 @@ -2763,7 +2760,7 @@ rfu_CHILD_getConnectRecoveryStatus: @ 82E53B0 adds r2, r0, 0 movs r0, 0xFF strb r0, [r2] - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r1, [r0] @@ -2863,7 +2860,7 @@ rfu_getMasterSlave: @ 82E5450 lsrs r2, r0, 24 cmp r2, 0x1 bne _082E547E - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r1, [r0] adds r0, r1, 0 adds r0, 0x2C @@ -2906,7 +2903,7 @@ rfu_clearAllSlot: @ 82E5488 _082E54A4: mov r0, sp strh r7, [r0] - ldr r0, =gUnknown_03007880 + ldr r0, =gRfuSlotStatusNI lsls r4, r5, 2 adds r0, r4, r0 ldr r1, [r0] @@ -2914,13 +2911,13 @@ _082E54A4: ldr r2, =0x01000034 bl CpuSet strh r7, [r6] - ldr r0, =gUnknown_03007870 + ldr r0, =gRfuSlotStatusUNI adds r4, r0 ldr r1, [r4] adds r0, r6, 0 ldr r2, =0x0100000a bl CpuSet - ldr r3, =gUnknown_03007890 + ldr r3, =gRfuLinkStatus ldr r0, [r3] adds r0, 0x10 adds r0, r5 @@ -2941,7 +2938,7 @@ _082E54A4: strb r1, [r0, 0x5] ldr r0, [r3] strb r1, [r0, 0x6] - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] strb r1, [r0, 0x2] ldr r0, =0x04000208 @@ -2966,14 +2963,14 @@ rfu_STC_releaseFrame: @ 82E5528 adds r5, r2, 0 lsls r1, 24 lsrs r3, r1, 24 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] ldrb r1, [r0] movs r0, 0x80 ands r0, r1 cmp r0, 0 bne _082E5568 - ldr r6, =gUnknown_03007890 + ldr r6, =gRfuLinkStatus cmp r3, 0 bne _082E5554 ldr r1, [r6] @@ -2990,7 +2987,7 @@ _082E5554: .align 2, 0 .pool _082E5568: - ldr r6, =gUnknown_03007890 + ldr r6, =gRfuLinkStatus cmp r3, 0 bne _082E557C ldr r1, [r6] @@ -3054,7 +3051,7 @@ _082E55C4: cmp r0, 0 beq _082E568C movs r3, 0 - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI lsls r0, r7, 2 adds r0, r1 mov r9, r0 @@ -3069,7 +3066,7 @@ _082E55E2: beq _082E5634 mov r2, r9 ldr r4, [r2] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] adds r0, r4, 0 adds r0, 0x2C @@ -3090,7 +3087,7 @@ _082E5614: ldr r0, [r2] adds r4, r0, 0 adds r4, 0x34 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] movs r1, 0x1 lsls r1, r7 @@ -3150,7 +3147,7 @@ _082E568C: ands r0, r4 cmp r0, 0 beq _082E5702 - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, r7, 2 adds r0, r1 ldr r3, [r0] @@ -3160,14 +3157,14 @@ _082E568C: ands r0, r1 cmp r0, 0 beq _082E56F4 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] ldrb r1, [r0] movs r0, 0x80 ands r0, r1 cmp r0, 0 bne _082E56D8 - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r1, [r2] ldrb r0, [r1, 0xF] adds r0, 0x3 @@ -3178,7 +3175,7 @@ _082E568C: .align 2, 0 .pool _082E56D8: - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r1, [r2] adds r1, 0x10 adds r1, r7 @@ -3209,7 +3206,7 @@ _082E5702: mov r1, sp movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, r7, 2 adds r0, r1 ldr r1, [r0] @@ -3256,7 +3253,7 @@ _082E576C: ands r0, r3 cmp r0, 0 beq _082E5788 - ldr r0, =gUnknown_03007880 + ldr r0, =gRfuSlotStatusNI lsls r1, 2 adds r1, r0 ldr r0, [r1] @@ -3274,7 +3271,7 @@ _082E5788: lsls r0, 3 b _082E57A4 _082E5796: - ldr r0, =gUnknown_03007870 + ldr r0, =gRfuSlotStatusUNI lsls r1, r4, 2 adds r1, r0 ldr r0, [r1] @@ -3324,7 +3321,7 @@ rfu_UNI_setSendData: @ 82E57DC lsrs r1, r0, 24 lsls r2, 24 lsrs r2, 24 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0] cmp r0, 0x1 @@ -3362,7 +3359,7 @@ rfu_NI_CHILD_setSendGameName: @ 82E5818 lsls r1, 17 lsls r1, r0 lsrs r1, 24 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r3, [r0] adds r3, 0x98 movs r0, 0x1A @@ -3394,7 +3391,7 @@ rfu_STC_setSendData_org: @ 82E584C lsls r2, 24 lsrs r2, 24 mov r8, r2 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r1, [r2] mov r10, r0 @@ -3444,7 +3441,7 @@ _082E58C0: movs r2, 0 movs r0, 0x1 ands r0, r3 - ldr r4, =gUnknown_089A3220 + ldr r4, =llsf_struct cmp r0, 0 bne _082E58E2 movs r1, 0x1 @@ -3509,7 +3506,7 @@ _082E591E: cmp r6, 0x40 bne _082E59F4 _082E5938: - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI lsls r0, r2, 2 adds r0, r1 ldr r0, [r0] @@ -3568,7 +3565,7 @@ _082E5998: bls _082E5998 movs r2, 0 movs r5, 0x1 - ldr r4, =gUnknown_03007880 + ldr r4, =gRfuSlotStatusNI movs r1, 0 _082E59B2: adds r0, r3, 0 @@ -3608,7 +3605,7 @@ _082E59F4: ands r0, r6 cmp r0, 0 beq _082E5A2C - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, r2, 2 adds r0, r1 ldr r1, [r0] @@ -3674,7 +3671,7 @@ rfu_changeSendTarget: @ 82E5A54 _082E5A78: cmp r0, 0x20 bne _082E5B18 - ldr r0, =gUnknown_03007880 + ldr r0, =gRfuSlotStatusNI mov r12, r0 lsls r0, r7, 2 add r0, r12 @@ -3725,7 +3722,7 @@ _082E5AD2: lsrs r2, r0, 24 cmp r2, 0x3 bls _082E5ABE - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] ldrb r0, [r1, 0x4] ldr r2, [sp] @@ -3751,7 +3748,7 @@ _082E5AFE: _082E5B18: cmp r3, 0x10 bne _082E5BA4 - ldr r3, =gUnknown_03007870 + ldr r3, =gRfuSlotStatusUNI lsls r1, r7, 2 adds r0, r1, r3 ldr r0, [r0] @@ -3797,7 +3794,7 @@ _082E5B70: ldrh r0, [r3] mov r8, r0 strh r2, [r3] - ldr r4, =gUnknown_03007890 + ldr r4, =gRfuLinkStatus ldr r2, [r4] adds r5, r1, r5 ldr r0, [r5] @@ -3845,7 +3842,7 @@ rfu_NI_stopReceivingData: @ 82E5BBC lsls r0, 3 b _082E5C26 _082E5BCC: - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI lsls r0, r3, 2 adds r0, r1 ldr r2, [r0] @@ -3873,7 +3870,7 @@ _082E5C04: movs r0, 0x47 _082E5C06: strh r0, [r2, 0x34] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] movs r1, 0x1 lsls r1, r3 @@ -3911,7 +3908,7 @@ rfu_UNI_changeAndReadySendData: @ 82E5C34 lsls r0, 3 b _082E5CC0 _082E5C4C: - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, 2 adds r0, r1 ldr r4, [r0] @@ -3924,7 +3921,7 @@ _082E5C4C: .align 2, 0 .pool _082E5C6C: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] ldrb r0, [r1] cmp r0, 0x1 @@ -3981,7 +3978,7 @@ rfu_UNI_readySendData: @ 82E5CC8 lsrs r0, 24 cmp r0, 0x3 bhi _082E5CE6 - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, 2 adds r0, r1 ldr r2, [r0] @@ -4005,7 +4002,7 @@ rfu_UNI_clearRecvNewDataFlag: @ 82E5CF4 lsrs r0, 24 cmp r0, 0x3 bhi _082E5D0A - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, 2 adds r0, r1 ldr r1, [r0] @@ -4023,7 +4020,7 @@ rfu_REQ_sendData: @ 82E5D14 push {r4,r5,lr} lsls r0, 24 lsrs r5, r0, 24 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r1, [r2] adds r4, r0, 0 @@ -4041,7 +4038,7 @@ _082E5D28: orrs r3, r0 cmp r3, 0 bne _082E5DB8 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] ldrb r1, [r2, 0x3] adds r4, r0, 0 @@ -4076,7 +4073,7 @@ _082E5D6E: cmp r0, 0 bne _082E5E12 _082E5D80: - ldr r4, =gUnknown_03007898 + ldr r4, =gRfuFixed ldr r1, [r4] movs r0, 0x1 str r0, [r1, 0x68] @@ -4114,10 +4111,10 @@ _082E5DC4: bl STWI_set_Callback_M cmp r5, 0 beq _082E5DFC - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0x68 - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic ldr r1, [r1] ldr r1, [r1, 0x24] adds r1, 0x4 @@ -4128,10 +4125,10 @@ _082E5DC4: .align 2, 0 .pool _082E5DFC: - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0x68 - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic ldr r1, [r1] ldr r1, [r1, 0x24] adds r1, 0x4 @@ -4141,12 +4138,12 @@ _082E5DFC: _082E5E12: cmp r5, 0 beq _082E5E4E - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0] cmp r0, 0x1 bne _082E5E44 - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r0, [r0] ldr r1, [r0, 0x1C] cmp r1, 0 @@ -4181,7 +4178,7 @@ rfu_CB_sendData: @ 82E5E58 ldr r0, =0x00008020 mov r8, r0 _082E5E6C: - ldr r0, =gUnknown_03007870 + ldr r0, =gRfuSlotStatusUNI lsls r2, r6, 2 adds r0, r2, r0 ldr r1, [r0] @@ -4191,7 +4188,7 @@ _082E5E6C: movs r0, 0 strb r0, [r1, 0x2] _082E5E7E: - ldr r0, =gUnknown_03007880 + ldr r0, =gRfuSlotStatusNI adds r0, r2, r0 ldr r4, [r0] ldrh r0, [r4] @@ -4201,7 +4198,7 @@ _082E5E7E: movs r1, 0 adds r2, r4, 0 bl rfu_STC_releaseFrame - ldr r5, =gUnknown_03007890 + ldr r5, =gRfuLinkStatus ldr r2, [r5] ldrb r1, [r4, 0x1A] ldrb r0, [r2, 0x4] @@ -4227,7 +4224,7 @@ _082E5EB8: cmp r6, 0x3 bls _082E5E6C _082E5EC2: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r1, [r0] ldrb r0, [r1, 0xE] movs r0, 0 @@ -4286,7 +4283,7 @@ rfu_constructSendLLFrame: @ 82E5F28 mov r5, r8 push {r5-r7} sub sp, 0x4 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r0, [r2] cmp r0, 0xFF @@ -4304,7 +4301,7 @@ _082E5F40: movs r0, 0 strb r0, [r2, 0xE] mov r8, r0 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0x6C str r0, [sp] @@ -4316,7 +4313,7 @@ _082E5F40: mov r10, r1 _082E5F6A: movs r5, 0 - ldr r0, =gUnknown_03007880 + ldr r0, =gRfuSlotStatusNI lsls r7, r6, 2 adds r4, r7, r0 ldr r2, [r4] @@ -4345,7 +4342,7 @@ _082E5F8A: lsrs r0, 16 adds r5, r0 _082E5FA6: - ldr r0, =gUnknown_03007870 + ldr r0, =gRfuSlotStatusUNI adds r0, r7, r0 ldr r0, [r0] ldrh r0, [r0] @@ -4360,7 +4357,7 @@ _082E5FA6: _082E5FC0: cmp r5, 0 beq _082E5FF4 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0] cmp r0, 0x1 @@ -4382,15 +4379,15 @@ _082E5FF4: lsrs r6, r0, 24 cmp r6, 0x3 bls _082E5F6A - ldr r6, =gUnknown_03007894 + ldr r6, =gRfuStatic mov r0, r8 cmp r0, 0 beq _082E603E ldr r2, [sp] movs r0, 0x3 ands r0, r2 - ldr r5, =gUnknown_03007890 - ldr r1, =gUnknown_03007898 + ldr r5, =gRfuLinkStatus + ldr r1, =gRfuFixed cmp r0, 0 beq _082E6026 movs r4, 0 @@ -4446,11 +4443,11 @@ rfu_STC_NI_constructLLSF: @ 82E6060 lsls r0, 24 lsrs r0, 24 mov r10, r0 - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r0, [r2] ldrb r0, [r0] lsls r0, 4 - ldr r1, =gUnknown_089A3220 + ldr r1, =llsf_struct adds r0, r1 mov r8, r0 ldrh r1, [r4] @@ -4570,7 +4567,7 @@ _082E6130: orrs r3, r0 orrs r3, r5 str r3, [sp] - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r0, [r2] ldrb r0, [r0] cmp r0, 0x1 @@ -4611,7 +4608,7 @@ _082E61A2: adds r0, r1 ldr r0, [r0] str r0, [sp, 0x4] - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r1, [r0] add r0, sp, 0x4 ldr r3, [r1, 0x4] @@ -4633,7 +4630,7 @@ _082E61C2: movs r0, 0 strb r0, [r6] _082E61DC: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r1, [r2] cmp r1, 0x1 @@ -4677,7 +4674,7 @@ rfu_STC_UNI_constructLLSF: @ 82E6220 lsls r0, 24 lsrs r0, 24 mov r8, r0 - ldr r1, =gUnknown_03007870 + ldr r1, =gRfuSlotStatusUNI lsls r0, 2 adds r0, r1 ldr r4, [r0] @@ -4693,11 +4690,11 @@ _082E6244: .align 2, 0 .pool _082E624C: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r0, [r2] lsls r0, 4 - ldr r1, =gUnknown_089A3220 + ldr r1, =llsf_struct adds r5, r0, r1 ldrh r0, [r4] movs r1, 0xF @@ -4717,7 +4714,7 @@ _082E624C: _082E6276: mov r2, sp movs r3, 0 - ldr r1, =gUnknown_03007898 + ldr r1, =gRfuFixed mov r12, r1 add r7, sp, 0x4 ldrb r0, [r5] @@ -4746,7 +4743,7 @@ _082E629E: adds r0, r7, 0 adds r1, r6, 0 bl _call_via_r3 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r0, [r2] cmp r0, 0x1 @@ -4782,12 +4779,12 @@ _082E62E8: thumb_func_start rfu_REQ_recvData rfu_REQ_recvData: @ 82E62F4 push {r4,lr} - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r4, [r0] ldrb r0, [r4] cmp r0, 0xFF beq _082E6320 - ldr r2, =gUnknown_03007894 + ldr r2, =gRfuStatic ldr r3, [r2] ldrb r0, [r4, 0x4] ldrb r1, [r4, 0x5] @@ -4823,17 +4820,17 @@ rfu_CB_recvData: @ 82E6334 lsrs r7, r1, 16 cmp r7, 0 bne _082E63F8 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r0, [r0] ldrb r0, [r0, 0x1] cmp r0, 0 beq _082E63F8 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] strb r7, [r0, 0x1] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0] cmp r0, 0x1 @@ -4848,16 +4845,16 @@ _082E6380: movs r6, 0 ldr r0, =0x00008043 mov r8, r0 - ldr r3, =gUnknown_03007890 + ldr r3, =gRfuLinkStatus _082E6388: - ldr r0, =gUnknown_03007880 + ldr r0, =gRfuSlotStatusNI lsls r1, r6, 2 adds r1, r0 ldr r4, [r1] ldrh r0, [r4, 0x34] cmp r0, r8 bne _082E63DA - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r0, [r0] ldrb r0, [r0, 0x1] asrs r0, r6 @@ -4897,7 +4894,7 @@ _082E63DA: lsrs r6, r0, 24 cmp r6, 0x3 bls _082E6388 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] ldrb r0, [r1, 0x4] cmp r0, 0 @@ -4926,7 +4923,7 @@ _082E63F8: rfu_STC_PARENT_analyzeRecvPacket: @ 82E6420 push {r4-r7,lr} sub sp, 0x4 - ldr r1, =gUnknown_03007898 + ldr r1, =gRfuFixed ldr r0, [r1] adds r0, 0xDC ldr r0, [r0] @@ -4935,7 +4932,7 @@ rfu_STC_PARENT_analyzeRecvPacket: @ 82E6420 movs r5, 0 mov r12, r1 movs r7, 0x1F - ldr r4, =gUnknown_03007894 + ldr r4, =gRfuStatic movs r6, 0x1 _082E643A: mov r0, sp @@ -5007,7 +5004,7 @@ _082E64A0: thumb_func_start rfu_STC_CHILD_analyzeRecvPacket rfu_STC_CHILD_analyzeRecvPacket: @ 82E64B8 push {r4-r6,lr} - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] adds r0, 0xDC ldr r1, [r0] @@ -5018,7 +5015,7 @@ rfu_STC_CHILD_analyzeRecvPacket: @ 82E64B8 adds r5, 0x8 cmp r4, 0 bne _082E64D8 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r1, [r0] movs r0, 0xF strb r0, [r1, 0x1] @@ -5065,14 +5062,14 @@ rfu_STC_analyzeLLSF: @ 82E6510 mov r12, r0 lsls r2, 16 lsrs r3, r2, 16 - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r0, [r2] ldrb r0, [r0] mvns r0, r0 movs r1, 0x1 ands r0, r1 lsls r0, 4 - ldr r1, =gUnknown_089A3220 + ldr r1, =llsf_struct adds r6, r0, r1 ldrb r0, [r6] cmp r3, r0 @@ -5188,7 +5185,7 @@ _082E6574: beq _082E661A b _082E673C _082E661A: - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r3, [r2] ldrb r2, [r3] cmp r2, 0x1 @@ -5226,7 +5223,7 @@ _082E6664: b _082E673C _082E6678: movs r4, 0 - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI ldr r0, [r1] ldrb r0, [r0, 0x1A] mov r5, r12 @@ -5254,7 +5251,7 @@ _082E6694: ands r0, r2 cmp r0, 0 beq _082E6694 - ldr r3, =gUnknown_03007890 + ldr r3, =gRfuLinkStatus ldr r0, [r3] ldrb r0, [r0, 0x4] mov r5, r12 @@ -5307,7 +5304,7 @@ _082E6706: bl rfu_STC_NI_receive_Receiver b _082E6732 _082E6718: - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r0, [r0] ldrb r0, [r0, 0x4] asrs r0, r4 @@ -5348,7 +5345,7 @@ rfu_STC_UNI_receive: @ 82E6754 str r2, [sp] lsls r0, 24 lsrs r7, r0, 24 - ldr r2, =gUnknown_03007870 + ldr r2, =gRfuSlotStatusUNI lsls r1, r7, 2 adds r1, r2 ldr r3, [r1] @@ -5401,7 +5398,7 @@ _082E67B4: ldr r0, [r0] ldr r0, [r0, 0x14] str r0, [sp, 0x4] - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] add r1, sp, 0x4 ldr r3, [r0, 0x4] @@ -5414,7 +5411,7 @@ _082E67DE: ldrh r0, [r5, 0x2] cmp r0, 0 beq _082E67F2 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] movs r0, 0x10 lsls r0, r7 @@ -5443,7 +5440,7 @@ rfu_STC_NI_receive_Sender: @ 82E6808 lsls r1, 24 lsrs r1, 24 mov r10, r1 - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI lsrs r0, 22 adds r0, r1 ldr r0, [r0] @@ -5645,7 +5642,7 @@ _082E69A8: ldrh r2, [r4] movs r0, 0 strh r0, [r4] - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r3, [r0] movs r0, 0x10 mov r7, r10 @@ -5655,7 +5652,7 @@ _082E69A8: movs r1, 0 strb r0, [r3, 0x2] lsls r0, r7, 2 - ldr r3, =gUnknown_03007880 + ldr r3, =gRfuSlotStatusNI adds r0, r3 ldr r0, [r0] strh r1, [r0, 0x2] @@ -5687,7 +5684,7 @@ rfu_STC_NI_receive_Receiver: @ 82E69F4 lsrs r0, 24 mov r8, r0 movs r7, 0 - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI lsls r0, 2 adds r0, r1 ldr r4, [r0] @@ -5704,7 +5701,7 @@ rfu_STC_NI_receive_Receiver: @ 82E69F4 ldrb r0, [r6, 0x2] cmp r0, 0x3 bne _082E6A64 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] movs r0, 0x1 mov r1, r8 @@ -5773,7 +5770,7 @@ _082E6AAE: ands r0, r1 cmp r2, r0 bne _082E6B04 - ldr r0, =gUnknown_03007898 + ldr r0, =gRfuFixed ldr r0, [r0] lsls r1, r3, 2 adds r1, 0x4 @@ -5831,7 +5828,7 @@ _082E6B2C: ldrh r2, [r3] movs r0, 0 strh r0, [r3] - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r4, [r0] movs r0, 0x1 mov r1, r8 @@ -5861,7 +5858,7 @@ rfu_STC_NI_initSlot_asRecvControllData: @ 82E6B70 adds r2, r1, 0 lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r3, [r0] ldrb r1, [r3] mov r12, r0 @@ -5895,7 +5892,7 @@ _082E6B98: strh r0, [r2] ldr r0, =0x00000702 strh r0, [r2, 0x18] - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r2, [r0] ldrb r1, [r2, 0x4] adds r0, r6, 0 @@ -5943,7 +5940,7 @@ rfu_STC_NI_initSlot_asRecvDataEntity: @ 82E6C00 ldrb r0, [r0] cmp r0, 0x1 bne _082E6C24 - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus lsls r1, r5, 5 adds r1, 0x14 ldr r0, [r0] @@ -5953,7 +5950,7 @@ rfu_STC_NI_initSlot_asRecvDataEntity: @ 82E6C00 .align 2, 0 .pool _082E6C24: - ldr r1, =gUnknown_03007880 + ldr r1, =gRfuSlotStatusNI lsls r0, r5, 2 adds r0, r1 ldr r2, [r0] @@ -5965,13 +5962,13 @@ _082E6C24: lsls r1, 17 lsls r1, r5 lsrs r1, 24 - ldr r0, =gUnknown_03007894 + ldr r0, =gRfuStatic ldr r3, [r0] ldrb r2, [r3, 0x4] adds r0, r1, 0 orrs r0, r2 strb r0, [r3, 0x4] - ldr r0, =gUnknown_03007890 + ldr r0, =gRfuLinkStatus ldr r2, [r0] ldrb r0, [r2, 0x5] bics r0, r1 @@ -6027,7 +6024,7 @@ _082E6CAC: thumb_func_start rfu_NI_checkCommFailCounter rfu_NI_checkCommFailCounter: @ 82E6CB8 push {r4-r7,lr} - ldr r2, =gUnknown_03007890 + ldr r2, =gRfuLinkStatus ldr r0, [r2] ldrb r1, [r0, 0x4] ldrb r0, [r0, 0x5] @@ -6039,14 +6036,14 @@ rfu_NI_checkCommFailCounter: @ 82E6CB8 mov r12, r0 movs r0, 0 strh r0, [r1] - ldr r1, =gUnknown_03007894 + ldr r1, =gRfuStatic ldr r0, [r1] ldrb r0, [r0, 0x2] lsrs r7, r0, 4 movs r3, 0 adds r6, r1, 0 adds r5, r2, 0 - ldr r4, =gUnknown_03007880 + ldr r4, =gRfuSlotStatusNI _082E6CE2: movs r0, 0x80 lsls r0, 17 @@ -6118,8 +6115,8 @@ rfu_REQ_noise: @ 82E6D54 .pool thumb_func_end rfu_REQ_noise - thumb_func_start sub_82E6D6C -sub_82E6D6C: @ 82E6D6C + thumb_func_start AgbRFU_checkID +AgbRFU_checkID: @ 82E6D6C push {r4-r7,lr} mov r7, r8 push {r7} @@ -6138,13 +6135,13 @@ _082E6D88: ldr r0, =0x04000200 ldrh r0, [r0] mov r8, r0 - ldr r4, =gRfuState + ldr r4, =gSTWIStatus ldr r1, [r4] movs r0, 0xA str r0, [r1] - ldr r0, =sub_82E6F88 + ldr r0, =Sio32IDIntr bl STWI_set_Callback_ID - bl sub_82E6E20 + bl Sio32IDInit ldr r0, [r4] ldrb r0, [r0, 0xA] lsls r0, 2 @@ -6173,7 +6170,7 @@ _082E6DD6: lsrs r5, r0, 24 cmp r5, 0xFF beq _082E6DEA - bl sub_82E6E94 + bl Sio32IDMain adds r6, r0, 0 cmp r6, 0 beq _082E6DC4 @@ -6186,7 +6183,7 @@ _082E6DEA: strh r2, [r0] movs r0, 0x1 strh r0, [r1] - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r1, [r0] movs r0, 0 str r0, [r1] @@ -6200,17 +6197,17 @@ _082E6E08: bx r1 .align 2, 0 .pool - thumb_func_end sub_82E6D6C + thumb_func_end AgbRFU_checkID - thumb_func_start sub_82E6E20 -sub_82E6E20: @ 82E6E20 + thumb_func_start Sio32IDInit +Sio32IDInit: @ 82E6E20 push {r4,r5,lr} sub sp, 0x4 ldr r3, =0x04000208 movs r4, 0 strh r4, [r3] ldr r2, =0x04000200 - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r0, [r0] movs r1, 0x8 ldrb r0, [r0, 0xA] @@ -6237,7 +6234,7 @@ sub_82E6E20: @ 82E6E20 strh r0, [r2] movs r0, 0 str r0, [sp] - ldr r1, =gUnknown_030078A0 + ldr r1, =gRfuSIO32Id ldr r2, =0x05000003 mov r0, sp bl CpuSet @@ -6249,12 +6246,12 @@ sub_82E6E20: @ 82E6E20 bx r0 .align 2, 0 .pool - thumb_func_end sub_82E6E20 + thumb_func_end Sio32IDInit - thumb_func_start sub_82E6E94 -sub_82E6E94: @ 82E6E94 + thumb_func_start Sio32IDMain +Sio32IDMain: @ 82E6E94 push {r4-r7,lr} - ldr r0, =gUnknown_030078A0 + ldr r0, =gRfuSIO32Id ldrb r1, [r0, 0x1] mov r12, r1 adds r7, r0, 0 @@ -6364,14 +6361,14 @@ _082E6F82: pop {r4-r7} pop {r1} bx r1 - thumb_func_end sub_82E6E94 + thumb_func_end Sio32IDMain - thumb_func_start sub_82E6F88 -sub_82E6F88: @ 82E6F88 + thumb_func_start Sio32IDIntr +Sio32IDIntr: @ 82E6F88 push {r4,r5,lr} ldr r0, =0x04000120 ldr r5, [r0] - ldr r0, =gUnknown_030078A0 + ldr r0, =gRfuSIO32Id ldrb r1, [r0] adds r4, r0, 0 cmp r1, 0x1 @@ -6381,7 +6378,7 @@ sub_82E6F88: @ 82E6F88 movs r2, 0x80 orrs r1, r2 strh r1, [r0] - thumb_func_end sub_82E6F88 + thumb_func_end Sio32IDIntr non_word_aligned_thumb_func_start sub_82E6FA2 sub_82E6FA2: @ 82E6FA2 @@ -6429,7 +6426,7 @@ _082E6FF6: cmp r0, 0x3 bhi _082E700C lsls r0, 1 - ldr r1, =gUnknown_089A3258 + ldr r1, =Sio32ConnectionData adds r0, r1 ldrh r0, [r0] b _082E700E diff --git a/asm/librfu_intr.s b/asm/librfu_intr.s index 7f375e419..fe79ae17d 100644 --- a/asm/librfu_intr.s +++ b/asm/librfu_intr.s @@ -18,7 +18,7 @@ IntrSIO32: @ 82E3554 cmp r0, 0 ldmdbeq r11, {r11,sp,lr} bxeq lr - bl sub_82E3EB0 + bl Callback_Dummy_ID ldmdb r11, {r11,sp,lr} bx lr _082E3590: @@ -33,7 +33,7 @@ _082E35A8: ldmdb r11, {r11,sp,lr} bx lr .align 2, 0 -_082E35B4: .4byte gRfuState +_082E35B4: .4byte gSTWIStatus arm_func_end IntrSIO32 arm_func_start sio32intr_clock_master @@ -204,10 +204,10 @@ _082E3800: beq _082E3840 ldrh r1, [r0, 0x12] ldrb r0, [r0, 0x6] - bl sub_82E3EA8 + bl Callback_Dummy_M b _082E3840 .align 2, 0 -_082E382C: .4byte gRfuState +_082E382C: .4byte gSTWIStatus _082E3830: add r3, r5, 0x3 strh r3, [r4] @@ -423,7 +423,7 @@ _082E3AD4: beq _082E3C4C mov r0, 0x1EC add r0, r0, 0x2 - bl sub_82E3EAC + bl Callback_Dummy_S b _082E3C4C _082E3B48: mov r3, 0x120 @@ -445,7 +445,7 @@ _082E3B48: ldrb r0, [r0, 0x6] mov r1, r2 orr r0, r0, r3, lsl 8 - bl sub_82E3EAC + bl Callback_Dummy_S b _082E3C4C _082E3B9C: mov r3, 0x208 @@ -472,7 +472,7 @@ _082E3BE4: bhi _082E3BE4 b _082E3C20 .align 2, 0 -_082E3BF4: .4byte gRfuState +_082E3BF4: .4byte gSTWIStatus _082E3BF8: .4byte 0x996601ee _082E3BFC: mov r2, 0xFF00 @@ -532,7 +532,7 @@ _082E3CA4: ldmdb r11, {r11,sp,lr} bx lr .align 2, 0 -_082E3CB8: .4byte gRfuState +_082E3CB8: .4byte gSTWIStatus arm_func_end handshake_wait arm_func_start STWI_set_timer_in_RAM @@ -588,7 +588,7 @@ _082E3D5C: mov r3, 0x3 b _082E3D8C .align 2, 0 -_082E3D74: .4byte gRfuState +_082E3D74: .4byte gSTWIStatus _082E3D78: mvn r3, 0x850 sub r3, r3, 0x2 @@ -637,7 +637,7 @@ STWI_stop_timer_in_RAM: @ 82E3DCC ldmdb r11, {r11,sp,lr} bx lr .align 2, 0 -_082E3E18: .4byte gRfuState +_082E3E18: .4byte gSTWIStatus arm_func_end STWI_stop_timer_in_RAM arm_func_start STWI_init_slave @@ -677,20 +677,20 @@ STWI_init_slave: @ 82E3E1C ldmdb r11, {r11,sp,lr} bx lr .align 2, 0 -_082E3EA4: .4byte gRfuState +_082E3EA4: .4byte gSTWIStatus arm_func_end STWI_init_slave - arm_func_start sub_82E3EA8 -sub_82E3EA8: @ 82E3EA8 + arm_func_start Callback_Dummy_M +Callback_Dummy_M: @ 82E3EA8 bx r2 - arm_func_end sub_82E3EA8 + arm_func_end Callback_Dummy_M - arm_func_start sub_82E3EAC -sub_82E3EAC: @ 82E3EAC + arm_func_start Callback_Dummy_S +Callback_Dummy_S: @ 82E3EAC bx r1 - arm_func_end sub_82E3EAC + arm_func_end Callback_Dummy_S - arm_func_start sub_82E3EB0 -sub_82E3EB0: @ 82E3EB0 + arm_func_start Callback_Dummy_ID +Callback_Dummy_ID: @ 82E3EB0 bx r0 - arm_func_end sub_82E3EB0 + arm_func_end Callback_Dummy_ID diff --git a/common_syms/librfu.txt b/common_syms/librfu.txt index e81d78795..820c865be 100644 --- a/common_syms/librfu.txt +++ b/common_syms/librfu.txt @@ -1,6 +1,6 @@ -gUnknown_03007870 -gUnknown_03007880 -gUnknown_03007890 -gUnknown_03007894 -gUnknown_03007898 -gUnknown_030078A0 +gRfuSlotStatusUNI +gRfuSlotStatusNI +gRfuLinkStatus +gRfuStatic +gRfuFixed +gRfuSIO32Id diff --git a/common_syms/librfu_stwi.txt b/common_syms/librfu_stwi.txt index 0e8468f4d..a1f773553 100644 --- a/common_syms/librfu_stwi.txt +++ b/common_syms/librfu_stwi.txt @@ -1 +1 @@ -gRfuState +gSTWIStatus diff --git a/data/librfu_rodata.s b/data/librfu_rodata.s index aa8f5170d..679256541 100644 --- a/data/librfu_rodata.s +++ b/data/librfu_rodata.s @@ -1,6 +1,6 @@ .section .rodata -gUnknown_089A3220:: @ 89A3220 +llsf_struct:: @ 89A3220 .byte 2, 14, 0, 10, 9, 5, 7, 2 .byte 0, 15, 1, 3, 3, 0, 31, 0 .byte 3, 22, 18, 14, 13, 9, 11, 3 @@ -9,9 +9,9 @@ gUnknown_089A3220:: @ 89A3220 .asciz "RFU_V1026" .align 2 -gUnknown_089A324C:: @ 89A324C +str_checkMbootLL:: @ 89A324C .asciz "RFU-MBOOT" .align 2 -gUnknown_089A3258:: @ 89A3258 +Sio32ConnectionData:: @ 89A3258 .asciz "NINTENDOSio32ID_030820" diff --git a/include/librfu.h b/include/librfu.h index 55b5d264c..1806482e4 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -1,6 +1,7 @@ #ifndef GUARD_LIBRFU_H #define GUARD_LIBRFU_H +#include "global.h" #include "main.h" enum @@ -70,34 +71,7 @@ union RfuPacket struct RfuPacket8 rfuPacket8; }; -struct UnkLinkRfuStruct_02022B14Substruct -{ - u16 unk_00_0:4; - u16 unk_00_4:1; - u16 unk_00_5:1; - u16 unk_00_6:1; - u16 isChampion:1; - u16 hasNationalDex:1; - u16 gameClear:1; // never read, redundant with isChampion - u16 unk_01_2:4; // always 3? - u16 unk_01_6:2; - u8 playerTrainerId[2]; -}; - -struct __attribute__((packed, aligned(2))) UnkLinkRfuStruct_02022B14 -{ - struct UnkLinkRfuStruct_02022B14Substruct unk_00; - u8 unk_04[4]; - u16 species:10; - u16 type:6; - u8 unk_0a_0:7; - u8 unk_0a_7:1; - u8 playerGender:1; - u8 level:7; - u8 unk_0c; -}; - -struct RfuStruct +struct STWIStatus { vs32 unk_0; u8 txParams; @@ -133,7 +107,7 @@ struct RfuIntrStruct u8 block2[0x30]; }; -struct RfuUnk1 +struct RfuSlotStatusUNI { u16 unk_0; u8 unk_2; @@ -145,7 +119,7 @@ struct RfuUnk1 struct RfuIntrStruct unk_1c; }; -struct RfuUnk2 +struct RfuSlotStatusNI { u16 unk_0; u16 unk_2; @@ -164,7 +138,7 @@ struct RfuUnk2 u8 unk_70[0x70]; }; -struct RfuUnk3 +struct RfuFixed { u32 unk_0; u32 unk_4; @@ -172,17 +146,19 @@ struct RfuUnk3 u32 unk_dc; }; +#define RFU_GAME_NAME_LENGTH 13 // Possible length of game name set by rfu_REQB_configGameData +#define RFU_USER_NAME_LENGTH 8 + struct RfuUnk5Sub { u16 unk_00; u8 unk_02; u16 unk_04; - struct UnkLinkRfuStruct_02022B14 unk_06; - u8 fill_13[1]; - u8 playerName[PLAYER_NAME_LENGTH + 1]; + u8 gname[RFU_GAME_NAME_LENGTH + 2]; // Game name of parent candidate Game name of connection partner + u8 uname[RFU_USER_NAME_LENGTH + 1]; // User name for parent candidate User name for connection partner }; -struct RfuUnk5 +struct RfuLinkStatus { u8 unk_00; u8 unk_01; @@ -196,16 +172,16 @@ struct RfuUnk5 u8 filler_09[1]; u8 unk_0a[4]; u8 filler_0e[6]; - struct RfuUnk5Sub unk_14[4]; + struct RfuUnk5Sub unk_14[5]; }; -extern struct RfuStruct *gRfuState; +extern struct STWIStatus *gSTWIStatus; -extern struct RfuUnk5 *gUnknown_03007890; -extern u32 *gUnknown_03007894; -extern struct RfuUnk3* gUnknown_03007898; -extern struct RfuUnk2* gUnknown_03007880[4]; -extern struct RfuUnk1* gUnknown_03007870[4]; +extern struct RfuLinkStatus *gRfuLinkStatus; +extern u32 *gRfuStatic; +extern struct RfuFixed* gRfuFixed; +extern struct RfuSlotStatusNI* gRfuSlotStatusNI[4]; +extern struct RfuSlotStatusUNI* gRfuSlotStatusUNI[4]; extern void* sub_82E53F4; extern void rfu_STC_clearAPIVariables(void); @@ -221,7 +197,7 @@ void rfu_REQBN_watchLink(u16 a0, u8 *a1, u8 *a2, u8 *a3); bool16 rfu_syncVBlank(void); void rfu_REQ_reset(void); void rfu_REQ_configSystem(u16, u8, u8); -void rfu_REQ_configGameData(u8, u16, struct UnkLinkRfuStruct_02022B14 *, u8 *); +void rfu_REQ_configGameData(u8, u16, const u8 *gname, const u8 *uname); void rfu_REQ_startSearchChild(void); void rfu_REQ_pollSearchChild(void); void rfu_REQ_endSearchChild(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index 533e515c5..0c169dd26 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -6,6 +6,33 @@ // Exported type declarations +struct UnkLinkRfuStruct_02022B14Substruct +{ + u16 unk_00_0:4; + u16 unk_00_4:1; + u16 unk_00_5:1; + u16 unk_00_6:1; + u16 isChampion:1; + u16 hasNationalDex:1; + u16 gameClear:1; // never read, redundant with isChampion + u16 unk_01_2:4; // always 3? + u16 unk_01_6:2; + u8 playerTrainerId[2]; +}; + +struct __attribute__((packed, aligned(2))) UnkLinkRfuStruct_02022B14 +{ + struct UnkLinkRfuStruct_02022B14Substruct unk_00; + u8 unk_04[4]; + u16 species:10; + u16 type:6; + u8 unk_0a_0:7; + u8 unk_0a_7:1; + u8 playerGender:1; + u8 level:7; + u8 unk_0c; +}; + struct UnkLinkRfuStruct_02022B2C { u8 unk_00; diff --git a/include/union_room.h b/include/union_room.h index 54f09cbeb..cc0415155 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -1,7 +1,7 @@ #ifndef GUARD_UNION_ROOM_H #define GUARD_UNION_ROOM_H -#include "librfu.h" +#include "link_rfu.h" // Exported type declarations diff --git a/src/crt0.s b/src/crt0.s index 9ed678968..3ab711713 100644 --- a/src/crt0.s +++ b/src/crt0.s @@ -163,7 +163,7 @@ IntrMain: @ 8000248 IntrMain_FoundIntr: strh r0, [r3, OFFSET_REG_IF - 0x200] bic r2, r2, r0 - ldr r0, =gRfuState + ldr r0, =gSTWIStatus ldr r0, [r0] ldrb r0, [r0, 0xA] mov r1, 0x8 diff --git a/src/librfu.c b/src/librfu.c index cdf14b693..b84ba7ae5 100644 --- a/src/librfu.c +++ b/src/librfu.c @@ -1,9 +1,9 @@ #include "global.h" #include "librfu.h" -struct RfuUnk1* gUnknown_03007870[4]; -struct RfuUnk2* gUnknown_03007880[4]; -struct RfuUnk5 *gUnknown_03007890; -u32 *gUnknown_03007894; -struct RfuUnk3* gUnknown_03007898; -u8 gUnknown_030078A0[12]; +struct RfuSlotStatusUNI* gRfuSlotStatusUNI[4]; +struct RfuSlotStatusNI* gRfuSlotStatusNI[4]; +struct RfuLinkStatus *gRfuLinkStatus; +u32 *gRfuStatic; +struct RfuFixed* gRfuFixed; +u8 gRfuSIO32Id[12]; diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index c5aa25c10..7437bcecf 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -36,33 +36,33 @@ if (unk1 < num) return 1; } - gUnknown_03007890 = unk0; - gUnknown_03007894 = unk0 + (0xB4 / sizeof(u32)); - gUnknown_03007898 = (struct RfuUnk3*)(unk0 + (0xDC / sizeof(u32))); - gUnknown_03007880[0] = (struct RfuUnk2*)(unk0 + (0x1BC / sizeof(u32))); - gUnknown_03007870[0] = (struct RfuUnk1*)(unk0 + (0x37C / sizeof(u32))); + gRfuLinkStatus = unk0; + gRfuStatic = unk0 + (0xB4 / sizeof(u32)); + gRfuFixed = (struct RfuFixed*)(unk0 + (0xDC / sizeof(u32))); + gRfuSlotStatusNI[0] = (struct RfuSlotStatusNI*)(unk0 + (0x1BC / sizeof(u32))); + gRfuSlotStatusUNI[0] = (struct RfuSlotStatusUNI*)(unk0 + (0x37C / sizeof(u32))); for (i = 1; i < 4; i++, num) { - gUnknown_03007880[i] = (struct RfuUnk2*)&gUnknown_03007880[i-1]->unk_70; - gUnknown_03007870[i] = (struct RfuUnk1*)&gUnknown_03007870[i-1]->unk_1c; + gRfuSlotStatusNI[i] = (struct RfuSlotStatusNI*)&gRfuSlotStatusNI[i-1]->unk_70; + gRfuSlotStatusUNI[i] = (struct RfuSlotStatusUNI*)&gRfuSlotStatusUNI[i-1]->unk_1c; } - gUnknown_03007898->unk_dc = (u32)&gUnknown_03007870[3]->unk_1c; - STWI_init_all(&gUnknown_03007870[3]->unk_1c, interrupt, copyInterruptToRam); + gRfuFixed->unk_dc = (u32)&gRfuSlotStatusUNI[3]->unk_1c; + STWI_init_all(&gRfuSlotStatusUNI[3]->unk_1c, interrupt, copyInterruptToRam); rfu_STC_clearAPIVariables(); for (i = 0; i < 4; i++) { - gUnknown_03007880[i]->unk_68 = 0; - gUnknown_03007880[i]->unk_6c = 0; - gUnknown_03007870[i]->unk_14 = 0; - gUnknown_03007870[i]->unk_18 = 0; + gRfuSlotStatusNI[i]->unk_68 = 0; + gRfuSlotStatusNI[i]->unk_6c = 0; + gRfuSlotStatusUNI[i]->unk_14 = 0; + gRfuSlotStatusUNI[i]->unk_18 = 0; } // Not matching, register differences v12 = (u16*)((u32)&sub_82E53F4 & ~1); - v13 = (u16*)gUnknown_03007898->unk_8; + v13 = (u16*)gRfuFixed->unk_8; for (i = 47; i != 0xFFFF; i--) { @@ -71,7 +71,7 @@ ++v13; } - gUnknown_03007898->unk_4 = (u32)(&gUnknown_03007898->unk_8[1]); + gRfuFixed->unk_4 = (u32)(&gRfuFixed->unk_8[1]); return 0; }*/ diff --git a/src/librfu_stwi.c b/src/librfu_stwi.c index 670692118..45abaa70b 100644 --- a/src/librfu_stwi.c +++ b/src/librfu_stwi.c @@ -1,7 +1,7 @@ #include "global.h" #include "librfu.h" -struct RfuStruct *gRfuState; +struct STWIStatus *gSTWIStatus; extern IntrFunc IntrSIO32(void); @@ -22,34 +22,34 @@ int STWI_reset_ClockCounter(void); void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam) { // If we're copying our interrupt into RAM, DMA it to block1 and use - // block2 for our RfuStruct, otherwise block1 holds the RfuStruct. + // block2 for our STWIStatus, otherwise block1 holds the STWIStatus. // interrupt usually is a pointer to gIntrTable[1] if (copyInterruptToRam == TRUE) { *interrupt = (IntrFunc)interruptStruct->block1; DmaCopy16(3, &IntrSIO32, interruptStruct->block1, 0x960); - gRfuState = (struct RfuStruct*)interruptStruct->block2; + gSTWIStatus = (struct STWIStatus*)interruptStruct->block2; } else { *interrupt = (IntrFunc)IntrSIO32; - gRfuState = (struct RfuStruct*)interruptStruct->block1; + gSTWIStatus = (struct STWIStatus*)interruptStruct->block1; } - gRfuState->rxPacket = (union RfuPacket*)interruptStruct->rxPacketAlloc; - gRfuState->txPacket = (union RfuPacket*)interruptStruct->txPacketAlloc; - gRfuState->msMode = 1; - gRfuState->unk_0 = 0; - gRfuState->txParams = 0; - gRfuState->unk_5 = 0; - gRfuState->unk_7 = 0; - gRfuState->unk_8 = 0; - gRfuState->unk_9 = 0; - gRfuState->timerState = 0; - gRfuState->timerActive = 0; - gRfuState->unk_12 = 0; - gRfuState->unk_15 = 0; - gRfuState->unk_2c = 0; + gSTWIStatus->rxPacket = (union RfuPacket*)interruptStruct->rxPacketAlloc; + gSTWIStatus->txPacket = (union RfuPacket*)interruptStruct->txPacketAlloc; + gSTWIStatus->msMode = 1; + gSTWIStatus->unk_0 = 0; + gSTWIStatus->txParams = 0; + gSTWIStatus->unk_5 = 0; + gSTWIStatus->unk_7 = 0; + gSTWIStatus->unk_8 = 0; + gSTWIStatus->unk_9 = 0; + gSTWIStatus->timerState = 0; + gSTWIStatus->timerActive = 0; + gSTWIStatus->unk_12 = 0; + gSTWIStatus->unk_15 = 0; + gSTWIStatus->unk_2c = 0; REG_RCNT = 0x100; //TODO: mystery bit? REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS; @@ -62,9 +62,9 @@ void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, b void STWI_init_timer(IntrFunc *interrupt, int timerSelect) { *interrupt = STWI_intr_timer; - gRfuState->timerSelect = timerSelect; + gSTWIStatus->timerSelect = timerSelect; - IntrEnable(INTR_FLAG_TIMER0 << gRfuState->timerSelect); + IntrEnable(INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect); } void AgbRFU_SoftReset(void) @@ -74,8 +74,8 @@ void AgbRFU_SoftReset(void) REG_RCNT = 0x8000; REG_RCNT = 0x80A0; // all these bits are undocumented - timerL = ®_TMCNT_L(gRfuState->timerSelect); - timerH = ®_TMCNT_H(gRfuState->timerSelect); + timerL = ®_TMCNT_L(gSTWIStatus->timerSelect); + timerH = ®_TMCNT_H(gSTWIStatus->timerSelect); *timerH = 0; *timerL = 0; *timerH = 0x83; @@ -85,24 +85,24 @@ void AgbRFU_SoftReset(void) REG_RCNT = 0x80A0; REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS; - gRfuState->unk_0 = 0; - gRfuState->txParams = 0; - gRfuState->unk_5 = 0; - gRfuState->activeCommand = 0; - gRfuState->unk_7 = 0; - gRfuState->unk_8 = 0; - gRfuState->unk_9 = 0; - gRfuState->timerState = 0; - gRfuState->timerActive = 0; - gRfuState->unk_12 = 0; - gRfuState->msMode = 1; - gRfuState->unk_15 = 0; - gRfuState->unk_2c = 0; + gSTWIStatus->unk_0 = 0; + gSTWIStatus->txParams = 0; + gSTWIStatus->unk_5 = 0; + gSTWIStatus->activeCommand = 0; + gSTWIStatus->unk_7 = 0; + gSTWIStatus->unk_8 = 0; + gSTWIStatus->unk_9 = 0; + gSTWIStatus->timerState = 0; + gSTWIStatus->timerActive = 0; + gSTWIStatus->unk_12 = 0; + gSTWIStatus->msMode = 1; + gSTWIStatus->unk_15 = 0; + gSTWIStatus->unk_2c = 0; } void STWI_set_MS_mode(u8 mode) { - gRfuState->msMode = mode; + gSTWIStatus->msMode = mode; } u16 STWI_read_status(u8 index) @@ -110,13 +110,13 @@ u16 STWI_read_status(u8 index) switch (index) { case 0: - return gRfuState->unk_12; + return gSTWIStatus->unk_12; case 1: - return gRfuState->msMode; + return gSTWIStatus->msMode; case 2: - return gRfuState->unk_0; + return gSTWIStatus->unk_0; case 3: - return gRfuState->activeCommand; + return gSTWIStatus->activeCommand; default: return 0xFFFF; } @@ -134,31 +134,31 @@ void STWI_init_Callback_S(void) void STWI_set_Callback_M(void *callback) { - gRfuState->callbackM = callback; + gSTWIStatus->callbackM = callback; } void STWI_set_Callback_S(void *callback) { - gRfuState->callbackS = callback; + gSTWIStatus->callbackS = callback; } void STWI_set_Callback_ID(u32 id) { - gRfuState->callbackID = id; + gSTWIStatus->callbackID = id; } u16 STWI_poll_CommandEnd(void) { - while (gRfuState->unk_2c == TRUE) + while (gSTWIStatus->unk_2c == TRUE) ; - return gRfuState->unk_12; + return gSTWIStatus->unk_12; } void STWI_send_ResetREQ(void) { if (!STWI_init(RFU_RESET)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -167,7 +167,7 @@ void STWI_send_LinkStatusREQ(void) { if (!STWI_init(RFU_LINK_STATUS)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -176,7 +176,7 @@ void STWI_send_VersionStatusREQ(void) { if (!STWI_init(RFU_VERSION_STATUS)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -185,7 +185,7 @@ void STWI_send_SystemStatusREQ(void) { if (!STWI_init(RFU_SYSTEM_STATUS)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -194,7 +194,7 @@ void STWI_send_SlotStatusREQ(void) { if (!STWI_init(RFU_SLOT_STATUS)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -203,7 +203,7 @@ void STWI_send_ConfigStatusREQ(void) { if (!STWI_init(RFU_CONFIG_STATUS)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -215,10 +215,10 @@ void STWI_send_GameConfigREQ(u8 * unk1, u8 *data) if (!STWI_init(RFU_GAME_CONFIG)) { - gRfuState->txParams = 6; + gSTWIStatus->txParams = 6; //TODO: what is unk1 - packetBytes = gRfuState->txPacket->rfuPacket8.data; + packetBytes = gSTWIStatus->txPacket->rfuPacket8.data; packetBytes += sizeof(u32); *(u16*)packetBytes = *(u16*)unk1; @@ -249,9 +249,9 @@ void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3) { u8 *packetBytes; - gRfuState->txParams = 1; + gSTWIStatus->txParams = 1; - packetBytes = gRfuState->txPacket->rfuPacket8.data; + packetBytes = gSTWIStatus->txPacket->rfuPacket8.data; packetBytes += sizeof(u32); *packetBytes++ = unk3; @@ -265,7 +265,7 @@ void STWI_send_SC_StartREQ(void) { if (!STWI_init(RFU_SC_START)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -274,7 +274,7 @@ void STWI_send_SC_PollingREQ(void) { if (!STWI_init(RFU_SC_POLLING)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -283,7 +283,7 @@ void STWI_send_SC_EndREQ(void) { if (!STWI_init(RFU_SC_END)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -292,7 +292,7 @@ void STWI_send_SP_StartREQ(void) { if (!STWI_init(RFU_SP_START)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -301,7 +301,7 @@ void STWI_send_SP_PollingREQ(void) { if (!STWI_init(RFU_SP_POLLING)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -310,7 +310,7 @@ void STWI_send_SP_EndREQ(void) { if (!STWI_init(RFU_SP_END)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -319,8 +319,8 @@ void STWI_send_CP_StartREQ(u16 unk1) { if (!STWI_init(RFU_CP_START)) { - gRfuState->txParams = 1; - gRfuState->txPacket->rfuPacket32.data[0] = unk1; + gSTWIStatus->txParams = 1; + gSTWIStatus->txPacket->rfuPacket32.data[0] = unk1; STWI_start_Command(); } } @@ -329,7 +329,7 @@ void STWI_send_CP_PollingREQ(void) { if (!STWI_init(RFU_CP_POLLING)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -338,7 +338,7 @@ void STWI_send_CP_EndREQ(void) { if (!STWI_init(RFU_CP_END)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -351,8 +351,8 @@ void STWI_send_DataTxREQ(void *in, u8 size) if (size & (sizeof(u32) - 1)) txParams += 1; - gRfuState->txParams = txParams; - CpuCopy32(in, gRfuState->txPacket->rfuPacket32.data, gRfuState->txParams * sizeof(u32)); + gSTWIStatus->txParams = txParams; + CpuCopy32(in, gSTWIStatus->txPacket->rfuPacket32.data, gSTWIStatus->txParams * sizeof(u32)); STWI_start_Command(); } } @@ -365,8 +365,8 @@ void STWI_send_DataTxAndChangeREQ(void *in, u8 size) if (size & (sizeof(u32) - 1)) txParams += 1; - gRfuState->txParams = txParams; - CpuCopy32(in, gRfuState->txPacket->rfuPacket32.data, gRfuState->txParams * sizeof(u32)); + gSTWIStatus->txParams = txParams; + CpuCopy32(in, gSTWIStatus->txPacket->rfuPacket32.data, gSTWIStatus->txParams * sizeof(u32)); STWI_start_Command(); } } @@ -375,7 +375,7 @@ void STWI_send_DataRxREQ(void) { if (!STWI_init(RFU_DATA_RX)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -384,7 +384,7 @@ void STWI_send_MS_ChangeREQ(void) { if (!STWI_init(RFU_MS_CHANGE)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -395,15 +395,15 @@ void STWI_send_DataReadyAndChangeREQ(u8 unk) { if (!unk) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; } else { u8 *packetBytes; - gRfuState->txParams = 1; + gSTWIStatus->txParams = 1; - packetBytes = gRfuState->txPacket->rfuPacket8.data; + packetBytes = gSTWIStatus->txPacket->rfuPacket8.data; packetBytes += sizeof(u32); *packetBytes++ = unk; @@ -422,9 +422,9 @@ void STWI_send_DisconnectedAndChangeREQ(u8 unk0, u8 unk1) { u8 *packetBytes; - gRfuState->txParams = 1; + gSTWIStatus->txParams = 1; - packetBytes = gRfuState->txPacket->rfuPacket8.data; + packetBytes = gSTWIStatus->txPacket->rfuPacket8.data; packetBytes += sizeof(u32); *packetBytes++ = unk0; @@ -440,7 +440,7 @@ void STWI_send_ResumeRetransmitAndChangeREQ(void) { if (!STWI_init(RFU_RESUME_RETRANSMIT_AND_CHANGE)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -449,8 +449,8 @@ void STWI_send_DisconnectREQ(u8 unk) { if (!STWI_init(RFU_DISCONNECT)) { - gRfuState->txParams = 1; - gRfuState->txPacket->rfuPacket32.data[0] = unk; + gSTWIStatus->txParams = 1; + gSTWIStatus->txPacket->rfuPacket32.data[0] = unk; STWI_start_Command(); } @@ -460,8 +460,8 @@ void STWI_send_TestModeREQ(u8 unk0, u8 unk1) { if (!STWI_init(RFU_TEST_MODE)) { - gRfuState->txParams = 1; - gRfuState->txPacket->rfuPacket32.data[0] = unk0 | (unk1 << 8); + gSTWIStatus->txParams = 1; + gSTWIStatus->txPacket->rfuPacket32.data[0] = unk0 | (unk1 << 8); STWI_start_Command(); } @@ -474,10 +474,10 @@ void STWI_send_CPR_StartREQ(u16 unk0, u16 unk1, u8 unk2) if (!STWI_init(RFU_CPR_START)) { - gRfuState->txParams = 2; + gSTWIStatus->txParams = 2; arg1 = unk1 | (unk0 << 16); - packetData = gRfuState->txPacket->rfuPacket32.data; + packetData = gSTWIStatus->txPacket->rfuPacket32.data; packetData[0] = arg1; packetData[1] = unk2; @@ -489,7 +489,7 @@ void STWI_send_CPR_PollingREQ(void) { if (!STWI_init(RFU_CPR_POLLING)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -498,7 +498,7 @@ void STWI_send_CPR_EndREQ(void) { if (!STWI_init(RFU_CPR_END)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } @@ -507,18 +507,18 @@ void STWI_send_StopModeREQ(void) { if (!STWI_init(RFU_STOP_MODE)) { - gRfuState->txParams = 0; + gSTWIStatus->txParams = 0; STWI_start_Command(); } } void STWI_intr_timer(void) { - switch (gRfuState->timerState) + switch (gSTWIStatus->timerState) { //TODO: Make an enum for these case 2: - gRfuState->timerActive = 1; + gSTWIStatus->timerActive = 1; STWI_set_timer(50); break; case 1: @@ -527,11 +527,11 @@ void STWI_intr_timer(void) STWI_restart_Command(); break; case 3: - gRfuState->timerActive = 1; + gSTWIStatus->timerActive = 1; STWI_stop_timer(); STWI_reset_ClockCounter(); - if (gRfuState->callbackM) - gRfuState->callbackM(255, 0); + if (gSTWIStatus->callbackM) + gSTWIStatus->callbackM(255, 0); break; } } @@ -541,79 +541,79 @@ void STWI_set_timer(u8 unk) vu16 *timerL; vu16 *timerH; - timerL = ®_TMCNT_L(gRfuState->timerSelect); - timerH = ®_TMCNT_H(gRfuState->timerSelect); + timerL = ®_TMCNT_L(gSTWIStatus->timerSelect); + timerH = ®_TMCNT_H(gSTWIStatus->timerSelect); REG_IME = 0; switch (unk) { case 50: *timerL = 0xFCCB; - gRfuState->timerState = 1; + gSTWIStatus->timerState = 1; break; case 80: *timerL = 0xFAE0; - gRfuState->timerState = 2; + gSTWIStatus->timerState = 2; break; case 100: *timerL = 0xF996; - gRfuState->timerState = 3; + gSTWIStatus->timerState = 3; break; case 130: *timerL = 0xF7AD; - gRfuState->timerState = 4; + gSTWIStatus->timerState = 4; break; } *timerH = TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_1024CLK; - REG_IF = INTR_FLAG_TIMER0 << gRfuState->timerSelect; + REG_IF = INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect; REG_IME = 1; } void STWI_stop_timer(void) { - gRfuState->timerState = 0; + gSTWIStatus->timerState = 0; - REG_TMCNT_L(gRfuState->timerSelect) = 0; - REG_TMCNT_H(gRfuState->timerSelect) = 0; + REG_TMCNT_L(gSTWIStatus->timerSelect) = 0; + REG_TMCNT_H(gSTWIStatus->timerSelect) = 0; } u16 STWI_init(u8 request) { if (!REG_IME) { - gRfuState->unk_12 = 6; - if (gRfuState->callbackM) - gRfuState->callbackM(request, gRfuState->unk_12); + gSTWIStatus->unk_12 = 6; + if (gSTWIStatus->callbackM) + gSTWIStatus->callbackM(request, gSTWIStatus->unk_12); return TRUE; } - else if (gRfuState->unk_2c == TRUE) + else if (gSTWIStatus->unk_2c == TRUE) { - gRfuState->unk_12 = 2; - gRfuState->unk_2c = FALSE; - if (gRfuState->callbackM) - gRfuState->callbackM(request, gRfuState->unk_12); + gSTWIStatus->unk_12 = 2; + gSTWIStatus->unk_2c = FALSE; + if (gSTWIStatus->callbackM) + gSTWIStatus->callbackM(request, gSTWIStatus->unk_12); return TRUE; } - else if(!gRfuState->msMode) + else if(!gSTWIStatus->msMode) { - gRfuState->unk_12 = 4; - if (gRfuState->callbackM) - gRfuState->callbackM(request, gRfuState->unk_12, gRfuState); + gSTWIStatus->unk_12 = 4; + if (gSTWIStatus->callbackM) + gSTWIStatus->callbackM(request, gSTWIStatus->unk_12, gSTWIStatus); return TRUE; } else { - gRfuState->unk_2c = TRUE; - gRfuState->activeCommand = request; - gRfuState->unk_0 = 0; - gRfuState->txParams = 0; - gRfuState->unk_5 = 0; - gRfuState->unk_7 = 0; - gRfuState->unk_8 = 0; - gRfuState->unk_9 = 0; - gRfuState->timerState = 0; - gRfuState->timerActive = 0; - gRfuState->unk_12 = 0; - gRfuState->unk_15 = 0; + gSTWIStatus->unk_2c = TRUE; + gSTWIStatus->activeCommand = request; + gSTWIStatus->unk_0 = 0; + gSTWIStatus->txParams = 0; + gSTWIStatus->unk_5 = 0; + gSTWIStatus->unk_7 = 0; + gSTWIStatus->unk_8 = 0; + gSTWIStatus->unk_9 = 0; + gSTWIStatus->timerState = 0; + gSTWIStatus->timerActive = 0; + gSTWIStatus->unk_12 = 0; + gSTWIStatus->unk_15 = 0; REG_RCNT = 0x100; REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS; @@ -626,15 +626,15 @@ int STWI_start_Command() u16 imeTemp; // Yes, it matters that it's casted to a u32... - *(u32*)gRfuState->txPacket->rfuPacket8.data = 0x99660000 | (gRfuState->txParams << 8) | gRfuState->activeCommand; - REG_SIODATA32 = gRfuState->txPacket->rfuPacket32.command; + *(u32*)gSTWIStatus->txPacket->rfuPacket8.data = 0x99660000 | (gSTWIStatus->txParams << 8) | gSTWIStatus->activeCommand; + REG_SIODATA32 = gSTWIStatus->txPacket->rfuPacket32.command; - gRfuState->unk_0 = 0; - gRfuState->unk_5 = 1; + gSTWIStatus->unk_0 = 0; + gSTWIStatus->unk_5 = 1; imeTemp = REG_IME; REG_IME = 0; - REG_IE |= (INTR_FLAG_TIMER0 << gRfuState->timerSelect); + REG_IE |= (INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect); REG_IE |= INTR_FLAG_SERIAL; REG_IME = imeTemp; @@ -645,30 +645,30 @@ int STWI_start_Command() int STWI_restart_Command(void) { - if (gRfuState->unk_15 <= 1) + if (gSTWIStatus->unk_15 <= 1) { - gRfuState->unk_15++; + gSTWIStatus->unk_15++; STWI_start_Command(); } else { - if (gRfuState->activeCommand == RFU_MS_CHANGE || gRfuState->activeCommand == RFU_DATA_TX_AND_CHANGE || gRfuState->activeCommand == RFU_UNK35 || gRfuState->activeCommand == RFU_RESUME_RETRANSMIT_AND_CHANGE) + if (gSTWIStatus->activeCommand == RFU_MS_CHANGE || gSTWIStatus->activeCommand == RFU_DATA_TX_AND_CHANGE || gSTWIStatus->activeCommand == RFU_UNK35 || gSTWIStatus->activeCommand == RFU_RESUME_RETRANSMIT_AND_CHANGE) { - gRfuState->unk_12 = 1; - gRfuState->unk_2c = 0; + gSTWIStatus->unk_12 = 1; + gSTWIStatus->unk_2c = 0; - if (gRfuState->callbackM) - gRfuState->callbackM(gRfuState->activeCommand, gRfuState->unk_12); + if (gSTWIStatus->callbackM) + gSTWIStatus->callbackM(gSTWIStatus->activeCommand, gSTWIStatus->unk_12); } else { - gRfuState->unk_12 = 1; - gRfuState->unk_2c = 0; + gSTWIStatus->unk_12 = 1; + gSTWIStatus->unk_2c = 0; - if (gRfuState->callbackM) - gRfuState->callbackM(gRfuState->activeCommand, gRfuState->unk_12); + if (gSTWIStatus->callbackM) + gSTWIStatus->callbackM(gSTWIStatus->activeCommand, gSTWIStatus->unk_12); - gRfuState->unk_0 = 4; //TODO: what's 4 + gSTWIStatus->unk_0 = 4; //TODO: what's 4 } } @@ -677,9 +677,9 @@ int STWI_restart_Command(void) int STWI_reset_ClockCounter(void) { - gRfuState->unk_0 = 5; //TODO: what is 5 - gRfuState->txParams = 0; - gRfuState->unk_5 = 0; + gSTWIStatus->unk_0 = 5; //TODO: what is 5 + gSTWIStatus->txParams = 0; + gSTWIStatus->unk_5 = 0; REG_SIODATA32 = (1 << 31); REG_SIOCNT = 0; REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS; diff --git a/src/link_rfu.c b/src/link_rfu.c index cedc6b2fb..6f45b528e 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -364,7 +364,7 @@ u32 sub_800BEC0(void) void rfu_REQ_sendData_wrapper(u8 r2) { u8 val; - if (!gUnknown_03007890->unk_00) + if (!gRfuLinkStatus->unk_00) { val = gUnknown_03004140.unk_02; r2 = 0; @@ -515,14 +515,14 @@ u8 sub_800C12C(u16 r6, u16 r8) sub_800D30C(0xF3, 0x01); return 2; } - for (i = 0; i < gUnknown_03007890->unk_08; i++) + for (i = 0; i < gRfuLinkStatus->unk_08; i++) { - if (gUnknown_03007890->unk_14[i].unk_00 == r6) + if (gRfuLinkStatus->unk_14[i].unk_00 == r6) { break; } } - if (gUnknown_03007890->unk_08 == 0 || i == gUnknown_03007890->unk_08) + if (gRfuLinkStatus->unk_08 == 0 || i == gRfuLinkStatus->unk_08) { gUnknown_03004140.unk_14 = 3; sub_800D30C(0xF3, 0x01); @@ -561,7 +561,7 @@ void sub_800C210(u8 a0) gUnknown_03004140.unk_34[i] = 0; } } - i = gUnknown_03007890->unk_03 & a0; + i = gRfuLinkStatus->unk_03 & a0; if (i) { sub_800D334(i); @@ -630,8 +630,8 @@ void sub_800C27C(bool8 a0) case 16: gUnknown_03004140.unk_04 = gUnknown_03004140.unk_11; gUnknown_03004140.unk_05 = gUnknown_03004140.unk_12; - sub_800D334(gUnknown_03007890->unk_03); - gUnknown_03004140.unk_14 = gUnknown_03007890->unk_03; + sub_800D334(gRfuLinkStatus->unk_03); + gUnknown_03004140.unk_14 = gRfuLinkStatus->unk_03; sub_800D30C(0x33, 0x01); return; case 17: @@ -703,7 +703,7 @@ bool8 sub_800C36C(u16 a0) } sub_800D610(); } - if (gUnknown_03007890->unk_00 == 1) + if (gRfuLinkStatus->unk_00 == 1) { if (sp2) { @@ -800,7 +800,7 @@ void sub_800C54C(u32 a0) rfu_REQ_configSystem(gUnknown_03004140.unk_3c->unk_02, gUnknown_03004140.unk_3c->unk_00, gUnknown_03004140.unk_3c->unk_01); break; case 4: - rfu_REQ_configGameData(gUnknown_03004140.unk_3c->unk_04, gUnknown_03004140.unk_3c->unk_06, gUnknown_03004140.unk_3c->unk_08, gUnknown_03004140.unk_3c->unk_0c); + rfu_REQ_configGameData(gUnknown_03004140.unk_3c->unk_04, gUnknown_03004140.unk_3c->unk_06, (const u8 *)gUnknown_03004140.unk_3c->unk_08, gUnknown_03004140.unk_3c->unk_0c); break; case 5: rfu_REQ_startSearchChild(); @@ -834,7 +834,7 @@ void sub_800C54C(u32 a0) case 15: break; case 16: - rfu_REQ_CHILD_startConnectRecovery(gUnknown_03007890->unk_03); + rfu_REQ_CHILD_startConnectRecovery(gRfuLinkStatus->unk_03); break; case 17: rfu_REQ_CHILD_pollConnectRecovery(); @@ -857,7 +857,7 @@ void sub_800C54C(u32 a0) gUnknown_03004140.unk_0e = 0; } } while (gUnknown_03004140.unk_04 == 18 || gUnknown_03004140.unk_04 == 19); - if (gUnknown_03007890->unk_00 != 1 || !sub_800C36C(0)) + if (gRfuLinkStatus->unk_00 != 1 || !sub_800C36C(0)) { sub_800CF34(); sub_800D158(); @@ -983,7 +983,7 @@ static void sub_800C7B4(u16 r8, u16 r6) { sub_800D30C(0x20, 0x01); } - if (gUnknown_03004140.unk_0b && gUnknown_03004140.unk_1a != 1 && gUnknown_03007890->unk_08 == 4) + if (gUnknown_03004140.unk_0b && gUnknown_03004140.unk_1a != 1 && gRfuLinkStatus->unk_08 == 4) { rfu_REQ_endSearchParent(); rfu_waitREQComplete(); @@ -1059,11 +1059,11 @@ static void sub_800C7B4(u16 r8, u16 r6) case 50: if (r6 == 0) { - gUnknown_03004140.unk_14 = gUnknown_03007890->unk_03; + gUnknown_03004140.unk_14 = gRfuLinkStatus->unk_03; gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 17; for (gUnknown_03004140.unk_10 = 0; gUnknown_03004140.unk_10 < 4; gUnknown_03004140.unk_10 ++) { - if ((gUnknown_03007890->unk_03 >> gUnknown_03004140.unk_10) & 1) + if ((gRfuLinkStatus->unk_03 >> gUnknown_03004140.unk_10) & 1) { break; } @@ -1092,7 +1092,7 @@ static void sub_800C7B4(u16 r8, u16 r6) else { gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0; - sub_800D334(gUnknown_03007890->unk_03); + sub_800D334(gRfuLinkStatus->unk_03); gUnknown_03004140.unk_1e = 0x33; } gUnknown_03004140.unk_34[gUnknown_03004140.unk_10] = 0; @@ -1126,7 +1126,7 @@ static void sub_800C7B4(u16 r8, u16 r6) { gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0; sub_800D610(); - sub_800D334(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03); + sub_800D334(gRfuLinkStatus->unk_02 | gRfuLinkStatus->unk_03); gUnknown_03004140.unk_14 = sp0; sub_800D30C(0x25, 0x01); } @@ -1148,10 +1148,10 @@ static void sub_800C7B4(u16 r8, u16 r6) rfu_REQ_RFUStatus(); rfu_waitREQComplete(); rfu_getRFUStatus(&sp0); - if (sp0 == 0 && gUnknown_03007890->unk_00 == 0) + if (sp0 == 0 && gRfuLinkStatus->unk_00 == 0) { stwiRecvBuffer = rfu_getSTWIRecvBuffer(); - stwiRecvBuffer[4] = gUnknown_03007890->unk_02; + stwiRecvBuffer[4] = gRfuLinkStatus->unk_02; stwiRecvBuffer[5] = 1; sub_800C36C(0x29); r6 = 0; @@ -1191,7 +1191,7 @@ static void sub_800C7B4(u16 r8, u16 r6) gUnknown_03004140.unk_00 &= ~gUnknown_03004140.unk_14; if (gUnknown_03004140.unk_07) { - if (gUnknown_03007890->unk_00 == 0xFF) + if (gRfuLinkStatus->unk_00 == 0xFF) { if (gUnknown_03004140.unk_07 == 8) { @@ -1206,7 +1206,7 @@ static void sub_800C7B4(u16 r8, u16 r6) } } } - if (gUnknown_03007890->unk_00 == 0xFF) + if (gRfuLinkStatus->unk_00 == 0xFF) { if (gUnknown_03004140.unk_04 == 0) { @@ -1221,7 +1221,7 @@ static void sub_800C7B4(u16 r8, u16 r6) break; case 38: sub_800D20C(); - if (gUnknown_03007890->unk_00 != 0xFF) + if (gRfuLinkStatus->unk_00 != 0xFF) { sub_800D30C(0x50, 0x00); } @@ -1246,8 +1246,8 @@ static void sub_800C7B4(u16 r8, u16 r6) { if (r8 == 28 && r6 != 0 && gUnknown_03004140.unk_07 == 4) { - gUnknown_03007890->unk_00 = 1; - gUnknown_03007890->unk_02 = 15; + gRfuLinkStatus->unk_00 = 1; + gRfuLinkStatus->unk_02 = 15; sub_800D334(15); rfu_waitREQComplete(); return; @@ -1279,7 +1279,7 @@ static void sub_800CEB0(u16 r6) r7 = gUnknown_03004140.unk_0e; gUnknown_03004140.unk_0e = 0; gUnknown_03004140.unk_0f = 1; - if (gUnknown_03007890->unk_00 == 0) + if (gRfuLinkStatus->unk_00 == 0) { sub_800C36C(r6); if (gUnknown_03004140.unk_02 != 1) @@ -1321,8 +1321,8 @@ static void sub_800CF34(void) if (gUnknown_03004140.unk_04 == 5 || gUnknown_03004140.unk_04 == 6 || gUnknown_03004140.unk_04 == 7 || gUnknown_03004140.unk_04 == 8) { - flags = ((gUnknown_03007890->unk_02 ^ gUnknown_03004140.unk_0c) & gUnknown_03007890->unk_02) & ~gUnknown_03007890->unk_07; - gUnknown_03004140.unk_0c = gUnknown_03007890->unk_02; + flags = ((gRfuLinkStatus->unk_02 ^ gUnknown_03004140.unk_0c) & gRfuLinkStatus->unk_02) & ~gRfuLinkStatus->unk_07; + gUnknown_03004140.unk_0c = gRfuLinkStatus->unk_02; if (flags) { gUnknown_03004140.unk_14 = flags; @@ -1340,14 +1340,14 @@ static void sub_800CF34(void) } else if (gUnknown_03004140.unk_24 & r4) { - if (gUnknown_03007880[i]->unk_34 == 0x46) + if (gRfuSlotStatusNI[i]->unk_34 == 0x46) { - if (gUnknown_03007880[i]->unk_61 == 1) + if (gRfuSlotStatusNI[i]->unk_61 == 1) { r5 = 0x02; for (ptr = gUnknown_03004140.unk_20; *ptr != 0xFFFF; ptr++) { - if (gUnknown_03007890->unk_14[i].unk_04 == *ptr) + if (gRfuLinkStatus->unk_14[i].unk_04 == *ptr) { gUnknown_03004140.unk_00 |= r4; gUnknown_03004140.unk_01++; @@ -1386,7 +1386,7 @@ static void sub_800CF34(void) if (gUnknown_03004140.unk_0d) { r5 = 0x01; - if (gUnknown_03007890->unk_06 && ((gUnknown_03004140.unk_03 & gUnknown_03004140.unk_00) != gUnknown_03004140.unk_00)) + if (gRfuLinkStatus->unk_06 && ((gUnknown_03004140.unk_03 & gUnknown_03004140.unk_00) != gUnknown_03004140.unk_00)) { r5 = 0x00; } @@ -1434,7 +1434,7 @@ static void sub_800D158(void) REG_IME = 0; if (gUnknown_03004140.unk_04 == 15) { - if (--gUnknown_03004140.unk_28[gUnknown_03004140.unk_10] == 0 || gUnknown_03007880[gUnknown_03004140.unk_10]->unk_0 == 0x27) + if (--gUnknown_03004140.unk_28[gUnknown_03004140.unk_10] == 0 || gRfuSlotStatusNI[gUnknown_03004140.unk_10]->unk_0 == 0x27) { sub_800D630(); gUnknown_03004140.unk_04 = 24; @@ -1453,7 +1453,7 @@ static void sub_800D158(void) if (gUnknown_03004140.unk_02 == 0) { gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0; - sub_800D334(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03); + sub_800D334(gRfuLinkStatus->unk_02 | gRfuLinkStatus->unk_03); gUnknown_03004140.unk_14 = 0; sub_800D30C(0x25, 0x01); } @@ -1462,7 +1462,7 @@ static void sub_800D158(void) static void sub_800D20C(void) { - if (gUnknown_03004140.unk_04 == 15 && gUnknown_03007880[gUnknown_03004140.unk_10]->unk_0 == 0x26) + if (gUnknown_03004140.unk_04 == 15 && gRfuSlotStatusNI[gUnknown_03004140.unk_10]->unk_0 == 0x26) { gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0; rfu_clearSlot(4, gUnknown_03004140.unk_10); @@ -1490,11 +1490,11 @@ static u8 sub_800D294(void) const u16 *ptr; u8 flags = 0x00; - for (i = 0; i < gUnknown_03007890->unk_08; i++) + for (i = 0; i < gRfuLinkStatus->unk_08; i++) { for (ptr = gUnknown_03004140.unk_20; *ptr != 0xFFFF; ptr++) { - if (gUnknown_03007890->unk_14[i].unk_04 == *ptr) + if (gRfuLinkStatus->unk_14[i].unk_04 == *ptr) { flags |= (1 << i); } @@ -1525,34 +1525,34 @@ static void sub_800D358(u8 a0) { u8 i; - if (gUnknown_03007890->unk_04) + if (gRfuLinkStatus->unk_04) { for (i = 0; i < 4; i++) { - if (gUnknown_03007880[i]->unk_0 & 0x8000 && gUnknown_03007880[i]->unk_1a & a0) + if (gRfuSlotStatusNI[i]->unk_0 & 0x8000 && gRfuSlotStatusNI[i]->unk_1a & a0) { - rfu_changeSendTarget(0x20, i, gUnknown_03007880[i]->unk_1a & ~a0); + rfu_changeSendTarget(0x20, i, gRfuSlotStatusNI[i]->unk_1a & ~a0); } } } - if (gUnknown_03007890->unk_05) + if (gRfuLinkStatus->unk_05) { for (i = 0; i < 4; i++) { - if (gUnknown_03007880[i]->unk_34 & 0x8000 && gUnknown_03007880[i]->unk_4e & a0) + if (gRfuSlotStatusNI[i]->unk_34 & 0x8000 && gRfuSlotStatusNI[i]->unk_4e & a0) { rfu_NI_stopReceivingData(i); } } } - if (gUnknown_03007890->unk_06) + if (gRfuLinkStatus->unk_06) { - gUnknown_03007890->unk_06 &= ~a0; + gRfuLinkStatus->unk_06 &= ~a0; for (i = 0; i < 4; i++) { - if (gUnknown_03007870[i]->unk_0 == 0x8024 && a0 & gUnknown_03007870[i]->unk_3) + if (gRfuSlotStatusUNI[i]->unk_0 == 0x8024 && a0 & gRfuSlotStatusUNI[i]->unk_3) { - gUnknown_03007870[i]->unk_3 &= ~a0; + gRfuSlotStatusUNI[i]->unk_3 &= ~a0; } } } @@ -1566,32 +1566,32 @@ static void sub_800D434(void) if (gUnknown_03004140.unk_18) { - if (gUnknown_03007890->unk_04) + if (gRfuLinkStatus->unk_04) { for (i = 0; i < 4; i ++) { - if (gUnknown_03007880[i]->unk_0 & 0x8000) + if (gRfuSlotStatusNI[i]->unk_0 & 0x8000) { flags = 0; for (j = 0; j < 4; j++) { - if ((gUnknown_03007880[i]->unk_1a >> j) & 1 && gUnknown_03007880[j]->unk_2 > gUnknown_03004140.unk_18) + if ((gRfuSlotStatusNI[i]->unk_1a >> j) & 1 && gRfuSlotStatusNI[j]->unk_2 > gUnknown_03004140.unk_18) { flags |= (1 << j); } if (flags) { - rfu_changeSendTarget(0x20, i, flags ^ gUnknown_03007880[i]->unk_1a); + rfu_changeSendTarget(0x20, i, flags ^ gRfuSlotStatusNI[i]->unk_1a); } } } } } - if (gUnknown_03007890->unk_05) + if (gRfuLinkStatus->unk_05) { for (i = 0; i < 4; i++) { - if (gUnknown_03007880[i]->unk_34 & 0x8000 && gUnknown_03007880[i]->unk_36 > gUnknown_03004140.unk_18) + if (gRfuSlotStatusNI[i]->unk_34 & 0x8000 && gRfuSlotStatusNI[i]->unk_36 > gUnknown_03004140.unk_18) { rfu_NI_stopReceivingData(i); } @@ -1628,7 +1628,7 @@ u8 sub_800D550(u8 a0, u16 a1) u8 sub_800D594(u16 a0) { - if (gUnknown_03007890->unk_04 | gUnknown_03007890->unk_05) + if (gRfuLinkStatus->unk_04 | gRfuLinkStatus->unk_05) { gUnknown_03004140.unk_14 = 6; sub_800D30C(0xf3, 0x01); @@ -2049,17 +2049,17 @@ void ASCIIToPkmnStr(u8 *q1, const u8 *q2) u8 sub_800DD1C(u8 maxFlags) { u8 flagCount = 0; - u32 flags = gUnknown_03007890->unk_02; + u32 flags = gRfuLinkStatus->unk_02; u8 i; - if (gUnknown_03007890->unk_00 == 1) + if (gRfuLinkStatus->unk_00 == 1) { for (i = 0; i < 4; flags >>= 1, i++) { if (flags & 1) { if (maxFlags == flagCount + 1) - return gUnknown_03007890->unk_0a[i]; + return gRfuLinkStatus->unk_0a[i]; flagCount++; } } @@ -2069,7 +2069,7 @@ u8 sub_800DD1C(u8 maxFlags) for (i = 0; i < 4; flags >>= 1, i++) { if (flags & 1) - return gUnknown_03007890->unk_0a[i]; + return gRfuLinkStatus->unk_0a[i]; } } return 0; @@ -2081,7 +2081,7 @@ NAKED u8 sub_800DD1C(u8 maxFlags) "\tlsls r0, 24\n" "\tlsrs r5, r0, 24\n" "\tmovs r6, 0\n" - "\tldr r0, =gUnknown_03007890\n" + "\tldr r0, =gRfuLinkStatus\n" "\tldr r4, [r0]\n" "\tldrb r2, [r4, 0x2]\n" "\tldrb r1, [r4]\n" @@ -2177,24 +2177,24 @@ bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx) if (gUnknown_03004140.unk_06 == 1) { retVal = TRUE; - if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04) && ((gUnknown_03007890->unk_07 >> idx) & 1)) + if (sub_8010454(gRfuLinkStatus->unk_14[idx].unk_04) && ((gRfuLinkStatus->unk_07 >> idx) & 1)) { - memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, 0xD); - memcpy(buff2, gUnknown_03007890->unk_14[idx].playerName, PLAYER_NAME_LENGTH + 1); + memcpy(buff1, gRfuLinkStatus->unk_14[idx].gname, 0xD); + memcpy(buff2, gRfuLinkStatus->unk_14[idx].uname, PLAYER_NAME_LENGTH + 1); } else { memset(buff1, 0, 0xD); - memset(buff2, 0, sizeof(gUnknown_03007890->unk_14[idx].playerName)); + memset(buff2, 0, PLAYER_NAME_LENGTH + 1); } } else { retVal = FALSE; - if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04)) + if (sub_8010454(gRfuLinkStatus->unk_14[idx].unk_04)) { - memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, 0xD); - memcpy(buff2, gUnknown_03007890->unk_14[idx].playerName, PLAYER_NAME_LENGTH + 1); + memcpy(buff1, gRfuLinkStatus->unk_14[idx].gname, 0xD); + memcpy(buff2, gRfuLinkStatus->unk_14[idx].uname, PLAYER_NAME_LENGTH + 1); } else { @@ -2208,10 +2208,10 @@ bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx) bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx) { bool8 retVal = FALSE; - if (gUnknown_03007890->unk_14[idx].unk_04 == 0x7F7D) + if (gRfuLinkStatus->unk_14[idx].unk_04 == 0x7F7D) { - memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, 0xD); - memcpy(buff2, gUnknown_03007890->unk_14[idx].playerName, 8); + memcpy(buff1, gRfuLinkStatus->unk_14[idx].gname, 0xD); + memcpy(buff2, gRfuLinkStatus->unk_14[idx].uname, 8); retVal = TRUE; } else @@ -2237,7 +2237,7 @@ void CreateWirelessStatusIndicatorSprite(u8 x, u8 y) x = 0xE7; y = 0x08; } - if (gUnknown_03007890->unk_00 == 1) + if (gRfuLinkStatus->unk_00 == 1) { sprId = CreateSprite(&sWirelessStatusIndicatorSpriteTemplate, x, y, 0); gSprites[sprId].data[7] = 0x1234; @@ -2278,12 +2278,12 @@ void LoadWirelessStatusIndicatorSpriteGfx(void) u8 sub_800E124(void) { u8 i; - u8 flags = gUnknown_03007890->unk_02; + u8 flags = gRfuLinkStatus->unk_02; for (i = 0; i < 4; i++) { if (flags & 1) { - return gUnknown_03007890->unk_0a[i]; + return gRfuLinkStatus->unk_0a[i]; } flags >>= 1; } @@ -2307,7 +2307,7 @@ void sub_800E174(void) struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId]; u8 signalStrength = 255; u8 i = 0; - if (gUnknown_03007890->unk_00 == 1) + if (gRfuLinkStatus->unk_00 == 1) { for (i = 0; i < GetLinkPlayerCount() - 1; i++) { @@ -2787,7 +2787,7 @@ void sub_800ED34(u16 unused) } rfu_REQ_recvData(); rfu_waitREQComplete(); - if (gUnknown_03007870[gUnknown_03005000.unk_c3e]->unk_12) + if (gRfuSlotStatusUNI[gUnknown_03005000.unk_c3e]->unk_12) { gUnknown_03005000.unk_cd0++; sub_800D7D8(&gUnknown_03005000.unk_124, gUnknown_03005000.unk_c3f); @@ -2858,7 +2858,7 @@ bool8 sub_800EE94(void) bool32 sub_800EEBC(void) { - if (gUnknown_03005000.unk_04 == 7 && !sub_800C12C(gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3d].unk_00, 240)) + if (gUnknown_03005000.unk_04 == 7 && !sub_800C12C(gRfuLinkStatus->unk_14[gUnknown_03005000.unk_c3d].unk_00, 240)) { gUnknown_03005000.unk_04 = 9; return TRUE; @@ -2971,7 +2971,7 @@ bool32 IsRfuRecvQueueEmpty(void) s32 i; s32 j; - if (gUnknown_03007890->unk_06 == 0) + if (gRfuLinkStatus->unk_06 == 0) { return FALSE; } @@ -2999,7 +2999,7 @@ bool32 sub_800F0F8(void) else { gUnknown_03005000.unk_cdb = 0; - if ((gUnknown_03005000.unk_ce2 & gUnknown_03007890->unk_02) == gUnknown_03005000.unk_ce2 && (gUnknown_03005000.unk_ce2 & gUnknown_03007890->unk_02)) + if ((gUnknown_03005000.unk_ce2 & gRfuLinkStatus->unk_02) == gUnknown_03005000.unk_ce2 && (gUnknown_03005000.unk_ce2 & gRfuLinkStatus->unk_02)) { if (!gUnknown_03005000.unk_cdc) { @@ -3119,7 +3119,7 @@ bool32 sub_800F1E0(void) gUnknown_03005000.unk_0e = 0; } retval = gUnknown_03005000.unk_cdc; - return gUnknown_03007890->unk_06 ? retval & 1 : FALSE; + return gRfuLinkStatus->unk_06 ? retval & 1 : FALSE; } void sub_800F498(u16 *a0, u8 *a1) @@ -3162,7 +3162,7 @@ bool32 sub_800F4F0(void) sub_800F86C(0); if (gUnknown_03004140.unk_02 == 0 && gUnknown_03005000.unk_ce4) { - rfu_REQ_disconnect(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03); + rfu_REQ_disconnect(gRfuLinkStatus->unk_02 | gRfuLinkStatus->unk_03); rfu_waitREQComplete(); switchval = sub_8011A74(); if (switchval != 1 && switchval != 6 && switchval != 9) @@ -3305,7 +3305,7 @@ static void sub_800F86C(u8 unused) return; // fallthrough case 0x7700: - if (gUnknown_03007890->unk_00 == 0) + if (gRfuLinkStatus->unk_00 == 0) { gUnknown_03005000.playerCount = gRecvCmds[i][1]; gUnknown_03005000.unk_cce = sub_800F74C((u8 *)(gRecvCmds[i] + 2)); @@ -3353,7 +3353,7 @@ static void sub_800F86C(u8 unused) { if (gReceivedRemoteLinkPlayers != 0) { - if (gRecvCmds[i][1] & gUnknown_03007890->unk_02) + if (gRecvCmds[i][1] & gRfuLinkStatus->unk_02) { gReceivedRemoteLinkPlayers = 0; sub_800D630(); @@ -3611,7 +3611,7 @@ void sub_801011C(void) void sub_8010148(void) { - rfu_REQ_disconnect(gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03); + rfu_REQ_disconnect(gRfuLinkStatus->unk_02 | gRfuLinkStatus->unk_03); rfu_waitREQComplete(); sub_801011C(); } @@ -3631,7 +3631,7 @@ void LinkRfu_FatalError(void) { sub_800D630(); gUnknown_03005000.unk_ce4 = 1; - gUnknown_03005000.unk_ce3 = gUnknown_03007890->unk_02 | gUnknown_03007890->unk_03; + gUnknown_03005000.unk_ce3 = gRfuLinkStatus->unk_02 | gRfuLinkStatus->unk_03; } void sub_80101CC(void) @@ -3821,7 +3821,7 @@ bool8 sub_8010540(void) { if (gUnknown_03005000.unk_cd1[i] < 5 || gUnknown_03005000.unk_cd1[i] > 6) { - if (gUnknown_03007880[i]->unk_34 == 0x46 || gUnknown_03007880[i]->unk_34 == 0x48) + if (gRfuSlotStatusNI[i]->unk_34 == 0x46 || gRfuSlotStatusNI[i]->unk_34 == 0x48) { if (gUnknown_03005000.unk_cd5[i] == 8) { @@ -3833,7 +3833,7 @@ bool8 sub_8010540(void) } } - else if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x47) + else if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->unk_34 == 0x47) rfu_clearSlot(8, i); { @@ -3898,7 +3898,7 @@ u32 sub_8010714(u16 a0, const u8 *a1) u8 r0 = sub_8011CE4(a1, a0); if (r0 == 0xFF) return 2; - if (gUnknown_03007880[r0]->unk_0 == 0) + if (gRfuSlotStatusNI[r0]->unk_0 == 0) return 1; return 0; } @@ -3910,7 +3910,7 @@ void sub_8010750(void) sub_8010540(); for (i = 0; i < 4; i++) { - if (gUnknown_03007880[i]->unk_0 == 0x26 || gUnknown_03007880[i]->unk_0 == 0x27) + if (gRfuSlotStatusNI[i]->unk_0 == 0x26 || gRfuSlotStatusNI[i]->unk_0 == 0x27) { if (gUnknown_03005000.unk_cd5[i] == 10) gUnknown_03005000.unk_cd5[i] = 11; @@ -3924,16 +3924,16 @@ s32 sub_80107A0(void) s32 retval = 0; if (gUnknown_03005000.unk_c85 == 8) { - if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_0 == 0x26 || gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_0 == 0x27) + if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->unk_0 == 0x26 || gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->unk_0 == 0x27) rfu_clearSlot(4, gUnknown_03005000.unk_c3e); } - if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x46 || gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x48) + if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->unk_34 == 0x46 || gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->unk_34 == 0x48) { rfu_clearSlot(8, gUnknown_03005000.unk_c3e); sub_8011A64(gUnknown_03005000.unk_c86, 0); retval = gUnknown_03005000.unk_c86; } - else if (gUnknown_03007880[gUnknown_03005000.unk_c3e]->unk_34 == 0x47) + else if (gRfuSlotStatusNI[gUnknown_03005000.unk_c3e]->unk_34 == 0x47) { rfu_clearSlot(8, gUnknown_03005000.unk_c3e); retval = 6; @@ -4282,14 +4282,14 @@ void sub_801103C(void) void sub_8011068(u8 a0) { gUnknown_02022B14.unk_0a_7 = a0; - rfu_REQ_configGameData(0, 2, &gUnknown_02022B14, gUnknown_02022B22); + rfu_REQ_configGameData(0, 2, (const u8 *)&gUnknown_02022B14, gUnknown_02022B22); } void sub_8011090(u8 a0, u32 a1, u32 a2) { if (a0) sub_8010F84(a0, a1, a2); - rfu_REQ_configGameData(0, 2, &gUnknown_02022B14, gUnknown_02022B22); + rfu_REQ_configGameData(0, 2, (const u8 *)&gUnknown_02022B14, gUnknown_02022B22); } void sub_80110B8(u32 a0) @@ -4370,7 +4370,7 @@ void sub_801120C(u8 a0, u8 unused1) { if ((gUnknown_03004140.unk_14 >> i) & 1) { - struct UnkLinkRfuStruct_02022B14 *structPtr = &gUnknown_03007890->unk_14[i].unk_06; + struct UnkLinkRfuStruct_02022B14 *structPtr = (void *)gRfuLinkStatus->unk_14[i].gname; if (structPtr->unk_0a_0 == sub_800F7DC()->unk_0a_0) { gUnknown_03005000.unk_cd1[i] = 0; @@ -4528,7 +4528,7 @@ u8 sub_8011628(s32 a0) { if ((a0 >> i) & 1) { - struct UnkLinkRfuStruct_02022B14 *structPtr = &gUnknown_03007890->unk_14[i].unk_06; + struct UnkLinkRfuStruct_02022B14 *structPtr = (void *)gRfuLinkStatus->unk_14[i].gname; if (structPtr->unk_0a_0 == 0x45) ret |= (1 << i); } @@ -4629,7 +4629,7 @@ void sub_8011674(u8 a0, u8 unused1) break; case 0x32: gUnknown_03005000.unk_f0 = 3; - if (gUnknown_03007890->unk_00 == 0) + if (gRfuLinkStatus->unk_00 == 0) gUnknown_03005000.unk_c3c = 1; break; case 0x30: @@ -4654,7 +4654,7 @@ void sub_8011674(u8 a0, u8 unused1) sub_800C27C(0); } - if (gUnknown_03007890->unk_00 == 0xFF && gUnknown_03004140.unk_07 == 0 && FuncIsActiveTask(sub_800EB44) == TRUE) + if (gRfuLinkStatus->unk_00 == 0xFF && gUnknown_03004140.unk_07 == 0 && FuncIsActiveTask(sub_800EB44) == TRUE) gUnknown_03005000.unk_04 = 0x11; sub_8011A64(2, a0); @@ -4825,13 +4825,13 @@ u8 sub_8011CE4(const u8 *a0, u16 a1) for (i = 0; i < 4; i++) { - u16 trainerId = ReadU16(gUnknown_03007890->unk_14[i].unk_06.unk_00.playerTrainerId); - if (sub_8010454(gUnknown_03007890->unk_14[i].unk_04) - && !StringCompare(a0, gUnknown_03007890->unk_14[i].playerName) + u16 trainerId = ReadU16(gRfuLinkStatus->unk_14[i].gname + 2); + if (sub_8010454(gRfuLinkStatus->unk_14[i].unk_04) + && !StringCompare(a0, gRfuLinkStatus->unk_14[i].uname) && a1 == trainerId) { ret = i; - if (gUnknown_03007890->unk_14[i].unk_02 != 0xFF) + if (gRfuLinkStatus->unk_14[i].unk_02 != 0xFF) break; } } @@ -4911,7 +4911,7 @@ void sub_8011EF4(u8 taskId) u8 id = sub_8011CE4((u8*)data, ReadU16(&data[8])); if (id != 0xFF) { - if (gUnknown_03007890->unk_14[id].unk_02 != 0xFF) + if (gRfuLinkStatus->unk_14[id].unk_02 != 0xFF) { gUnknown_03005000.unk_c3d = id; if (sub_800EEBC()) @@ -5006,9 +5006,9 @@ void sub_801209C(u8 taskId) u8 id = sub_8011CE4(gUnknown_03005000.playerName, trainerId); if (id != 0xFF) { - if (!sub_801200C(gTasks[taskId].data[1], &gUnknown_03007890->unk_14[id].unk_06)) + if (!sub_801200C(gTasks[taskId].data[1], (void *)gRfuLinkStatus->unk_14[id].gname)) { - if (gUnknown_03007890->unk_14[id].unk_02 != 0xFF && !sub_800C12C(gUnknown_03007890->unk_14[id].unk_00, 0x5A)) + if (gRfuLinkStatus->unk_14[id].unk_02 != 0xFF && !sub_800C12C(gRfuLinkStatus->unk_14[id].unk_00, 0x5A)) { gUnknown_03005000.unk_04 = 0xA; DestroyTask(taskId); @@ -5081,17 +5081,17 @@ void sub_801229C(void) s32 i, j; nullsub_13(GetBlockReceivedStatus(), 0x1C, 0x13, 2); - nullsub_13(gUnknown_03007890->unk_02, 0x14, 1, 1); - nullsub_13(gUnknown_03007890->unk_03, 0x17, 1, 1); + nullsub_13(gRfuLinkStatus->unk_02, 0x14, 1, 1); + nullsub_13(gRfuLinkStatus->unk_03, 0x17, 1, 1); if (gUnknown_03005000.unk_0c == 1) { for (i = 0; i < 4; i++) { - if ((gUnknown_03007890->unk_07 >> i) & 1) + if ((gRfuLinkStatus->unk_07 >> i) & 1) { - nullsub_13(gUnknown_03007890->unk_14[i].unk_04, 1, i + 3, 4); - nullsub_5((void*) &gUnknown_03007890->unk_14[i].unk_06, 6, i + 3); - nullsub_5(gUnknown_03007890->unk_14[i].playerName, 0x16, i + 3); + nullsub_13(gRfuLinkStatus->unk_14[i].unk_04, 1, i + 3, 4); + nullsub_5((void*)gRfuLinkStatus->unk_14[i].gname, 6, i + 3); + nullsub_5(gRfuLinkStatus->unk_14[i].uname, 0x16, i + 3); } } for (i = 0; i < 4; i++) @@ -5103,7 +5103,7 @@ void sub_801229C(void) } nullsub_5(gUnknown_082ED868, 1, 0xF); } - else if (gUnknown_03007890->unk_02 != 0 && gUnknown_03007890->unk_07 != 0) + else if (gRfuLinkStatus->unk_02 != 0 && gRfuLinkStatus->unk_07 != 0) { for (i = 0; i < 4; i++) { @@ -5111,19 +5111,19 @@ void sub_801229C(void) nullsub_5(gUnknown_082ED84B, 6, i + 3); nullsub_5(gUnknown_082ED85B, 0x16, i + 3); } - nullsub_13(gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3e].unk_04, 1, 3, 4); - nullsub_5((void*) &gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3e].unk_06, 6, 3); - nullsub_5(gUnknown_03007890->unk_14[gUnknown_03005000.unk_c3e].playerName, 0x16, 3); + nullsub_13(gRfuLinkStatus->unk_14[gUnknown_03005000.unk_c3e].unk_04, 1, 3, 4); + nullsub_5((void*)gRfuLinkStatus->unk_14[gUnknown_03005000.unk_c3e].gname, 6, 3); + nullsub_5(gRfuLinkStatus->unk_14[gUnknown_03005000.unk_c3e].uname, 0x16, 3); } else { - for (i = 0; i < gUnknown_03007890->unk_08; i++) + for (i = 0; i < gRfuLinkStatus->unk_08; i++) { - if (gUnknown_03007890->unk_14[i].unk_02 != 0xFF) + if (gRfuLinkStatus->unk_14[i].unk_02 != 0xFF) { - nullsub_13(gUnknown_03007890->unk_14[i].unk_04, 1, i + 3, 4); - nullsub_13(gUnknown_03007890->unk_14[i].unk_00, 6, i + 3, 4); - nullsub_5(gUnknown_03007890->unk_14[i].playerName, 0x16, i + 3); + nullsub_13(gRfuLinkStatus->unk_14[i].unk_04, 1, i + 3, 4); + nullsub_13(gRfuLinkStatus->unk_14[i].unk_00, 6, i + 3, 4); + nullsub_5(gRfuLinkStatus->unk_14[i].uname, 0x16, i + 3); } } for (; i < 4; i++) diff --git a/src/trade.c b/src/trade.c index a9a0b9b2a..9abc61428 100644 --- a/src/trade.c +++ b/src/trade.c @@ -254,7 +254,7 @@ static bool32 sub_80771BC(void) { if (gUnknown_02022C2C == 29) { - if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) + if (gRfuSlotStatusNI[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) return TRUE; else return FALSE; diff --git a/src/union_room.c b/src/union_room.c index 4eea421ba..9cb3bec79 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -4077,7 +4077,7 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) StringCopy(arg3->field_58 + 0x10, gSpeciesNames[sUnionRoomTrade.playerSpecies]); for (i = 0; i < 4; i++) { - if (gUnknown_03007890->unk_14[i].unk_04 == 2) + if (gRfuLinkStatus->unk_14[i].unk_04 == 2) { ConvertIntToDecimalStringN(arg3->field_58 + 0x20, arg2[2], STR_CONV_MODE_LEFT_ALIGN, 3); StringCopy(arg3->field_58 + 0x30, gSpeciesNames[arg2[1]]);