match RFU SDK v1.0.26
This commit is contained in:
+8
-2
@@ -4,6 +4,8 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
#define LIBRFU_VERSION 1024
|
||||||
|
|
||||||
/* TODOs:
|
/* TODOs:
|
||||||
* - documentation
|
* - documentation
|
||||||
* - check if any field needs to be volatile
|
* - check if any field needs to be volatile
|
||||||
@@ -307,7 +309,11 @@ struct STWIStatus
|
|||||||
u8 ackActiveCommand;
|
u8 ackActiveCommand;
|
||||||
u8 timerSelect;
|
u8 timerSelect;
|
||||||
u8 unk_b;
|
u8 unk_b;
|
||||||
u32 timerState; // this field is s32 in emerald
|
#if LIBRFU_VERSION >= 1026
|
||||||
|
s32 timerState;
|
||||||
|
#else
|
||||||
|
u32 timerState;
|
||||||
|
#endif
|
||||||
vu8 timerActive;
|
vu8 timerActive;
|
||||||
u8 unk_11;
|
u8 unk_11;
|
||||||
vu16 error;
|
vu16 error;
|
||||||
@@ -472,7 +478,7 @@ extern struct RfuFixed *gRfuFixed;
|
|||||||
extern struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX];
|
extern struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX];
|
||||||
extern struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX];
|
extern struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX];
|
||||||
|
|
||||||
// librfu_s32id
|
// librfu_sio32id
|
||||||
s32 AgbRFU_checkID(u8 maxTries);
|
s32 AgbRFU_checkID(u8 maxTries);
|
||||||
|
|
||||||
// Arguments with "bm..." specify slots of the form (0x01 << slot number) that are the object of a function operation.
|
// Arguments with "bm..." specify slots of the form (0x01 << slot number) that are the object of a function operation.
|
||||||
|
|||||||
+43
-17
@@ -108,7 +108,7 @@ static const struct LLSFStruct llsf_struct[2] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EMERALD
|
#if LIBRFU_VERSION == 1026
|
||||||
static const char lib_ver[] = "RFU_V1026";
|
static const char lib_ver[] = "RFU_V1026";
|
||||||
#else
|
#else
|
||||||
static const char lib_ver[] = "RFU_V1024";
|
static const char lib_ver[] = "RFU_V1024";
|
||||||
@@ -116,12 +116,12 @@ static const char lib_ver[] = "RFU_V1024";
|
|||||||
|
|
||||||
static const char str_checkMbootLL[] = "RFU-MBOOT";
|
static const char str_checkMbootLL[] = "RFU-MBOOT";
|
||||||
|
|
||||||
#define COPY(src, dst, size) do { \
|
#define COPY(src, dst, iterator, size) do { \
|
||||||
const u16 *_src = (const u16 *)(src); \
|
const u16 *_src = (const u16 *)(src); \
|
||||||
u16 *_dst = (u16 *)(dst); \
|
u16 *_dst = (u16 *)(dst); \
|
||||||
u16 _size = (size); \
|
iterator = (size); \
|
||||||
while (_size-- != 0) \
|
while (iterator-- != 0) \
|
||||||
*_dst++ = *_src++; \
|
*_dst++ = *_src++; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
u16 rfu_initializeAPI(u32 *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam)
|
u16 rfu_initializeAPI(u32 *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam)
|
||||||
@@ -177,17 +177,17 @@ u16 rfu_initializeAPI(u32 *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p
|
|||||||
gRfuSlotStatusUNI[i]->recvBufferSize = 0;
|
gRfuSlotStatusUNI[i]->recvBufferSize = 0;
|
||||||
}
|
}
|
||||||
// rfu_REQ_changeMasterSlave is the function next to rfu_STC_fastCopy
|
// rfu_REQ_changeMasterSlave is the function next to rfu_STC_fastCopy
|
||||||
#if LIBRFU_VERSION < 1028
|
#if LIBRFU_VERSION < 1026
|
||||||
src = (const u16 *)((uintptr_t)&rfu_STC_fastCopy & ~1);
|
src = (const u16 *)((uintptr_t)&rfu_STC_fastCopy & ~1);
|
||||||
dst = gRfuFixed->fastCopyBuffer;
|
dst = gRfuFixed->fastCopyBuffer;
|
||||||
buffByteSizeMax = ((void *)rfu_REQ_changeMasterSlave - (void *)rfu_STC_fastCopy) / sizeof(u16);
|
buffByteSizeMax = ((void *)rfu_REQ_changeMasterSlave - (void *)rfu_STC_fastCopy) / sizeof(u16);
|
||||||
while (buffByteSizeMax-- != 0)
|
while (buffByteSizeMax-- != 0)
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
#else
|
#else
|
||||||
// register swap dst <--> buffByteSizeMax
|
|
||||||
COPY(
|
COPY(
|
||||||
(const u16 *)((uintptr_t)&rfu_STC_fastCopy & ~1),
|
(uintptr_t)&rfu_STC_fastCopy & ~1,
|
||||||
gRfuFixed->fastCopyBuffer,
|
gRfuFixed->fastCopyBuffer,
|
||||||
|
buffByteSizeMax,
|
||||||
0x60 / sizeof(u16)
|
0x60 / sizeof(u16)
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
@@ -501,7 +501,7 @@ static void rfu_CB_configGameData(u8 reqCommand, u16 reqResult)
|
|||||||
void rfu_REQ_startSearchChild(void)
|
void rfu_REQ_startSearchChild(void)
|
||||||
{
|
{
|
||||||
u16 result;
|
u16 result;
|
||||||
#if LIBRFU_VERSION >= 1028
|
#if LIBRFU_VERSION >= 1026
|
||||||
u16 i;
|
u16 i;
|
||||||
for (i = 0; i < RFU_CHILD_MAX; i++)
|
for (i = 0; i < RFU_CHILD_MAX; i++)
|
||||||
{
|
{
|
||||||
@@ -591,14 +591,12 @@ static void rfu_STC_readChildList(void)
|
|||||||
u8 numSlots = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[1];
|
u8 numSlots = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[1];
|
||||||
u8 *data_p;
|
u8 *data_p;
|
||||||
u8 i;
|
u8 i;
|
||||||
u8 true_slots[RFU_CHILD_MAX];
|
|
||||||
u8 bm_slot_id;
|
u8 bm_slot_id;
|
||||||
|
#if LIBRFU_VERSION < 1026
|
||||||
#if LIBRFU_VERSION >= 1028
|
u8 true_slots[RFU_CHILD_MAX];
|
||||||
//#if 1
|
|
||||||
// TODO: decompile this
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBRFU_VERSION < 1026
|
||||||
if (numSlots != 0)
|
if (numSlots != 0)
|
||||||
{
|
{
|
||||||
stwiParam = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0];
|
stwiParam = gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0];
|
||||||
@@ -612,6 +610,7 @@ static void rfu_STC_readChildList(void)
|
|||||||
}
|
}
|
||||||
gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0] = stwiParam;
|
gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket32.data[0] = stwiParam;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
for (data_p = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4];
|
for (data_p = &gRfuFixed->STWIBuffer->rxPacketAlloc.rfuPacket8.data[4];
|
||||||
numSlots != 0;
|
numSlots != 0;
|
||||||
data_p += 4)
|
data_p += 4)
|
||||||
@@ -619,6 +618,7 @@ static void rfu_STC_readChildList(void)
|
|||||||
bm_slot_id = data_p[2];
|
bm_slot_id = data_p[2];
|
||||||
if (bm_slot_id < RFU_CHILD_MAX && !((gRfuLinkStatus->connSlotFlag >> bm_slot_id) & 1) && !((gRfuLinkStatus->linkLossSlotFlag >> bm_slot_id) & 1))
|
if (bm_slot_id < RFU_CHILD_MAX && !((gRfuLinkStatus->connSlotFlag >> bm_slot_id) & 1) && !((gRfuLinkStatus->linkLossSlotFlag >> bm_slot_id) & 1))
|
||||||
{
|
{
|
||||||
|
#if LIBRFU_VERSION < 1026
|
||||||
if (true_slots[bm_slot_id] != 0)
|
if (true_slots[bm_slot_id] != 0)
|
||||||
++gRfuStatic->lsFixedCount[bm_slot_id];
|
++gRfuStatic->lsFixedCount[bm_slot_id];
|
||||||
if (gRfuStatic->lsFixedCount[bm_slot_id] >= 4)
|
if (gRfuStatic->lsFixedCount[bm_slot_id] >= 4)
|
||||||
@@ -633,6 +633,17 @@ static void rfu_STC_readChildList(void)
|
|||||||
gRfuStatic->flags &= 0x7F;
|
gRfuStatic->flags &= 0x7F;
|
||||||
gRfuStatic->cidBak[bm_slot_id] = gRfuLinkStatus->partner[bm_slot_id].id;
|
gRfuStatic->cidBak[bm_slot_id] = gRfuLinkStatus->partner[bm_slot_id].id;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
gRfuStatic->lsFixedCount[bm_slot_id] = 0xF0;
|
||||||
|
gRfuLinkStatus->strength[bm_slot_id] = 16;
|
||||||
|
gRfuLinkStatus->connSlotFlag |= 1 << bm_slot_id;
|
||||||
|
++gRfuLinkStatus->connCount;
|
||||||
|
gRfuLinkStatus->partner[bm_slot_id].id = *(u16 *)data_p;
|
||||||
|
gRfuLinkStatus->partner[bm_slot_id].slot = bm_slot_id;
|
||||||
|
gRfuLinkStatus->parentChild = MODE_PARENT;
|
||||||
|
gRfuStatic->flags &= 0x7F;
|
||||||
|
gRfuStatic->cidBak[bm_slot_id] = gRfuLinkStatus->partner[bm_slot_id].id;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
--numSlots;
|
--numSlots;
|
||||||
}
|
}
|
||||||
@@ -881,7 +892,11 @@ u16 rfu_REQBN_watchLink(u16 reqCommandId, u8 *bmLinkLossSlot, u8 *linkLossReason
|
|||||||
gRfuStatic->watchdogTimer = 360;
|
gRfuStatic->watchdogTimer = 360;
|
||||||
if (gRfuStatic->nowWatchInterval == 0)
|
if (gRfuStatic->nowWatchInterval == 0)
|
||||||
{
|
{
|
||||||
|
#if LIBRFU_VERSION < 1026
|
||||||
gRfuStatic->nowWatchInterval = gRfuLinkStatus->watchInterval;
|
gRfuStatic->nowWatchInterval = gRfuLinkStatus->watchInterval;
|
||||||
|
#else
|
||||||
|
gRfuStatic->nowWatchInterval = 4;
|
||||||
|
#endif
|
||||||
reasonMaybe = 1;
|
reasonMaybe = 1;
|
||||||
}
|
}
|
||||||
if ((u8)reqCommandId == ID_DISCONNECTED_AND_CHANGE_REQ)
|
if ((u8)reqCommandId == ID_DISCONNECTED_AND_CHANGE_REQ)
|
||||||
@@ -934,6 +949,14 @@ u16 rfu_REQBN_watchLink(u16 reqCommandId, u8 *bmLinkLossSlot, u8 *linkLossReason
|
|||||||
}
|
}
|
||||||
for (; i < RFU_CHILD_MAX; ++i)
|
for (; i < RFU_CHILD_MAX; ++i)
|
||||||
{
|
{
|
||||||
|
#if LIBRFU_VERSION >= 1026
|
||||||
|
if (gRfuStatic->lsFixedCount[i] != 0)
|
||||||
|
{
|
||||||
|
gRfuStatic->lsFixedCount[i] -= 4;
|
||||||
|
if (gRfuLinkStatus->strength[i] <= 15)
|
||||||
|
gRfuLinkStatus->strength[i] = 16;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
newLinkLossFlag = 1 << i;
|
newLinkLossFlag = 1 << i;
|
||||||
if (reqResult == 0)
|
if (reqResult == 0)
|
||||||
{
|
{
|
||||||
@@ -1041,6 +1064,9 @@ static void rfu_STC_removeLinkData(u8 bmConnectedPartnerId, u8 bmDisconnect)
|
|||||||
u8 bmLinkLossFlag = 1 << bmConnectedPartnerId;
|
u8 bmLinkLossFlag = 1 << bmConnectedPartnerId;
|
||||||
s32 bmLinkRetainedFlag;
|
s32 bmLinkRetainedFlag;
|
||||||
|
|
||||||
|
#if LIBRFU_VERSION >= 1026
|
||||||
|
gRfuStatic->lsFixedCount[bmConnectedPartnerId] = 0;
|
||||||
|
#endif
|
||||||
if ((gRfuLinkStatus->connSlotFlag & bmLinkLossFlag) && gRfuLinkStatus->connCount != 0)
|
if ((gRfuLinkStatus->connSlotFlag & bmLinkLossFlag) && gRfuLinkStatus->connCount != 0)
|
||||||
--gRfuLinkStatus->connCount;
|
--gRfuLinkStatus->connCount;
|
||||||
gRfuLinkStatus->connSlotFlag &= bmLinkRetainedFlag = ~bmLinkLossFlag;
|
gRfuLinkStatus->connSlotFlag &= bmLinkRetainedFlag = ~bmLinkLossFlag;
|
||||||
@@ -1421,7 +1447,7 @@ static u16 rfu_STC_setSendData_org(u8 ni_or_uni, u8 bmSendSlot, u8 subFrameSize,
|
|||||||
slotStatus_NI->send.src = src;
|
slotStatus_NI->send.src = src;
|
||||||
slotStatus_NI->send.ack = 0;
|
slotStatus_NI->send.ack = 0;
|
||||||
slotStatus_NI->send.phase = 0;
|
slotStatus_NI->send.phase = 0;
|
||||||
#ifndef NONMATCHING // to fix bm_slot_id, r3, frameSize, sending register roulette
|
#ifndef NONMATCHING // to fix r2, r3, r4, r5 register roulette
|
||||||
asm("":::"r2");
|
asm("":::"r2");
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < WINDOW_COUNT; ++i)
|
for (i = 0; i < WINDOW_COUNT; ++i)
|
||||||
|
|||||||
Reference in New Issue
Block a user