sovereignx/include/link_rfu.h

295 lines
8.7 KiB
C
Raw Normal View History

2017-11-11 03:08:17 +00:00
#ifndef GUARD_LINK_RFU_H
#define GUARD_LINK_RFU_H
2018-12-02 10:58:50 +00:00
#include "librfu.h"
2018-12-13 03:55:39 +00:00
#include "link.h"
2020-02-16 18:49:36 +00:00
#include "AgbRfu_LinkManager.h"
2018-12-02 10:58:50 +00:00
2020-06-06 21:46:19 +01:00
#define RFU_COMMAND_0x4400 0x4400
#define RFU_COMMAND_0x8800 0x8800
#define RFU_COMMAND_0x8900 0x8900
#define RFU_COMMAND_0xA100 0xA100
#define RFU_COMMAND_0x7700 0x7700
#define RFU_COMMAND_0x7800 0x7800
#define RFU_COMMAND_0x6600 0x6600
#define RFU_COMMAND_0x5F00 0x5F00
#define RFU_COMMAND_0x2F00 0x2F00
#define RFU_COMMAND_0xBE00 0xBE00
#define RFU_COMMAND_0xEE00 0xEE00
#define RFU_COMMAND_0xED00 0xED00
2017-11-11 03:08:17 +00:00
2020-02-16 18:49:36 +00:00
// RfuTgtData.gname is read as these structs.
struct GFtgtGnameSub
2020-01-15 20:46:17 +00:00
{
2020-02-16 18:49:36 +00:00
u16 language:4;
u16 hasNews:1;
u16 hasCard:1;
2020-06-07 22:37:09 +01:00
u16 unknown:1; // Never read
2020-01-15 20:46:17 +00:00
u16 isChampion:1;
u16 hasNationalDex:1;
2020-02-16 18:49:36 +00:00
u16 gameClear:1;
u16 version:4;
2020-01-15 20:46:17 +00:00
u8 playerTrainerId[2];
};
2020-02-16 18:49:36 +00:00
struct __attribute__((packed, aligned(2))) GFtgtGname
2020-01-15 20:46:17 +00:00
{
2020-02-16 18:49:36 +00:00
struct GFtgtGnameSub unk_00;
u8 child_sprite_gender[RFU_CHILD_MAX]; // u8 sprite_idx:3;
// u8 gender:1;
// u8 unk_4:3
// u8 active:1
2020-01-15 20:46:17 +00:00
u16 species:10;
u16 type:6;
2020-02-16 18:49:36 +00:00
u8 activity:7;
u8 started:1;
2020-01-15 20:46:17 +00:00
u8 playerGender:1;
u8 level:7;
2020-02-16 18:49:36 +00:00
u8 padding;
}; // size: RFU_GNAME_SIZE
2020-01-15 20:46:17 +00:00
2017-11-17 13:44:54 +00:00
struct UnkLinkRfuStruct_02022B2C
{
2017-11-19 21:54:49 +00:00
u8 unk_00;
u8 unk_01;
u16 unk_02;
u8 unk_04;
u16 unk_06;
2020-02-16 18:49:36 +00:00
struct GFtgtGname *unk_08;
u8 *unk_0c;
2017-11-17 13:44:54 +00:00
u8 unk_10;
u8 unk_11;
u16 unk_12;
u16 unk_14;
};
2017-12-07 05:28:12 +00:00
struct UnkLinkRfuStruct_02022B44
{
2017-12-08 01:21:30 +00:00
u8 fill_00[6];
u16 unk_06;
2018-01-18 13:46:17 +00:00
u8 fill_08[6];
vu8 unk_0e;
2017-12-07 05:28:12 +00:00
u8 unk_0f;
2018-01-20 16:53:35 +00:00
u8 fill_10[0x54];
u16 unk_64;
u8 fill_66[0x1d];
u8 unk_83;
u8 fill_84[0x58];
2017-12-07 05:28:12 +00:00
};
2020-06-06 21:46:19 +01:00
struct RfuBlockSend
2018-12-01 17:54:59 +00:00
{
2020-06-06 21:46:19 +01:00
/* 0x00 */ u16 next;
/* 0x02 */ u16 count;
/* 0x04 */ const u8 *payload;
/* 0x08 */ u32 receivedFlags;
/* 0x0c */ u32 failedFlags;
/* 0x10 */ bool8 sending;
/* 0x11 */ u8 owner;
/* 0x12 */ u8 receiving;
2017-12-05 00:51:26 +00:00
};
2020-06-06 21:46:19 +01:00
struct RfuRecvQueue
2018-12-01 17:54:59 +00:00
{
2020-06-07 22:37:09 +01:00
/* 0x000 */ u8 slots[32][70];
/* 0x8c0 */ vu8 recvSlot;
/* 0x8c1 */ vu8 sendSlot;
2020-06-06 21:46:19 +01:00
/* 0x8c2 */ vu8 count;
/* 0x8c3 */ vu8 full;
2017-12-01 03:56:56 +00:00
};
2020-06-06 21:46:19 +01:00
struct RfuSendQueue
2018-12-01 17:54:59 +00:00
{
2020-06-07 22:37:09 +01:00
/* 0x000 */ u8 slots[40][14];
/* 0x230 */ vu8 recvSlot;
/* 0x231 */ vu8 sendSlot;
2020-06-06 21:46:19 +01:00
/* 0x232 */ vu8 count;
/* 0x233 */ vu8 full;
2017-12-01 03:56:56 +00:00
};
2020-06-07 22:37:09 +01:00
struct RfuBackupQueue
2018-12-01 17:54:59 +00:00
{
2020-06-07 22:37:09 +01:00
/* 0x00 */ u8 slots[2][14];
/* 0x1c */ vu8 recvSlot;
/* 0x1d */ vu8 sendSlot;
2020-06-06 21:46:19 +01:00
/* 0x1e */ vu8 count;
2017-12-02 02:51:06 +00:00
};
2020-06-06 21:46:19 +01:00
struct GFRfuManager
2018-12-01 17:54:59 +00:00
{
2020-06-06 21:46:19 +01:00
/* 0x000 */ void (*callback)(void);
/* 0x004 */ u16 state;
2018-01-20 23:43:58 +00:00
/* 0x006 */ u8 filler_06[4];
2020-06-06 21:46:19 +01:00
/* 0x00a */ u16 linkmanMsg;
/* 0x00c */ u8 parentChild;
2017-11-19 05:02:15 +00:00
/* 0x00d */ u8 playerCount;
2017-12-16 17:07:20 +00:00
/* 0x00e */ u8 unk_0e;
2018-01-20 23:43:58 +00:00
/* 0x00f */ u8 unk_0f;
/* 0x010 */ u16 unk_10;
/* 0x012 */ u16 unk_12;
2017-12-07 13:48:49 +00:00
/* 0x014 */ u8 unk_14[4][14];
2017-12-08 13:24:54 +00:00
/* 0x04c */ u8 unk_4c[14];
2018-01-20 15:16:09 +00:00
/* 0x05a */ u8 unk_5a;
/* 0x05b */ u8 unk_5b;
2020-06-07 22:37:09 +01:00
/* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS];
/* 0x061 */ bool8 numBlocksReceived[MAX_RFU_PLAYERS];
2020-06-06 21:46:19 +01:00
/* 0x066 */ u8 idleTaskId;
/* 0x067 */ u8 searchTaskId;
2017-12-07 05:28:12 +00:00
/* 0x068 */ u8 filler_68[4];
2020-06-06 21:46:19 +01:00
/* 0x06c */ struct RfuBlockSend unk_6c;
/* 0x080 */ struct RfuBlockSend unk_80[MAX_RFU_PLAYERS];
2018-01-20 02:50:30 +00:00
/* 0x0e4 */ u8 unk_e4[5];
/* 0x0e9 */ u8 unk_e9[5];
2020-06-06 21:46:19 +01:00
/* 0x0ee */ vu8 errorState;
/* 0x0ef */ bool8 isShuttingDown;
/* 0x0f0 */ u8 linkLossRecoveryState;
/* 0x0f1 */ u8 errorStatus;
2018-01-20 15:16:09 +00:00
/* 0x0f2 */ u16 unk_f2[6];
2018-01-20 19:59:34 +00:00
/* 0x0fe */ u16 unk_fe;
2018-01-20 02:50:30 +00:00
/* 0x100 */ u16 unk_100;
2018-01-18 18:18:24 +00:00
/* 0x102 */ u8 unk_102;
2018-12-01 17:54:59 +00:00
/* 0x103 */ u8 filler_103[0x10A - 0x103];
2020-02-16 18:49:36 +00:00
/* 0x10A */ struct GFtgtGname unk_10A;
2018-12-02 10:58:50 +00:00
u8 filler_;
u8 playerName[PLAYER_NAME_LENGTH + 1];
2020-06-06 21:46:19 +01:00
/* 0x124 */ struct RfuRecvQueue recvQueue;
/* 0x9e8 */ struct RfuSendQueue sendQueue;
2020-06-07 22:37:09 +01:00
/* 0xc1c */ struct RfuBackupQueue backupQueue;
/* 0xc3c */ vu8 linkRecovered;
2017-12-10 15:23:43 +00:00
/* 0xc3d */ u8 unk_c3d;
2020-06-06 21:46:19 +01:00
/* 0xc3e */ vu8 childSlot;
2017-12-07 13:48:49 +00:00
/* 0xc3f */ u8 unk_c3f[70];
2018-01-20 20:50:45 +00:00
/* 0xc85 */ u8 unk_c85;
/* 0xc86 */ u8 unk_c86;
2020-06-06 21:46:19 +01:00
/* 0xc87 */ u8 recvCmds[5][7][2];
/* 0xccd */ u8 parentId;
/* 0xcce */ u8 multiplayerId;
2018-01-20 02:50:30 +00:00
/* 0xccf */ u8 unk_ccf;
2017-12-08 01:21:30 +00:00
/* 0xcd0 */ vu8 unk_cd0;
2018-01-20 20:50:45 +00:00
/* 0xcd1 */ u8 unk_cd1[4];
/* 0xcd5 */ u8 unk_cd5[4];
2018-01-18 13:46:17 +00:00
/* 0xcd9 */ u8 unk_cd9;
2017-12-08 01:21:30 +00:00
/* 0xcda */ u8 unk_cda;
2017-12-05 02:05:41 +00:00
/* 0xcdb */ vu8 unk_cdb;
2017-12-16 17:07:20 +00:00
/* 0xcdc */ vu8 unk_cdc;
/* 0xcdd */ u8 unk_cdd;
2020-06-06 21:46:19 +01:00
/* 0xcde */ u8 linkPlayerIdx[RFU_CHILD_MAX];
2017-12-07 13:48:49 +00:00
/* 0xce2 */ u8 unk_ce2;
/* 0xce2 */ u8 unk_ce3;
2017-12-07 05:28:12 +00:00
/* 0xce4 */ u8 unk_ce4;
2018-01-18 13:46:17 +00:00
/* 0xce5 */ u8 unk_ce5;
/* 0xce5 */ u8 unk_ce6;
2020-06-06 21:46:19 +01:00
/* 0xce7 */ u8 acceptSlot_flag;
2017-12-08 01:04:07 +00:00
/* 0xce8 */ u8 unk_ce8;
2018-01-18 13:46:17 +00:00
/* 0xce9 */ u8 unk_ce9;
/* 0xcea */ u8 unk_cea[4];
/* 0xcee */ u8 unk_cee[4];
2017-12-05 00:51:26 +00:00
}; // size = 0xcf4
2017-11-17 04:37:09 +00:00
2017-11-11 03:08:17 +00:00
// Exported RAM declarations
2020-06-06 21:46:19 +01:00
extern struct GFtgtGname gHostRFUtgtGnameBuffer;
extern u8 gHostRFUtgtUnameBuffer[];
extern struct GFRfuManager Rfu;
extern u8 gWirelessStatusIndicatorSpriteId;
2017-11-17 04:37:09 +00:00
2017-11-11 03:08:17 +00:00
// Exported ROM declarations
void WipeTrainerNameRecords(void);
2017-11-11 03:08:17 +00:00
void sub_800E700(void);
2020-05-30 09:09:21 +01:00
void LinkRfu_Shutdown(void);
2020-06-06 21:46:19 +01:00
void Rfu_SetBlockReceivedFlag(u8 who);
void Rfu_ResetBlockReceivedFlag(u8 who);
bool32 IsSendingKeysToRfu(void);
2020-06-06 21:46:19 +01:00
void StartSendingKeysToRfu(void);
2017-11-11 03:08:17 +00:00
void sub_800F850(void);
2020-06-06 21:46:19 +01:00
u8 Rfu_GetBlockReceivedStatus(void);
bool32 Rfu_InitBlockSend(const u8 *src, size_t size);
2019-10-05 15:41:37 +01:00
void ClearLinkRfuCallback(void);
2020-06-06 21:46:19 +01:00
u8 Rfu_GetLinkPlayerCount(void);
u8 Rfu_GetMultiplayerId(void);
2017-11-11 03:08:17 +00:00
bool8 sub_8010100(u8 a0);
2019-10-09 10:56:44 +01:00
bool8 IsLinkRfuTaskFinished(void);
2017-11-13 03:09:11 +00:00
bool8 Rfu_IsMaster(void);
void task_add_05_task_del_08FA224_when_no_RfuFunc(void);
2017-11-13 03:44:20 +00:00
void sub_8010434(void);
2020-06-06 21:46:19 +01:00
void ResetLinkRfuGFLayer(void);
2020-06-07 22:37:09 +01:00
void UpdateWirelessStatusIndicatorSprite(void);
2020-06-06 21:46:19 +01:00
void InitRFU(void);
2017-11-13 06:01:27 +00:00
bool32 sub_8010EC0(void);
bool32 sub_8010F1C(void);
2020-05-30 09:09:21 +01:00
bool32 RfuIsErrorStatus1or2(void);
bool32 IsRfuRecvQueueEmpty(void);
u32 GetRfuRecvQueueLength(void);
2017-11-14 13:44:32 +00:00
void RfuVSync(void);
2017-12-05 02:05:41 +00:00
void sub_80111B0(bool32 a0);
2020-05-30 09:09:21 +01:00
u8 RfuGetErrorStatus(void);
struct GFtgtGname *GetHostRFUtgtGname(void);
void UpdateGameData_GroupLockedIn(u8 a0);
2020-06-06 21:46:19 +01:00
void GetLinkmanErrorParams(u32 a0);
2020-05-30 09:09:21 +01:00
void RfuSetErrorStatus(u8 a0, u16 a1);
2018-05-20 09:51:09 +01:00
u8 sub_801048C(bool32 a0);
2020-05-30 09:09:21 +01:00
void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2);
void SetHostRFUtgtGname(u8 a0, u32 a1, u32 a2);
void InitializeRfuLinkManager_LinkLeader(u32 a0);
2018-06-03 08:37:01 +01:00
bool32 sub_8012240(void);
2020-05-30 09:09:21 +01:00
void LinkRfu_StopManagerAndFinalizeSlots(void);
2018-06-03 08:37:01 +01:00
bool32 sub_80105EC(void);
2020-05-30 09:09:21 +01:00
bool32 TrainerIdAndNameStillInPartnersList(u16 a0, const u8 *a1);
void SendByteToPartnerByIdAndName(u8 a0, u16 a1, const u8 *a2);
u32 WaitSendByteToPartnerByIdAndName(u16 a0, const u8 *a1);
void RequestDisconnectSlotByTrainerNameAndId(const u8 *a0, u16 a1);
bool8 LmanAcceptSlotFlagIsNotZero(void);
bool32 WaitRfuState(bool32 a0);
2018-06-03 08:37:01 +01:00
void sub_801103C(void);
2020-05-30 09:09:21 +01:00
void InitializeRfuLinkManager_JoinGroup(void);
void LinkRfuNIsend8(void);
void RecordMixTrainerNames(void);
2020-05-30 09:09:21 +01:00
void LinkRfu_CreateConnectionAsParent(void);
void LinkRfu_StopManagerBeforeEnteringChat(void);
void UpdateGameDataWithActivitySpriteGendersFlag(u8 a0, u32 a1, u32 a2);
void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId);
void SetGnameBufferWonderFlags(bool32 a0, bool32 a1);
void ClearAndInitHostRFUtgtGname(void);
2020-06-06 21:46:19 +01:00
void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level);
2020-05-30 09:09:21 +01:00
void InitializeRfuLinkManager_EnterUnionRoom(void);
2020-02-16 18:49:36 +00:00
void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2);
2020-05-30 09:09:21 +01:00
bool32 IsUnionRoomListenTaskActive(void);
2019-08-01 18:01:50 +01:00
void sub_800FE50(void *a0);
2020-05-30 09:09:21 +01:00
bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name);
2018-06-09 21:14:52 +01:00
void sub_8011DE0(u32 arg0);
2019-06-29 03:26:11 +01:00
u8 sub_801100C(s32 a0);
2018-06-10 17:28:37 +01:00
void sub_800EF7C(void);
2020-05-30 09:09:21 +01:00
bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
2018-12-19 01:29:41 +00:00
s32 sub_800E87C(u8 idx);
2020-06-06 21:46:19 +01:00
void CreateTask_RfuIdle(void);
void DestroyTask_RfuIdle(void);
2019-02-08 17:48:51 +00:00
void sub_8010198(void);
2019-03-25 19:26:23 +00:00
void sub_8011AC8(void);
void LinkRfu_FatalError(void);
2019-03-27 00:03:46 +00:00
bool32 sub_8011A9C(void);
void sub_80104B0(void);
void sub_8011A50(void);
void sub_80110B8(u32 a0);
2020-06-07 22:37:09 +01:00
bool32 IsRfuSerialNumberValid(u32 serialNo);
bool8 IsRfuRecoveringFromLinkLoss(void);
2020-02-16 18:49:36 +00:00
void sub_8011BA4(void);
2020-06-07 22:37:09 +01:00
void RfuRecvQueue_Reset(struct RfuRecvQueue *queue);
void RfuSendQueue_Reset(struct RfuSendQueue *queue);
void RfuRecvQueue_Enqueue(struct RfuRecvQueue *queue, u8 *data);
void RfuSendQueue_Enqueue(struct RfuSendQueue *queue, u8 *data);
bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest);
bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *dest);
void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *q2);
bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *q2);
2020-02-16 18:49:36 +00:00
void sub_800DBF8(u8 *q1, u8 mode);
u8 sub_800DD1C(u8 maxFlags);
2020-06-07 22:37:09 +01:00
void InitHostRFUtgtGname(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3);
2020-02-16 18:49:36 +00:00
void CreateWirelessStatusIndicatorSprite(u8 x, u8 y);
void DestroyWirelessStatusIndicatorSprite(void);
void LoadWirelessStatusIndicatorSpriteGfx(void);
u8 sub_800E124(void);
void sub_800E15C(struct Sprite *sprite, s32 signalStrengthAnimNum);
2017-11-11 03:08:17 +00:00
#endif //GUARD_LINK_RFU_H