summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/AgbRfu_LinkManager.h200
-rw-r--r--include/gba/defines.h1
-rw-r--r--include/librfu.h64
-rw-r--r--include/link_rfu.h155
-rw-r--r--include/trade.h4
-rw-r--r--include/union_room.h4
6 files changed, 319 insertions, 109 deletions
diff --git a/include/AgbRfu_LinkManager.h b/include/AgbRfu_LinkManager.h
new file mode 100644
index 000000000..d4ef13183
--- /dev/null
+++ b/include/AgbRfu_LinkManager.h
@@ -0,0 +1,200 @@
+#ifndef GUARD_LINKMANAGER_H
+#define GUARD_LINKMANAGER_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.
+
+// Value of lman.p_c_switch_flag
+#define PCSWITCH_1ST_SC_START 0x01
+#define PCSWITCH_1ST_SC 0x02
+#define PCSWITCH_2ND_SP_START 0x03
+#define PCSWITCH_2ND_SP 0x04
+#define PCSWITCH_3RD_SC_START 0x05
+#define PCSWITCH_3RD_SC 0x06
+#define PCSWITCH_CP 0x07
+#define PCSWITCH_SC_LOCK 0x08
+#define PCSWITCH_FORCE_SP_START 0x09
+
+// Period for which parent-child switching search specified
+#define PCSWITCH_ALL_PERIOD 180 // Entire cycle 180 frames
+#define PCSWITCH_SP_PERIOD 40 // Child period 40 frames
+
+// 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.
+
+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;
+
+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;
+
+extern struct linkManagerTag lman;
+
+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);
+
+#endif //GUARD_LINKMANAGER_H
diff --git a/include/gba/defines.h b/include/gba/defines.h
index 9bd695aaa..2df9a3feb 100644
--- a/include/gba/defines.h
+++ b/include/gba/defines.h
@@ -9,6 +9,7 @@
#define BSS_DATA __attribute__((section(".bss")))
#define IWRAM_DATA __attribute__((section("iwram_data")))
#define EWRAM_DATA __attribute__((section("ewram_data")))
+#define UNUSED __attribute__((unused))
#if MODERN
#define NOINLINE __attribute__((noinline))
diff --git a/include/librfu.h b/include/librfu.h
index 39cc68319..1baa4253e 100644
--- a/include/librfu.h
+++ b/include/librfu.h
@@ -4,10 +4,10 @@
#include "global.h"
#include "main.h"
-/* TODOs:
+#define LIBRFU_VERSION 1026
+
+/* TODOs:
* - documentation
- * - decompile librfu_intr.s once arm support is back again
- (for internal structs not documented in SDK)
* - check if any field needs to be volatile
* - check if field names make sense
*/
@@ -70,6 +70,7 @@
#define ID_CPR_POLL_REQ 0x0033
#define ID_CPR_END_REQ 0x0034
#define ID_UNK35_REQ 0x0035 // not defined in SDK header
+#define ID_UNK36_REQ 0x0036 // not defined in SDK header
#define ID_RESUME_RETRANSMIT_AND_CHANGE_REQ 0x0037
#define ID_STOP_MODE_REQ 0x003d
#define ID_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA_REQ 0x00ff // When the AGB is the clock slave, the RFU generates an informational notice, and an automatically started DMA, such as HDMA, is generated at the instant the AGB is being returned as the clock master. This ID is notified by a REQ callback when the exchange of this information (REQ command) fails.
@@ -89,8 +90,13 @@
#define RFU_MBOOT_DOWNLOADER_SERIAL_NO 0x0000 // The game serial number of the multi-boot downloader (programs that boot without a Game Pak)
+#if LIBRFU_VERSION >= 1028
#define RFU_API_BUFF_SIZE_RAM 0x0e8c // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in RAM)
#define RFU_API_BUFF_SIZE_ROM 0x052c // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in ROM)
+#else
+#define RFU_API_BUFF_SIZE_RAM 0x0e64 // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in RAM)
+#define RFU_API_BUFF_SIZE_ROM 0x0504 // Necessary size for buffer specified by rfu_initializeAPI (fast communication version that operates the library SIO interrupt routines in ROM)
+#endif
#define RFU_CHILD_MAX 4 // Maximum number of slaves that can be connected to one parent device
@@ -303,7 +309,11 @@ struct STWIStatus
u8 ackActiveCommand;
u8 timerSelect;
u8 unk_b;
- s32 timerState; // this field is u32 in firered
+#if LIBRFU_VERSION >= 1026
+ s32 timerState;
+#else
+ u32 timerState;
+#endif
vu8 timerActive;
u8 unk_11;
vu16 error;
@@ -313,10 +323,10 @@ struct STWIStatus
u8 unk_17;
void (*callbackM)();
void (*callbackS)(u16);
- void (*unk_20)(void);
+ void (*callbackID)(void);
union RfuPacket *txPacket;
union RfuPacket *rxPacket;
- vu8 unk_2c;
+ vu8 sending;
};
// This struct is used as u8 array in SDK.
@@ -451,54 +461,32 @@ struct RfuStatic
u8 nullFrameCount;
u8 emberCount;
u8 SCStartFlag;
- u8 linkEmergencyFlag[4];
- u8 lsFixedCount[4];
- u16 cidBak[4];
- u16 unk_1a;
+ u8 linkEmergencyFlag[RFU_CHILD_MAX];
+ u8 lsFixedCount[RFU_CHILD_MAX];
+ u16 cidBak[RFU_CHILD_MAX];
+ u16 linkEmergencyLimit;
u16 reqResult;
u16 tryPid;
u16 watchdogTimer;
u32 totalPacketSize;
};
-struct RfuSIO32Id
-{
- u8 unk0;
- u8 unk1;
- u16 unk2;
- u16 unk4;
- u16 unk6;
- u16 unk8; // unused
- u16 unkA;
-};
-
-struct RfuAPIBuffer
-{
- struct RfuLinkStatus linkStatus;
- struct RfuStatic static_;
- struct RfuFixed fixed;
- struct RfuSlotStatusNI NI[RFU_CHILD_MAX];
- struct RfuSlotStatusUNI UNI[RFU_CHILD_MAX];
- struct RfuIntrStruct intr;
-};
-
extern struct STWIStatus *gSTWIStatus;
extern struct RfuLinkStatus *gRfuLinkStatus;
extern struct RfuStatic *gRfuStatic;
extern struct RfuFixed *gRfuFixed;
extern struct RfuSlotStatusNI *gRfuSlotStatusNI[RFU_CHILD_MAX];
extern struct RfuSlotStatusUNI *gRfuSlotStatusUNI[RFU_CHILD_MAX];
-extern struct RfuSIO32Id gRfuSIO32Id;
-// librfu_s32id
-s32 AgbRFU_checkID(u8);
+// librfu_sio32id
+s32 AgbRFU_checkID(u8 maxTries);
// Arguments with "bm..." specify slots of the form (0x01 << slot number) that are the object of a function operation.
// librfu_rfu
// API Initialization and Initial Settings
// API Initialization
-u16 rfu_initializeAPI(struct RfuAPIBuffer *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam);
+u16 rfu_initializeAPI(u32 *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam);
// Set Timer Interrupt
void rfu_setTimerInterrupt(u8 timerNo, IntrFunc *timerIntrTable_p);
// Resident Function called from within a V-Blank Interrupt
@@ -599,7 +587,7 @@ u16 rfu_MBOOT_CHILD_inheritanceLinkStatus(void);
// For Debug
// Obtain address of the SWTI-layer receive buffer
-struct RfuIntrStruct *rfu_getSTWIRecvBuffer(void);
+u8 *rfu_getSTWIRecvBuffer(void);
// Obtain RFU state
void rfu_REQ_RFUStatus(void);
u16 rfu_getRFUStatus(u8 *rfuState);
@@ -625,14 +613,14 @@ void STWI_send_DataRxREQ(void);
void STWI_send_MS_ChangeREQ(void);
void STWI_send_StopModeREQ(void);
void STWI_send_SystemStatusREQ(void);
-void STWI_send_GameConfigREQ(const u8 *unk1, const u8 *data);
+void STWI_send_GameConfigREQ(const u8 *serial_uname, const u8 *gname);
void STWI_send_ResetREQ(void);
void STWI_send_LinkStatusREQ(void);
void STWI_send_VersionStatusREQ(void);
void STWI_send_SlotStatusREQ(void);
void STWI_send_ConfigStatusREQ(void);
void STWI_send_ResumeRetransmitAndChangeREQ(void);
-void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3);
+void STWI_send_SystemConfigREQ(u16 availSlotFlag, u8 maxMFrame, u8 mcTimer);
void STWI_send_SC_StartREQ(void);
void STWI_send_SC_PollingREQ(void);
void STWI_send_SC_EndREQ(void);
diff --git a/include/link_rfu.h b/include/link_rfu.h
index 0c169dd26..2d74e686a 100644
--- a/include/link_rfu.h
+++ b/include/link_rfu.h
@@ -3,35 +3,40 @@
#include "librfu.h"
#include "link.h"
+#include "AgbRfu_LinkManager.h"
// Exported type declarations
-struct UnkLinkRfuStruct_02022B14Substruct
+// 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; // never read, redundant with isChampion
- u16 unk_01_2:4; // always 3?
+ u16 gameClear:1;
+ u16 version:4;
u16 unk_01_6:2;
u8 playerTrainerId[2];
};
-struct __attribute__((packed, aligned(2))) UnkLinkRfuStruct_02022B14
+struct __attribute__((packed, aligned(2))) GFtgtGname
{
- struct UnkLinkRfuStruct_02022B14Substruct unk_00;
- u8 unk_04[4];
+ 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 unk_0a_0:7;
- u8 unk_0a_7:1;
+ u8 activity:7;
+ u8 started:1;
u8 playerGender:1;
u8 level:7;
- u8 unk_0c;
-};
+ u8 padding;
+}; // size: RFU_GNAME_SIZE
struct UnkLinkRfuStruct_02022B2C
{
@@ -40,7 +45,7 @@ struct UnkLinkRfuStruct_02022B2C
u16 unk_02;
u8 unk_04;
u16 unk_06;
- struct UnkLinkRfuStruct_02022B14 *unk_08;
+ struct GFtgtGname *unk_08;
u8 *unk_0c;
u8 unk_10;
u8 unk_11;
@@ -62,50 +67,6 @@ struct UnkLinkRfuStruct_02022B44
u8 fill_84[0x58];
};
-struct UnkRfuStruct_1
-{
- /* 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;
- // 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[4];
- /* 0x030 */ u8 unk_30;
- // aligned
- /* 0x032 */ u16 unk_32;
- /* 0x034 */ u16 unk_34[4];
- /* 0x03c */ const struct UnkLinkRfuStruct_02022B2C *unk_3c;
- /* 0x040 */ void (*unk_40)(u8, u8);
- /* 0x044 */ void (*unk_44)(u16);
- /* 0x048 */ u8 filler_48[8];
- /* 0x050 */ u32 unk_50[0x399];
- /* 0xeb4 */ u8 filler_e64[12];
-};
-
struct UnkRfuStruct_2_Sub_6c
{
/* 0x00 */ u16 unk_00;
@@ -187,7 +148,7 @@ struct UnkRfuStruct_2
/* 0x100 */ u16 unk_100;
/* 0x102 */ u8 unk_102;
/* 0x103 */ u8 filler_103[0x10A - 0x103];
- /* 0x10A */ struct UnkLinkRfuStruct_02022B14 unk_10A;
+ /* 0x10A */ struct GFtgtGname unk_10A;
u8 filler_;
u8 playerName[PLAYER_NAME_LENGTH + 1];
/* 0x124 */ struct UnkRfuStruct_2_Sub_124 unk_124;
@@ -235,13 +196,13 @@ struct UnkRfuStruct_8010A14
// Exported RAM declarations
-extern struct UnkRfuStruct_1 gUnknown_03004140;
-extern struct UnkRfuStruct_2 gUnknown_03005000;
+extern struct GFtgtGname gUnknown_02022B14;
+extern u8 gUnknown_02022B22[];
+extern struct UnkRfuStruct_2 Rfu;
extern u8 gWirelessStatusIndicatorSpriteId;
// Exported ROM declarations
void WipeTrainerNameRecords(void);
-u32 sub_800BEC0(void);
void sub_800E700(void);
void sub_800EDD4(void);
void sub_800F6FC(u8 who);
@@ -270,12 +231,12 @@ u32 GetRfuRecvQueueLength(void);
void RfuVSync(void);
void sub_80111B0(bool32 a0);
u8 sub_8011A74(void);
-struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void);
+struct GFtgtGname *sub_800F7DC(void);
void sub_8011068(u8 a0);
void sub_8011170(u32 a0);
void sub_8011A64(u8 a0, u16 a1);
u8 sub_801048C(bool32 a0);
-void sub_800DF90(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2);
+void sub_800DF90(struct GFtgtGname *buff1, u8 *buff2);
void sub_8010F84(u8 a0, u32 a1, u32 a2);
void sub_8011C10(u32 a0);
bool32 sub_8012240(void);
@@ -300,15 +261,15 @@ void sub_8010FA0(bool32 a0, bool32 a1);
void sub_8010F60(void);
void sub_8010FCC(u32 a0, u32 a1, u32 a2);
void sub_8011C84(void);
-void sub_8012188(const u8 *name, struct UnkLinkRfuStruct_02022B14 *structPtr, u8 a2);
+void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2);
bool32 sub_8011B90(void);
void sub_800FE50(void *a0);
bool32 sub_800E540(u16 id, u8 *name);
void sub_8011DE0(u32 arg0);
u8 sub_801100C(s32 a0);
void sub_800EF7C(void);
-bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx);
-bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx);
+bool8 sub_800DE7C(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
+bool8 sub_800DF34(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
s32 sub_800E87C(u8 idx);
void sub_8011BA4(void);
void sub_8010198(void);
@@ -318,5 +279,65 @@ bool32 sub_8011A9C(void);
void sub_80104B0(void);
void sub_8011A50(void);
void sub_80110B8(u32 a0);
+bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2);
+void sub_800EAB4(void);
+void sub_800EAFC(void);
+void sub_800ED34(u16 unused);
+void sub_800EDBC(u16 unused);
+void sub_800F048(void);
+void sub_800F86C(u8 unused);
+void sub_800FCC4(struct UnkRfuStruct_2_Sub_6c *data);
+void sub_800FD14(u16 command);
+void rfufunc_80F9F44(void);
+void sub_800FFB0(void);
+void rfufunc_80FA020(void);
+bool32 sub_8010454(u32 a0);
+void sub_8010528(void);
+void sub_8010750(void);
+s32 sub_80107A0(void);
+void sub_801084C(u8 taskId);
+void sub_80109E8(u16 a0);
+void sub_8010A70(void *a0);
+void sub_8010AAC(u8 taskId);
+void sub_8010D0C(u8 taskId);
+void sub_80115EC(s32 a0);
+u8 sub_8011CE4(const u8 *a0, u16 a1);
+void sub_8011D6C(u32 a0);
+void sub_8011E94(u32 a0, u32 a1);
+bool8 sub_8012224(void);
+void sub_801227C(void);
+void sub_801209C(u8 taskId);
+void sub_8011BF8(void);
+void sub_8011BA4(void);
+void sub_800D6C8(struct UnkRfuStruct_2_Sub_124 *ptr);
+void sub_800D724(struct UnkRfuStruct_2_Sub_9e8 *ptr);
+void sub_800D780(struct UnkRfuStruct_Sub_Unused *ptr);
+void sub_800D7D8(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2);
+void sub_800D888(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2);
+bool8 sub_800D934(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2);
+bool8 sub_800D9DC(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2);
+void sub_800DA68(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2);
+bool8 sub_800DAC8(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2);
+void sub_800DB18(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2);
+bool8 sub_800DB84(struct UnkRfuStruct_Sub_Unused *q1, u8 *q2);
+void sub_800DBF8(u8 *q1, u8 mode);
+void PkmnStrToASCII(u8 *q1, const u8 *q2);
+void ASCIIToPkmnStr(u8 *q1, const u8 *q2);
+u8 sub_800DD1C(u8 maxFlags);
+void sub_800DD94(struct GFtgtGname *data, u8 r9, bool32 r2, s32 r3);
+bool8 sub_800DE7C(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
+bool8 sub_800DF34(struct GFtgtGname *buff1, u8 *buff2, u8 idx);
+void sub_800DF90(struct GFtgtGname *buff1, u8 *buff2);
+void CreateWirelessStatusIndicatorSprite(u8 x, u8 y);
+void DestroyWirelessStatusIndicatorSprite(void);
+void LoadWirelessStatusIndicatorSpriteGfx(void);
+u8 sub_800E124(void);
+void sub_800E15C(struct Sprite *sprite, s32 signalStrengthAnimNum);
+void sub_800E174(void);
+void CopyTrainerRecord(struct TrainerNameRecord *dest, u32 trainerId, const u8 *name);
+bool32 NameIsNotEmpty(const u8 *name);
+void RecordMixTrainerNames(void);
+bool32 sub_800E540(u16 id, u8 *name);
+void WipeTrainerNameRecords(void);
#endif //GUARD_LINK_RFU_H
diff --git a/include/trade.h b/include/trade.h
index 72a04ed21..bd8ef8f63 100644
--- a/include/trade.h
+++ b/include/trade.h
@@ -16,8 +16,8 @@ extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate;
s32 GetGameProgressForLinkTrade(void);
void CB2_StartCreateTradeMenu(void);
void CB2_LinkTrade(void);
-int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, u16, u16, u8);
-int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6);
+int CanRegisterMonForTradingBoard(struct GFtgtGnameSub a0, u16, u16, u8);
+int GetUnionRoomTradeMessageId(struct GFtgtGnameSub a0, struct GFtgtGnameSub a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6);
int CanSpinTradeMon(struct Pokemon*, u16);
void InitTradeSequenceBgGpuRegs(void);
void LinkTradeDrawWindow(void);
diff --git a/include/union_room.h b/include/union_room.h
index cc0415155..4c4cb5a62 100644
--- a/include/union_room.h
+++ b/include/union_room.h
@@ -7,7 +7,7 @@
struct UnkStruct_Shared
{
- struct UnkLinkRfuStruct_02022B14 field_0;
+ struct GFtgtGname field_0;
u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH + 1];
};
@@ -154,7 +154,7 @@ struct UnionRoomTrade
extern u8 gUnknown_02022C2C;
extern union UnkUnion_Main gUnknown_02022C30;
-extern struct UnkLinkRfuStruct_02022B14Substruct gUnknown_02022C38;
+extern struct GFtgtGnameSub gUnknown_02022C38;
extern u16 gUnionRoomOfferedSpecies;
extern u8 gUnionRoomRequestedMonType;