diff options
author | GriffinR <griffin.g.richards@gmail.com> | 2021-10-05 23:38:36 -0400 |
---|---|---|
committer | GriffinR <griffin.g.richards@gmail.com> | 2021-10-07 10:43:03 -0400 |
commit | 6aaf50ee27c175c8e54c7299fdc86d90b0b29187 (patch) | |
tree | 2152fab10b10669b6a1ead030814dfe61960cd92 /include | |
parent | 4efa6c882a68d69e32f59580faa438a6b1fd0b68 (diff) |
Rename GF Gname, Rfu, finish bulk of Union Room, more link doc
Diffstat (limited to 'include')
-rw-r--r-- | include/constants/union_room.h | 24 | ||||
-rw-r--r-- | include/link_rfu.h | 97 | ||||
-rw-r--r-- | include/trade.h | 4 | ||||
-rw-r--r-- | include/union_room.h | 100 | ||||
-rw-r--r-- | include/union_room_player_avatar.h | 8 |
5 files changed, 119 insertions, 114 deletions
diff --git a/include/constants/union_room.h b/include/constants/union_room.h index d867fb340..6e08c9ebb 100644 --- a/include/constants/union_room.h +++ b/include/constants/union_room.h @@ -1,7 +1,11 @@ #ifndef GUARD_CONSTANTS_UNION_ROOM_H #define GUARD_CONSTANTS_UNION_ROOM_H -#define MAX_UNION_ROOM_PLAYERS 8 +// The number of possible group leaders visible in the Union Room. +// Note that this is different than the number of people actively +// connected as children via the Wireless Adapter, which cannot +// exceed RFU_CHILD_MAX (4), for a total of 5 including the player. +#define MAX_UNION_ROOM_LEADERS 8 #define UNION_ROOM_SPAWN_NONE 0 #define UNION_ROOM_SPAWN_IN 1 @@ -13,8 +17,8 @@ #define ACTIVITY_BATTLE_MULTI 3 #define ACTIVITY_TRADE 4 #define ACTIVITY_CHAT 5 -#define ACTIVITY_WONDER_CARD 6 -#define ACTIVITY_WONDER_NEWS 7 +#define ACTIVITY_WONDER_CARD_DUP 6 // Duplicates of later WONDER constants +#define ACTIVITY_WONDER_NEWS_DUP 7 // #define ACTIVITY_CARD 8 #define ACTIVITY_POKEMON_JUMP 9 #define ACTIVITY_BERRY_CRUSH 10 @@ -32,9 +36,8 @@ #define ACTIVITY_NPCTALK 19 #define ACTIVITY_PLYRTALK 20 -// Duplicate IDs? -#define ACTIVITY_WONDER_CARD2 21 -#define ACTIVITY_WONDER_NEWS2 22 +#define ACTIVITY_WONDER_CARD 21 +#define ACTIVITY_WONDER_NEWS 22 #define ACTIVITY_CONTEST_COOL 23 #define ACTIVITY_CONTEST_BEAUTY 24 @@ -46,15 +49,6 @@ #define IN_UNION_ROOM (1 << 6) -// 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 diff --git a/include/link_rfu.h b/include/link_rfu.h index 04f1b7f9a..eb071618e 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -20,10 +20,10 @@ #define RFUCMD_DISCONNECT 0xED00 #define RFUCMD_DISCONNECT_PARENT 0xEE00 -#define RFU_SERIAL_A 0x0002 -#define RFU_SERIAL_B 0x7F7D -#define RFU_SERIAL_C 0x0000 -#define RFU_SERIAL_END 0xFFFF +#define RFU_SERIAL_GAME 0x0002 // Serial number for Pokémon game (FRLG or Emerald) +#define RFU_SERIAL_WONDER_DISTRIBUTOR 0x7F7D // Serial number for distributing Wonder Cards / News +#define RFU_SERIAL_UNKNOWN 0x0000 // Unreferenced acceptable serial number. Gamecube? +#define RFU_SERIAL_END 0xFFFF #define RECV_QUEUE_NUM_SLOTS 32 #define RECV_QUEUE_SLOT_LENGTH (14 * MAX_RFU_PLAYERS) @@ -68,8 +68,7 @@ enum { RFU_ERROR_STATE_IGNORE, }; -// RfuTgtData.gname is read as these structs. -struct GFtgtGnameSub +struct RfuGameCompatibilityData { u16 language:4; u16 hasNews:1; @@ -79,24 +78,41 @@ struct GFtgtGnameSub u16 hasNationalDex:1; u16 gameClear:1; u16 version:4; + u16 unused:2; u8 playerTrainerId[2]; }; -struct __attribute__((packed, aligned(2))) GFtgtGname +// This struct is sent via the Wireless Adapter as the game name or "gname" data. +// Gname is only applicable during Wireless Single Game Pak Multiplay, when the +// adapter needs this data for connection. Per the RFU manual, during "normal" +// wireless play (the kind the Pokémon games use) the gname data can be used for +// anything the developers want. This struct is what GF decided to use it for. +// It can be up to 13 bytes in size (RFU_GAME_NAME_LENGTH). +// The player's name is sent separately as the username ("uname"), and does not +// use a struct (gHostRfuUsername). +struct __attribute__((packed, aligned(2))) RfuGameData { - struct GFtgtGnameSub unk_00; - u8 child_sprite_gender[RFU_CHILD_MAX]; // u8 sprite_idx:3; - // u8 gender:1; - // u8 unk_4:3 - // u8 active:1 - u16 species:10; - u16 type:6; + struct RfuGameCompatibilityData compatibility; + u8 partnerInfo[RFU_CHILD_MAX]; + u16 tradeSpecies:10; + u16 tradeType:6; u8 activity:7; - u8 started:1; + u8 startedActivity:1; u8 playerGender:1; - u8 level:7; + u8 tradeLevel:7; u8 padding; -}; // size: RFU_GNAME_SIZE +}; + +// Constants for getting/setting information in 'partnerInfo' of RfuGameData. +// This data is used to determine what the link partners look like from +// the host's perspective. +// Bits 0-2 are a shortened trainerId +// Bit 3 is the player's gender +// Bits 4-6 are unknown/unused +// Bit 7 is an 'active' flag +#define PINFO_TID_MASK 0x7 +#define PINFO_GENDER_SHIFT 3 +#define PINFO_ACTIVE_FLAG (1 << 7) struct RfuBlockSend { @@ -136,7 +152,8 @@ struct RfuBackupQueue /* 0x1e */ vu8 count; }; -struct GFRfuManager +// Stores data needed for the RFU on GF's end +struct RfuManager { /* 0x000 */ void (*callback)(void); /* 0x004 */ u16 state; @@ -151,7 +168,7 @@ struct GFRfuManager /* 0x014 */ u8 childRecvBuffer[RFU_CHILD_MAX][CHILD_DATA_LENGTH]; /* 0x04c */ u8 childSendBuffer[CHILD_DATA_LENGTH]; /* 0x05a */ u8 blockRequestType; - /* 0x05b */ u8 unk_5b; + /* 0x05b */ u8 blockSendAttempts; /* 0x05c */ bool8 blockReceived[MAX_RFU_PLAYERS]; /* 0x061 */ bool8 numBlocksReceived[MAX_RFU_PLAYERS]; /* 0x066 */ u8 idleTaskId; @@ -170,9 +187,9 @@ struct GFRfuManager /* 0x100 */ u16 allReadyNum; /* 0x102 */ u8 unk_102; /* 0x103 */ u8 filler_103[7]; - /* 0x10A */ struct GFtgtGname unk_10A; + /* 0x10A */ struct RfuGameData parent; u8 filler_; - u8 playerName[PLAYER_NAME_LENGTH + 1]; + u8 parentName[RFU_USER_NAME_LENGTH]; /* 0x124 */ struct RfuRecvQueue recvQueue; /* 0x9e8 */ struct RfuSendQueue sendQueue; /* 0xc1c */ struct RfuBackupQueue backupQueue; @@ -180,7 +197,7 @@ struct GFRfuManager /* 0xc3d */ u8 unk_c3d; /* 0xc3e */ vu8 childSlot; /* 0xc3f */ u8 unk_c3f[70]; - /* 0xc85 */ u8 unk_c85; + /* 0xc85 */ u8 leaveGroupStatus; /* 0xc86 */ u8 recvStatus; /* 0xc87 */ u8 recvCmds[5][7][2]; /* 0xccd */ u8 parentId; @@ -198,18 +215,18 @@ struct GFRfuManager /* 0xce2 */ u8 unk_ce2; /* 0xce2 */ u8 disconnectSlots; /* 0xce4 */ u8 disconnectMode; - /* 0xce5 */ u8 unk_ce5; - /* 0xce5 */ u8 unk_ce6; + /* 0xce5 */ u8 nextChildBits; + /* 0xce5 */ u8 newChildQueue; /* 0xce7 */ u8 acceptSlot_flag; /* 0xce8 */ bool8 unk_ce8; - /* 0xce9 */ u8 unk_ce9; + /* 0xce9 */ u8 incomingChild; /* 0xcea */ u8 unk_cea[4]; /* 0xcee */ u8 unk_cee[4]; }; // size = 0xcf4 -extern struct GFtgtGname gHostRFUtgtGnameBuffer; -extern u8 gHostRFUtgtUnameBuffer[]; -extern struct GFRfuManager Rfu; +extern struct RfuGameData gHostRfuGameData; +extern u8 gHostRfuUsername[]; +extern struct RfuManager gRfu; extern u8 gWirelessStatusIndicatorSpriteId; void WipeTrainerNameRecords(void); @@ -241,13 +258,13 @@ u32 GetRfuRecvQueueLength(void); void RfuVSync(void); void RfuSetIgnoreError(bool32 enable); u8 RfuGetStatus(void); -struct GFtgtGname *GetHostRFUtgtGname(void); -void UpdateGameData_GroupLockedIn(u8 started); +struct RfuGameData *GetHostRfuGameData(void); +void UpdateGameData_GroupLockedIn(u8 startedActivity); void GetLinkmanErrorParams(u32 msg); void RfuSetStatus(u8 status, u16 msg); u8 Rfu_SetLinkRecovery(bool32 enable); -void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *buff1, u8 *buff2); -void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, bool32 started); +void CopyHostRfuGameDataAndUsername(struct RfuGameData *buff1, u8 *buff2); +void SetHostRfuGameData(u8 activity, u32 partnerInfo, bool32 startedActivity); void InitializeRfuLinkManager_LinkLeader(u32 a0); bool32 IsRfuCommunicatingWithAllChildren(void); void LinkRfu_StopManagerAndFinalizeSlots(void); @@ -264,22 +281,22 @@ void SendLeaveGroupNotice(void); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(void); void LinkRfu_StopManagerBeforeEnteringChat(void); -void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 started); +void UpdateGameData_SetActivity(u8 activity, u32 flags, bool32 startedActivity); void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); -void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); -void ClearAndInitHostRFUtgtGname(void); +void SetHostRfuWonderFlags(bool32 hasNews, bool32 hasCard); +void ResetHostRfuGameData(void); void SetTradeBoardRegisteredMonInfo(u32 type, u32 species, u32 level); void InitializeRfuLinkManager_EnterUnionRoom(void); -void sub_8012188(const u8 *name, struct GFtgtGname *structPtr, u8 a2); +void TryConnectToUnionRoomParent(const u8 *name, struct RfuGameData *structPtr, u8 a2); bool32 IsUnionRoomListenTaskActive(void); void Rfu_SendPacket(void *data); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); void Rfu_DisconnectPlayerById(u32 playerIdx); u8 GetLinkPlayerInfoFlags(s32 playerId); void sub_800EF7C(void); -bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *buff1, u8 *buff2, u8 idx); -bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *buff1, u8 *buff2, u8 idx); -s32 sub_800E87C(u8 idx); +bool8 Rfu_GetCompatiblePlayerData(struct RfuGameData *player, u8 *username, u8 idx); +bool8 Rfu_GetWonderDistributorPlayerData(struct RfuGameData *player, u8 *username, u8 idx); +s32 Rfu_GetIndexOfNewestChild(u8 bits); void CreateTask_RfuIdle(void); void DestroyTask_RfuIdle(void); void ClearRecvCommands(void); @@ -298,7 +315,7 @@ bool8 RfuRecvQueue_Dequeue(struct RfuRecvQueue *queue, u8 *dest); bool8 RfuSendQueue_Dequeue(struct RfuSendQueue *queue, u8 *dest); void RfuBackupQueue_Enqueue(struct RfuBackupQueue *queue, const u8 *q2); bool8 RfuBackupQueue_Dequeue(struct RfuBackupQueue *queue, u8 *q2); -void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders); +void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedActivity, s32 partnerInfo); void CreateWirelessStatusIndicatorSprite(u8 x, u8 y); void DestroyWirelessStatusIndicatorSprite(void); void LoadWirelessStatusIndicatorSpriteGfx(void); diff --git a/include/trade.h b/include/trade.h index bd8ef8f63..05a905ab3 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 GFtgtGnameSub a0, u16, u16, u8); -int GetUnionRoomTradeMessageId(struct GFtgtGnameSub a0, struct GFtgtGnameSub a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6); +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData a0, u16, u16, u8); +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData a0, struct RfuGameCompatibilityData 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 563a048d3..11dbccf70 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -5,23 +5,30 @@ #include "link.h" #include "constants/union_room.h" -// Exported type declarations - -struct WirelessGnameUnamePair +// In the Union Room the player is only ever connected to ≤ 4 other players. +// However, there can be up to MAX_UNION_ROOM_LEADERS (8) object events to +// represent leaders of recently discovered link groups, and each of those groups +// may have up to MAX_RFU_PLAYERS (5) players in it including the leader. +// These players are represented on-screen by NPC sprites drawn around the leader. +// Thus there can be 40 sprites of other players on-screen, in 8 groups of 5. +#define NUM_UNION_ROOM_SPRITES (MAX_UNION_ROOM_LEADERS * MAX_RFU_PLAYERS) + +// The maximum number of recently connected players that can be tracked. +// Note that this is significantly less than NUM_UNION_ROOM_SPRITES, i.e. not +// every player that can be shown in the Union Room can be tracked at once. +// Information such as a group member's gender can instead be read from partnerInfo +// of the leader's RfuGameData by tracking at least all of the group leaders. +#define MAX_RFU_PLAYER_LIST_SIZE 16 + +struct RfuPlayerData { - struct GFtgtGname gname; - u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH + 1]; + struct RfuGameData data; + u8 ALIGNED(4) name[RFU_USER_NAME_LENGTH]; }; -struct UnkStruct_x1C +struct RfuPlayer { - struct WirelessGnameUnamePair gname_uname; - u8 active:1; -}; - -struct UnkStruct_x20 -{ - struct WirelessGnameUnamePair gname_uname; + struct RfuPlayerData rfu; u16 timeoutCounter; u8 groupScheduledAnim:2; bool8 useRedText:1; // Never set @@ -29,26 +36,27 @@ struct UnkStruct_x20 u8 filler[3]; }; -struct UnkStruct_Main0 +struct RfuPlayerList { - struct UnkStruct_x20 arr[MAX_UNION_ROOM_PLAYERS]; + struct RfuPlayer players[MAX_RFU_PLAYER_LIST_SIZE]; }; -struct UnkStruct_Main4 +struct RfuIncomingPlayer { - struct UnkStruct_x1C arr[MAX_RFU_PLAYERS]; + struct RfuPlayerData rfu; + bool8 active:1; }; -struct UnkStruct_Main8 +struct RfuIncomingPlayerList { - struct UnkStruct_x20 arr[MAX_RFU_PLAYERS]; + struct RfuIncomingPlayer players[MAX_RFU_PLAYERS]; }; struct WirelessLink_Leader { - struct UnkStruct_Main0 *field_0; - struct UnkStruct_Main4 *field_4; - struct UnkStruct_Main8 *field_8; + struct RfuPlayerList *playerList; + struct RfuIncomingPlayerList *incomingPlayerList; + struct RfuPlayerList *playerListBackup; u8 state; u8 textState; u8 delayTimerAfterOk; @@ -57,8 +65,8 @@ struct WirelessLink_Leader u8 nPlayerModeWindowId; u8 listTaskId; u8 playerCount; - u16 field_14; - u8 field_16; + u16 yesNoWindowId; + u8 unused; u8 listenTaskId; u8 activity; u8 joinRequestAnswer; @@ -67,20 +75,20 @@ struct WirelessLink_Leader struct WirelessLink_Group { - struct UnkStruct_Main0 *field_0; - struct UnkStruct_Main4 *field_4; + struct RfuPlayerList *playerList; + struct RfuIncomingPlayerList *incomingPlayerList; u8 state; u8 textState; - u8 field_A; + u8 delayTimerAfterOk; // Unused u8 listWindowId; u8 bButtonCancelWindowId; u8 playerNameAndIdWindowId; u8 listTaskId; u8 leaderId; - u8 field_10; + u8 unused; u8 listenTaskId; - u8 isWonderNews; - u8 field_13; + bool8 isWonderNews; + bool8 showListMenu; // Never set u8 refreshTimer; u8 delayBeforePrint; }; @@ -95,10 +103,10 @@ struct UnionRoomObject struct WirelessLink_URoom { - struct UnkStruct_Main0 *field_0; - struct UnkStruct_Main4 *field_4; - struct UnkStruct_Main0 *field_8; - struct UnkStruct_Main4 *field_C; + struct RfuPlayerList *playerList; + struct RfuIncomingPlayerList *incomingChildList; + struct RfuPlayerList *spawnPlayer; + struct RfuIncomingPlayerList *incomingParentList; u16 unknown; // Never read u16 field_12; u8 state; @@ -107,56 +115,42 @@ struct WirelessLink_URoom u8 filler[4]; u8 topListMenuWindowId; u8 topListMenuId; - u8 tradeBoardSelectWindowId; - u8 tradeBoardDetailsWindowId; + u8 tradeBoardMainWindowId; + u8 tradeBoardHeaderWindowId; u8 unused1; u8 searchTaskId; - u8 spriteIds[40]; + u8 spriteIds[NUM_UNION_ROOM_SPRITES]; u8 unused2; u8 tradeBoardListMenuId; u16 playerSendBuffer[6]; u8 activityRequestStrbufs[4][16]; u16 partnerYesNoResponse; u16 recvActivityRequest[3]; - struct UnionRoomObject objects[MAX_UNION_ROOM_PLAYERS]; + struct UnionRoomObject objects[MAX_UNION_ROOM_LEADERS]; u8 trainerCardStrBuffer[12][15]; u8 trainerCardColorStrBuffer[48]; u8 trainerCardMsgStrBuffer[200]; }; -union WirelessLink_Main -{ - struct WirelessLink_Leader *leader; - struct WirelessLink_Group *group; - struct WirelessLink_URoom *uRoom; -}; - struct UnionRoomTrade { u16 state; u16 type; u32 playerPersonality; u8 offerPlayerId; - u8 filler1; u16 playerSpecies; u16 playerLevel; u16 species; u16 level; - u16 filler2; u32 personality; }; -// Exported RAM declarations - extern u8 gPlayerCurrActivity; -extern union WirelessLink_Main gUnknown_02022C30; -extern struct GFtgtGnameSub gPartnerTgtGnameSub; +extern struct RfuGameCompatibilityData gRfuPartnerCompatibilityData; extern u16 gUnionRoomOfferedSpecies; extern u8 gUnionRoomRequestedMonType; -// Exported ROM declarations - u8 CreateTask_CreateTradeMenu(void); void SetUsingUnionRoomStartMenu(void); void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); diff --git a/include/union_room_player_avatar.h b/include/union_room_player_avatar.h index c7add758a..e6526739f 100644 --- a/include/union_room_player_avatar.h +++ b/include/union_room_player_avatar.h @@ -3,12 +3,12 @@ u8 InitUnionRoomPlayerObjects(struct UnionRoomObject *players); void DestroyUnionRoomPlayerObjects(void); -void CreateGroupMemberSpritesInvisible(u8 *spriteIds, s32 playerIdx); -void DestroyGroupMemberSprites(u8 *spriteIds); +void CreateUnionRoomPlayerSprites(u8 *spriteIds, s32 playerIdx); +void DestroyUnionRoomPlayerSprites(u8 *spriteIds); void SetTilesAroundUnionRoomPlayersPassable(void); void ScheduleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom); void HandleUnionRoomPlayerRefresh(struct WirelessLink_URoom *uroom); -bool32 TryInteractWithUnionRoomMember(struct UnkStruct_Main0 *main0, s16 *directionPtr, s16 *playerIdxPtr, u8 *spriteIds); -void UpdateUnionRoomMemberFacing(u32 currDirection, u32 playerIdx, struct UnkStruct_Main0 *main0); +bool32 TryInteractWithUnionRoomMember(struct RfuPlayerList *main0, s16 *directionPtr, s16 *playerIdxPtr, u8 *spriteIds); +void UpdateUnionRoomMemberFacing(u32 currDirection, u32 playerIdx, struct RfuPlayerList *main0); #endif //GUARD_UNION_ROOM_PLAYER_AVATAR_H |