summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/AgbRfu_LinkManager.h245
-rw-r--r--include/berry_crush.h2
-rw-r--r--include/constants/easy_chat.h17
-rw-r--r--include/constants/union_room.h45
-rw-r--r--include/digit_obj_util.h24
-rw-r--r--include/dodrio_berry_picking.h2
-rw-r--r--include/ereader_helpers.h36
-rw-r--r--include/event_data.h4
-rw-r--r--include/event_object_80688E4.h10
-rw-r--r--include/event_object_lock.h2
-rw-r--r--include/fieldmap.h2
-rw-r--r--include/global.h23
-rw-r--r--include/help_system.h34
-rw-r--r--include/librfu.h55
-rw-r--r--include/link.h22
-rw-r--r--include/link_rfu.h333
-rw-r--r--include/menu.h2
-rw-r--r--include/mevent.h41
-rw-r--r--include/mevent_server.h1
-rw-r--r--include/overworld.h4
-rw-r--r--include/pokemon_jump.h2
-rw-r--r--include/rfu_union_tool.h17
-rw-r--r--include/script.h2
-rw-r--r--include/sprite.h2
-rw-r--r--include/strings.h26
-rw-r--r--include/union_room.h82
-rw-r--r--include/union_room_battle.h6
-rw-r--r--include/union_room_message.h40
-rw-r--r--include/unk_810c3a4.h26
-rw-r--r--include/unk_815C980.h24
-rw-r--r--include/unk_815c27c.h11
-rw-r--r--include/vs_seeker.h3
32 files changed, 678 insertions, 467 deletions
diff --git a/include/AgbRfu_LinkManager.h b/include/AgbRfu_LinkManager.h
new file mode 100644
index 000000000..0970a4233
--- /dev/null
+++ b/include/AgbRfu_LinkManager.h
@@ -0,0 +1,245 @@
+#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.
+
+// 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;
+
+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/berry_crush.h b/include/berry_crush.h
index 2583aba61..e8e9c216f 100644
--- a/include/berry_crush.h
+++ b/include/berry_crush.h
@@ -1,6 +1,6 @@
#ifndef GUARD_BERRY_CRUSH_H
#define GUARD_BERRY_CRUSH_H
-void sub_814B754(MainCallback callback);
+void StartBerryCrush(MainCallback callback);
#endif //GUARD_BERRY_CRUSH_H
diff --git a/include/constants/easy_chat.h b/include/constants/easy_chat.h
index 4ef90ed60..7261365c2 100644
--- a/include/constants/easy_chat.h
+++ b/include/constants/easy_chat.h
@@ -6,22 +6,7 @@
#define EASY_CHAT_TYPE_BATTLE_WON 2
#define EASY_CHAT_TYPE_BATTLE_LOST 3
#define EASY_CHAT_TYPE_MAIL 4
-#define EASY_CHAT_TYPE_INTERVIEW 5
-#define EASY_CHAT_TYPE_BARD_SONG 6
-#define EASY_CHAT_TYPE_FAN_CLUB 7
-#define EASY_CHAT_TYPE_UNK_8 8
-#define EASY_CHAT_TYPE_TRENDY_PHRASE 9
-#define EASY_CHAT_TYPE_GABBY_AND_TY 10
-#define EASY_CHAT_TYPE_CONTEST_INTERVIEW 11
-#define EASY_CHAT_TYPE_BATTLE_TOWER_INTERVIEW 12
-#define EASY_CHAT_TYPE_GOOD_SAYING 13
-#define EASY_CHAT_TYPE_FAN_QUESTION 14
-#define EASY_CHAT_TYPE_QUIZ_ANSWER 15
-#define EASY_CHAT_TYPE_QUIZ_QUESTION 16
-#define EASY_CHAT_TYPE_QUIZ_SET_QUESTION 17
-#define EASY_CHAT_TYPE_QUIZ_SET_ANSWER 18
-#define EASY_CHAT_TYPE_APPRENTICE 19
-#define EASY_CHAT_TYPE_QUESTIONNAIRE 20
+#define EASY_CHAT_TYPE_QUESTIONNAIRE 14
#define EC_GROUP_POKEMON_2 0x0
#define EC_GROUP_TRAINER 0x1
diff --git a/include/constants/union_room.h b/include/constants/union_room.h
index 021424773..b23860645 100644
--- a/include/constants/union_room.h
+++ b/include/constants/union_room.h
@@ -1,6 +1,48 @@
#ifndef GUARD_CONSTANTS_UNION_ROOM_H
#define GUARD_CONSTANTS_UNION_ROOM_H
+#define UNION_ROOM_SPAWN_NONE 0
+#define UNION_ROOM_SPAWN_IN 1
+#define UNION_ROOM_SPAWN_OUT 2
+
+#define ACTIVITY_NONE 0
+#define ACTIVITY_BATTLE 1
+#define ACTIVITY_DBLBATTLE 2
+#define ACTIVITY_MLTBATTLE 3
+#define ACTIVITY_TRADE 4
+#define ACTIVITY_CHAT 5
+#define ACTIVITY_WCARD 6
+#define ACTIVITY_WNEWS 7
+#define ACTIVITY_CARD 8
+#define ACTIVITY_PJUMP 9
+#define ACTIVITY_BCRUSH 10
+#define ACTIVITY_BPICK 11
+#define ACTIVITY_SEARCH 12
+#define ACTIVITY_SPINTRADE 13
+#define ACTIVITY_ITEMTRADE 14
+
+// Player response
+#define ACTIVITY_ACCEPT 17
+#define ACTIVITY_DECLINE 18
+
+#define ACTIVITY_NPCTALK 19
+#define ACTIVITY_PLYRTALK 20
+
+// Duplicate IDs?
+#define ACTIVITY_WCARD2 21
+#define ACTIVITY_WNEWS2 22
+
+#define IN_UNION_ROOM 0x40
+
+// Used in UR_AddTextPrinterParameterized
+#define UR_COLOR_DKE_WHT_LTE 0
+#define UR_COLOR_RED_WHT_LTR 1
+#define UR_COLOR_GRN_WHT_LTG 2
+#define UR_COLOR_WHT_WHT_LTE 3
+#define UR_COLOR_WHT_DKE_LTE 4
+#define UR_COLOR_GRN_DN6_LTB 5
+#define UR_COLOR_DN5_DN6_LTB 6
+
#define LINK_GROUP_SINGLE_BATTLE 0
#define LINK_GROUP_DOUBLE_BATTLE 1
#define LINK_GROUP_MULTI_BATTLE 2
@@ -12,4 +54,7 @@
#define LINK_GROUP_WONDER_NEWS 8
#define NUM_LINK_GROUP_TYPES 9
+#define LINK_GROUP_UNION_ROOM_RESUME 9
+#define LINK_GROUP_UNION_ROOM_INIT 10
+
#endif //GUARD_CONSTANTS_UNION_ROOM_H
diff --git a/include/digit_obj_util.h b/include/digit_obj_util.h
new file mode 100644
index 000000000..b2ecd42bc
--- /dev/null
+++ b/include/digit_obj_util.h
@@ -0,0 +1,24 @@
+#ifndef GUARD_DIGIT_OBJ_UTIL_H
+#define GUARD_DIGIT_OBJ_UTIL_H
+
+struct DigitObjUtilTemplate
+{
+ u8 strConvMode:2;
+ u8 shape:2;
+ u8 size:2;
+ u8 priority:2;
+ u8 oamCount;
+ u8 xDelta;
+ s16 x;
+ s16 y;
+ const struct SpriteSheet *spriteSheet;
+ const struct SpritePalette *spritePal;
+};
+
+void DigitObjUtil_Teardown(void);
+bool32 DigitObjUtil_CreatePrinter(u32 id, s32 num, const struct DigitObjUtilTemplate *template);
+void DigitObjUtil_PrintNumOn(u32 id, s32 num);
+void DigitObjUtil_DeletePrinter(u32 id);
+void DigitObjUtil_HideOrShow(u32 id, bool32 hide);
+
+#endif //GUARD_DIGIT_OBJ_UTIL_H
diff --git a/include/dodrio_berry_picking.h b/include/dodrio_berry_picking.h
index 59736ba7a..47cece996 100644
--- a/include/dodrio_berry_picking.h
+++ b/include/dodrio_berry_picking.h
@@ -1,6 +1,6 @@
#ifndef GUARD_DODRIO_BERRY_PICKING_H
#define GUARD_DODRIO_BERRY_PICKING_H
-void sub_81507FC(u16 species, MainCallback callback);
+void StartDodrioBerryPicking(u16 species, MainCallback callback);
#endif //GUARD_DODRIO_BERRY_PICKING_H
diff --git a/include/ereader_helpers.h b/include/ereader_helpers.h
new file mode 100644
index 000000000..dab97470a
--- /dev/null
+++ b/include/ereader_helpers.h
@@ -0,0 +1,36 @@
+#ifndef GUARD_EREADER_HELPERS_H
+#define GUARD_EREADER_HELPERS_H
+
+enum {
+ EREADER_XFR_STATE_INIT = 0,
+ EREADER_XFR_STATE_HANDSHAKE,
+ EREADER_XFR_STATE_START,
+ EREADER_XFR_STATE_TRANSFER,
+ EREADER_XFR_STATE_TRANSFER_DONE,
+ EREADER_XFR_STATE_CHECKSUM,
+ EREADER_XFR_STATE_DONE
+};
+
+#define EREADER_XFER_EXE 1
+#define EREADER_XFER_CHK 2
+#define EREADER_XFER_SHIFT 0
+#define EREADER_XFER_MASK 3
+
+#define EREADER_CANCEL_TIMEOUT 1
+#define EREADER_CANCEL_KEY 2
+#define EREADER_CANCEL_MASK 0xC
+#define EREADER_CANCEL_SHIFT 2
+
+#define EREADER_CHECKSUM_OK 1
+#define EREADER_CHECKSUM_ERR 2
+#define EREADER_CHECKSUM_MASK 0x30
+#define EREADER_CHECKSUM_SHIFT 4
+
+void EReaderHelper_SerialCallback(void);
+void EReaderHelper_Timer3Callback(void);
+void EReaderHelper_SaveRegsState(void);
+void EReaderHelper_ClearsSendRecvMgr(void);
+void EReaderHelper_RestoreRegsState(void);
+u16 EReaderHandleTransfer(u8 mode, size_t size, const void * src, void * dest);
+
+#endif //GUARD_EREADER_HELPERS_H
diff --git a/include/event_data.h b/include/event_data.h
index 7987720f1..e635cbc6d 100644
--- a/include/event_data.h
+++ b/include/event_data.h
@@ -54,8 +54,8 @@ bool8 FlagGet(u16 id);
u16 * GetVarPointer(u16 id);
bool32 IsMysteryGiftEnabled(void);
void ResetSpecialVars(void);
-void sub_806E2D0(void);
-void sub_806E370(void);
+void ResetMysteryEventFlags(void);
+void ResetMysteryEventVars(void);
bool32 IsNationalPokedexEnabled(void);
void sub_806E190(void);
diff --git a/include/event_object_80688E4.h b/include/event_object_80688E4.h
index a3da168b4..241d48c3a 100644
--- a/include/event_object_80688E4.h
+++ b/include/event_object_80688E4.h
@@ -6,10 +6,10 @@
void FreezeObjectEvents(void);
bool8 FreezeObjectEvent(struct ObjectEvent *);
void FreezeObjectEventsExceptOne(u8 objEventId);
-void RfuUnionObjectToggleInvisibility(u8 a0, bool32 a1);
-u32 RfuUnionObjectIsInvisible(u8 a0);
-void RfuUnionObjectStartWarp(u8 a0, u8 a1);
-void RfuUnionObjectSetFacingDirection(u8 a0, u8 a1);
-bool32 RfuUnionObjectIsWarping(u8 a0);
+void RfuUnionObjectSetFacingDirection(u8 objectEventId, u8 direction);
+void RfuUnionObjectToggleInvisibility(u8 objectEventId, bool32 invisible);
+bool32 RfuUnionObjectIsInvisible(u8 objectEventId);
+void RfuUnionObjectStartWarp(u8 objectEventId, u8 animNo);
+bool32 RfuUnionObjectIsWarping(u8 objectEventId);
#endif // GUARD_EVENT_OBJECT_80688E4_H
diff --git a/include/event_object_lock.h b/include/event_object_lock.h
index 5c65585b5..1a0f452fc 100644
--- a/include/event_object_lock.h
+++ b/include/event_object_lock.h
@@ -11,6 +11,6 @@ void sub_8098630(void);
bool8 sub_8098734(void);
void sub_80696C0(void);
bool8 walkrun_is_standing_still(void);
-void sub_80696F0(void);
+void UnionRoom_UnlockPlayerAndChatPartner(void);
#endif // GUARD_EVENT_OBJECT_LOCK_H
diff --git a/include/fieldmap.h b/include/fieldmap.h
index 91a45d8c5..406ec2959 100644
--- a/include/fieldmap.h
+++ b/include/fieldmap.h
@@ -31,6 +31,6 @@ void sub_8059948(u8 a0, u8 a1);
void save_serialize_map(void);
u32 sub_8058F1C(u32 original, u8 bit);
u32 sub_8058F48(s16 x, s16 y, u8 z);
-void sub_8059024(s32 x, s32 y, bool32 arg2);
+void MapGridSetMetatileImpassabilityAt(s32 x, s32 y, bool32 arg2);
#endif //GUARD_FIELDMAP_H
diff --git a/include/global.h b/include/global.h
index a0027f9dc..8644fe364 100644
--- a/include/global.h
+++ b/include/global.h
@@ -74,8 +74,8 @@
// GameFreak never ceases to amaze.
// TODO: Propagate use of this macro
#define TEST_BUTTON(field, button) ({(field) & (button);})
-#define JOY_NEW(button) TEST_BUTTON(gMain.newKeys, button)
-#define JOY_HELD(button) TEST_BUTTON(gMain.heldKeys, button)
+#define JOY_NEW(button) TEST_BUTTON(gMain.newKeys, button)
+#define JOY_HELD(button) TEST_BUTTON(gMain.heldKeys, button)
#define JOY_REPT(button) TEST_BUTTON(gMain.newAndRepeatedKeys, button)
extern u8 gStringVar1[];
@@ -658,8 +658,8 @@ struct FameCheckerSaveData
struct MEWonderNewsData
{
- u16 unk_00;
- u8 unk_02;
+ u16 newsId;
+ u8 shareState;
u8 unk_03;
u8 unk_04[40];
u8 unk_2C[10][40];
@@ -673,13 +673,13 @@ struct MEWonderNewsStruct
struct MEWonderCardData
{
- u16 unk_00;
+ u16 cardId;
u16 unk_02;
u32 unk_04;
u8 unk_08_0:2;
u8 unk_08_2:4;
- u8 unk_08_6:2;
- u8 unk_09;
+ u8 shareState:2;
+ u8 recvMonCapacity;
u8 unk_0A[40];
u8 unk_32[40];
u8 unk_5A[4][40];
@@ -695,11 +695,12 @@ struct MEWonderCardStruct
struct MEventBuffer_3430_Sub
{
- u16 unk_00;
- u16 unk_02;
- u16 unk_04;
+ u16 linkWins;
+ u16 linkLosses;
+ u16 linkTrades;
u16 unk_06;
- u16 unk_08[2][7];
+ u16 distributedMons[2][7]; // [0][x] = species
+ // [1][x] = ???
};
struct MEventBuffer_3430
diff --git a/include/help_system.h b/include/help_system.h
index 59adec912..c5ae5e5fa 100644
--- a/include/help_system.h
+++ b/include/help_system.h
@@ -17,16 +17,16 @@ struct HelpSystemListMenu_sub
struct HelpSystemListMenu
{
struct HelpSystemListMenu_sub sub;
- u8 field_0C;
- u8 field_0D;
- u8 field_0E;
+ u8 itemsAbove;
+ u8 cursorPos;
+ u8 state;
u8 filler_10[0xC];
};
extern struct HelpSystemListMenu gHelpSystemListMenu;
extern struct ListMenuItem gHelpSystemListMenuItems[];
extern bool8 gHelpSystemEnabled;
-extern u8 gUnknown_203F175;
+extern bool8 gHelpSystemToggleWithRButtonDisabled;
// help_system_812B1E0
void HelpSystem_SetSomeVariable(u8);
@@ -35,19 +35,19 @@ bool8 sub_812B40C(void);
bool8 sub_812B45C(void);
void HelpSystem_Disable(void);
void HelpSystem_Enable(void);
-void sub_812B4B8(void);
-bool8 sub_812BB9C(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BC54(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BC80(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BCA8(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BCD0(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BD2C(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BD64(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BD98(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
+void HelpSystem_EnableToggleWithRButton(void);
+bool8 RunHelpMenuSubroutine(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpSystemSubroutine_PrintWelcomeMessage(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpSystemSubroutine_WelcomeWaitButton(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpSystemSubroutine_WelcomeEndGotoMenu(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpSystemSubroutine_MenuInputHandlerMain(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpMenuSubroutine_InitSubmenu(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpMenuSubroutine_ReturnFromSubmenu(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpMenuSubroutine_SubmenuInputHandler(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
void sub_812BDEC(void);
-bool8 sub_812BE10(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BEEC(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
-bool8 sub_812BF18(struct HelpSystemListMenu * a0, struct ListMenuItem * a1);
+bool8 HelpMenuSubroutine_HelpItemPrint(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpMenuSubroutine_ReturnFromHelpItem(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
+bool8 HelpMenuSubroutine_HelpItemWaitButton(struct HelpSystemListMenu * helpListMenu, struct ListMenuItem * listMenuItemsBuffer);
bool8 sub_812BF88(void);
// help_system
@@ -92,6 +92,6 @@ bool8 MoveCursor(u8 by, u8 dirn);
void HelpSystem_BackupSomeVariable(void);
void HelpSystem_RestoreSomeVariable(void);
void HelpSystemRenderText(u8 font, u8 * dest, const u8 * src, u8 x, u8 y, u8 width, u8 height);
-void sub_812B4AC(void);
+void HelpSystem_DisableToggleWithRButton(void);
#endif //GUARD_HELP_SYSTEM_H
diff --git a/include/librfu.h b/include/librfu.h
index 97fd8044e..50dd1c3db 100644
--- a/include/librfu.h
+++ b/include/librfu.h
@@ -4,11 +4,8 @@
#include "global.h"
#include "main.h"
-/* TODOs:
- * - split files
+/* 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
*/
@@ -71,6 +68,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.
@@ -90,8 +88,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
@@ -314,10 +317,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.
@@ -452,54 +455,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);
+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
@@ -600,7 +581,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);
@@ -626,14 +607,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.h b/include/link.h
index 770a60f44..e36ac8078 100644
--- a/include/link.h
+++ b/include/link.h
@@ -246,38 +246,38 @@ void sub_800E0E8(void);
bool8 sub_800A520(void);
bool8 sub_8010500(void);
void sub_800DFB4(u8, u8);
-void sub_800AB9C(void);
-void sub_800B1F4(void);
+void PrepareSendLinkCmd2FFE_or_RfuCmd6600(void);
+void SetWirelessCommType1(void);
void sub_8009734(void);
void sub_800A620(void);
-void sub_80FBB4C(void);
+void LinkRfu_DestroyIdleTask(void);
u8 sub_800ABAC(void);
u8 sub_800ABBC(void);
-void sub_800AAC0(void);
+void Link_TryStartSend5FFF(void);
void OpenLink(void);
bool8 IsLinkMaster(void);
void CheckShouldAdvanceLinkState(void);
-void sub_800AA80(u16 a0);
+void Link_StartSend5FFFwithParam(u16 a0);
void sub_80098D8(void);
void CloseLink(void);
bool8 IsLinkTaskFinished(void);
bool32 sub_800B270(void);
void ResetSerial(void);
void sub_8054A28(void);
-void sub_800B1F4(void);
+void SetWirelessCommType1(void);
void LoadWirelessStatusIndicatorSpriteGfx(void);
void CreateWirelessStatusIndicatorSprite(u8, u8);
void sub_8009FE8(void);
void ClearLinkCallback_2(void);
-void sub_80FA42C(void);
-void sub_800B284(struct LinkPlayer * linkPlayer);
+void LinkRfu_SetRfuFuncToSend6600(void);
+void IntlConvertLinkPlayerName(struct LinkPlayer * linkPlayer);
bool8 IsWirelessAdapterConnected(void);
bool8 sub_800A474(u8 a0);
void LinkVSync(void);
bool8 HandleLinkConnection(void);
-void sub_800B0B4(void);
-void sub_800B110(u32 who);
-void sub_800ACBC(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06);
+void PrepareLocalLinkPlayerBlock(void);
+void LinkPlayerFromBlock(u32 who);
+void SetLinkErrorFromRfu(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06);
u8 sub_800A8D4(void);
#endif // GUARD_LINK_H
diff --git a/include/link_rfu.h b/include/link_rfu.h
index 81dd7fdf0..86d55047d 100644
--- a/include/link_rfu.h
+++ b/include/link_rfu.h
@@ -3,169 +3,78 @@
#include "global.h"
#include "librfu.h"
-
-// 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 unk_00_6:1;
- u16 isChampion:1;
- u16 hasNationalDex:1;
- u16 gameClear:1;
- u16 unk_01_2:4;
- u16 unk_01_6:2;
- u8 playerTrainerId[2];
-};
-
-struct __attribute__((packed, aligned(2))) GFtgtGname
-{
- struct GFtgtGnameSub unk_00;
- u8 unk_04[4];
- u16 species:10;
- u16 type:6;
- u8 unk_0a_0:7;
- u8 unk_0a_7:1;
- u8 playerGender:1;
- u8 level:7;
- u8 unk_0c;
-};
-
-struct Padded_U8
-{
- u8 value;
-};
-
-struct UnkLinkRfuStruct_02022B2C
+#include "AgbRfu_LinkManager.h"
+
+#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
{
- 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;
-};
-
-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];
-};
-
-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[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);
-};
-
-struct UnkRfuStruct_2_Sub_6c
-{
- /* 0x00 */ u16 unk_00;
- /* 0x02 */ u16 unk_02;
- /* 0x04 */ const u8 *unk_04;
- /* 0x08 */ u32 unk_08;
- /* 0x0c */ u32 unk_0c;
- /* 0x10 */ u8 unk_10;
- /* 0x11 */ u8 unk_11;
- /* 0x12 */ u8 unk_12;
+ /* 0x00 */ u16 next;
+ /* 0x02 */ u16 count; // max 21
+ /* 0x04 */ const u8 *payload;
+ /* 0x08 */ u32 receivedFlags;
+ /* 0x0c */ u32 failedFlags;
+ /* 0x10 */ u8 sending;
+ /* 0x11 */ u8 owner;
+ /* 0x12 */ u8 receiving;
};
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;
};
-struct UnkRfuStruct_2
+typedef struct UnkRfuStruct_2
{
/* 0x000 */ void (*RfuFunc)(void);
- /* 0x004 */ u16 unk_04;
+ /* 0x004 */ u16 state;
/* 0x006 */ u8 filler_06[4];
- /* 0x00a */ u16 unk_0a;
- /* 0x00c */ u8 unk_0c; // parentChildMode?
+ /* 0x00a */ u16 linkman_msg;
+ /* 0x00c */ u8 parent_child;
/* 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;
@@ -175,30 +84,30 @@ 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];
- /* 0x0e4 */ u8 unk_e4[5];
- /* 0x0e9 */ u8 unk_e9[5];
- /* 0x0ee */ vu8 unk_ee;
+ /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf;
+ /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5];
+ /* 0x0e4 */ u8 cmd5f00Ack[5];
+ /* 0x0e9 */ u8 cmd_6600_recvd[5];
+ /* 0x0ee */ vu8 errorState;
/* 0x0ef */ u8 unk_ef;
- /* 0x0f0 */ u8 unk_f0;
+ /* 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;
- /* 0x8f6 */ vu8 unk_c3e;
+ /* 0x8f5 */ u8 reconnectedParentIdx;
+ /* 0x8f6 */ vu8 child_slot;
/* 0x8f7 */ u8 unk_c3f[70];
/* 0x93d */ u8 unk_c85;
/* 0x93e */ u8 unk_c86;
- /* 0x93f */ u8 unk_c87[5][7][2];
- /* 0x985 */ u8 unk_ccd;
+ /* 0x93f */ u8 recvCmds[5][7][2];
+ /* 0x985 */ u8 parentId;
/* 0x986 */ u8 unk_cce; // childId
/* 0x987 */ u8 unk_ccf;
/* 0x988 */ vu8 unk_cd0;
@@ -209,43 +118,42 @@ struct UnkRfuStruct_2
/* 0x993 */ vu8 unk_cdb;
/* 0x994 */ vu8 unk_cdc;
/* 0x995 */ u8 unk_cdd;
- /* 0x996 */ u8 unk_cde[RFU_CHILD_MAX];
- /* 0x99a */ u8 unk_ce2;
- /* 0x99b */ u8 unk_ce3;
+ /* 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;
- /* 0x99f */ u8 unk_ce7;
+ /* 0x99e */ u8 unionRoomChatters;
+ /* 0x99f */ u8 acceptSlot_flag;
/* 0x9a0 */ bool8 unk_ce8;
/* 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 UnkRfuStruct_1 gUnknown_3005E10;
extern struct GFtgtGname gHostRFUtgtGnameBuffer;
extern u8 gHostRFUtgtUnameBuffer[];
+// GameFreak signatures
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);
void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0);
void MEvent_CreateTask_Leader(u32 arg0);
-void sub_80F9E2C(void * data);
-u8 sub_8116DE0(void);
-void sub_80FBB4C(void);
+void RfuPrepareSend0x2f00(void * data);
+u8 CreateTask_ListenToWireless(void);
+void LinkRfu_DestroyIdleTask(void);
void sub_80F86F4(void);
void sub_80FB128(bool32 a0);
-u32 sub_80FD3A4(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);
@@ -253,78 +161,65 @@ u8 Rfu_GetBlockReceivedStatus(void);
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);
+void ResetLinkRfuGFLayer(void);
+bool32 LinkRfuMain1(void);
+bool32 LinkRfuMain2(void);
bool32 IsRfuRecvQueueEmpty(void);
u32 GetRfuRecvQueueLength(void);
-void sub_80F8DC0(void);
-void sub_80FBB20(void);
+void LinkRfu_Shutdown(void);
+void LinkRfu_CreateIdleTask(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 sub_80FEB14(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 sub_80FB9E4(u8 a0, u16 a1);
-u8 sub_80FB9F4(void);
-void LinkRfu_REQ_SendData_HandleParentRelationship(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);
-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);
-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 sub_80FAFE0(u8 a0);
-bool32 sub_80FA44C(u32 a0);
+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 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);
+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 started, s32 child_sprite_genders);
+void UpdateGameData_GroupLockedIn(bool8 started);
+bool32 RfuSerialNumberIsValid(u32 a0);
bool8 sub_80FC1B0(void);
-bool8 sub_80F8F40(void);
-void sub_80F8F5C(void);
+bool8 LmanAcceptSlotFlagIsNotZero(void);
+void LinkRfu_StopManagerAndFinalizeSlots(void);
bool32 sub_80FA5D4(void);
bool32 sub_80FC1CC(void);
-bool32 sub_80F8F7C(bool32 a0);
-bool32 sub_80FA634(u16 a0, const u8 *a1);
-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);
+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 RequestDisconnectSlotByTrainerNameAndId(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 InitializeRfuLinkManager_JoinGroup(void);
+void LinkRfuNIsend8(void);
+void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId);
+void UpdateGameDataWithActivitySpriteGendersFlag(u8 activity, u32 child_sprite_genders, u32 started);
void RecordMixTrainerNames(void);
-void sub_80F8CFC();
-void sub_80F8D14();
-void sub_80FAF74(bool32 a0, bool32 a1);
+void LinkRfu_CreateConnectionAsParent();
+void LinkRfu_StopManagerBeforeEnteringChat();
+void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard);
void ClearAndInitHostRFUtgtGname(void);
void sub_80F8FA0(void);
-void sub_80FAFA0(u32 type, u32 species, u32 level);
-bool32 sub_80FBB0C(void);
-void sub_80FBC00(void);
+void RfuUpdatePlayerGnameStateAndSend(u32 type, u32 species, u32 level);
+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);
-bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx);
-bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx);
+bool8 LinkRfu_GetNameIfCompatible(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);
diff --git a/include/menu.h b/include/menu.h
index b6d757f85..49dd43e26 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -30,7 +30,7 @@ s8 sub_812EAE4(u16 species, u32 personality, u8 a2);
// list_menu
void sub_8107CD8(u8 palOffset, u16 speciesId);
void sub_8107CF8(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y);
-void sub_8107D38(u8 palOffset, u8 palId);
+void ListMenuLoadStdPalAt(u8 palOffset, u8 palId);
void BlitMoveInfoIcon(u8 windowId, u8 iconId, u16 x, u16 y);
// menu
diff --git a/include/mevent.h b/include/mevent.h
index 85782f20a..4f3e365f7 100644
--- a/include/mevent.h
+++ b/include/mevent.h
@@ -13,7 +13,7 @@ struct MEventClientHeaderStruct
u16 id;
u16 unk_16[4];
struct MEventBuffer_3430_Sub unk_20;
- u8 unk_44;
+ u8 maxDistributionMons;
u8 playerName[7];
u8 playerTrainerId[4];
u16 easyChatProfile[6];
@@ -33,21 +33,38 @@ struct MEvent_Str_2
u8 fill_00[0x40];
};
+struct UnkStruct_8467FB8
+{
+ u8 textPal1:4;
+ u8 textPal2:4;
+ u8 textPal3:4;
+ u8 index:4;
+ const u8 * tiles;
+ const u8 * map;
+ const u16 * pal;
+};
+
+extern const u16 gCard1Pal[];
+extern const u16 gCard2Pal[];
+extern const u16 gCard3Pal[];
+extern const u16 gCard4Pal[];
+extern const u16 gCard5Pal[];
+
struct MEWonderNewsData * GetSavedWonderNews(void);
struct MEWonderCardData * GetSavedWonderCard(void);
struct MEventBuffer_3430_Sub * sav1_get_mevent_buffer_2(void);
struct MENewsJisanStruct * GetMENewsJisanStructPtr(void);
-bool32 sub_8143DC8(const struct MEWonderNewsData * src);
+bool32 OverwriteSavedWonderNewsWithReceivedNews(const struct MEWonderNewsData * src);
bool32 ValidateReceivedWonderNews(void);
bool32 ValidateReceivedWonderCard(void);
-bool32 sub_8143EF4(const u8 * src);
-bool32 sub_8143F68(const struct MEWonderCardData * data);
-void sub_814410C(struct MEWonderCardData * buffer);
-bool32 sub_8144254(const u16 * data);
+bool32 MEvent_HaveAlreadyReceivedWonderNews(const u8 * src);
+bool32 OverwriteSavedWonderCardWithReceivedCard(const struct MEWonderCardData * data);
+void MEvent_WonderCardResetUnk08_6(struct MEWonderCardData * buffer);
+bool32 MEvent_ReceiveDistributionMon(const u16 * data);
void BuildMEventClientHeader(struct MEventClientHeaderStruct * data);
bool32 ValidateMEventClientHeader(const struct MEventClientHeaderStruct * data);
u32 sub_8144418(const u16 * a0, const struct MEventClientHeaderStruct * a1, void * unused);
-u32 sub_8144434(const u16 * a0, const struct MEventClientHeaderStruct * a1, void * unused);
+u32 MEvent_CanPlayerReceiveDistributionMon(const u16 * a0, const struct MEventClientHeaderStruct * a1, void * unused);
bool32 sub_8144474(const struct MEventClientHeaderStruct * a0, const u16 * a1);
u16 sub_81444B0(const struct MEventClientHeaderStruct * a0, u32 command);
bool32 InitWonderCardResources(struct MEWonderCardData * r5, struct MEventBuffer_3430_Sub * r6);
@@ -66,12 +83,12 @@ void MENews_RemoveScrollIndicatorArrowPair(void);
bool32 WonderNews_Test_Unk_02(void);
bool32 WonderCard_Test_Unk_08_6(void);
u32 MENews_GetInput(u16 input);
-void sub_8143D24(void);
-u16 sub_81445C0(u32 command);
-void sub_8144714(u32 a0, u32 a1);
+void InitMEventData(void);
+u16 MEvent_GetBattleCardCount(u32 command);
+void MEvent_RecordIdOfWonderCardSenderByEventType(u32 eventId, u32 trainerId);
u16 *GetMEventProfileECWordsMaybe(void);
-void sub_81446C4(void);
-bool32 sub_81446D0(u16 a0);
+void ResetReceivedWonderCardFlag(void);
+bool32 MEventHandleReceivedWonderCard(u16 cardId);
u16 GetWonderCardFlagId(void);
#endif //GUARD_MEVENT_H
diff --git a/include/mevent_server.h b/include/mevent_server.h
index 1e9ef7bef..a7c7a3f23 100644
--- a/include/mevent_server.h
+++ b/include/mevent_server.h
@@ -48,6 +48,7 @@ struct mevent_client_cmd
#define CLI_RECVBUF {.instr = 12, .parameter = 0}
#define CLI_REQWORD {.instr = 13, .parameter = 0}
#define CLI_SNDWORD {.instr = 14, .parameter = 0}
+#define CLI_RECVMON {.instr = 16, .parameter = 0}
#define CLI_RECVRAM {.instr = 17, .parameter = 0}
#define CLI_SENDALL {.instr = 20, .parameter = 0}
diff --git a/include/overworld.h b/include/overworld.h
index a7031e56d..8242615c7 100644
--- a/include/overworld.h
+++ b/include/overworld.h
@@ -147,7 +147,7 @@ void Overworld_ResetStateAfterTeleport(void);
void Overworld_FadeOutMapMusic(void);
void CB2_LoadMap(void);
bool8 BGMusicStopped(void);
-bool8 is_light_level_8_or_9(u8 mapType);
+bool8 IsMapTypeIndoors(u8 mapType);
bool32 sub_8055C9C(void);
void Overworld_ResetStateAfterDigEscRope(void);
bool32 sub_8058244(void);
@@ -156,7 +156,7 @@ u8 GetCurrentMapType(void);
u8 get_map_light_from_warp0(void);
const struct MapHeader *warp1_get_mapheader(void);
void sub_8055F88(void);
-void sub_8056788(void);
+void CB2_ReturnToFieldCableClub(void);
void ResetGameStats(void);
void Overworld_CreditsMainCB(void);
diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h
index 0e9094752..fa4105a0e 100644
--- a/include/pokemon_jump.h
+++ b/include/pokemon_jump.h
@@ -5,6 +5,6 @@
void ResetPokeJumpResults(void);
bool32 IsSpeciesAllowedInPokemonJump(u16 species);
-void sub_8147AA8(u16 species, MainCallback callback);
+void StartPokemonJump(u16 species, MainCallback callback);
#endif // GUARD_POKEMON_JUMP_H
diff --git a/include/rfu_union_tool.h b/include/rfu_union_tool.h
index b8b5cd664..7fc7fd4cb 100644
--- a/include/rfu_union_tool.h
+++ b/include/rfu_union_tool.h
@@ -3,15 +3,14 @@
#include "union_room.h"
-void sub_811C1C8(void);
-void sub_811BAAC(u8 *spriteIds, s32 arg1);
-void sub_811BB40(u8 *spriteIds);
-void sub_811BB68(void);
-void sub_811BECC(struct UnkStruct_URoom *arg0);
-void sub_811BEDC(struct UnkStruct_URoom *arg0);
-bool32 sub_811BF00(struct UnkStruct_Main0 *arg0, s16 *arg1, s16 *arg2, u8 *arg3);
-void sub_811C028(u32 arg0, u32 arg1, struct UnkStruct_Main0 *arg2);
u8 ZeroUnionObjWork(struct UnionObj * ptr);
-void sub_811BA78(void);
+void DeleteUnionObjWorkAndStopTask(void);
+void CreateGroupMemberObjectsInvisible(u8 *spriteIds, s32 group);
+void DestroyGroupMemberObjects(u8 *spriteIds);
+void MakeGroupAssemblyAreasPassable(void);
+void ScheduleUnionRoomPlayerRefresh(struct UnkStruct_URoom *uroom_p);
+void HandleUnionRoomPlayerRefresh(struct UnkStruct_URoom *uroom_p);
+bool32 RfuUnionTool_GetGroupAndMemberInFrontOfPlayer(struct UnkStruct_Main0 *main0_p, s16 *member_p, s16 *group_p, u8 *spriteIds);
+void UpdateUnionGroupMemberFacing(u32 member, u32 group, struct UnkStruct_Main0 *main0_p);
#endif //GUARD_UNION_ROOM_PLAYER_AVATAR_H
diff --git a/include/script.h b/include/script.h
index c0b23e248..ad7094a9b 100644
--- a/include/script.h
+++ b/include/script.h
@@ -62,7 +62,7 @@ u8 *GetRamScript(u8 objectId, u8 *script);
bool32 sub_80991F8(void);
u8 *sub_8099244(void);
void sub_80992A0(u8 *script, u16 scriptSize);
-bool32 sub_8069DFC(void);
+bool32 ValidateRamScript(void);
void MEventSetRamScript(u8 * script, u16 scriptSize);
u8 * sub_8069E48(void);
void sub_8069998(u8 var);
diff --git a/include/sprite.h b/include/sprite.h
index 7432306a4..acf8f719c 100644
--- a/include/sprite.h
+++ b/include/sprite.h
@@ -315,6 +315,6 @@ void CopyFromSprites(u8 *dest);
u8 SpriteTileAllocBitmapOp(u16 bit, u8 op);
void ClearSpriteCopyRequests(void);
void ResetAffineAnimData(void);
-void sub_8007FFC(struct Sprite* sprite, s16 a2, s16 a3);
+void obj_pos2_update_enable(struct Sprite* sprite, s16 xmod, s16 ymod);
#endif //GUARD_SPRITE_H
diff --git a/include/strings.h b/include/strings.h
index 5c8ffde4b..d468af4f3 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -1100,4 +1100,30 @@ extern const u8 gText_Symbols[];
extern const u8 gText_Register2[];
extern const u8 gText_Exit[];
+// wireless_communication_status_screen
+extern const u8 gUnknown_841E2B4[];
+extern const u8 gUnknown_841E2BF[];
+extern const u8 gUnknown_841E2C9[];
+extern const u8 gUnknown_841E2D4[];
+extern const u8 gText_WirelessCommunicationStatus[];
+extern const u8 gText_PeopleTrading[];
+extern const u8 gText_PeopleBattling[];
+extern const u8 gText_PeopleInUnionRoom[];
+extern const u8 gText_PeopleCommunicating[];
+
+// mevent
+extern const u8 gJPText_ReceiveMysteryGiftWithEReader[];
+extern const u8 gJPText_SelectConnectFromEReaderMenu[];
+extern const u8 gJPText_SelectConnectWithGBA[];
+extern const u8 gJPText_LinkIsIncorrect[];
+extern const u8 gJPText_CardReadingHasBeenHalted[];
+extern const u8 gJPText_Connecting[];
+extern const u8 gJPText_ConnectionErrorCheckLink[];
+extern const u8 gJPText_ConnectionErrorTryAgain[];
+extern const u8 gJPText_AllowEReaderToLoadCard[];
+extern const u8 gJPText_ConnectionComplete[];
+extern const u8 gJPText_NewTrainerHasComeToSevii[];
+extern const u8 gJPText_PleaseWaitAMoment[];
+extern const u8 gJPText_WriteErrorUnableToSaveData[];
+
#endif //GUARD_STRINGS_H
diff --git a/include/union_room.h b/include/union_room.h
index 7e48b3e6e..e24bcd480 100644
--- a/include/union_room.h
+++ b/include/union_room.h
@@ -4,28 +4,34 @@
#include "global.h"
#include "link_rfu.h"
-struct UnkStruct_Shared
+// Return value of IsRequestedTypeAndSpeciesInPlayerParty
+#define UR_TRADE_MATCH 0
+#define UR_TRADE_NOTYPE 1
+#define UR_TRADE_NOEGG 2
+
+#define UROOM_MAX_GROUP_COUNT 8
+#define UROOM_MAX_PARTY_SIZE 5
+
+struct UnionGnameUnamePair
{
struct GFtgtGname gname;
- u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH + 1];
+ u8 ALIGNED(4) uname[PLAYER_NAME_LENGTH + 1];
};
struct UnkStruct_x1C
{
- struct UnkStruct_Shared unk0;
- u8 unk18:1;
+ struct UnionGnameUnamePair gname_uname;
+ u8 active:1;
};
struct UnkStruct_x20
{
- struct UnkStruct_Shared unk;
+ struct UnionGnameUnamePair gname_uname;
u16 field_18;
- u8 field_1A_0:2;
- u8 field_1A_1:1;
+ u8 groupScheduledAnim:2;
+ bool8 field_1A_1:1;
u8 field_1B;
- u8 field_1D;
- u8 field_1E;
- u8 field_1F;
+ u32 field_1C; // unused
};
// These arrays are dynamically allocated but must be
@@ -51,17 +57,17 @@ struct UnkStruct_Leader
struct UnkStruct_Main0 * field_8;
u8 state;
u8 textState;
- u8 field_E;
+ u8 delayTimerAfterOk;
u8 listWindowId;
- u8 field_10;
- u8 field_11;
+ u8 bButtonCancelWindowId;
+ u8 nPlayerModeWindowId;
u8 listTaskId;
- u8 field_13;
- u8 field_14;
+ u8 playerCount;
+ u8 messageWindowId;
u8 field_15;
u8 field_16;
- u8 field_17;
- u8 field_18;
+ u8 listenTaskId;
+ u8 activity;
u8 field_19;
u16 field_1A;
};
@@ -72,18 +78,18 @@ struct UnkStruct_Group
struct UnkStruct_Main4 * field_4;
u8 state;
u8 textState;
- u8 field_A;
+ u8 field_A; // unused
u8 listWindowId;
- u8 field_C;
- u8 field_D;
+ u8 bButtonCancelWindowId;
+ u8 playerNameAndIdWindowId;
u8 listTaskId;
- u8 field_F;
+ u8 leaderId;
u8 field_10;
- u8 field_11;
- u8 field_12;
- u8 field_13;
- u8 field_14;
- u8 field_15;
+ u8 listenTaskId;
+ u8 cardOrNews;
+ u8 field_13; // referenced but never set
+ u8 refreshTimer;
+ u8 delayBeforePrint;
};
struct UnionObj
@@ -109,19 +115,21 @@ struct UnkStruct_URoom
/* 0x018 */ u8 field_18;
/* 0x019 */ u8 field_19;
/* 0x01A */ u8 field_1A;
- /* 0x01B */ u8 field_1B;
- /* 0x01C */ u8 field_1C;
- /* 0x01D */ u8 field_1D;
- /* 0x01E */ u8 field_1E;
+ /* 0x01B */ u8 topListMenuWindowId;
+ /* 0x01C */ u8 topListMenuListMenuId;
+ /* 0x01D */ u8 tradeBoardSelectWindowId;
+ /* 0x01E */ u8 tradeBoardDetailsWindowId;
/* 0x01F */ u8 field_1F;
/* 0x020 */ u8 field_20;
/* 0x021 */ u8 spriteIds[40];
/* 0x049 */ u8 field_49;
- /* 0x04A */ u8 field_4A;
- /* 0x04C */ u16 field_4C[6];
- /* 0x058 */ u8 field_58[4][11];
- /* 0x084 */ u16 field_98;
- /* 0x086 */ u16 field_9A[3];
+ /* 0x04A */ u8 tradeBoardListMenuId;
+
+ // For communication with potential link partners
+ /* 0x04C */ u16 playerSendBuffer[6];
+ /* 0x058 */ u8 activityRequestStrbufs[4][11];
+ /* 0x084 */ u16 partnerYesNoResponse;
+ /* 0x086 */ u16 recvActivityRequest[3]; // activity[, species, level]
/* 0x08C */ struct UnionObj unionObjs[8];
/* 0x0AC */ u8 trainerCardStrbufs[12][15];
/* 0x160 */ u8 field_174[48];
@@ -150,10 +158,10 @@ struct UnionRoomTrade
u32 personality;
};
-extern struct GFtgtGnameSub gUnknown_203B064;
+extern struct GFtgtGnameSub gPartnerTgtGnameSub;
extern u16 gUnionRoomOfferedSpecies;
extern u8 gUnionRoomRequestedMonType;
-void sub_81173C0(u16 battleFlags);
+void StartUnionRoomBattle(u16 battleFlags);
#endif //GUARD_UNION_ROOM_H
diff --git a/include/union_room_battle.h b/include/union_room_battle.h
new file mode 100644
index 000000000..ffccf197f
--- /dev/null
+++ b/include/union_room_battle.h
@@ -0,0 +1,6 @@
+#ifndef GUARD_UNION_ROOM_BATTLE_H
+#define GUARD_UNION_ROOM_BATTLE_H
+
+void CB2_UnionRoomBattle(void);
+
+#endif //GUARD_UNION_ROOM_BATTLE_H
diff --git a/include/union_room_message.h b/include/union_room_message.h
index b7de673ba..db24aca15 100644
--- a/include/union_room_message.h
+++ b/include/union_room_message.h
@@ -3,7 +3,7 @@
#include "global.h"
-extern const u8 gUnknown_84571AC[];
+extern const u8 gUnionRoomActivity_Blank[];
extern const u8 gUnknown_84571B0[];
extern const u8 gUnknown_84571B4[];
extern const u8 gUnknown_84571B8[];
@@ -31,8 +31,8 @@ extern const u8 gUnknown_84577BC[];
extern const u8 gUnknown_84577F8[];
extern const u8 *const gUnknown_8457838[];
extern const u8 gUnknown_84578BC[];
-extern const u8 *const gUnknown_8457A34[];
-extern const u8 *const gUnknown_8457B04[][2];
+extern const u8 *const gURText_PleaseWaitMsgs[];
+extern const u8 *const gURText_FriendPromptsForActivity[][2];
extern const u8 *const gUnknown_8457BCC[];
extern const u8 *const gUnknown_8457C20[];
extern const u8 gUnknown_8457C48[];
@@ -46,7 +46,7 @@ extern const u8 gUnknown_8457E44[];
extern const u8 gUnknown_8457E60[];
extern const u8 *const gUnknown_8457F80[][2];
extern const u8 gUnknown_8457F90[];
-extern const u8 *const gUnknown_84580F4[][4];
+extern const u8 *const gResponseToURoomActivityInviteStringPtrs[][4];
extern const u8 *const gUnknown_8458230[][2][3];
extern const u8 *const gUnknown_8458314[];
extern const u8 *const gUnknown_84583B4[];
@@ -63,7 +63,7 @@ extern const u8 *const gUnknown_8458A78[2][4];
extern const u8 gUnknown_8458A98[];
extern const u8 gUnknown_8458AB8[];
extern const u8 gUnknown_8458B44[];
-extern const u8 gUnknown_8458CD4[];
+extern const u8 gURText_PleaseChooseTypeOfMon[];
extern const u8 gUnknown_8458D1C[];
extern const u8 gUnknown_8458D54[];
extern const u8 gUnknown_8458D78[];
@@ -75,7 +75,7 @@ extern const u8 gUnknown_8458E70[];
extern const u8 gUnknown_8458ED0[];
extern const u8 gUnknown_8458F04[];
extern const u8 gUnknown_8458F9C[];
-extern const u8 gUnknown_8458FBC[];
+extern const u8 gText_EggTrade[];
extern const u8 gUnknown_8458FC8[];
extern const u8 gUnknown_8458FE4[];
extern const u8 gUnknown_84591DC[];
@@ -91,20 +91,20 @@ extern const u8 gUnknown_8459360[];
extern const u8 gUnknown_8459368[];
extern const u8 gUnknown_8459370[];
extern const u8 gUnknown_8459378[];
-extern const u8 gUnknown_8459394[];
-extern const u8 gUnknown_84593A4[];
-extern const u8 gUnknown_84593B4[];
-extern const u8 gUnknown_84593C4[];
-extern const u8 gUnknown_84593D4[];
-extern const u8 gUnknown_84593E4[];
-extern const u8 gUnknown_84593F4[];
-extern const u8 gUnknown_84593DC[];
-extern const u8 gUnknown_8459400[];
-extern const u8 gUnknown_8459410[];
-extern const u8 gUnknown_845941C[];
-extern const u8 gUnknown_845942C[];
-extern const u8 gUnknown_8459434[];
-extern const u8 gUnknown_8459440[];
+extern const u8 gUnionRoomActivity_SingleBattle[];
+extern const u8 gUnionRoomActivity_DoubleBattle[];
+extern const u8 gUnionRoomActivity_MultiBattle[];
+extern const u8 gUnionRoomActivity_PokemonTrades[];
+extern const u8 gUnionRoomActivity_Chat[];
+extern const u8 gUnionRoomActivity_WonderCards[];
+extern const u8 gunionRoomActivity_WonderNews[];
+extern const u8 gUnionRoomActivity_Cards[];
+extern const u8 gUnionRoomActivity_PokemonJump[];
+extern const u8 gUnionRoomActivity_BerryCrush[];
+extern const u8 gUnionRoomActivity_BerryPicking[];
+extern const u8 gUnionRoomActivity_Search[];
+extern const u8 gUnionRoomActivity_SpinTradeJP[];
+extern const u8 gUnionRoomActivity_ItemTradeJP[];
extern const u8 *const gUnknown_84594B0[];
extern const u8 gUnknown_84594C4[];
extern const u8 gUnknown_8459504[];
diff --git a/include/unk_810c3a4.h b/include/unk_810c3a4.h
deleted file mode 100644
index 11a91b5ef..000000000
--- a/include/unk_810c3a4.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef GUARD_UNK_810C3A4_H
-#define GUARD_UNK_810C3A4_H
-
-#define GET_VS_SEEKER_COUNTER_0() (gSaveBlock1Ptr->trainerRematch.stepCounter & 0xFF)
-#define GET_VS_SEEKER_COUNTER_1() (gSaveBlock1Ptr->trainerRematch.stepCounter >> 8)
-#define SET_VS_SEEKER_COUNTER_0(x) ({\
- gSaveBlock1Ptr->trainerRematch.stepCounter &= 0xFF00;\
- gSaveBlock1Ptr->trainerRematch.stepCounter |= (x);\
-})
-#define SET_VS_SEEKER_COUNTER_1(x) ({\
- gSaveBlock1Ptr->trainerRematch.stepCounter &= 0x00FF;\
- gSaveBlock1Ptr->trainerRematch.stepCounter |= ((x) << 8);\
-})
-#define INC_VS_SEEKER_COUNTER_0() ({\
- u8 x = GET_VS_SEEKER_COUNTER_0();\
- if (x < 100) gSaveBlock1Ptr->trainerRematch.stepCounter++;\
-})
-#define INC_VS_SEEKER_COUNTER_1() ({\
- u8 x = GET_VS_SEEKER_COUNTER_1();\
- if (x < 100) {x++; SET_VS_SEEKER_COUNTER_1(x);}\
-})
-
-void sub_810C604(void);
-void sub_810C640(void);
-
-#endif //GUARD_UNK_810C3A4_H
diff --git a/include/unk_815C980.h b/include/unk_815C980.h
deleted file mode 100644
index a3249a8e2..000000000
--- a/include/unk_815C980.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef GUARD_UNK_815C980_H
-#define GUARD_UNK_815C980_H
-
-struct UnkStruct3
-{
- u8 field_0_0:2;
- u8 shape:2;
- u8 size:2;
- u8 priority:2;
- u8 field_1;
- u8 xDelta;
- s16 x;
- s16 y;
- const struct SpriteSheet *spriteSheet;
- const struct SpritePalette *spritePal;
-};
-
-void sub_815C9F4(void);
-void sub_815D108(u32 id);
-void sub_815D1A8(u32 id, bool32 arg1);
-bool32 sub_815CA40(u32 id, s32 arg1, const struct UnkStruct3 *arg2);
-void sub_815CD70(u32 id, s32 arg1);
-
-#endif //GUARD_UNK_815C980_H
diff --git a/include/unk_815c27c.h b/include/unk_815c27c.h
deleted file mode 100644
index 02c886895..000000000
--- a/include/unk_815c27c.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef GUARD_UNK_815C27C_H
-#define GUARD_UNK_815C27C_H
-
-void EReaderHelper_SerialCallback(void);
-void EReaderHelper_Timer3Callback(void);
-void EReaderHelper_SaveRegsState(void);
-void EReaderHelper_ClearsSendRecvMgr(void);
-void EReaderHelper_RestoreRegsState(void);
-u16 EReaderHandleTransfer(u8, size_t, const void *, void *);
-
-#endif //GUARD_UNK_815C27C_H
diff --git a/include/vs_seeker.h b/include/vs_seeker.h
index fdd6839df..2d88417fa 100644
--- a/include/vs_seeker.h
+++ b/include/vs_seeker.h
@@ -3,6 +3,9 @@
#include "global.h"
+void sub_810C604(void);
+void sub_810C640(void);
+
void Task_VsSeeker_0(u8 taskId);
void sub_810CB90(void);
void sub_810CDE8(void);