From e01ae55c13f9717f6b0f781846d9ceaeeb2a250d Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 11 Jul 2021 20:42:05 -0400 Subject: Start more link_rfu_2 documentation --- include/link_rfu.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index e1c3a6fba..da13fe539 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -41,8 +41,8 @@ #define RFU_STATUS_WAIT_ACK_JOIN_GROUP 7 #define RFU_STATUS_LEAVE_GROUP_NOTICE 8 #define RFU_STATUS_LEAVE_GROUP 9 -#define RFU_STATUS_10 10 -#define RFU_STATUS_11 11 +#define RFU_STATUS_CHILD_LEAVE_READY 10 +#define RFU_STATUS_CHILD_LEAVE 11 #define RFU_STATUS_ACK_JOIN_GROUP 12 // RfuTgtData.gname is read as these structs. @@ -213,8 +213,8 @@ void Rfu_SetLinkStandbyCallback(void); void ResetLinkRfuGFLayer(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -bool32 sub_8010EC0(void); -bool32 sub_8010F1C(void); +bool32 RfuMain1(void); +bool32 RfuMain2(void); bool32 RfuHasErrored(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); @@ -229,9 +229,9 @@ u8 sub_801048C(bool32 a0); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2); void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started); void InitializeRfuLinkManager_LinkLeader(u32 a0); -bool32 sub_8012240(void); +bool32 IsRfuCommunicatingWithAllChildren(void); void LinkRfu_StopManagerAndFinalizeSlots(void); -bool32 sub_80105EC(void); +bool32 RfuTryDisconnectLeavingChildren(void); bool32 HasTrainerLeftPartnersList(u16 trainerId, const u8 *name); void SendRfuStatusToPartner(u8 status, u16 trainerId, const u8 *name); u32 WaitSendRfuStatusToPartner(u16 trainerId, const u8 *name); -- cgit v1.2.3 From 4efa6c882a68d69e32f59580faa438a6b1fd0b68 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 15 Aug 2021 18:26:09 -0400 Subject: Continue misc link documentation, rename reset_save_heap --- include/link_rfu.h | 88 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 34 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index da13fe539..04f1b7f9a 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -5,20 +5,25 @@ #include "link.h" #include "AgbRfu_LinkManager.h" +#define RFUCMD_MASK 0xFF00 + #define RFUCMD_SEND_PACKET 0x2F00 #define RFUCMD_BLENDER_SEND_KEYS 0x4400 #define RFUCMD_READY_CLOSE_LINK 0x5F00 #define RFUCMD_READY_EXIT_STANDBY 0x6600 -#define RFUCMD_0x7700 0x7700 -#define RFUCMD_0x7800 0x7800 -#define RFUCMD_0x8800 0x8800 -#define RFUCMD_0x8900 0x8900 +#define RFUCMD_SEND_PLAYER_IDS 0x7700 +#define RFUCMD_SEND_PLAYER_IDS_NEW 0x7800 +#define RFUCMD_SEND_BLOCK_INIT 0x8800 +#define RFUCMD_SEND_BLOCK 0x8900 #define RFUCMD_SEND_BLOCK_REQ 0xA100 #define RFUCMD_SEND_HELD_KEYS 0xBE00 -#define RFUCMD_0xED00 0xED00 -#define RFUCMD_0xEE00 0xEE00 +#define RFUCMD_DISCONNECT 0xED00 +#define RFUCMD_DISCONNECT_PARENT 0xEE00 -#define RFU_SERIAL_7F7D 0x7F7D +#define RFU_SERIAL_A 0x0002 +#define RFU_SERIAL_B 0x7F7D +#define RFU_SERIAL_C 0x0000 +#define RFU_SERIAL_END 0xFFFF #define RECV_QUEUE_NUM_SLOTS 32 #define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS) @@ -45,6 +50,24 @@ #define RFU_STATUS_CHILD_LEAVE 11 #define RFU_STATUS_ACK_JOIN_GROUP 12 +#define CHILD_DATA_LENGTH 14 + +// Values for disconnectMode +enum { + RFU_DISCONNECT_NONE, + RFU_DISCONNECT_ERROR, + RFU_DISCONNECT_NORMAL, +}; + +// Values for errorState +enum { + RFU_ERROR_STATE_NONE, + RFU_ERROR_STATE_1, + RFU_ERROR_STATE_2, + RFU_ERROR_STATE_3, + RFU_ERROR_STATE_IGNORE, +}; + // RfuTgtData.gname is read as these structs. struct GFtgtGnameSub { @@ -125,8 +148,8 @@ struct GFRfuManager /* 0x00f */ u8 unk_0f; /* 0x010 */ u16 unk_10; /* 0x012 */ u16 unk_12; - /* 0x014 */ u8 unk_14[RFU_CHILD_MAX][14]; - /* 0x04c */ u8 unk_4c[14]; + /* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH]; + /* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH]; /* 0x05a */ u8 blockRequestType; /* 0x05b */ u8 unk_5b; /* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS]; @@ -144,9 +167,9 @@ struct GFRfuManager /* 0x0f1 */ u8 status; /* 0x0f2 */ u16 packet[RFU_PACKET_SIZE]; /* 0x0fe */ u16 resendExitStandbyTimer; - /* 0x100 */ u16 unk_100; + /* 0x100 */ u16 allReadyNum; /* 0x102 */ u8 unk_102; - /* 0x103 */ u8 filler_103[0x10A - 0x103]; + /* 0x103 */ u8 filler_103[7]; /* 0x10A */ struct GFtgtGname unk_10A; u8 filler_; u8 playerName[PLAYER_NAME_LENGTH + 1]; @@ -162,36 +185,33 @@ struct GFRfuManager /* 0xc87 */ u8 recvCmds[5][7][2]; /* 0xccd */ u8 parentId; /* 0xcce */ u8 multiplayerId; - /* 0xccf */ u8 unk_ccf; - /* 0xcd0 */ vu8 unk_cd0; + /* 0xccf */ u8 connectParentFailures; + /* 0xcd0 */ vu8 childSendCount; /* 0xcd1 */ u8 partnerSendStatuses[RFU_CHILD_MAX]; /* 0xcd5 */ u8 partnerRecvStatuses[RFU_CHILD_MAX]; - /* 0xcd9 */ u8 unk_cd9; + /* 0xcd9 */ bool8 stopNewConnections; /* 0xcda */ u8 unk_cda; /* 0xcdb */ vbool8 unk_cdb; /* 0xcdc */ vbool8 unk_cdc; /* 0xcdd */ u8 unk_cdd; /* 0xcde */ u8 linkPlayerIdx[RFU_CHILD_MAX]; /* 0xce2 */ u8 unk_ce2; - /* 0xce2 */ u8 unk_ce3; - /* 0xce4 */ u8 unk_ce4; + /* 0xce2 */ u8 disconnectSlots; + /* 0xce4 */ u8 disconnectMode; /* 0xce5 */ u8 unk_ce5; /* 0xce5 */ u8 unk_ce6; /* 0xce7 */ u8 acceptSlot_flag; - /* 0xce8 */ u8 unk_ce8; + /* 0xce8 */ bool8 unk_ce8; /* 0xce9 */ u8 unk_ce9; /* 0xcea */ u8 unk_cea[4]; /* 0xcee */ u8 unk_cee[4]; }; // size = 0xcf4 -// Exported RAM declarations - extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; extern struct GFRfuManager Rfu; extern u8 gWirelessStatusIndicatorSpriteId; -// Exported ROM declarations void WipeTrainerNameRecords(void); void InitRFUAPI(void); void LinkRfu_Shutdown(void); @@ -219,13 +239,13 @@ bool32 RfuHasErrored(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); void RfuVSync(void); -void sub_80111B0(bool32 a0); +void RfuSetIgnoreError(bool32 enable); u8 RfuGetStatus(void); struct GFtgtGname *GetHostRFUtgtGname(void); -void UpdateGameData_GroupLockedIn(u8 a0); -void GetLinkmanErrorParams(u32 a0); -void RfuSetStatus(u8 a0, u16 a1); -u8 sub_801048C(bool32 a0); +void UpdateGameData_GroupLockedIn(u8 started); +void GetLinkmanErrorParams(u32 msg); +void RfuSetStatus(u8 status, u16 msg); +u8 Rfu_SetLinkRecovery(bool32 enable); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2); void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started); void InitializeRfuLinkManager_LinkLeader(u32 a0); @@ -235,10 +255,10 @@ bool32 RfuTryDisconnectLeavingChildren(void); bool32 HasTrainerLeftPartnersList(u16 trainerId, const u8 *name); void SendRfuStatusToPartner(u8 status, u16 trainerId, const u8 *name); u32 WaitSendRfuStatusToPartner(u16 trainerId, const u8 *name); -void RequestDisconnectSlotByTrainerNameAndId(const u8 *a0, u16 a1); +void RequestDisconnectSlotByTrainerNameAndId(const u8 *name, u16 id); bool8 LmanAcceptSlotFlagIsNotZero(void); -bool32 WaitRfuState(bool32 a0); -void sub_801103C(void); +bool32 WaitRfuState(bool32 force); +void GetOtherPlayersInfoFlags(void); void InitializeRfuLinkManager_JoinGroup(void); void SendLeaveGroupNotice(void); void RecordMixTrainerNames(void); @@ -246,7 +266,7 @@ void LinkRfu_CreateConnectionAsParent(void); void LinkRfu_StopManagerBeforeEnteringChat(void); void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 started); void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); -void SetGnameBufferWonderFlags(bool32 a0, bool32 a1); +void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level); void InitializeRfuLinkManager_EnterUnionRoom(void); @@ -254,8 +274,8 @@ void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 IsUnionRoomListenTaskActive(void); void Rfu_SendPacket(void *data); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); -void sub_8011DE0(u32 arg0); -u8 sub_801100C(s32 a0); +void Rfu_DisconnectPlayerById(u32 playerIdx); +u8 GetLinkPlayerInfoFlags(s32 playerId); void sub_800EF7C(void); bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx); bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx); @@ -265,9 +285,9 @@ void DestroyTask_RfuIdle(void); void ClearRecvCommands(void); void LinkRfu_FatalError(void); bool32 sub_8011A9C(void); -void sub_80104B0(void); -void sub_8011A50(void); -void sub_80110B8(u32 a0); +void Rfu_StopPartnerSearch(void); +void RfuSetNormalDisconnectMode(void); +void SetUnionRoomChatPlayerData(u32 numPlayers); bool32 IsRfuSerialNumberValid(u32 serialNo); bool8 IsRfuRecoveringFromLinkLoss(void); void RfuRecvQueue_Reset(struct RfuRecvQueue *queue); -- cgit v1.2.3 From 6aaf50ee27c175c8e54c7299fdc86d90b0b29187 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 5 Oct 2021 23:38:36 -0400 Subject: Rename GF Gname, Rfu, finish bulk of Union Room, more link doc --- include/link_rfu.h | 97 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 40 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 04f1b7f9a..eb071618e 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -20,10 +20,10 @@ #define RFUCMD_DISCONNECT 0xED00 #define RFUCMD_DISCONNECT_PARENT 0xEE00 -#define RFU_SERIAL_A 0x0002 -#define RFU_SERIAL_B 0x7F7D -#define RFU_SERIAL_C 0x0000 -#define RFU_SERIAL_END 0xFFFF +#define RFU_SERIAL_GAME 0x0002 // Serial number for Pokémon game (FRLG or Emerald) +#define RFU_SERIAL_WONDER_DISTRIBUTOR 0x7F7D // Serial number for distributing Wonder Cards / News +#define RFU_SERIAL_UNKNOWN 0x0000 // Unreferenced acceptable serial number. Gamecube? +#define RFU_SERIAL_END 0xFFFF #define RECV_QUEUE_NUM_SLOTS 32 #define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS) @@ -68,8 +68,7 @@ enum { RFU_ERROR_STATE_IGNORE, }; -// RfuTgtData.gname is read as these structs. -struct GFtgtGnameSub +struct RfuGameCompatibilityData { u16 language:4; u16 hasNews:1; @@ -79,24 +78,41 @@ struct GFtgtGnameSub u16 hasNationalDex:1; u16 gameClear:1; u16 version:4; + u16 unused:2; u8 playerTrainerId[2]; }; -struct __attribute__((packed, aligned(2))) GFtgtGname +// This struct is sent via the Wireless Adapter as the game name or "gname" data. +// Gname is only applicable during Wireless Single Game Pak Multiplay, when the +// adapter needs this data for connection. Per the RFU manual, during "normal" +// wireless play (the kind the Pokémon games use) the gname data can be used for +// anything the developers want. This struct is what GF decided to use it for. +// It can be up to 13 bytes in size (RFU_GAME_NAME_LENGTH). +// The player's name is sent separately as the username ("uname"), and does not +// use a struct (gHostRfuUsername). +struct __attribute__((packed, aligned(2))) RfuGameData { - 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 - u16 species:10; - u16 type:6; + struct RfuGameCompatibilityData compatibility; + u8 partnerInfo[RFU_CHILD_MAX]; + u16 tradeSpecies:10; + u16 tradeType:6; u8 activity:7; - u8 started:1; + u8 startedActivity:1; u8 playerGender:1; - u8 level:7; + u8 tradeLevel:7; u8 padding; -}; // size: RFU_GNAME_SIZE +}; + +// Constants for getting/setting information in 'partnerInfo' of RfuGameData. +// This data is used to determine what the link partners look like from +// the host's perspective. +// Bits 0-2 are a shortened trainerId +// Bit 3 is the player's gender +// Bits 4-6 are unknown/unused +// Bit 7 is an 'active' flag +#define PINFO_TID_MASK 0x7 +#define PINFO_GENDER_SHIFT 3 +#define PINFO_ACTIVE_FLAG (1 << 7) struct RfuBlockSend { @@ -136,7 +152,8 @@ struct RfuBackupQueue /* 0x1e */ vu8 count; }; -struct GFRfuManager +// Stores data needed for the RFU on GF's end +struct RfuManager { /* 0x000 */ void (*callback)(void); /* 0x004 */ u16 state; @@ -151,7 +168,7 @@ struct GFRfuManager /* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH]; /* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH]; /* 0x05a */ u8 blockRequestType; - /* 0x05b */ u8 unk_5b; + /* 0x05b */ u8 blockSendAttempts; /* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS]; /* 0x061 */ bool8 numBlocksReceived[MAX_RFU_PLAYERS]; /* 0x066 */ u8 idleTaskId; @@ -170,9 +187,9 @@ struct GFRfuManager /* 0x100 */ u16 allReadyNum; /* 0x102 */ u8 unk_102; /* 0x103 */ u8 filler_103[7]; - /* 0x10A */ struct GFtgtGname unk_10A; + /* 0x10A */ struct RfuGameData parent; u8 filler_; - u8 playerName[PLAYER_NAME_LENGTH + 1]; + u8 parentName[RFU_USER_NAME_LENGTH]; /* 0x124 */ struct RfuRecvQueue recvQueue; /* 0x9e8 */ struct RfuSendQueue sendQueue; /* 0xc1c */ struct RfuBackupQueue backupQueue; @@ -180,7 +197,7 @@ struct GFRfuManager /* 0xc3d */ u8 unk_c3d; /* 0xc3e */ vu8 childSlot; /* 0xc3f */ u8 unk_c3f[70]; - /* 0xc85 */ u8 unk_c85; + /* 0xc85 */ u8 leaveGroupStatus; /* 0xc86 */ u8 recvStatus; /* 0xc87 */ u8 recvCmds[5][7][2]; /* 0xccd */ u8 parentId; @@ -198,18 +215,18 @@ struct GFRfuManager /* 0xce2 */ u8 unk_ce2; /* 0xce2 */ u8 disconnectSlots; /* 0xce4 */ u8 disconnectMode; - /* 0xce5 */ u8 unk_ce5; - /* 0xce5 */ u8 unk_ce6; + /* 0xce5 */ u8 nextChildBits; + /* 0xce5 */ u8 newChildQueue; /* 0xce7 */ u8 acceptSlot_flag; /* 0xce8 */ bool8 unk_ce8; - /* 0xce9 */ u8 unk_ce9; + /* 0xce9 */ u8 incomingChild; /* 0xcea */ u8 unk_cea[4]; /* 0xcee */ u8 unk_cee[4]; }; // size = 0xcf4 -extern struct GFtgtGname gHostRFUtgtGnameBuffer; -extern u8 gHostRFUtgtUnameBuffer[]; -extern struct GFRfuManager Rfu; +extern struct RfuGameData gHostRfuGameData; +extern u8 gHostRfuUsername[]; +extern struct RfuManager gRfu; extern u8 gWirelessStatusIndicatorSpriteId; void WipeTrainerNameRecords(void); @@ -241,13 +258,13 @@ u32 GetRfuRecvQueueLength(void); void RfuVSync(void); void RfuSetIgnoreError(bool32 enable); u8 RfuGetStatus(void); -struct GFtgtGname *GetHostRFUtgtGname(void); -void UpdateGameData_GroupLockedIn(u8 started); +struct RfuGameData *GetHostRfuGameData(void); +void UpdateGameData_GroupLockedIn(u8 startedActivity); void GetLinkmanErrorParams(u32 msg); void RfuSetStatus(u8 status, u16 msg); u8 Rfu_SetLinkRecovery(bool32 enable); -void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2); -void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started); +void CopyHostRfuGameDataAndUsername(struct RfuGameData *buff1, u8 *buff2); +void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity); void InitializeRfuLinkManager_LinkLeader(u32 a0); bool32 IsRfuCommunicatingWithAllChildren(void); void LinkRfu_StopManagerAndFinalizeSlots(void); @@ -264,22 +281,22 @@ void SendLeaveGroupNotice(void); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(void); void LinkRfu_StopManagerBeforeEnteringChat(void); -void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 started); +void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 startedActivity); void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); -void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); -void ClearAndInitHostRFUtgtGname(void); +void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard); +void ResetHostRfuGameData(void); void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level); void InitializeRfuLinkManager_EnterUnionRoom(void); -void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2); +void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *structPtr, u8 a2); bool32 IsUnionRoomListenTaskActive(void); void Rfu_SendPacket(void *data); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); void Rfu_DisconnectPlayerById(u32 playerIdx); u8 GetLinkPlayerInfoFlags(s32 playerId); void sub_800EF7C(void); -bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx); -bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx); -s32 sub_800E87C(u8 idx); +bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *player, u8 *username, u8 idx); +bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *player, u8 *username, u8 idx); +s32 Rfu_GetIndexOfNewestChild(u8 bits); void CreateTask_RfuIdle(void); void DestroyTask_RfuIdle(void); void ClearRecvCommands(void); @@ -298,7 +315,7 @@ 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); -void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders); +void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo); void CreateWirelessStatusIndicatorSprite(u8 x, u8 y); void DestroyWirelessStatusIndicatorSprite(void); void LoadWirelessStatusIndicatorSpriteGfx(void); -- cgit v1.2.3 From 846942ce48d650efd3d837493157ce462e568d78 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 7 Oct 2021 14:55:15 -0400 Subject: Finish remaining symbols in link_rfu_2 --- include/link_rfu.h | 65 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 25 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index eb071618e..6ca06349a 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -68,6 +68,21 @@ enum { RFU_ERROR_STATE_IGNORE, }; +// These error flags are set in errorInfo, and given as +// the uppermost 16 bits of 'status' for sLinkErrorBuffer. +// The first 8 bits are reserved for the link manager msg +// when the error occurred, and the last 8 bits are this +// sequence of presumably meaningful error flags, but +// ultimately sLinkErrorBuffer's status is never read. +#define F_RFU_ERROR_1 (1 << 8) +#define F_RFU_ERROR_2 (1 << 9) // Never set +#define F_RFU_ERROR_3 (1 << 10) // Never set +#define F_RFU_ERROR_4 (1 << 11) // Never set +#define F_RFU_ERROR_5 (1 << 12) +#define F_RFU_ERROR_6 (1 << 13) +#define F_RFU_ERROR_7 (1 << 14) +#define F_RFU_ERROR_8 (1 << 15) + struct RfuGameCompatibilityData { u16 language:4; @@ -157,14 +172,14 @@ struct RfuManager { /* 0x000 */ void (*callback)(void); /* 0x004 */ u16 state; - /* 0x006 */ u8 filler_06[4]; - /* 0x00a */ u16 linkmanMsg; + /* 0x006 */ u8 unused1[4]; + /* 0x00a */ u16 errorInfo; /* 0x00c */ u8 parentChild; /* 0x00d */ u8 playerCount; - /* 0x00e */ bool8 unk_0e; - /* 0x00f */ u8 unk_0f; - /* 0x010 */ u16 unk_10; - /* 0x012 */ u16 unk_12; + /* 0x00e */ bool8 runParentMain2; + /* 0x00f */ u8 unused2; + /* 0x010 */ u16 errorParam0; + /* 0x012 */ u16 errorParam1; /* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH]; /* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH]; /* 0x05a */ u8 blockRequestType; @@ -173,7 +188,7 @@ struct RfuManager /* 0x061 */ bool8 numBlocksReceived[MAX_RFU_PLAYERS]; /* 0x066 */ u8 idleTaskId; /* 0x067 */ u8 searchTaskId; - /* 0x068 */ u8 filler_68[4]; + /* 0x068 */ u8 unused3[4]; /* 0x06c */ struct RfuBlockSend sendBlock; /* 0x080 */ struct RfuBlockSend recvBlock[MAX_RFU_PLAYERS]; /* 0x0e4 */ bool8 readyCloseLink[MAX_RFU_PLAYERS]; @@ -185,8 +200,8 @@ struct RfuManager /* 0x0f2 */ u16 packet[RFU_PACKET_SIZE]; /* 0x0fe */ u16 resendExitStandbyTimer; /* 0x100 */ u16 allReadyNum; - /* 0x102 */ u8 unk_102; - /* 0x103 */ u8 filler_103[7]; + /* 0x102 */ u8 childSendCmdId; + /* 0x103 */ u8 unused4[7]; /* 0x10A */ struct RfuGameData parent; u8 filler_; u8 parentName[RFU_USER_NAME_LENGTH]; @@ -194,12 +209,12 @@ struct RfuManager /* 0x9e8 */ struct RfuSendQueue sendQueue; /* 0xc1c */ struct RfuBackupQueue backupQueue; /* 0xc3c */ vu8 linkRecovered; - /* 0xc3d */ u8 unk_c3d; + /* 0xc3d */ u8 reconnectParentId; /* 0xc3e */ vu8 childSlot; - /* 0xc3f */ u8 unk_c3f[70]; + /* 0xc3f */ u8 childRecvQueue[RECV_QUEUE_SLOT_LENGTH]; /* 0xc85 */ u8 leaveGroupStatus; - /* 0xc86 */ u8 recvStatus; - /* 0xc87 */ u8 recvCmds[5][7][2]; + /* 0xc86 */ u8 childRecvStatus; + /* 0xc87 */ u8 recvCmds[MAX_RFU_PLAYERS][CMD_LENGTH - 1][2]; /* 0xccd */ u8 parentId; /* 0xcce */ u8 multiplayerId; /* 0xccf */ u8 connectParentFailures; @@ -207,21 +222,21 @@ struct RfuManager /* 0xcd1 */ u8 partnerSendStatuses[RFU_CHILD_MAX]; /* 0xcd5 */ u8 partnerRecvStatuses[RFU_CHILD_MAX]; /* 0xcd9 */ bool8 stopNewConnections; - /* 0xcda */ u8 unk_cda; - /* 0xcdb */ vbool8 unk_cdb; - /* 0xcdc */ vbool8 unk_cdc; - /* 0xcdd */ u8 unk_cdd; + /* 0xcda */ u8 parentSendSlot; + /* 0xcdb */ vbool8 parentFinished; + /* 0xcdc */ vbool8 parentMain2Failed; + /* 0xcdd */ u8 unused5; /* 0xcde */ u8 linkPlayerIdx[RFU_CHILD_MAX]; - /* 0xce2 */ u8 unk_ce2; + /* 0xce2 */ u8 parentSlots; /* 0xce2 */ u8 disconnectSlots; /* 0xce4 */ u8 disconnectMode; /* 0xce5 */ u8 nextChildBits; /* 0xce5 */ u8 newChildQueue; /* 0xce7 */ u8 acceptSlot_flag; - /* 0xce8 */ bool8 unk_ce8; + /* 0xce8 */ bool8 playerExchangeActive; /* 0xce9 */ u8 incomingChild; - /* 0xcea */ u8 unk_cea[4]; - /* 0xcee */ u8 unk_cee[4]; + /* 0xcea */ u8 numChildRecvErrors[RFU_CHILD_MAX]; + /* 0xcee */ u8 childRecvIds[RFU_CHILD_MAX]; }; // size = 0xcf4 extern struct RfuGameData gHostRfuGameData; @@ -260,8 +275,8 @@ void RfuSetIgnoreError(bool32 enable); u8 RfuGetStatus(void); struct RfuGameData *GetHostRfuGameData(void); void UpdateGameData_GroupLockedIn(u8 startedActivity); -void GetLinkmanErrorParams(u32 msg); -void RfuSetStatus(u8 status, u16 msg); +void RfuSetErrorParams(u32 errorInfo); +void RfuSetStatus(u8 status, u16 errorInfo); u8 Rfu_SetLinkRecovery(bool32 enable); void CopyHostRfuGameDataAndUsername(struct RfuGameData *buff1, u8 *buff2); void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity); @@ -293,7 +308,7 @@ void Rfu_SendPacket(void *data); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); void Rfu_DisconnectPlayerById(u32 playerIdx); u8 GetLinkPlayerInfoFlags(s32 playerId); -void sub_800EF7C(void); +void StopUnionRoomLinkManager(void); bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *player, u8 *username, u8 idx); bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *player, u8 *username, u8 idx); s32 Rfu_GetIndexOfNewestChild(u8 bits); @@ -301,7 +316,7 @@ void CreateTask_RfuIdle(void); void DestroyTask_RfuIdle(void); void ClearRecvCommands(void); void LinkRfu_FatalError(void); -bool32 sub_8011A9C(void); +bool32 Rfu_IsPlayerExchangeActive(void); void Rfu_StopPartnerSearch(void); void RfuSetNormalDisconnectMode(void); void SetUnionRoomChatPlayerData(u32 numPlayers); -- cgit v1.2.3 From e86d3410a1719fcbf62754bfda93a295aa7e0d57 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 7 Oct 2021 15:32:51 -0400 Subject: Update argument names in link headers, link_rfu doc cleanup --- include/link_rfu.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 6ca06349a..df2b80c4f 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -62,9 +62,9 @@ enum { // Values for errorState enum { RFU_ERROR_STATE_NONE, - RFU_ERROR_STATE_1, - RFU_ERROR_STATE_2, - RFU_ERROR_STATE_3, + RFU_ERROR_STATE_OCCURRED, + RFU_ERROR_STATE_PROCESSED, + RFU_ERROR_STATE_DISCONNECTING, RFU_ERROR_STATE_IGNORE, }; @@ -247,8 +247,8 @@ extern u8 gWirelessStatusIndicatorSpriteId; void WipeTrainerNameRecords(void); void InitRFUAPI(void); void LinkRfu_Shutdown(void); -void Rfu_SetBlockReceivedFlag(u8 who); -void Rfu_ResetBlockReceivedFlag(u8 who); +void Rfu_SetBlockReceivedFlag(u8 linkPlayerId); +void Rfu_ResetBlockReceivedFlag(u8 linkPlayerId); bool32 IsSendingKeysToRfu(void); void StartSendingKeysToRfu(void); void Rfu_SetBerryBlenderLinkCallback(void); @@ -278,9 +278,9 @@ void UpdateGameData_GroupLockedIn(u8 startedActivity); void RfuSetErrorParams(u32 errorInfo); void RfuSetStatus(u8 status, u16 errorInfo); u8 Rfu_SetLinkRecovery(bool32 enable); -void CopyHostRfuGameDataAndUsername(struct RfuGameData *buff1, u8 *buff2); +void CopyHostRfuGameDataAndUsername(struct RfuGameData *gameData, u8 *username); void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity); -void InitializeRfuLinkManager_LinkLeader(u32 a0); +void InitializeRfuLinkManager_LinkLeader(u32 groupMax); bool32 IsRfuCommunicatingWithAllChildren(void); void LinkRfu_StopManagerAndFinalizeSlots(void); bool32 RfuTryDisconnectLeavingChildren(void); @@ -296,21 +296,21 @@ void SendLeaveGroupNotice(void); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(void); void LinkRfu_StopManagerBeforeEnteringChat(void); -void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 startedActivity); -void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); +void UpdateGameData_SetActivity(u8 activity, u32 partnerInfo, bool32 startedActivity); +void CreateTask_RfuReconnectWithParent(const u8 *name, u16 trainerId); void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard); void ResetHostRfuGameData(void); void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level); void InitializeRfuLinkManager_EnterUnionRoom(void); -void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *structPtr, u8 a2); +void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *parent, u8 activity); bool32 IsUnionRoomListenTaskActive(void); void Rfu_SendPacket(void *data); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); void Rfu_DisconnectPlayerById(u32 playerIdx); u8 GetLinkPlayerInfoFlags(s32 playerId); void StopUnionRoomLinkManager(void); -bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *player, u8 *username, u8 idx); -bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *player, u8 *username, u8 idx); +bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *gameData, u8 *username, u8 idx); +bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *gameData, u8 *username, u8 idx); s32 Rfu_GetIndexOfNewestChild(u8 bits); void CreateTask_RfuIdle(void); void DestroyTask_RfuIdle(void); @@ -328,8 +328,8 @@ 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); +void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *data); +bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *src); void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo); void CreateWirelessStatusIndicatorSprite(u8 x, u8 y); void DestroyWirelessStatusIndicatorSprite(void); -- cgit v1.2.3 From 7c5c41f23c0159667675d98dc1360f92097b34f9 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 7 Oct 2021 16:19:02 -0400 Subject: Combine link slot length constants --- include/link_rfu.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index df2b80c4f..ae123c223 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -25,14 +25,10 @@ #define RFU_SERIAL_UNKNOWN 0x0000 // Unreferenced acceptable serial number. Gamecube? #define RFU_SERIAL_END 0xFFFF +#define COMM_SLOT_LENGTH 14 #define RECV_QUEUE_NUM_SLOTS 32 -#define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS) - #define SEND_QUEUE_NUM_SLOTS 40 -#define SEND_QUEUE_SLOT_LENGTH 14 - #define BACKUP_QUEUE_NUM_SLOTS 2 -#define BACKUP_QUEUE_SLOT_LENGTH 14 #define RFU_PACKET_SIZE 6 @@ -50,8 +46,6 @@ #define RFU_STATUS_CHILD_LEAVE 11 #define RFU_STATUS_ACK_JOIN_GROUP 12 -#define CHILD_DATA_LENGTH 14 - // Values for disconnectMode enum { RFU_DISCONNECT_NONE, @@ -143,7 +137,7 @@ struct RfuBlockSend struct RfuRecvQueue { - /* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][RECV_QUEUE_SLOT_LENGTH]; + /* 0x000 */ u8 slots[RECV_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH * MAX_RFU_PLAYERS]; /* 0x8c0 */ vu8 recvSlot; /* 0x8c1 */ vu8 sendSlot; /* 0x8c2 */ vu8 count; @@ -152,7 +146,7 @@ struct RfuRecvQueue struct RfuSendQueue { - /* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][SEND_QUEUE_SLOT_LENGTH]; + /* 0x000 */ u8 slots[SEND_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH]; /* 0x230 */ vu8 recvSlot; /* 0x231 */ vu8 sendSlot; /* 0x232 */ vu8 count; @@ -161,7 +155,7 @@ struct RfuSendQueue struct RfuBackupQueue { - /* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][BACKUP_QUEUE_SLOT_LENGTH]; + /* 0x00 */ u8 slots[BACKUP_QUEUE_NUM_SLOTS][COMM_SLOT_LENGTH]; /* 0x1c */ vu8 recvSlot; /* 0x1d */ vu8 sendSlot; /* 0x1e */ vu8 count; @@ -180,8 +174,8 @@ struct RfuManager /* 0x00f */ u8 unused2; /* 0x010 */ u16 errorParam0; /* 0x012 */ u16 errorParam1; - /* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH]; - /* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH]; + /* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][COMM_SLOT_LENGTH]; + /* 0x04c */ u8 childSendBuffer[COMM_SLOT_LENGTH]; /* 0x05a */ u8 blockRequestType; /* 0x05b */ u8 blockSendAttempts; /* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS]; @@ -211,7 +205,7 @@ struct RfuManager /* 0xc3c */ vu8 linkRecovered; /* 0xc3d */ u8 reconnectParentId; /* 0xc3e */ vu8 childSlot; - /* 0xc3f */ u8 childRecvQueue[RECV_QUEUE_SLOT_LENGTH]; + /* 0xc3f */ u8 childRecvQueue[COMM_SLOT_LENGTH * MAX_RFU_PLAYERS]; /* 0xc85 */ u8 leaveGroupStatus; /* 0xc86 */ u8 childRecvStatus; /* 0xc87 */ u8 recvCmds[MAX_RFU_PLAYERS][CMD_LENGTH - 1][2]; -- cgit v1.2.3 From 3a7995bc7ce8fda6a763ab14f96a2011f735def6 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 11 Oct 2021 10:39:37 -0400 Subject: Fix misleading RecordMixTrainerNames name --- include/link_rfu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index ae123c223..dfbc71657 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -287,7 +287,7 @@ bool32 WaitRfuState(bool32 force); void GetOtherPlayersInfoFlags(void); void InitializeRfuLinkManager_JoinGroup(void); void SendLeaveGroupNotice(void); -void RecordMixTrainerNames(void); +void SaveLinkTrainerNames(void); void LinkRfu_CreateConnectionAsParent(void); void LinkRfu_StopManagerBeforeEnteringChat(void); void UpdateGameData_SetActivity(u8 activity, u32 partnerInfo, bool32 startedActivity); -- cgit v1.2.3