Decompiled librfu to STWI_send_CP_EndREQ

This commit is contained in:
shinyquagsire23 2017-09-07 03:59:39 -06:00
parent f1216076d7
commit b420fb3962
2 changed files with 228 additions and 416 deletions

View File

@ -4,420 +4,6 @@
.text
thumb_func_start STWI_poll_CommandEnd
STWI_poll_CommandEnd: @ 82E2C90
push {lr}
ldr r0, _082E2CB4
ldr r1, [r0]
adds r2, r1, 0
adds r2, 0x2C
ldrb r1, [r2]
adds r3, r0, 0
cmp r1, 0x1
bne _082E2CAA
adds r1, r2, 0
_082E2CA4:
ldrb r0, [r1]
cmp r0, 0x1
beq _082E2CA4
_082E2CAA:
ldr r0, [r3]
ldrh r0, [r0, 0x12]
pop {r1}
bx r1
.align 2, 0
_082E2CB4: .4byte gRfuState
thumb_func_end STWI_poll_CommandEnd
thumb_func_start STWI_send_ResetREQ
STWI_send_ResetREQ: @ 82E2CB8
push {lr}
movs r0, 0x10
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2CD2
ldr r0, _082E2CD8
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2CD2:
pop {r0}
bx r0
.align 2, 0
_082E2CD8: .4byte gRfuState
thumb_func_end STWI_send_ResetREQ
thumb_func_start STWI_send_LinkStatusREQ
STWI_send_LinkStatusREQ: @ 82E2CDC
push {lr}
movs r0, 0x11
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2CF6
ldr r0, _082E2CFC
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2CF6:
pop {r0}
bx r0
.align 2, 0
_082E2CFC: .4byte gRfuState
thumb_func_end STWI_send_LinkStatusREQ
thumb_func_start STWI_send_VersionStatusREQ
STWI_send_VersionStatusREQ: @ 82E2D00
push {lr}
movs r0, 0x12
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2D1A
ldr r0, _082E2D20
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2D1A:
pop {r0}
bx r0
.align 2, 0
_082E2D20: .4byte gRfuState
thumb_func_end STWI_send_VersionStatusREQ
thumb_func_start STWI_send_SystemStatusREQ
STWI_send_SystemStatusREQ: @ 82E2D24
push {lr}
movs r0, 0x13
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2D3E
ldr r0, _082E2D44
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2D3E:
pop {r0}
bx r0
.align 2, 0
_082E2D44: .4byte gRfuState
thumb_func_end STWI_send_SystemStatusREQ
thumb_func_start STWI_send_SlotStatusREQ
STWI_send_SlotStatusREQ: @ 82E2D48
push {lr}
movs r0, 0x14
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2D62
ldr r0, _082E2D68
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2D62:
pop {r0}
bx r0
.align 2, 0
_082E2D68: .4byte gRfuState
thumb_func_end STWI_send_SlotStatusREQ
thumb_func_start STWI_send_ConfigStatusREQ
STWI_send_ConfigStatusREQ: @ 82E2D6C
push {lr}
movs r0, 0x15
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2D86
ldr r0, _082E2D8C
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2D86:
pop {r0}
bx r0
.align 2, 0
_082E2D8C: .4byte gRfuState
thumb_func_end STWI_send_ConfigStatusREQ
thumb_func_start STWI_send_GameConfigREQ
STWI_send_GameConfigREQ: @ 82E2D90
push {r4,r5,lr}
adds r4, r0, 0
adds r5, r1, 0
movs r0, 0x16
bl STWI_init
lsls r0, 16
cmp r0, 0
bne _082E2DDC
ldr r2, _082E2DE4
ldr r1, [r2]
movs r0, 0x6
strb r0, [r1, 0x4]
ldr r0, [r2]
ldr r1, [r0, 0x24]
adds r1, 0x4
ldrh r0, [r4]
strh r0, [r1]
adds r1, 0x2
adds r4, 0x2
movs r2, 0xD
_082E2DBA:
ldrb r0, [r4]
strb r0, [r1]
adds r1, 0x1
adds r4, 0x1
subs r2, 0x1
cmp r2, 0
bge _082E2DBA
movs r2, 0x7
_082E2DCA:
ldrb r0, [r5]
strb r0, [r1]
adds r1, 0x1
adds r5, 0x1
subs r2, 0x1
cmp r2, 0
bge _082E2DCA
bl STWI_start_Command
_082E2DDC:
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_082E2DE4: .4byte gRfuState
thumb_func_end STWI_send_GameConfigREQ
thumb_func_start STWI_send_SystemConfigREQ
STWI_send_SystemConfigREQ: @ 82E2DE8
push {r4-r6,lr}
lsls r0, 16
lsrs r6, r0, 16
lsls r1, 24
lsrs r5, r1, 24
lsls r2, 24
lsrs r4, r2, 24
movs r0, 0x17
bl STWI_init
lsls r0, 16
cmp r0, 0
bne _082E2E1E
ldr r2, _082E2E24
ldr r1, [r2]
movs r0, 0x1
strb r0, [r1, 0x4]
ldr r0, [r2]
ldr r0, [r0, 0x24]
adds r0, 0x4
strb r4, [r0]
adds r0, 0x1
strb r5, [r0]
adds r0, 0x1
strh r6, [r0]
bl STWI_start_Command
_082E2E1E:
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_082E2E24: .4byte gRfuState
thumb_func_end STWI_send_SystemConfigREQ
thumb_func_start STWI_send_SC_StartREQ
STWI_send_SC_StartREQ: @ 82E2E28
push {lr}
movs r0, 0x19
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2E42
ldr r0, _082E2E48
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2E42:
pop {r0}
bx r0
.align 2, 0
_082E2E48: .4byte gRfuState
thumb_func_end STWI_send_SC_StartREQ
thumb_func_start STWI_send_SC_PollingREQ
STWI_send_SC_PollingREQ: @ 82E2E4C
push {lr}
movs r0, 0x1A
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2E66
ldr r0, _082E2E6C
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2E66:
pop {r0}
bx r0
.align 2, 0
_082E2E6C: .4byte gRfuState
thumb_func_end STWI_send_SC_PollingREQ
thumb_func_start STWI_send_SC_EndREQ
STWI_send_SC_EndREQ: @ 82E2E70
push {lr}
movs r0, 0x1B
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2E8A
ldr r0, _082E2E90
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2E8A:
pop {r0}
bx r0
.align 2, 0
_082E2E90: .4byte gRfuState
thumb_func_end STWI_send_SC_EndREQ
thumb_func_start STWI_send_SP_StartREQ
STWI_send_SP_StartREQ: @ 82E2E94
push {lr}
movs r0, 0x1C
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2EAE
ldr r0, _082E2EB4
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2EAE:
pop {r0}
bx r0
.align 2, 0
_082E2EB4: .4byte gRfuState
thumb_func_end STWI_send_SP_StartREQ
thumb_func_start STWI_send_SP_PollingREQ
STWI_send_SP_PollingREQ: @ 82E2EB8
push {lr}
movs r0, 0x1D
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2ED2
ldr r0, _082E2ED8
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2ED2:
pop {r0}
bx r0
.align 2, 0
_082E2ED8: .4byte gRfuState
thumb_func_end STWI_send_SP_PollingREQ
thumb_func_start STWI_send_SP_EndREQ
STWI_send_SP_EndREQ: @ 82E2EDC
push {lr}
movs r0, 0x1E
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2EF6
ldr r0, _082E2EFC
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2EF6:
pop {r0}
bx r0
.align 2, 0
_082E2EFC: .4byte gRfuState
thumb_func_end STWI_send_SP_EndREQ
thumb_func_start STWI_send_CP_StartREQ
STWI_send_CP_StartREQ: @ 82E2F00
push {r4,lr}
lsls r0, 16
lsrs r4, r0, 16
movs r0, 0x1F
bl STWI_init
lsls r0, 16
cmp r0, 0
bne _082E2F24
ldr r2, _082E2F2C
ldr r1, [r2]
movs r0, 0x1
strb r0, [r1, 0x4]
ldr r0, [r2]
ldr r0, [r0, 0x24]
str r4, [r0, 0x4]
bl STWI_start_Command
_082E2F24:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_082E2F2C: .4byte gRfuState
thumb_func_end STWI_send_CP_StartREQ
thumb_func_start STWI_send_CP_PollingREQ
STWI_send_CP_PollingREQ: @ 82E2F30
push {lr}
movs r0, 0x20
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2F4A
ldr r0, _082E2F50
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2F4A:
pop {r0}
bx r0
.align 2, 0
_082E2F50: .4byte gRfuState
thumb_func_end STWI_send_CP_PollingREQ
thumb_func_start STWI_send_CP_EndREQ
STWI_send_CP_EndREQ: @ 82E2F54
push {lr}
movs r0, 0x21
bl STWI_init
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
bne _082E2F6E
ldr r0, _082E2F74
ldr r0, [r0]
strb r1, [r0, 0x4]
bl STWI_start_Command
_082E2F6E:
pop {r0}
bx r0
.align 2, 0
_082E2F74: .4byte gRfuState
thumb_func_end STWI_send_CP_EndREQ
thumb_func_start STWI_send_DataTxREQ
STWI_send_DataTxREQ: @ 82E2F78
push {r4-r6,lr}

View File

@ -2,6 +2,28 @@
#include "main.h"
enum
{
RFU_RESET = 0x10,
RFU_LINK_STATUS,
RFU_VERSION_STATUS,
RFU_SYSTEM_STATUS,
RFU_SLOT_STATUS,
RFU_CONFIG_STATUS,
RFU_GAME_CONFIG,
RFU_SYSTEM_CONFIG,
RFU_UNK18,
RFU_SC_START,
RFU_SC_POLLING,
RFU_SC_END,
RFU_SP_START,
RFU_SP_POLLING,
RFU_SP_END,
RFU_CP_START,
RFU_CP_POLLING,
RFU_CP_END
};
typedef struct RfuStruct
{
s32 unk_0;
@ -24,7 +46,7 @@ typedef struct RfuStruct
void * callbackM;
void * callbackS;
u32 callbackID;
void * unk_24;
u8 * unk_24;
void * unk_28;
vu8 unk_2c;
u8 padding[3];
@ -49,6 +71,8 @@ void STWI_init_Callback_M();
void STWI_init_Callback_S();
void STWI_set_Callback_M(void * callback);
void STWI_set_Callback_S(void * callback);
u16 STWI_init(u8 request);
int STWI_start_Command();
extern void STWI_intr_timer();
void STWI_init_all(RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam)
@ -76,7 +100,7 @@ void STWI_init_all(RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 co
rfuStructPtr = (struct RfuStruct**)&gRfuState.rfuStruct;
(*rfuStructPtr)->unk_28 = (void*)&interruptStruct->unk28Data;
(*rfuStructPtr)->unk_24 = (void*)(&interruptStruct->unk24Data);
(*rfuStructPtr)->unk_24 = (u8*)(&interruptStruct->unk24Data);
(*rfuStructPtr)->msMode = 1;
(*rfuStructPtr)->unk_0 = 0;
@ -215,3 +239,205 @@ void STWI_set_Callback_ID(u32 id)
gRfuState.rfuStruct->callbackID = id;
}
u16 STWI_poll_CommandEnd()
{
while ( gRfuState.rfuStruct->unk_2c == TRUE );
return gRfuState.rfuStruct->unk_12;
}
void STWI_send_ResetREQ()
{
if (!STWI_init(RFU_RESET))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_LinkStatusREQ()
{
if (!STWI_init(RFU_LINK_STATUS))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_VersionStatusREQ()
{
if (!STWI_init(RFU_VERSION_STATUS))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SystemStatusREQ()
{
if (!STWI_init(RFU_SYSTEM_STATUS))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SlotStatusREQ()
{
if (!STWI_init(RFU_SLOT_STATUS))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_ConfigStatusREQ()
{
if (!STWI_init(RFU_CONFIG_STATUS))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_GameConfigREQ(u8 * unk1, u8 *data)
{
u8 *v5;
int i;
if (!STWI_init(RFU_GAME_CONFIG))
{
gRfuState.rfuStruct->unk_4 = 6; //TODO: what is 6
//TODO: kinda gross but idk what's going on here
v5 = (u8*)gRfuState.rfuStruct->unk_24;
v5 += 4;
*(u16*)v5 = *(u16*)unk1;
v5 += 2;
unk1 += 2;
i = 13;
do
{
*v5 = *unk1;
v5++;
unk1++;
i--;
}
while(i >= 0);
i = 7;
do
{
*v5 = *data;
v5++;
data++;
i--;
}
while(i >= 0);
STWI_start_Command();
}
}
void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3)
{
u8 *v5;
if (!STWI_init(RFU_SYSTEM_CONFIG))
{
gRfuState.rfuStruct->unk_4 = 1; //TODO: what is 1
//TODO: kinda weird but idk what's going on here
v5 = (u8*)gRfuState.rfuStruct->unk_24;
v5 += 4;
*v5++ = unk3;
*v5++ = unk2;
*(u16*)v5 = unk1;
STWI_start_Command();
}
}
void STWI_send_SC_StartREQ()
{
if (!STWI_init(RFU_SC_START))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SC_PollingREQ()
{
if (!STWI_init(RFU_SC_POLLING))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SC_EndREQ()
{
if (!STWI_init(RFU_SC_END))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SP_StartREQ()
{
if (!STWI_init(RFU_SP_START))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SP_PollingREQ()
{
if (!STWI_init(RFU_SP_POLLING))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_SP_EndREQ()
{
if (!STWI_init(RFU_SP_END))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_CP_StartREQ(u16 unk1)
{
if (!STWI_init(RFU_CP_START))
{
gRfuState.rfuStruct->unk_4 = 1;
*(u32*)(gRfuState.rfuStruct->unk_24 + 4) = unk1;
STWI_start_Command();
}
}
void STWI_send_CP_PollingREQ()
{
if (!STWI_init(RFU_CP_POLLING))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}
void STWI_send_CP_EndREQ()
{
if (!STWI_init(RFU_CP_END))
{
gRfuState.rfuStruct->unk_4 = 0;
STWI_start_Command();
}
}