From 1cc9d0eea9a8ca4ff03ff30c2eadacb35557e1d3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 29 Jan 2020 12:39:54 -0500 Subject: Document link_rfu.c as official SDK linkManager.c --- include/link_rfu.h | 239 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 172 insertions(+), 67 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 81dd7fdf0..f90de0daf 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -4,6 +4,101 @@ #include "global.h" #include "librfu.h" +//----------------------------------------------------------------- +// Constant definition +//----------------------------------------------------------------- + +// Link Manager operation mode (specified by u8 parent_child argument of rfu_LMAN_establishConnection) +//#define MODE_CHILD 0 // Start Link Manager in CHILD mode +//#define MODE_PARENT 1 // Start Link Manager in PARENT mode +//Note: This value uses the item defined by AgbRFU_LL.h. +#define MODE_P_C_SWITCH 2 // Start Link Manager in parent-child switching mode. + + +// Error code returned by Link Manager API (rfu_LMAN_...return value of function) +#define LMAN_ERROR_MANAGER_BUSY 1 // Link Manager is already running. +#define LMAN_ERROR_AGB_CLK_SLAVE 2 // AGB is clock slave so link manager cannot run. +#define LMAN_ERROR_PID_NOT_FOUND 3 // Parent device information of the specified PID does not exist in rfuLinkStatus->partner[0-3]. +#define LMAN_ERROR_ILLEGAL_PARAMETER 4 // Specified argument is unusual. +#define LMAN_ERROR_NOW_LINK_RECOVERY 5 // New settings were ignored because link recovery was under way when current link recovery was ON and new settings turned link recovery OFF. +#define LMAN_ERROR_NOW_COMMUNICATION 6 // New settings were ignored because currently communicating with NI. +#define LMAN_ERROR_NOW_SEARCH_PARENT 7 // Parent search currently under way, so ignore new setting. + +// Details of messages and the related parameters returned by the u8 msg, u8 param_count, and lman.param[0-1] arguments of the LMAN callback generated by the operation of the Link Manager. +// msg name msg No. param qty param[0] param[1] Description +#define LMAN_MSG_INITIALIZE_COMPLETED 0x00 // 0 - - Generated when RFU reset and initial settings are completed +#define LMAN_MSG_NEW_CHILD_CONNECT_DETECTED 0x10 // 1 Bit indicating slot - Generated when new child device connection was detected at RFU level. +// with detected connection +#define LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED 0x11 // 1 Bit indicating slot - Generated when game identification information from child device connected at RFU level is received and accepted (game serial numbers match). +// where connection was accepted +#define LMAN_MSG_NEW_CHILD_CONNECT_REJECTED 0x12 // 1 Bit indicating slot - Generated when the connection from the child device connected at RFU level is rejected (game identification information reception failed or game serial numbers do not match). +// where connection was rejected +#define LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED 0x13 // 0 - - Generated when SearchChild operation time expires. +#define LMAN_MSG_END_WAIT_CHILD_NAME 0x14 // 0 - - Generated when reception of game identification information from all child devices completes after the SearchChild operation time expires. +#define LMAN_MSG_PARENT_FOUND 0x20 // 1 Bit indicating - Generated when valid (game serial numbers match) parent devices are found during SearchParent. +// rfuLinkStatus->partner[x] index number storing the valid parent devices (game serial number matches) from among the discovered parent devices. +#define LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED 0x21 // 0 - - Generated when SearchParent time expires. +#define LMAN_MSG_CONNECT_PARENT_SUCCESSED 0x22 // 1 Connected slot number - Generated when connection with parent device at RFU level succeeds. +#define LMAN_MSG_CONNECT_PARENT_FAILED 0x23 // 1 Connection failure reason - Generated when connection with parent device at RFU level fails. +#define LMAN_MSG_CHILD_NAME_SEND_COMPLETED 0x24 // 0 - - Generated when transmission of the child's game identification information to the parent device succeeds after connection with parent device at RFU level succeeds. +#define LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED 0x25 // 0 - - Generated when transmission of the child's game identification information to the parent device fails after connection with parent device at RFU level succeeds. +#define LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED 0x30 // 1 Bit indicating slot - Generated when a link cut is detected and that slot disconnects. (Generated only when link recovery is OFF.) +// that was disconnected and where link cut was detected but link recover not attempted +#define LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY 0x31 // 1 Bit indicating slot - Generated when a link cut is detected and the link recovery process starts. (Generated only when link recovery is ON.) +// where link cut was detected and link recovery was started +#define LMAN_MSG_LINK_RECOVERY_SUCCESSED 0x32 // 1 Bit indicating slot - Generated when link recovery succeeds. (Generated only when link recovery is ON.) +// where link recovery succeeded +#define LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED 0x33 // 1 Bit indicating slot - Generated when link recovery fails and that slot disconnects. (Generated only when link recovery is ON.) +// where link recovery failed and that disconnected +#define LMAN_MSG_LINK_DISCONNECTED_BY_USER 0x40 // 1 Generated on disconnection by execution of rfu_REQ_disconnect by disconnected user. +// Slot indicated in bits *Note: If rfu_REQ_disconnect is used for disconnection during link recovery in the child device, the link recovery is also suspended, but the only message returned is DISCONNECTED_BY_USER. +#define LMAN_MSG_CHANGE_AGB_CLOCK_SLAVE 0x41 // 0 - - Generated when the AGB-RFU clock switches to AGB clock slave after a successful connection or link recovery in the child device. (This message is not generated when the AGB switches to a clock slave when an MSC callback completes.) +#define LMAN_MSG_CHANGE_AGB_CLOCK_MASTER 0x45 // 0 - - Generated when the AGB-RFU intercommunication clock is switched to the AGB clock master in the child device. +#define LMAN_MSG_RFU_POWER_DOWN 0x42 // 0 - - Generated when the RFU enters power conservation mode with rfu_LMAN_powerDownRFU. +#define LMAN_MSG_MANAGER_STOPPED 0x43 // 0 - - Generated when the Link Manager is halted by rfu_LMAN_stopLMAN(0). (This message is not generated during SearchChild, SearchParent, ConnectParent, and LinkRecovery. A message (-PERIOD_EXPIRED, -SUCCESSED, -FAILED) corresponding to the operation completion is returned.) +#define LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET 0x44 // 0 - - Generates when the Link Manager is forcibly halted by rfu_LMAN_stopLMAN(1) and RFU is reset. + +#define LMAN_MSG_RECV_DATA_REQ_COMPLETED 0x50 // 0 - - Generated when the execution of rfu_REQ_recvData completes. (This message is not notification of data reception from a RFU.) + +#define LMAN_MSG_REQ_API_ERROR 0xf0 // 2 REQ_commandID REQ_result REQ-API resulted in error. This message is also generated by an REQ-API executed by either the link manager or the user. +#define LMAN_MSG_WATCH_DOG_TIMER_ERROR 0xf1 // 0 - - Generated when a MSC callback does not occur even after 6 seconds pass when the AGB is the clock slave. +#define LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA 0xf2 // 0 - - Generated when an automatic starting DMA, such as HDMA, is issued at the same time the RFU attempts to send notification and to return the AGB to the clock master while the AGB is the clock slave and the exchange of that information (REQ command) fails. +#define LMAN_MSG_LMAN_API_ERROR_RETURN 0xf3 // 1 Return error code - Generated when LMAN-API execution returns an error. +#define LMAN_MSG_RFU_FATAL_ERROR 0xff // 0 - - Generated when the Link Manager cannot recongize a RFU because of the execution of rfu_REQBN_softReset_and_checkID. + + +// Value of lman.childClockSlave_flag +#define RFU_CHILD_CLOCK_SLAVE_OFF 0 // The child device is not operating in AGB clock slave mode. (The child device is in this mode in cases such as when the child has not established a connection or during link recovery.) +#define RFU_CHILD_CLOCK_SLAVE_ON 1 // The child device is operating in AGB clock slave mode. (Child automatically enters this mode when a connection is established.) +#define RFU_CHILD_CLOCK_SLAVE_OFF_REQ 2 // The child device has requested that AGB clock slave mode be halted. + +// State of Link Manager (values of lman.state, lman.next_state) +#define LMAN_STATE_READY 0x00 // Waiting +#define LMAN_STATE_SOFT_RESET_AND_CHECK_ID 0x01 // Requesting execution of rfu_REQBN_softResetAndCheckID (same as below) +#define LMAN_STATE_RESET 0x02 // rfu_REQ_reset +#define LMAN_STATE_CONFIG_SYSTEM 0x03 // rfu_REQ_configSystem +#define LMAN_STATE_CONFIG_GAME_DATA 0x04 // rfu_REQ_configGameData +#define LMAN_STATE_START_SEARCH_CHILD 0x05 // rfu_REQ_startSearchChild +#define LMAN_STATE_POLL_SEARCH_CHILD 0x06 // rfu_REQ_pollSearchChild +#define LMAN_STATE_END_SEARCH_CHILD 0x07 // rfu_REQ_endSearchChild +#define LMAN_STATE_WAIT_RECV_CHILD_NAME 0x08 // Awaiting reception of game name from connected child device. +#define LMAN_STATE_START_SEARCH_PARENT 0x09 // rfu_REQ_startSearchParent +#define LMAN_STATE_POLL_SEARCH_PARENT 0x0a // rfu_REQ_pollSearchParent +#define LMAN_STATE_END_SEARCH_PARENT 0x0b // rfu_REQ_endSearchParent +#define LMAN_STATE_START_CONNECT_PARENT 0x0c // rfu_REQ_startConnectParent +#define LMAN_STATE_POLL_CONNECT_PARENT 0x0d // rfu_REQ_pollConnectParent +#define LMAN_STATE_END_CONNECT_PARENT 0x0e // rfu_REQ_endConnectParent +#define LMAN_STATE_SEND_CHILD_NAME 0x0f // Sending child game name. +#define LMAN_STATE_START_LINK_RECOVERY 0x10 // rfu_REQ_CHILD_startConnectRecovery +#define LMAN_STATE_POLL_LINK_RECOVERY 0x11 // rfu_REQ_CHILD_pollConnectRecovery +#define LMAN_STATE_END_LINK_RECOVERY 0x12 // rfu_REQ_CHILD_endConnectRecovery +#define LMAN_STATE_MS_CHANGE 0x13 // rfu_REQ_changeMasterSlave +#define LMAN_STATE_WAIT_CLOCK_MASTER 0x14 // Waiting for AGB-RFU intercommunication clock to become AGB clock master. +#define LMAN_STATE_STOP_MODE 0x15 // rfu_REQ_stopMode +#define LMAN_STATE_BACK_STATE 0x16 // Following the completion of link-recovery processing, return the Link Manager state to the state present before link-recovery processing was initiated. +#define LMAN_FORCED_STOP_AND_RFU_RESET 0x17 // Attempt to forcibly stop Link Manager using rfu_LMAN_stopLMAN(1). +#define LMAN_STATE_WAIT_CHANGE_CLOCK_MASTER 0x18 // Attempt to return to AGB clock master after child fails in sending game name. + // RfuTgtData.gname is read as these structs. struct GFtgtGnameSub { @@ -37,20 +132,37 @@ struct Padded_U8 u8 value; }; -struct UnkLinkRfuStruct_02022B2C -{ - u8 maxMFrame; - u8 mcTimer; - u16 availSlotFlag; - u8 mbootFlag; - u16 serialNo; - struct GFtgtGname *gname; - u8 *uname; - u8 unk_10; - u8 unk_11; - u16 unk_12; - u16 unk_14; -}; +// Parameter group used in initial setting run of the link manager (rfu_LMAN_initializeRFU) +typedef struct InitializeParametersTag { + // rfu_REQ_configSystem argument + u8 maxMFrame; // Maximum number of times to re-transmit of RFU level + u8 MC_TimerCount; // MC_Timer count (x16.7ms) + u16 availSlot_flag; // Use RFU-API constant "AVAIL_SLOT1-4" to specify the maximum number of child devices (1 - 4) that can be connected to a parent device. + + // rfu_REQB_configGameData argument + u8 mboot_flag; // Multiplayer boot flag + u16 serialNo; // Game serial number + u8 *gameName; // Game name + u8 *userName; // User name + + // ON/OFF flag for parent fast search operation by child. + u8 fastSearchParent_flag; // Flag indicating whether parent fast search operation to be performed by child. + + // Link recovery settings + u8 linkRecovery_enable; // Determines whether or not to execute the link recovery process when a link cut occurs + u16 linkRecovery_period; // Time to spend on the link recovery process (x 16.7 ms) Note: Runs for unlimited time when specifying 0. + + // Setting for NI-type data transmit/receive period + u16 NI_failCounter_limit; // Limit for failCounter during NI type data transmit/receive (x 16.7 ms) Note: Runs for unlimited time when specifying 0. +}INIT_PARAM; + + +// Timer that counts with the V-Blank cycle +typedef struct VblankTimerTag { + u8 active; // Timer ON/OFF (bits 0 - 3 indicate ON/OFF for each connected slot) + u16 count_max; // Maximum count value (x16.7ms) + u16 count[RFU_CHILD_MAX]; // Current count value (x 16.7 ms) for each connected slot +}VBL_TIMER; struct UnkLinkRfuStruct_02022B44 { @@ -66,46 +178,39 @@ struct UnkLinkRfuStruct_02022B44 u8 fill_84[0x58]; }; -struct UnkRfuStruct_1 +typedef struct linkManagerTag { - /* 0x000 */ u8 unk_00; - /* 0x001 */ u8 unk_01; - /* 0x002 */ vu8 unk_02; - /* 0x003 */ vu8 unk_03; - /* 0x004 */ u8 unk_04; - /* 0x005 */ u8 unk_05; - /* 0x006 */ u8 unk_06; - /* 0x007 */ u8 unk_07; - /* 0x008 */ u8 unk_08; - /* 0x009 */ u8 unk_09; - /* 0x00a */ u8 unk_0a; - /* 0x00b */ u8 unk_0b; - /* 0x00c */ u8 unk_0c; - /* 0x00d */ u8 unk_0d; - /* 0x00e */ u8 unk_0e; - /* 0x00f */ u8 unk_0f; - /* 0x010 */ u8 unk_10; - /* 0x011 */ u8 unk_11; - /* 0x012 */ u8 unk_12; + /* 0x000 */ u8 acceptSlot_flag; + /* 0x001 */ u8 acceptCount; + /* 0x002 */ vu8 childClockSlave_flag; + /* 0x003 */ vu8 parentAck_flag; + /* 0x004 */ u8 state; + /* 0x005 */ u8 next_state; + /* 0x006 */ u8 parent_child; + /* 0x007 */ u8 pcswitch_flag; + /* 0x008 */ u8 RFU_powerOn_flag; + /* 0x009 */ u8 linkRecovery_enable; + /* 0x00a */ u8 linkRecovery_start_flag; + /* 0x00b */ u8 fastSearchParent_flag; + /* 0x00c */ u8 connectSlot_flag_old; + /* 0x00d */ u8 reserveDisconnectSlot_flag; + /* 0x00e */ u8 active; + /* 0x00f */ u8 msc_exe_flag; + /* 0x010 */ u8 child_slot; + /* 0x011 */ u8 state_bak[2]; // aligned - /* 0x014 */ u16 unk_14; - /* 0x016 */ u16 unk_16; - /* 0x018 */ u16 unk_18; - /* 0x01a */ u16 unk_1a; - /* 0x01c */ u16 unk_1c; - /* 0x01e */ u16 unk_1e; - /* 0x020 */ const u16 *unk_20; - /* 0x024 */ u8 unk_24; - /* 0x026 */ u16 unk_26; - /* 0x028 */ u16 unk_28[RFU_CHILD_MAX]; - /* 0x030 */ u8 unk_30; - // aligned - /* 0x032 */ u16 unk_32; - /* 0x034 */ u16 unk_34[RFU_CHILD_MAX]; - /* 0x03c */ const struct UnkLinkRfuStruct_02022B2C *unk_3c; - /* 0x040 */ void (*unk_40)(u8, u8); - /* 0x044 */ void (*unk_44)(u16); -}; + /* 0x014 */ u16 param[2]; + /* 0x018 */ u16 NI_failCounter_limit; + /* 0x01a */ u16 connect_period; + /* 0x01c */ u16 pcswitch_period_bak; + /* 0x01e */ u16 work; + /* 0x020 */ u16 *acceptable_serialNo_list; + /* 0x024 */ VBL_TIMER nameAcceptTimer; + /* 0x030 */ VBL_TIMER linkRecoveryTimer; + /* 0x03c */ INIT_PARAM *init_param; + /* 0x040 */ void (*LMAN_callback)(u8, u8); + /* 0x044 */ void (*MSC_callback)(u16); +} LINK_MANAGER; struct UnkRfuStruct_2_Sub_6c { @@ -222,7 +327,7 @@ struct UnkRfuStruct_2 /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; }; // size: 0x9AC -extern struct UnkRfuStruct_1 gUnknown_3005E10; +extern struct linkManagerTag lman; extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; @@ -241,7 +346,7 @@ u8 sub_8116DE0(void); void sub_80FBB4C(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); -u32 sub_80FD3A4(void); +u32 rfu_LMAN_REQBN_softReset_and_checkID(void); bool32 IsSendingKeysToRfu(void); void Rfu_set_zero(void); u8 GetRfuPlayerCount(void); @@ -265,33 +370,33 @@ void var_800D_set_xB(void); struct GFtgtGname *sub_80F9800(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -void sub_80FEB14(void); +void rfu_LMAN_requestChangeAgbClockMaster(void); bool32 sub_80FBA00(void); void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); -void sub_80FD4B0(const struct UnkLinkRfuStruct_02022B2C *unk0); -u8 sub_80FD538(u8 r5, u16 r7, u16 r8, const u16 *r6); -void sub_80FD760(bool8 a0); -void sub_80FEA10(void (*func)(u16)); +void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); +u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); +void rfu_LMAN_stopManager(bool8 a0); +void rfu_LMAN_setMSCCallback(void (*func)(u16)); void sub_80FB9E4(u8 a0, u16 a1); u8 sub_80FB9F4(void); -void LinkRfu_REQ_SendData_HandleParentRelationship(bool8 clockChangeFlag); +void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); -void sub_80FD52C(void); -u8 sub_80FD610(u16 parentId, u16 unk_1a); +void rfu_LMAN_powerDownRFU(void); +u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 unk_1a); bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); -u8 sub_80FEA34(u8 a0, u16 a1); -void sub_80FDA30(u32 a0); +u8 rfu_LMAN_setLinkRecovery(u8 a0, u16 a1); +void rfu_LMAN_manager_entity(u32 a0); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void LinkRfu_syncVBlank_(void); -s32 sub_80FD430(void (*func1)(u8, u8), void (*func2)(u16)); -void sub_80FEB3C(void); +void rfu_LMAN_syncVBlank(void); +u8 rfu_LMAN_initializeManager(void (*func1)(u8, u8), void (*func2)(u16)); +void rfu_LMAN_forceChangeSP(void); void sub_80FAFE0(u8 a0); bool32 sub_80FA44C(u32 a0); bool8 sub_80FC1B0(void); -- cgit v1.2.3 From 664fa0130a5381c5f647565a71f8fe248a0ebafa Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 29 Jan 2020 16:10:52 -0500 Subject: More doccing of linkManager --- include/link_rfu.h | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index f90de0daf..277cdf018 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -259,18 +259,17 @@ struct UnkRfuStruct_Sub_Unused /* 0x203 */ vu8 unk_203; }; -struct UnkRfuStruct_2 +typedef struct UnkRfuStruct_2 { /* 0x000 */ void (*RfuFunc)(void); /* 0x004 */ u16 unk_04; /* 0x006 */ u8 filler_06[4]; - /* 0x00a */ u16 unk_0a; + /* 0x00a */ u16 linkman_msg; /* 0x00c */ u8 unk_0c; // parentChildMode? /* 0x00d */ u8 playerCount; /* 0x00e */ u8 unk_0e; /* 0x00f */ u8 unk_0f; - /* 0x010 */ u16 unk_10; - /* 0x012 */ u16 unk_12; + /* 0x010 */ u16 linkman_param[2]; /* 0x014 */ u8 unk_14[RFU_CHILD_MAX][14]; /* 0x04c */ u8 unk_4c[14]; /* 0x05a */ u8 unk_5a; @@ -286,7 +285,7 @@ struct UnkRfuStruct_2 /* 0x0e9 */ u8 unk_e9[5]; /* 0x0ee */ vu8 unk_ee; /* 0x0ef */ u8 unk_ef; - /* 0x0f0 */ u8 unk_f0; + /* 0x0f0 */ u8 linkLossRecoveryState; /* 0x0f1 */ u8 unk_f1; /* 0x0f2 */ u16 unk_f2[6]; /* 0x0fe */ u16 unk_fe; @@ -302,7 +301,7 @@ struct UnkRfuStruct_2 /* 0x8f7 */ u8 unk_c3f[70]; /* 0x93d */ u8 unk_c85; /* 0x93e */ u8 unk_c86; - /* 0x93f */ u8 unk_c87[5][7][2]; + /* 0x93f */ u8 recvCmds[5][7][2]; /* 0x985 */ u8 unk_ccd; /* 0x986 */ u8 unk_cce; // childId /* 0x987 */ u8 unk_ccf; @@ -315,8 +314,8 @@ struct UnkRfuStruct_2 /* 0x994 */ vu8 unk_cdc; /* 0x995 */ u8 unk_cdd; /* 0x996 */ u8 unk_cde[RFU_CHILD_MAX]; - /* 0x99a */ u8 unk_ce2; - /* 0x99b */ u8 unk_ce3; + /* 0x99a */ u8 bm_PartnerFlags; + /* 0x99b */ u8 bm_DisconnectSlot; /* 0x99c */ u8 unk_ce4; /* 0x99d */ u8 unk_ce5; /* 0x99e */ u8 unk_ce6; @@ -325,12 +324,29 @@ struct UnkRfuStruct_2 /* 0x9a1 */ u8 unk_ce9; /* 0x9a2 */ u8 unk_cea[RFU_CHILD_MAX]; /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; -}; // size: 0x9AC +} GF_RFU_MANAGER; // size: 0x9AC extern struct linkManagerTag lman; extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; +// Official signatures +u32 rfu_LMAN_REQBN_softReset_and_checkID(void); +void rfu_LMAN_requestChangeAgbClockMaster(void); +void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); +u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); +void rfu_LMAN_stopManager(bool8 forced_stop_and_RFU_reset_flag); +void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16)); +void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); +void rfu_LMAN_powerDownRFU(void); +u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period); +u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period); +void rfu_LMAN_manager_entity(u32 rand); +void rfu_LMAN_syncVBlank(void); +u8 rfu_LMAN_initializeManager(void (*LMAN_callback_p)(u8, u8), void (*MSC_callback_p)(u16)); +void rfu_LMAN_forceChangeSP(void); + +// GameFreak signatures void AddTextPrinterToWindow1(const u8 *str); bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src); void LinkRfu_FatalError(void); @@ -346,11 +362,10 @@ u8 sub_8116DE0(void); void sub_80FBB4C(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); -u32 rfu_LMAN_REQBN_softReset_and_checkID(void); bool32 IsSendingKeysToRfu(void); void Rfu_set_zero(void); u8 GetRfuPlayerCount(void); -void sub_80F9828(void); +void StartSendingKeysToRfu(void); u8 LinkRfu_GetMultiplayerId(void); bool32 Rfu_InitBlockSend(const u8 * src, size_t size); bool8 sub_80FA0F8(u8 a0); @@ -367,36 +382,23 @@ void sub_80F8DC0(void); void sub_80FBB20(void); bool8 sub_80FA484(bool32 a0); void var_800D_set_xB(void); -struct GFtgtGname *sub_80F9800(void); +struct GFtgtGname *GetHostRFUtgtGname(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -void rfu_LMAN_requestChangeAgbClockMaster(void); bool32 sub_80FBA00(void); void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); -void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); -u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); -void rfu_LMAN_stopManager(bool8 a0); -void rfu_LMAN_setMSCCallback(void (*func)(u16)); -void sub_80FB9E4(u8 a0, u16 a1); +void sub_80FB9E4(u8 a0, u16 msg); u8 sub_80FB9F4(void); -void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); -void rfu_LMAN_powerDownRFU(void); -u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 unk_1a); bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); -u8 rfu_LMAN_setLinkRecovery(u8 a0, u16 a1); -void rfu_LMAN_manager_entity(u32 a0); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void rfu_LMAN_syncVBlank(void); -u8 rfu_LMAN_initializeManager(void (*func1)(u8, u8), void (*func2)(u16)); -void rfu_LMAN_forceChangeSP(void); void sub_80FAFE0(u8 a0); bool32 sub_80FA44C(u32 a0); bool8 sub_80FC1B0(void); -- cgit v1.2.3 From 8a3eb95ed4c67031efc641fad632782dbe7b46bf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 29 Jan 2020 16:54:03 -0500 Subject: Yet more documentation of rfu fields and functions --- include/link_rfu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 277cdf018..5a66bb6bb 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -283,7 +283,7 @@ typedef struct UnkRfuStruct_2 /* 0x080 */ struct UnkRfuStruct_2_Sub_6c unk_80[5]; /* 0x0e4 */ u8 unk_e4[5]; /* 0x0e9 */ u8 unk_e9[5]; - /* 0x0ee */ vu8 unk_ee; + /* 0x0ee */ vu8 errorState; /* 0x0ef */ u8 unk_ef; /* 0x0f0 */ u8 linkLossRecoveryState; /* 0x0f1 */ u8 unk_f1; @@ -374,8 +374,8 @@ void Rfu_SetBlockReceivedFlag(u8 who); void Rfu_ResetBlockReceivedFlag(u8 who); bool8 Rfu_IsMaster(void); void sub_80F85F8(void); -bool32 sub_80FAE94(void); -bool32 sub_80FAEF0(void); +bool32 LinkRfuMain1(void); +bool32 LinkRfuMain2(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); void sub_80F8DC0(void); -- cgit v1.2.3 From 78196be41e84f632d3569f5f40cf4da2844902eb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 30 Jan 2020 10:48:42 -0500 Subject: More RFU documentation --- include/link_rfu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 5a66bb6bb..050d68bb6 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -120,7 +120,7 @@ struct __attribute__((packed, aligned(2))) GFtgtGname u8 unk_04[4]; u16 species:10; u16 type:6; - u8 unk_0a_0:7; + u8 activity:7; u8 unk_0a_7:1; u8 playerGender:1; u8 level:7; @@ -400,19 +400,19 @@ bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); void sub_80FAFE0(u8 a0); -bool32 sub_80FA44C(u32 a0); +bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); bool8 sub_80F8F40(void); void sub_80F8F5C(void); bool32 sub_80FA5D4(void); bool32 sub_80FC1CC(void); bool32 sub_80F8F7C(bool32 a0); -bool32 sub_80FA634(u16 a0, const u8 *a1); +bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); void sub_80FA670(u8 a0, u16 a1, const u8 *a2); u32 sub_80FA6FC(u16 a0, const u8 *a1); void SetHostRFUtgtGname(u8 a0, u32 a1, u32 a2); void sub_80FBB8C(u32 a0); -void sub_80FBD4C(const u8 *ptr, u16 a1); +void sub_80FBD4C(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void sub_80FBBD8(void); void sub_80FA6BC(void); -- cgit v1.2.3 From e3307a5b7abc9df8dcd6a0726e0b8fff3188c703 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 30 Jan 2020 14:54:21 -0500 Subject: Still more documentation of RFU --- include/link_rfu.h | 63 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 050d68bb6..52fd07f7c 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -198,7 +198,6 @@ typedef struct linkManagerTag /* 0x00f */ u8 msc_exe_flag; /* 0x010 */ u8 child_slot; /* 0x011 */ u8 state_bak[2]; - // aligned /* 0x014 */ u16 param[2]; /* 0x018 */ u16 NI_failCounter_limit; /* 0x01a */ u16 connect_period; @@ -215,48 +214,48 @@ typedef struct linkManagerTag struct UnkRfuStruct_2_Sub_6c { /* 0x00 */ u16 unk_00; - /* 0x02 */ u16 unk_02; - /* 0x04 */ const u8 *unk_04; + /* 0x02 */ u16 count; + /* 0x04 */ const u8 *payload; /* 0x08 */ u32 unk_08; /* 0x0c */ u32 unk_0c; /* 0x10 */ u8 unk_10; - /* 0x11 */ u8 unk_11; + /* 0x11 */ u8 owner; /* 0x12 */ u8 unk_12; }; struct UnkRfuStruct_2_Sub_124 { - /* 0x000 */ u8 unk_00[20][70]; - /* 0x578 */ vu8 unk_8c0; - /* 0x579 */ vu8 unk_8c1; - /* 0x57a */ vu8 unk_8c2; - /* 0x57b */ vu8 unk_8c3; + /* 0x000 */ u8 slots[20][70]; + /* 0x578 */ vu8 recv_slot; + /* 0x579 */ vu8 send_slot; + /* 0x57a */ vu8 count; + /* 0x57b */ vu8 full; }; struct UnkRfuStruct_2_Sub_9e8 { - /* 0x000 */ u8 unk_00[40][14]; - /* 0x230 */ vu8 unk_230; - /* 0x231 */ vu8 unk_231; - /* 0x232 */ vu8 unk_232; - /* 0x233 */ vu8 unk_233; + /* 0x000 */ u8 slots[40][14]; + /* 0x230 */ vu8 recv_slot; + /* 0x231 */ vu8 send_slot; + /* 0x232 */ vu8 count; + /* 0x233 */ vu8 full; }; struct UnkRfuStruct_2_Sub_c1c { - /* 0x00 */ u8 unk_00[2][14]; - /* 0x1c */ vu8 unk_1c; - /* 0x1d */ vu8 unk_1d; - /* 0x1e */ vu8 unk_1e; + /* 0x00 */ u8 slots[2][14]; + /* 0x1c */ vu8 recv_slot; + /* 0x1d */ vu8 send_slot; + /* 0x1e */ vu8 count; }; struct UnkRfuStruct_Sub_Unused { - /* 0x000 */ u8 unk_00[2][256]; - /* 0x200 */ vu8 unk_200; - /* 0x201 */ vu8 unk_201; - /* 0x202 */ vu8 unk_202; - /* 0x203 */ vu8 unk_203; + /* 0x000 */ u8 slots[2][256]; + /* 0x200 */ vu8 recv_slot; + /* 0x201 */ vu8 send_slot; + /* 0x202 */ vu8 count; + /* 0x203 */ vu8 full; }; typedef struct UnkRfuStruct_2 @@ -297,7 +296,7 @@ typedef struct UnkRfuStruct_2 /* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c; /* 0x8f4 */ vu8 unk_c3c; /* 0x8f5 */ u8 unk_c3d; - /* 0x8f6 */ vu8 unk_c3e; + /* 0x8f6 */ vu8 child_slot; /* 0x8f7 */ u8 unk_c3f[70]; /* 0x93d */ u8 unk_c85; /* 0x93e */ u8 unk_c86; @@ -387,17 +386,17 @@ void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); bool32 sub_80FBA00(void); -void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); -void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); +void RFU_queue_20_70_reset(struct UnkRfuStruct_2_Sub_124 *ptr); +void RFU_queue_40_14_reset(struct UnkRfuStruct_2_Sub_9e8 *ptr); void sub_80FB9E4(u8 a0, u16 msg); u8 sub_80FB9F4(void); -void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); -bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); -bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); -void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); -bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); -void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); +void RFU_queue_20_70_recv(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); +bool8 RFU_queue_40_14_send(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); +bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); +void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); +bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); +void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); void sub_80FAFE0(u8 a0); bool32 RfuSerialNumberIsValid(u32 a0); -- cgit v1.2.3 From aed9c28dc30b5da30186844d78cf74162409486e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 11:02:02 -0500 Subject: Document rfu_union_tool --- include/link_rfu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 52fd07f7c..4f11d8cb6 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -117,7 +117,8 @@ struct GFtgtGnameSub struct __attribute__((packed, aligned(2))) GFtgtGname { struct GFtgtGnameSub unk_00; - u8 unk_04[4]; + u8 unk_04[RFU_CHILD_MAX]; // u8 sprite_idx:3; + // u8 gender:1; u16 species:10; u16 type:6; u8 activity:7; -- cgit v1.2.3 From 46a3ca51341fd3b68e4fe5251e70abc8a03644c5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 13:42:57 -0500 Subject: Union room activity documentation --- include/link_rfu.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 4f11d8cb6..0bcebd7ad 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -117,8 +117,10 @@ struct GFtgtGnameSub struct __attribute__((packed, aligned(2))) GFtgtGname { struct GFtgtGnameSub unk_00; - u8 unk_04[RFU_CHILD_MAX]; // u8 sprite_idx:3; - // u8 gender:1; + 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; u8 activity:7; @@ -385,13 +387,13 @@ void var_800D_set_xB(void); struct GFtgtGname *GetHostRFUtgtGname(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -bool32 sub_80FBA00(void); +bool32 RfuIsErrorStatus1or2(void); void RFU_queue_20_70_reset(struct UnkRfuStruct_2_Sub_124 *ptr); void RFU_queue_40_14_reset(struct UnkRfuStruct_2_Sub_9e8 *ptr); -void sub_80FB9E4(u8 a0, u16 msg); -u8 sub_80FB9F4(void); +void RfuSetErrorStatus(u8 a0, u16 msg); +u8 RfuGetErrorStatus(void); void RFU_queue_20_70_recv(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); bool8 RFU_queue_40_14_send(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); @@ -410,14 +412,14 @@ bool32 sub_80F8F7C(bool32 a0); bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); void sub_80FA670(u8 a0, u16 a1, const u8 *a2); u32 sub_80FA6FC(u16 a0, const u8 *a1); -void SetHostRFUtgtGname(u8 a0, u32 a1, u32 a2); +void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2); void sub_80FBB8C(u32 a0); void sub_80FBD4C(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void sub_80FBBD8(void); void sub_80FA6BC(void); void sub_80FBF54(const u8 *src, u16 trainerId); -void sub_80FB008(u8 a0, u32 a1, u32 a2); +void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); void RecordMixTrainerNames(void); void sub_80F8CFC(); void sub_80F8D14(); -- cgit v1.2.3 From 7bd0a83d359beafc69a1a63cb51b11e98186a292 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 16:41:25 -0500 Subject: I'm so original with these commit names --- include/link_rfu.h | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 0bcebd7ad..d25ed020e 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -102,14 +102,14 @@ // RfuTgtData.gname is read as these structs. struct GFtgtGnameSub { - u16 unk_00_0:4; - u16 unk_00_4:1; - u16 unk_00_5:1; + u16 language:4; + u16 hasNews:1; + u16 hasCard:1; u16 unk_00_6:1; u16 isChampion:1; u16 hasNationalDex:1; u16 gameClear:1; - u16 unk_01_2:4; + u16 version:4; u16 unk_01_6:2; u8 playerTrainerId[2]; }; @@ -214,16 +214,28 @@ typedef struct linkManagerTag /* 0x044 */ void (*MSC_callback)(u16); } LINK_MANAGER; -struct UnkRfuStruct_2_Sub_6c +#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 + +struct RfuBlockSend { - /* 0x00 */ u16 unk_00; - /* 0x02 */ u16 count; + /* 0x00 */ u16 next; + /* 0x02 */ u16 count; // max 21 /* 0x04 */ const u8 *payload; - /* 0x08 */ u32 unk_08; - /* 0x0c */ u32 unk_0c; - /* 0x10 */ u8 unk_10; + /* 0x08 */ u32 receivedFlags; + /* 0x0c */ u32 failedFlags; + /* 0x10 */ u8 sending; /* 0x11 */ u8 owner; - /* 0x12 */ u8 unk_12; + /* 0x12 */ u8 receiving; }; struct UnkRfuStruct_2_Sub_124 @@ -264,7 +276,7 @@ struct UnkRfuStruct_Sub_Unused typedef struct UnkRfuStruct_2 { /* 0x000 */ void (*RfuFunc)(void); - /* 0x004 */ u16 unk_04; + /* 0x004 */ u16 state; /* 0x006 */ u8 filler_06[4]; /* 0x00a */ u16 linkman_msg; /* 0x00c */ u8 unk_0c; // parentChildMode? @@ -281,8 +293,8 @@ typedef struct UnkRfuStruct_2 /* 0x066 */ u8 unk_66; /* 0x067 */ u8 unk_67; /* 0x068 */ u8 filler_68[4]; - /* 0x06c */ struct UnkRfuStruct_2_Sub_6c unk_6c; - /* 0x080 */ struct UnkRfuStruct_2_Sub_6c unk_80[5]; + /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf; + /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5]; /* 0x0e4 */ u8 unk_e4[5]; /* 0x0e9 */ u8 unk_e9[5]; /* 0x0ee */ vu8 errorState; @@ -304,7 +316,7 @@ typedef struct UnkRfuStruct_2 /* 0x93d */ u8 unk_c85; /* 0x93e */ u8 unk_c86; /* 0x93f */ u8 recvCmds[5][7][2]; - /* 0x985 */ u8 unk_ccd; + /* 0x985 */ u8 parentId; /* 0x986 */ u8 unk_cce; // childId /* 0x987 */ u8 unk_ccf; /* 0x988 */ vu8 unk_cd0; @@ -423,16 +435,16 @@ void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); void RecordMixTrainerNames(void); void sub_80F8CFC(); void sub_80F8D14(); -void sub_80FAF74(bool32 a0, bool32 a1); +void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void sub_80F8FA0(void); -void sub_80FAFA0(u32 type, u32 species, u32 level); +void RfuUpdatePlayerGnameStateAndSend(u32 type, u32 species, u32 level); bool32 sub_80FBB0C(void); void sub_80FBC00(void); void sub_80FBD6C(u32 a0); void sub_80FC114(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); -bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx); +bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *gname, u8 *uname, u8 idx); bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx); bool32 GetRfuUnkCE8(void); void sub_80FA4A8(void); -- cgit v1.2.3 From e0d25c32898b1284297159a5d1c1c6422a040150 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 20:09:14 -0500 Subject: Document wireless_communication_status_screen --- include/link_rfu.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index d25ed020e..40d69201e 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -279,7 +279,7 @@ typedef struct UnkRfuStruct_2 /* 0x004 */ u16 state; /* 0x006 */ u8 filler_06[4]; /* 0x00a */ u16 linkman_msg; - /* 0x00c */ u8 unk_0c; // parentChildMode? + /* 0x00c */ u8 parent_child; /* 0x00d */ u8 playerCount; /* 0x00e */ u8 unk_0e; /* 0x00f */ u8 unk_0f; @@ -372,7 +372,7 @@ void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_Leader(u32 arg0); void sub_80F9E2C(void * data); -u8 sub_8116DE0(void); +u8 CreateTask_ListenToWireless(void); void sub_80FBB4C(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); @@ -392,7 +392,7 @@ bool32 LinkRfuMain1(void); bool32 LinkRfuMain2(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); -void sub_80F8DC0(void); +void LinkRfu_Shutdown(void); void sub_80FBB20(void); bool8 sub_80FA484(bool32 a0); void var_800D_set_xB(void); @@ -425,10 +425,10 @@ bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); void sub_80FA670(u8 a0, u16 a1, const u8 *a2); u32 sub_80FA6FC(u16 a0, const u8 *a1); void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2); -void sub_80FBB8C(u32 a0); +void InitializeRfuLinkManager_LinkLeader(u32 availSlots); void sub_80FBD4C(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); -void sub_80FBBD8(void); +void InitializeRfuLinkManager_JoinGroup(void); void sub_80FA6BC(void); void sub_80FBF54(const u8 *src, u16 trainerId); void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); -- cgit v1.2.3 From 4770fac9eb9696236fa998554a353f1f140a1ed4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 4 Feb 2020 14:16:45 -0500 Subject: More mevent documentation --- include/link_rfu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 40d69201e..92aceec59 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -295,7 +295,7 @@ typedef struct UnkRfuStruct_2 /* 0x068 */ u8 filler_68[4]; /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf; /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5]; - /* 0x0e4 */ u8 unk_e4[5]; + /* 0x0e4 */ u8 cmd5f00Ack[5]; /* 0x0e9 */ u8 unk_e9[5]; /* 0x0ee */ vu8 errorState; /* 0x0ef */ u8 unk_ef; @@ -365,7 +365,7 @@ void AddTextPrinterToWindow1(const u8 *str); bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src); void LinkRfu_FatalError(void); void MG_DrawCheckerboardPattern(void); -void task_add_05_task_del_08FA224_when_no_RfuFunc(void); +void Rfu_BeginBuildAndSendCommand5F(void); bool8 IsLinkRfuTaskFinished(void); void DestroyWirelessStatusIndicatorSprite(void); void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); @@ -413,7 +413,7 @@ void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void sub_80FAFE0(u8 a0); +void sub_80FAFE0(bool8 unk_0a_7); bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); bool8 sub_80F8F40(void); -- cgit v1.2.3 From 6af7391add68be30c6bd7d22803a3dd454e08a33 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 4 Feb 2020 17:01:57 -0500 Subject: More renaming in union_room.c --- include/link_rfu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 92aceec59..dc96e3a77 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -433,8 +433,8 @@ void sub_80FA6BC(void); void sub_80FBF54(const u8 *src, u16 trainerId); void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); void RecordMixTrainerNames(void); -void sub_80F8CFC(); -void sub_80F8D14(); +void LinkRfu_CreateConnectionAsParent(); +void LinkRfu_StopManagerBeforeEnteringChat(); void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void sub_80F8FA0(void); @@ -445,7 +445,7 @@ void sub_80FBD6C(u32 a0); void sub_80FC114(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *gname, u8 *uname, u8 idx); -bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx); +bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *gname, u8 *uname, u8 idx); bool32 GetRfuUnkCE8(void); void sub_80FA4A8(void); void sub_80FB9D0(void); -- cgit v1.2.3 From 78caeff45b98bf3cce180d37606d5a5239fbb030 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 6 Feb 2020 10:44:22 -0500 Subject: Name remaining funcs in union_room.c --- include/link_rfu.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index dc96e3a77..472f5fa74 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -124,11 +124,11 @@ struct __attribute__((packed, aligned(2))) GFtgtGname u16 species:10; u16 type:6; u8 activity:7; - u8 unk_0a_7:1; + u8 started:1; u8 playerGender:1; u8 level:7; - u8 unk_0c; -}; + u8 padding; +}; // size: RFU_GNAME_SIZE struct Padded_U8 { @@ -333,7 +333,7 @@ typedef struct UnkRfuStruct_2 /* 0x99c */ u8 unk_ce4; /* 0x99d */ u8 unk_ce5; /* 0x99e */ u8 unk_ce6; - /* 0x99f */ u8 unk_ce7; + /* 0x99f */ u8 acceptSlot_flag; /* 0x9a0 */ bool8 unk_ce8; /* 0x9a1 */ u8 unk_ce9; /* 0x9a2 */ u8 unk_cea[RFU_CHILD_MAX]; @@ -371,7 +371,7 @@ void DestroyWirelessStatusIndicatorSprite(void); void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_Leader(u32 arg0); -void sub_80F9E2C(void * data); +void RfuPrepareSend0x2f00(void * data); u8 CreateTask_ListenToWireless(void); void sub_80FBB4C(void); void sub_80F86F4(void); @@ -412,26 +412,26 @@ bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); -void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void sub_80FAFE0(bool8 unk_0a_7); +void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders); +void UpdateGameData_GroupLockedIn(bool8 started); bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); -bool8 sub_80F8F40(void); +bool8 LmanAcceptSlotFlagIsNotZero(void); void sub_80F8F5C(void); bool32 sub_80FA5D4(void); bool32 sub_80FC1CC(void); -bool32 sub_80F8F7C(bool32 a0); -bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); -void sub_80FA670(u8 a0, u16 a1, const u8 *a2); -u32 sub_80FA6FC(u16 a0, const u8 *a1); +bool32 WaitRfuState(bool32 a0); +bool32 TrainerIdAndNameStillInPartnersList(u16 trainerId, const u8 *trainerName); +void SendByteToPartnerByIdAndName(u8 a0, u16 a1, const u8 *a2); +u32 WaitSendByteToPartnerByIdAndName(u16 a0, const u8 *a1); void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2); void InitializeRfuLinkManager_LinkLeader(u32 availSlots); -void sub_80FBD4C(const u8 *trainerName, u16 trainerId); +void RequestDisconnectSlotByTrainerNameAndId(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void InitializeRfuLinkManager_JoinGroup(void); -void sub_80FA6BC(void); -void sub_80FBF54(const u8 *src, u16 trainerId); -void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); +void LinkRfuNIsend8(void); +void CreateTask_sub_80FBE80(const u8 *src, u16 trainerId); +void UpdateGameDataWithActivitySpriteGendersFlag(u8 activity, u32 child_sprite_genders, u32 started); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(); void LinkRfu_StopManagerBeforeEnteringChat(); -- cgit v1.2.3 From c0373e9e93ff07edebc120e317b6473c171a946a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 10 Feb 2020 11:11:25 -0500 Subject: Address review comments --- include/link_rfu.h | 228 +---------------------------------------------------- 1 file changed, 1 insertion(+), 227 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 472f5fa74..96c595100 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,216 +3,7 @@ #include "global.h" #include "librfu.h" - -//----------------------------------------------------------------- -// Constant definition -//----------------------------------------------------------------- - -// Link Manager operation mode (specified by u8 parent_child argument of rfu_LMAN_establishConnection) -//#define MODE_CHILD 0 // Start Link Manager in CHILD mode -//#define MODE_PARENT 1 // Start Link Manager in PARENT mode -//Note: This value uses the item defined by AgbRFU_LL.h. -#define MODE_P_C_SWITCH 2 // Start Link Manager in parent-child switching mode. - - -// Error code returned by Link Manager API (rfu_LMAN_...return value of function) -#define LMAN_ERROR_MANAGER_BUSY 1 // Link Manager is already running. -#define LMAN_ERROR_AGB_CLK_SLAVE 2 // AGB is clock slave so link manager cannot run. -#define LMAN_ERROR_PID_NOT_FOUND 3 // Parent device information of the specified PID does not exist in rfuLinkStatus->partner[0-3]. -#define LMAN_ERROR_ILLEGAL_PARAMETER 4 // Specified argument is unusual. -#define LMAN_ERROR_NOW_LINK_RECOVERY 5 // New settings were ignored because link recovery was under way when current link recovery was ON and new settings turned link recovery OFF. -#define LMAN_ERROR_NOW_COMMUNICATION 6 // New settings were ignored because currently communicating with NI. -#define LMAN_ERROR_NOW_SEARCH_PARENT 7 // Parent search currently under way, so ignore new setting. - -// Details of messages and the related parameters returned by the u8 msg, u8 param_count, and lman.param[0-1] arguments of the LMAN callback generated by the operation of the Link Manager. -// msg name msg No. param qty param[0] param[1] Description -#define LMAN_MSG_INITIALIZE_COMPLETED 0x00 // 0 - - Generated when RFU reset and initial settings are completed -#define LMAN_MSG_NEW_CHILD_CONNECT_DETECTED 0x10 // 1 Bit indicating slot - Generated when new child device connection was detected at RFU level. -// with detected connection -#define LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED 0x11 // 1 Bit indicating slot - Generated when game identification information from child device connected at RFU level is received and accepted (game serial numbers match). -// where connection was accepted -#define LMAN_MSG_NEW_CHILD_CONNECT_REJECTED 0x12 // 1 Bit indicating slot - Generated when the connection from the child device connected at RFU level is rejected (game identification information reception failed or game serial numbers do not match). -// where connection was rejected -#define LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED 0x13 // 0 - - Generated when SearchChild operation time expires. -#define LMAN_MSG_END_WAIT_CHILD_NAME 0x14 // 0 - - Generated when reception of game identification information from all child devices completes after the SearchChild operation time expires. -#define LMAN_MSG_PARENT_FOUND 0x20 // 1 Bit indicating - Generated when valid (game serial numbers match) parent devices are found during SearchParent. -// rfuLinkStatus->partner[x] index number storing the valid parent devices (game serial number matches) from among the discovered parent devices. -#define LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED 0x21 // 0 - - Generated when SearchParent time expires. -#define LMAN_MSG_CONNECT_PARENT_SUCCESSED 0x22 // 1 Connected slot number - Generated when connection with parent device at RFU level succeeds. -#define LMAN_MSG_CONNECT_PARENT_FAILED 0x23 // 1 Connection failure reason - Generated when connection with parent device at RFU level fails. -#define LMAN_MSG_CHILD_NAME_SEND_COMPLETED 0x24 // 0 - - Generated when transmission of the child's game identification information to the parent device succeeds after connection with parent device at RFU level succeeds. -#define LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED 0x25 // 0 - - Generated when transmission of the child's game identification information to the parent device fails after connection with parent device at RFU level succeeds. -#define LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED 0x30 // 1 Bit indicating slot - Generated when a link cut is detected and that slot disconnects. (Generated only when link recovery is OFF.) -// that was disconnected and where link cut was detected but link recover not attempted -#define LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY 0x31 // 1 Bit indicating slot - Generated when a link cut is detected and the link recovery process starts. (Generated only when link recovery is ON.) -// where link cut was detected and link recovery was started -#define LMAN_MSG_LINK_RECOVERY_SUCCESSED 0x32 // 1 Bit indicating slot - Generated when link recovery succeeds. (Generated only when link recovery is ON.) -// where link recovery succeeded -#define LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED 0x33 // 1 Bit indicating slot - Generated when link recovery fails and that slot disconnects. (Generated only when link recovery is ON.) -// where link recovery failed and that disconnected -#define LMAN_MSG_LINK_DISCONNECTED_BY_USER 0x40 // 1 Generated on disconnection by execution of rfu_REQ_disconnect by disconnected user. -// Slot indicated in bits *Note: If rfu_REQ_disconnect is used for disconnection during link recovery in the child device, the link recovery is also suspended, but the only message returned is DISCONNECTED_BY_USER. -#define LMAN_MSG_CHANGE_AGB_CLOCK_SLAVE 0x41 // 0 - - Generated when the AGB-RFU clock switches to AGB clock slave after a successful connection or link recovery in the child device. (This message is not generated when the AGB switches to a clock slave when an MSC callback completes.) -#define LMAN_MSG_CHANGE_AGB_CLOCK_MASTER 0x45 // 0 - - Generated when the AGB-RFU intercommunication clock is switched to the AGB clock master in the child device. -#define LMAN_MSG_RFU_POWER_DOWN 0x42 // 0 - - Generated when the RFU enters power conservation mode with rfu_LMAN_powerDownRFU. -#define LMAN_MSG_MANAGER_STOPPED 0x43 // 0 - - Generated when the Link Manager is halted by rfu_LMAN_stopLMAN(0). (This message is not generated during SearchChild, SearchParent, ConnectParent, and LinkRecovery. A message (-PERIOD_EXPIRED, -SUCCESSED, -FAILED) corresponding to the operation completion is returned.) -#define LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET 0x44 // 0 - - Generates when the Link Manager is forcibly halted by rfu_LMAN_stopLMAN(1) and RFU is reset. - -#define LMAN_MSG_RECV_DATA_REQ_COMPLETED 0x50 // 0 - - Generated when the execution of rfu_REQ_recvData completes. (This message is not notification of data reception from a RFU.) - -#define LMAN_MSG_REQ_API_ERROR 0xf0 // 2 REQ_commandID REQ_result REQ-API resulted in error. This message is also generated by an REQ-API executed by either the link manager or the user. -#define LMAN_MSG_WATCH_DOG_TIMER_ERROR 0xf1 // 0 - - Generated when a MSC callback does not occur even after 6 seconds pass when the AGB is the clock slave. -#define LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA 0xf2 // 0 - - Generated when an automatic starting DMA, such as HDMA, is issued at the same time the RFU attempts to send notification and to return the AGB to the clock master while the AGB is the clock slave and the exchange of that information (REQ command) fails. -#define LMAN_MSG_LMAN_API_ERROR_RETURN 0xf3 // 1 Return error code - Generated when LMAN-API execution returns an error. -#define LMAN_MSG_RFU_FATAL_ERROR 0xff // 0 - - Generated when the Link Manager cannot recongize a RFU because of the execution of rfu_REQBN_softReset_and_checkID. - - -// Value of lman.childClockSlave_flag -#define RFU_CHILD_CLOCK_SLAVE_OFF 0 // The child device is not operating in AGB clock slave mode. (The child device is in this mode in cases such as when the child has not established a connection or during link recovery.) -#define RFU_CHILD_CLOCK_SLAVE_ON 1 // The child device is operating in AGB clock slave mode. (Child automatically enters this mode when a connection is established.) -#define RFU_CHILD_CLOCK_SLAVE_OFF_REQ 2 // The child device has requested that AGB clock slave mode be halted. - -// State of Link Manager (values of lman.state, lman.next_state) -#define LMAN_STATE_READY 0x00 // Waiting -#define LMAN_STATE_SOFT_RESET_AND_CHECK_ID 0x01 // Requesting execution of rfu_REQBN_softResetAndCheckID (same as below) -#define LMAN_STATE_RESET 0x02 // rfu_REQ_reset -#define LMAN_STATE_CONFIG_SYSTEM 0x03 // rfu_REQ_configSystem -#define LMAN_STATE_CONFIG_GAME_DATA 0x04 // rfu_REQ_configGameData -#define LMAN_STATE_START_SEARCH_CHILD 0x05 // rfu_REQ_startSearchChild -#define LMAN_STATE_POLL_SEARCH_CHILD 0x06 // rfu_REQ_pollSearchChild -#define LMAN_STATE_END_SEARCH_CHILD 0x07 // rfu_REQ_endSearchChild -#define LMAN_STATE_WAIT_RECV_CHILD_NAME 0x08 // Awaiting reception of game name from connected child device. -#define LMAN_STATE_START_SEARCH_PARENT 0x09 // rfu_REQ_startSearchParent -#define LMAN_STATE_POLL_SEARCH_PARENT 0x0a // rfu_REQ_pollSearchParent -#define LMAN_STATE_END_SEARCH_PARENT 0x0b // rfu_REQ_endSearchParent -#define LMAN_STATE_START_CONNECT_PARENT 0x0c // rfu_REQ_startConnectParent -#define LMAN_STATE_POLL_CONNECT_PARENT 0x0d // rfu_REQ_pollConnectParent -#define LMAN_STATE_END_CONNECT_PARENT 0x0e // rfu_REQ_endConnectParent -#define LMAN_STATE_SEND_CHILD_NAME 0x0f // Sending child game name. -#define LMAN_STATE_START_LINK_RECOVERY 0x10 // rfu_REQ_CHILD_startConnectRecovery -#define LMAN_STATE_POLL_LINK_RECOVERY 0x11 // rfu_REQ_CHILD_pollConnectRecovery -#define LMAN_STATE_END_LINK_RECOVERY 0x12 // rfu_REQ_CHILD_endConnectRecovery -#define LMAN_STATE_MS_CHANGE 0x13 // rfu_REQ_changeMasterSlave -#define LMAN_STATE_WAIT_CLOCK_MASTER 0x14 // Waiting for AGB-RFU intercommunication clock to become AGB clock master. -#define LMAN_STATE_STOP_MODE 0x15 // rfu_REQ_stopMode -#define LMAN_STATE_BACK_STATE 0x16 // Following the completion of link-recovery processing, return the Link Manager state to the state present before link-recovery processing was initiated. -#define LMAN_FORCED_STOP_AND_RFU_RESET 0x17 // Attempt to forcibly stop Link Manager using rfu_LMAN_stopLMAN(1). -#define LMAN_STATE_WAIT_CHANGE_CLOCK_MASTER 0x18 // Attempt to return to AGB clock master after child fails in sending game name. - -// RfuTgtData.gname is read as these structs. -struct GFtgtGnameSub -{ - u16 language:4; - u16 hasNews:1; - u16 hasCard:1; - u16 unk_00_6:1; - u16 isChampion:1; - u16 hasNationalDex:1; - u16 gameClear:1; - u16 version:4; - u16 unk_01_6:2; - u8 playerTrainerId[2]; -}; - -struct __attribute__((packed, aligned(2))) GFtgtGname -{ - 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; - u8 activity:7; - u8 started:1; - u8 playerGender:1; - u8 level:7; - u8 padding; -}; // size: RFU_GNAME_SIZE - -struct Padded_U8 -{ - u8 value; -}; - -// Parameter group used in initial setting run of the link manager (rfu_LMAN_initializeRFU) -typedef struct InitializeParametersTag { - // rfu_REQ_configSystem argument - u8 maxMFrame; // Maximum number of times to re-transmit of RFU level - u8 MC_TimerCount; // MC_Timer count (x16.7ms) - u16 availSlot_flag; // Use RFU-API constant "AVAIL_SLOT1-4" to specify the maximum number of child devices (1 - 4) that can be connected to a parent device. - - // rfu_REQB_configGameData argument - u8 mboot_flag; // Multiplayer boot flag - u16 serialNo; // Game serial number - u8 *gameName; // Game name - u8 *userName; // User name - - // ON/OFF flag for parent fast search operation by child. - u8 fastSearchParent_flag; // Flag indicating whether parent fast search operation to be performed by child. - - // Link recovery settings - u8 linkRecovery_enable; // Determines whether or not to execute the link recovery process when a link cut occurs - u16 linkRecovery_period; // Time to spend on the link recovery process (x 16.7 ms) Note: Runs for unlimited time when specifying 0. - - // Setting for NI-type data transmit/receive period - u16 NI_failCounter_limit; // Limit for failCounter during NI type data transmit/receive (x 16.7 ms) Note: Runs for unlimited time when specifying 0. -}INIT_PARAM; - - -// Timer that counts with the V-Blank cycle -typedef struct VblankTimerTag { - u8 active; // Timer ON/OFF (bits 0 - 3 indicate ON/OFF for each connected slot) - u16 count_max; // Maximum count value (x16.7ms) - u16 count[RFU_CHILD_MAX]; // Current count value (x 16.7 ms) for each connected slot -}VBL_TIMER; - -struct UnkLinkRfuStruct_02022B44 -{ - u8 fill_00[6]; - u16 unk_06; - u8 fill_08[6]; - vu8 unk_0e; - u8 unk_0f; - u8 fill_10[0x54]; - u16 unk_64; - u8 fill_66[0x1d]; - u8 unk_83; - u8 fill_84[0x58]; -}; - -typedef struct linkManagerTag -{ - /* 0x000 */ u8 acceptSlot_flag; - /* 0x001 */ u8 acceptCount; - /* 0x002 */ vu8 childClockSlave_flag; - /* 0x003 */ vu8 parentAck_flag; - /* 0x004 */ u8 state; - /* 0x005 */ u8 next_state; - /* 0x006 */ u8 parent_child; - /* 0x007 */ u8 pcswitch_flag; - /* 0x008 */ u8 RFU_powerOn_flag; - /* 0x009 */ u8 linkRecovery_enable; - /* 0x00a */ u8 linkRecovery_start_flag; - /* 0x00b */ u8 fastSearchParent_flag; - /* 0x00c */ u8 connectSlot_flag_old; - /* 0x00d */ u8 reserveDisconnectSlot_flag; - /* 0x00e */ u8 active; - /* 0x00f */ u8 msc_exe_flag; - /* 0x010 */ u8 child_slot; - /* 0x011 */ u8 state_bak[2]; - /* 0x014 */ u16 param[2]; - /* 0x018 */ u16 NI_failCounter_limit; - /* 0x01a */ u16 connect_period; - /* 0x01c */ u16 pcswitch_period_bak; - /* 0x01e */ u16 work; - /* 0x020 */ u16 *acceptable_serialNo_list; - /* 0x024 */ VBL_TIMER nameAcceptTimer; - /* 0x030 */ VBL_TIMER linkRecoveryTimer; - /* 0x03c */ INIT_PARAM *init_param; - /* 0x040 */ void (*LMAN_callback)(u8, u8); - /* 0x044 */ void (*MSC_callback)(u16); -} LINK_MANAGER; +#include "linkManager.h" #define RFU_COMMAND_0x8800 0x8800 #define RFU_COMMAND_0x8900 0x8900 @@ -340,26 +131,9 @@ typedef struct UnkRfuStruct_2 /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; } GF_RFU_MANAGER; // size: 0x9AC -extern struct linkManagerTag lman; extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; -// Official signatures -u32 rfu_LMAN_REQBN_softReset_and_checkID(void); -void rfu_LMAN_requestChangeAgbClockMaster(void); -void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); -u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); -void rfu_LMAN_stopManager(bool8 forced_stop_and_RFU_reset_flag); -void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16)); -void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); -void rfu_LMAN_powerDownRFU(void); -u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period); -u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period); -void rfu_LMAN_manager_entity(u32 rand); -void rfu_LMAN_syncVBlank(void); -u8 rfu_LMAN_initializeManager(void (*LMAN_callback_p)(u8, u8), void (*MSC_callback_p)(u16)); -void rfu_LMAN_forceChangeSP(void); - // GameFreak signatures void AddTextPrinterToWindow1(const u8 *str); bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src); -- cgit v1.2.3 From b9f1132aa65c8f79d6c2c93ad372146b0bbda094 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 10 Feb 2020 12:07:22 -0500 Subject: link_rfu.c --> AgbRfu_LinkManager.c --- 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 96c595100..52d3a4c9c 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,7 +3,7 @@ #include "global.h" #include "librfu.h" -#include "linkManager.h" +#include "AgbRfu_LinkManager.h" #define RFU_COMMAND_0x8800 0x8800 #define RFU_COMMAND_0x8900 0x8900 -- cgit v1.2.3 From aa4a979334036eb647cef5cd6a4ecd0bcad4b235 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 12 Feb 2020 15:32:14 -0500 Subject: More function documentation in union_room, link, link_rfu_2 --- include/link_rfu.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'include/link_rfu.h') diff --git a/include/link_rfu.h b/include/link_rfu.h index 52d3a4c9c..86d55047d 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -87,21 +87,21 @@ typedef struct UnkRfuStruct_2 /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf; /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5]; /* 0x0e4 */ u8 cmd5f00Ack[5]; - /* 0x0e9 */ u8 unk_e9[5]; + /* 0x0e9 */ u8 cmd_6600_recvd[5]; /* 0x0ee */ vu8 errorState; /* 0x0ef */ u8 unk_ef; /* 0x0f0 */ u8 linkLossRecoveryState; /* 0x0f1 */ u8 unk_f1; /* 0x0f2 */ u16 unk_f2[6]; - /* 0x0fe */ u16 unk_fe; - /* 0x100 */ u16 unk_100; + /* 0x0fe */ u16 cmd_6600_timer; + /* 0x100 */ u16 cmd_6600_count; /* 0x102 */ u8 unk_102; /* 0x104 */ struct RfuTgtData unk_104; /* 0x124 */ struct UnkRfuStruct_2_Sub_124 unk_124; /* 0x6a0 */ struct UnkRfuStruct_2_Sub_9e8 unk_9e8; /* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c; /* 0x8f4 */ vu8 unk_c3c; - /* 0x8f5 */ u8 unk_c3d; + /* 0x8f5 */ u8 reconnectedParentIdx; /* 0x8f6 */ vu8 child_slot; /* 0x8f7 */ u8 unk_c3f[70]; /* 0x93d */ u8 unk_c85; @@ -118,12 +118,12 @@ typedef struct UnkRfuStruct_2 /* 0x993 */ vu8 unk_cdb; /* 0x994 */ vu8 unk_cdc; /* 0x995 */ u8 unk_cdd; - /* 0x996 */ u8 unk_cde[RFU_CHILD_MAX]; + /* 0x996 */ u8 linkPlayerIdx[RFU_CHILD_MAX]; /* 0x99a */ u8 bm_PartnerFlags; /* 0x99b */ u8 bm_DisconnectSlot; /* 0x99c */ u8 unk_ce4; /* 0x99d */ u8 unk_ce5; - /* 0x99e */ u8 unk_ce6; + /* 0x99e */ u8 unionRoomChatters; /* 0x99f */ u8 acceptSlot_flag; /* 0x9a0 */ bool8 unk_ce8; /* 0x9a1 */ u8 unk_ce9; @@ -147,7 +147,7 @@ void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_Leader(u32 arg0); void RfuPrepareSend0x2f00(void * data); u8 CreateTask_ListenToWireless(void); -void sub_80FBB4C(void); +void LinkRfu_DestroyIdleTask(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); bool32 IsSendingKeysToRfu(void); @@ -161,13 +161,13 @@ u8 Rfu_GetBlockReceivedStatus(void); void Rfu_SetBlockReceivedFlag(u8 who); void Rfu_ResetBlockReceivedFlag(u8 who); bool8 Rfu_IsMaster(void); -void sub_80F85F8(void); +void ResetLinkRfuGFLayer(void); bool32 LinkRfuMain1(void); bool32 LinkRfuMain2(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); void LinkRfu_Shutdown(void); -void sub_80FBB20(void); +void LinkRfu_CreateIdleTask(void); bool8 sub_80FA484(bool32 a0); void var_800D_set_xB(void); struct GFtgtGname *GetHostRFUtgtGname(void); @@ -191,7 +191,7 @@ void UpdateGameData_GroupLockedIn(bool8 started); bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); bool8 LmanAcceptSlotFlagIsNotZero(void); -void sub_80F8F5C(void); +void LinkRfu_StopManagerAndFinalizeSlots(void); bool32 sub_80FA5D4(void); bool32 sub_80FC1CC(void); bool32 WaitRfuState(bool32 a0); @@ -204,7 +204,7 @@ void RequestDisconnectSlotByTrainerNameAndId(const u8 *trainerName, u16 trainerI void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void InitializeRfuLinkManager_JoinGroup(void); void LinkRfuNIsend8(void); -void CreateTask_sub_80FBE80(const u8 *src, u16 trainerId); +void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); void UpdateGameDataWithActivitySpriteGendersFlag(u8 activity, u32 child_sprite_genders, u32 started); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(); @@ -213,8 +213,8 @@ void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void sub_80F8FA0(void); void RfuUpdatePlayerGnameStateAndSend(u32 type, u32 species, u32 level); -bool32 sub_80FBB0C(void); -void sub_80FBC00(void); +bool32 IsUnionRoomListenTaskActive(void); +void InitializeRfuLinkManager_EnterUnionRoom(void); void sub_80FBD6C(u32 a0); void sub_80FC114(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); -- cgit v1.2.3