summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshinyquagsire23 <mtinc2@gmail.com>2017-09-10 22:22:10 -0600
committershinyquagsire23 <mtinc2@gmail.com>2017-09-10 22:22:10 -0600
commitce08f34ed54b9e5af9a8d1d6cd780df7207c1dbb (patch)
tree594968fbed4d6ee3555f23f52758077613a4dfef
parente26e1f1275a23e290322059bab1f80f89dac4f8a (diff)
Finish with STWI_send_*
-rw-r--r--asm/librfu.s93
-rw-r--r--src/librfu.c59
2 files changed, 55 insertions, 97 deletions
diff --git a/asm/librfu.s b/asm/librfu.s
index a01d4e505..290c1b6c0 100644
--- a/asm/librfu.s
+++ b/asm/librfu.s
@@ -4,99 +4,6 @@
.text
- thumb_func_start STWI_send_CPR_StartREQ
-STWI_send_CPR_StartREQ: @ 82E316C
- push {r4-r6,lr}
- lsls r0, 16
- lsrs r5, r0, 16
- lsls r1, 16
- lsrs r4, r1, 16
- lsls r2, 24
- lsrs r6, r2, 24
- movs r0, 0x32
- bl STWI_init
- lsls r0, 16
- cmp r0, 0
- bne _082E319E
- ldr r2, _082E31A4
- ldr r1, [r2]
- movs r0, 0x2
- strb r0, [r1, 0x4]
- lsls r0, r5, 16
- orrs r0, r4
- ldr r1, [r2]
- ldr r1, [r1, 0x24]
- str r0, [r1, 0x4]
- str r6, [r1, 0x8]
- bl STWI_start_Command
-_082E319E:
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2, 0
-_082E31A4: .4byte gRfuState
- thumb_func_end STWI_send_CPR_StartREQ
-
- thumb_func_start STWI_send_CPR_PollingREQ
-STWI_send_CPR_PollingREQ: @ 82E31A8
- push {lr}
- movs r0, 0x33
- bl STWI_init
- lsls r0, 16
- lsrs r1, r0, 16
- cmp r1, 0
- bne _082E31C2
- ldr r0, _082E31C8
- ldr r0, [r0]
- strb r1, [r0, 0x4]
- bl STWI_start_Command
-_082E31C2:
- pop {r0}
- bx r0
- .align 2, 0
-_082E31C8: .4byte gRfuState
- thumb_func_end STWI_send_CPR_PollingREQ
-
- thumb_func_start STWI_send_CPR_EndREQ
-STWI_send_CPR_EndREQ: @ 82E31CC
- push {lr}
- movs r0, 0x34
- bl STWI_init
- lsls r0, 16
- lsrs r1, r0, 16
- cmp r1, 0
- bne _082E31E6
- ldr r0, _082E31EC
- ldr r0, [r0]
- strb r1, [r0, 0x4]
- bl STWI_start_Command
-_082E31E6:
- pop {r0}
- bx r0
- .align 2, 0
-_082E31EC: .4byte gRfuState
- thumb_func_end STWI_send_CPR_EndREQ
-
- thumb_func_start STWI_send_StopModeREQ
-STWI_send_StopModeREQ: @ 82E31F0
- push {lr}
- movs r0, 0x3D
- bl STWI_init
- lsls r0, 16
- lsrs r1, r0, 16
- cmp r1, 0
- bne _082E320A
- ldr r0, _082E3210
- ldr r0, [r0]
- strb r1, [r0, 0x4]
- bl STWI_start_Command
-_082E320A:
- pop {r0}
- bx r0
- .align 2, 0
-_082E3210: .4byte gRfuState
- thumb_func_end STWI_send_StopModeREQ
-
thumb_func_start STWI_intr_timer
STWI_intr_timer: @ 82E3214
push {r4,lr}
diff --git a/src/librfu.c b/src/librfu.c
index 5cbe9eb49..dfb2f7221 100644
--- a/src/librfu.c
+++ b/src/librfu.c
@@ -37,12 +37,18 @@ enum
RFU_UNK2F,
RFU_DISCONNECT,
RFU_TEST_MODE,
- RFU_UNK32,
- RFU_UNK33,
- RFU_UNK34,
+ RFU_CPR_START,
+ RFU_CPR_POLLING,
+ RFU_CPR_END,
RFU_UNK35,
RFU_UNK36,
- RFU_RESUME_RETRANSMIT_AND_CHANGE
+ RFU_RESUME_RETRANSMIT_AND_CHANGE,
+ RFU_UNK38,
+ RFU_UNK39,
+ RFU_UNK3A,
+ RFU_UNK3B,
+ RFU_UNK3C,
+ RFU_STOP_MODE, //3D
};
struct RfuPacket8
@@ -555,3 +561,48 @@ void STWI_send_TestModeREQ(u8 unk0, u8 unk1)
STWI_start_Command();
}
}
+
+void STWI_send_CPR_StartREQ(u16 unk0, u16 unk1, u8 unk2)
+{
+ u32 *packetData;
+ u32 arg1;
+
+ if (!STWI_init(RFU_CPR_START))
+ {
+ gRfuState->txParams = 2;
+
+ arg1 = unk1 | (unk0 << 16);
+ packetData = gRfuState->txPacket->rfuPacket32.data;
+ packetData[0] = arg1;
+ packetData[1] = unk2;
+
+ STWI_start_Command();
+ }
+}
+
+void STWI_send_CPR_PollingREQ()
+{
+ if (!STWI_init(RFU_CPR_POLLING))
+ {
+ gRfuState->txParams = 0;
+ STWI_start_Command();
+ }
+}
+
+void STWI_send_CPR_EndREQ()
+{
+ if (!STWI_init(RFU_CPR_END))
+ {
+ gRfuState->txParams = 0;
+ STWI_start_Command();
+ }
+}
+
+void STWI_send_StopModeREQ()
+{
+ if (!STWI_init(RFU_STOP_MODE))
+ {
+ gRfuState->txParams = 0;
+ STWI_start_Command();
+ }
+}