diff --git a/asm/librfu.s b/asm/librfu.s deleted file mode 100644 index 28cc015943..0000000000 --- a/asm/librfu.s +++ /dev/null @@ -1,6487 +0,0 @@ - .include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start rfu_initializeAPI -rfu_initializeAPI: @ 82E3EB4 - push {r4-r7,lr} - adds r4, r0, 0 - mov r12, r2 - lsls r1, 16 - lsrs r2, r1, 16 - lsls r3, 24 - lsrs r7, r3, 24 - movs r0, 0xF0 - lsls r0, 20 - ands r0, r4 - movs r1, 0x80 - lsls r1, 18 - cmp r0, r1 - bne _082E3ED4 - cmp r7, 0 - bne _082E3EDC -_082E3ED4: - movs r0, 0x3 - ands r0, r4 - cmp r0, 0 - beq _082E3EE0 -_082E3EDC: - movs r0, 0x2 - b _082E3FB8 -_082E3EE0: - cmp r7, 0 - beq _082E3EEC - ldr r3, =0x00000e64 - b _082E3EEE - .align 2, 0 - .pool -_082E3EEC: - ldr r3, =0x00000504 -_082E3EEE: - cmp r2, r3 - bcs _082E3EFC - movs r0, 0x1 - b _082E3FB8 - .align 2, 0 - .pool -_082E3EFC: - ldr r0, =gRfuLinkStatus - str r4, [r0] - ldr r1, =gRfuStatic - adds r0, r4, 0 - adds r0, 0xB4 - str r0, [r1] - ldr r1, =gRfuFixed - adds r0, 0x28 - str r0, [r1] - ldr r2, =gRfuSlotStatusNI - movs r1, 0xDE - lsls r1, 1 - adds r0, r4, r1 - str r0, [r2] - ldr r1, =gRfuSlotStatusUNI - movs r3, 0xDF - lsls r3, 2 - adds r0, r4, r3 - str r0, [r1] - movs r5, 0x1 - adds r6, r2, 0 - adds r4, r1, 0 -_082E3F28: - lsls r2, r5, 2 - adds r3, r2, r6 - subs r1, r5, 0x1 - lsls r1, 2 - adds r0, r1, r6 - ldr r0, [r0] - adds r0, 0x70 - str r0, [r3] - adds r2, r4 - adds r1, r4 - ldr r0, [r1] - adds r0, 0x1C - str r0, [r2] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x3 - bls _082E3F28 - ldr r0, =gRfuFixed - ldr r1, [r0] - adds r1, 0xDC - ldr r4, =gRfuSlotStatusUNI - ldr r0, [r4, 0xC] - adds r0, 0x1C - str r0, [r1] - mov r1, r12 - adds r2, r7, 0 - bl STWI_init_all - bl rfu_STC_clearAPIVariables - movs r5, 0 - ldr r3, =gRfuSlotStatusNI - movs r2, 0 -_082E3F6C: - lsls r1, r5, 2 - adds r0, r1, r3 - ldr r0, [r0] - str r2, [r0, 0x68] - str r2, [r0, 0x6C] - adds r1, r4 - ldr r0, [r1] - str r2, [r0, 0x14] - str r2, [r0, 0x18] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x3 - bls _082E3F6C - ldr r4, =sub_82E53F4 - movs r0, 0x2 - negs r0, r0 - ands r4, r0 - ldr r1, =gRfuFixed - ldr r0, [r1] - adds r2, r0, 0 - adds r2, 0x8 - movs r3, 0x2F - ldr r5, =0x0000ffff -_082E3F9C: - ldrh r0, [r4] - strh r0, [r2] - adds r4, 0x2 - adds r2, 0x2 - subs r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, r5 - bne _082E3F9C - ldr r1, [r1] - adds r0, r1, 0 - adds r0, 0x9 - str r0, [r1, 0x4] - movs r0, 0 -_082E3FB8: - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_initializeAPI - - thumb_func_start rfu_STC_clearAPIVariables -rfu_STC_clearAPIVariables: @ 82E3FDC - push {r4-r7,lr} - sub sp, 0x4 - ldr r1, =0x04000208 - ldrh r0, [r1] - adds r7, r0, 0 - movs r6, 0 - strh r6, [r1] - ldr r5, =gRfuStatic - ldr r1, [r5] - ldrb r4, [r1] - mov r0, sp - strh r6, [r0] - ldr r2, =0x01000014 - bl CpuSet - ldr r2, [r5] - movs r0, 0x8 - ands r4, r0 - movs r1, 0 - strb r4, [r2] - mov r0, sp - adds r0, 0x2 - strh r1, [r0] - ldr r4, =gRfuLinkStatus - ldr r1, [r4] - ldr r2, =0x0100005a - bl CpuSet - ldr r1, [r4] - movs r0, 0x4 - strb r0, [r1, 0x9] - ldr r0, [r5] - strb r6, [r0, 0x6] - ldr r1, [r4] - movs r0, 0xFF - strb r0, [r1] - bl rfu_clearAllSlot - ldr r0, [r5] - strb r6, [r0, 0x9] - movs r2, 0 - movs r3, 0 -_082E4030: - ldr r0, [r5] - lsls r1, r2, 1 - adds r0, 0x12 - adds r0, r1 - strh r3, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _082E4030 - ldr r0, =0x04000208 - strh r7, [r0] - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_clearAPIVariables - - thumb_func_start rfu_REQ_PARENT_resumeRetransmitAndChange -rfu_REQ_PARENT_resumeRetransmitAndChange: @ 82E4064 - push {lr} - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - bl STWI_send_ResumeRetransmitAndChangeREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_PARENT_resumeRetransmitAndChange - - thumb_func_start rfu_UNI_PARENT_getDRAC_ACK -rfu_UNI_PARENT_getDRAC_ACK: @ 82E4078 - push {r4,r5,lr} - adds r4, r0, 0 - movs r0, 0 - strb r0, [r4] - ldr r5, =gRfuLinkStatus - ldr r0, [r5] - ldrb r0, [r0] - cmp r0, 0x1 - beq _082E4094 - movs r0, 0xC0 - lsls r0, 2 - b _082E40BA - .align 2, 0 - .pool -_082E4094: - bl rfu_getSTWIRecvBuffer - adds r1, r0, 0 - ldrb r0, [r1] - cmp r0, 0x28 - beq _082E40A4 - cmp r0, 0x36 - bne _082E40B8 -_082E40A4: - ldrb r0, [r1, 0x1] - cmp r0, 0 - bne _082E40B0 - ldr r0, [r5] - ldrb r0, [r0, 0x2] - b _082E40B2 -_082E40B0: - ldrb r0, [r1, 0x4] -_082E40B2: - strb r0, [r4] - movs r0, 0 - b _082E40BA -_082E40B8: - movs r0, 0x10 -_082E40BA: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end rfu_UNI_PARENT_getDRAC_ACK - - thumb_func_start rfu_setTimerInterrupt -rfu_setTimerInterrupt: @ 82E40C0 - push {lr} - adds r2, r0, 0 - adds r0, r1, 0 - lsls r2, 24 - lsrs r2, 24 - adds r1, r2, 0 - bl STWI_init_timer - pop {r0} - bx r0 - thumb_func_end rfu_setTimerInterrupt - - thumb_func_start rfu_getSTWIRecvBuffer -rfu_getSTWIRecvBuffer: @ 82E40D4 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - bx lr - .align 2, 0 - .pool - thumb_func_end rfu_getSTWIRecvBuffer - - thumb_func_start rfu_setMSCCallback -rfu_setMSCCallback: @ 82E40E4 - push {lr} - bl STWI_set_Callback_S - pop {r0} - bx r0 - thumb_func_end rfu_setMSCCallback - - thumb_func_start rfu_setREQCallback -rfu_setREQCallback: @ 82E40F0 - push {lr} - adds r1, r0, 0 - ldr r0, =gRfuFixed - ldr r0, [r0] - str r1, [r0] - negs r0, r1 - orrs r0, r1 - lsrs r0, 31 - bl rfu_enableREQCallback - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_setREQCallback - - thumb_func_start rfu_enableREQCallback -rfu_enableREQCallback: @ 82E410C - push {lr} - lsls r0, 24 - cmp r0, 0 - beq _082E4124 - ldr r0, =gRfuStatic - ldr r2, [r0] - ldrb r1, [r2] - movs r0, 0x8 - orrs r0, r1 - b _082E412E - .align 2, 0 - .pool -_082E4124: - ldr r0, =gRfuStatic - ldr r2, [r0] - ldrb r1, [r2] - movs r0, 0xF7 - ands r0, r1 -_082E412E: - strb r0, [r2] - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_enableREQCallback - - thumb_func_start rfu_STC_REQ_callback -rfu_STC_REQ_callback: @ 82E4138 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r4, r1, 16 - ldr r0, =rfu_CB_defaultCallback - bl STWI_set_Callback_M - ldr r0, =gRfuStatic - ldr r0, [r0] - strh r4, [r0, 0x1C] - ldrb r1, [r0] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _082E4166 - ldr r0, =gRfuFixed - ldr r0, [r0] - ldr r2, [r0] - adds r0, r5, 0 - adds r1, r4, 0 - bl _call_via_r2 -_082E4166: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_REQ_callback - - thumb_func_start rfu_CB_defaultCallback -rfu_CB_defaultCallback: @ 82E4178 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r3, r1, 16 - cmp r0, 0xFF - bne _082E41D4 - ldr r0, =gRfuStatic - ldr r0, [r0] - ldrb r1, [r0] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _082E41A2 - ldr r0, =gRfuFixed - ldr r0, [r0] - ldr r2, [r0] - movs r0, 0xFF - adds r1, r3, 0 - bl _call_via_r2 -_082E41A2: - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r1, [r0, 0x2] - ldrb r0, [r0, 0x3] - adds r5, r0, 0 - orrs r5, r1 - movs r4, 0 -_082E41B0: - adds r0, r5, 0 - asrs r0, r4 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _082E41C2 - adds r0, r4, 0 - bl rfu_STC_removeLinkData -_082E41C2: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _082E41B0 - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - movs r0, 0xFF - strb r0, [r1] -_082E41D4: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_defaultCallback - - thumb_func_start rfu_waitREQComplete -rfu_waitREQComplete: @ 82E41E8 - push {lr} - bl STWI_poll_CommandEnd - ldr r0, =gRfuStatic - ldr r0, [r0] - ldrh r0, [r0, 0x1C] - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_waitREQComplete - - thumb_func_start rfu_REQ_RFUStatus -rfu_REQ_RFUStatus: @ 82E41FC - push {lr} - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - bl STWI_send_SystemStatusREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_RFUStatus - - thumb_func_start rfu_getRFUStatus -rfu_getRFUStatus: @ 82E4210 - push {r4,r5,lr} - adds r4, r0, 0 - ldr r5, =gRfuFixed - ldr r0, [r5] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x93 - beq _082E422C - movs r0, 0x10 - b _082E4246 - .align 2, 0 - .pool -_082E422C: - bl STWI_poll_CommandEnd - lsls r0, 16 - cmp r0, 0 - bne _082E4240 - ldr r0, [r5] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0, 0x7] - b _082E4242 -_082E4240: - movs r0, 0xFF -_082E4242: - strb r0, [r4] - movs r0, 0 -_082E4246: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end rfu_getRFUStatus - - thumb_func_start rfu_MBOOT_CHILD_inheritanceLinkStatus -rfu_MBOOT_CHILD_inheritanceLinkStatus: @ 82E424C - push {lr} - ldr r2, =str_checkMbootLL - ldr r3, =gDma3Requests + 0xE0 - b _082E4266 - .align 2, 0 - .pool -_082E425C: - ldrb r0, [r3] - adds r3, 0x1 - adds r2, 0x1 - cmp r1, r0 - bne _082E42BC -_082E4266: - ldrb r1, [r2] - cmp r1, 0 - bne _082E425C - movs r2, 0xC0 - lsls r2, 18 - movs r3, 0 - movs r1, 0 -_082E4274: - ldrh r0, [r2] - adds r0, r3, r0 - lsls r0, 16 - lsrs r3, r0, 16 - adds r2, 0x2 - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x59 - bls _082E4274 - ldr r0, =gDma3Requests + 0xEA - ldrh r0, [r0] - cmp r3, r0 - bne _082E42BC - movs r0, 0xC0 - lsls r0, 18 - ldr r1, =gRfuLinkStatus - ldr r1, [r1] - movs r2, 0x5A - bl CpuSet - ldr r0, =gRfuStatic - ldr r2, [r0] - ldrb r1, [r2] - movs r0, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r0, 0 - b _082E42BE - .align 2, 0 - .pool -_082E42BC: - movs r0, 0x1 -_082E42BE: - pop {r1} - bx r1 - thumb_func_end rfu_MBOOT_CHILD_inheritanceLinkStatus - - thumb_func_start rfu_REQ_stopMode -rfu_REQ_stopMode: @ 82E42C4 - push {lr} - ldr r0, =0x04000208 - ldrh r0, [r0] - cmp r0, 0 - bne _082E42EC - movs r0, 0x3D - movs r1, 0x6 - bl rfu_STC_REQ_callback - ldr r0, =gSTWIStatus - ldr r1, [r0] - ldrh r0, [r1, 0x12] - movs r0, 0x6 - strh r0, [r1, 0x12] - b _082E4362 - .align 2, 0 - .pool -_082E42EC: - bl AgbRFU_SoftReset - bl rfu_STC_clearAPIVariables - movs r0, 0x8 - bl AgbRFU_checkID - ldr r1, =0x00008001 - cmp r0, r1 - bne _082E4350 - ldr r0, =gSTWIStatus - ldr r0, [r0] - ldrb r0, [r0, 0xA] - lsls r0, 2 - ldr r2, =0x04000100 - adds r1, r0, r2 - movs r0, 0 - str r0, [r1] - movs r0, 0x83 - lsls r0, 16 - str r0, [r1] - ldr r0, [r1] - lsls r0, 16 - ldr r2, =0x0105ffff - ldr r3, =rfu_CB_stopMode - cmp r0, r2 - bhi _082E432A -_082E4322: - ldr r0, [r1] - lsls r0, 16 - cmp r0, r2 - bls _082E4322 -_082E432A: - movs r0, 0 - str r0, [r1] - adds r0, r3, 0 - bl STWI_set_Callback_M - bl STWI_send_StopModeREQ - b _082E4362 - .align 2, 0 - .pool -_082E4350: - ldr r1, =0x04000128 - movs r2, 0x80 - lsls r2, 6 - adds r0, r2, 0 - strh r0, [r1] - movs r0, 0x3D - movs r1, 0 - bl rfu_STC_REQ_callback -_082E4362: - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_stopMode - - thumb_func_start rfu_CB_stopMode -rfu_CB_stopMode: @ 82E436C - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 16 - lsrs r1, 16 - adds r2, r1, 0 - cmp r2, 0 - bne _082E4386 - ldr r1, =0x04000128 - movs r4, 0x80 - lsls r4, 6 - adds r0, r4, 0 - strh r0, [r1] -_082E4386: - adds r0, r3, 0 - adds r1, r2, 0 - bl rfu_STC_REQ_callback - pop {r4} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_stopMode - - thumb_func_start rfu_REQBN_softReset_and_checkID -rfu_REQBN_softReset_and_checkID: @ 82E4398 - push {lr} - ldr r0, =0x04000208 - ldrh r0, [r0] - cmp r0, 0 - bne _082E43AC - movs r0, 0x1 - negs r0, r0 - b _082E43CC - .align 2, 0 - .pool -_082E43AC: - bl AgbRFU_SoftReset - bl rfu_STC_clearAPIVariables - movs r0, 0x1E - bl AgbRFU_checkID - adds r2, r0, 0 - cmp r2, 0 - bne _082E43CA - ldr r1, =0x04000128 - movs r3, 0x80 - lsls r3, 6 - adds r0, r3, 0 - strh r0, [r1] -_082E43CA: - adds r0, r2, 0 -_082E43CC: - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_REQBN_softReset_and_checkID - - thumb_func_start rfu_REQ_reset -rfu_REQ_reset: @ 82E43D4 - push {lr} - ldr r0, =rfu_CB_reset - bl STWI_set_Callback_M - bl STWI_send_ResetREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_reset - - thumb_func_start rfu_CB_reset -rfu_CB_reset: @ 82E43E8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r1, 16 - adds r4, r1, 0 - cmp r4, 0 - bne _082E43FC - bl rfu_STC_clearAPIVariables -_082E43FC: - adds r0, r5, 0 - adds r1, r4, 0 - bl rfu_STC_REQ_callback - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end rfu_CB_reset - - thumb_func_start rfu_REQ_configSystem -rfu_REQ_configSystem: @ 82E440C - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 24 - lsrs r5, 24 - lsls r2, 24 - lsrs r6, r2, 24 - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - movs r0, 0x3 - ands r4, r0 - movs r0, 0x3C - orrs r4, r0 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - bl STWI_send_SystemConfigREQ - cmp r6, 0 - bne _082E444C - ldr r0, =gRfuStatic - ldr r1, [r0] - movs r0, 0x1 - strh r0, [r1, 0x1A] - b _082E4466 - .align 2, 0 - .pool -_082E444C: - ldr r5, =0x04000208 - ldrh r4, [r5] - movs r0, 0 - strh r0, [r5] - movs r0, 0x96 - lsls r0, 2 - adds r1, r6, 0 - bl Div - ldr r1, =gRfuStatic - ldr r1, [r1] - strh r0, [r1, 0x1A] - strh r4, [r5] -_082E4466: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_configSystem - - thumb_func_start rfu_REQ_configGameData -rfu_REQ_configGameData: @ 82E4474 - push {r4-r7,lr} - sub sp, 0x10 - adds r4, r2, 0 - adds r7, r3, 0 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r2, r1, 16 - adds r5, r4, 0 - mov r0, sp - strb r1, [r0] - lsrs r2, 24 - strb r2, [r0, 0x1] - cmp r6, 0 - beq _082E449A - movs r1, 0x80 - orrs r2, r1 - movs r1, 0 - orrs r2, r1 - strb r2, [r0, 0x1] -_082E449A: - movs r2, 0x2 - ldr r0, =rfu_CB_configGameData - mov r12, r0 -_082E44A0: - mov r3, sp - adds r1, r3, r2 - ldrb r0, [r4] - strb r0, [r1] - adds r4, 0x1 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xE - bls _082E44A0 - movs r3, 0 - adds r1, r7, 0 - movs r2, 0 -_082E44BA: - ldrb r0, [r1] - adds r0, r3, r0 - lsls r0, 24 - adds r1, 0x1 - lsrs r0, 24 - ldrb r3, [r5] - adds r0, r3 - lsls r0, 24 - lsrs r3, r0, 24 - adds r5, 0x1 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x7 - bls _082E44BA - mov r1, sp - mvns r0, r3 - strb r0, [r1, 0xF] - cmp r6, 0 - beq _082E44E6 - movs r0, 0 - strb r0, [r1, 0xE] -_082E44E6: - mov r0, r12 - bl STWI_set_Callback_M - mov r0, sp - adds r1, r7, 0 - bl STWI_send_GameConfigREQ - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_configGameData - - thumb_func_start rfu_CB_configGameData -rfu_CB_configGameData: @ 82E4500 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - mov r12, r0 - lsls r1, 16 - lsrs r7, r1, 16 - cmp r7, 0 - bne _082E458A - ldr r0, =gSTWIStatus - ldr r0, [r0] - ldr r1, [r0, 0x24] - ldr r0, =gRfuLinkStatus - ldr r6, [r0] - ldrb r2, [r1, 0x4] - adds r5, r6, 0 - adds r5, 0x98 - strh r2, [r5] - ldrb r0, [r1, 0x5] - lsls r3, r0, 8 - orrs r3, r2 - strh r3, [r5] - adds r4, r1, 0x6 - movs r1, 0x80 - lsls r1, 8 - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _082E454C - eors r3, r1 - strh r3, [r5] - adds r1, r6, 0 - adds r1, 0x97 - movs r0, 0x1 - b _082E4552 - .align 2, 0 - .pool -_082E454C: - adds r1, r6, 0 - adds r1, 0x97 - movs r0, 0 -_082E4552: - strb r0, [r1] - movs r2, 0 - ldr r3, =gRfuLinkStatus -_082E4558: - ldr r0, [r3] - adds r0, 0x9A - adds r0, r2 - ldrb r1, [r4] - strb r1, [r0] - adds r4, 0x1 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0xC - bls _082E4558 - adds r4, 0x1 - movs r2, 0 - ldr r3, =gRfuLinkStatus -_082E4574: - ldr r0, [r3] - adds r0, 0xA9 - adds r0, r2 - ldrb r1, [r4] - strb r1, [r0] - adds r4, 0x1 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x7 - bls _082E4574 -_082E458A: - mov r0, r12 - adds r1, r7, 0 - bl rfu_STC_REQ_callback - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_configGameData - - thumb_func_start rfu_REQ_startSearchChild -rfu_REQ_startSearchChild: @ 82E459C - push {r4,lr} - movs r1, 0 - ldr r4, =rfu_CB_defaultCallback - ldr r3, =gRfuStatic - movs r2, 0 -_082E45A6: - ldr r0, [r3] - adds r0, 0xE - adds r0, r1 - strb r2, [r0] - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x3 - bls _082E45A6 - adds r0, r4, 0 - bl STWI_set_Callback_M - bl STWI_send_SystemStatusREQ - bl STWI_poll_CommandEnd - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - bne _082E45F0 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0, 0x7] - cmp r0, 0 - bne _082E45F6 - movs r0, 0x1 - bl rfu_STC_clearLinkStatus - b _082E45F6 - .align 2, 0 - .pool -_082E45F0: - movs r0, 0x19 - bl rfu_STC_REQ_callback -_082E45F6: - ldr r0, =rfu_CB_startSearchChild - bl STWI_set_Callback_M - bl STWI_send_SC_StartREQ - pop {r4} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_startSearchChild - - thumb_func_start rfu_CB_startSearchChild -rfu_CB_startSearchChild: @ 82E460C - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 16 - lsrs r1, 16 - adds r2, r1, 0 - cmp r2, 0 - bne _082E4624 - ldr r0, =gRfuStatic - ldr r1, [r0] - movs r0, 0x1 - strb r0, [r1, 0x9] -_082E4624: - adds r0, r3, 0 - adds r1, r2, 0 - bl rfu_STC_REQ_callback - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_startSearchChild - - thumb_func_start rfu_STC_clearLinkStatus -rfu_STC_clearLinkStatus: @ 82E4634 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl rfu_clearAllSlot - cmp r4, 0 - beq _082E465C - mov r0, sp - movs r5, 0 - strh r5, [r0] - ldr r4, =gRfuLinkStatus - ldr r1, [r4] - adds r1, 0x14 - ldr r2, =0x01000040 - bl CpuSet - ldr r0, [r4] - strb r5, [r0, 0x8] -_082E465C: - movs r1, 0 - ldr r2, =gRfuLinkStatus - adds r4, r2, 0 - movs r3, 0 -_082E4664: - ldr r0, [r4] - adds r0, 0xA - adds r0, r1 - strb r3, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bls _082E4664 - ldr r0, [r2] - movs r1, 0 - strb r1, [r0, 0x1] - ldr r0, [r2] - strb r1, [r0, 0x2] - ldr r0, [r2] - strb r1, [r0, 0x3] - ldr r0, [r2] - strb r1, [r0, 0x7] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_clearLinkStatus - - thumb_func_start rfu_REQ_pollSearchChild -rfu_REQ_pollSearchChild: @ 82E4698 - push {lr} - ldr r0, =rfu_CB_pollAndEndSearchChild - bl STWI_set_Callback_M - bl STWI_send_SC_PollingREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_pollSearchChild - - thumb_func_start rfu_REQ_endSearchChild -rfu_REQ_endSearchChild: @ 82E46AC - push {lr} - ldr r0, =rfu_CB_pollAndEndSearchChild - bl STWI_set_Callback_M - bl STWI_send_SC_EndREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_endSearchChild - - thumb_func_start rfu_CB_pollAndEndSearchChild -rfu_CB_pollAndEndSearchChild: @ 82E46C0 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, 16 - lsrs r6, r1, 16 - cmp r6, 0 - bne _082E46D2 - bl rfu_STC_readChildList -_082E46D2: - cmp r4, 0x1A - bne _082E4714 - ldr r5, =gRfuLinkStatus - ldr r0, [r5] - adds r0, 0x94 - ldrh r0, [r0] - cmp r0, 0 - bne _082E4730 - ldr r0, =rfu_CB_defaultCallback - bl STWI_set_Callback_M - bl STWI_send_SystemStatusREQ - bl STWI_poll_CommandEnd - lsls r0, 16 - cmp r0, 0 - bne _082E4730 - ldr r1, [r5] - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrh r0, [r0, 0x4] - adds r1, 0x94 - strh r0, [r1] - b _082E4730 - .align 2, 0 - .pool -_082E4714: - cmp r4, 0x1B - bne _082E4730 - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - ldrb r0, [r1] - cmp r0, 0xFF - bne _082E4728 - adds r1, 0x94 - movs r0, 0 - strh r0, [r1] -_082E4728: - ldr r0, =gRfuStatic - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x9] -_082E4730: - adds r0, r4, 0 - adds r1, r6, 0 - bl rfu_STC_REQ_callback - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_pollAndEndSearchChild - - thumb_func_start rfu_STC_readChildList -rfu_STC_readChildList: @ 82E4748 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r7, [r0, 0x1] - adds r6, r0, 0x4 - cmp r7, 0 - beq _082E47EE - ldr r0, =gRfuStatic - mov r8, r0 - ldr r1, =gRfuLinkStatus - mov r12, r1 -_082E4766: - ldrb r4, [r6, 0x2] - cmp r4, 0x3 - bhi _082E47E2 - mov r2, r12 - ldr r1, [r2] - ldrb r0, [r1, 0x2] - asrs r0, r4 - movs r5, 0x1 - ands r0, r5 - cmp r0, 0 - bne _082E47E2 - ldrb r0, [r1, 0x3] - asrs r0, r4 - ands r0, r5 - cmp r0, 0 - bne _082E47E2 - mov r1, r8 - ldr r0, [r1] - adds r0, 0xE - adds r0, r4 - movs r1, 0xF0 - strb r1, [r0] - ldr r0, [r2] - adds r0, 0xA - adds r0, r4 - movs r1, 0x10 - strb r1, [r0] - ldr r2, [r2] - adds r0, r5, 0 - lsls r0, r4 - ldrb r1, [r2, 0x2] - orrs r0, r1 - strb r0, [r2, 0x2] - mov r2, r12 - ldr r1, [r2] - ldrb r0, [r1, 0x1] - adds r0, 0x1 - strb r0, [r1, 0x1] - ldr r1, [r2] - lsls r3, r4, 5 - adds r1, r3 - ldrh r0, [r6] - strh r0, [r1, 0x14] - strb r4, [r1, 0x16] - ldr r0, [r2] - strb r5, [r0] - mov r0, r8 - ldr r2, [r0] - ldrb r1, [r2] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2] - mov r2, r8 - ldr r1, [r2] - lsls r0, r4, 1 - adds r1, 0x12 - adds r1, r0 - mov r2, r12 - ldr r0, [r2] - adds r0, r3 - ldrh r0, [r0, 0x14] - strh r0, [r1] -_082E47E2: - subs r0, r7, 0x1 - lsls r0, 24 - lsrs r7, r0, 24 - adds r6, 0x4 - cmp r7, 0 - bne _082E4766 -_082E47EE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_readChildList - - thumb_func_start rfu_REQ_startSearchParent -rfu_REQ_startSearchParent: @ 82E4804 - push {lr} - ldr r0, =rfu_CB_startSearchParent - bl STWI_set_Callback_M - bl STWI_send_SP_StartREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_startSearchParent - - thumb_func_start rfu_CB_startSearchParent -rfu_CB_startSearchParent: @ 82E4818 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r1, 16 - adds r4, r1, 0 - cmp r4, 0 - bne _082E482E - movs r0, 0 - bl rfu_STC_clearLinkStatus -_082E482E: - adds r0, r5, 0 - adds r1, r4, 0 - bl rfu_STC_REQ_callback - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end rfu_CB_startSearchParent - - thumb_func_start rfu_REQ_pollSearchParent -rfu_REQ_pollSearchParent: @ 82E483C - push {lr} - ldr r0, =sub_82E4850 - bl STWI_set_Callback_M - bl STWI_send_SP_PollingREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_pollSearchParent - - thumb_func_start sub_82E4850 -sub_82E4850: @ 82E4850 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r1, 16 - adds r4, r1, 0 - cmp r4, 0 - bne _082E4864 - bl rfu_STC_readParentCandidateList -_082E4864: - adds r0, r5, 0 - adds r1, r4, 0 - bl rfu_STC_REQ_callback - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_82E4850 - - thumb_func_start rfu_REQ_endSearchParent -rfu_REQ_endSearchParent: @ 82E4874 - push {lr} - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - bl STWI_send_SP_EndREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_endSearchParent - - thumb_func_start rfu_STC_readParentCandidateList -rfu_STC_readParentCandidateList: @ 82E4888 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - mov r0, sp - movs r4, 0 - strh r4, [r0] - ldr r5, =gRfuLinkStatus - ldr r1, [r5] - adds r1, 0x14 - ldr r2, =0x01000040 - bl CpuSet - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r2, [r0] - ldrb r7, [r2, 0x1] - adds r2, 0x4 - ldr r0, [r5] - strb r4, [r0, 0x8] - movs r6, 0 - cmp r7, 0 - beq _082E498C - mov r12, r5 - ldr r0, =0x00007fff - mov r8, r0 -_082E48BE: - subs r0, r7, 0x7 - lsls r0, 24 - lsrs r7, r0, 24 - adds r1, r2, 0x6 - adds r2, 0x13 - ldrb r0, [r2] - mvns r0, r0 - lsls r0, 24 - lsrs r5, r0, 24 - adds r2, 0x1 - movs r4, 0 - movs r3, 0 - adds r6, 0x1 -_082E48D8: - ldrb r0, [r2] - adds r0, r4, r0 - lsls r0, 24 - adds r2, 0x1 - lsrs r0, 24 - ldrb r4, [r1] - adds r0, r4 - lsls r0, 24 - lsrs r4, r0, 24 - adds r1, 0x1 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x7 - bls _082E48D8 - cmp r4, r5 - bne _082E4980 - subs r2, 0x1C - mov r0, r12 - ldr r1, [r0] - ldrb r0, [r1, 0x8] - lsls r0, 5 - adds r0, 0x14 - adds r4, r1, r0 - ldrh r0, [r2] - movs r3, 0 - strh r0, [r4] - adds r2, 0x2 - ldrb r0, [r2] - strb r0, [r4, 0x2] - adds r2, 0x2 - ldrh r1, [r2] - mov r0, r8 - ands r0, r1 - strh r0, [r4, 0x4] - ldrh r1, [r2] - movs r0, 0x80 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _082E4940 - movs r0, 0x1 - strb r0, [r4, 0x3] - b _082E4942 - .align 2, 0 - .pool -_082E4940: - strb r3, [r4, 0x3] -_082E4942: - adds r2, 0x2 - movs r3, 0 - adds r5, r4, 0 - adds r5, 0x15 - adds r4, 0x6 -_082E494C: - adds r1, r4, r3 - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0xC - bls _082E494C - adds r2, 0x1 - movs r3, 0 - adds r4, r5, 0 -_082E4964: - adds r1, r4, r3 - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x7 - bls _082E4964 - mov r4, r12 - ldr r1, [r4] - ldrb r0, [r1, 0x8] - adds r0, 0x1 - strb r0, [r1, 0x8] -_082E4980: - lsls r0, r6, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bhi _082E498C - cmp r7, 0 - bne _082E48BE -_082E498C: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end rfu_STC_readParentCandidateList - - thumb_func_start rfu_REQ_startConnectParent -rfu_REQ_startConnectParent: @ 82E4998 - push {r4,r5,lr} - lsls r0, 16 - lsrs r4, r0, 16 - movs r3, 0 - movs r2, 0 - ldr r1, =gRfuLinkStatus - ldr r0, [r1] - ldrh r0, [r0, 0x14] - cmp r0, r4 - beq _082E49C4 - adds r5, r1, 0 -_082E49AE: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bhi _082E49C4 - ldr r0, [r5] - lsls r1, r2, 5 - adds r0, r1 - ldrh r0, [r0, 0x14] - cmp r0, r4 - bne _082E49AE -_082E49C4: - cmp r2, 0x4 - bne _082E49CC - movs r3, 0x80 - lsls r3, 1 -_082E49CC: - cmp r3, 0 - bne _082E49F0 - ldr r0, =gRfuStatic - ldr r0, [r0] - strh r4, [r0, 0x1E] - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - adds r0, r4, 0 - bl STWI_send_CP_StartREQ - b _082E49F8 - .align 2, 0 - .pool -_082E49F0: - movs r0, 0x1F - adds r1, r3, 0 - bl rfu_STC_REQ_callback -_082E49F8: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end rfu_REQ_startConnectParent - - thumb_func_start rfu_REQ_pollConnectParent -rfu_REQ_pollConnectParent: @ 82E4A00 - push {lr} - ldr r0, =rfu_CB_pollConnectParent - bl STWI_set_Callback_M - bl STWI_send_CP_PollingREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_pollConnectParent - - thumb_func_start rfu_CB_pollConnectParent -rfu_CB_pollConnectParent: @ 82E4A14 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x2C - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x24] - lsls r1, 16 - lsrs r1, 16 - str r1, [sp, 0x28] - cmp r1, 0 - bne _082E4B16 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrh r5, [r0, 0x4] - ldrb r1, [r0, 0x6] - mov r10, r1 - ldrb r0, [r0, 0x7] - cmp r0, 0 - bne _082E4B16 - movs r0, 0x80 - lsls r0, 17 - lsls r0, r1 - lsrs r2, r0, 24 - ldr r4, =gRfuLinkStatus - ldr r3, [r4] - ldrb r1, [r3, 0x2] - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - bne _082E4B16 - adds r0, r2, 0 - orrs r0, r1 - strb r0, [r3, 0x2] - ldr r1, [r4] - ldrb r0, [r1, 0x3] - bics r0, r2 - strb r0, [r1, 0x3] - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0x94 - movs r2, 0 - strh r5, [r0] - ldrb r0, [r1, 0x1] - adds r0, 0x1 - strb r0, [r1, 0x1] - ldr r0, [r4] - strb r2, [r0] - ldr r3, =gRfuStatic - ldr r2, [r3] - ldrb r1, [r2] - movs r0, 0x80 - orrs r0, r1 - strb r0, [r2] - movs r5, 0 - adds r7, r4, 0 - add r6, sp, 0x20 - movs r0, 0 - mov r8, r0 -_082E4A92: - ldr r2, [r7] - lsls r4, r5, 5 - adds r0, r2, r4 - ldr r1, [r3] - ldrh r0, [r0, 0x14] - ldrh r1, [r1, 0x1E] - cmp r0, r1 - bne _082E4AEA - ldrb r0, [r2, 0x8] - cmp r0, 0 - beq _082E4AE0 - mov r9, sp - adds r0, r4, 0 - adds r0, 0x14 - adds r0, r2, r0 - mov r1, sp - movs r2, 0x10 - bl CpuSet - mov r1, r8 - strh r1, [r6] - ldr r1, [r7] - adds r1, 0x14 - adds r0, r6, 0 - ldr r2, =0x01000040 - bl CpuSet - ldr r0, [r7] - mov r1, r8 - strb r1, [r0, 0x8] - b _082E4AF4 - .align 2, 0 - .pool -_082E4AE0: - adds r0, r4, 0 - adds r0, 0x14 - adds r2, r0 - mov r9, r2 - b _082E4AF4 -_082E4AEA: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _082E4A92 -_082E4AF4: - cmp r5, 0x3 - bhi _082E4B16 - ldr r4, =gRfuLinkStatus - mov r0, r10 - lsls r5, r0, 5 - adds r0, r5, 0 - adds r0, 0x14 - ldr r1, [r4] - adds r1, r0 - mov r0, r9 - movs r2, 0x10 - bl CpuSet - ldr r0, [r4] - adds r0, r5 - mov r1, r10 - strb r1, [r0, 0x16] -_082E4B16: - ldr r0, [sp, 0x24] - ldr r1, [sp, 0x28] - bl rfu_STC_REQ_callback - add sp, 0x2C - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_pollConnectParent - - thumb_func_start rfu_getConnectParentStatus -rfu_getConnectParentStatus: @ 82E4B34 - push {lr} - adds r3, r0, 0 - movs r0, 0xFF - strb r0, [r3] - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r2, [r0] - ldrb r0, [r2] - adds r0, 0x60 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _082E4B58 - movs r0, 0x10 - b _082E4B64 - .align 2, 0 - .pool -_082E4B58: - adds r2, 0x6 - ldrb r0, [r2] - strb r0, [r1] - ldrb r0, [r2, 0x1] - strb r0, [r3] - movs r0, 0 -_082E4B64: - pop {r1} - bx r1 - thumb_func_end rfu_getConnectParentStatus - - thumb_func_start rfu_REQ_endConnectParent -rfu_REQ_endConnectParent: @ 82E4B68 - push {lr} - ldr r0, =rfu_CB_pollConnectParent - bl STWI_set_Callback_M - bl STWI_send_CP_EndREQ - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r1, [r0] - ldrb r0, [r1, 0x6] - cmp r0, 0x3 - bhi _082E4B90 - ldr r0, =gRfuStatic - ldr r0, [r0] - adds r0, 0xA - ldrb r1, [r1, 0x6] - adds r0, r1 - movs r1, 0 - strb r1, [r0] -_082E4B90: - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_endConnectParent - - thumb_func_start rfu_syncVBlank -rfu_syncVBlank: @ 82E4BA0 - push {r4,r5,lr} - bl rfu_NI_checkCommFailCounter - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0xFF - beq _082E4C78 - ldr r4, =gRfuStatic - ldr r1, [r4] - ldrb r0, [r1, 0x6] - cmp r0, 0 - beq _082E4BBE - subs r0, 0x1 - strb r0, [r1, 0x6] -_082E4BBE: - bl rfu_getMasterSlave - lsls r0, 24 - lsrs r3, r0, 24 - ldr r2, [r4] - ldrb r1, [r2] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _082E4BF0 - cmp r3, 0 - bne _082E4BFE - movs r0, 0x4 - orrs r0, r1 - strb r0, [r2] - ldr r1, [r4] - movs r0, 0xB4 - lsls r0, 1 - strh r0, [r1, 0x20] - b _082E4BFA - .align 2, 0 - .pool -_082E4BF0: - cmp r3, 0 - beq _082E4C10 - movs r0, 0xFB - ands r0, r1 - strb r0, [r2] -_082E4BFA: - cmp r3, 0 - beq _082E4C10 -_082E4BFE: - ldr r3, =gRfuStatic - ldr r2, [r3] - ldrb r1, [r2] - movs r0, 0xFD - ands r0, r1 - b _082E4C1A - .align 2, 0 - .pool -_082E4C10: - ldr r3, =gRfuStatic - ldr r2, [r3] - ldrb r1, [r2] - movs r0, 0x2 - orrs r0, r1 -_082E4C1A: - strb r0, [r2] - ldr r3, [r3] - ldrb r1, [r3] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _082E4C78 - ldrh r0, [r3, 0x20] - cmp r0, 0 - bne _082E4C74 - movs r0, 0xFB - ands r0, r1 - strb r0, [r3] - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r1, [r0, 0x2] - ldrb r0, [r0, 0x3] - adds r5, r0, 0 - orrs r5, r1 - movs r4, 0 -_082E4C42: - adds r0, r5, 0 - asrs r0, r4 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _082E4C54 - adds r0, r4, 0 - bl rfu_STC_removeLinkData -_082E4C54: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _082E4C42 - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - movs r0, 0xFF - strb r0, [r1] - movs r0, 0x1 - b _082E4C7A - .align 2, 0 - .pool -_082E4C74: - subs r0, 0x1 - strh r0, [r3, 0x20] -_082E4C78: - movs r0, 0 -_082E4C7A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end rfu_syncVBlank - - thumb_func_start rfu_REQBN_watchLink -rfu_REQBN_watchLink: @ 82E4C80 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x18 - mov r8, r1 - str r2, [sp] - str r3, [sp, 0x4] - lsls r0, 16 - lsrs r6, r0, 16 - movs r0, 0 - str r0, [sp, 0x8] - movs r1, 0 - str r1, [sp, 0xC] - mov r2, r8 - strb r1, [r2] - mov r0, sp - ldrb r1, [r0, 0xC] - ldr r0, [sp] - strb r1, [r0] - mov r2, sp - ldrb r0, [r2, 0xC] - ldr r2, [sp, 0x4] - strb r0, [r2] - ldr r5, =gRfuLinkStatus - ldr r0, [r5] - ldrb r0, [r0] - cmp r0, 0xFF - bne _082E4CBE - b _082E504E -_082E4CBE: - ldr r0, =gSTWIStatus - ldr r0, [r0] - ldrb r0, [r0, 0x14] - cmp r0, 0 - bne _082E4CCA - b _082E504E -_082E4CCA: - ldr r3, =gRfuStatic - ldr r2, [r3] - ldrb r1, [r2] - movs r4, 0x4 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _082E4CE0 - movs r0, 0xB4 - lsls r0, 1 - strh r0, [r2, 0x20] -_082E4CE0: - ldr r1, [r3] - ldrb r0, [r1, 0x6] - cmp r0, 0 - bne _082E4CEE - strb r4, [r1, 0x6] - movs r1, 0x1 - str r1, [sp, 0x8] -_082E4CEE: - lsls r0, r6, 24 - lsrs r0, 24 - cmp r0, 0x29 - bne _082E4D30 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r1, [r0] - ldrb r0, [r1, 0x4] - mov r2, r8 - strb r0, [r2] - ldrb r0, [r1, 0x5] - ldr r1, [sp] - strb r0, [r1] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _082E4D18 - ldr r0, [r5] - ldrb r0, [r0, 0x2] - strb r0, [r2] -_082E4D18: - movs r2, 0x2 - str r2, [sp, 0x8] - b _082E4D88 - .align 2, 0 - .pool -_082E4D30: - movs r0, 0x9B - lsls r0, 1 - cmp r6, r0 - bne _082E4D80 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r6, [r0, 0x5] - ldr r0, [r5] - ldrb r0, [r0, 0x2] - eors r6, r0 - ands r6, r0 - mov r0, r8 - strb r6, [r0] - movs r0, 0x1 - ldr r1, [sp] - strb r0, [r1] - movs r5, 0 -_082E4D56: - mov r2, r8 - ldrb r0, [r2] - asrs r0, r5 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _082E4D76 - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - adds r0, 0xA - adds r0, r5 - movs r1, 0 - strb r1, [r0] - adds r0, r5, 0 - bl rfu_STC_removeLinkData -_082E4D76: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _082E4D56 -_082E4D80: - ldr r0, [sp, 0x8] - cmp r0, 0 - bne _082E4D88 - b _082E504E -_082E4D88: - ldr r4, =gRfuFixed - ldr r0, [r4] - adds r0, 0xDC - ldr r0, [r0] - ldr r1, [r0] - str r1, [sp, 0x10] - ldr r0, [r0, 0x4] - str r0, [sp, 0x14] - ldr r0, =rfu_CB_defaultCallback - bl STWI_set_Callback_M - bl STWI_send_LinkStatusREQ - bl STWI_poll_CommandEnd - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0xC] - cmp r0, 0 - bne _082E4DE8 - ldr r0, [r4] - adds r0, 0xDC - ldr r0, [r0] - adds r2, r0, 0x4 - movs r5, 0 - ldr r3, =gRfuLinkStatus -_082E4DBC: - ldr r0, [r3] - adds r0, 0xA - adds r0, r5 - ldrb r1, [r2] - strb r1, [r0] - adds r2, 0x1 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _082E4DBC - movs r2, 0 - mov r9, r2 - movs r5, 0 - b _082E4DF4 - .align 2, 0 - .pool -_082E4DE8: - movs r0, 0x11 - ldr r1, [sp, 0xC] - bl rfu_STC_REQ_callback - ldr r0, [sp, 0xC] - b _082E5050 -_082E4DF4: - ldr r1, =gRfuStatic - ldr r0, [r1] - adds r0, 0xE - adds r2, r0, r5 - ldrb r0, [r2] - adds r3, r1, 0 - cmp r0, 0 - beq _082E4E1A - subs r0, 0x4 - strb r0, [r2] - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - adds r0, 0xA - adds r1, r0, r5 - ldrb r0, [r1] - cmp r0, 0xF - bhi _082E4E1A - movs r0, 0x10 - strb r0, [r1] -_082E4E1A: - movs r0, 0x80 - lsls r0, 17 - lsls r0, r5 - lsrs r6, r0, 24 - adds r0, r5, 0x1 - mov r10, r0 - ldr r1, [sp, 0xC] - cmp r1, 0 - beq _082E4E2E - b _082E5002 -_082E4E2E: - ldr r2, [sp, 0x8] - cmp r2, 0x1 - bne _082E4F10 - ldr r4, =gRfuLinkStatus - ldr r1, [r4] - ldrb r0, [r1, 0x2] - ands r0, r6 - cmp r0, 0 - beq _082E4F10 - adds r0, r1, 0 - adds r0, 0xA - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _082E4F04 - ldrb r0, [r1] - cmp r0, 0x1 - bne _082E4E84 - ldr r1, [r3] - adds r1, 0xA - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - ldr r0, [r3] - adds r0, 0xA - adds r0, r5 - ldrb r0, [r0] - cmp r0, 0x3 - bls _082E4F10 - mov r0, r8 - ldrb r1, [r0] - adds r0, r6, 0 - orrs r0, r1 - mov r1, r8 - strb r0, [r1] - ldr r0, [sp] - strb r2, [r0] - b _082E4F10 - .align 2, 0 - .pool -_082E4E84: - bl STWI_send_SystemStatusREQ - bl STWI_poll_CommandEnd - lsls r0, 16 - cmp r0, 0 - bne _082E4F10 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0, 0x7] - cmp r0, 0 - bne _082E4EB8 - mov r2, r8 - ldrb r1, [r2] - adds r0, r6, 0 - orrs r0, r1 - strb r0, [r2] - mov r0, sp - ldrb r1, [r0, 0x8] - ldr r0, [sp] - b _082E4F0E - .align 2, 0 - .pool -_082E4EB8: - ldr r2, =gRfuStatic - ldr r1, [r2] - adds r1, 0xA - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - lsls r0, 24 - ldr r2, [r2] - lsrs r0, 24 - ldrh r1, [r2, 0x1A] - cmp r0, r1 - bls _082E4F10 - adds r0, r2, 0 - adds r0, 0xA - adds r0, r5 - mov r2, sp - ldrb r2, [r2, 0xC] - strb r2, [r0] - ldr r0, [r4] - ldrb r0, [r0, 0x2] - bl STWI_send_DisconnectREQ - bl STWI_poll_CommandEnd - mov r0, r8 - ldrb r1, [r0] - adds r0, r6, 0 - orrs r0, r1 - mov r1, r8 - strb r0, [r1] - mov r2, sp - ldrb r0, [r2, 0x8] - ldr r2, [sp] - strb r0, [r2] - b _082E4F10 - .align 2, 0 - .pool -_082E4F04: - ldr r0, [r3] - adds r0, 0xA - adds r0, r5 - mov r1, sp - ldrb r1, [r1, 0xC] -_082E4F0E: - strb r1, [r0] -_082E4F10: - ldr r2, =gRfuLinkStatus - mov r12, r2 - ldr r1, [r2] - ldrb r7, [r1] - adds r0, r5, 0x1 - mov r10, r0 - cmp r7, 0x1 - bne _082E5002 - adds r0, r1, 0 - adds r0, 0xA - adds r4, r0, r5 - ldrb r3, [r4] - cmp r3, 0 - beq _082E5002 - ldrb r2, [r1, 0x3] - adds r0, r6, 0 - ands r0, r2 - cmp r0, 0 - beq _082E4F7E - cmp r3, 0xA - bls _082E4F78 - ldr r2, [sp, 0x4] - ldrb r1, [r2] - adds r0, r6, 0 - orrs r0, r1 - strb r0, [r2] - mov r0, r12 - ldr r2, [r0] - ldrb r1, [r2, 0x2] - adds r0, r6, 0 - orrs r0, r1 - movs r3, 0 - strb r0, [r2, 0x2] - mov r2, r12 - ldr r1, [r2] - ldrb r0, [r1, 0x3] - bics r0, r6 - strb r0, [r1, 0x3] - ldr r1, [r2] - ldrb r0, [r1, 0x1] - adds r0, 0x1 - strb r0, [r1, 0x1] - ldr r0, =gRfuStatic - ldr r0, [r0] - adds r0, 0xA - adds r0, r5 - strb r3, [r0] - b _082E5002 - .align 2, 0 - .pool -_082E4F78: - movs r0, 0 - strb r0, [r4] - b _082E5002 -_082E4F7E: - ldrb r0, [r1, 0x2] - orrs r0, r2 - ands r0, r6 - cmp r0, 0 - bne _082E5002 - bl STWI_send_SlotStatusREQ - bl STWI_poll_CommandEnd - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r2, [r0] - ldrb r0, [r2, 0x1] - subs r0, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - adds r2, 0x8 - cmp r3, 0 - beq _082E5002 - ldrh r4, [r2] - ldrb r0, [r2, 0x2] - cmp r0, r5 - bne _082E4FD0 - ldr r0, =gRfuStatic - ldr r0, [r0] - lsls r1, r5, 1 - adds r0, 0x12 - adds r0, r1 - ldrh r0, [r0] - cmp r4, r0 - bne _082E4FD0 - lsls r7, r5 - mov r0, r9 - orrs r0, r7 - lsls r0, 24 - b _082E4FFE - .align 2, 0 - .pool -_082E4FD0: - adds r2, 0x4 - subs r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0 - beq _082E5002 - ldrh r4, [r2] - ldrb r0, [r2, 0x2] - cmp r0, r5 - bne _082E4FD0 - ldr r0, =gRfuStatic - ldr r0, [r0] - lsls r1, r5, 1 - adds r0, 0x12 - adds r0, r1 - ldrh r0, [r0] - cmp r4, r0 - bne _082E4FD0 - movs r0, 0x1 - lsls r0, r5 - mov r1, r9 - orrs r1, r0 - lsls r0, r1, 24 -_082E4FFE: - lsrs r0, 24 - mov r9, r0 -_082E5002: - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r1, [r0, 0x2] - mov r2, r8 - ldrb r0, [r2] - ands r0, r1 - ands r6, r0 - cmp r6, 0 - beq _082E501C - adds r0, r5, 0 - movs r1, 0 - bl rfu_STC_removeLinkData -_082E501C: - mov r1, r10 - lsls r0, r1, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bhi _082E5028 - b _082E4DF4 -_082E5028: - mov r2, r9 - cmp r2, 0 - beq _082E5038 - mov r0, r9 - bl STWI_send_DisconnectREQ - bl STWI_poll_CommandEnd -_082E5038: - ldr r1, =gRfuFixed - ldr r0, [r1] - adds r0, 0xDC - ldr r0, [r0] - ldr r2, [sp, 0x10] - str r2, [r0] - ldr r0, [r1] - adds r0, 0xDC - ldr r0, [r0] - ldr r1, [sp, 0x14] - str r1, [r0, 0x4] -_082E504E: - movs r0, 0 -_082E5050: - add sp, 0x18 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_REQBN_watchLink - - thumb_func_start rfu_STC_removeLinkData -rfu_STC_removeLinkData: @ 82E506C - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r7, r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r12, r1 - movs r0, 0x80 - lsls r0, 17 - lsls r0, r7 - lsrs r6, r0, 24 - ldr r0, =gRfuStatic - ldr r0, [r0] - adds r0, 0xE - adds r0, r7 - movs r1, 0 - strb r1, [r0] - ldr r1, =gRfuLinkStatus - ldr r4, [r1] - ldrb r0, [r4, 0x2] - ands r0, r6 - mov r8, r1 - cmp r0, 0 - beq _082E50AA - ldrb r0, [r4, 0x1] - cmp r0, 0 - beq _082E50AA - subs r0, 0x1 - strb r0, [r4, 0x1] -_082E50AA: - mov r3, r8 - ldr r2, [r3] - mvns r5, r6 - ldrb r1, [r2, 0x2] - adds r0, r5, 0 - ands r0, r1 - strb r0, [r2, 0x2] - ldr r2, [r3] - ldrb r1, [r2, 0x3] - adds r0, r6, 0 - orrs r0, r1 - strb r0, [r2, 0x3] - ldr r3, [r3] - ldr r0, [r3] - ldr r1, =0x00ff00ff - ands r0, r1 - cmp r0, 0 - bne _082E50D2 - movs r0, 0xFF - strb r0, [r3] -_082E50D2: - mov r0, r12 - cmp r0, 0 - beq _082E5110 - mov r1, sp - movs r4, 0 - movs r0, 0 - strh r0, [r1] - lsls r0, r7, 5 - adds r0, 0x14 - mov r2, r8 - ldr r1, [r2] - adds r1, r0 - ldr r2, =0x01000010 - mov r0, sp - bl CpuSet - mov r0, r8 - ldr r2, [r0] - ldrb r1, [r2, 0x3] - adds r0, r5, 0 - ands r0, r1 - strb r0, [r2, 0x3] - mov r2, r8 - ldr r1, [r2] - ldrb r0, [r1, 0x7] - ands r5, r0 - strb r5, [r1, 0x7] - ldr r0, [r2] - adds r0, 0xA - adds r0, r7 - strb r4, [r0] -_082E5110: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_removeLinkData - - thumb_func_start rfu_REQ_disconnect -rfu_REQ_disconnect: @ 82E512C - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r2, =gRfuLinkStatus - ldr r1, [r2] - ldrb r0, [r1, 0x2] - ldrb r1, [r1, 0x3] - orrs r0, r1 - ands r0, r4 - cmp r0, 0 - beq _082E51B0 - ldr r0, =gRfuStatic - ldr r1, [r0] - strb r4, [r1, 0x5] - ldr r2, [r2] - ldrb r1, [r2] - adds r3, r0, 0 - cmp r1, 0xFF - bne _082E5178 - ldr r0, [r3] - ldrb r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _082E5178 - ldrb r0, [r2, 0x3] - ands r0, r4 - cmp r0, 0 - beq _082E51B0 - movs r0, 0x30 - movs r1, 0 - bl rfu_CB_disconnect - b _082E51B0 - .align 2, 0 - .pool -_082E5178: - ldr r0, [r3] - ldrb r0, [r0, 0x9] - cmp r0, 0 - beq _082E51A4 - ldr r0, =rfu_CB_defaultCallback - bl STWI_set_Callback_M - bl STWI_send_SC_EndREQ - bl STWI_poll_CommandEnd - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - beq _082E51A4 - movs r0, 0x1B - bl rfu_STC_REQ_callback - b _082E51B0 - .align 2, 0 - .pool -_082E51A4: - ldr r0, =rfu_CB_disconnect - bl STWI_set_Callback_M - adds r0, r4, 0 - bl STWI_send_DisconnectREQ -_082E51B0: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_disconnect - - thumb_func_start rfu_CB_disconnect -rfu_CB_disconnect: @ 82E51BC - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r5, r1, 16 - cmp r5, 0x3 - bne _082E51F8 - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0 - bne _082E51F8 - ldr r0, =rfu_CB_defaultCallback - bl STWI_set_Callback_M - bl STWI_send_SystemStatusREQ - bl STWI_poll_CommandEnd - lsls r0, 16 - cmp r0, 0 - bne _082E51F8 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0, 0x7] - cmp r0, 0 - bne _082E51F8 - movs r5, 0 -_082E51F8: - ldr r3, =gRfuStatic - ldr r2, [r3] - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - ldrb r0, [r1, 0x2] - ldrb r1, [r1, 0x3] - orrs r0, r1 - ldrb r1, [r2, 0x5] - ands r0, r1 - strb r0, [r2, 0x5] - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r1, [r0] - ldr r0, [r3] - ldrb r0, [r0, 0x5] - strb r0, [r1, 0x8] - cmp r5, 0 - bne _082E5246 - movs r4, 0 -_082E5220: - movs r0, 0x80 - lsls r0, 17 - lsls r0, r4 - lsrs r0, 24 - ldr r1, =gRfuStatic - ldr r1, [r1] - ldrb r1, [r1, 0x5] - ands r0, r1 - cmp r0, 0 - beq _082E523C - adds r0, r4, 0 - movs r1, 0x1 - bl rfu_STC_removeLinkData -_082E523C: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _082E5220 -_082E5246: - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r1, [r2, 0x2] - ldrb r0, [r2, 0x3] - orrs r0, r1 - cmp r0, 0 - bne _082E5258 - movs r0, 0xFF - strb r0, [r2] -_082E5258: - adds r0, r6, 0 - adds r1, r5, 0 - bl rfu_STC_REQ_callback - ldr r0, =gRfuStatic - ldr r0, [r0] - ldrb r0, [r0, 0x9] - cmp r0, 0 - beq _082E5286 - ldr r0, =rfu_CB_defaultCallback - bl STWI_set_Callback_M - bl STWI_send_SC_StartREQ - bl STWI_poll_CommandEnd - adds r5, r0, 0 - cmp r5, 0 - beq _082E5286 - movs r0, 0x19 - adds r1, r5, 0 - bl rfu_STC_REQ_callback -_082E5286: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_disconnect - - thumb_func_start rfu_REQ_CHILD_startConnectRecovery -rfu_REQ_CHILD_startConnectRecovery: @ 82E529C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gRfuStatic - ldr r0, [r0] - strb r5, [r0, 0x5] - movs r4, 0 - movs r0, 0x1 - ands r0, r5 - ldr r2, =rfu_STC_REQ_callback - cmp r0, 0 - bne _082E52CA - movs r1, 0x1 -_082E52B6: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bhi _082E52CA - adds r0, r5, 0 - asrs r0, r4 - ands r0, r1 - cmp r0, 0 - beq _082E52B6 -_082E52CA: - adds r0, r2, 0 - bl STWI_set_Callback_M - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - lsls r0, r4, 5 - adds r0, r1, r0 - ldrh r0, [r0, 0x14] - adds r1, 0x94 - ldrh r1, [r1] - adds r2, r5, 0 - bl STWI_send_CPR_StartREQ - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_CHILD_startConnectRecovery - - thumb_func_start rfu_REQ_CHILD_pollConnectRecovery -rfu_REQ_CHILD_pollConnectRecovery: @ 82E52F8 - push {lr} - ldr r0, =rfu_CB_CHILD_pollConnectRecovery - bl STWI_set_Callback_M - bl STWI_send_CPR_PollingREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_CHILD_pollConnectRecovery - - thumb_func_start rfu_CB_CHILD_pollConnectRecovery -rfu_CB_CHILD_pollConnectRecovery: @ 82E530C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 16 - lsrs r7, r1, 16 - cmp r7, 0 - bne _082E5390 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0, 0x4] - cmp r0, 0 - bne _082E5390 - ldr r0, =gRfuStatic - ldr r1, [r0] - ldrb r1, [r1, 0x5] - adds r6, r0, 0 - cmp r1, 0 - beq _082E5390 - ldr r1, =gRfuLinkStatus - ldr r0, [r1] - strb r7, [r0] - movs r4, 0 - adds r5, r1, 0 - mov r12, r4 -_082E5346: - movs r0, 0x80 - lsls r0, 17 - lsls r0, r4 - lsrs r3, r0, 24 - ldr r2, [r5] - ldr r0, [r6] - ldrb r0, [r0, 0x5] - ands r0, r3 - ldrb r1, [r2, 0x3] - ands r0, r1 - cmp r0, 0 - beq _082E5380 - ldrb r1, [r2, 0x2] - adds r0, r3, 0 - orrs r0, r1 - strb r0, [r2, 0x2] - ldr r1, [r5] - ldrb r0, [r1, 0x3] - bics r0, r3 - strb r0, [r1, 0x3] - ldr r1, [r5] - ldrb r0, [r1, 0x1] - adds r0, 0x1 - strb r0, [r1, 0x1] - ldr r0, [r6] - adds r0, 0xA - adds r0, r4 - mov r1, r12 - strb r1, [r0] -_082E5380: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _082E5346 - ldr r1, [r6] - movs r0, 0 - strb r0, [r1, 0x5] -_082E5390: - mov r0, r8 - adds r1, r7, 0 - bl rfu_STC_REQ_callback - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_CHILD_pollConnectRecovery - - thumb_func_start rfu_CHILD_getConnectRecoveryStatus -rfu_CHILD_getConnectRecoveryStatus: @ 82E53B0 - push {lr} - adds r2, r0, 0 - movs r0, 0xFF - strb r0, [r2] - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r1, [r0] - ldrb r0, [r1] - adds r0, 0x4D - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _082E53D4 - movs r0, 0x10 - b _082E53DA - .align 2, 0 - .pool -_082E53D4: - ldrb r0, [r1, 0x4] - strb r0, [r2] - movs r0, 0 -_082E53DA: - pop {r1} - bx r1 - thumb_func_end rfu_CHILD_getConnectRecoveryStatus - - thumb_func_start rfu_REQ_CHILD_endConnectRecovery -rfu_REQ_CHILD_endConnectRecovery: @ 82E53E0 - push {lr} - ldr r0, =rfu_CB_CHILD_pollConnectRecovery - bl STWI_set_Callback_M - bl STWI_send_CPR_EndREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_CHILD_endConnectRecovery - - thumb_func_start sub_82E53F4 -sub_82E53F4: @ 82E53F4 - push {r4-r6,lr} - adds r5, r0, 0 - adds r6, r1, 0 - ldr r3, [r5] - ldr r1, [r6] - subs r2, 0x1 - movs r0, 0x1 - negs r0, r0 - cmp r2, r0 - beq _082E5418 - adds r4, r0, 0 - thumb_func_end sub_82E53F4 - - non_word_aligned_thumb_func_start sub_82E540A -sub_82E540A: @ 82E540A - ldrb r0, [r3] - strb r0, [r1] - adds r3, 0x1 - adds r1, 0x1 - subs r2, 0x1 - cmp r2, r4 - bne sub_82E540A -_082E5418: - str r3, [r5] - str r1, [r6] - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_82E540A - - thumb_func_start rfu_REQ_changeMasterSlave -rfu_REQ_changeMasterSlave: @ 82E5424 - push {lr} - movs r0, 0x1 - bl STWI_read_status - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _082E5444 - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - bl STWI_send_MS_ChangeREQ - b _082E544C - .align 2, 0 - .pool -_082E5444: - movs r0, 0x27 - movs r1, 0 - bl rfu_STC_REQ_callback -_082E544C: - pop {r0} - bx r0 - thumb_func_end rfu_REQ_changeMasterSlave - - thumb_func_start rfu_getMasterSlave -rfu_getMasterSlave: @ 82E5450 - push {lr} - movs r0, 0x1 - bl STWI_read_status - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1 - bne _082E547E - ldr r0, =gSTWIStatus - ldr r1, [r0] - adds r0, r1, 0 - adds r0, 0x2C - ldrb r0, [r0] - cmp r0, 0 - beq _082E547E - ldrb r0, [r1, 0x6] - cmp r0, 0x27 - beq _082E547C - cmp r0, 0x25 - beq _082E547C - cmp r0, 0x37 - bne _082E547E -_082E547C: - movs r2, 0 -_082E547E: - adds r0, r2, 0 - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_getMasterSlave - - thumb_func_start rfu_clearAllSlot -rfu_clearAllSlot: @ 82E5488 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - ldr r1, =0x04000208 - ldrh r0, [r1] - mov r8, r0 - movs r0, 0 - strh r0, [r1] - movs r5, 0 - mov r0, sp - adds r0, 0x2 - movs r7, 0 - adds r6, r0, 0 -_082E54A4: - mov r0, sp - strh r7, [r0] - ldr r0, =gRfuSlotStatusNI - lsls r4, r5, 2 - adds r0, r4, r0 - ldr r1, [r0] - mov r0, sp - ldr r2, =0x01000034 - bl CpuSet - strh r7, [r6] - ldr r0, =gRfuSlotStatusUNI - adds r4, r0 - ldr r1, [r4] - adds r0, r6, 0 - ldr r2, =0x0100000a - bl CpuSet - ldr r3, =gRfuLinkStatus - ldr r0, [r3] - adds r0, 0x10 - adds r0, r5 - movs r1, 0x10 - strb r1, [r0] - adds r0, r5, 0x1 - lsls r0, 16 - lsrs r5, r0, 16 - cmp r5, 0x3 - bls _082E54A4 - ldr r2, [r3] - movs r1, 0 - movs r0, 0x57 - strb r0, [r2, 0xF] - ldr r0, [r3] - strb r1, [r0, 0x4] - ldr r0, [r3] - strb r1, [r0, 0x5] - ldr r0, [r3] - strb r1, [r0, 0x6] - ldr r0, =gRfuStatic - ldr r0, [r0] - strb r1, [r0, 0x2] - ldr r0, =0x04000208 - mov r1, r8 - strh r1, [r0] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_clearAllSlot - - thumb_func_start rfu_STC_releaseFrame -rfu_STC_releaseFrame: @ 82E5528 - push {r4-r6,lr} - adds r4, r2, 0 - lsls r0, 24 - lsrs r2, r0, 24 - adds r5, r2, 0 - lsls r1, 24 - lsrs r3, r1, 24 - ldr r0, =gRfuStatic - ldr r0, [r0] - ldrb r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _082E5568 - ldr r6, =gRfuLinkStatus - cmp r3, 0 - bne _082E5554 - ldr r1, [r6] - ldrb r0, [r1, 0xF] - ldrh r4, [r4, 0x2E] - adds r0, r4 - strb r0, [r1, 0xF] -_082E5554: - ldr r1, [r6] - ldrb r0, [r1, 0xF] - adds r0, 0x3 - strb r0, [r1, 0xF] - b _082E5588 - .align 2, 0 - .pool -_082E5568: - ldr r6, =gRfuLinkStatus - cmp r3, 0 - bne _082E557C - ldr r1, [r6] - adds r1, 0x10 - adds r1, r2 - ldrb r0, [r1] - ldrh r4, [r4, 0x2E] - adds r0, r4 - strb r0, [r1] -_082E557C: - ldr r1, [r6] - adds r1, 0x10 - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x2 - strb r0, [r1] -_082E5588: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_releaseFrame - - thumb_func_start rfu_clearSlot -rfu_clearSlot: @ 82E5594 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r1, 24 - lsrs r7, r1, 24 - cmp r7, 0x3 - bls _082E55B4 - movs r0, 0x80 - lsls r0, 3 - b _082E572C -_082E55B4: - movs r0, 0xF - mov r1, r8 - ands r0, r1 - cmp r0, 0 - bne _082E55C4 - movs r0, 0xC0 - lsls r0, 3 - b _082E572C -_082E55C4: - ldr r1, =0x04000208 - ldrh r0, [r1] - mov r10, r0 - movs r0, 0 - strh r0, [r1] - movs r0, 0xC - mov r2, r8 - ands r0, r2 - cmp r0, 0 - beq _082E568C - movs r3, 0 - ldr r1, =gRfuSlotStatusNI - lsls r0, r7, 2 - adds r0, r1 - mov r9, r0 -_082E55E2: - movs r4, 0 - cmp r3, 0 - bne _082E5614 - movs r0, 0x4 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _082E5634 - mov r2, r9 - ldr r4, [r2] - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - adds r0, r4, 0 - adds r0, 0x2C - ldrb r1, [r0] - ldrb r0, [r2, 0x4] - bics r0, r1 - strb r0, [r2, 0x4] - b _082E5634 - .align 2, 0 - .pool -_082E5614: - movs r0, 0x8 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _082E5634 - mov r2, r9 - ldr r0, [r2] - adds r4, r0, 0 - adds r4, 0x34 - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - movs r1, 0x1 - lsls r1, r7 - ldrb r0, [r2, 0x5] - bics r0, r1 - strb r0, [r2, 0x5] -_082E5634: - adds r6, r3, 0x1 - cmp r4, 0 - beq _082E5684 - ldrh r0, [r4] - movs r2, 0x80 - lsls r2, 8 - adds r1, r2, 0 - ands r0, r1 - cmp r0, 0 - beq _082E5674 - lsls r1, r3, 24 - lsrs r1, 24 - adds r0, r7, 0 - adds r2, r4, 0 - bl rfu_STC_releaseFrame - movs r1, 0 - adds r2, r4, 0 - adds r2, 0x2C - movs r5, 0x1 - movs r3, 0 -_082E565E: - ldrb r0, [r2] - asrs r0, r1 - ands r0, r5 - cmp r0, 0 - beq _082E566A - strh r3, [r4, 0x2] -_082E566A: - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x3 - bls _082E565E -_082E5674: - mov r1, sp - movs r0, 0 - strh r0, [r1] - mov r0, sp - adds r1, r4, 0 - ldr r2, =0x0100001a - bl CpuSet -_082E5684: - lsls r0, r6, 16 - lsrs r3, r0, 16 - cmp r3, 0x1 - bls _082E55E2 -_082E568C: - movs r0, 0x1 - mov r4, r8 - ands r0, r4 - cmp r0, 0 - beq _082E5702 - ldr r1, =gRfuSlotStatusUNI - lsls r0, r7, 2 - adds r0, r1 - ldr r3, [r0] - ldrh r1, [r3] - movs r0, 0x80 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _082E56F4 - ldr r0, =gRfuStatic - ldr r0, [r0] - ldrb r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _082E56D8 - ldr r2, =gRfuLinkStatus - ldr r1, [r2] - ldrb r0, [r1, 0xF] - adds r0, 0x3 - ldrb r4, [r3, 0x4] - adds r0, r4 - strb r0, [r1, 0xF] - b _082E56EA - .align 2, 0 - .pool -_082E56D8: - ldr r2, =gRfuLinkStatus - ldr r1, [r2] - adds r1, 0x10 - adds r1, r7 - ldrb r0, [r1] - adds r0, 0x2 - ldrb r4, [r3, 0x4] - adds r0, r4 - strb r0, [r1] -_082E56EA: - ldr r2, [r2] - ldrb r1, [r3, 0x3] - ldrb r0, [r2, 0x6] - bics r0, r1 - strb r0, [r2, 0x6] -_082E56F4: - mov r0, sp - movs r1, 0 - strh r1, [r0] - ldr r2, =0x01000006 - adds r1, r3, 0 - bl CpuSet -_082E5702: - movs r0, 0x2 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _082E5724 - mov r1, sp - movs r0, 0 - strh r0, [r1] - ldr r1, =gRfuSlotStatusUNI - lsls r0, r7, 2 - adds r0, r1 - ldr r1, [r0] - adds r1, 0xC - ldr r2, =0x01000004 - mov r0, sp - bl CpuSet -_082E5724: - ldr r0, =0x04000208 - mov r2, r10 - strh r2, [r0] - movs r0, 0 -_082E572C: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_clearSlot - - thumb_func_start rfu_setRecvBuffer -rfu_setRecvBuffer: @ 82E5750 - push {r4-r6,lr} - adds r5, r2, 0 - adds r6, r3, 0 - lsls r0, 24 - lsrs r3, r0, 24 - adds r2, r3, 0 - lsls r1, 24 - lsrs r1, 24 - adds r4, r1, 0 - cmp r1, 0x3 - bls _082E576C - movs r0, 0x80 - lsls r0, 3 - b _082E57A4 -_082E576C: - movs r0, 0x20 - ands r0, r3 - cmp r0, 0 - beq _082E5788 - ldr r0, =gRfuSlotStatusNI - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - str r5, [r0, 0x68] - str r6, [r0, 0x6C] - b _082E57A2 - .align 2, 0 - .pool -_082E5788: - movs r0, 0x10 - ands r2, r0 - cmp r2, 0 - bne _082E5796 - movs r0, 0xC0 - lsls r0, 3 - b _082E57A4 -_082E5796: - ldr r0, =gRfuSlotStatusUNI - lsls r1, r4, 2 - adds r1, r0 - ldr r0, [r1] - str r5, [r0, 0x14] - str r6, [r0, 0x18] -_082E57A2: - movs r0, 0 -_082E57A4: - pop {r4-r6} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_setRecvBuffer - - thumb_func_start rfu_NI_setSendData -rfu_NI_setSendData: @ 82E57B0 - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - str r3, [sp] - movs r0, 0x20 - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl rfu_STC_setSendData_org - lsls r0, 16 - lsrs r0, 16 - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end rfu_NI_setSendData - - thumb_func_start rfu_UNI_setSendData -rfu_UNI_setSendData: @ 82E57DC - push {lr} - sub sp, 0x4 - adds r3, r1, 0 - lsls r0, 24 - lsrs r1, r0, 24 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x1 - bne _082E57FC - adds r0, r2, 0x3 - b _082E57FE - .align 2, 0 - .pool -_082E57FC: - adds r0, r2, 0x2 -_082E57FE: - lsls r0, 24 - lsrs r2, r0, 24 - movs r0, 0 - str r0, [sp] - movs r0, 0x10 - bl rfu_STC_setSendData_org - lsls r0, 16 - lsrs r0, 16 - add sp, 0x4 - pop {r1} - bx r1 - thumb_func_end rfu_UNI_setSendData - - thumb_func_start rfu_NI_CHILD_setSendGameName -rfu_NI_CHILD_setSendGameName: @ 82E5818 - push {lr} - sub sp, 0x4 - adds r2, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - movs r1, 0x80 - lsls r1, 17 - lsls r1, r0 - lsrs r1, 24 - ldr r0, =gRfuLinkStatus - ldr r3, [r0] - adds r3, 0x98 - movs r0, 0x1A - str r0, [sp] - movs r0, 0x40 - bl rfu_STC_setSendData_org - lsls r0, 16 - lsrs r0, 16 - add sp, 0x4 - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_NI_CHILD_setSendGameName - - thumb_func_start rfu_STC_setSendData_org -rfu_STC_setSendData_org: @ 82E584C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - str r3, [sp] - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r3, r1, 24 - lsls r2, 24 - lsrs r2, 24 - mov r8, r2 - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r1, [r2] - mov r10, r0 - cmp r1, 0xFF - bne _082E5880 - ldr r0, =0x00000301 - b _082E5A36 - .align 2, 0 - .pool -_082E5880: - movs r0, 0xF - ands r0, r3 - cmp r0, 0 - bne _082E588E - movs r0, 0x80 - lsls r0, 3 - b _082E5A36 -_082E588E: - ldrb r0, [r2, 0x2] - ldrb r1, [r2, 0x3] - orrs r0, r1 - ands r0, r3 - cmp r0, r3 - beq _082E58A4 - ldr r0, =0x00000401 - b _082E5A36 - .align 2, 0 - .pool -_082E58A4: - movs r0, 0x10 - ands r0, r6 - cmp r0, 0 - beq _082E58B0 - ldrb r0, [r2, 0x6] - b _082E58B2 -_082E58B0: - ldrb r0, [r2, 0x4] -_082E58B2: - ands r0, r3 - cmp r0, 0 - beq _082E58C0 - ldr r0, =0x00000402 - b _082E5A36 - .align 2, 0 - .pool -_082E58C0: - movs r2, 0 - movs r0, 0x1 - ands r0, r3 - ldr r4, =llsf_struct - cmp r0, 0 - bne _082E58E2 - movs r1, 0x1 -_082E58CE: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bhi _082E58E2 - adds r0, r3, 0 - asrs r0, r2 - ands r0, r1 - cmp r0, 0 - beq _082E58CE -_082E58E2: - mov r0, r10 - ldr r1, [r0] - ldrb r0, [r1] - cmp r0, 0x1 - bne _082E58F4 - adds r1, 0xF - b _082E58FE - .align 2, 0 - .pool -_082E58F4: - cmp r0, 0 - bne _082E5900 - adds r0, r2, 0 - adds r0, 0x10 - adds r1, r0 -_082E58FE: - mov r9, r1 -_082E5900: - mov r1, r10 - ldr r0, [r1] - ldrb r0, [r0] - lsls r0, 4 - adds r0, r4 - ldrb r4, [r0] - mov r0, r9 - ldrb r0, [r0] - cmp r8, r0 - bhi _082E5918 - cmp r8, r4 - bhi _082E591E -_082E5918: - movs r0, 0xA0 - lsls r0, 3 - b _082E5A36 -_082E591E: - ldr r1, =0x04000208 - ldrh r0, [r1] - str r0, [sp, 0x4] - movs r7, 0 - strh r7, [r1] - movs r0, 0x20 - ands r0, r6 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _082E5938 - cmp r6, 0x40 - bne _082E59F4 -_082E5938: - ldr r1, =gRfuSlotStatusNI - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - mov r12, r0 - movs r1, 0 - strh r1, [r0, 0x18] - mov r1, r12 - adds r1, 0x2D - mov r2, r12 - str r1, [r2, 0x4] - movs r0, 0x7 - str r0, [r2, 0x14] - mov r0, r12 - adds r0, 0x2C - strb r3, [r0] - strb r3, [r2, 0x1A] - mov r2, r8 - subs r0, r2, r4 - mov r2, r12 - strh r0, [r2, 0x2E] - cmp r5, 0 - beq _082E5974 - strb r7, [r1] - b _082E5978 - .align 2, 0 - .pool -_082E5974: - movs r0, 0x1 - strb r0, [r1] -_082E5978: - ldr r0, [sp, 0x28] - mov r1, r12 - str r0, [r1, 0x30] - ldr r2, [sp] - str r2, [r1, 0x28] - movs r1, 0 - mov r0, r12 - strb r1, [r0, 0x1F] - adds r0, 0x20 - strb r1, [r0] - mov r4, r12 - adds r4, 0x1B - movs r6, 0 - mov r2, r12 - adds r2, 0x21 - movs r5, 0x1 -_082E5998: - adds r0, r4, r1 - strb r6, [r0] - adds r0, r2, r1 - strb r5, [r0] - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x3 - bls _082E5998 - movs r2, 0 - movs r5, 0x1 - ldr r4, =gRfuSlotStatusNI - movs r1, 0 -_082E59B2: - adds r0, r3, 0 - asrs r0, r2 - ands r0, r5 - cmp r0, 0 - beq _082E59C4 - lsls r0, r2, 2 - adds r0, r4 - ldr r0, [r0] - strh r1, [r0, 0x2] -_082E59C4: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _082E59B2 - mov r1, r10 - ldr r2, [r1] - ldrb r1, [r2, 0x4] - adds r0, r3, 0 - orrs r0, r1 - strb r0, [r2, 0x4] - mov r2, r9 - ldrb r0, [r2] - mov r1, r8 - subs r0, r1 - strb r0, [r2] - ldr r0, =0x00008021 - mov r2, r12 - strh r0, [r2] - b _082E5A2C - .align 2, 0 - .pool -_082E59F4: - movs r0, 0x10 - ands r0, r6 - cmp r0, 0 - beq _082E5A2C - ldr r1, =gRfuSlotStatusUNI - lsls r0, r2, 2 - adds r0, r1 - ldr r1, [r0] - strb r3, [r1, 0x3] - ldr r0, [sp] - str r0, [r1, 0x8] - mov r2, r8 - subs r0, r2, r4 - strh r0, [r1, 0x4] - mov r2, r9 - ldrb r0, [r2] - mov r2, r8 - subs r0, r2 - mov r2, r9 - strb r0, [r2] - ldr r0, =0x00008024 - strh r0, [r1] - mov r0, r10 - ldr r2, [r0] - ldrb r1, [r2, 0x6] - adds r0, r3, 0 - orrs r0, r1 - strb r0, [r2, 0x6] -_082E5A2C: - ldr r0, =0x04000208 - mov r1, sp - ldrh r1, [r1, 0x4] - strh r1, [r0] - movs r0, 0 -_082E5A36: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_STC_setSendData_org - - thumb_func_start rfu_changeSendTarget -rfu_changeSendTarget: @ 82E5A54 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - lsls r1, 24 - lsrs r7, r1, 24 - lsls r2, 24 - lsrs r6, r2, 24 - cmp r7, 0x3 - bls _082E5A78 - movs r0, 0x80 - lsls r0, 3 - b _082E5BAC -_082E5A78: - cmp r0, 0x20 - bne _082E5B18 - ldr r0, =gRfuSlotStatusNI - mov r12, r0 - lsls r0, r7, 2 - add r0, r12 - ldr r5, [r0] - ldrh r2, [r5] - ldr r1, =0x00008020 - adds r0, r1, 0 - ands r0, r2 - cmp r0, r1 - bne _082E5B2E - ldrb r0, [r5, 0x1A] - adds r3, r6, 0 - eors r3, r0 - adds r2, r3, 0 - ands r2, r6 - cmp r2, 0 - bne _082E5B66 - cmp r3, 0 - bne _082E5AA6 - b _082E5BAA -_082E5AA6: - ldr r1, =0x04000208 - ldrh r0, [r1] - mov r8, r0 - strh r2, [r1] - movs r2, 0 - mvns r1, r3 - str r1, [sp] - lsls r4, r6, 24 - mov r10, r4 - movs r0, 0x1 - mov r9, r0 - movs r1, 0 -_082E5ABE: - adds r0, r3, 0 - asrs r0, r2 - mov r4, r9 - ands r0, r4 - cmp r0, 0 - beq _082E5AD2 - lsls r0, r2, 2 - add r0, r12 - ldr r0, [r0] - strh r1, [r0, 0x2] -_082E5AD2: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _082E5ABE - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - ldrb r0, [r1, 0x4] - ldr r2, [sp] - ands r2, r0 - strb r2, [r1, 0x4] - strb r6, [r5, 0x1A] - mov r0, r10 - cmp r0, 0 - bne _082E5AFE - adds r0, r7, 0 - movs r1, 0 - adds r2, r5, 0 - bl rfu_STC_releaseFrame - movs r0, 0x27 - strh r0, [r5] -_082E5AFE: - ldr r0, =0x04000208 - mov r1, r8 - strh r1, [r0] - b _082E5BAA - .align 2, 0 - .pool -_082E5B18: - cmp r3, 0x10 - bne _082E5BA4 - ldr r3, =gRfuSlotStatusUNI - lsls r1, r7, 2 - adds r0, r1, r3 - ldr r0, [r0] - ldrh r2, [r0] - ldr r0, =0x00008024 - adds r5, r3, 0 - cmp r2, r0 - beq _082E5B40 -_082E5B2E: - ldr r0, =0x00000403 - b _082E5BAC - .align 2, 0 - .pool -_082E5B40: - movs r3, 0 - movs r2, 0 - adds r4, r5, 0 -_082E5B46: - cmp r2, r7 - beq _082E5B54 - lsls r0, r2, 2 - adds r0, r4 - ldr r0, [r0] - ldrb r0, [r0, 0x3] - orrs r3, r0 -_082E5B54: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _082E5B46 - adds r2, r6, 0 - ands r2, r3 - cmp r2, 0 - beq _082E5B70 -_082E5B66: - ldr r0, =0x00000404 - b _082E5BAC - .align 2, 0 - .pool -_082E5B70: - ldr r3, =0x04000208 - ldrh r0, [r3] - mov r8, r0 - strh r2, [r3] - ldr r4, =gRfuLinkStatus - ldr r2, [r4] - adds r5, r1, r5 - ldr r0, [r5] - ldrb r1, [r0, 0x3] - ldrb r0, [r2, 0x6] - bics r0, r1 - strb r0, [r2, 0x6] - ldr r2, [r4] - ldrb r1, [r2, 0x6] - adds r0, r6, 0 - orrs r0, r1 - strb r0, [r2, 0x6] - ldr r0, [r5] - strb r6, [r0, 0x3] - mov r2, r8 - strh r2, [r3] - b _082E5BAA - .align 2, 0 - .pool -_082E5BA4: - movs r0, 0xC0 - lsls r0, 3 - b _082E5BAC -_082E5BAA: - movs r0, 0 -_082E5BAC: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end rfu_changeSendTarget - - thumb_func_start rfu_NI_stopReceivingData -rfu_NI_stopReceivingData: @ 82E5BBC - push {r4,r5,lr} - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bls _082E5BCC - movs r0, 0x80 - lsls r0, 3 - b _082E5C26 -_082E5BCC: - ldr r1, =gRfuSlotStatusNI - lsls r0, r3, 2 - adds r0, r1 - ldr r2, [r0] - adds r5, r2, 0 - adds r5, 0x34 - ldr r1, =0x04000208 - ldrh r0, [r1] - adds r4, r0, 0 - movs r0, 0 - strh r0, [r1] - ldrh r1, [r2, 0x34] - movs r0, 0x80 - lsls r0, 8 - ands r0, r1 - cmp r0, 0 - beq _082E5C20 - ldr r0, =0x00008043 - cmp r1, r0 - bne _082E5C04 - movs r0, 0x48 - b _082E5C06 - .align 2, 0 - .pool -_082E5C04: - movs r0, 0x47 -_082E5C06: - strh r0, [r2, 0x34] - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - movs r1, 0x1 - lsls r1, r3 - ldrb r0, [r2, 0x5] - bics r0, r1 - strb r0, [r2, 0x5] - adds r0, r3, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl rfu_STC_releaseFrame -_082E5C20: - ldr r0, =0x04000208 - strh r4, [r0] - movs r0, 0 -_082E5C26: - pop {r4,r5} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_NI_stopReceivingData - - thumb_func_start rfu_UNI_changeAndReadySendData -rfu_UNI_changeAndReadySendData: @ 82E5C34 - push {r4-r7,lr} - adds r7, r1, 0 - lsls r0, 24 - lsrs r0, 24 - adds r3, r0, 0 - lsls r2, 24 - lsrs r5, r2, 24 - cmp r0, 0x3 - bls _082E5C4C - movs r0, 0x80 - lsls r0, 3 - b _082E5CC0 -_082E5C4C: - ldr r1, =gRfuSlotStatusUNI - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] - ldrh r1, [r4] - ldr r0, =0x00008024 - cmp r1, r0 - beq _082E5C6C - ldr r0, =0x00000403 - b _082E5CC0 - .align 2, 0 - .pool -_082E5C6C: - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - ldrb r0, [r1] - cmp r0, 0x1 - bne _082E5C84 - adds r6, r1, 0 - adds r6, 0xF - ldrb r0, [r4, 0x4] - ldrb r1, [r1, 0xF] - b _082E5C92 - .align 2, 0 - .pool -_082E5C84: - adds r0, r3, 0 - adds r0, 0x10 - adds r6, r1, r0 - adds r1, 0x10 - adds r1, r3 - ldrb r0, [r4, 0x4] - ldrb r1, [r1] -_082E5C92: - adds r0, r1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, r5 - bcc _082E5CBC - ldr r2, =0x04000208 - ldrh r1, [r2] - movs r0, 0 - strh r0, [r2] - str r7, [r4, 0x8] - subs r0, r3, r5 - strb r0, [r6] - strh r5, [r4, 0x4] - movs r0, 0x1 - strb r0, [r4, 0x2] - strh r1, [r2] - movs r0, 0 - b _082E5CC0 - .align 2, 0 - .pool -_082E5CBC: - movs r0, 0xA0 - lsls r0, 3 -_082E5CC0: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end rfu_UNI_changeAndReadySendData - - thumb_func_start rfu_UNI_readySendData -rfu_UNI_readySendData: @ 82E5CC8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bhi _082E5CE6 - ldr r1, =gRfuSlotStatusUNI - lsls r0, 2 - adds r0, r1 - ldr r2, [r0] - ldrh r1, [r2] - ldr r0, =0x00008024 - cmp r1, r0 - bne _082E5CE6 - movs r0, 0x1 - strb r0, [r2, 0x2] -_082E5CE6: - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_UNI_readySendData - - thumb_func_start rfu_UNI_clearRecvNewDataFlag -rfu_UNI_clearRecvNewDataFlag: @ 82E5CF4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bhi _082E5D0A - ldr r1, =gRfuSlotStatusUNI - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - movs r0, 0 - strb r0, [r1, 0x12] -_082E5D0A: - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_UNI_clearRecvNewDataFlag - - thumb_func_start rfu_REQ_sendData -rfu_REQ_sendData: @ 82E5D14 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r1, [r2] - adds r4, r0, 0 - cmp r1, 0xFF - bne _082E5D28 - b _082E5E4E -_082E5D28: - cmp r1, 0x1 - bne _082E5DB8 - ldrb r0, [r2, 0x4] - ldrb r1, [r2, 0x5] - adds r3, r0, 0 - orrs r3, r1 - ldrb r0, [r2, 0x6] - orrs r3, r0 - cmp r3, 0 - bne _082E5DB8 - ldr r0, =gRfuStatic - ldr r2, [r0] - ldrb r1, [r2, 0x3] - adds r4, r0, 0 - cmp r1, 0 - beq _082E5D50 - movs r0, 0x10 - strb r0, [r2, 0x8] - ldr r0, [r4] - strb r3, [r0, 0x7] -_082E5D50: - ldr r1, [r4] - ldrb r0, [r1, 0x8] - cmp r0, 0 - beq _082E5D68 - subs r0, 0x1 - strb r0, [r1, 0x8] - b _082E5D6E - .align 2, 0 - .pool -_082E5D68: - ldrb r0, [r1, 0x7] - adds r0, 0x1 - strb r0, [r1, 0x7] -_082E5D6E: - ldr r1, [r4] - ldrb r0, [r1, 0x8] - cmp r0, 0 - bne _082E5D80 - ldrb r1, [r1, 0x7] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _082E5E12 -_082E5D80: - ldr r4, =gRfuFixed - ldr r1, [r4] - movs r0, 0x1 - str r0, [r1, 0x68] - movs r0, 0xFF - str r0, [r1, 0x78] - ldr r0, =sub_82E5F00 - bl STWI_set_Callback_M - cmp r5, 0 - bne _082E5DAC - ldr r0, [r4] - adds r0, 0x68 - movs r1, 0x1 - bl STWI_send_DataTxREQ - b _082E5E4E - .align 2, 0 - .pool -_082E5DAC: - ldr r0, [r4] - adds r0, 0x68 - movs r1, 0x1 - bl STWI_send_DataTxAndChangeREQ - b _082E5E4E -_082E5DB8: - ldr r0, [r4] - ldrb r0, [r0, 0xE] - cmp r0, 0 - bne _082E5DC4 - bl rfu_constructSendLLFrame -_082E5DC4: - ldr r0, [r4] - ldrb r0, [r0, 0xE] - cmp r0, 0 - beq _082E5E12 - ldr r0, =rfu_CB_sendData - bl STWI_set_Callback_M - cmp r5, 0 - beq _082E5DFC - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0x68 - ldr r1, =gRfuStatic - ldr r1, [r1] - ldr r1, [r1, 0x24] - adds r1, 0x4 - lsls r1, 24 - lsrs r1, 24 - bl STWI_send_DataTxAndChangeREQ - b _082E5E4E - .align 2, 0 - .pool -_082E5DFC: - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0x68 - ldr r1, =gRfuStatic - ldr r1, [r1] - ldr r1, [r1, 0x24] - adds r1, 0x4 - lsls r1, 24 - lsrs r1, 24 - bl STWI_send_DataTxREQ -_082E5E12: - cmp r5, 0 - beq _082E5E4E - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x1 - bne _082E5E44 - ldr r0, =gSTWIStatus - ldr r0, [r0] - ldr r1, [r0, 0x1C] - cmp r1, 0 - beq _082E5E4E - movs r0, 0x27 - bl _call_via_r1 - b _082E5E4E - .align 2, 0 - .pool -_082E5E44: - ldr r0, =rfu_CB_sendData2 - bl STWI_set_Callback_M - bl STWI_send_MS_ChangeREQ -_082E5E4E: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_sendData - - thumb_func_start rfu_CB_sendData -rfu_CB_sendData: @ 82E5E58 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r1, 16 - lsrs r7, r1, 16 - cmp r7, 0 - bne _082E5EC2 - movs r6, 0 - ldr r0, =0x00008020 - mov r8, r0 -_082E5E6C: - ldr r0, =gRfuSlotStatusUNI - lsls r2, r6, 2 - adds r0, r2, r0 - ldr r1, [r0] - ldrb r0, [r1, 0x2] - cmp r0, 0 - beq _082E5E7E - movs r0, 0 - strb r0, [r1, 0x2] -_082E5E7E: - ldr r0, =gRfuSlotStatusNI - adds r0, r2, r0 - ldr r4, [r0] - ldrh r0, [r4] - cmp r0, r8 - bne _082E5EB8 - adds r0, r6, 0 - movs r1, 0 - adds r2, r4, 0 - bl rfu_STC_releaseFrame - ldr r5, =gRfuLinkStatus - ldr r2, [r5] - ldrb r1, [r4, 0x1A] - ldrb r0, [r2, 0x4] - bics r0, r1 - strb r0, [r2, 0x4] - adds r0, r4, 0 - adds r0, 0x2D - ldrb r3, [r0] - cmp r3, 0x1 - bne _082E5EB4 - ldr r1, [r5] - lsls r3, r6 - ldrb r0, [r1, 0x7] - orrs r3, r0 - strb r3, [r1, 0x7] -_082E5EB4: - movs r0, 0x26 - strh r0, [r4] -_082E5EB8: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _082E5E6C -_082E5EC2: - ldr r0, =gRfuLinkStatus - ldr r1, [r0] - ldrb r0, [r1, 0xE] - movs r0, 0 - strb r0, [r1, 0xE] - movs r0, 0x24 - adds r1, r7, 0 - bl rfu_STC_REQ_callback - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_sendData - - thumb_func_start rfu_CB_sendData2 -rfu_CB_sendData2: @ 82E5EF0 - push {lr} - lsls r1, 16 - lsrs r1, 16 - movs r0, 0x24 - bl rfu_STC_REQ_callback - pop {r0} - bx r0 - thumb_func_end rfu_CB_sendData2 - - thumb_func_start sub_82E5F00 -sub_82E5F00: @ 82E5F00 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - cmp r1, 0 - beq _082E5F16 - movs r0, 0x24 - bl rfu_STC_REQ_callback - b _082E5F22 -_082E5F16: - cmp r0, 0xFF - bne _082E5F22 - movs r0, 0xFF - movs r1, 0 - bl rfu_STC_REQ_callback -_082E5F22: - pop {r0} - bx r0 - thumb_func_end sub_82E5F00 - - thumb_func_start rfu_constructSendLLFrame -rfu_constructSendLLFrame: @ 82E5F28 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r0, [r2] - cmp r0, 0xFF - bne _082E5F40 - b _082E6044 -_082E5F40: - ldrb r0, [r2, 0x4] - ldrb r1, [r2, 0x5] - orrs r0, r1 - ldrb r1, [r2, 0x6] - orrs r0, r1 - cmp r0, 0 - beq _082E6044 - ldrb r0, [r2, 0xE] - movs r0, 0 - strb r0, [r2, 0xE] - mov r8, r0 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0x6C - str r0, [sp] - movs r6, 0 - movs r0, 0x80 - lsls r0, 8 - mov r9, r0 - ldr r1, =0x00008024 - mov r10, r1 -_082E5F6A: - movs r5, 0 - ldr r0, =gRfuSlotStatusNI - lsls r7, r6, 2 - adds r4, r7, r0 - ldr r2, [r4] - ldrh r1, [r2] - mov r0, r9 - ands r0, r1 - cmp r0, 0 - beq _082E5F8A - adds r0, r6, 0 - mov r1, sp - bl rfu_STC_NI_constructLLSF - lsls r0, 16 - lsrs r5, r0, 16 -_082E5F8A: - ldr r2, [r4] - ldrh r1, [r2, 0x34] - mov r0, r9 - ands r0, r1 - cmp r0, 0 - beq _082E5FA6 - adds r2, 0x34 - adds r0, r6, 0 - mov r1, sp - bl rfu_STC_NI_constructLLSF - lsls r0, 16 - lsrs r0, 16 - adds r5, r0 -_082E5FA6: - ldr r0, =gRfuSlotStatusUNI - adds r0, r7, r0 - ldr r0, [r0] - ldrh r0, [r0] - cmp r0, r10 - bne _082E5FC0 - adds r0, r6, 0 - mov r1, sp - bl rfu_STC_UNI_constructLLSF - lsls r0, 16 - lsrs r0, 16 - adds r5, r0 -_082E5FC0: - cmp r5, 0 - beq _082E5FF4 - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x1 - bne _082E5FE8 - add r8, r5 - b _082E5FF4 - .align 2, 0 - .pool -_082E5FE8: - adds r0, r7, r6 - adds r0, 0x8 - lsls r5, r0 - mov r2, r8 - orrs r2, r5 - mov r8, r2 -_082E5FF4: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _082E5F6A - ldr r6, =gRfuStatic - mov r0, r8 - cmp r0, 0 - beq _082E603E - ldr r2, [sp] - movs r0, 0x3 - ands r0, r2 - ldr r5, =gRfuLinkStatus - ldr r1, =gRfuFixed - cmp r0, 0 - beq _082E6026 - movs r4, 0 - movs r3, 0x3 -_082E6018: - strb r4, [r2] - adds r0, r2, 0x1 - str r0, [sp] - adds r2, r0, 0 - ands r0, r3 - cmp r0, 0 - bne _082E6018 -_082E6026: - ldr r0, [r1] - mov r2, r8 - str r2, [r0, 0x68] - ldr r0, [r5] - ldrb r0, [r0] - cmp r0, 0 - bne _082E603E - ldr r0, [sp] - subs r0, 0x6C - ldr r1, [r1] - subs r0, r1 - mov r8, r0 -_082E603E: - ldr r0, [r6] - mov r1, r8 - str r1, [r0, 0x24] -_082E6044: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_constructSendLLFrame - - thumb_func_start rfu_STC_NI_constructLLSF -rfu_STC_NI_constructLLSF: @ 82E6060 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - mov r12, r1 - adds r4, r2, 0 - lsls r0, 24 - lsrs r0, 24 - mov r10, r0 - ldr r2, =gRfuLinkStatus - ldr r0, [r2] - ldrb r0, [r0] - lsls r0, 4 - ldr r1, =llsf_struct - adds r0, r1 - mov r8, r0 - ldrh r1, [r4] - ldr r0, =0x00008022 - cmp r1, r0 - bne _082E60CA - adds r3, r4, 0 - adds r3, 0x20 - ldrb r1, [r3] - lsls r1, 2 - adds r5, r4, 0x4 - adds r1, r5, r1 - ldr r2, [r4, 0x28] - ldr r0, [r4, 0x30] - adds r2, r0 - ldr r0, [r1] - adds r6, r3, 0 - cmp r0, r2 - bcc _082E60CA - movs r7, 0 -_082E60A8: - ldrb r0, [r3] - adds r0, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _082E60B8 - strb r7, [r6] -_082E60B8: - ldrb r1, [r3] - lsls r1, 2 - adds r1, r5, r1 - ldr r2, [r4, 0x28] - ldr r0, [r4, 0x30] - adds r2, r0 - ldr r0, [r1] - cmp r0, r2 - bcs _082E60A8 -_082E60CA: - ldrh r1, [r4] - movs r0, 0x40 - ands r0, r1 - mov r9, r1 - cmp r0, 0 - beq _082E60E8 - movs r5, 0 - b _082E612C - .align 2, 0 - .pool -_082E60E8: - ldr r0, =0x00008022 - cmp r9, r0 - bne _082E611C - adds r3, r4, 0 - adds r3, 0x20 - ldrb r0, [r3] - lsls r0, 2 - adds r1, r4, 0x4 - adds r1, r0 - ldrh r7, [r4, 0x2E] - ldr r5, [r1] - adds r2, r5, r7 - ldr r1, [r4, 0x28] - ldr r0, [r4, 0x30] - adds r0, r1, r0 - adds r6, r3, 0 - cmp r2, r0 - bls _082E6118 - subs r0, r5 - lsls r0, 16 - lsrs r5, r0, 16 - b _082E6130 - .align 2, 0 - .pool -_082E6118: - adds r5, r7, 0 - b _082E6130 -_082E611C: - ldrh r2, [r4, 0x2E] - ldr r0, [r4, 0x14] - cmp r0, r2 - bcc _082E6128 - adds r5, r2, 0 - b _082E612C -_082E6128: - lsls r0, 16 - lsrs r5, r0, 16 -_082E612C: - adds r6, r4, 0 - adds r6, 0x20 -_082E6130: - movs r3, 0xF - mov r0, r9 - ands r3, r0 - mov r1, r8 - ldrb r1, [r1, 0x3] - lsls r3, r1 - ldrb r0, [r4, 0x1F] - mov r2, r8 - ldrb r2, [r2, 0x4] - lsls r0, r2 - orrs r3, r0 - ldrb r1, [r6] - adds r0, r1, 0 - mov r7, r8 - ldrb r7, [r7, 0x5] - lsls r0, r7 - orrs r3, r0 - adds r0, r4, 0 - adds r0, 0x21 - adds r0, r1 - ldrb r0, [r0] - mov r1, r8 - ldrb r1, [r1, 0x6] - lsls r0, r1 - orrs r3, r0 - orrs r3, r5 - str r3, [sp] - ldr r2, =gRfuLinkStatus - ldr r0, [r2] - ldrb r0, [r0] - cmp r0, 0x1 - bne _082E6178 - ldrb r0, [r4, 0x1A] - lsls r0, 18 - orrs r3, r0 - str r3, [sp] -_082E6178: - mov r2, sp - movs r3, 0 - mov r7, r8 - ldrb r7, [r7] - cmp r3, r7 - bcs _082E61A2 -_082E6184: - mov r0, r12 - ldr r1, [r0] - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r1, 0x1 - mov r7, r12 - str r1, [r7] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - mov r0, r8 - ldrb r0, [r0] - cmp r3, r0 - bcc _082E6184 -_082E61A2: - cmp r5, 0 - beq _082E61C2 - ldrb r1, [r6] - lsls r1, 2 - adds r0, r4, 0x4 - adds r0, r1 - ldr r0, [r0] - str r0, [sp, 0x4] - ldr r0, =gRfuFixed - ldr r1, [r0] - add r0, sp, 0x4 - ldr r3, [r1, 0x4] - mov r1, r12 - adds r2, r5, 0 - bl _call_via_r3 -_082E61C2: - ldrh r1, [r4] - ldr r0, =0x00008022 - cmp r1, r0 - bne _082E61DC - ldrb r0, [r6] - adds r0, 0x1 - strb r0, [r6] - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _082E61DC - movs r0, 0 - strb r0, [r6] -_082E61DC: - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r1, [r2] - cmp r1, 0x1 - bne _082E61F8 - ldrb r0, [r2, 0xE] - strb r1, [r2, 0xE] - b _082E6206 - .align 2, 0 - .pool -_082E61F8: - movs r0, 0x1 - mov r1, r10 - lsls r0, r1 - ldrb r1, [r2, 0xE] - orrs r0, r1 - ldrb r1, [r2, 0xE] - strb r0, [r2, 0xE] -_082E6206: - mov r2, r8 - ldrb r0, [r2] - adds r0, r5, r0 - lsls r0, 16 - lsrs r0, 16 - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end rfu_STC_NI_constructLLSF - - thumb_func_start rfu_STC_UNI_constructLLSF -rfu_STC_UNI_constructLLSF: @ 82E6220 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - adds r6, r1, 0 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r1, =gRfuSlotStatusUNI - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] - ldrb r0, [r4, 0x2] - cmp r0, 0 - beq _082E6244 - ldrb r0, [r4, 0x3] - cmp r0, 0 - bne _082E624C -_082E6244: - movs r0, 0 - b _082E62E8 - .align 2, 0 - .pool -_082E624C: - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r0, [r2] - lsls r0, 4 - ldr r1, =llsf_struct - adds r5, r0, r1 - ldrh r0, [r4] - movs r1, 0xF - ands r1, r0 - ldrb r0, [r5, 0x3] - lsls r1, r0 - ldrh r0, [r4, 0x4] - orrs r1, r0 - str r1, [sp] - ldrb r0, [r2] - cmp r0, 0x1 - bne _082E6276 - ldrb r0, [r4, 0x3] - lsls r0, 18 - orrs r1, r0 - str r1, [sp] -_082E6276: - mov r2, sp - movs r3, 0 - ldr r1, =gRfuFixed - mov r12, r1 - add r7, sp, 0x4 - ldrb r0, [r5] - cmp r3, r0 - bcs _082E629E -_082E6286: - ldr r1, [r6] - ldrb r0, [r2] - strb r0, [r1] - adds r2, 0x1 - adds r1, 0x1 - str r1, [r6] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - ldrb r1, [r5] - cmp r3, r1 - bcc _082E6286 -_082E629E: - ldr r0, [r4, 0x8] - str r0, [sp, 0x4] - mov r2, r12 - ldr r0, [r2] - ldrh r2, [r4, 0x4] - ldr r3, [r0, 0x4] - adds r0, r7, 0 - adds r1, r6, 0 - bl _call_via_r3 - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r0, [r2] - cmp r0, 0x1 - bne _082E62D0 - ldrb r0, [r2, 0xE] - movs r0, 0x10 - b _082E62DC - .align 2, 0 - .pool -_082E62D0: - movs r0, 0x10 - mov r1, r8 - lsls r0, r1 - ldrb r1, [r2, 0xE] - orrs r0, r1 - ldrb r1, [r2, 0xE] -_082E62DC: - strb r0, [r2, 0xE] - ldrh r0, [r4, 0x4] - ldrb r5, [r5] - adds r0, r5 - lsls r0, 16 - lsrs r0, 16 -_082E62E8: - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end rfu_STC_UNI_constructLLSF - - thumb_func_start rfu_REQ_recvData -rfu_REQ_recvData: @ 82E62F4 - push {r4,lr} - ldr r0, =gRfuLinkStatus - ldr r4, [r0] - ldrb r0, [r4] - cmp r0, 0xFF - beq _082E6320 - ldr r2, =gRfuStatic - ldr r3, [r2] - ldrb r0, [r4, 0x4] - ldrb r1, [r4, 0x5] - orrs r0, r1 - ldrb r1, [r4, 0x6] - orrs r0, r1 - movs r1, 0 - strb r0, [r3, 0x3] - ldr r0, [r2] - strb r1, [r0, 0x4] - ldr r0, =rfu_CB_recvData - bl STWI_set_Callback_M - bl STWI_send_DataRxREQ -_082E6320: - pop {r4} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_recvData - - thumb_func_start rfu_CB_recvData -rfu_CB_recvData: @ 82E6334 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r1, 16 - lsrs r7, r1, 16 - cmp r7, 0 - bne _082E63F8 - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r0, [r0] - ldrb r0, [r0, 0x1] - cmp r0, 0 - beq _082E63F8 - ldr r0, =gRfuStatic - ldr r0, [r0] - strb r7, [r0, 0x1] - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0] - cmp r0, 0x1 - bne _082E637C - bl rfu_STC_PARENT_analyzeRecvPacket - b _082E6380 - .align 2, 0 - .pool -_082E637C: - bl rfu_STC_CHILD_analyzeRecvPacket -_082E6380: - movs r6, 0 - ldr r0, =0x00008043 - mov r8, r0 - ldr r3, =gRfuLinkStatus -_082E6388: - ldr r0, =gRfuSlotStatusNI - lsls r1, r6, 2 - adds r1, r0 - ldr r4, [r1] - ldrh r0, [r4, 0x34] - cmp r0, r8 - bne _082E63DA - ldr r0, =gRfuStatic - ldr r0, [r0] - ldrb r0, [r0, 0x1] - asrs r0, r6 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - bne _082E63DA - adds r5, r4, 0 - adds r5, 0x34 - adds r0, r4, 0 - adds r0, 0x61 - ldrb r2, [r0] - cmp r2, 0x1 - bne _082E63BE - ldr r1, [r3] - lsls r2, r6 - ldrb r0, [r1, 0x7] - orrs r2, r0 - strb r2, [r1, 0x7] -_082E63BE: - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r5, 0 - str r3, [sp] - bl rfu_STC_releaseFrame - ldr r3, [sp] - ldr r2, [r3] - ldrb r1, [r5, 0x1A] - ldrb r0, [r2, 0x5] - bics r0, r1 - strb r0, [r2, 0x5] - movs r0, 0x46 - strh r0, [r4, 0x34] -_082E63DA: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x3 - bls _082E6388 - ldr r0, =gRfuStatic - ldr r1, [r0] - ldrb r0, [r1, 0x4] - cmp r0, 0 - beq _082E63F8 - adds r7, r0, 0 - movs r1, 0xE0 - lsls r1, 3 - adds r0, r1, 0 - orrs r7, r0 -_082E63F8: - mov r0, r9 - adds r1, r7, 0 - bl rfu_STC_REQ_callback - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_CB_recvData - - thumb_func_start rfu_STC_PARENT_analyzeRecvPacket -rfu_STC_PARENT_analyzeRecvPacket: @ 82E6420 - push {r4-r7,lr} - sub sp, 0x4 - ldr r1, =gRfuFixed - ldr r0, [r1] - adds r0, 0xDC - ldr r0, [r0] - ldr r0, [r0, 0x4] - lsrs r3, r0, 8 - movs r5, 0 - mov r12, r1 - movs r7, 0x1F - ldr r4, =gRfuStatic - movs r6, 0x1 -_082E643A: - mov r0, sp - adds r1, r0, r5 - adds r0, r3, 0 - ands r0, r7 - strb r0, [r1] - lsrs r3, 5 - cmp r0, 0 - bne _082E6456 - ldr r0, [r4] - adds r1, r6, 0 - lsls r1, r5 - ldrb r2, [r0, 0x1] - orrs r1, r2 - strb r1, [r0, 0x1] -_082E6456: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _082E643A - mov r1, r12 - ldr r0, [r1] - adds r0, 0xDC - ldr r0, [r0] - adds r6, r0, 0 - adds r6, 0x8 - movs r5, 0 -_082E646E: - mov r0, sp - adds r1, r0, r5 - ldrb r0, [r1] - adds r7, r5, 0x1 - cmp r0, 0 - beq _082E64A0 - adds r4, r1, 0 -_082E647C: - ldrb r2, [r4] - adds r0, r5, 0 - adds r1, r6, 0 - bl rfu_STC_analyzeLLSF - lsls r0, 24 - lsrs r0, 24 - adds r6, r0 - ldrb r1, [r4] - subs r1, r0 - strb r1, [r4] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _082E64A0 - lsls r0, r1, 24 - cmp r0, 0 - bne _082E647C -_082E64A0: - lsls r0, r7, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _082E646E - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_PARENT_analyzeRecvPacket - - thumb_func_start rfu_STC_CHILD_analyzeRecvPacket -rfu_STC_CHILD_analyzeRecvPacket: @ 82E64B8 - push {r4-r6,lr} - ldr r0, =gRfuFixed - ldr r0, [r0] - adds r0, 0xDC - ldr r1, [r0] - ldrh r0, [r1, 0x4] - movs r4, 0x7F - ands r4, r0 - adds r5, r1, 0 - adds r5, 0x8 - cmp r4, 0 - bne _082E64D8 - ldr r0, =gRfuStatic - ldr r1, [r0] - movs r0, 0xF - strb r0, [r1, 0x1] -_082E64D8: - movs r0, 0x80 - lsls r0, 8 - adds r6, r0, 0 -_082E64DE: - cmp r4, 0 - beq _082E6500 - movs r0, 0 - adds r1, r5, 0 - adds r2, r4, 0 - bl rfu_STC_analyzeLLSF - lsls r0, 16 - lsrs r0, 16 - adds r5, r0 - subs r0, r4, r0 - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - ands r0, r6 - cmp r0, 0 - beq _082E64DE -_082E6500: - pop {r4-r6} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_CHILD_analyzeRecvPacket - - thumb_func_start rfu_STC_analyzeLLSF -rfu_STC_analyzeLLSF: @ 82E6510 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - adds r7, r1, 0 - lsls r0, 24 - lsrs r0, 24 - mov r12, r0 - lsls r2, 16 - lsrs r3, r2, 16 - ldr r2, =gRfuLinkStatus - ldr r0, [r2] - ldrb r0, [r0] - mvns r0, r0 - movs r1, 0x1 - ands r0, r1 - lsls r0, 4 - ldr r1, =llsf_struct - adds r6, r0, r1 - ldrb r0, [r6] - cmp r3, r0 - bcs _082E654C - adds r0, r3, 0 - b _082E673E - .align 2, 0 - .pool -_082E654C: - movs r5, 0 - movs r4, 0 - ldrb r3, [r6, 0x1] - ldrb r1, [r6, 0x7] - mov r8, r1 - ldr r2, [sp] - mov r9, r2 - cmp r4, r0 - bcs _082E6574 - adds r2, r0, 0 -_082E6560: - ldrb r0, [r7] - lsls r1, r4, 3 - lsls r0, r1 - orrs r5, r0 - adds r7, 0x1 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, r2 - bcc _082E6560 -_082E6574: - adds r0, r5, 0 - lsrs r0, r3 - mov r3, r8 - ands r0, r3 - ldr r1, =0xffffff00 - mov r10, r1 - mov r3, r10 - mov r2, r9 - ands r3, r2 - orrs r3, r0 - str r3, [sp] - adds r0, r5, 0 - ldrb r1, [r6, 0x2] - lsrs r0, r1 - ldrb r1, [r6, 0x8] - ands r0, r1 - lsls r0, 8 - ldr r4, =0xffff00ff - adds r2, r4, 0 - ands r2, r3 - orrs r2, r0 - str r2, [sp] - adds r0, r5, 0 - ldrb r3, [r6, 0x3] - lsrs r0, r3 - ldrb r1, [r6, 0x9] - ands r0, r1 - lsls r0, 16 - ldr r3, =0xff00ffff - ands r3, r2 - orrs r3, r0 - str r3, [sp] - adds r0, r5, 0 - ldrb r1, [r6, 0x4] - lsrs r0, r1 - ldrb r1, [r6, 0xA] - ands r0, r1 - lsls r0, 24 - ldr r2, =0x00ffffff - mov r8, r2 - mov r1, r8 - ands r1, r3 - orrs r1, r0 - mov r8, r1 - str r1, [sp] - adds r1, r5, 0 - ldrb r2, [r6, 0x5] - lsrs r1, r2 - ldrb r0, [r6, 0xB] - ands r1, r0 - mov r9, sp - ldr r2, [sp, 0x4] - mov r3, r10 - ands r2, r3 - orrs r2, r1 - str r2, [sp, 0x4] - adds r0, r5, 0 - ldrb r1, [r6, 0x6] - lsrs r0, r1 - ldrb r1, [r6, 0xC] - ands r0, r1 - lsls r0, 8 - ands r4, r2 - orrs r4, r0 - str r4, [sp, 0x4] - ldrh r0, [r6, 0xE] - ands r5, r0 - lsls r1, r5, 16 - ldr r0, =0x0000ffff - ands r0, r4 - orrs r0, r1 - str r0, [sp, 0x4] - lsrs r0, 16 - ldrb r6, [r6] - adds r0, r6 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - mov r0, sp - ldrb r0, [r0] - cmp r0, 0 - beq _082E661A - b _082E673C -_082E661A: - ldr r2, =gRfuLinkStatus - ldr r3, [r2] - ldrb r2, [r3] - cmp r2, 0x1 - bne _082E66D8 - ldrb r0, [r3, 0x2] - mov r5, r12 - asrs r0, r5 - ands r0, r2 - cmp r0, 0 - bne _082E6632 - b _082E673C -_082E6632: - mov r1, r8 - lsrs r0, r1, 16 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _082E6664 - mov r0, r12 - mov r1, sp - adds r2, r7, 0 - bl rfu_STC_UNI_receive - b _082E673C - .align 2, 0 - .pool -_082E6664: - mov r5, r9 - ldrb r0, [r5, 0x3] - cmp r0, 0 - bne _082E6678 - mov r0, r12 - mov r1, sp - adds r2, r7, 0 - bl rfu_STC_NI_receive_Receiver - b _082E673C -_082E6678: - movs r4, 0 - ldr r1, =gRfuSlotStatusNI - ldr r0, [r1] - ldrb r0, [r0, 0x1A] - mov r5, r12 - asrs r0, r5 - ands r0, r2 - cmp r0, 0 - beq _082E6694 - ldrb r0, [r3, 0x4] - b _082E66BA - .align 2, 0 - .pool -_082E6694: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bhi _082E673C - lsls r0, r4, 2 - adds r0, r1 - ldr r0, [r0] - ldrb r0, [r0, 0x1A] - mov r2, r12 - asrs r0, r2 - movs r2, 0x1 - ands r0, r2 - cmp r0, 0 - beq _082E6694 - ldr r3, =gRfuLinkStatus - ldr r0, [r3] - ldrb r0, [r0, 0x4] - mov r5, r12 -_082E66BA: - asrs r0, r5 - ands r0, r2 - cmp r0, 0 - beq _082E6694 - cmp r4, 0x3 - bhi _082E673C - adds r0, r4, 0 - mov r1, r12 - mov r2, sp - adds r3, r7, 0 - bl rfu_STC_NI_receive_Sender - b _082E673C - .align 2, 0 - .pool -_082E66D8: - ldrb r1, [r3, 0x2] - mov r2, r9 - ldrb r0, [r2, 0x1] - adds r5, r1, 0 - ands r5, r0 - cmp r5, 0 - beq _082E673C - movs r4, 0 - movs r6, 0x1 -_082E66EA: - adds r0, r5, 0 - asrs r0, r4 - ands r0, r6 - cmp r0, 0 - beq _082E6732 - mov r1, sp - ldrb r0, [r1, 0x2] - cmp r0, 0x4 - bne _082E6706 - adds r0, r4, 0 - adds r2, r7, 0 - bl rfu_STC_UNI_receive - b _082E6732 -_082E6706: - ldrb r0, [r1, 0x3] - cmp r0, 0 - bne _082E6718 - adds r0, r4, 0 - mov r1, sp - adds r2, r7, 0 - bl rfu_STC_NI_receive_Receiver - b _082E6732 -_082E6718: - ldr r0, =gRfuLinkStatus - ldr r0, [r0] - ldrb r0, [r0, 0x4] - asrs r0, r4 - ands r0, r6 - cmp r0, 0 - beq _082E6732 - adds r0, r4, 0 - adds r1, r4, 0 - mov r2, sp - adds r3, r7, 0 - bl rfu_STC_NI_receive_Sender -_082E6732: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _082E66EA -_082E673C: - mov r0, r10 -_082E673E: - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end rfu_STC_analyzeLLSF - - thumb_func_start rfu_STC_UNI_receive -rfu_STC_UNI_receive: @ 82E6754 - push {r4-r7,lr} - sub sp, 0x8 - adds r6, r1, 0 - str r2, [sp] - lsls r0, 24 - lsrs r7, r0, 24 - ldr r2, =gRfuSlotStatusUNI - lsls r1, r7, 2 - adds r1, r2 - ldr r3, [r1] - adds r5, r3, 0 - adds r5, 0xC - movs r4, 0 - movs r0, 0 - strh r0, [r5, 0x2] - ldr r0, [r1] - ldr r0, [r0, 0x18] - adds r1, r2, 0 - ldrh r2, [r6, 0x6] - cmp r0, r2 - bcs _082E6790 - movs r0, 0x49 - strh r0, [r3, 0xC] - ldr r0, =0x00000701 - strh r0, [r5, 0x2] - b _082E67DE - .align 2, 0 - .pool -_082E6790: - ldrb r0, [r5, 0x7] - cmp r0, 0 - beq _082E67A8 - ldrb r0, [r5, 0x6] - cmp r0, 0 - beq _082E67B4 - ldr r0, =0x00000709 - strh r0, [r5, 0x2] - b _082E67DE - .align 2, 0 - .pool -_082E67A8: - ldrb r0, [r5, 0x6] - cmp r0, 0 - beq _082E67B4 - movs r0, 0xE1 - lsls r0, 3 - strh r0, [r5, 0x2] -_082E67B4: - movs r4, 0 - ldr r0, =0x00008042 - strh r0, [r5] - ldrh r0, [r6, 0x6] - strh r0, [r5, 0x4] - ldrh r2, [r6, 0x6] - lsls r0, r7, 2 - adds r0, r1 - ldr r0, [r0] - ldr r0, [r0, 0x14] - str r0, [sp, 0x4] - ldr r0, =gRfuFixed - ldr r0, [r0] - add r1, sp, 0x4 - ldr r3, [r0, 0x4] - mov r0, sp - bl _call_via_r3 - movs r0, 0x1 - strb r0, [r5, 0x6] - strh r4, [r5] -_082E67DE: - ldrh r0, [r5, 0x2] - cmp r0, 0 - beq _082E67F2 - ldr r0, =gRfuStatic - ldr r2, [r0] - movs r0, 0x10 - lsls r0, r7 - ldrb r1, [r2, 0x4] - orrs r0, r1 - strb r0, [r2, 0x4] -_082E67F2: - add sp, 0x8 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_UNI_receive - - thumb_func_start rfu_STC_NI_receive_Sender -rfu_STC_NI_receive_Sender: @ 82E6808 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - adds r6, r2, 0 - lsls r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r10, r1 - ldr r1, =gRfuSlotStatusNI - lsrs r0, 22 - adds r0, r1 - ldr r0, [r0] - mov r12, r0 - ldrh r0, [r0] - mov r9, r0 - mov r0, r12 - adds r0, 0x21 - ldrb r2, [r6, 0x4] - adds r0, r2 - ldrb r0, [r0] - str r0, [sp] - ldrb r2, [r6, 0x2] - cmp r2, 0x2 - bne _082E6844 - ldr r0, =0x00008022 - cmp r9, r0 - beq _082E685E -_082E6844: - cmp r2, 0x1 - bne _082E684E - ldr r0, =0x00008021 - cmp r9, r0 - beq _082E685E -_082E684E: - movs r3, 0x1B - add r3, r12 - mov r8, r3 - cmp r2, 0x3 - bne _082E6882 - ldr r0, =0x00008023 - cmp r9, r0 - bne _082E6882 -_082E685E: - ldrb r1, [r6, 0x4] - mov r0, r12 - adds r0, 0x21 - adds r0, r1 - ldrb r0, [r0] - movs r7, 0x1B - add r7, r12 - mov r8, r7 - ldrb r2, [r6, 0x5] - cmp r0, r2 - bne _082E6882 - adds r0, r7, r1 - movs r1, 0x1 - mov r3, r10 - lsls r1, r3 - ldrb r2, [r0] - orrs r1, r2 - strb r1, [r0] -_082E6882: - ldrb r2, [r6, 0x4] - mov r7, r8 - adds r0, r7, r2 - ldrb r0, [r0] - mov r3, r12 - ldrb r1, [r3, 0x1A] - ands r0, r1 - cmp r0, r1 - bne _082E697E - adds r3, 0x21 - adds r2, r3, r2 - ldrb r0, [r2] - adds r0, 0x1 - movs r1, 0x3 - ands r0, r1 - movs r1, 0 - strb r0, [r2] - ldrb r0, [r6, 0x4] - add r0, r8 - strb r1, [r0] - mov r7, r12 - ldrh r1, [r7] - ldr r2, =0x00007fdf - adds r0, r1, r2 - lsls r0, 16 - lsrs r0, 16 - adds r5, r3, 0 - cmp r0, 0x1 - bhi _082E6970 - ldr r0, =0x00008021 - cmp r1, r0 - bne _082E68E8 - ldrb r1, [r6, 0x4] - lsls r1, 2 - subs r3, 0x1D - adds r1, r3, r1 - ldrh r2, [r7, 0x2E] - ldr r0, [r1] - adds r0, r2 - str r0, [r1] - b _082E68FE - .align 2, 0 - .pool -_082E68E8: - ldrb r2, [r6, 0x4] - lsls r2, 2 - mov r3, r12 - adds r3, 0x4 - adds r2, r3, r2 - mov r7, r12 - ldrh r1, [r7, 0x2E] - lsls r1, 2 - ldr r0, [r2] - adds r0, r1 - str r0, [r2] -_082E68FE: - mov r0, r12 - ldrh r1, [r0, 0x2E] - ldr r0, [r0, 0x14] - subs r0, r1 - mov r1, r12 - str r0, [r1, 0x14] - cmp r0, 0 - beq _082E6912 - cmp r0, 0 - bge _082E697E -_082E6912: - mov r0, r12 - adds r0, 0x20 - movs r2, 0 - strb r2, [r0] - mov r7, r12 - ldrh r1, [r7] - ldr r0, =0x00008021 - cmp r1, r0 - bne _082E695C - movs r4, 0 -_082E6926: - adds r0, r5, r4 - movs r1, 0x1 - strb r1, [r0] - lsls r1, r4, 2 - adds r1, r3, r1 - mov r2, r12 - ldrh r0, [r2, 0x2E] - adds r2, r0, 0 - muls r2, r4 - mov r7, r12 - ldr r0, [r7, 0x28] - adds r0, r2 - str r0, [r1] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _082E6926 - ldr r0, [r7, 0x30] - str r0, [r7, 0x14] - ldr r0, =0x00008022 - strh r0, [r7] - b _082E697E - .align 2, 0 - .pool -_082E695C: - strb r2, [r5] - mov r0, r12 - str r2, [r0, 0x14] - ldr r0, =0x00008023 - mov r1, r12 - strh r0, [r1] - b _082E697E - .align 2, 0 - .pool -_082E6970: - lsls r1, 16 - ldr r0, =0x80230000 - cmp r1, r0 - bne _082E697E - ldr r0, =0x00008020 - mov r2, r12 - strh r0, [r2] -_082E697E: - mov r3, r12 - ldrh r0, [r3] - cmp r0, r9 - bne _082E69A8 - ldrb r2, [r6, 0x4] - mov r0, r12 - adds r0, 0x21 - adds r0, r2 - ldrb r0, [r0] - ldr r7, [sp] - cmp r0, r7 - bne _082E69A8 - mov r1, r8 - adds r0, r1, r2 - ldrb r0, [r0] - mov r2, r10 - asrs r0, r2 - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _082E69CE -_082E69A8: - ldr r4, =0x04000208 - ldrh r2, [r4] - movs r0, 0 - strh r0, [r4] - ldr r0, =gRfuStatic - ldr r3, [r0] - movs r0, 0x10 - mov r7, r10 - lsls r0, r7 - ldrb r1, [r3, 0x2] - orrs r0, r1 - movs r1, 0 - strb r0, [r3, 0x2] - lsls r0, r7, 2 - ldr r3, =gRfuSlotStatusNI - adds r0, r3 - ldr r0, [r0] - strh r1, [r0, 0x2] - strh r2, [r4] -_082E69CE: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_NI_receive_Sender - - thumb_func_start rfu_STC_NI_receive_Receiver -rfu_STC_NI_receive_Receiver: @ 82E69F4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - adds r6, r1, 0 - str r2, [sp] - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - movs r7, 0 - ldr r1, =gRfuSlotStatusNI - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] - adds r5, r4, 0 - adds r5, 0x34 - ldrh r0, [r4, 0x34] - mov r9, r0 - ldrb r0, [r6, 0x4] - adds r3, r4, 0 - adds r3, 0x55 - adds r0, r3, r0 - ldrb r0, [r0] - mov r10, r0 - ldrb r0, [r6, 0x2] - cmp r0, 0x3 - bne _082E6A64 - ldr r0, =gRfuStatic - ldr r2, [r0] - movs r0, 0x1 - mov r1, r8 - lsls r0, r1 - ldrb r1, [r2, 0x1] - orrs r0, r1 - strb r0, [r2, 0x1] - ldrh r1, [r4, 0x34] - ldr r0, =0x00008042 - cmp r1, r0 - bne _082E6AAA - adds r0, r4, 0 - adds r0, 0x54 - strb r7, [r0] - strb r7, [r3] - ldr r0, =0x00008043 - strh r0, [r4, 0x34] - b _082E6AAA - .align 2, 0 - .pool -_082E6A64: - cmp r0, 0x2 - bne _082E6A90 - ldr r0, =0x00008041 - cmp r9, r0 - bne _082E6A7C - ldr r0, [r5, 0x14] - cmp r0, 0 - bne _082E6A7C - mov r0, r8 - adds r1, r5, 0 - bl rfu_STC_NI_initSlot_asRecvDataEntity -_082E6A7C: - ldrh r1, [r5] - ldr r0, =0x00008042 - cmp r1, r0 - bne _082E6AAA - b _082E6AAE - .align 2, 0 - .pool -_082E6A90: - cmp r0, 0x1 - bne _082E6AAA - ldr r7, =0x00008041 - cmp r9, r7 - beq _082E6AAE - mov r0, r8 - adds r1, r5, 0 - bl rfu_STC_NI_initSlot_asRecvControllData - ldrh r0, [r4, 0x34] - cmp r0, r7 - bne _082E6B4A - movs r7, 0x1 -_082E6AAA: - cmp r7, 0 - beq _082E6B04 -_082E6AAE: - ldrb r2, [r6, 0x5] - ldrb r3, [r6, 0x4] - adds r4, r5, 0 - adds r4, 0x21 - adds r0, r4, r3 - ldrb r0, [r0] - adds r0, 0x1 - movs r1, 0x3 - ands r0, r1 - cmp r2, r0 - bne _082E6B04 - ldr r0, =gRfuFixed - ldr r0, [r0] - lsls r1, r3, 2 - adds r1, 0x4 - adds r1, r5, r1 - ldrh r2, [r6, 0x6] - ldr r3, [r0, 0x4] - mov r0, sp - bl _call_via_r3 - ldrh r1, [r5] - ldr r0, =0x00008042 - cmp r1, r0 - bne _082E6AF4 - ldrb r0, [r6, 0x4] - lsls r0, 2 - adds r2, r5, 0x4 - adds r2, r0 - ldrh r0, [r5, 0x2E] - lsls r1, r0, 1 - adds r1, r0 - ldr r0, [r2] - adds r0, r1 - str r0, [r2] -_082E6AF4: - ldrh r1, [r6, 0x6] - ldr r0, [r5, 0x14] - subs r0, r1 - str r0, [r5, 0x14] - ldrb r0, [r6, 0x4] - adds r0, r4, r0 - ldrb r1, [r6, 0x5] - strb r1, [r0] -_082E6B04: - ldrh r0, [r5, 0x18] - cmp r0, 0 - bne _082E6B4A - ldrb r0, [r6, 0x4] - adds r1, r5, 0 - adds r1, 0x20 - strb r0, [r1] - ldrh r0, [r5] - cmp r0, r9 - bne _082E6B2C - adds r0, r5, 0 - adds r0, 0x21 - ldrb r2, [r6, 0x4] - adds r0, r2 - ldrb r0, [r0] - cmp r0, r10 - bne _082E6B2C - ldrb r6, [r6, 0x5] - cmp r0, r6 - bne _082E6B4A -_082E6B2C: - ldr r3, =0x04000208 - ldrh r2, [r3] - movs r0, 0 - strh r0, [r3] - ldr r0, =gRfuStatic - ldr r4, [r0] - movs r0, 0x1 - mov r1, r8 - lsls r0, r1 - ldrb r1, [r4, 0x2] - orrs r0, r1 - movs r1, 0 - strb r0, [r4, 0x2] - strh r1, [r5, 0x2] - strh r2, [r3] -_082E6B4A: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_NI_receive_Receiver - - thumb_func_start rfu_STC_NI_initSlot_asRecvControllData -rfu_STC_NI_initSlot_asRecvControllData: @ 82E6B70 - push {r4-r7,lr} - adds r2, r1, 0 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gRfuLinkStatus - ldr r3, [r0] - ldrb r1, [r3] - mov r12, r0 - cmp r1, 0x1 - bne _082E6B90 - movs r5, 0x3 - adds r1, r3, 0 - adds r1, 0xF - b _082E6B98 - .align 2, 0 - .pool -_082E6B90: - movs r5, 0x2 - adds r0, r4, 0 - adds r0, 0x10 - adds r1, r3, r0 -_082E6B98: - movs r7, 0x1 - adds r0, r7, 0 - lsls r0, r4 - lsls r0, 24 - lsrs r6, r0, 24 - adds r4, r6, 0 - ldrh r3, [r2] - cmp r3, 0 - bne _082E6BF6 - ldrb r0, [r1] - cmp r0, r5 - bcs _082E6BD0 - movs r0, 0x49 - strh r0, [r2] - ldr r0, =0x00000702 - strh r0, [r2, 0x18] - ldr r0, =gRfuStatic - ldr r2, [r0] - ldrb r1, [r2, 0x4] - adds r0, r6, 0 - orrs r0, r1 - strb r0, [r2, 0x4] - b _082E6BF6 - .align 2, 0 - .pool -_082E6BD0: - strh r3, [r2, 0x18] - ldrb r0, [r1] - subs r0, r5 - strb r0, [r1] - adds r0, r2, 0 - adds r0, 0x2D - str r0, [r2, 0x4] - movs r0, 0x7 - str r0, [r2, 0x14] - strb r7, [r2, 0x1F] - strh r3, [r2, 0x2E] - strb r4, [r2, 0x1A] - ldr r0, =0x00008041 - strh r0, [r2] - mov r0, r12 - ldr r1, [r0] - ldrb r0, [r1, 0x5] - orrs r4, r0 - strb r4, [r1, 0x5] -_082E6BF6: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_NI_initSlot_asRecvControllData - - thumb_func_start rfu_STC_NI_initSlot_asRecvDataEntity -rfu_STC_NI_initSlot_asRecvDataEntity: @ 82E6C00 - push {r4-r7,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r4, 0 - adds r0, 0x2D - ldrb r0, [r0] - cmp r0, 0x1 - bne _082E6C24 - ldr r0, =gRfuLinkStatus - lsls r1, r5, 5 - adds r1, 0x14 - ldr r0, [r0] - adds r0, r1 - adds r0, 0x4 - b _082E6C7A - .align 2, 0 - .pool -_082E6C24: - ldr r1, =gRfuSlotStatusNI - lsls r0, r5, 2 - adds r0, r1 - ldr r2, [r0] - ldr r1, [r4, 0x30] - ldr r0, [r2, 0x6C] - cmp r1, r0 - bls _082E6C78 - movs r1, 0x80 - lsls r1, 17 - lsls r1, r5 - lsrs r1, 24 - ldr r0, =gRfuStatic - ldr r3, [r0] - ldrb r2, [r3, 0x4] - adds r0, r1, 0 - orrs r0, r2 - strb r0, [r3, 0x4] - ldr r0, =gRfuLinkStatus - ldr r2, [r0] - ldrb r0, [r2, 0x5] - bics r0, r1 - strb r0, [r2, 0x5] - ldr r0, =0x00000701 - strh r0, [r4, 0x18] - movs r0, 0x47 - strh r0, [r4] - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl rfu_STC_releaseFrame - b _082E6CAC - .align 2, 0 - .pool -_082E6C78: - ldr r0, [r2, 0x68] -_082E6C7A: - str r0, [r4, 0x4] - movs r3, 0 - adds r6, r4, 0 - adds r6, 0x21 - movs r7, 0 - adds r5, r4, 0x4 -_082E6C86: - adds r0, r6, r3 - strb r7, [r0] - lsls r1, r3, 2 - adds r1, r5, r1 - ldrh r0, [r4, 0x2E] - adds r2, r0, 0 - muls r2, r3 - ldr r0, [r4, 0x4] - adds r0, r2 - str r0, [r1] - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bls _082E6C86 - ldr r0, [r4, 0x30] - str r0, [r4, 0x14] - ldr r0, =0x00008042 - strh r0, [r4] -_082E6CAC: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_STC_NI_initSlot_asRecvDataEntity - - thumb_func_start rfu_NI_checkCommFailCounter -rfu_NI_checkCommFailCounter: @ 82E6CB8 - push {r4-r7,lr} - ldr r2, =gRfuLinkStatus - ldr r0, [r2] - ldrb r1, [r0, 0x4] - ldrb r0, [r0, 0x5] - orrs r0, r1 - cmp r0, 0 - beq _082E6D3E - ldr r1, =0x04000208 - ldrh r0, [r1] - mov r12, r0 - movs r0, 0 - strh r0, [r1] - 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, =gRfuSlotStatusNI -_082E6CE2: - movs r0, 0x80 - lsls r0, 17 - lsls r0, r3 - lsrs r2, r0, 24 - ldr r0, [r5] - ldrb r0, [r0, 0x4] - ands r0, r2 - cmp r0, 0 - beq _082E6D0A - ldr r0, [r6] - ldrb r0, [r0, 0x2] - ands r0, r2 - cmp r0, 0 - bne _082E6D0A - lsls r0, r3, 2 - adds r0, r4 - ldr r1, [r0] - ldrh r0, [r1, 0x2] - adds r0, 0x1 - strh r0, [r1, 0x2] -_082E6D0A: - ldr r0, [r5] - ldrb r0, [r0, 0x5] - ands r0, r2 - cmp r0, 0 - beq _082E6D28 - adds r0, r7, 0 - ands r0, r2 - cmp r0, 0 - bne _082E6D28 - lsls r0, r3, 2 - adds r0, r4 - ldr r1, [r0] - ldrh r0, [r1, 0x36] - adds r0, 0x1 - strh r0, [r1, 0x36] -_082E6D28: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x3 - bls _082E6CE2 - ldr r0, [r6] - movs r1, 0 - strb r1, [r0, 0x2] - ldr r0, =0x04000208 - mov r1, r12 - strh r1, [r0] -_082E6D3E: - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_NI_checkCommFailCounter - - thumb_func_start rfu_REQ_noise -rfu_REQ_noise: @ 82E6D54 - push {lr} - ldr r0, =rfu_STC_REQ_callback - bl STWI_set_Callback_M - movs r0, 0x1 - movs r1, 0 - bl STWI_send_TestModeREQ - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end rfu_REQ_noise - - thumb_func_start AgbRFU_checkID -AgbRFU_checkID: @ 82E6D6C - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =0x04000208 - ldrh r0, [r0] - cmp r0, 0 - bne _082E6D88 - movs r0, 0x1 - negs r0, r0 - b _082E6E08 - .align 2, 0 - .pool -_082E6D88: - ldr r0, =0x04000200 - ldrh r0, [r0] - mov r8, r0 - ldr r4, =gSTWIStatus - ldr r1, [r4] - movs r0, 0xA - str r0, [r1] - ldr r0, =Sio32IDIntr - bl STWI_set_Callback_ID - bl Sio32IDInit - ldr r0, [r4] - ldrb r0, [r0, 0xA] - lsls r0, 2 - ldr r1, =0x04000100 - adds r4, r0, r1 - lsls r0, r5, 27 - lsrs r5, r0, 24 - movs r7, 0 - b _082E6DD6 - .align 2, 0 - .pool -_082E6DC4: - strh r6, [r4, 0x2] - strh r6, [r4] - movs r0, 0x83 - strh r0, [r4, 0x2] -_082E6DCC: - ldrh r0, [r4] - cmp r0, 0x1F - bls _082E6DCC - strh r7, [r4, 0x2] - strh r7, [r4] -_082E6DD6: - subs r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0xFF - beq _082E6DEA - bl Sio32IDMain - adds r6, r0, 0 - cmp r6, 0 - beq _082E6DC4 -_082E6DEA: - ldr r1, =0x04000208 - movs r0, 0 - strh r0, [r1] - ldr r0, =0x04000200 - mov r2, r8 - strh r2, [r0] - movs r0, 0x1 - strh r0, [r1] - ldr r0, =gSTWIStatus - ldr r1, [r0] - movs r0, 0 - str r0, [r1] - bl STWI_set_Callback_ID - adds r0, r6, 0 -_082E6E08: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - .align 2, 0 - .pool - thumb_func_end AgbRFU_checkID - - 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, =gSTWIStatus - ldr r0, [r0] - movs r1, 0x8 - ldrb r0, [r0, 0xA] - lsls r1, r0 - movs r5, 0x80 - orrs r1, r5 - ldrh r0, [r2] - bics r0, r1 - strh r0, [r2] - movs r0, 0x1 - strh r0, [r3] - ldr r0, =0x04000134 - strh r4, [r0] - subs r2, 0xD8 - movs r1, 0x80 - lsls r1, 5 - adds r0, r1, 0 - strh r0, [r2] - ldrh r0, [r2] - movs r3, 0x81 - lsls r3, 7 - adds r1, r3, 0 - orrs r0, r1 - strh r0, [r2] - movs r0, 0 - str r0, [sp] - ldr r1, =gRfuSIO32Id - ldr r2, =0x05000003 - mov r0, sp - bl CpuSet - ldr r0, =0x04000202 - strh r5, [r0] - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end Sio32IDInit - - thumb_func_start Sio32IDMain -Sio32IDMain: @ 82E6E94 - push {r4-r7,lr} - ldr r0, =gRfuSIO32Id - ldrb r1, [r0, 0x1] - mov r12, r1 - adds r7, r0, 0 - cmp r1, 0 - beq _082E6EAC - cmp r1, 0x1 - beq _082E6EE4 - b _082E6F7C - .align 2, 0 - .pool -_082E6EAC: - movs r6, 0x1 - strb r6, [r7] - ldr r3, =0x04000128 - ldrh r0, [r3] - movs r5, 0x1 - orrs r0, r5 - strh r0, [r3] - ldr r4, =0x04000208 - mov r0, r12 - strh r0, [r4] - ldr r2, =0x04000200 - ldrh r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strh r0, [r2] - strh r6, [r4] - strb r5, [r7, 0x1] - ldrb r0, [r3] - orrs r0, r1 - strb r0, [r3] - b _082E6F80 - .align 2, 0 - .pool -_082E6EE4: - ldrh r0, [r7, 0xA] - cmp r0, 0 - bne _082E6F78 - ldrb r0, [r7] - cmp r0, 0x1 - bne _082E6F14 - ldrh r0, [r7, 0x2] - cmp r0, 0 - bne _082E6F80 - ldr r3, =0x04000208 - strh r0, [r3] - ldr r2, =0x04000128 - ldrh r0, [r2] - movs r1, 0x80 - orrs r0, r1 - strh r0, [r2] - mov r1, r12 - strh r1, [r3] - b _082E6F80 - .align 2, 0 - .pool -_082E6F14: - ldrh r1, [r7, 0x4] - ldr r0, =0x00008001 - cmp r1, r0 - beq _082E6F80 - ldrh r6, [r7, 0x2] - cmp r6, 0 - bne _082E6F80 - ldr r4, =0x04000208 - strh r6, [r4] - ldr r3, =0x04000200 - ldrh r1, [r3] - ldr r0, =0x0000ff7f - ands r0, r1 - strh r0, [r3] - mov r7, r12 - strh r7, [r4] - ldr r2, =0x04000128 - strh r6, [r2] - movs r1, 0x80 - lsls r1, 5 - adds r0, r1, 0 - strh r0, [r2] - ldr r0, =0x04000202 - movs r5, 0x80 - strh r5, [r0] - ldrh r0, [r2] - movs r7, 0x81 - lsls r7, 7 - adds r1, r7, 0 - orrs r0, r1 - strh r0, [r2] - strh r6, [r4] - ldrh r0, [r3] - orrs r0, r5 - strh r0, [r3] - mov r0, r12 - strh r0, [r4] - b _082E6F80 - .align 2, 0 - .pool -_082E6F78: - movs r0, 0x2 - strb r0, [r7, 0x1] -_082E6F7C: - ldrh r0, [r7, 0xA] - b _082E6F82 -_082E6F80: - movs r0, 0 -_082E6F82: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end Sio32IDMain - - thumb_func_start Sio32IDIntr -Sio32IDIntr: @ 82E6F88 - push {r4,r5,lr} - ldr r0, =0x04000120 - ldr r5, [r0] - ldr r0, =gRfuSIO32Id - ldrb r1, [r0] - adds r4, r0, 0 - cmp r1, 0x1 - beq sub_82E6FA2 - ldr r0, =0x04000128 - ldrh r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strh r1, [r0] - thumb_func_end Sio32IDIntr - - non_word_aligned_thumb_func_start sub_82E6FA2 -sub_82E6FA2: @ 82E6FA2 - ldrb r2, [r4] - lsls r1, r2, 4 - adds r0, r5, 0 - lsls r0, r1 - lsrs r1, r0, 16 - movs r0, 0x1 - subs r0, r2 - lsls r0, 4 - lsls r5, r0 - adds r0, r5, 0 - lsrs r5, r0, 16 - ldrh r0, [r4, 0xA] - cmp r0, 0 - bne _082E6FF6 - ldrh r2, [r4, 0x6] - cmp r1, r2 - bne _082E6FF4 - ldrh r3, [r4, 0x2] - cmp r3, 0x3 - bls _082E6FDC - strh r5, [r4, 0xA] - b _082E6FF6 - .align 2, 0 - .pool -_082E6FDC: - ldrh r0, [r4, 0x4] - mvns r0, r0 - lsls r0, 16 - lsrs r0, 16 - cmp r1, r0 - bne _082E6FF6 - mvns r0, r2 - lsls r0, 16 - lsrs r0, 16 - cmp r5, r0 - bne _082E6FF6 - adds r0, r3, 0x1 -_082E6FF4: - strh r0, [r4, 0x2] -_082E6FF6: - ldrh r0, [r4, 0x2] - cmp r0, 0x3 - bhi _082E700C - lsls r0, 1 - ldr r1, =Sio32ConnectionData - adds r0, r1 - ldrh r0, [r0] - b _082E700E - .align 2, 0 - .pool -_082E700C: - ldr r0, =0x00008001 -_082E700E: - strh r0, [r4, 0x4] - mvns r0, r5 - strh r0, [r4, 0x6] - ldr r3, =0x04000120 - ldrh r2, [r4, 0x4] - ldrb r1, [r4] - movs r0, 0x1 - subs r0, r1 - lsls r0, 4 - lsls r2, r0 - ldrh r0, [r4, 0x6] - lsls r1, 4 - lsls r0, r1 - adds r2, r0 - str r2, [r3] - ldrb r0, [r4] - cmp r0, 0x1 - bne _082E705C - ldrh r0, [r4, 0x2] - cmp r0, 0 - bne _082E703E - ldr r0, =0x0000494e - cmp r5, r0 - bne _082E705C -_082E703E: - movs r0, 0 - ldr r1, =0x00000257 -_082E7042: - adds r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, r1 - bls _082E7042 - ldrh r0, [r4, 0xA] - cmp r0, 0 - bne _082E705C - ldr r0, =0x04000128 - ldrh r1, [r0] - movs r2, 0x80 - orrs r1, r2 - strh r1, [r0] -_082E705C: - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 - .pool - thumb_func_end sub_82E6FA2 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index df79b084d3..071a89bc58 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -461,7 +461,7 @@ #define REG_DMA3CNT_L (*(vu16 *)REG_ADDR_DMA3CNT_L) #define REG_DMA3CNT_H (*(vu16 *)REG_ADDR_DMA3CNT_H) -#define REG_TMCNT(n) (*(vu16 *)(REG_ADDR_TMCNT + ((n) * 4))) +#define REG_TMCNT(n) (*(vu32 *)(REG_ADDR_TMCNT + ((n) * 4))) #define REG_TMCNT_L(n) (*(vu16 *)(REG_ADDR_TMCNT_L + ((n) * 4))) #define REG_TMCNT_H(n) (*(vu16 *)(REG_ADDR_TMCNT_H + ((n) * 4))) #define REG_TM0CNT (*(vu32 *)REG_ADDR_TM0CNT) diff --git a/include/gba/syscall.h b/include/gba/syscall.h index f3382b874c..56cd4ba587 100644 --- a/include/gba/syscall.h +++ b/include/gba/syscall.h @@ -45,4 +45,6 @@ void RLUnCompVram(const void *src, void *dest); int MultiBoot(struct MultiBootParam *mp); +s32 Div(s32 num, s32 denom); + #endif // GUARD_GBA_SYSCALL_H diff --git a/ld_script.txt b/ld_script.txt index 7e0eeac3de..6719b69075 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -358,7 +358,7 @@ SECTIONS { src/librfu_intr.o(.text); asm/librfu_intr.o(.text); src/librfu_rfu.o(.text); - asm/librfu.o(.text); + src/librfu_sio32id.o(.text); src/libisagbprn.o(.text); *libagbsyscall.a:ArcTan2.o(.text); *libagbsyscall.a:BgAffineSet.o(.text); diff --git a/src/agb_flash.c b/src/agb_flash.c index 34fb4e84a6..a9cf13d5f4 100644 --- a/src/agb_flash.c +++ b/src/agb_flash.c @@ -74,7 +74,7 @@ u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void)) return 1; sTimerNum = timerNum; - sTimerReg = ®_TMCNT(sTimerNum); + sTimerReg = ®_TMCNT_L(sTimerNum); *intrFunc = FlashTimerIntr; return 0; } diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index 7437bcecf6..f5f13cc5d4 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1,77 +1,2218 @@ -#include "global.h" -#include "main.h" - #include "librfu.h" -// Nonmatching, only register differences -/*u16 rfu_initializeAPI(u32 *unk0, u16 unk1, IntrFunc *interrupt, bool8 copyInterruptToRam) +struct LLSFStruct +{ + u8 unk00; + u8 unk01; + u8 unk02; + u8 unk03; + u8 unk04; + u8 unk05; + u8 unk06; + u8 unk07; + u8 unk08; + u8 unk09; + u8 unk0A; + u8 unk0B; + u8 unk0C; + u16 unk0E; +}; + +struct RfuLocalStruct +{ + u8 unk00; + u8 unk01; + u8 unk02; + u8 unk03; + u8 unk04; + u8 unk05; + u16 unk06; +}; + +static void rfu_CB_defaultCallback(u8, u16); +static void rfu_CB_reset(u8, u16); +static void rfu_CB_configGameData(u8, u16); +static void rfu_CB_stopMode(u8, u16); +static void rfu_CB_startSearchChild(u8, u16); +static void rfu_CB_pollAndEndSearchChild(u8, u16); +static void rfu_CB_startSearchParent(u8, u16); +static void rfu_CB_pollSearchParent(u8, u16); +static void rfu_CB_pollConnectParent(u8, u16); +static void rfu_CB_pollConnectParent(u8, u16); +static void rfu_CB_disconnect(u8, u16); +static void rfu_CB_CHILD_pollConnectRecovery(u8, u16); +static void rfu_CB_sendData(__attribute__((unused)) u8, u16); +static void rfu_CB_sendData2(__attribute__((unused)) u8, u16); +static void rfu_CB_sendData3(u8, u16); +static void rfu_CB_recvData(u8, u16); +static void rfu_enableREQCallback(bool8); +static void rfu_STC_clearAPIVariables(void); +static void rfu_STC_readChildList(void); +static void rfu_STC_readParentCandidateList(void); +static void rfu_STC_REQ_callback(u8, u16); +static void rfu_STC_removeLinkData(u8, u8); +static void rfu_STC_fastCopy(const u8 **, u8 **, s32); +static void rfu_STC_clearLinkStatus(u8); +static void rfu_NI_checkCommFailCounter(void); +static u16 rfu_STC_setSendData_org(u8, u8, u8, const void *, u32); +static void rfu_constructSendLLFrame(void); +static u16 rfu_STC_NI_constructLLSF(u8, u8 **, struct NIComm *); +static u16 rfu_STC_UNI_constructLLSF(u8, u8 **); +static void rfu_STC_PARENT_analyzeRecvPacket(void); +static void rfu_STC_CHILD_analyzeRecvPacket(void); +static u16 rfu_STC_analyzeLLSF(u8, const u8 *, u16); +static void rfu_STC_UNI_receive(u8, const struct RfuLocalStruct *, const u8 *); +static void rfu_STC_NI_receive_Receiver(u8, const struct RfuLocalStruct *, const u8 *); +static void rfu_STC_NI_receive_Sender(u8, u8, const struct RfuLocalStruct *, __attribute__((unused)) const u8 *); +static void rfu_STC_NI_initSlot_asRecvDataEntity(u8, struct NIComm *); +static void rfu_STC_NI_initSlot_asRecvControllData(u8, struct NIComm *); + +//struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX]; +//struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX]; +//struct RfuLinkStatus *gRfuLinkStatus; +//struct RfuStatic *gRfuStatic; +//struct RfuFixed *gRfuFixed; + +/*static const struct LLSFStruct llsf_struct[2] = { + { + 2, 14, 0, 10, 9, 5, 7, 2, + 0, 15, 1, 3, 3, 0x1f + }, { + 3, 22, 18, 14, 13, 9, 11, 3, + 15, 15, 1, 3, 3, 0x7f + } +}; + +#ifdef EMERALD +static const char lib_ver[] = "RFU_V1026"; +#else +static const char lib_ver[] = "RFU_V1024"; +#endif + +static const char str_checkMbootLL[] = "RFU-MBOOT"; +*/ +extern const struct LLSFStruct llsf_struct[2]; +extern const char str_checkMbootLL[];// = "RFU-MBOOT"; + +u16 rfu_initializeAPI(struct RfuAPIBuffer *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam) { u16 i; - u16 *v13; - u16 *v12; - u16 num; + u16 *dst; + const u16 *src; + u16 r3; - if (((u32)unk0 & 0xF000000) == 0x2000000 && copyInterruptToRam) - { - return 2; - } - - if ((u32)unk0 & 3) - return 2; - - // Nintendo pls, just use a ternary for once + // is in EWRAM? + if (((u32)APIBuffer & 0xF000000) == 0x2000000 && copyInterruptToRam) + return ERR_RFU_API_BUFF_ADR; + // is not 4-byte aligned? + if ((u32)APIBuffer & 3) + return ERR_RFU_API_BUFF_ADR; if (copyInterruptToRam) { // An assert/debug print may have existed before, ie - // printf("%s %u < %u", "somefile.c:12345", unk1, num) + // printf("%s %u < %u", "somefile.c:12345", buffByteSize, num) // to push this into r3? - num = 0xe64; - if (unk1 < num) - return 1; + r3 = sizeof(struct RfuAPIBuffer); + if (buffByteSize < r3) + return ERR_RFU_API_BUFF_SIZE; } - - if (copyInterruptToRam == FALSE) + if (!copyInterruptToRam) { - num = 0x504; // same as above, this should be r3 not r0 - if (unk1 < num) - return 1; + r3 = 0x504; // same issue as above + if (buffByteSize < r3) + return ERR_RFU_API_BUFF_SIZE; } - 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) + gRfuLinkStatus = &APIBuffer->linkStatus; + gRfuStatic = &APIBuffer->static_; + gRfuFixed = &APIBuffer->fixed; + gRfuSlotStatusNI[0] = &APIBuffer->NI[0]; + gRfuSlotStatusUNI[0] = &APIBuffer->UNI[0]; + for (i = 1; i < RFU_CHILD_MAX; ++i) { - gRfuSlotStatusNI[i] = (struct RfuSlotStatusNI*)&gRfuSlotStatusNI[i-1]->unk_70; - gRfuSlotStatusUNI[i] = (struct RfuSlotStatusUNI*)&gRfuSlotStatusUNI[i-1]->unk_1c; + gRfuSlotStatusNI[i] = &gRfuSlotStatusNI[i - 1][1]; + gRfuSlotStatusUNI[i] = &gRfuSlotStatusUNI[i - 1][1]; } - - gRfuFixed->unk_dc = (u32)&gRfuSlotStatusUNI[3]->unk_1c; - STWI_init_all(&gRfuSlotStatusUNI[3]->unk_1c, interrupt, copyInterruptToRam); + // TODO: Is it possible to fix the following 2 statements? + // It's equivalent to: + // gRfuFixed->STWIBuffer = &APIBuffer->intr; + // STWI_init_all(&APIBuffer->intr, sioIntrTable_p, copyInterruptToRam); + gRfuFixed->STWIBuffer = (struct RfuIntrStruct *)&gRfuSlotStatusUNI[3][1]; + STWI_init_all((struct RfuIntrStruct *)&gRfuSlotStatusUNI[3][1], sioIntrTable_p, copyInterruptToRam); rfu_STC_clearAPIVariables(); - - for (i = 0; i < 4; i++) + for (i = 0; i < RFU_CHILD_MAX; ++i) { - gRfuSlotStatusNI[i]->unk_68 = 0; - gRfuSlotStatusNI[i]->unk_6c = 0; - gRfuSlotStatusUNI[i]->unk_14 = 0; - gRfuSlotStatusUNI[i]->unk_18 = 0; + gRfuSlotStatusNI[i]->recvBuffer = NULL; + gRfuSlotStatusNI[i]->recvBufferSize = 0; + gRfuSlotStatusUNI[i]->recvBuffer = NULL; + gRfuSlotStatusUNI[i]->recvBufferSize = 0; } - - // Not matching, register differences - v12 = (u16*)((u32)&sub_82E53F4 & ~1); - v13 = (u16*)gRfuFixed->unk_8; - - for (i = 47; i != 0xFFFF; i--) + // looks like a macro copying data + do { - *v13 = *v12; - ++v12; - ++v13; - } - - gRfuFixed->unk_4 = (u32)(&gRfuFixed->unk_8[1]); - + src = (const u16 *)((u32)&rfu_STC_fastCopy & 0xFFFFFFFE); + dst = gRfuFixed->fastCopyBuffer; + for (r3 = 0x2F; r3 != 0xFFFF; --r3) // copy rfu_STC_fastCopy function body to buffer + *dst++ = *src++; + gRfuFixed->fastCopyPtr = (void *)gRfuFixed->fastCopyBuffer + 1; + } while (0); return 0; -}*/ +} + +static void rfu_STC_clearAPIVariables(void) +{ + u16 IMEBackup = REG_IME; + u8 i, r4; + + REG_IME = 0; + r4 = gRfuStatic->flags; + CpuFill16(0, gRfuStatic, sizeof(struct RfuStatic)); + gRfuStatic->flags = r4 & 8; + CpuFill16(0, gRfuLinkStatus, sizeof(struct RfuLinkStatus)); + gRfuLinkStatus->watchInterval = 4; + gRfuStatic->nowWatchInterval = 0; + gRfuLinkStatus->parentChild = MODE_NEUTRAL; + rfu_clearAllSlot(); + gRfuStatic->SCStartFlag = 0; + for (i = 0; i < NELEMS(gRfuStatic->cidBak); ++i) + gRfuStatic->cidBak[i] = 0; + REG_IME = IMEBackup; +} + +void rfu_REQ_PARENT_resumeRetransmitAndChange(void) +{ + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_ResumeRetransmitAndChangeREQ(); +} + +u16 rfu_UNI_PARENT_getDRAC_ACK(u8 *ackFlag) +{ + struct RfuIntrStruct *buf; + + *ackFlag = 0; + if (gRfuLinkStatus->parentChild != MODE_PARENT) + return ERR_MODE_NOT_PARENT; + buf = rfu_getSTWIRecvBuffer(); + switch (buf->rxPacketAlloc.rfuPacket8.data[0]) + { + case 40: + case 54: + if (buf->rxPacketAlloc.rfuPacket8.data[1] == 0) + *ackFlag = gRfuLinkStatus->connSlotFlag; + else + *ackFlag = buf->rxPacketAlloc.rfuPacket8.data[4]; + return 0; + default: + return ERR_REQ_CMD_ID; + } +} + +void rfu_setTimerInterrupt(u8 timerNo, IntrFunc *timerIntrTable_p) +{ + STWI_init_timer(timerIntrTable_p, timerNo); +} + +struct RfuIntrStruct *rfu_getSTWIRecvBuffer(void) +{ + return gRfuFixed->STWIBuffer; +} + +void rfu_setMSCCallback(void (*callback)(u16 reqCommandId)) +{ + STWI_set_Callback_S(callback); +} + +void rfu_setREQCallback(void (*callback)(u16 reqCommandId, u16 reqResult)) +{ + gRfuFixed->reqCallback = callback; + rfu_enableREQCallback(callback != NULL); +} + +static void rfu_enableREQCallback(bool8 enable) +{ + if (enable) + gRfuStatic->flags |= 8; + else + gRfuStatic->flags &= 0xF7; +} + +static void rfu_STC_REQ_callback(u8 r5, u16 reqResult) +{ + STWI_set_Callback_M(rfu_CB_defaultCallback); + gRfuStatic->reqResult = reqResult; + if (gRfuStatic->flags & 8) + gRfuFixed->reqCallback(r5, reqResult); +} + +static void rfu_CB_defaultCallback(u8 r0, u16 reqResult) +{ + s32 r5; + u8 i; + + if (r0 == 0xFF) + { + if (gRfuStatic->flags & 8) + gRfuFixed->reqCallback(r0, reqResult); + r5 = gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag; + for (i = 0; i < RFU_CHILD_MAX; ++i) + if ((r5 >> i) & 1) + rfu_STC_removeLinkData(i, 1); + gRfuLinkStatus->parentChild = MODE_NEUTRAL; + } +} + +u16 rfu_waitREQComplete(void) +{ + STWI_poll_CommandEnd(); + return gRfuStatic->reqResult; +} + +void rfu_REQ_RFUStatus(void) +{ + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_SystemStatusREQ(); +} + +u16 rfu_getRFUStatus(u8 *rfuState) +{ + if (gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[0] != 0x93) + return ERR_REQ_CMD_ID; + if (STWI_poll_CommandEnd() == 0) + *rfuState = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[7]; + else + *rfuState = 0xFF; + return 0; +} + +u16 rfu_MBOOT_CHILD_inheritanceLinkStatus(void) +{ + const char *s1 = str_checkMbootLL; + char *s2 = (char *)0x30000F0; + u16 checksum; + u16 *r2; + u8 i; + + while (*s1 != '\0') + if (*s1++ != *s2++) + return 1; + r2 = (u16 *)0x3000000; + checksum = 0; + for (i = 0; i < 90; ++i) + checksum += *r2++; + if (checksum != *(u16 *)0x30000FA) + return 1; + CpuCopy16((u16 *)0x3000000, gRfuLinkStatus, sizeof(struct RfuLinkStatus)); + gRfuStatic->flags |= 0x80; + return 0; +} + +void rfu_REQ_stopMode(void) +{ + vu32 *timerReg; + + if (REG_IME == 0) + { + rfu_STC_REQ_callback(61, 6); + gSTWIStatus->error = ERR_REQ_CMD_IME_DISABLE; + } + else + { + AgbRFU_SoftReset(); + rfu_STC_clearAPIVariables(); + if (AgbRFU_checkID(8) == 0x8001) + { + timerReg = ®_TMCNT(gSTWIStatus->timerSelect); + *timerReg = 0; + *timerReg = (TIMER_ENABLE | TIMER_1024CLK) << 16; + while (*timerReg << 16 < 262 << 16) + ; + *timerReg = 0; + STWI_set_Callback_M(rfu_CB_stopMode); + STWI_send_StopModeREQ(); + } + else + { + REG_SIOCNT = SIO_MULTI_MODE; + rfu_STC_REQ_callback(61, 0); + } + } +} + +static void rfu_CB_stopMode(u8 a1, u16 reqResult) +{ + if (reqResult == 0) + REG_SIOCNT = SIO_MULTI_MODE; + rfu_STC_REQ_callback(a1, reqResult); +} + +u32 rfu_REQBN_softReset_and_checkID(void) +{ + u32 r2; + + if (REG_IME == 0) + return ERR_ID_CHECK_IME_DISABLE; + AgbRFU_SoftReset(); + rfu_STC_clearAPIVariables(); + if ((r2 = AgbRFU_checkID(30)) == 0) + REG_SIOCNT = SIO_MULTI_MODE; + return r2; +} + +void rfu_REQ_reset(void) +{ + STWI_set_Callback_M(rfu_CB_reset); + STWI_send_ResetREQ(); +} + +static void rfu_CB_reset(u8 a1, u16 reqResult) +{ + if (reqResult == 0) + rfu_STC_clearAPIVariables(); + rfu_STC_REQ_callback(a1, reqResult); +} + +void rfu_REQ_configSystem(u16 availSlotFlag, u8 maxMFrame, u8 mcTimer) +{ + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_SystemConfigREQ((availSlotFlag & AVAIL_SLOT1) | 0x3C, maxMFrame, mcTimer); + if (mcTimer == 0) + { + gRfuStatic->unk_1a = 1; + } + else + { + u16 IMEBackup = REG_IME; + + REG_IME = 0; + gRfuStatic->unk_1a = Div(600, mcTimer); + REG_IME = IMEBackup; + } +} + +void rfu_REQ_configGameData(u8 mbootFlag, u16 serialNo, const u8 *gname, const u8 *uname) +{ + u8 sp[16]; + u8 i; + u8 r3; + const u8 *gnameBackup = gname; + const u8 *unameBackup; + + sp[0] = serialNo; + sp[1] = serialNo >> 8; + if (mbootFlag != 0) + sp[1] = (serialNo >> 8) | 0x80; + for (i = 2; i < 15; ++i) + sp[i] = *gname++; + r3 = 0; + unameBackup = uname; + for (i = 0; i < 8; ++i) + { + r3 += *unameBackup++; + r3 += *gnameBackup++; + } + sp[15] = ~r3; + if (mbootFlag != 0) + sp[14] = 0; + STWI_set_Callback_M(rfu_CB_configGameData); + STWI_send_GameConfigREQ(sp, uname); +} + +static void rfu_CB_configGameData(u8 ip, u16 r7) +{ + s32 r2, r3; + u8 *r4; + u8 i; + u8 *r1; + + if (r7 == 0) + { + r1 = gSTWIStatus->txPacket->rfuPacket8.data; + r2 = gRfuLinkStatus->my.serialNo = r1[4]; + gRfuLinkStatus->my.serialNo = (r1[5] << 8) | r2; + r4 = &r1[6]; + if (gRfuLinkStatus->my.serialNo & 0x8000) + { + gRfuLinkStatus->my.serialNo = gRfuLinkStatus->my.serialNo ^ 0x8000; + gRfuLinkStatus->my.mbootFlag = 1; + } + else + { + gRfuLinkStatus->my.mbootFlag = 0; + } + for (i = 0; i < RFU_GAME_NAME_LENGTH; ++i) + gRfuLinkStatus->my.gname[i] = *r4++; + ++r4; + for (i = 0; i < RFU_USER_NAME_LENGTH; ++i) + gRfuLinkStatus->my.uname[i] = *r4++; + } + rfu_STC_REQ_callback(ip, r7); +} + +void rfu_REQ_startSearchChild(void) +{ + u16 r1; + + for (r1 = 0; r1 < 4; ++r1) + gRfuStatic->lsFixedCount[r1] = 0; + STWI_set_Callback_M(rfu_CB_defaultCallback); + STWI_send_SystemStatusREQ(); + r1 = STWI_poll_CommandEnd(); + if (r1 == 0) + { + if (gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[7] == 0) + rfu_STC_clearLinkStatus(1); + } + else + { + rfu_STC_REQ_callback(25, r1); + } + STWI_set_Callback_M(rfu_CB_startSearchChild); + STWI_send_SC_StartREQ(); +} + +static void rfu_CB_startSearchChild(u8 r3, u16 reqResult) +{ + if (reqResult == 0) + gRfuStatic->SCStartFlag = 1; + rfu_STC_REQ_callback(r3, reqResult); +} + +static void rfu_STC_clearLinkStatus(u8 r4) +{ + u8 i; + + rfu_clearAllSlot(); + if (r4 != 0) + { + CpuFill16(0, gRfuLinkStatus->partner, sizeof(gRfuLinkStatus->partner)); + gRfuLinkStatus->findParentCount = 0; + } + for (i = 0; i < RFU_CHILD_MAX; ++i) + gRfuLinkStatus->strength[i] = 0; + gRfuLinkStatus->connCount = 0; + gRfuLinkStatus->connSlotFlag = 0; + gRfuLinkStatus->linkLossSlotFlag = 0; + gRfuLinkStatus->getNameFlag = 0; +} + +void rfu_REQ_pollSearchChild(void) +{ + STWI_set_Callback_M(rfu_CB_pollAndEndSearchChild); + STWI_send_SC_PollingREQ(); +} + +void rfu_REQ_endSearchChild(void) +{ + STWI_set_Callback_M(rfu_CB_pollAndEndSearchChild); + STWI_send_SC_EndREQ(); +} + +static void rfu_CB_pollAndEndSearchChild(u8 r4, u16 reqResult) +{ + if (reqResult == 0) + rfu_STC_readChildList(); + if (r4 == 26) + { + if (gRfuLinkStatus->my.id == 0) + { + STWI_set_Callback_M(rfu_CB_defaultCallback); + STWI_send_SystemStatusREQ(); + if (STWI_poll_CommandEnd() == 0) + gRfuLinkStatus->my.id = *(u16 *)&gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0]; + } + } + else if (r4 == 27) + { + if (gRfuLinkStatus->parentChild == MODE_NEUTRAL) + gRfuLinkStatus->my.id = 0; + gRfuStatic->SCStartFlag = 0; + } + rfu_STC_REQ_callback(r4, reqResult); +} + +static void rfu_STC_readChildList(void) +{ + u32 r5; + u8 r8 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[1]; + u8 *r4; + u8 i; + u8 r2; + + for (r4 = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4]; + r8 != 0; + r4 += 4) + { + r2 = r4[2]; + if (r2 < RFU_CHILD_MAX && !((gRfuLinkStatus->connSlotFlag >> r2) & 1) && !((gRfuLinkStatus->linkLossSlotFlag >> r2) & 1)) + { + gRfuStatic->lsFixedCount[r2] = 0xF0; + gRfuLinkStatus->strength[r2] = 0x10; + gRfuLinkStatus->connSlotFlag |= 1 << r2; + ++gRfuLinkStatus->connCount; + gRfuLinkStatus->partner[r2].id = *(u16 *)r4; + gRfuLinkStatus->partner[r2].slot = r2; + gRfuLinkStatus->parentChild = MODE_PARENT; + gRfuStatic->flags &= 0x7F; + gRfuStatic->cidBak[r2] = gRfuLinkStatus->partner[r2].id; + } + --r8; + } +} + +void rfu_REQ_startSearchParent(void) +{ + STWI_set_Callback_M(rfu_CB_startSearchParent); + STWI_send_SP_StartREQ(); +} + +static void rfu_CB_startSearchParent(u8 r5, u16 reqResult) +{ + if (reqResult == 0) + rfu_STC_clearLinkStatus(0); + rfu_STC_REQ_callback(r5, reqResult); +} + +void rfu_REQ_pollSearchParent(void) +{ + STWI_set_Callback_M(rfu_CB_pollSearchParent); + STWI_send_SP_PollingREQ(); +} + +static void rfu_CB_pollSearchParent(u8 r5, u16 reqResult) +{ + if (reqResult == 0) + rfu_STC_readParentCandidateList(); + rfu_STC_REQ_callback(r5, reqResult); +} + +void rfu_REQ_endSearchParent(void) +{ + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_SP_EndREQ(); +} + +static void rfu_STC_readParentCandidateList(void) +{ + u8 r7, r6, r5, r4, r3; + u8 *r1, *r2; + struct RfuTgtData *r4_; + + CpuFill16(0, gRfuLinkStatus->partner, sizeof(gRfuLinkStatus->partner)); + r2 = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[0]; + r7 = r2[1]; + r2 += 4; + gRfuLinkStatus->findParentCount = 0; + for (r6 = 0; r6 < 4 && r7 != 0; ++r6) + { + r7 -= 7; + r1 = r2 + 6; + r2 += 19; + r5 = ~*r2; + ++r2; + r4 = 0; + for (r3 = 0; r3 < 8; ++r3) + { + r4 += *r2++; + r4 += *r1++; + } + if (r4 == r5) + { + r2 -= 28; + r4_ = &gRfuLinkStatus->partner[gRfuLinkStatus->findParentCount]; + r4_->id = *(u16 *)r2; + r2 += 2; + r4_->slot = *r2; + r2 += 2; + r4_->serialNo = *(u16 *)r2 & 0x7FFF; + if (*(u16 *)r2 & 0x8000) + r4_->mbootFlag = 1; + else + r4_->mbootFlag = 0; + r2 += 2; + for (r3 = 0; r3 < RFU_GAME_NAME_LENGTH; ++r3) + r4_->gname[r3] = *r2++; + ++r2; + for (r3 = 0; r3 < RFU_USER_NAME_LENGTH; ++r3) + r4_->uname[r3] = *r2++; + ++gRfuLinkStatus->findParentCount; + } + } +} + +void rfu_REQ_startConnectParent(u16 pid) +{ + u16 r3 = 0; + u8 i; + for (i = 0; i < RFU_CHILD_MAX && gRfuLinkStatus->partner[i].id != pid; ++i) + ; + if (i == 4) + r3 = 256; + if (r3 == 0) + { + gRfuStatic->tryPid = pid; + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_CP_StartREQ(pid); + } + else + { + rfu_STC_REQ_callback(31, r3); + } +} + +void rfu_REQ_pollConnectParent(void) +{ + STWI_set_Callback_M(rfu_CB_pollConnectParent); + STWI_send_CP_PollingREQ(); +} + +static void rfu_CB_pollConnectParent(u8 sp24, u16 sp28) +{ + u16 id; + u8 slot; + u8 r2, r5; + struct RfuTgtData *r9; + struct RfuTgtData sp; + + if (sp28 == 0) + { + id = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0]; + slot = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[6]; + if (gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[7] == 0) + { + r2 = 1 << slot; + if (!(r2 & gRfuLinkStatus->connSlotFlag)) + { + gRfuLinkStatus->connSlotFlag |= r2; + gRfuLinkStatus->linkLossSlotFlag &= ~r2; + gRfuLinkStatus->my.id = id; + ++gRfuLinkStatus->connCount; + gRfuLinkStatus->parentChild = MODE_CHILD; + gRfuStatic->flags |= 0x80; + for (r5 = 0; r5 < RFU_CHILD_MAX; ++r5) + { + if (gRfuLinkStatus->partner[r5].id == gRfuStatic->tryPid) + { + if (gRfuLinkStatus->findParentCount != 0) + { + r9 = &sp; + CpuCopy16(&gRfuLinkStatus->partner[r5], &sp, sizeof(struct RfuTgtData)); + CpuFill16(0, gRfuLinkStatus->partner, sizeof(gRfuLinkStatus->partner)); + gRfuLinkStatus->findParentCount = 0; + } + else + { + r9 = &gRfuLinkStatus->partner[r5]; + } + break; + } + } + if (r5 < RFU_CHILD_MAX) + { + CpuCopy16(r9, &gRfuLinkStatus->partner[slot], sizeof(struct RfuTgtData)); + gRfuLinkStatus->partner[slot].slot = slot; + } + } + } + } + rfu_STC_REQ_callback(sp24, sp28); +} + +u16 rfu_getConnectParentStatus(u8 *status, u8 *connectSlotNo) +{ + u8 r0, *r2; + + *status = 0xFF; + r2 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data; + r0 = r2[0] + 96; + if (r0 <= 1) + { + r2 += 6; + *connectSlotNo = r2[0]; + *status = r2[1]; + return 0; + } + return ERR_REQ_CMD_ID; +} + +void rfu_REQ_endConnectParent(void) +{ + STWI_set_Callback_M(rfu_CB_pollConnectParent); + STWI_send_CP_EndREQ(); + if (gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[6] < 4) + gRfuStatic->linkEmergencyFlag[gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[6]] = 0; +} + +u16 rfu_syncVBlank(void) +{ + u8 r3, r4; + s32 r5; + + rfu_NI_checkCommFailCounter(); + if (gRfuLinkStatus->parentChild == MODE_NEUTRAL) + return 0; + if (gRfuStatic->nowWatchInterval != 0) + --gRfuStatic->nowWatchInterval; + r3 = rfu_getMasterSlave(); + if (!(gRfuStatic->flags & 2)) + { + if (r3 == 0) + { + gRfuStatic->flags |= 4; + gRfuStatic->watchdogTimer = 360; + } + } + else if (r3 != 0) + { + gRfuStatic->flags &= 0xFB; + } + if (r3 != 0) + gRfuStatic->flags &= 0xFD; + else + gRfuStatic->flags |= 2; + if (!(gRfuStatic->flags & 4)) + return 0; + if (gRfuStatic->watchdogTimer == 0) + { + gRfuStatic->flags &= 0xFB; + r5 = gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag; + for (r4 = 0; r4 < RFU_CHILD_MAX; ++r4) + if ((r5 >> r4) & 1) + rfu_STC_removeLinkData(r4, 1); + gRfuLinkStatus->parentChild = MODE_NEUTRAL; + return 1; + } + --gRfuStatic->watchdogTimer; + return 0; +} + +u16 rfu_REQBN_watchLink(u16 reqCommandId, u8 *bmLinkLossSlot, u8 *linkLossReason, u8 *parentBmLinkRecoverySlot) +{ + u8 sp08 = 0; + u8 sp0C = 0; + u8 i; + s32 sp10, sp14; + u8 *r2; + u8 r9, r6, r3, connSlotFlag, r0; + + *bmLinkLossSlot = 0; + *linkLossReason = REASON_DISCONNECTED; + *parentBmLinkRecoverySlot = 0; + if (gRfuLinkStatus->parentChild == MODE_NEUTRAL || gSTWIStatus->msMode == 0) + return 0; + if (gRfuStatic->flags & 4) + gRfuStatic->watchdogTimer = 360; + if (gRfuStatic->nowWatchInterval == 0) + { + gRfuStatic->nowWatchInterval = 4; + sp08 = 1; + } + if ((u8)reqCommandId == 41) + { + u8 *r1 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data; + + *bmLinkLossSlot = r1[4]; + *linkLossReason = r1[5]; + if (*linkLossReason == REASON_LINK_LOSS) + *bmLinkLossSlot = gRfuLinkStatus->connSlotFlag; + sp08 = 2; + } + else + { + if (reqCommandId == 310) + { + r6 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[5]; + r6 ^= gRfuLinkStatus->connSlotFlag; + *bmLinkLossSlot = r6 & gRfuLinkStatus->connSlotFlag; + *linkLossReason = REASON_LINK_LOSS; + for (i = 0; i < RFU_CHILD_MAX; ++i) + { + if ((*bmLinkLossSlot >> i) & 1) + { + gRfuLinkStatus->strength[i] = 0; + rfu_STC_removeLinkData(i, 0); + } + } + } + if (sp08 == 0) + return 0; + } + sp10 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.command; + sp14 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0]; + STWI_set_Callback_M(rfu_CB_defaultCallback); + STWI_send_LinkStatusREQ(); + sp0C = STWI_poll_CommandEnd(); + if (sp0C == 0) + { + r2 = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4]; + for (i = 0; i < RFU_CHILD_MAX; ++i) + gRfuLinkStatus->strength[i] = *r2++; + r9 = 0; + i = 0; + } + else + { + rfu_STC_REQ_callback(17, sp0C); + return sp0C; + } + for (; i < RFU_CHILD_MAX; ++i) + { + if (gRfuStatic->lsFixedCount[i] != 0) + { + gRfuStatic->lsFixedCount[i] -= 4; + if (gRfuLinkStatus->strength[i] <= 15) + gRfuLinkStatus->strength[i] = 16; + } + r6 = 1 << i; + if (sp0C == 0) + { + if (sp08 == 1 && (gRfuLinkStatus->connSlotFlag & r6)) + { + if (gRfuLinkStatus->strength[i] == 0) + { + if (gRfuLinkStatus->parentChild == MODE_PARENT) + { + ++gRfuStatic->linkEmergencyFlag[i]; + if (gRfuStatic->linkEmergencyFlag[i] > 3) + { + *bmLinkLossSlot |= r6; + *linkLossReason = sp08; // why not directly use REASON_LINK_LOSS? + } + } + else + { + STWI_send_SystemStatusREQ(); + if (STWI_poll_CommandEnd() == 0) + { + if (gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[7] == 0) + { + *bmLinkLossSlot |= r6; + *linkLossReason = sp08; // why not directly use REASON_LINK_LOSS? + } + else + { + if (++gRfuStatic->linkEmergencyFlag[i] > gRfuStatic->unk_1a) + { + gRfuStatic->linkEmergencyFlag[i] = 0; + STWI_send_DisconnectREQ(gRfuLinkStatus->connSlotFlag); + STWI_poll_CommandEnd(); + *bmLinkLossSlot |= r6; + *linkLossReason = sp08; // why not directly use REASON_LINK_LOSS? + } + } + } + } + } + else + { + gRfuStatic->linkEmergencyFlag[i] = sp0C; // why not directly use 0? + } + } + if (gRfuLinkStatus->parentChild == MODE_PARENT && gRfuLinkStatus->strength[i] != 0) + { + if (r6 & gRfuLinkStatus->linkLossSlotFlag) + { + if (gRfuLinkStatus->strength[i] > 10) + { + *parentBmLinkRecoverySlot |= r6; + gRfuLinkStatus->connSlotFlag |= r6; + gRfuLinkStatus->linkLossSlotFlag &= ~r6; + ++gRfuLinkStatus->connCount; + gRfuStatic->linkEmergencyFlag[i] = 0; + } + else + { + gRfuLinkStatus->strength[i] = 0; + } + } + else + { + if (!((gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag) & r6)) + { + STWI_send_SlotStatusREQ(); + STWI_poll_CommandEnd(); + r2 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data; + r3 = r2[1] - 1; + for (r2 += 8; r3 != 0; r2 += 4, --r3) + { + u16 r4 = *(u16 *)r2; + + if (r2[2] == i && r4 == gRfuStatic->cidBak[i]) + { + r9 |= 1 << i; + break; + } + } + } + } + } + } + connSlotFlag = gRfuLinkStatus->connSlotFlag; + r0 = *bmLinkLossSlot; + r0 &= connSlotFlag; + if (r6 & r0) + rfu_STC_removeLinkData(i, 0); + } + if (r9 != 0) + { + STWI_send_DisconnectREQ(r9); + STWI_poll_CommandEnd(); + } + // equivalent to: + // gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.command = sp10; + *(u32 *)gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data = sp10; + gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0] = sp14; + return 0; +} + +static void rfu_STC_removeLinkData(u8 r7, u8 r12) +{ + u8 r5 = 1 << r7; + s32 r6; + + gRfuStatic->lsFixedCount[r7] = 0; + if ((gRfuLinkStatus->connSlotFlag & r5) && gRfuLinkStatus->connCount != 0) + --gRfuLinkStatus->connCount; + gRfuLinkStatus->connSlotFlag &= r6 = ~r5; + gRfuLinkStatus->linkLossSlotFlag |= r5; + if ((*(u32 *)gRfuLinkStatus & 0xFF00FF) == 0) + gRfuLinkStatus->parentChild = MODE_NEUTRAL; + if (r12 != 0) + { + CpuFill16(0, &gRfuLinkStatus->partner[r7], sizeof(struct RfuTgtData)); + gRfuLinkStatus->linkLossSlotFlag &= r6; + gRfuLinkStatus->getNameFlag &= r6; + gRfuLinkStatus->strength[r7] = 0; + } +} + +void rfu_REQ_disconnect(u8 bmDisconnectSlot) +{ + u16 r1; + + if ((gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag) & bmDisconnectSlot) + { + gRfuStatic->recoveryBmSlot = bmDisconnectSlot; + if (gRfuLinkStatus->parentChild == MODE_NEUTRAL && gRfuStatic->flags & 0x80) + { + if (gRfuLinkStatus->linkLossSlotFlag & bmDisconnectSlot) + rfu_CB_disconnect(48, 0); + } + else if (gRfuStatic->SCStartFlag + && (STWI_set_Callback_M(rfu_CB_defaultCallback), + STWI_send_SC_EndREQ(), + (r1 = STWI_poll_CommandEnd()) != 0)) + { + rfu_STC_REQ_callback(27, r1); + } + else + { + STWI_set_Callback_M(rfu_CB_disconnect); + STWI_send_DisconnectREQ(bmDisconnectSlot); + } + } +} + +static void rfu_CB_disconnect(u8 r6, u16 r5) +{ + u8 r4, r0; + + if (r5 == 3 && gRfuLinkStatus->parentChild == MODE_CHILD) + { + STWI_set_Callback_M(rfu_CB_defaultCallback); + STWI_send_SystemStatusREQ(); + if (STWI_poll_CommandEnd() == 0 && gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[7] == 0) + r5 = 0; + } + gRfuStatic->recoveryBmSlot &= gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag; + gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[8] = gRfuStatic->recoveryBmSlot; + if (r5 == 0) + { + for (r4 = 0; r4 < RFU_CHILD_MAX; ++r4) + { + r0 = 1 << r4; + if (r0 & gRfuStatic->recoveryBmSlot) + rfu_STC_removeLinkData(r4, 1); + } + } + if ((gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag) == 0) + gRfuLinkStatus->parentChild = MODE_NEUTRAL; + rfu_STC_REQ_callback(r6, r5); + if (gRfuStatic->SCStartFlag) + { + STWI_set_Callback_M(rfu_CB_defaultCallback); + STWI_send_SC_StartREQ(); + r5 = STWI_poll_CommandEnd(); + if (r5 != 0) + rfu_STC_REQ_callback(25, r5); + } +} + +void rfu_REQ_CHILD_startConnectRecovery(u8 bmRecoverySlot) +{ + u8 i; + + gRfuStatic->recoveryBmSlot = bmRecoverySlot; + for (i = 0; i < RFU_CHILD_MAX && !((bmRecoverySlot >> i) & 1); ++i) + ; + STWI_set_Callback_M(rfu_STC_REQ_callback); + // if i == 4, gRfuLinkStatus->partner[i].id becomes gRfuLinkStatus->my.id + STWI_send_CPR_StartREQ(gRfuLinkStatus->partner[i].id, gRfuLinkStatus->my.id, bmRecoverySlot); +} + +void rfu_REQ_CHILD_pollConnectRecovery(void) +{ + STWI_set_Callback_M(rfu_CB_CHILD_pollConnectRecovery); + STWI_send_CPR_PollingREQ(); +} + +static void rfu_CB_CHILD_pollConnectRecovery(u8 r8, u16 r7) +{ + u8 r3, r4; + struct RfuLinkStatus *r2; + + if (r7 == 0 && gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4] == 0 && gRfuStatic->recoveryBmSlot) + { + gRfuLinkStatus->parentChild = MODE_CHILD; + for (r4 = 0; r4 < NELEMS(gRfuStatic->linkEmergencyFlag); ++r4) + { + r3 = 1 << r4; + r2 = gRfuLinkStatus; // ??? + if (gRfuStatic->recoveryBmSlot & r3 & r2->linkLossSlotFlag) + { + gRfuLinkStatus->connSlotFlag |= r3; + gRfuLinkStatus->linkLossSlotFlag &= ~r3; + ++gRfuLinkStatus->connCount; + gRfuStatic->linkEmergencyFlag[r4] = 0; + } + } + gRfuStatic->recoveryBmSlot = 0; + } + rfu_STC_REQ_callback(r8, r7); +} + +u16 rfu_CHILD_getConnectRecoveryStatus(u8 *status) +{ + u8 r0; + + *status = 0xFF; + r0 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[0] + 77; + if (r0 <= 1) + { + *status = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4]; + return 0; + } + return ERR_REQ_CMD_ID; +} + +void rfu_REQ_CHILD_endConnectRecovery(void) +{ + STWI_set_Callback_M(rfu_CB_CHILD_pollConnectRecovery); + STWI_send_CPR_EndREQ(); +} + +static void rfu_STC_fastCopy(const u8 **src_p, u8 **dst_p, s32 size) +{ + const u8 *src = *src_p; + u8 *dst = *dst_p; + s32 i; + + for (i = size - 1; i != -1; --i) + *dst++ = *src++; + *src_p = src; + *dst_p = dst; +} + +void rfu_REQ_changeMasterSlave(void) +{ + if (STWI_read_status(1) == 1) + { + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_MS_ChangeREQ(); + } + else + { + rfu_STC_REQ_callback(39, 0); + } +} + +bool8 rfu_getMasterSlave(void) +{ + bool8 masterSlave = STWI_read_status(1); + + if (masterSlave == AGB_CLK_MASTER) + { + if (gSTWIStatus->unk_2c) + { + if (gSTWIStatus->reqActiveCommand == 39 + || gSTWIStatus->reqActiveCommand == 37 + || gSTWIStatus->reqActiveCommand == 55) + masterSlave = AGB_CLK_SLAVE; + } + } + return masterSlave; +} + +void rfu_clearAllSlot(void) +{ + u16 i; + u16 IMEBackup = REG_IME; + + REG_IME = 0; + for (i = 0; i < RFU_CHILD_MAX; ++i) + { + CpuFill16(0, gRfuSlotStatusNI[i], 2 * sizeof(struct NIComm)); + CpuFill16(0, gRfuSlotStatusUNI[i], sizeof(struct UNISend) + sizeof(struct UNIRecv)); + gRfuLinkStatus->remainLLFrameSizeChild[i] = 16; + } + gRfuLinkStatus->remainLLFrameSizeParent = LLF_P_SIZE; + gRfuLinkStatus->sendSlotNIFlag = 0; + gRfuLinkStatus->recvSlotNIFlag = 0; + gRfuLinkStatus->sendSlotUNIFlag = 0; + gRfuStatic->recvRenewalFlag = 0; + REG_IME = IMEBackup; +} + +static void rfu_STC_releaseFrame(u8 r5, u8 r3, struct NIComm *r4) +{ + + if (!(gRfuStatic->flags & 0x80)) + { + if (r3 == 0) + gRfuLinkStatus->remainLLFrameSizeParent += r4->payloadSize; + gRfuLinkStatus->remainLLFrameSizeParent += 3; + } + else + { + if (r3 == 0) + gRfuLinkStatus->remainLLFrameSizeChild[r5] += r4->payloadSize; + gRfuLinkStatus->remainLLFrameSizeChild[r5] += 2; + } +} + +u16 rfu_clearSlot(u8 connTypeFlag, u8 slotStatusIndex) +{ + u16 r10, r3, r1; + struct NIComm *r4; + + if (slotStatusIndex >= RFU_CHILD_MAX) + return ERR_SLOT_NO; + if (!(connTypeFlag & (TYPE_UNI_SEND | TYPE_UNI_RECV | TYPE_NI_SEND | TYPE_NI_RECV))) + return ERR_COMM_TYPE; + r10 = REG_IME; + REG_IME = 0; + if (connTypeFlag & (TYPE_NI_SEND | TYPE_NI_RECV)) + { + for (r3 = 0; r3 < 2; ++r3) + { + r4 = NULL; + if (r3 == 0) + { + if (connTypeFlag & TYPE_NI_SEND) + { + r4 = &gRfuSlotStatusNI[slotStatusIndex]->send; + gRfuLinkStatus->sendSlotNIFlag &= ~r4->bmSlotOrg; + } + } + else + { + if (connTypeFlag & TYPE_NI_RECV) + { + r4 = &gRfuSlotStatusNI[slotStatusIndex]->recv; + gRfuLinkStatus->recvSlotNIFlag &= ~(1 << slotStatusIndex); + } + } + if (r4 != NULL) + { + if (r4->state & SLOT_BUSY_FLAG) + { + rfu_STC_releaseFrame(slotStatusIndex, r3, r4); + for (r1 = 0; r1 < RFU_CHILD_MAX; ++r1) + if ((r4->bmSlotOrg >> r1) & 1) + r4->failCounter = 0; + } + CpuFill16(0, r4, sizeof(struct NIComm)); + } + } + } + if (connTypeFlag & TYPE_UNI_SEND) + { + struct RfuSlotStatusUNI *r3 = gRfuSlotStatusUNI[slotStatusIndex]; + + if (r3->send.state & SLOT_BUSY_FLAG) + { + if (!(gRfuStatic->flags & 0x80)) + gRfuLinkStatus->remainLLFrameSizeParent += 3 + (u8)r3->send.payloadSize; + else + gRfuLinkStatus->remainLLFrameSizeChild[slotStatusIndex] += 2 + (u8)r3->send.payloadSize; + gRfuLinkStatus->sendSlotUNIFlag &= ~r3->send.bmSlot; + } + CpuFill16(0, &r3->send, sizeof(struct UNISend)); + } + if (connTypeFlag & TYPE_UNI_RECV) + { + CpuFill16(0, &gRfuSlotStatusUNI[slotStatusIndex]->recv, sizeof(struct UNIRecv)); + } + REG_IME = r10; + return 0; +} + +u16 rfu_setRecvBuffer(u8 connType, u8 slotNo, void *buffer, u32 buffSize) +{ + if (slotNo >= RFU_CHILD_MAX) + return ERR_SLOT_NO; + if (connType & TYPE_NI) + { + gRfuSlotStatusNI[slotNo]->recvBuffer = buffer; + gRfuSlotStatusNI[slotNo]->recvBufferSize = buffSize; + } + else if (!(connType & TYPE_UNI)) + { + return ERR_COMM_TYPE; + } + else + { + gRfuSlotStatusUNI[slotNo]->recvBuffer = buffer; + gRfuSlotStatusUNI[slotNo]->recvBufferSize = buffSize; + } + return 0; +} + +u16 rfu_NI_setSendData(u8 bmSendSlot, u8 subFrameSize, const void *src, u32 size) +{ + return rfu_STC_setSendData_org(32, bmSendSlot, subFrameSize, src, size); +} + +u16 rfu_UNI_setSendData(u8 bmSendSlot, const void *src, u8 size) +{ + u8 subFrameSize; + + if (gRfuLinkStatus->parentChild == MODE_PARENT) + subFrameSize = size + 3; + else + subFrameSize = size + 2; + return rfu_STC_setSendData_org(16, bmSendSlot, subFrameSize, src, 0); +} + +u16 rfu_NI_CHILD_setSendGameName(u8 slotNo, u8 subFrameSize) +{ + return rfu_STC_setSendData_org(64, 1 << slotNo, subFrameSize, &gRfuLinkStatus->my.serialNo, 26); +} + +static u16 rfu_STC_setSendData_org(u8 r6, u8 bmSendSlot, u8 subFrameSize, const void *src, u32 sp28) +{ + u8 r2, r0; + u8 r4; + u8 *r9; + u8 r5; + u8 i; + u16 sp04; + struct RfuSlotStatusUNI *r1; + struct RfuSlotStatusNI *r12; + + if (gRfuLinkStatus->parentChild == MODE_NEUTRAL) + return ERR_MODE_NOT_CONNECTED; + if (!(bmSendSlot & 0xF)) + return ERR_SLOT_NO; + if (((gRfuLinkStatus->connSlotFlag | gRfuLinkStatus->linkLossSlotFlag) & bmSendSlot) != bmSendSlot) + return ERR_SLOT_NOT_CONNECTED; + if (r6 & 0x10) + r0 = gRfuLinkStatus->sendSlotUNIFlag; + else + r0 = gRfuLinkStatus->sendSlotNIFlag; + if (r0 & bmSendSlot) + return ERR_SLOT_BUSY; + for (r2 = 0; r2 < RFU_CHILD_MAX && !((bmSendSlot >> r2) & 1); ++r2) + ; + if (gRfuLinkStatus->parentChild == MODE_PARENT) + r9 = &gRfuLinkStatus->remainLLFrameSizeParent; + else if (gRfuLinkStatus->parentChild == MODE_CHILD) + r9 = &gRfuLinkStatus->remainLLFrameSizeChild[r2]; + r4 = llsf_struct[gRfuLinkStatus->parentChild].unk00; + if (subFrameSize > *r9 || subFrameSize <= r4) + return ERR_SUBFRAME_SIZE; + sp04 = REG_IME; + REG_IME = 0; + r5 = r6 & 0x20; + if (r5 || r6 == 0x40) + { + u8 *r1; // a hack to swap instructions + + r12 = gRfuSlotStatusNI[r2]; + r1 = NULL; + r12->send.errorCode = 0; + *r12->send.now_p = r1 = &r12->send.dataType; + r12->send.remainSize = 7; + r12->send.bmSlotOrg = bmSendSlot; + r12->send.bmSlot = bmSendSlot; + r12->send.payloadSize = subFrameSize - r4; + if (r5 != 0) + *r1 = 0; + else + *r1 = 1; + r12->send.dataSize = sp28; + r12->send.src = src; + r12->send.ack = 0; + r12->send.phase = 0; + #ifndef NONMATCHING // to fix r2, r3, r4, r5 register roulette + asm("":::"r2"); + #endif + for (i = 0; i < WINDOW_COUNT; ++i) + { + r12->send.recvAckFlag[i] = 0; + r12->send.n[i] = 1; + } + for (r2 = 0; r2 < RFU_CHILD_MAX; ++r2) + if ((bmSendSlot >> r2) & 1) + gRfuSlotStatusNI[r2]->send.failCounter = 0; + gRfuLinkStatus->sendSlotNIFlag |= bmSendSlot; + *r9 -= subFrameSize; + r12->send.state = SLOT_STATE_SEND_START; + } + else if (r6 & 0x10) + { + r1 = gRfuSlotStatusUNI[r2]; + r1->send.bmSlot = bmSendSlot; + r1->send.src = src; + r1->send.payloadSize = subFrameSize - r4; + *r9 -= subFrameSize; + r1->send.state = SLOT_STATE_SEND_UNI; + gRfuLinkStatus->sendSlotUNIFlag |= bmSendSlot; + } + REG_IME = sp04; + return 0; +} + +u16 rfu_changeSendTarget(u8 connType, u8 slotStatusIndex, u8 bmNewTgtSlot) +{ + struct RfuSlotStatusNI *r5; + u16 r8; + u8 r2; + + if (slotStatusIndex >= RFU_CHILD_MAX) + return ERR_SLOT_NO; + if (connType == 0x20) + { + r5 = gRfuSlotStatusNI[slotStatusIndex]; + if ((r5->send.state & SLOT_BUSY_FLAG) + && (r5->send.state & SLOT_SEND_FLAG)) + { + connType = bmNewTgtSlot ^ r5->send.bmSlot; + + if (!(connType & bmNewTgtSlot)) + { + if (connType) + { + r8 = REG_IME; + REG_IME = 0; + for (r2 = 0; r2 < RFU_CHILD_MAX; ++r2) + { + if ((connType >> r2) & 1) + gRfuSlotStatusNI[r2]->send.failCounter = 0; + } + gRfuLinkStatus->sendSlotNIFlag &= ~connType; + r5->send.bmSlot = bmNewTgtSlot; + if (r5->send.bmSlot == 0) + { + rfu_STC_releaseFrame(slotStatusIndex, 0, &r5->send); + r5->send.state = SLOT_STATE_SEND_FAILED; + } + REG_IME = r8; + } + } + else + { + return ERR_SLOT_TARGET; + } + } + else + { + return ERR_SLOT_NOT_SENDING; + } + } + else + { + if (connType == 16) + { + s32 r3; + + if (gRfuSlotStatusUNI[slotStatusIndex]->send.state != SLOT_STATE_SEND_UNI) + return ERR_SLOT_NOT_SENDING; + for (r3 = 0, r2 = 0; r2 < RFU_CHILD_MAX; ++r2) + if (r2 != slotStatusIndex) + r3 |= gRfuSlotStatusUNI[r2]->send.bmSlot; + if (bmNewTgtSlot & r3) + return ERR_SLOT_TARGET; + r8 = REG_IME; + REG_IME = 0; + gRfuLinkStatus->sendSlotUNIFlag &= ~gRfuSlotStatusUNI[slotStatusIndex]->send.bmSlot; + gRfuLinkStatus->sendSlotUNIFlag |= bmNewTgtSlot; + gRfuSlotStatusUNI[slotStatusIndex]->send.bmSlot = bmNewTgtSlot; + REG_IME = r8; + } + else + { + return ERR_COMM_TYPE; + } + } + return 0; +} + +u16 rfu_NI_stopReceivingData(u8 slotStatusIndex) +{ + struct NIComm *r5; + u16 r4, r1; + + if (slotStatusIndex >= RFU_CHILD_MAX) + return ERR_SLOT_NO; + r5 = &gRfuSlotStatusNI[slotStatusIndex]->recv; + r4 = REG_IME; + ++r4; --r4; // fix r4, r5 register swap + REG_IME = 0; + if (gRfuSlotStatusNI[slotStatusIndex]->recv.state & SLOT_BUSY_FLAG) + { + if (gRfuSlotStatusNI[slotStatusIndex]->recv.state == SLOT_STATE_RECV_LAST) + gRfuSlotStatusNI[slotStatusIndex]->recv.state = SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN; + else + gRfuSlotStatusNI[slotStatusIndex]->recv.state = SLOT_STATE_RECV_FAILED; + gRfuLinkStatus->recvSlotNIFlag &= ~(1 << slotStatusIndex); + rfu_STC_releaseFrame(slotStatusIndex, 1, r5); + } + REG_IME = r4; + return 0; +} + +u16 rfu_UNI_changeAndReadySendData(u8 slotStatusIndex, const void *src, u8 size) +{ + struct UNISend *r4; + u8 *r6; + u16 r1; + u8 r3_; + + if (slotStatusIndex >= RFU_CHILD_MAX) + return ERR_SLOT_NO; + r4 = &gRfuSlotStatusUNI[slotStatusIndex]->send; + if (r4->state != SLOT_STATE_SEND_UNI) + return ERR_SLOT_NOT_SENDING; + if (gRfuLinkStatus->parentChild == MODE_PARENT) + { + r6 = &gRfuLinkStatus->remainLLFrameSizeParent; + r3_ = gRfuLinkStatus->remainLLFrameSizeParent + (u8)r4->payloadSize; + } + else + { + r6 = &gRfuLinkStatus->remainLLFrameSizeChild[slotStatusIndex]; + r3_ = gRfuLinkStatus->remainLLFrameSizeChild[slotStatusIndex] + (u8)r4->payloadSize; + } + if (r3_ < size) + return ERR_SUBFRAME_SIZE; + r1 = REG_IME; + REG_IME = 0; + r4->src = src; + *r6 = r3_ - size; + r4->payloadSize = size; + r4->dataReadyFlag = 1; + REG_IME = r1; + return 0; +} + +void rfu_UNI_readySendData(u8 slotStatusIndex) +{ + if (slotStatusIndex < RFU_CHILD_MAX) + { + if (gRfuSlotStatusUNI[slotStatusIndex]->send.state == SLOT_STATE_SEND_UNI) + gRfuSlotStatusUNI[slotStatusIndex]->send.dataReadyFlag = 1; + } +} + +void rfu_UNI_clearRecvNewDataFlag(u8 slotStatusIndex) +{ + if (slotStatusIndex < RFU_CHILD_MAX) + gRfuSlotStatusUNI[slotStatusIndex]->recv.newDataFlag = 0; +} + +void rfu_REQ_sendData(bool8 clockChangeFlag) +{ + if (gRfuLinkStatus->parentChild != MODE_NEUTRAL) + { + if (gRfuLinkStatus->parentChild == MODE_PARENT + && !(gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag | gRfuLinkStatus->sendSlotUNIFlag)) + { + if (gRfuStatic->commExistFlag) + { + gRfuStatic->emberCount = 16; + gRfuStatic->nullFrameCount = 0; + } + if (gRfuStatic->emberCount) + --gRfuStatic->emberCount; + else + ++gRfuStatic->nullFrameCount; + if (gRfuStatic->emberCount + || !(gRfuStatic->nullFrameCount & 0xF)) + { + gRfuFixed->LLFBuffer[0] = 1; + gRfuFixed->LLFBuffer[4] = 0xFF; + STWI_set_Callback_M(rfu_CB_sendData3); + if (!clockChangeFlag) + STWI_send_DataTxREQ(gRfuFixed->LLFBuffer, 1); + else + STWI_send_DataTxAndChangeREQ(gRfuFixed->LLFBuffer, 1); + return; + } + } + else + { + if (!gRfuLinkStatus->LLFReadyFlag) + rfu_constructSendLLFrame(); + if (gRfuLinkStatus->LLFReadyFlag) + { + STWI_set_Callback_M(rfu_CB_sendData); + if (clockChangeFlag) + { + STWI_send_DataTxAndChangeREQ(gRfuFixed->LLFBuffer, gRfuStatic->totalPacketSize + 4); + return; + } + STWI_send_DataTxREQ(gRfuFixed->LLFBuffer, gRfuStatic->totalPacketSize + 4); + } + } + if (clockChangeFlag) + { + if (gRfuLinkStatus->parentChild == MODE_PARENT) + { + if (gSTWIStatus->callbackS != NULL) + gSTWIStatus->callbackS(39); + } + else + { + STWI_set_Callback_M(rfu_CB_sendData2); + STWI_send_MS_ChangeREQ(); + } + } + } +} + +static void rfu_CB_sendData(__attribute__((unused)) u8 r0, u16 r7) +{ + u8 r6; + struct NIComm *r4; + + if (r7 == 0) + { + for (r6 = 0; r6 < RFU_CHILD_MAX; ++r6) + { + if (gRfuSlotStatusUNI[r6]->send.dataReadyFlag) + gRfuSlotStatusUNI[r6]->send.dataReadyFlag = 0; + r4 = &gRfuSlotStatusNI[r6]->send; + if (r4->state == SLOT_STATE_SEND_NULL) + { + rfu_STC_releaseFrame(r6, 0, r4); + gRfuLinkStatus->sendSlotNIFlag &= ~r4->bmSlot; + if (r4->dataType == 1) + gRfuLinkStatus->getNameFlag |= 1 << r6; + r4->state = SLOT_STATE_SEND_SUCCESS; + } + } + } + gRfuLinkStatus->LLFReadyFlag = 0; + rfu_STC_REQ_callback(36, r7); +} + +static void rfu_CB_sendData2(__attribute__((unused)) u8 r0, u16 r1) +{ + rfu_STC_REQ_callback(36, r1); +} + +static void rfu_CB_sendData3(u8 r0, u16 r1) +{ + if (r1 != 0) + rfu_STC_REQ_callback(36, r1); + else if (r0 == 0xFF) + rfu_STC_REQ_callback(0xFF, 0); +} + +static void rfu_constructSendLLFrame(void) +{ + u32 r8, r5; + u8 r6; + u8 *sp00; + struct RfuSlotStatusNI *r2; + + if (gRfuLinkStatus->parentChild != MODE_NEUTRAL + && gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag | gRfuLinkStatus->sendSlotUNIFlag) + { + gRfuLinkStatus->LLFReadyFlag = 0; + r8 = 0; + sp00 = (u8 *)&gRfuFixed->LLFBuffer[1]; + for (r6 = 0; r6 < RFU_CHILD_MAX; ++r6) + { + r5 = 0; + if (gRfuSlotStatusNI[r6]->send.state & SLOT_BUSY_FLAG) + r5 = rfu_STC_NI_constructLLSF(r6, &sp00, &gRfuSlotStatusNI[r6]->send); + if (gRfuSlotStatusNI[r6]->recv.state & SLOT_BUSY_FLAG) + r5 += rfu_STC_NI_constructLLSF(r6, &sp00, &gRfuSlotStatusNI[r6]->recv); + if (gRfuSlotStatusUNI[r6]->send.state == SLOT_STATE_SEND_UNI) + r5 += rfu_STC_UNI_constructLLSF(r6, &sp00); + if (r5 != 0) + { + if (gRfuLinkStatus->parentChild == MODE_PARENT) + r8 += r5; + else + r8 |= r5 << (5 * r6 + 8); + } + } + if (r8 != 0) + { + while ((u32)sp00 & 3) + *sp00++ = 0; + gRfuFixed->LLFBuffer[0] = r8; + if (gRfuLinkStatus->parentChild == MODE_CHILD) + { + u8 *r0 = sp00 - offsetof(struct RfuFixed, LLFBuffer[1]); + + // Does the volatile qualifier make sense? + // It's the same as: + // asm("":::"memory"); + r8 = r0 - *(u8 *volatile *)&gRfuFixed; + } + } + gRfuStatic->totalPacketSize = r8; + } +} + +static u16 rfu_STC_NI_constructLLSF(u8 r10, u8 **r12, struct NIComm *r4) +{ + u16 r5; + u32 sp00; + u8 i; + u8 *r2; + const struct LLSFStruct *r8 = &llsf_struct[gRfuLinkStatus->parentChild]; + + if (r4->state == SLOT_STATE_SENDING) + { + while (r4->now_p[r4->phase] >= (const u8 *)r4->src + r4->dataSize) + { + ++r4->phase; + if (r4->phase == 4) + r4->phase = 0; + } + } + if (r4->state & SLOT_RECV_FLAG) + { + r5 = 0; + } + else if (r4->state == SLOT_STATE_SENDING) + { + if (r4->now_p[r4->phase] + r4->payloadSize > (const u8 *)r4->src + r4->dataSize) + r5 = (const u8 *)r4->src + r4->dataSize - r4->now_p[r4->phase]; + else + r5 = r4->payloadSize; + } + else + { + if ((u32)r4->remainSize >= r4->payloadSize) + r5 = r4->payloadSize; + else + r5 = r4->remainSize; + } + sp00 = (r4->state & 0xF) << r8->unk03 + | r4->ack << r8->unk04 + | r4->phase << r8->unk05 + | r4->n[r4->phase] << r8->unk06 + | r5; + if (gRfuLinkStatus->parentChild == MODE_PARENT) + sp00 |= r4->bmSlot << 18; + r2 = (u8 *)&sp00; + for (i = 0; i < r8->unk00; ++i) + *(*r12)++ = *r2++; + if (r5 != 0) + { + const u8 *sp04 = r4->now_p[r4->phase]; + + gRfuFixed->fastCopyPtr(&sp04, r12, r5); + } + if (r4->state == SLOT_STATE_SENDING) + { + ++r4->phase; + if (r4->phase == 4) + r4->phase = 0; + } + if (gRfuLinkStatus->parentChild == MODE_PARENT) + gRfuLinkStatus->LLFReadyFlag = 1; + else + gRfuLinkStatus->LLFReadyFlag |= 1 << r10; + return r5 + r8->unk00; +} + +static u16 rfu_STC_UNI_constructLLSF(u8 r8, u8 **r6) +{ + const struct LLSFStruct *r5; + const u8 *sp04; + u32 sp00; + u8 *r2; + u8 i; + struct UNISend *r4 = &gRfuSlotStatusUNI[r8]->send; + + if (!r4->dataReadyFlag || !r4->bmSlot) + return 0; + r5 = &llsf_struct[gRfuLinkStatus->parentChild]; + sp00 = (r4->state & 0xF) << r5->unk03 + | r4->payloadSize; + if (gRfuLinkStatus->parentChild == MODE_PARENT) + sp00 |= r4->bmSlot << 18; + r2 = (u8 *)&sp00; + for (i = 0; i < r5->unk00; ++i) + *(*r6)++ = *r2++; + sp04 = r4->src; + gRfuFixed->fastCopyPtr(&sp04, r6, r4->payloadSize); + if (gRfuLinkStatus->parentChild == MODE_PARENT) + gRfuLinkStatus->LLFReadyFlag = 16; + else + gRfuLinkStatus->LLFReadyFlag |= 16 << r8; + return r5->unk00 + r4->payloadSize; +} + +void rfu_REQ_recvData(void) +{ + if (gRfuLinkStatus->parentChild != MODE_NEUTRAL) + { + gRfuStatic->commExistFlag = gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag | gRfuLinkStatus->sendSlotUNIFlag; + gRfuStatic->recvErrorFlag = 0; + STWI_set_Callback_M(rfu_CB_recvData); + STWI_send_DataRxREQ(); + } +} + +static void rfu_CB_recvData(u8 r9, u16 r7) +{ + u8 r6; + struct RfuSlotStatusNI *r4; + struct NIComm *r5; + + if (r7 == 0 && gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[1]) + { + gRfuStatic->NIEndRecvFlag = 0; + if (gRfuLinkStatus->parentChild == MODE_PARENT) + rfu_STC_PARENT_analyzeRecvPacket(); + else + rfu_STC_CHILD_analyzeRecvPacket(); + for (r6 = 0; r6 < RFU_CHILD_MAX; ++r6) + { + r4 = gRfuSlotStatusNI[r6]; + if (r4->recv.state == SLOT_STATE_RECV_LAST && !((gRfuStatic->NIEndRecvFlag >> r6) & 1)) + { + r5 = &r4->recv; + if (r5->dataType == 1) + gRfuLinkStatus->getNameFlag |= 1 << r6; + rfu_STC_releaseFrame(r6, 1, r5); + gRfuLinkStatus->recvSlotNIFlag &= ~r5->bmSlot; + r4->recv.state = SLOT_STATE_RECV_SUCCESS; + } + } + if (gRfuStatic->recvErrorFlag) + r7 = gRfuStatic->recvErrorFlag | ERR_DATA_RECV; + } + rfu_STC_REQ_callback(r9, r7); +} + +static void rfu_STC_PARENT_analyzeRecvPacket(void) +{ + u32 r3; + u8 r5; + u8 sp[4]; + u8 *r6; + + r3 = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0] >> 8; + for (r5 = 0; r5 < NELEMS(sp); ++r5) + { + sp[r5] = r3 & 0x1F; + r3 >>= 5; + if (sp[r5] == 0) + gRfuStatic->NIEndRecvFlag |= 1 << r5; + } + r6 = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[8]; + for (r5 = 0; r5 < NELEMS(sp); ++r5) + { + if (sp[r5]) + { + u8 *r4 = &sp[r5]; + + do + { + u8 r0 = rfu_STC_analyzeLLSF(r5, r6, *r4); + + r6 += r0; + *r4 -= r0; + } while (!(*r4 & 0x80) && (*r4)); + } + } +} + +static void rfu_STC_CHILD_analyzeRecvPacket(void) +{ + u16 r4; + u8 *r5; + u16 r0; + + r4 = *(u16 *)&gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4] & 0x7F; + r5 = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[8]; + if (r4 == 0) + gRfuStatic->NIEndRecvFlag = 15; + do + { + if (r4 == 0) + break; + r0 = rfu_STC_analyzeLLSF(0, r5, r4); + r5 += r0; + r4 -= r0; + } while (!(r4 & 0x8000)); +} + +static u16 rfu_STC_analyzeLLSF(u8 r12, const u8 *r7, u16 r3) +{ + struct RfuLocalStruct sp00; + const struct LLSFStruct *r6; + u32 r5; + u8 r4; + u32 r0; + u16 r10; + + r6 = &llsf_struct[~gRfuLinkStatus->parentChild & (MODE_NEUTRAL & MODE_PARENT)]; + if (r3 < r6->unk00) + return r3; + r5 = 0; + for (r4 = 0; r4 < r6->unk00; ++r4) + r5 |= *r7++ << 8 * r4; + sp00.unk00 = (r5 >> r6->unk01) & r6->unk07; + sp00.unk01 = (r5 >> r6->unk02) & r6->unk08; + sp00.unk02 = (r5 >> r6->unk03) & r6->unk09; + sp00.unk03 = (r5 >> r6->unk04) & r6->unk0A; + sp00.unk04 = (r5 >> r6->unk05) & r6->unk0B; + sp00.unk05 = (r5 >> r6->unk06) & r6->unk0C; + sp00.unk06 = (r5 & r6->unk0E) & r5; + r10 = sp00.unk06 + r6->unk00; + if (sp00.unk00 == 0) + { + if (gRfuLinkStatus->parentChild == MODE_PARENT) + { + if ((gRfuLinkStatus->connSlotFlag >> r12) & 1) + { + if (sp00.unk02 == 4) + { + rfu_STC_UNI_receive(r12, &sp00, r7); + } + else if (sp00.unk03 == 0) + { + rfu_STC_NI_receive_Receiver(r12, &sp00, r7); + } + else + { + for (r4 = 0; r4 < RFU_CHILD_MAX; ++r4) + if (((gRfuSlotStatusNI[r4]->send.bmSlot >> r12) & 1) + && ((gRfuLinkStatus->sendSlotNIFlag >> r12) & 1)) + break; + if (r4 <= 3) + rfu_STC_NI_receive_Sender(r4, r12, &sp00, r7); + } + } + } + else + { + s32 r5 = gRfuLinkStatus->connSlotFlag & sp00.unk01; + + if (r5) + { + for (r4 = 0; r4 < RFU_CHILD_MAX; ++r4) + { + if ((r5 >> r4) & 1) + { + if (sp00.unk02 == 4) + rfu_STC_UNI_receive(r4, &sp00, r7); + else if (sp00.unk03 == 0) + rfu_STC_NI_receive_Receiver(r4, &sp00, r7); + else if ((gRfuLinkStatus->sendSlotNIFlag >> r4) & 1) + rfu_STC_NI_receive_Sender(r4, r4, &sp00, r7); + } + } + } + } + } + return r10; +} + +static void rfu_STC_UNI_receive(u8 r7, const struct RfuLocalStruct *r6, const u8 *sp00) +{ + u8 *sp04; + u32 r2; + struct RfuSlotStatusUNI *r3 = gRfuSlotStatusUNI[r7]; + struct UNIRecv *r5 = &r3->recv; + + r5->errorCode = 0; + if (gRfuSlotStatusUNI[r7]->recvBufferSize < r6->unk06) + { + r3->recv.state = SLOT_STATE_RECV_IGNORE; + r5->errorCode = ERR_RECV_BUFF_OVER; + } + else + { + if (r5->dataBlockFlag) + { + if (r5->newDataFlag) + { + r5->errorCode = ERR_RECV_UNK; + goto _081E2F0E; + } + } + else + { + if (r5->newDataFlag) + r5->errorCode = ERR_RECV_DATA_OVERWRITED; + } + r5->state = SLOT_STATE_RECEIVING; + r2 = r5->dataSize = r6->unk06; + sp04 = gRfuSlotStatusUNI[r7]->recvBuffer; + gRfuFixed->fastCopyPtr(&sp00, &sp04, r2); + r5->newDataFlag = 1; + r5->state = 0; + } +_081E2F0E: + if (r5->errorCode) + gRfuStatic->recvErrorFlag |= 16 << r7; +} + +static void rfu_STC_NI_receive_Sender(u8 r0, u8 r10, const struct RfuLocalStruct *r6, const u8 *r3) +{ + struct NIComm *r12 = &gRfuSlotStatusNI[r0]->send; + u16 r9 = r12->state; + u8 sp00 = r12->n[r6->unk04]; + u8 *r8; + u8 r4; + u16 r2; + + if ((r6->unk02 == 2 && r9 == SLOT_STATE_SENDING) + || (r6->unk02 == 1 && r9 == SLOT_STATE_SEND_START) + || (r6->unk02 == 3 && r9 == SLOT_STATE_SEND_LAST)) + { + if (r12->n[r6->unk04] == r6->unk05) + r12->recvAckFlag[r6->unk04] |= 1 << r10; + } + if ((r12->recvAckFlag[r6->unk04] & r12->bmSlot) == r12->bmSlot) + { + r12->n[r6->unk04] = (r12->n[r6->unk04] + 1) & 3; + r12->recvAckFlag[r6->unk04] = 0; + if ((u16)(r12->state + ~SLOT_STATE_SEND_NULL) <= 1) + { + if (r12->state == SLOT_STATE_SEND_START) + r12->now_p[r6->unk04] += r12->payloadSize; + else + r12->now_p[r6->unk04] += r12->payloadSize << 2; + r12->remainSize -= r12->payloadSize; + if (r12->remainSize != 0) + if (r12->remainSize >= 0) + goto _081E30AE; + // Above is a hack to avoid optimization over comparison. + // rfu_STC_NI_constructLLSF uses this field as u32. + // It's equivalent to the following condition: + // if (r12->remainSize == 0 || r12->remainSize < 0) + { + r12->phase = 0; + if (r12->state == SLOT_STATE_SEND_START) + { + for (r4 = 0; r4 < WINDOW_COUNT; ++r4) + { + r12->n[r4] = 1; + r12->now_p[r4] = r12->src + r12->payloadSize * r4; + } + r12->remainSize = r12->dataSize; + r12->state = SLOT_STATE_SENDING; + } + else + { + r12->n[0] = 0; + r12->remainSize = 0; + r12->state = SLOT_STATE_SEND_LAST; + } + } + _081E30AE: + } + else if (r12->state == SLOT_STATE_SEND_LAST) + { + r12->state = SLOT_STATE_SEND_NULL; + } + } + if (r12->state != r9 + || r12->n[r6->unk04] != sp00 + || (r12->recvAckFlag[r6->unk04] >> r10) & 1) + { + r2 = REG_IME; + REG_IME = 0; + gRfuStatic->recvRenewalFlag |= 16 << r10; + gRfuSlotStatusNI[r10]->send.failCounter = 0; + REG_IME = r2; + } +} + +static void rfu_STC_NI_receive_Receiver(u8 r8, const struct RfuLocalStruct *r6, const u8 *sp00) +{ + u16 r2; + u32 r7 = 0; + struct RfuSlotStatusNI *r4 = gRfuSlotStatusNI[r8]; + struct NIComm *r5 = &r4->recv; + u16 r9 = r4->recv.state; + u8 r10 = r4->recv.n[r6->unk04]; + + if (r6->unk02 == 3) + { + gRfuStatic->NIEndRecvFlag |= 1 << r8; + if (r4->recv.state == SLOT_STATE_RECEIVING) + { + r4->recv.phase = 0; + r4->recv.n[0] = 0; + r4->recv.state = SLOT_STATE_RECV_LAST; + } + } + else if (r6->unk02 == 2) + { + if (r9 == SLOT_STATE_RECV_START && !r5->remainSize) + rfu_STC_NI_initSlot_asRecvDataEntity(r8, r5); + if (r5->state == SLOT_STATE_RECEIVING) + r7 = 1; + } + else if (r6->unk02 == 1) + { + if (r9 == SLOT_STATE_RECV_START) + { + r7 = 1; + } + else + { + rfu_STC_NI_initSlot_asRecvControllData(r8, r5); + if (r4->recv.state != SLOT_STATE_RECV_START) + return; + r7 = 1; + } + } + if (r7 != 0) + { + if (r6->unk05 == ((r5->n[r6->unk04] + 1) & 3)) + { + gRfuFixed->fastCopyPtr(&sp00, (u8 **)&r5->now_p[r6->unk04], r6->unk06); + if (r5->state == SLOT_STATE_RECEIVING) + r5->now_p[r6->unk04] += 3 * r5->payloadSize; + r5->remainSize -= r6->unk06; + r5->n[r6->unk04] = r6->unk05; + } + } + if (r5->errorCode == 0) + { + r5->phase = r6->unk04; + if (r5->state != r9 || r5->n[r6->unk04] != r10 || r5->n[r6->unk04] == r6->unk05) + { + r2 = REG_IME; + REG_IME = 0; + gRfuStatic->recvRenewalFlag |= 1 << r8; + r5->failCounter = 0; + REG_IME = r2; + } + } +} + +static void rfu_STC_NI_initSlot_asRecvControllData(u8 r4, struct NIComm *r2) +{ + u8 *r1; + u32 r5; + u8 r6; + + if (gRfuLinkStatus->parentChild == MODE_PARENT) + { + r5 = 3; + r1 = &gRfuLinkStatus->remainLLFrameSizeParent; + } + else + { + r5 = 2; + r1 = &gRfuLinkStatus->remainLLFrameSizeChild[r4]; + } + r6 = 1 << r4; + if (r2->state == 0) + { + if (*r1 < r5) + { + r2->state = SLOT_STATE_RECV_IGNORE; + r2->errorCode = ERR_RECV_REPLY_SUBFRAME_SIZE; + gRfuStatic->recvErrorFlag |= r6; + } + else + { + r2->errorCode = 0; + *r1 -= r5; + r2->now_p[0] = &r2->dataType; + r2->remainSize = 7; + r2->ack = 1; + r2->payloadSize = 0; + r2->bmSlot = r6; + r2->state = SLOT_STATE_RECV_START; + gRfuLinkStatus->recvSlotNIFlag |= r6; + } + } +} + +static void rfu_STC_NI_initSlot_asRecvDataEntity(u8 r5, struct NIComm *r4) +{ + u8 r1, r3; + + if (r4->dataType == 1) + { + r4->now_p[0] = (void *)&gRfuLinkStatus->partner[r5].serialNo; + } + else + { + if (r4->dataSize > gRfuSlotStatusNI[r5]->recvBufferSize) + { + r1 = 1 << r5; + gRfuStatic->recvErrorFlag |= r1; + gRfuLinkStatus->recvSlotNIFlag &= ~r1; + r4->errorCode = ERR_RECV_BUFF_OVER; + r4->state = SLOT_STATE_RECV_FAILED; + rfu_STC_releaseFrame(r5, 1, r4); + return; + } + r4->now_p[0] = gRfuSlotStatusNI[r5]->recvBuffer; + } + for (r3 = 0; r3 < WINDOW_COUNT; ++r3) + { + r4->n[r3] = 0; + r4->now_p[r3] = &r4->now_p[0][r4->payloadSize * r3]; + } + r4->remainSize = r4->dataSize; + r4->state = SLOT_STATE_RECEIVING; +} + +static void rfu_NI_checkCommFailCounter(void) +{ + u16 r12; + u32 r7; + u8 r2, r3; + + if (gRfuLinkStatus->sendSlotNIFlag | gRfuLinkStatus->recvSlotNIFlag) + { + r12 = REG_IME; + REG_IME = 0; + r7 = gRfuStatic->recvRenewalFlag >> 4; + for (r3 = 0; r3 < RFU_CHILD_MAX; ++r3) + { + r2 = 1 << r3; + if (gRfuLinkStatus->sendSlotNIFlag & r2 + && !(gRfuStatic->recvRenewalFlag & r2)) + ++gRfuSlotStatusNI[r3]->send.failCounter; + if (gRfuLinkStatus->recvSlotNIFlag & r2 + && !(r7 & r2)) + ++gRfuSlotStatusNI[r3]->recv.failCounter; + } + gRfuStatic->recvRenewalFlag = 0; + REG_IME = r12; + } +} + +void rfu_REQ_noise(void) +{ + STWI_set_Callback_M(rfu_STC_REQ_callback); + STWI_send_TestModeREQ(1, 0); +} diff --git a/src/librfu_sio32id.c b/src/librfu_sio32id.c new file mode 100644 index 0000000000..f5d652348f --- /dev/null +++ b/src/librfu_sio32id.c @@ -0,0 +1,167 @@ +#include "librfu.h" + +static void Sio32IDIntr(void); +static void Sio32IDInit(void); +static s32 Sio32IDMain(void); + +//struct RfuSIO32Id gRfuSIO32Id; + +//static const u16 Sio32ConnectionData[] = { 0x494e, 0x544e, 0x4e45, 0x4f44 }; // NINTENDO +//static const char Sio32IDLib_Var[] = "Sio32ID_030820"; + +extern const u16 Sio32ConnectionData[]; +extern const char Sio32IDLib_Var[]; + +s32 AgbRFU_checkID(u8 r5) +{ + u16 r8; + vu16 *r4; + s32 r6; + + if (REG_IME == 0) + return -1; + r8 = REG_IE; + gSTWIStatus->state = 10; + STWI_set_Callback_ID(Sio32IDIntr); + Sio32IDInit(); + r4 = ®_TMCNT_L(gSTWIStatus->timerSelect); + r5 *= 8; + while (--r5 != 0xFF) + { + r6 = Sio32IDMain(); + if (r6 != 0) + break; + r4[1] = 0; + r4[0] = 0; + r4[1] = TIMER_1024CLK | TIMER_ENABLE; + while (r4[0] < 32) + ; + r4[1] = 0; + r4[0] = 0; + } + REG_IME = 0; + REG_IE = r8; + REG_IME = 1; + gSTWIStatus->state = 0; + STWI_set_Callback_ID(NULL); + return r6; +} + +static void Sio32IDInit(void) +{ + REG_IME = 0; + REG_IE &= ~((8 << gSTWIStatus->timerSelect) | INTR_FLAG_SERIAL); + REG_IME = 1; + REG_RCNT = 0; + REG_SIOCNT = SIO_32BIT_MODE; + REG_SIOCNT |= SIO_INTR_ENABLE | SIO_ENABLE; + CpuFill32(0, &gRfuSIO32Id, sizeof(struct RfuSIO32Id)); + REG_IF = INTR_FLAG_SERIAL; +} + +static s32 Sio32IDMain(void) +{ + u8 r12; + + switch (r12 = gRfuSIO32Id.unk1) + { + case 0: + gRfuSIO32Id.unk0 = 1; + REG_SIOCNT |= SIO_38400_BPS; + REG_IME = r12; + REG_IE |= INTR_FLAG_SERIAL; + REG_IME = 1; + gRfuSIO32Id.unk1 = 1; + *(vu8 *)®_SIOCNT |= SIO_ENABLE; + break; + case 1: + if (gRfuSIO32Id.unkA == 0) + { + if (gRfuSIO32Id.unk0 == 1) + { + if (gRfuSIO32Id.unk2 == 0) + { + REG_IME = gRfuSIO32Id.unk2; + REG_SIOCNT |= SIO_ENABLE; + REG_IME = r12; + } + } + else if (gRfuSIO32Id.unk4 != 0x8001 && !gRfuSIO32Id.unk2) + { + REG_IME = gRfuSIO32Id.unk2; + REG_IE &= ~INTR_FLAG_SERIAL; + REG_IME = r12; + REG_SIOCNT = gRfuSIO32Id.unk2; + REG_SIOCNT = SIO_32BIT_MODE; + REG_IF = INTR_FLAG_SERIAL; + REG_SIOCNT |= SIO_INTR_ENABLE | SIO_ENABLE; + REG_IME = gRfuSIO32Id.unk2; + REG_IE |= INTR_FLAG_SERIAL; + REG_IME = r12; + } + break; + } + else + { + gRfuSIO32Id.unk1 = 2; + // fallthrough + } + default: + return gRfuSIO32Id.unkA; + } + return 0; +} + +static void Sio32IDIntr(void) +{ + u32 r5; + u16 r0; +#ifndef NONMATCHING + register u32 r1 asm("r1"); + register u16 r0_ asm("r0"); +#else + u32 r1; + u16 r0_; +#endif + + r5 = REG_SIODATA32; + if (gRfuSIO32Id.unk0 != 1) + REG_SIOCNT |= SIO_ENABLE; + r1 = 16 * gRfuSIO32Id.unk0; // to handle side effect of inline asm + r1 = (r5 << r1) >> 16; + r5 = (r5 << 16 * (1 - gRfuSIO32Id.unk0)) >> 16; + if (gRfuSIO32Id.unkA == 0) + { + if (r1 == gRfuSIO32Id.unk6) + { + if (gRfuSIO32Id.unk2 > 3) + { + gRfuSIO32Id.unkA = r5; + } + else if (r1 == (u16)~gRfuSIO32Id.unk4) + { + r0_ = ~gRfuSIO32Id.unk6; + if (r5 == r0_) + ++gRfuSIO32Id.unk2; + } + } + else + { + gRfuSIO32Id.unk2 = gRfuSIO32Id.unkA; + } + } + if (gRfuSIO32Id.unk2 < 4) + gRfuSIO32Id.unk4 = *(gRfuSIO32Id.unk2 + Sio32ConnectionData); + else + gRfuSIO32Id.unk4 = 0x8001; + gRfuSIO32Id.unk6 = ~r5; + REG_SIODATA32 = (gRfuSIO32Id.unk4 << 16 * (1 - gRfuSIO32Id.unk0)) + + (gRfuSIO32Id.unk6 << 16 * gRfuSIO32Id.unk0); + if (gRfuSIO32Id.unk0 == 1 && (gRfuSIO32Id.unk2 || r5 == 0x494E)) + { + for (r0 = 0; r0 < 600; ++r0) + ; + if (gRfuSIO32Id.unkA == 0) + REG_SIOCNT |= SIO_ENABLE; + } +}