From c2bf9898a533a0b0cd2bba346e3df8c6f300f016 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 23 Jan 2020 02:02:57 -0500 Subject: Document Vermilion scripts --- include/constants/metatile_labels.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include') diff --git a/include/constants/metatile_labels.h b/include/constants/metatile_labels.h index f2bf4b865..fc8418b44 100644 --- a/include/constants/metatile_labels.h +++ b/include/constants/metatile_labels.h @@ -4,6 +4,37 @@ // General #define METATILE_General_CalmWater 0x12B +// Vermilion Gym +#define METATILE_VermilionGym_Floor 0x281 +#define METATILE_VermilionGym_Beam_MidTop 0x285 +#define METATILE_VermilionGym_Beam_MidBottom 0x28D +#define METATILE_VermilionGym_Beam_Node_TopLeft_Off 0x293 +#define METATILE_VermilionGym_Beam_Node_TopLeft_Edge_Off 0x294 +#define METATILE_VermilionGym_Beam_Node_TopRight_Edge_Off 0x295 +#define METATILE_VermilionGym_Beam_Node_TopRight_Off 0x296 +#define METATILE_VermilionGym_Beam_Node_BottomLeft_Off 0x29B +#define METATILE_VermilionGym_Beam_Node_BottomLeft_Edge_Off 0x29C +#define METATILE_VermilionGym_Beam_Node_BottomRight_Edge_Off 0x29D +#define METATILE_VermilionGym_Beam_Node_BottomRight_Off 0x29E +#define METATILE_VermilionGym_Beam_Node_TopLeft_On 0x2A9 +#define METATILE_VermilionGym_Beam_Node_TopLeft_Edge_On 0x2AA +#define METATILE_VermilionGym_Beam_Node_TopRight_Edge_On 0x2AB +#define METATILE_VermilionGym_Beam_Node_TopRight_On 0x2AC +#define METATILE_VermilionGym_Beam_Node_BottomLeft_On 0x2B1 +#define METATILE_VermilionGym_Beam_Node_BottomLeft_Edge_On 0x2B2 +#define METATILE_VermilionGym_Beam_Node_BottomRight_Edge_On 0x2B3 +#define METATILE_VermilionGym_Beam_Node_BottomRight_On 0x2B4 +#define METATILE_VermilionGym_Beam_Node_TopLeft_HalfOn 0x2BB +#define METATILE_VermilionGym_Beam_Node_TopLeft_Edge_HalfOn 0x2BC +#define METATILE_VermilionGym_Beam_MidTop_HalfOn 0x2BD +#define METATILE_VermilionGym_Beam_Node_TopRight_Edge_HalfOn 0x2BE +#define METATILE_VermilionGym_Beam_Node_TopRight_HalfOn 0x2BF +#define METATILE_VermilionGym_Beam_Node_BottomLeft_HalfOn 0x2C3 +#define METATILE_VermilionGym_Beam_Node_BottomLeft_Edge_HalfOn 0x2C4 +#define METATILE_VermilionGym_Beam_MidBottom_HalfOn 0x2C5 +#define METATILE_VermilionGym_Beam_Node_BottomRight_Edge_HalfOn 0x2C6 +#define METATILE_VermilionGym_Beam_Node_BottomRight_HalfOn 0x2C7 + // Pokemon Mansion #define METATILE_PokemonMansion_Floor 0x284 #define METATILE_PokemonMansion_Floor_ShadeFull 0x285 -- cgit v1.2.3 From 4ff5769f4286212d6ca50f82647cdd3849e1a361 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 23 Jan 2020 16:52:41 -0500 Subject: union_room_chat through sub_81287B4 --- include/global.h | 5 ++++- include/help_system.h | 1 + include/link_rfu.h | 1 + include/main.h | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 180a1e0a3..686ecb11c 100644 --- a/include/global.h +++ b/include/global.h @@ -718,6 +718,8 @@ struct TrainerNameRecord u8 trainerName[PLAYER_NAME_LENGTH]; }; +#define UNION_ROOM_KB_ROW_COUNT 10 + struct SaveBlock1 { /*0x0000*/ struct Coords16 pos; @@ -772,7 +774,8 @@ struct SaveBlock1 /*0x3A18*/ u8 seen2[DEX_FLAGS_NO]; /*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH]; /*0x3A54*/ struct FameCheckerSaveData fameChecker[NUM_FAMECHECKER_PERSONS]; - /*0x3A94*/ u8 filler3A94[0x114]; + /*0x3A94*/ u8 filler3A94[0x40]; + /*0x3AD4*/ u8 unk3AD4[UNION_ROOM_KB_ROW_COUNT][21]; /*0x3BA8*/ struct TrainerNameRecord trainerNameRecords[20]; /*0x3C98*/ struct DaycareMon route5DayCareMon; /*0x3D24*/ u8 filler3D24[0x10]; diff --git a/include/help_system.h b/include/help_system.h index 273b5e119..59adec912 100644 --- a/include/help_system.h +++ b/include/help_system.h @@ -92,5 +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); #endif //GUARD_HELP_SYSTEM_H diff --git a/include/link_rfu.h b/include/link_rfu.h index 790429870..2e502165a 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -325,6 +325,7 @@ 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); +bool32 sub_80FBA1C(void); #include "mevent_server.h" extern const struct mevent_server_cmd gMEventSrvScript_OtherTrainerCanceled[]; diff --git a/include/main.h b/include/main.h index c962cf7bd..f89ffbd63 100644 --- a/include/main.h +++ b/include/main.h @@ -73,5 +73,6 @@ extern const char RomHeaderGameCode[4]; extern const char RomHeaderSoftwareVersion; extern u8 gLinkTransferringData; +extern u16 gKeyRepeatStartDelay; #endif // GUARD_MAIN_H -- cgit v1.2.3 From 14b7ed7a5f21e2a0c81373f6861ebd0d4c6eb78c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 24 Jan 2020 13:07:41 -0500 Subject: through sub_8128FB8 --- include/data_8479668.h | 35 +++++++++++++++++++++++++++++++++++ include/link_rfu.h | 1 + 2 files changed, 36 insertions(+) create mode 100644 include/data_8479668.h (limited to 'include') diff --git a/include/data_8479668.h b/include/data_8479668.h new file mode 100644 index 000000000..1a1f44267 --- /dev/null +++ b/include/data_8479668.h @@ -0,0 +1,35 @@ +#ifndef GUARD_DATA_8479668_H +#define GUARD_DATA_8479668_H + +extern const u8 gText_UnionRoomChatKeyboard_ABCDE[]; +extern const u8 gText_UnionRoomChatKeyboard_FGHIJ[]; +extern const u8 gText_UnionRoomChatKeyboard_KLMNO[]; +extern const u8 gText_UnionRoomChatKeyboard_PQRST[]; +extern const u8 gText_UnionRoomChatKeyboard_UVWXY[]; +extern const u8 gText_UnionRoomChatKeyboard_Z[]; +extern const u8 gText_UnionRoomChatKeyboard_01234Upper[]; +extern const u8 gText_UnionRoomChatKeyboard_56789Upper[]; +extern const u8 gText_UnionRoomChatKeyboard_PunctuationUpper[]; +extern const u8 gText_UnionRoomChatKeyboard_SymbolsUpper[]; +extern const u8 gText_UnionRoomChatKeyboard_abcde[]; +extern const u8 gText_UnionRoomChatKeyboard_fghij[]; +extern const u8 gText_UnionRoomChatKeyboard_klmno[]; +extern const u8 gText_UnionRoomChatKeyboard_pqrst[]; +extern const u8 gText_UnionRoomChatKeyboard_uvwxy[]; +extern const u8 gText_UnionRoomChatKeyboard_z[]; +extern const u8 gText_UnionRoomChatKeyboard_01234Lower[]; +extern const u8 gText_UnionRoomChatKeyboard_56789Lower[]; +extern const u8 gText_UnionRoomChatKeyboard_PunctuationLower[]; +extern const u8 gText_UnionRoomChatKeyboard_SymbolsLower[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji1[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji2[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji3[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji4[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji5[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji6[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji7[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji8[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji9[]; +extern const u8 gText_UnionRoomChatKeyboard_Emoji10[]; + +#endif //GUARD_DATA_8479668_H diff --git a/include/link_rfu.h b/include/link_rfu.h index 2e502165a..9dac781b3 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -326,6 +326,7 @@ 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); bool32 sub_80FBA1C(void); +void sub_80FA4A8(void); #include "mevent_server.h" extern const struct mevent_server_cmd gMEventSrvScript_OtherTrainerCanceled[]; -- cgit v1.2.3 From d22dd0f08b6e08b75b6db8391022b9662e6879ce Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 24 Jan 2020 17:03:03 -0500 Subject: through sub_8129560 --- include/text.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/text.h b/include/text.h index cd059e0e5..ff8b033e9 100644 --- a/include/text.h +++ b/include/text.h @@ -5,10 +5,24 @@ #define CHAR_SPACE 0x00 #define CHAR_0 0xA1 +#define CHAR_1 0xA2 +#define CHAR_2 0xA3 +#define CHAR_3 0xA4 +#define CHAR_4 0xA5 +#define CHAR_5 0xA6 +#define CHAR_6 0xA7 +#define CHAR_7 0xA8 +#define CHAR_8 0xA9 +#define CHAR_9 0xAA +#define CHAR_EXCL_MARK 0xAB #define CHAR_QUESTION_MARK 0xAC #define CHAR_PERIOD 0xAD #define CHAR_HYPHEN 0xAE #define CHAR_ELLIPSIS 0xB0 +#define CHAR_DBL_QUOT_LEFT 0xB1 +#define CHAR_DBL_QUOT_RIGHT 0xB2 +#define CHAR_SGL_QUOT_LEFT 0xB3 +#define CHAR_SGL_QUOT_RIGHT 0xB4 #define CHAR_MALE 0xB5 #define CHAR_FEMALE 0xB6 #define CHAR_CURRENCY 0xB7 -- cgit v1.2.3 From c0be66fc2e0ace7a9004fcbebe3a7595c30cda87 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 24 Jan 2020 14:42:46 -0500 Subject: Document Viridian City scripts and adjacent routes --- include/battle_setup.h | 2 +- include/constants/battle.h | 3 +++ include/constants/battle_setup.h | 2 +- include/constants/metatile_labels.h | 4 ++++ include/constants/object_events.h | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/battle_setup.h b/include/battle_setup.h index 4dc2f10f0..2aecbb0a4 100644 --- a/include/battle_setup.h +++ b/include/battle_setup.h @@ -19,7 +19,7 @@ void ConfigureAndSetUpOneTrainerBattle(u8 trainerEventObjId, const u8 *trainerSc bool32 GetTrainerFlagFromScriptPointer(const u8 *data); void SetUpTrainerMovement(void); u8 ScrSpecial_GetTrainerBattleMode(void); -u16 sub_80803D8(void); +u16 GetRivalBattleFlags(void); u16 ScrSpecial_HasTrainerBeenFought(void); void SetBattledTrainerFlag(void); bool8 HasTrainerBeenFought(u16 trainerId); diff --git a/include/constants/battle.h b/include/constants/battle.h index b28955210..63be37936 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -81,6 +81,9 @@ #define IS_BATTLE_TYPE_GHOST_WITHOUT_SCOPE(flags) ((flags) & BATTLE_TYPE_GHOST && !((flags) & BATTLE_TYPE_GHOST_UNVEILED)) #define IS_BATTLE_TYPE_GHOST_WITH_SCOPE(flags) ((flags) & BATTLE_TYPE_GHOST && (flags) & BATTLE_TYPE_GHOST_UNVEILED) +#define RIVAL_BATTLE_HEAL_AFTER 1 +#define RIVAL_BATTLE_TUTORIAL 3 + // Battle Outcome defines #define B_OUTCOME_WON 0x1 #define B_OUTCOME_LOST 0x2 diff --git a/include/constants/battle_setup.h b/include/constants/battle_setup.h index 8f700dc04..1e804fd18 100644 --- a/include/constants/battle_setup.h +++ b/include/constants/battle_setup.h @@ -10,6 +10,6 @@ #define TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE 6 #define TRAINER_BATTLE_REMATCH_DOUBLE 7 #define TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC 8 -#define TRAINER_BATTLE_TUTORIAL 9 +#define TRAINER_BATTLE_EARLY_RIVAL 9 #endif // GUARD_CONSTANTS_BATTLE_SETUP_H diff --git a/include/constants/metatile_labels.h b/include/constants/metatile_labels.h index 7cdfb25e5..0fe5bad47 100644 --- a/include/constants/metatile_labels.h +++ b/include/constants/metatile_labels.h @@ -4,6 +4,10 @@ // General #define METATILE_General_CalmWater 0x12B +// PokeMart +#define METATILE_Shop_CounterMid_Top 0x2BF +#define METATILE_Shop_CounterMid_Bottom 0x2C0 + // Pokemon Mansion #define METATILE_PokemonMansion_Floor 0x284 #define METATILE_PokemonMansion_Floor_ShadeFull 0x285 diff --git a/include/constants/object_events.h b/include/constants/object_events.h index 60783a793..d6f33b33c 100644 --- a/include/constants/object_events.h +++ b/include/constants/object_events.h @@ -35,7 +35,7 @@ #define OBJECT_EVENT_GFX_WOMAN_3 31 #define OBJECT_EVENT_GFX_OLD_MAN_1 32 #define OBJECT_EVENT_GFX_OLD_MAN_2 33 -#define OBJECT_EVENT_GFX_VIRIDIAN_DRUNK 34 +#define OBJECT_EVENT_GFX_OLD_MAN_LYING_DOWN 34 #define OBJECT_EVENT_GFX_OLD_WOMAN 35 #define OBJECT_EVENT_GFX_TUBER_M_1 36 #define OBJECT_EVENT_GFX_TUBER_F 37 -- cgit v1.2.3 From 70e7f464cafb9173aef2eb0a8a7b47bc90238f09 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 24 Jan 2020 21:57:31 -0500 Subject: PLAYER_NAME_LENGTH to 7 --- include/global.h | 14 +++++++------- include/trainer_card.h | 2 +- include/union_room.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 686ecb11c..3da77e307 100644 --- a/include/global.h +++ b/include/global.h @@ -182,13 +182,13 @@ struct BerryCrush u32 unk; }; -#define PLAYER_NAME_LENGTH 8 +#define PLAYER_NAME_LENGTH 7 #define LINK_B_RECORDS_COUNT 5 struct LinkBattleRecord { - u8 name[PLAYER_NAME_LENGTH]; + u8 name[PLAYER_NAME_LENGTH + 1]; u16 trainerId; u16 wins; u16 losses; @@ -261,7 +261,7 @@ struct BattleTowerData // Leftover from R/S struct SaveBlock2 { - /*0x000*/ u8 playerName[PLAYER_NAME_LENGTH]; + /*0x000*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x008*/ u8 playerGender; // MALE, FEMALE /*0x009*/ u8 specialSaveWarpFlags; /*0x00A*/ u8 playerTrainerId[4]; @@ -312,7 +312,7 @@ struct SecretBaseRecord /*0x1A9D*/ u8 gender:1; /*0x1A9D*/ u8 sbr_field_1_5:1; /*0x1A9D*/ u8 sbr_field_1_6:2; - /*0x1A9E*/ u8 trainerName[7]; // TODO: Change PLAYER_NAME_LENGTH to 7 + /*0x1A9E*/ u8 trainerName[7]; // TODO: Change PLAYER_NAME_LENGTH + 1 to 7 /*0x1AA5*/ u8 trainerId[4]; // byte 0 is used for determining trainer class /*0x1AA9*/ u8 language; /*0x1AAA*/ u16 sbr_field_e; @@ -404,7 +404,7 @@ struct UnkMauvilleOldManStruct u8 unk_2D95; /*0x2D96*/ u16 mauvilleOldMan_ecArray[6]; /*0x2DA2*/ u16 mauvilleOldMan_ecArray2[6]; - /*0x2DAE*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; + /*0x2DAE*/ u8 playerName[PLAYER_NAME_LENGTH + 1 + 1]; /*0x2DB6*/ u8 filler_2DB6[0x3]; /*0x2DB9*/ u8 playerTrainerId[4]; u8 unk_2DBD; @@ -715,7 +715,7 @@ struct TrainerRematchState struct TrainerNameRecord { u32 trainerId; - u8 trainerName[PLAYER_NAME_LENGTH]; + u8 trainerName[PLAYER_NAME_LENGTH + 1]; }; #define UNION_ROOM_KB_ROW_COUNT 10 @@ -772,7 +772,7 @@ struct SaveBlock1 /*0x361C*/ struct RamScript ramScript; /*0x3A08*/ u8 filler3A08[16]; /*0x3A18*/ u8 seen2[DEX_FLAGS_NO]; - /*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH]; + /*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH + 1]; /*0x3A54*/ struct FameCheckerSaveData fameChecker[NUM_FAMECHECKER_PERSONS]; /*0x3A94*/ u8 filler3A94[0x40]; /*0x3AD4*/ u8 unk3AD4[UNION_ROOM_KB_ROW_COUNT][21]; diff --git a/include/trainer_card.h b/include/trainer_card.h index 06844dc2e..ed3e803d5 100644 --- a/include/trainer_card.h +++ b/include/trainer_card.h @@ -24,7 +24,7 @@ struct TrainerCard /*0x20*/ u16 pokemonTrades; /*0x24*/ u32 money; /*0x28*/ u16 var_28[4]; - /*0x30*/ u8 playerName[PLAYER_NAME_LENGTH]; + /*0x30*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; /*0x38*/ u8 version; /*0x3A*/ u16 var_3A; /*0x3C*/ u32 berryCrushPoints; diff --git a/include/union_room.h b/include/union_room.h index 3cb8eb84a..7e48b3e6e 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -7,7 +7,7 @@ struct UnkStruct_Shared { struct GFtgtGname gname; - u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH]; + u8 ALIGNED(4) playerName[PLAYER_NAME_LENGTH + 1]; }; struct UnkStruct_x1C -- cgit v1.2.3 From c99246fccfc6f04f015d0b5b2850fa7d01914961 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Jan 2020 08:52:18 -0500 Subject: through sub_81298F8 --- include/link_rfu.h | 2 ++ include/strings.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/link_rfu.h b/include/link_rfu.h index 9dac781b3..8e4da4d87 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -327,6 +327,8 @@ bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx); bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx); bool32 sub_80FBA1C(void); void sub_80FA4A8(void); +void sub_80FB9D0(void); +void sub_80FB030(u32 a0); #include "mevent_server.h" extern const struct mevent_server_cmd gMEventSrvScript_OtherTrainerCanceled[]; diff --git a/include/strings.h b/include/strings.h index a57493a9b..81cbc63c1 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1061,4 +1061,18 @@ extern const u8 gText_CommStandbyAwaitingOtherPlayer[]; extern const u8 gText_RefusedBattle[]; extern const u8 gText_BattleWasRefused[]; +// union_room_chat +extern const u8 gText_F700JoinedChat[]; +extern const u8 gText_F700LeftChat[]; +extern const u8 gText_Hello[]; +extern const u8 gText_Pokemon2[]; +extern const u8 gText_Trade[]; +extern const u8 gText_Battle[]; +extern const u8 gText_Lets[]; +extern const u8 gText_Ok[]; +extern const u8 gText_Sorry[]; +extern const u8 gText_YaySmileEmoji[]; +extern const u8 gText_ThankYou[]; +extern const u8 gText_ByeBye[]; + #endif //GUARD_STRINGS_H -- cgit v1.2.3 From f249df41e3620c210841b57b7520f53b692fd411 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Jan 2020 10:47:17 -0500 Subject: union_room_chat_display through sub_812A1B8 --- include/union_room_chat.h | 7 ++++++- include/union_room_chat_display.h | 12 ++++++++++++ include/union_room_chat_objects.h | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 include/union_room_chat_display.h create mode 100644 include/union_room_chat_objects.h (limited to 'include') diff --git a/include/union_room_chat.h b/include/union_room_chat.h index 66daac376..3488e71bc 100644 --- a/include/union_room_chat.h +++ b/include/union_room_chat.h @@ -1,8 +1,13 @@ #ifndef GUARD_UNION_ROOM_CHAT_H #define GUARD_UNION_ROOM_CHAT_H -void sub_801DD98(void); void sub_8128420(void); +u8 *sub_8129714(void); +void sub_8129730(u32 *a0, u32 *a1); +u8 *sub_8129758(void); +u16 sub_8129788(void); +u8 *sub_81297C4(void); +u16 sub_81297D0(void); void copy_strings_to_sav1(void); #endif // GUARD_UNION_ROOM_CHAT_H diff --git a/include/union_room_chat_display.h b/include/union_room_chat_display.h new file mode 100644 index 000000000..597296869 --- /dev/null +++ b/include/union_room_chat_display.h @@ -0,0 +1,12 @@ +#ifndef GUARD_UNION_ROOM_CHAT_DISPLAY_H +#define GUARD_UNION_ROOM_CHAT_DISPLAY_H + +bool8 sub_8129B14(void); +bool32 sub_8129B78(void); +void sub_8129B88(void); +void sub_8129BFC(void); +void sub_8129C34(u16 a0, u8 a1); +u8 sub_8129C8C(u8 a0); +s8 sub_812A568(void); + +#endif //GUARD_UNION_ROOM_CHAT_DISPLAY_H diff --git a/include/union_room_chat_objects.h b/include/union_room_chat_objects.h new file mode 100644 index 000000000..41db4d3a4 --- /dev/null +++ b/include/union_room_chat_objects.h @@ -0,0 +1,16 @@ +#ifndef GUARD_UNION_ROOM_CHAT_OBJECTS_H +#define GUARD_UNION_ROOM_CHAT_OBJECTS_H + +bool32 sub_812AE70(void); +void sub_812AEB0(void); +void sub_812AEC8(void); +void sub_812AEFC(bool8 invisible); +void sub_812AF1C(void); +void sub_812AF8C(u32 idx); +void sub_812AFC0(void); +bool32 sub_812AFFC(void); +void sub_812B048(void); +void sub_812B100(void); +void sub_812B160(void); + +#endif //GUARD_UNION_ROOM_CHAT_OBJECTS_H -- cgit v1.2.3 From c0b05784d64a6fce12eb25c7e40e401a59593e68 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Jan 2020 13:35:34 -0500 Subject: Finish union_room_chat_display --- include/graphics.h | 8 ++++++++ include/strings.h | 35 ++++++++++++++++++++++++++++------- include/text_window.h | 1 + include/trade.h | 4 ++++ include/union_room_chat.h | 14 ++++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/graphics.h b/include/graphics.h index e87acb556..c3620279d 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4864,4 +4864,12 @@ extern const u32 gUnknown_8E83444[]; extern const u32 gBagBgPalette[]; extern const u32 gBagBgPalette_FemaleOverride[]; +// union_room_chat_display +extern const u16 gUnknown_8EAA9F0[]; +extern const u32 gUnknown_8EAAA10[]; +extern const u32 gUnknown_8EAAA6C[]; +extern const u16 gLinkMiscMenu_Pal[]; +extern const u32 gLinkMiscMenu_Gfx[]; +extern const u32 gLinkMiscMenu_Tilemap[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/strings.h b/include/strings.h index 81cbc63c1..7821825cf 100644 --- a/include/strings.h +++ b/include/strings.h @@ -40,7 +40,6 @@ extern const u8 gText_Second[]; extern const u8 gText_Third[]; extern const u8 gText_NoDecorations[]; extern const u8 gText_NoDecorationsInUse[]; -extern const u8 gText_Exit[]; extern const u8 gText_Cancel[]; extern const u8 gText_Color161Shadow161[]; extern const u8 gText_GoBackPrevMenu[]; @@ -288,7 +287,6 @@ extern const u8 gText_ThreePkmnAreNeeded[]; extern const u8 gText_TwoPokemonAreNeeded[]; extern const u8 gText_PokemonCantBeSame[]; extern const u8 gText_NoIdenticalHoldItems[]; -extern const u8 gString_Dummy[]; extern const u8 gText_DoWhatWithPokemon[]; extern const u8 gText_RestoreWhichMove[]; extern const u8 gText_BoostPp[]; @@ -327,13 +325,9 @@ extern const u8 gText_SendOut[]; extern const u8 gText_Enter[]; extern const u8 gText_NoEntry[]; extern const u8 gText_Store[]; -extern const u8 gText_Register[]; extern const u8 gText_Trade4[]; extern const u8 gText_NotPkmnOtherTrainerWants[]; extern const u8 gText_ThatIsntAnEgg[]; -extern const u8 gText_PkmnCantBeTradedNow[]; -extern const u8 gText_OtherTrainersPkmnCantBeTraded[]; -extern const u8 gText_EggCantBeTradedNow[]; extern const u8 gText_OtherTrainerCantAcceptPkmn[]; extern const u8 gText_CantTradeWithTrainer[]; extern const u8 gUnknown_84176CF[]; @@ -346,7 +340,6 @@ extern const u8 gText_PkmnCantParticipate[]; extern const u8 gText_CancelParticipation[]; extern const u8 gUnknown_8417494[]; extern const u8 gMenuText_Confirm[]; -extern const u8 gText_Lv[]; extern const u8 gText_MaleSymbol[]; extern const u8 gText_FemaleSymbol[]; extern const u8 gText_Slash[]; @@ -984,6 +977,16 @@ extern const u8 gUnknown_8415F6C[]; extern const u8 gUnknown_8415FFF[]; extern const u8 gUnknown_8416002[]; +// daycare +extern const u8 gText_Lv[]; +extern const u8 gDaycareText_GetAlongVeryWell[]; +extern const u8 gDaycareText_GetAlong[]; +extern const u8 gDaycareText_DontLikeOther[]; +extern const u8 gDaycareText_PlayOther[]; +extern const u8 gExpandedPlaceholder_Empty[]; +extern const u8 gText_HatchedFromEgg[]; +extern const u8 gText_NickHatchPrompt[]; + // trainer card extern const u8 gText_WaitingTrainerFinishReading[]; extern const u8 gText_TrainerCardName[]; @@ -1075,4 +1078,22 @@ extern const u8 gText_YaySmileEmoji[]; extern const u8 gText_ThankYou[]; extern const u8 gText_ByeBye[]; +// union_room_chat_display +extern const u8 gText_QuitChatting[]; +extern const u8 gText_RegisterTextWhere[]; +extern const u8 gText_RegisterTextHere[]; +extern const u8 gText_InputText[]; +extern const u8 gText_ExitingTheChat[]; +extern const u8 gText_LeaderHasLeftEndingChat[]; +extern const u8 gText_RegisteredTextChanged_OKtoSave[]; +extern const u8 gText_RegisteredTextChanged_AlreadySavedFile[]; +extern const u8 gText_RegisteredTextChanged_SavingDontTurnOff[]; +extern const u8 gText_RegisteredTextChanged_SavedTheGame[]; +extern const u8 gText_IfLeaderLeavesChatWillEnd[]; +extern const u8 gText_Upper[]; +extern const u8 gText_Lower[]; +extern const u8 gText_Symbols[]; +extern const u8 gText_Register2[]; +extern const u8 gText_Exit[]; + #endif //GUARD_STRINGS_H diff --git a/include/text_window.h b/include/text_window.h index 8e8466145..3796629b4 100644 --- a/include/text_window.h +++ b/include/text_window.h @@ -26,6 +26,7 @@ void TextWindow_SetUserSelectedFrame(u8 windowId, u16 tileStart, u8 palette); void LoadUserWindowBorderGfx(u8 windowId, u16 tileStart, u8 palette); void sub_814FDA0(u8 windowId, u16 tileStart, u8 palette); void DrawTextBorderOuter(u8 windowId, u16 tileStart, u8 palette); +void DrawTextBorderInner(u8 windowId, u16 tileNum, u8 palNum); void TextWindow_LoadTilesStdFrame1(u8 windowId, u16 destOffset); void sub_814FE6C(u8 windowId, u16 destOffset, u8 palIdx); void sub_814FEEC(u8 windowId, u16 destOffset, u8 palIdx); diff --git a/include/trade.h b/include/trade.h index d5106b172..f8e285e40 100644 --- a/include/trade.h +++ b/include/trade.h @@ -8,6 +8,10 @@ extern struct MailStruct gLinkPartnerMail[6]; extern u8 gSelectedTradeMonPositions[2]; +extern const u8 gText_MaleSymbol4[]; +extern const u8 gText_FemaleSymbol4[]; +extern const u8 gText_GenderlessSymbol[]; + extern const u16 gUnknown_826601C[]; void CB2_ReturnFromLinkTrade(void); s32 sub_804FB34(void); diff --git a/include/union_room_chat.h b/include/union_room_chat.h index 3488e71bc..93bd4a55f 100644 --- a/include/union_room_chat.h +++ b/include/union_room_chat.h @@ -1,13 +1,27 @@ #ifndef GUARD_UNION_ROOM_CHAT_H #define GUARD_UNION_ROOM_CHAT_H +enum +{ + UNION_ROOM_KB_PAGE_UPPER, + UNION_ROOM_KB_PAGE_LOWER, + UNION_ROOM_KB_PAGE_EMOJI, + UNION_ROOM_KB_PAGE_COUNT +}; + +extern const u8 *const gUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT][UNION_ROOM_KB_ROW_COUNT]; + void sub_8128420(void); +u8 *sub_81294B0(int arg0); u8 *sub_8129714(void); void sub_8129730(u32 *a0, u32 *a1); u8 *sub_8129758(void); u16 sub_8129788(void); u8 *sub_81297C4(void); u16 sub_81297D0(void); +int sub_81297DC(void); +u8 *sub_8129814(void); void copy_strings_to_sav1(void); +u8 GetCurrentKeyboardPage(void); #endif // GUARD_UNION_ROOM_CHAT_H -- cgit v1.2.3 From 1f47b6ae4fefbe50a3680251fc9b88a7655e7179 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Jan 2020 16:10:18 -0500 Subject: union_room_chat_objects --- include/graphics.h | 3 +++ include/union_room_chat.h | 3 +++ include/union_room_chat_objects.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/graphics.h b/include/graphics.h index c3620279d..e77cd2502 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4872,4 +4872,7 @@ extern const u16 gLinkMiscMenu_Pal[]; extern const u32 gLinkMiscMenu_Gfx[]; extern const u32 gLinkMiscMenu_Tilemap[]; +// union_room_chat_objects +extern const u32 gUnknown_8EA1A50[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/union_room_chat.h b/include/union_room_chat.h index 93bd4a55f..13e51289e 100644 --- a/include/union_room_chat.h +++ b/include/union_room_chat.h @@ -13,13 +13,16 @@ extern const u8 *const gUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT][UNION_RO void sub_8128420(void); u8 *sub_81294B0(int arg0); +void sub_8129700(u8 *arg0, u8 *arg1); u8 *sub_8129714(void); +int sub_8129720(void); void sub_8129730(u32 *a0, u32 *a1); u8 *sub_8129758(void); u16 sub_8129788(void); u8 *sub_81297C4(void); u16 sub_81297D0(void); int sub_81297DC(void); +int sub_81297E8(void); u8 *sub_8129814(void); void copy_strings_to_sav1(void); u8 GetCurrentKeyboardPage(void); diff --git a/include/union_room_chat_objects.h b/include/union_room_chat_objects.h index 41db4d3a4..38c94b668 100644 --- a/include/union_room_chat_objects.h +++ b/include/union_room_chat_objects.h @@ -4,7 +4,7 @@ bool32 sub_812AE70(void); void sub_812AEB0(void); void sub_812AEC8(void); -void sub_812AEFC(bool8 invisible); +void sub_812AEFC(bool32 invisible); void sub_812AF1C(void); void sub_812AF8C(u32 idx); void sub_812AFC0(void); -- cgit v1.2.3 From 0ebdbcfd5b1d352d37f5806943b124e915cbfe8b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Jan 2020 19:58:39 -0500 Subject: Document union room chat --- include/global.h | 2 +- include/graphics.h | 8 ++++---- include/link_rfu.h | 4 ++-- include/union_room_chat.h | 28 ++++++++++++++-------------- include/union_room_chat_display.h | 36 +++++++++++++++++++++++++++++------- include/union_room_chat_objects.h | 22 +++++++++++----------- 6 files changed, 61 insertions(+), 39 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 3da77e307..9f46c2eee 100644 --- a/include/global.h +++ b/include/global.h @@ -775,7 +775,7 @@ struct SaveBlock1 /*0x3A4C*/ u8 rivalName[PLAYER_NAME_LENGTH + 1]; /*0x3A54*/ struct FameCheckerSaveData fameChecker[NUM_FAMECHECKER_PERSONS]; /*0x3A94*/ u8 filler3A94[0x40]; - /*0x3AD4*/ u8 unk3AD4[UNION_ROOM_KB_ROW_COUNT][21]; + /*0x3AD4*/ u8 registeredTexts[UNION_ROOM_KB_ROW_COUNT][21]; /*0x3BA8*/ struct TrainerNameRecord trainerNameRecords[20]; /*0x3C98*/ struct DaycareMon route5DayCareMon; /*0x3D24*/ u8 filler3D24[0x10]; diff --git a/include/graphics.h b/include/graphics.h index e77cd2502..467a1d461 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4865,14 +4865,14 @@ extern const u32 gBagBgPalette[]; extern const u32 gBagBgPalette_FemaleOverride[]; // union_room_chat_display -extern const u16 gUnknown_8EAA9F0[]; -extern const u32 gUnknown_8EAAA10[]; -extern const u32 gUnknown_8EAAA6C[]; +extern const u16 gUnionRoomChatPanelBgPal_7[]; +extern const u32 gUnionRoomChatPanelBgTiles[]; +extern const u32 gUnionRoomChatPanelBgMap[]; extern const u16 gLinkMiscMenu_Pal[]; extern const u32 gLinkMiscMenu_Gfx[]; extern const u32 gLinkMiscMenu_Tilemap[]; // union_room_chat_objects -extern const u32 gUnknown_8EA1A50[]; +extern const u32 gUnionRoomChatIcons[]; #endif //GUARD_GRAPHICS_H diff --git a/include/link_rfu.h b/include/link_rfu.h index 8e4da4d87..81dd7fdf0 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -216,7 +216,7 @@ struct UnkRfuStruct_2 /* 0x99d */ u8 unk_ce5; /* 0x99e */ u8 unk_ce6; /* 0x99f */ u8 unk_ce7; - /* 0x9a0 */ u8 unk_ce8; + /* 0x9a0 */ bool8 unk_ce8; /* 0x9a1 */ u8 unk_ce9; /* 0x9a2 */ u8 unk_cea[RFU_CHILD_MAX]; /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; @@ -325,7 +325,7 @@ 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); -bool32 sub_80FBA1C(void); +bool32 GetRfuUnkCE8(void); void sub_80FA4A8(void); void sub_80FB9D0(void); void sub_80FB030(u32 a0); diff --git a/include/union_room_chat.h b/include/union_room_chat.h index 13e51289e..3ce78b210 100644 --- a/include/union_room_chat.h +++ b/include/union_room_chat.h @@ -11,20 +11,20 @@ enum extern const u8 *const gUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT][UNION_ROOM_KB_ROW_COUNT]; -void sub_8128420(void); -u8 *sub_81294B0(int arg0); -void sub_8129700(u8 *arg0, u8 *arg1); -u8 *sub_8129714(void); -int sub_8129720(void); -void sub_8129730(u32 *a0, u32 *a1); -u8 *sub_8129758(void); -u16 sub_8129788(void); -u8 *sub_81297C4(void); -u16 sub_81297D0(void); -int sub_81297DC(void); -int sub_81297E8(void); -u8 *sub_8129814(void); -void copy_strings_to_sav1(void); +void EnterUnionRoomChat(void); +u8 *UnionRoomChat_GetWorkRegisteredText(int arg0); +void UnionRoomChat_GetCursorColAndRow(u8 *colp, u8 *rowp); +u8 *UnionRoomChat_GetMessageEntryBuffer(void); +int UnionRoomChat_LenMessageEntryBuffer(void); +void UnionRoomChat_GetBufferSelectionRegion(u32 *startp, u32 *diffp); +u8 *UnionRoomChat_GetEndOfMessageEntryBuffer(void); +u16 UnionRoomChat_GetNumCharsInMessageEntryBuffer(void); +u8 *UnionRoomChat_GetLastReceivedMessage(void); +u16 UnionRoomChat_GetReceivedPlayerIndex(void); +int UnionRoomChat_GetMessageEntryCursorPosition(void); +int UnionRoomChat_GetWhetherShouldShowCaseToggleIcon(void); +u8 *UnionRoomChat_GetNameOfPlayerWhoDisbandedChat(void); +void UnionRoomChat_InitializeRegisteredTexts(void); u8 GetCurrentKeyboardPage(void); #endif // GUARD_UNION_ROOM_CHAT_H diff --git a/include/union_room_chat_display.h b/include/union_room_chat_display.h index 597296869..f880eeecb 100644 --- a/include/union_room_chat_display.h +++ b/include/union_room_chat_display.h @@ -1,12 +1,34 @@ #ifndef GUARD_UNION_ROOM_CHAT_DISPLAY_H #define GUARD_UNION_ROOM_CHAT_DISPLAY_H -bool8 sub_8129B14(void); -bool32 sub_8129B78(void); -void sub_8129B88(void); -void sub_8129BFC(void); -void sub_8129C34(u16 a0, u8 a1); -u8 sub_8129C8C(u8 a0); -s8 sub_812A568(void); +#define CHATDISPLAYROUTINE_LOADGFX 0 +#define CHATDISPLAYROUTINE_MOVEKBCURSOR 1 +#define CHATDISPLAYROUTINE_CURSORBLINK 2 +#define CHATDISPLAYROUTINE_SHOWKBSWAPMENU 3 +#define CHATDISPLAYROUTINE_HIDEKBSWAPMENU 4 +#define CHATDISPLAYROUTINE_SWITCHPAGES 5 +#define CHATDISPLAYROUTINE_SHOWQUITCHATTINGDIALOG 6 +#define CHATDISPLAYROUTINE_DESTROYSTDMSGANDYESNO 7 +#define CHATDISPLAYROUTINE_PRINTMSG 8 +#define CHATDISPLAYROUTINE_PRINTREGISTERWHERE 9 +#define CHATDISPLAYROUTINE_CANCELREGISTER 10 +#define CHATDISPLAYROUTINE_RETURNTOKB 11 +#define CHATDISPLAYROUTINE_SCROLLCHAT 12 +#define CHATDISPLAYROUTINE_PRINTINPUTTEXT 13 +#define CHATDISPLAYROUTINE_ASKSAVE 14 +#define CHATDISPLAYROUTINE_ASKOVERWRITESAVE 15 +#define CHATDISPLAYROUTINE_PRINTSAVING 16 +#define CHATDISPLAYROUTINE_PRINTSAVEDTHEGAME 17 +#define CHATDISPLAYROUTINE_PRINTEXITINGCHAT 18 +#define CHATDISPLAYROUTINE_PRINTLEADERLEFT 19 +#define CHATDISPLAYROUTINE_SHOWCONFIRMLEADERLEAVEDIALOG 20 + +bool8 UnionRoomChat_TryAllocGraphicsWork(void); +bool32 UnionRoomChat_RunDisplaySubtask0(void); +void UnionRoomChat_FreeGraphicsWork(void); +void UnionRoomChat_RunDisplaySubtasks(void); +void UnionRoomChat_StartDisplaySubtask(u16 a0, u8 a1); +u8 RunDisplaySubtask(u8 a0); +s8 UnionRoomChat_ProcessInput(void); #endif //GUARD_UNION_ROOM_CHAT_DISPLAY_H diff --git a/include/union_room_chat_objects.h b/include/union_room_chat_objects.h index 38c94b668..879f9f86b 100644 --- a/include/union_room_chat_objects.h +++ b/include/union_room_chat_objects.h @@ -1,16 +1,16 @@ #ifndef GUARD_UNION_ROOM_CHAT_OBJECTS_H #define GUARD_UNION_ROOM_CHAT_OBJECTS_H -bool32 sub_812AE70(void); -void sub_812AEB0(void); -void sub_812AEC8(void); -void sub_812AEFC(bool32 invisible); -void sub_812AF1C(void); -void sub_812AF8C(u32 idx); -void sub_812AFC0(void); -bool32 sub_812AFFC(void); -void sub_812B048(void); -void sub_812B100(void); -void sub_812B160(void); +bool32 UnionRoomChat_TryAllocSpriteWork(void); +void UnionRoomChat_FreeSpriteWork(void); +void UnionRoomChat_CreateSelectorCursorObj(void); +void UnionRoomChat_ToggleSelectorCursorObjVisibility(bool32 invisible); +void UnionRoomChat_MoveSelectorCursorObj(void); +void UnionRoomChat_UpdateObjPalCycle(u32 idx); +void UnionRoomChat_SetSelectorCursorClosedImage(void); +bool32 UnionRoomChat_AnimateSelectorCursorReopen(void); +void UnionRoomChat_SpawnTextEntryPointerSprites(void); +void CreatePageSwitchUISprites(void); +void UpdateVisibleUnionRoomChatIcon(void); #endif //GUARD_UNION_ROOM_CHAT_OBJECTS_H -- cgit v1.2.3 From 5b36288064ee0e999a2201b2dd6479da3c99d01e Mon Sep 17 00:00:00 2001 From: jiangzhengwenjz Date: Sat, 25 Jan 2020 10:05:33 +0800 Subject: field_screen_effect --- include/event_scripts.h | 4 ++++ include/field_fadetransition.h | 1 + include/field_screen_effect.h | 1 + include/heal_location.h | 4 ++-- include/strings.h | 4 ++++ 5 files changed, 12 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/event_scripts.h b/include/event_scripts.h index b8da8f3e0..f026cb57a 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -1170,6 +1170,10 @@ extern const u8 EventScript_ResetAllMapFlags[]; // player_pc extern const u8 EventScript_PalletTown_PlayersHouse_2F_ShutDownPC[]; +// field_screen_effect +extern const u8 EventScript_MomHeal[]; +extern const u8 EventScript_AfterWhiteOutHeal[]; + // start_menu extern const u8 gText_WouldYouLikeToSaveTheGame[]; extern const u8 gText_AlreadySaveFile_WouldLikeToOverwrite[]; diff --git a/include/field_fadetransition.h b/include/field_fadetransition.h index d27d0e54a..6683f5e2e 100644 --- a/include/field_fadetransition.h +++ b/include/field_fadetransition.h @@ -20,5 +20,6 @@ void FadeTransition_FadeInOnReturnToStartMenu(void); void sub_807DCE4(void); bool32 sub_807E418(void); +void palette_bg_faded_fill_black(void); #endif // GUARD_FIELD_FADETRANSITION_H diff --git a/include/field_screen_effect.h b/include/field_screen_effect.h index e48745a7b..ca7625782 100644 --- a/include/field_screen_effect.h +++ b/include/field_screen_effect.h @@ -10,5 +10,6 @@ void sub_807E3EC(void); void DoOutwardBarnDoorWipe(void); void Task_BarnDoorWipe(u8 taskId); void sub_807DC00(void); +void sub_807F5F0(void); #endif // GUARD_FIELD_SCREEN_EFFECT_H diff --git a/include/heal_location.h b/include/heal_location.h index 0143b8158..aaa2178c6 100644 --- a/include/heal_location.h +++ b/include/heal_location.h @@ -14,8 +14,8 @@ struct HealLocation { s8 group; s8 map; - u16 x; - u16 y; + s16 x; + s16 y; }; // Exported RAM declarations diff --git a/include/strings.h b/include/strings.h index a57493a9b..0969a8338 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1033,6 +1033,10 @@ extern const u8 gText_RegionMap_AreaDesc_AlteringCave[]; extern const u8 gText_RegionMap_AreaDesc_PatternBush[]; extern const u8 gText_RegionMap_AreaDesc_DottedHole[]; +// field_screen_effect +extern const u8 gUnknown_841B554[]; +extern const u8 gUnknown_841B5B6[]; + // save_failed_screen extern const u8 gText_SaveFailedScreen_CheckingBackupMemory[]; extern const u8 gText_SaveFailedScreen_BackupMemoryDamaged[]; -- cgit v1.2.3 From 52fbc43d73995977aa8f6c45405a91c68d515061 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 25 Jan 2020 21:00:51 -0500 Subject: Address review comments --- include/constants/global.h | 5 ++++ include/global.h | 73 +++++++++++++++++++++++++++++++--------------- 2 files changed, 55 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/constants/global.h b/include/constants/global.h index 77ef6f203..7f3c80bb4 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -38,6 +38,10 @@ #define FEMALE 1 #define GENDER_COUNT 2 +#define BARD_SONG_LENGTH 6 +#define NUM_STORYTELLER_TALES 4 +#define NUM_TRADER_ITEMS 4 + #define OPTIONS_BUTTON_MODE_HELP 0 #define OPTIONS_BUTTON_MODE_LR 1 #define OPTIONS_BUTTON_MODE_L_EQUALS_A 2 @@ -62,6 +66,7 @@ #define MAX_MON_MOVES 4 +#define TRAINER_ID_LENGTH 4 #define PARTY_SIZE 6 #define MULTI_PARTY_SIZE (PARTY_SIZE / 2) diff --git a/include/global.h b/include/global.h index 9f46c2eee..2f87a0c29 100644 --- a/include/global.h +++ b/include/global.h @@ -312,7 +312,7 @@ struct SecretBaseRecord /*0x1A9D*/ u8 gender:1; /*0x1A9D*/ u8 sbr_field_1_5:1; /*0x1A9D*/ u8 sbr_field_1_6:2; - /*0x1A9E*/ u8 trainerName[7]; // TODO: Change PLAYER_NAME_LENGTH + 1 to 7 + /*0x1A9E*/ u8 trainerName[PLAYER_NAME_LENGTH]; /*0x1AA5*/ u8 trainerId[4]; // byte 0 is used for determining trainer class /*0x1AA9*/ u8 language; /*0x1AAA*/ u16 sbr_field_e; @@ -398,41 +398,68 @@ struct MailStruct /*0x20*/ u16 itemId; }; -struct UnkMauvilleOldManStruct +struct MauvilleManCommon { - u8 unk_2D94; - u8 unk_2D95; - /*0x2D96*/ u16 mauvilleOldMan_ecArray[6]; - /*0x2DA2*/ u16 mauvilleOldMan_ecArray2[6]; - /*0x2DAE*/ u8 playerName[PLAYER_NAME_LENGTH + 1 + 1]; - /*0x2DB6*/ u8 filler_2DB6[0x3]; - /*0x2DB9*/ u8 playerTrainerId[4]; - u8 unk_2DBD; + u8 id; +}; + +struct MauvilleManBard +{ + /*0x00*/ u8 id; + /*0x02*/ u16 songLyrics[BARD_SONG_LENGTH]; + /*0x0E*/ u16 temporaryLyrics[BARD_SONG_LENGTH]; + /*0x1A*/ u8 playerName[PLAYER_NAME_LENGTH + 1]; + /*0x22*/ u8 filler_2DB6[0x3]; + /*0x25*/ u8 playerTrainerId[TRAINER_ID_LENGTH]; + /*0x29*/ bool8 hasChangedSong; + /*0x2A*/ u8 language; }; /*size = 0x2C*/ -struct UnkMauvilleOldManStruct2 +struct MauvilleManStoryteller +{ + u8 id; + bool8 alreadyRecorded; + u8 filler2[2]; + u8 gameStatIDs[NUM_STORYTELLER_TALES]; + u8 trainerNames[NUM_STORYTELLER_TALES][PLAYER_NAME_LENGTH]; + u8 statValues[NUM_STORYTELLER_TALES][4]; + u8 language[NUM_STORYTELLER_TALES]; +}; + +struct MauvilleManGiddy { - u8 filler0; - u8 unk1; - u8 unk2; - u16 mauvilleOldMan_ecArray[10]; - u8 mauvilleOldMan_ecArray2[12]; - u8 fillerF[0x2]; + /*0x00*/ u8 id; + /*0x01*/ u8 taleCounter; + /*0x02*/ u8 questionNum; + /*0x04*/ u16 randomWords[10]; + /*0x18*/ u8 questionList[8]; + /*0x20*/ u8 language; }; /*size = 0x2C*/ +struct MauvilleManHipster +{ + u8 id; + bool8 alreadySpoken; + u8 language; +}; + struct MauvilleOldManTrader { - u8 unk0; - u8 unk1[4]; - u8 unk5[4][11]; - u8 unk31; + u8 id; + u8 decorIds[NUM_TRADER_ITEMS]; + u8 playerNames[NUM_TRADER_ITEMS][11]; + u8 alreadyTraded; + u8 language[NUM_TRADER_ITEMS]; }; typedef union OldMan { - struct UnkMauvilleOldManStruct oldMan1; - struct UnkMauvilleOldManStruct2 oldMan2; + struct MauvilleManCommon common; + struct MauvilleManBard bard; + struct MauvilleManGiddy giddy; + struct MauvilleManHipster hipster; struct MauvilleOldManTrader trader; + struct MauvilleManStoryteller storyteller; u8 filler[0x40]; } OldMan; -- cgit v1.2.3 From 517f8fc9ef91dcee9607be3cdab38c3781164e4d Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 28 Jan 2020 16:05:15 -0500 Subject: Start doccing help system --- include/help_system.h | 34 +++++++++++++++++----------------- include/overworld.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'include') 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/overworld.h b/include/overworld.h index a7031e56d..b783248ce 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); -- cgit v1.2.3 From 1cc9d0eea9a8ca4ff03ff30c2eadacb35557e1d3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 29 Jan 2020 12:39:54 -0500 Subject: Document link_rfu.c as official SDK linkManager.c --- include/link_rfu.h | 239 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 172 insertions(+), 67 deletions(-) (limited to 'include') diff --git a/include/link_rfu.h b/include/link_rfu.h index 81dd7fdf0..f90de0daf 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -4,6 +4,101 @@ #include "global.h" #include "librfu.h" +//----------------------------------------------------------------- +// Constant definition +//----------------------------------------------------------------- + +// Link Manager operation mode (specified by u8 parent_child argument of rfu_LMAN_establishConnection) +//#define MODE_CHILD 0 // Start Link Manager in CHILD mode +//#define MODE_PARENT 1 // Start Link Manager in PARENT mode +//Note: This value uses the item defined by AgbRFU_LL.h. +#define MODE_P_C_SWITCH 2 // Start Link Manager in parent-child switching mode. + + +// Error code returned by Link Manager API (rfu_LMAN_...return value of function) +#define LMAN_ERROR_MANAGER_BUSY 1 // Link Manager is already running. +#define LMAN_ERROR_AGB_CLK_SLAVE 2 // AGB is clock slave so link manager cannot run. +#define LMAN_ERROR_PID_NOT_FOUND 3 // Parent device information of the specified PID does not exist in rfuLinkStatus->partner[0-3]. +#define LMAN_ERROR_ILLEGAL_PARAMETER 4 // Specified argument is unusual. +#define LMAN_ERROR_NOW_LINK_RECOVERY 5 // New settings were ignored because link recovery was under way when current link recovery was ON and new settings turned link recovery OFF. +#define LMAN_ERROR_NOW_COMMUNICATION 6 // New settings were ignored because currently communicating with NI. +#define LMAN_ERROR_NOW_SEARCH_PARENT 7 // Parent search currently under way, so ignore new setting. + +// Details of messages and the related parameters returned by the u8 msg, u8 param_count, and lman.param[0-1] arguments of the LMAN callback generated by the operation of the Link Manager. +// msg name msg No. param qty param[0] param[1] Description +#define LMAN_MSG_INITIALIZE_COMPLETED 0x00 // 0 - - Generated when RFU reset and initial settings are completed +#define LMAN_MSG_NEW_CHILD_CONNECT_DETECTED 0x10 // 1 Bit indicating slot - Generated when new child device connection was detected at RFU level. +// with detected connection +#define LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED 0x11 // 1 Bit indicating slot - Generated when game identification information from child device connected at RFU level is received and accepted (game serial numbers match). +// where connection was accepted +#define LMAN_MSG_NEW_CHILD_CONNECT_REJECTED 0x12 // 1 Bit indicating slot - Generated when the connection from the child device connected at RFU level is rejected (game identification information reception failed or game serial numbers do not match). +// where connection was rejected +#define LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED 0x13 // 0 - - Generated when SearchChild operation time expires. +#define LMAN_MSG_END_WAIT_CHILD_NAME 0x14 // 0 - - Generated when reception of game identification information from all child devices completes after the SearchChild operation time expires. +#define LMAN_MSG_PARENT_FOUND 0x20 // 1 Bit indicating - Generated when valid (game serial numbers match) parent devices are found during SearchParent. +// rfuLinkStatus->partner[x] index number storing the valid parent devices (game serial number matches) from among the discovered parent devices. +#define LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED 0x21 // 0 - - Generated when SearchParent time expires. +#define LMAN_MSG_CONNECT_PARENT_SUCCESSED 0x22 // 1 Connected slot number - Generated when connection with parent device at RFU level succeeds. +#define LMAN_MSG_CONNECT_PARENT_FAILED 0x23 // 1 Connection failure reason - Generated when connection with parent device at RFU level fails. +#define LMAN_MSG_CHILD_NAME_SEND_COMPLETED 0x24 // 0 - - Generated when transmission of the child's game identification information to the parent device succeeds after connection with parent device at RFU level succeeds. +#define LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED 0x25 // 0 - - Generated when transmission of the child's game identification information to the parent device fails after connection with parent device at RFU level succeeds. +#define LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED 0x30 // 1 Bit indicating slot - Generated when a link cut is detected and that slot disconnects. (Generated only when link recovery is OFF.) +// that was disconnected and where link cut was detected but link recover not attempted +#define LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY 0x31 // 1 Bit indicating slot - Generated when a link cut is detected and the link recovery process starts. (Generated only when link recovery is ON.) +// where link cut was detected and link recovery was started +#define LMAN_MSG_LINK_RECOVERY_SUCCESSED 0x32 // 1 Bit indicating slot - Generated when link recovery succeeds. (Generated only when link recovery is ON.) +// where link recovery succeeded +#define LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED 0x33 // 1 Bit indicating slot - Generated when link recovery fails and that slot disconnects. (Generated only when link recovery is ON.) +// where link recovery failed and that disconnected +#define LMAN_MSG_LINK_DISCONNECTED_BY_USER 0x40 // 1 Generated on disconnection by execution of rfu_REQ_disconnect by disconnected user. +// Slot indicated in bits *Note: If rfu_REQ_disconnect is used for disconnection during link recovery in the child device, the link recovery is also suspended, but the only message returned is DISCONNECTED_BY_USER. +#define LMAN_MSG_CHANGE_AGB_CLOCK_SLAVE 0x41 // 0 - - Generated when the AGB-RFU clock switches to AGB clock slave after a successful connection or link recovery in the child device. (This message is not generated when the AGB switches to a clock slave when an MSC callback completes.) +#define LMAN_MSG_CHANGE_AGB_CLOCK_MASTER 0x45 // 0 - - Generated when the AGB-RFU intercommunication clock is switched to the AGB clock master in the child device. +#define LMAN_MSG_RFU_POWER_DOWN 0x42 // 0 - - Generated when the RFU enters power conservation mode with rfu_LMAN_powerDownRFU. +#define LMAN_MSG_MANAGER_STOPPED 0x43 // 0 - - Generated when the Link Manager is halted by rfu_LMAN_stopLMAN(0). (This message is not generated during SearchChild, SearchParent, ConnectParent, and LinkRecovery. A message (-PERIOD_EXPIRED, -SUCCESSED, -FAILED) corresponding to the operation completion is returned.) +#define LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET 0x44 // 0 - - Generates when the Link Manager is forcibly halted by rfu_LMAN_stopLMAN(1) and RFU is reset. + +#define LMAN_MSG_RECV_DATA_REQ_COMPLETED 0x50 // 0 - - Generated when the execution of rfu_REQ_recvData completes. (This message is not notification of data reception from a RFU.) + +#define LMAN_MSG_REQ_API_ERROR 0xf0 // 2 REQ_commandID REQ_result REQ-API resulted in error. This message is also generated by an REQ-API executed by either the link manager or the user. +#define LMAN_MSG_WATCH_DOG_TIMER_ERROR 0xf1 // 0 - - Generated when a MSC callback does not occur even after 6 seconds pass when the AGB is the clock slave. +#define LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA 0xf2 // 0 - - Generated when an automatic starting DMA, such as HDMA, is issued at the same time the RFU attempts to send notification and to return the AGB to the clock master while the AGB is the clock slave and the exchange of that information (REQ command) fails. +#define LMAN_MSG_LMAN_API_ERROR_RETURN 0xf3 // 1 Return error code - Generated when LMAN-API execution returns an error. +#define LMAN_MSG_RFU_FATAL_ERROR 0xff // 0 - - Generated when the Link Manager cannot recongize a RFU because of the execution of rfu_REQBN_softReset_and_checkID. + + +// Value of lman.childClockSlave_flag +#define RFU_CHILD_CLOCK_SLAVE_OFF 0 // The child device is not operating in AGB clock slave mode. (The child device is in this mode in cases such as when the child has not established a connection or during link recovery.) +#define RFU_CHILD_CLOCK_SLAVE_ON 1 // The child device is operating in AGB clock slave mode. (Child automatically enters this mode when a connection is established.) +#define RFU_CHILD_CLOCK_SLAVE_OFF_REQ 2 // The child device has requested that AGB clock slave mode be halted. + +// State of Link Manager (values of lman.state, lman.next_state) +#define LMAN_STATE_READY 0x00 // Waiting +#define LMAN_STATE_SOFT_RESET_AND_CHECK_ID 0x01 // Requesting execution of rfu_REQBN_softResetAndCheckID (same as below) +#define LMAN_STATE_RESET 0x02 // rfu_REQ_reset +#define LMAN_STATE_CONFIG_SYSTEM 0x03 // rfu_REQ_configSystem +#define LMAN_STATE_CONFIG_GAME_DATA 0x04 // rfu_REQ_configGameData +#define LMAN_STATE_START_SEARCH_CHILD 0x05 // rfu_REQ_startSearchChild +#define LMAN_STATE_POLL_SEARCH_CHILD 0x06 // rfu_REQ_pollSearchChild +#define LMAN_STATE_END_SEARCH_CHILD 0x07 // rfu_REQ_endSearchChild +#define LMAN_STATE_WAIT_RECV_CHILD_NAME 0x08 // Awaiting reception of game name from connected child device. +#define LMAN_STATE_START_SEARCH_PARENT 0x09 // rfu_REQ_startSearchParent +#define LMAN_STATE_POLL_SEARCH_PARENT 0x0a // rfu_REQ_pollSearchParent +#define LMAN_STATE_END_SEARCH_PARENT 0x0b // rfu_REQ_endSearchParent +#define LMAN_STATE_START_CONNECT_PARENT 0x0c // rfu_REQ_startConnectParent +#define LMAN_STATE_POLL_CONNECT_PARENT 0x0d // rfu_REQ_pollConnectParent +#define LMAN_STATE_END_CONNECT_PARENT 0x0e // rfu_REQ_endConnectParent +#define LMAN_STATE_SEND_CHILD_NAME 0x0f // Sending child game name. +#define LMAN_STATE_START_LINK_RECOVERY 0x10 // rfu_REQ_CHILD_startConnectRecovery +#define LMAN_STATE_POLL_LINK_RECOVERY 0x11 // rfu_REQ_CHILD_pollConnectRecovery +#define LMAN_STATE_END_LINK_RECOVERY 0x12 // rfu_REQ_CHILD_endConnectRecovery +#define LMAN_STATE_MS_CHANGE 0x13 // rfu_REQ_changeMasterSlave +#define LMAN_STATE_WAIT_CLOCK_MASTER 0x14 // Waiting for AGB-RFU intercommunication clock to become AGB clock master. +#define LMAN_STATE_STOP_MODE 0x15 // rfu_REQ_stopMode +#define LMAN_STATE_BACK_STATE 0x16 // Following the completion of link-recovery processing, return the Link Manager state to the state present before link-recovery processing was initiated. +#define LMAN_FORCED_STOP_AND_RFU_RESET 0x17 // Attempt to forcibly stop Link Manager using rfu_LMAN_stopLMAN(1). +#define LMAN_STATE_WAIT_CHANGE_CLOCK_MASTER 0x18 // Attempt to return to AGB clock master after child fails in sending game name. + // RfuTgtData.gname is read as these structs. struct GFtgtGnameSub { @@ -37,20 +132,37 @@ struct Padded_U8 u8 value; }; -struct UnkLinkRfuStruct_02022B2C -{ - u8 maxMFrame; - u8 mcTimer; - u16 availSlotFlag; - u8 mbootFlag; - u16 serialNo; - struct GFtgtGname *gname; - u8 *uname; - u8 unk_10; - u8 unk_11; - u16 unk_12; - u16 unk_14; -}; +// Parameter group used in initial setting run of the link manager (rfu_LMAN_initializeRFU) +typedef struct InitializeParametersTag { + // rfu_REQ_configSystem argument + u8 maxMFrame; // Maximum number of times to re-transmit of RFU level + u8 MC_TimerCount; // MC_Timer count (x16.7ms) + u16 availSlot_flag; // Use RFU-API constant "AVAIL_SLOT1-4" to specify the maximum number of child devices (1 - 4) that can be connected to a parent device. + + // rfu_REQB_configGameData argument + u8 mboot_flag; // Multiplayer boot flag + u16 serialNo; // Game serial number + u8 *gameName; // Game name + u8 *userName; // User name + + // ON/OFF flag for parent fast search operation by child. + u8 fastSearchParent_flag; // Flag indicating whether parent fast search operation to be performed by child. + + // Link recovery settings + u8 linkRecovery_enable; // Determines whether or not to execute the link recovery process when a link cut occurs + u16 linkRecovery_period; // Time to spend on the link recovery process (x 16.7 ms) Note: Runs for unlimited time when specifying 0. + + // Setting for NI-type data transmit/receive period + u16 NI_failCounter_limit; // Limit for failCounter during NI type data transmit/receive (x 16.7 ms) Note: Runs for unlimited time when specifying 0. +}INIT_PARAM; + + +// Timer that counts with the V-Blank cycle +typedef struct VblankTimerTag { + u8 active; // Timer ON/OFF (bits 0 - 3 indicate ON/OFF for each connected slot) + u16 count_max; // Maximum count value (x16.7ms) + u16 count[RFU_CHILD_MAX]; // Current count value (x 16.7 ms) for each connected slot +}VBL_TIMER; struct UnkLinkRfuStruct_02022B44 { @@ -66,46 +178,39 @@ struct UnkLinkRfuStruct_02022B44 u8 fill_84[0x58]; }; -struct UnkRfuStruct_1 +typedef struct linkManagerTag { - /* 0x000 */ u8 unk_00; - /* 0x001 */ u8 unk_01; - /* 0x002 */ vu8 unk_02; - /* 0x003 */ vu8 unk_03; - /* 0x004 */ u8 unk_04; - /* 0x005 */ u8 unk_05; - /* 0x006 */ u8 unk_06; - /* 0x007 */ u8 unk_07; - /* 0x008 */ u8 unk_08; - /* 0x009 */ u8 unk_09; - /* 0x00a */ u8 unk_0a; - /* 0x00b */ u8 unk_0b; - /* 0x00c */ u8 unk_0c; - /* 0x00d */ u8 unk_0d; - /* 0x00e */ u8 unk_0e; - /* 0x00f */ u8 unk_0f; - /* 0x010 */ u8 unk_10; - /* 0x011 */ u8 unk_11; - /* 0x012 */ u8 unk_12; + /* 0x000 */ u8 acceptSlot_flag; + /* 0x001 */ u8 acceptCount; + /* 0x002 */ vu8 childClockSlave_flag; + /* 0x003 */ vu8 parentAck_flag; + /* 0x004 */ u8 state; + /* 0x005 */ u8 next_state; + /* 0x006 */ u8 parent_child; + /* 0x007 */ u8 pcswitch_flag; + /* 0x008 */ u8 RFU_powerOn_flag; + /* 0x009 */ u8 linkRecovery_enable; + /* 0x00a */ u8 linkRecovery_start_flag; + /* 0x00b */ u8 fastSearchParent_flag; + /* 0x00c */ u8 connectSlot_flag_old; + /* 0x00d */ u8 reserveDisconnectSlot_flag; + /* 0x00e */ u8 active; + /* 0x00f */ u8 msc_exe_flag; + /* 0x010 */ u8 child_slot; + /* 0x011 */ u8 state_bak[2]; // aligned - /* 0x014 */ u16 unk_14; - /* 0x016 */ u16 unk_16; - /* 0x018 */ u16 unk_18; - /* 0x01a */ u16 unk_1a; - /* 0x01c */ u16 unk_1c; - /* 0x01e */ u16 unk_1e; - /* 0x020 */ const u16 *unk_20; - /* 0x024 */ u8 unk_24; - /* 0x026 */ u16 unk_26; - /* 0x028 */ u16 unk_28[RFU_CHILD_MAX]; - /* 0x030 */ u8 unk_30; - // aligned - /* 0x032 */ u16 unk_32; - /* 0x034 */ u16 unk_34[RFU_CHILD_MAX]; - /* 0x03c */ const struct UnkLinkRfuStruct_02022B2C *unk_3c; - /* 0x040 */ void (*unk_40)(u8, u8); - /* 0x044 */ void (*unk_44)(u16); -}; + /* 0x014 */ u16 param[2]; + /* 0x018 */ u16 NI_failCounter_limit; + /* 0x01a */ u16 connect_period; + /* 0x01c */ u16 pcswitch_period_bak; + /* 0x01e */ u16 work; + /* 0x020 */ u16 *acceptable_serialNo_list; + /* 0x024 */ VBL_TIMER nameAcceptTimer; + /* 0x030 */ VBL_TIMER linkRecoveryTimer; + /* 0x03c */ INIT_PARAM *init_param; + /* 0x040 */ void (*LMAN_callback)(u8, u8); + /* 0x044 */ void (*MSC_callback)(u16); +} LINK_MANAGER; struct UnkRfuStruct_2_Sub_6c { @@ -222,7 +327,7 @@ struct UnkRfuStruct_2 /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; }; // size: 0x9AC -extern struct UnkRfuStruct_1 gUnknown_3005E10; +extern struct linkManagerTag lman; extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; @@ -241,7 +346,7 @@ u8 sub_8116DE0(void); void sub_80FBB4C(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); -u32 sub_80FD3A4(void); +u32 rfu_LMAN_REQBN_softReset_and_checkID(void); bool32 IsSendingKeysToRfu(void); void Rfu_set_zero(void); u8 GetRfuPlayerCount(void); @@ -265,33 +370,33 @@ void var_800D_set_xB(void); struct GFtgtGname *sub_80F9800(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -void sub_80FEB14(void); +void rfu_LMAN_requestChangeAgbClockMaster(void); bool32 sub_80FBA00(void); void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); -void sub_80FD4B0(const struct UnkLinkRfuStruct_02022B2C *unk0); -u8 sub_80FD538(u8 r5, u16 r7, u16 r8, const u16 *r6); -void sub_80FD760(bool8 a0); -void sub_80FEA10(void (*func)(u16)); +void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); +u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); +void rfu_LMAN_stopManager(bool8 a0); +void rfu_LMAN_setMSCCallback(void (*func)(u16)); void sub_80FB9E4(u8 a0, u16 a1); u8 sub_80FB9F4(void); -void LinkRfu_REQ_SendData_HandleParentRelationship(bool8 clockChangeFlag); +void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); -void sub_80FD52C(void); -u8 sub_80FD610(u16 parentId, u16 unk_1a); +void rfu_LMAN_powerDownRFU(void); +u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 unk_1a); bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); -u8 sub_80FEA34(u8 a0, u16 a1); -void sub_80FDA30(u32 a0); +u8 rfu_LMAN_setLinkRecovery(u8 a0, u16 a1); +void rfu_LMAN_manager_entity(u32 a0); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void LinkRfu_syncVBlank_(void); -s32 sub_80FD430(void (*func1)(u8, u8), void (*func2)(u16)); -void sub_80FEB3C(void); +void rfu_LMAN_syncVBlank(void); +u8 rfu_LMAN_initializeManager(void (*func1)(u8, u8), void (*func2)(u16)); +void rfu_LMAN_forceChangeSP(void); void sub_80FAFE0(u8 a0); bool32 sub_80FA44C(u32 a0); bool8 sub_80FC1B0(void); -- cgit v1.2.3 From 664fa0130a5381c5f647565a71f8fe248a0ebafa Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 29 Jan 2020 16:10:52 -0500 Subject: More doccing of linkManager --- include/librfu.h | 14 ++------------ include/link_rfu.h | 54 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 38 deletions(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index 97fd8044e..8fdee7317 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -473,16 +473,6 @@ struct RfuSIO32Id 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; @@ -499,7 +489,7 @@ s32 AgbRFU_checkID(u8); // 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 +590,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); diff --git a/include/link_rfu.h b/include/link_rfu.h index f90de0daf..277cdf018 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -259,18 +259,17 @@ struct UnkRfuStruct_Sub_Unused /* 0x203 */ vu8 unk_203; }; -struct UnkRfuStruct_2 +typedef struct UnkRfuStruct_2 { /* 0x000 */ void (*RfuFunc)(void); /* 0x004 */ u16 unk_04; /* 0x006 */ u8 filler_06[4]; - /* 0x00a */ u16 unk_0a; + /* 0x00a */ u16 linkman_msg; /* 0x00c */ u8 unk_0c; // parentChildMode? /* 0x00d */ u8 playerCount; /* 0x00e */ u8 unk_0e; /* 0x00f */ u8 unk_0f; - /* 0x010 */ u16 unk_10; - /* 0x012 */ u16 unk_12; + /* 0x010 */ u16 linkman_param[2]; /* 0x014 */ u8 unk_14[RFU_CHILD_MAX][14]; /* 0x04c */ u8 unk_4c[14]; /* 0x05a */ u8 unk_5a; @@ -286,7 +285,7 @@ struct UnkRfuStruct_2 /* 0x0e9 */ u8 unk_e9[5]; /* 0x0ee */ vu8 unk_ee; /* 0x0ef */ u8 unk_ef; - /* 0x0f0 */ u8 unk_f0; + /* 0x0f0 */ u8 linkLossRecoveryState; /* 0x0f1 */ u8 unk_f1; /* 0x0f2 */ u16 unk_f2[6]; /* 0x0fe */ u16 unk_fe; @@ -302,7 +301,7 @@ struct UnkRfuStruct_2 /* 0x8f7 */ u8 unk_c3f[70]; /* 0x93d */ u8 unk_c85; /* 0x93e */ u8 unk_c86; - /* 0x93f */ u8 unk_c87[5][7][2]; + /* 0x93f */ u8 recvCmds[5][7][2]; /* 0x985 */ u8 unk_ccd; /* 0x986 */ u8 unk_cce; // childId /* 0x987 */ u8 unk_ccf; @@ -315,8 +314,8 @@ struct UnkRfuStruct_2 /* 0x994 */ vu8 unk_cdc; /* 0x995 */ u8 unk_cdd; /* 0x996 */ u8 unk_cde[RFU_CHILD_MAX]; - /* 0x99a */ u8 unk_ce2; - /* 0x99b */ u8 unk_ce3; + /* 0x99a */ u8 bm_PartnerFlags; + /* 0x99b */ u8 bm_DisconnectSlot; /* 0x99c */ u8 unk_ce4; /* 0x99d */ u8 unk_ce5; /* 0x99e */ u8 unk_ce6; @@ -325,12 +324,29 @@ struct UnkRfuStruct_2 /* 0x9a1 */ u8 unk_ce9; /* 0x9a2 */ u8 unk_cea[RFU_CHILD_MAX]; /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; -}; // size: 0x9AC +} GF_RFU_MANAGER; // size: 0x9AC extern struct linkManagerTag lman; extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; +// Official signatures +u32 rfu_LMAN_REQBN_softReset_and_checkID(void); +void rfu_LMAN_requestChangeAgbClockMaster(void); +void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); +u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); +void rfu_LMAN_stopManager(bool8 forced_stop_and_RFU_reset_flag); +void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16)); +void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); +void rfu_LMAN_powerDownRFU(void); +u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period); +u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period); +void rfu_LMAN_manager_entity(u32 rand); +void rfu_LMAN_syncVBlank(void); +u8 rfu_LMAN_initializeManager(void (*LMAN_callback_p)(u8, u8), void (*MSC_callback_p)(u16)); +void rfu_LMAN_forceChangeSP(void); + +// GameFreak signatures void AddTextPrinterToWindow1(const u8 *str); bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src); void LinkRfu_FatalError(void); @@ -346,11 +362,10 @@ u8 sub_8116DE0(void); void sub_80FBB4C(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); -u32 rfu_LMAN_REQBN_softReset_and_checkID(void); bool32 IsSendingKeysToRfu(void); void Rfu_set_zero(void); u8 GetRfuPlayerCount(void); -void sub_80F9828(void); +void StartSendingKeysToRfu(void); u8 LinkRfu_GetMultiplayerId(void); bool32 Rfu_InitBlockSend(const u8 * src, size_t size); bool8 sub_80FA0F8(u8 a0); @@ -367,36 +382,23 @@ void sub_80F8DC0(void); void sub_80FBB20(void); bool8 sub_80FA484(bool32 a0); void var_800D_set_xB(void); -struct GFtgtGname *sub_80F9800(void); +struct GFtgtGname *GetHostRFUtgtGname(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -void rfu_LMAN_requestChangeAgbClockMaster(void); bool32 sub_80FBA00(void); void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); -void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); -u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); -void rfu_LMAN_stopManager(bool8 a0); -void rfu_LMAN_setMSCCallback(void (*func)(u16)); -void sub_80FB9E4(u8 a0, u16 a1); +void sub_80FB9E4(u8 a0, u16 msg); u8 sub_80FB9F4(void); -void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); -void rfu_LMAN_powerDownRFU(void); -u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 unk_1a); bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); -u8 rfu_LMAN_setLinkRecovery(u8 a0, u16 a1); -void rfu_LMAN_manager_entity(u32 a0); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void rfu_LMAN_syncVBlank(void); -u8 rfu_LMAN_initializeManager(void (*func1)(u8, u8), void (*func2)(u16)); -void rfu_LMAN_forceChangeSP(void); void sub_80FAFE0(u8 a0); bool32 sub_80FA44C(u32 a0); bool8 sub_80FC1B0(void); -- cgit v1.2.3 From 8a3eb95ed4c67031efc641fad632782dbe7b46bf Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 29 Jan 2020 16:54:03 -0500 Subject: Yet more documentation of rfu fields and functions --- include/link.h | 2 +- include/link_rfu.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/link.h b/include/link.h index 770a60f44..e41b89634 100644 --- a/include/link.h +++ b/include/link.h @@ -277,7 +277,7 @@ 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 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 277cdf018..5a66bb6bb 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -283,7 +283,7 @@ typedef struct UnkRfuStruct_2 /* 0x080 */ struct UnkRfuStruct_2_Sub_6c unk_80[5]; /* 0x0e4 */ u8 unk_e4[5]; /* 0x0e9 */ u8 unk_e9[5]; - /* 0x0ee */ vu8 unk_ee; + /* 0x0ee */ vu8 errorState; /* 0x0ef */ u8 unk_ef; /* 0x0f0 */ u8 linkLossRecoveryState; /* 0x0f1 */ u8 unk_f1; @@ -374,8 +374,8 @@ void Rfu_SetBlockReceivedFlag(u8 who); void Rfu_ResetBlockReceivedFlag(u8 who); bool8 Rfu_IsMaster(void); void sub_80F85F8(void); -bool32 sub_80FAE94(void); -bool32 sub_80FAEF0(void); +bool32 LinkRfuMain1(void); +bool32 LinkRfuMain2(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); void sub_80F8DC0(void); -- cgit v1.2.3 From 78196be41e84f632d3569f5f40cf4da2844902eb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 30 Jan 2020 10:48:42 -0500 Subject: More RFU documentation --- include/link_rfu.h | 8 ++++---- include/union_room.h | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/link_rfu.h b/include/link_rfu.h index 5a66bb6bb..050d68bb6 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -120,7 +120,7 @@ struct __attribute__((packed, aligned(2))) GFtgtGname u8 unk_04[4]; u16 species:10; u16 type:6; - u8 unk_0a_0:7; + u8 activity:7; u8 unk_0a_7:1; u8 playerGender:1; u8 level:7; @@ -400,19 +400,19 @@ bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); void sub_80FAFE0(u8 a0); -bool32 sub_80FA44C(u32 a0); +bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); bool8 sub_80F8F40(void); void sub_80F8F5C(void); bool32 sub_80FA5D4(void); bool32 sub_80FC1CC(void); bool32 sub_80F8F7C(bool32 a0); -bool32 sub_80FA634(u16 a0, const u8 *a1); +bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); void sub_80FA670(u8 a0, u16 a1, const u8 *a2); u32 sub_80FA6FC(u16 a0, const u8 *a1); void SetHostRFUtgtGname(u8 a0, u32 a1, u32 a2); void sub_80FBB8C(u32 a0); -void sub_80FBD4C(const u8 *ptr, u16 a1); +void sub_80FBD4C(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void sub_80FBBD8(void); void sub_80FA6BC(void); diff --git a/include/union_room.h b/include/union_room.h index 7e48b3e6e..0600d9cc0 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -4,6 +4,11 @@ #include "global.h" #include "link_rfu.h" +// Return value of IsRequestedTypeAndSpeciesInPlayerParty +#define UR_TRADE_MATCH 0 +#define UR_TRADE_NOTYPE 1 +#define UR_TRADE_NOEGG 2 + struct UnkStruct_Shared { struct GFtgtGname gname; @@ -20,7 +25,7 @@ struct UnkStruct_x20 { struct UnkStruct_Shared unk; u16 field_18; - u8 field_1A_0:2; + u8 tradeStatus:2; u8 field_1A_1:1; u8 field_1B; u8 field_1D; @@ -56,7 +61,7 @@ struct UnkStruct_Leader u8 field_10; u8 field_11; u8 listTaskId; - u8 field_13; + u8 playerCount; u8 field_14; u8 field_15; u8 field_16; -- cgit v1.2.3 From e3307a5b7abc9df8dcd6a0726e0b8fff3188c703 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 30 Jan 2020 14:54:21 -0500 Subject: Still more documentation of RFU --- include/librfu.h | 5 +++-- include/link_rfu.h | 63 +++++++++++++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index 8fdee7317..f93006627 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -90,8 +90,9 @@ #define RFU_MBOOT_DOWNLOADER_SERIAL_NO 0x0000 // The game serial number of the multi-boot downloader (programs that boot without a Game Pak) -#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) +// Sizes are 0x28 larger in v1028 +#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) #define RFU_CHILD_MAX 4 // Maximum number of slaves that can be connected to one parent device diff --git a/include/link_rfu.h b/include/link_rfu.h index 050d68bb6..52fd07f7c 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -198,7 +198,6 @@ typedef struct linkManagerTag /* 0x00f */ u8 msc_exe_flag; /* 0x010 */ u8 child_slot; /* 0x011 */ u8 state_bak[2]; - // aligned /* 0x014 */ u16 param[2]; /* 0x018 */ u16 NI_failCounter_limit; /* 0x01a */ u16 connect_period; @@ -215,48 +214,48 @@ typedef struct linkManagerTag struct UnkRfuStruct_2_Sub_6c { /* 0x00 */ u16 unk_00; - /* 0x02 */ u16 unk_02; - /* 0x04 */ const u8 *unk_04; + /* 0x02 */ u16 count; + /* 0x04 */ const u8 *payload; /* 0x08 */ u32 unk_08; /* 0x0c */ u32 unk_0c; /* 0x10 */ u8 unk_10; - /* 0x11 */ u8 unk_11; + /* 0x11 */ u8 owner; /* 0x12 */ u8 unk_12; }; struct UnkRfuStruct_2_Sub_124 { - /* 0x000 */ u8 unk_00[20][70]; - /* 0x578 */ vu8 unk_8c0; - /* 0x579 */ vu8 unk_8c1; - /* 0x57a */ vu8 unk_8c2; - /* 0x57b */ vu8 unk_8c3; + /* 0x000 */ u8 slots[20][70]; + /* 0x578 */ vu8 recv_slot; + /* 0x579 */ vu8 send_slot; + /* 0x57a */ vu8 count; + /* 0x57b */ vu8 full; }; struct UnkRfuStruct_2_Sub_9e8 { - /* 0x000 */ u8 unk_00[40][14]; - /* 0x230 */ vu8 unk_230; - /* 0x231 */ vu8 unk_231; - /* 0x232 */ vu8 unk_232; - /* 0x233 */ vu8 unk_233; + /* 0x000 */ u8 slots[40][14]; + /* 0x230 */ vu8 recv_slot; + /* 0x231 */ vu8 send_slot; + /* 0x232 */ vu8 count; + /* 0x233 */ vu8 full; }; struct UnkRfuStruct_2_Sub_c1c { - /* 0x00 */ u8 unk_00[2][14]; - /* 0x1c */ vu8 unk_1c; - /* 0x1d */ vu8 unk_1d; - /* 0x1e */ vu8 unk_1e; + /* 0x00 */ u8 slots[2][14]; + /* 0x1c */ vu8 recv_slot; + /* 0x1d */ vu8 send_slot; + /* 0x1e */ vu8 count; }; struct UnkRfuStruct_Sub_Unused { - /* 0x000 */ u8 unk_00[2][256]; - /* 0x200 */ vu8 unk_200; - /* 0x201 */ vu8 unk_201; - /* 0x202 */ vu8 unk_202; - /* 0x203 */ vu8 unk_203; + /* 0x000 */ u8 slots[2][256]; + /* 0x200 */ vu8 recv_slot; + /* 0x201 */ vu8 send_slot; + /* 0x202 */ vu8 count; + /* 0x203 */ vu8 full; }; typedef struct UnkRfuStruct_2 @@ -297,7 +296,7 @@ typedef struct UnkRfuStruct_2 /* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c; /* 0x8f4 */ vu8 unk_c3c; /* 0x8f5 */ u8 unk_c3d; - /* 0x8f6 */ vu8 unk_c3e; + /* 0x8f6 */ vu8 child_slot; /* 0x8f7 */ u8 unk_c3f[70]; /* 0x93d */ u8 unk_c85; /* 0x93e */ u8 unk_c86; @@ -387,17 +386,17 @@ void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); bool32 sub_80FBA00(void); -void sub_80FC478(struct UnkRfuStruct_2_Sub_124 *ptr); -void sub_80FC4D4(struct UnkRfuStruct_2_Sub_9e8 *ptr); +void RFU_queue_20_70_reset(struct UnkRfuStruct_2_Sub_124 *ptr); +void RFU_queue_40_14_reset(struct UnkRfuStruct_2_Sub_9e8 *ptr); void sub_80FB9E4(u8 a0, u16 msg); u8 sub_80FB9F4(void); -void sub_80FC588(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); -bool8 sub_80FC79C(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); -bool8 sub_80FC888(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); -void sub_80FC828(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); -bool8 sub_80FC6E8(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); -void sub_80FC63C(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); +void RFU_queue_20_70_recv(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); +bool8 RFU_queue_40_14_send(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); +bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); +void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); +bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); +void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); void sub_80FAFE0(u8 a0); bool32 RfuSerialNumberIsValid(u32 a0); -- cgit v1.2.3 From 7e894aa4d0b6440ca34b590a2a9f86dc834ea400 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 31 Jan 2020 09:26:00 -0500 Subject: Decompile librfu_intr against agbcc_arm --- include/librfu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index f93006627..2b5b39620 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -315,7 +315,7 @@ 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; -- cgit v1.2.3 From 7d77b9312365e0282d7546c514859ac20e2fea51 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 31 Jan 2020 13:27:10 -0500 Subject: Use SIO_ defines in librfu_intr --- include/librfu.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index 2b5b39620..4b41e9a71 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -71,6 +71,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. -- cgit v1.2.3 From 2d4c0040040908809c5fc1ff33faf6a2b693d1ab Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 31 Jan 2020 15:30:52 -0500 Subject: More documentation and symbol propagation --- include/librfu.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index 4b41e9a71..f0f6aefee 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 */ -- cgit v1.2.3 From 88bda9fabd069ed281d845568b7d3c748bdea0e4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 31 Jan 2020 16:23:04 -0500 Subject: Dcoument args to two STWI routines --- include/librfu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index f0f6aefee..c7dc0574d 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -615,14 +615,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); -- cgit v1.2.3 From 5ca03c0e32a723f9551b93e5aceb7b39d8ea10e6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 31 Jan 2020 16:57:52 -0500 Subject: name STWIStatus.unk_2c --- include/librfu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index c7dc0574d..33f370bf0 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -316,7 +316,7 @@ struct STWIStatus void (*callbackID)(void); union RfuPacket *txPacket; union RfuPacket *rxPacket; - vu8 unk_2c; + vu8 sending; }; // This struct is used as u8 array in SDK. -- cgit v1.2.3 From 01fedfa61c12ed9637124dd1f306e8b8f54ea116 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 1 Feb 2020 10:22:28 -0500 Subject: Minor style consistency edit in union_room_chat --- include/global.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/global.h b/include/global.h index 2f87a0c29..2ed7476e7 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[]; -- cgit v1.2.3 From 08aafe093caecf160417edb6b0635a9707a30989 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 1 Feb 2020 15:34:33 -0500 Subject: More rfu documentation --- include/librfu.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index 33f370bf0..cf738486e 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -461,27 +461,15 @@ struct RfuStatic u32 totalPacketSize; }; -struct RfuSIO32Id -{ - u8 unk0; - u8 unk1; - u16 unk2; - u16 unk4; - u16 unk6; - u16 unk8; // unused - u16 unkA; -}; - 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. -- cgit v1.2.3 From 0d60939fd7c58354552d8482980a8acf481aa4e2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 1 Feb 2020 16:46:52 -0500 Subject: Some small fixes --- include/librfu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index cf738486e..df5a5b79a 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -454,7 +454,7 @@ struct RfuStatic u8 linkEmergencyFlag[4]; u8 lsFixedCount[4]; u16 cidBak[4]; - u16 unk_1a; + u16 linkEmergencyLimit; u16 reqResult; u16 tryPid; u16 watchdogTimer; -- cgit v1.2.3 From a59d87837836606dbcdb234ac1ca7ff025a02f6a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 1 Feb 2020 17:01:29 -0500 Subject: Use RFU_CHILD_MAX for four arrays --- include/librfu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index df5a5b79a..83523433c 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -451,9 +451,9 @@ struct RfuStatic u8 nullFrameCount; u8 emberCount; u8 SCStartFlag; - u8 linkEmergencyFlag[4]; - u8 lsFixedCount[4]; - u16 cidBak[4]; + u8 linkEmergencyFlag[RFU_CHILD_MAX]; + u8 lsFixedCount[RFU_CHILD_MAX]; + u16 cidBak[RFU_CHILD_MAX]; u16 linkEmergencyLimit; u16 reqResult; u16 tryPid; -- cgit v1.2.3 From 708fa70823f81cb9b2dffd93bf5f00842ddb4d72 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 1 Feb 2020 21:39:02 -0500 Subject: event_object_80688E4 --- include/event_object_80688E4.h | 4 ++-- include/event_object_movement.h | 3 ++- include/field_effect.h | 2 +- include/global.fieldmap.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/event_object_80688E4.h b/include/event_object_80688E4.h index 36040e0a5..c5dadc672 100644 --- a/include/event_object_80688E4.h +++ b/include/event_object_80688E4.h @@ -4,9 +4,9 @@ #include "global.h" void FreezeObjectEvents(void); -void FreezeObjectEvent(struct ObjectEvent *); +bool8 FreezeObjectEvent(struct ObjectEvent *); void FreezeObjectEventsExceptOne(u8 objEventId); -void sub_8069124(u8 a0, bool8 a1); +void sub_8069124(u8 a0, bool32 a1); u32 sub_806916C(u8 a0); void sub_80691A4(u8 a0, u8 a1); void sub_8069094(u8 a0, u8 a1); diff --git a/include/event_object_movement.h b/include/event_object_movement.h index f2e7bd325..89cdd0cff 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -97,7 +97,7 @@ u8 sub_8063F84(u8 direction); u8 GetTrainerFacingDirectionMovementType(u8 direction); void CameraObjectSetFollowedObjectId(u8 spriteId); void UnfreezeObjectEvents(void); -void sub_8069058(u8, u8); +void TurnEventObject(u8, u8); // Exported data declarations @@ -105,5 +105,6 @@ extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[]; extern const struct SpritePalette gUnknown_83A5348; extern const struct SpriteTemplate * const gFieldEffectObjectTemplatePointers[]; extern const struct OamData gObjectEventBaseOam_32x32; +extern const struct UCoords16 gUnknown_83A64C8[]; #endif // GUARD_EVENT_OBJECT_MOVEMENT_H diff --git a/include/field_effect.h b/include/field_effect.h index c2d14d43c..3e30fa897 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -8,7 +8,7 @@ extern u32 gFieldEffectArguments[8]; extern void (*gPostMenuFieldCallback)(void); extern bool8 (*gFieldCallback2)(void); -u8 FieldEffectStart(u8); +u32 FieldEffectStart(u8); bool8 FieldEffectActiveListContains(u8 id); void sub_80B69DC(void); void CreateTeleportFieldEffectTask(void); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 01cd992ec..b7f28d8a0 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -190,7 +190,7 @@ struct ObjectEvent u32 mapobj_bit_19:1; u32 mapobj_bit_20:1; u32 mapobj_bit_21:1; - u32 mapobj_bit_22:1; + u32 hasShadow:1; u32 mapobj_bit_23:1; /*0x03*/ u32 mapobj_bit_24:1; u32 mapobj_bit_25:1; -- cgit v1.2.3 From ba7403c74e214fe798095e99949461aaadd274c7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 2 Feb 2020 11:10:07 -0500 Subject: Document event_object_80688E4 --- include/event_object_80688E4.h | 10 +++++----- include/event_object_movement.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/event_object_80688E4.h b/include/event_object_80688E4.h index c5dadc672..a3da168b4 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 sub_8069124(u8 a0, bool32 a1); -u32 sub_806916C(u8 a0); -void sub_80691A4(u8 a0, u8 a1); -void sub_8069094(u8 a0, u8 a1); -bool32 sub_8069294(u8 a0); +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); #endif // GUARD_EVENT_OBJECT_80688E4_H diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 89cdd0cff..650f137d9 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -97,7 +97,7 @@ u8 sub_8063F84(u8 direction); u8 GetTrainerFacingDirectionMovementType(u8 direction); void CameraObjectSetFollowedObjectId(u8 spriteId); void UnfreezeObjectEvents(void); -void TurnEventObject(u8, u8); +void TurnObjectEvent(u8, u8); // Exported data declarations -- cgit v1.2.3 From ceeed6247dbeca94fdb073441b98a885da44ffe1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 2 Feb 2020 11:23:04 -0500 Subject: Port object event flags from emerald --- include/global.fieldmap.h | 108 ++++++++++++++++++++++------------------------ include/global.h | 32 +++++++------- 2 files changed, 68 insertions(+), 72 deletions(-) (limited to 'include') diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index b7f28d8a0..e0053fe88 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -168,62 +168,58 @@ struct MapHeader struct ObjectEvent { - /*0x00*/ u32 active:1; - u32 mapobj_bit_1:1; - u32 mapobj_bit_2:1; - u32 mapobj_bit_3:1; - u32 mapobj_bit_4:1; - u32 mapobj_bit_5:1; - u32 mapobj_bit_6:1; - u32 mapobj_bit_7:1; - /*0x01*/ u32 mapobj_bit_8:1; - u32 mapobj_bit_9:1; - u32 mapobj_bit_10:1; - u32 mapobj_bit_11:1; - u32 mapobj_bit_12:1; - u32 mapobj_bit_13:1; - u32 mapobj_bit_14:1; - u32 mapobj_bit_15:1; - /*0x02*/ u32 mapobj_bit_16:1; - u32 mapobj_bit_17:1; - u32 mapobj_bit_18:1; - u32 mapobj_bit_19:1; - u32 mapobj_bit_20:1; - u32 mapobj_bit_21:1; - u32 hasShadow:1; - u32 mapobj_bit_23:1; - /*0x03*/ u32 mapobj_bit_24:1; - u32 mapobj_bit_25:1; - u32 mapobj_bit_26:1; - u32 mapobj_bit_27:1; - u32 mapobj_bit_28:1; - u32 mapobj_bit_29:1; - u32 mapobj_bit_30:1; - u32 mapobj_bit_31:1; - /*0x04*/ u8 spriteId; - /*0x05*/ u8 graphicsId; - /*0x06*/ u8 animPattern; - /*0x07*/ u8 trainerType; - /*0x08*/ u8 localId; - /*0x09*/ u8 mapNum; - /*0x0A*/ u8 mapGroup; - /*0x0B*/ u8 mapobj_unk_0B_0:4; - u8 elevation:4; - /*0x0C*/ struct Coords16 coords1; - /*0x10*/ struct Coords16 coords2; - /*0x14*/ struct Coords16 coords3; - /*0x18*/ u8 facingDirection:4; //current direction? - /*0x18*/ u8 placeholder18:4; - /*0x19*/ union ObjectEventRange range; - /*0x1A*/ u8 mapobj_unk_1A; - /*0x1B*/ u8 mapobj_unk_1B; - /*0x1C*/ u8 mapobj_unk_1C; - /*0x1D*/ u8 trainerRange_berryTreeId; - /*0x1E*/ u8 mapobj_unk_1E; - /*0x1F*/ u8 mapobj_unk_1F; - /*0x20*/ u8 mapobj_unk_20; - /*0x21*/ u8 mapobj_unk_21; - /*0x22*/ u8 animId; + /*0x00*/ /* 0*/ u32 active:1; + /* 1*/ u32 singleMovementActive:1; + /* 2*/ u32 triggerGroundEffectsOnMove:1; + /* 3*/ u32 triggerGroundEffectsOnStop:1; + /* 4*/ u32 disableCoveringGroundEffects:1; + /* 5*/ u32 landingJump:1; + /* 6*/ u32 heldMovementActive:1; + /* 7*/ u32 heldMovementFinished:1; + /*0x01*/ /* 8*/ u32 frozen:1; + /* 9*/ u32 facingDirectionLocked:1; + /*10*/ u32 disableAnim:1; + /*11*/ u32 enableAnim:1; + /*12*/ u32 inanimate:1; + /*13*/ u32 invisible:1; + /*14*/ u32 offScreen:1; + /*15*/ u32 trackedByCamera:1; + /*0x02*/ /*16*/ u32 isPlayer:1; + /*17*/ u32 hasReflection:1; + /*18*/ u32 inShortGrass:1; + /*19*/ u32 inShallowFlowingWater:1; + /*20*/ u32 inSandPile:1; + /*21*/ u32 inHotSprings:1; + /*22*/ u32 hasShadow:1; + /*23*/ u32 spriteAnimPausedBackup:1; + /*0x03*/ /*24*/ u32 spriteAffineAnimPausedBackup:1; + /*25*/ u32 disableJumpLandingGroundEffect:1; + /*26*/ u32 fixedPriority:1; + /*27*/ u32 hideReflection:1; + /*0x04*/ u8 spriteId; + /*0x05*/ u8 graphicsId; + /*0x06*/ u8 animPattern; + /*0x07*/ u8 trainerType; + /*0x08*/ u8 localId; + /*0x09*/ u8 mapNum; + /*0x0A*/ u8 mapGroup; + /*0x0B*/ u8 mapobj_unk_0B_0:4; + u8 elevation:4; + /*0x0C*/ struct Coords16 coords1; + /*0x10*/ struct Coords16 coords2; + /*0x14*/ struct Coords16 coords3; + /*0x18*/ u8 facingDirection:4; //current direction? + /*0x18*/ u8 placeholder18:4; + /*0x19*/ union ObjectEventRange range; + /*0x1A*/ u8 mapobj_unk_1A; + /*0x1B*/ u8 mapobj_unk_1B; + /*0x1C*/ u8 mapobj_unk_1C; + /*0x1D*/ u8 trainerRange_berryTreeId; + /*0x1E*/ u8 mapobj_unk_1E; + /*0x1F*/ u8 mapobj_unk_1F; + /*0x20*/ u8 mapobj_unk_20; + /*0x21*/ u8 mapobj_unk_21; + /*0x22*/ u8 animId; /*size = 0x24*/ }; diff --git a/include/global.h b/include/global.h index 2f87a0c29..a0027f9dc 100644 --- a/include/global.h +++ b/include/global.h @@ -591,22 +591,22 @@ union QuestLogMovement struct QuestLogObjectEvent { /*0x00*/ u8 active:1; - /*0x00*/ u8 mapobj_bit_3:1; - /*0x00*/ u8 mapobj_bit_4:1; - /*0x00*/ u8 mapobj_bit_5:1; - /*0x00*/ u8 mapobj_bit_8:1; - /*0x00*/ u8 mapobj_bit_9:1; - /*0x00*/ u8 mapobj_bit_10:1; - /*0x00*/ u8 mapobj_bit_11:1; - /*0x01*/ u8 mapobj_bit_12:1; - /*0x01*/ u8 mapobj_bit_13:1; - /*0x01*/ u8 mapobj_bit_14:1; - /*0x01*/ u8 mapobj_bit_15:1; - /*0x01*/ u8 mapobj_bit_16:1; - /*0x01*/ u8 mapobj_bit_23:1; - /*0x01*/ u8 mapobj_bit_24:1; - /*0x01*/ u8 mapobj_bit_25:1; - /*0x02*/ u8 mapobj_bit_26:1; + /*0x00*/ u8 triggerGroundEffectsOnStop:1; + /*0x00*/ u8 disableCoveringGroundEffects:1; + /*0x00*/ u8 landingJump:1; + /*0x00*/ u8 frozen:1; + /*0x00*/ u8 facingDirectionLocked:1; + /*0x00*/ u8 disableAnim:1; + /*0x00*/ u8 enableAnim:1; + /*0x01*/ u8 inanimate:1; + /*0x01*/ u8 invisible:1; + /*0x01*/ u8 offScreen:1; + /*0x01*/ u8 trackedByCamera:1; + /*0x01*/ u8 isPlayer:1; + /*0x01*/ u8 spriteAnimPausedBackup:1; + /*0x01*/ u8 spriteAffineAnimPausedBackup:1; + /*0x01*/ u8 disableJumpLandingGroundEffect:1; + /*0x02*/ u8 fixedPriority:1; /*0x02*/ u8 mapobj_unk_18:4; /*0x02*/ u8 unused_02_5:3; /*0x03*/ u8 mapobj_unk_0B_0:4; -- cgit v1.2.3 From aed9c28dc30b5da30186844d78cf74162409486e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 11:02:02 -0500 Subject: Document rfu_union_tool --- include/event_object_80688E4.h | 10 +++++----- include/fieldmap.h | 2 +- include/link_rfu.h | 3 ++- include/rfu_union_tool.h | 17 ++++++++--------- include/union_room_battle.h | 6 ++++++ 5 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 include/union_room_battle.h (limited to 'include') 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/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/link_rfu.h b/include/link_rfu.h index 52fd07f7c..4f11d8cb6 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -117,7 +117,8 @@ struct GFtgtGnameSub struct __attribute__((packed, aligned(2))) GFtgtGname { struct GFtgtGnameSub unk_00; - u8 unk_04[4]; + u8 unk_04[RFU_CHILD_MAX]; // u8 sprite_idx:3; + // u8 gender:1; u16 species:10; u16 type:6; u8 activity:7; 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/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 -- cgit v1.2.3 From 46a3ca51341fd3b68e4fe5251e70abc8a03644c5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 13:42:57 -0500 Subject: Union room activity documentation --- include/constants/union_room.h | 37 +++++++++++++++++++++++++++++++++++++ include/link_rfu.h | 16 +++++++++------- include/union_room.h | 22 ++++++++++++---------- include/union_room_message.h | 32 ++++++++++++++++---------------- 4 files changed, 74 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/include/constants/union_room.h b/include/constants/union_room.h index 021424773..04ffa3037 100644 --- a/include/constants/union_room.h +++ b/include/constants/union_room.h @@ -1,6 +1,43 @@ #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 UROOM_ACTIVITY_NONE 0 +#define UROOM_ACTIVITY_BATTLE 1 +#define UROOM_ACTIVITY_DBLBATTLE 2 +#define UROOM_ACTIVITY_MLTBATTLE 3 +#define UROOM_ACTIVITY_TRADE 4 +#define UROOM_ACTIVITY_CHAT 5 +#define UROOM_ACTIVITY_WCARD 6 +#define UROOM_ACTIVITY_WNEWS 7 +#define UROOM_ACTIVITY_CARD 8 +#define UROOM_ACTIVITY_PJUMP 9 +#define UROOM_ACTIVITY_BCRUSH 10 +#define UROOM_ACTIVITY_BPICK 11 +#define UROOM_ACTIVITY_SEARCH 12 +#define UROOM_ACTIVITY_SPINTRADE 13 +#define UROOM_ACTIVITY_ITEMTRADE 14 + +// Player response +#define UROOM_ACTIVITY_ACCEPT 17 +#define UROOM_ACTIVITY_DECLINE 18 + +// Duplicate IDs? +#define UROOM_ACTIVITY_WCARD2 21 +#define UROOM_ACTIVITY_WNEWS2 22 + +// 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 4f11d8cb6..0bcebd7ad 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -117,8 +117,10 @@ struct GFtgtGnameSub struct __attribute__((packed, aligned(2))) GFtgtGname { struct GFtgtGnameSub unk_00; - u8 unk_04[RFU_CHILD_MAX]; // u8 sprite_idx:3; - // u8 gender:1; + u8 child_sprite_gender[RFU_CHILD_MAX]; // u8 sprite_idx:3; + // u8 gender:1; + // u8 unk_4:3 + // u8 active:1 u16 species:10; u16 type:6; u8 activity:7; @@ -385,13 +387,13 @@ void var_800D_set_xB(void); struct GFtgtGname *GetHostRFUtgtGname(void); void UpdateWirelessStatusIndicatorSprite(void); void InitRFU(void); -bool32 sub_80FBA00(void); +bool32 RfuIsErrorStatus1or2(void); void RFU_queue_20_70_reset(struct UnkRfuStruct_2_Sub_124 *ptr); void RFU_queue_40_14_reset(struct UnkRfuStruct_2_Sub_9e8 *ptr); -void sub_80FB9E4(u8 a0, u16 msg); -u8 sub_80FB9F4(void); +void RfuSetErrorStatus(u8 a0, u16 msg); +u8 RfuGetErrorStatus(void); void RFU_queue_20_70_recv(struct UnkRfuStruct_2_Sub_124 *q1, u8 *q2); bool8 RFU_queue_40_14_send(struct UnkRfuStruct_2_Sub_9e8 *q1, u8 *q2); bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); @@ -410,14 +412,14 @@ bool32 sub_80F8F7C(bool32 a0); bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); void sub_80FA670(u8 a0, u16 a1, const u8 *a2); u32 sub_80FA6FC(u16 a0, const u8 *a1); -void SetHostRFUtgtGname(u8 a0, u32 a1, u32 a2); +void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2); void sub_80FBB8C(u32 a0); void sub_80FBD4C(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void sub_80FBBD8(void); void sub_80FA6BC(void); void sub_80FBF54(const u8 *src, u16 trainerId); -void sub_80FB008(u8 a0, u32 a1, u32 a2); +void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); void RecordMixTrainerNames(void); void sub_80F8CFC(); void sub_80F8D14(); diff --git a/include/union_room.h b/include/union_room.h index 0600d9cc0..f5a1ecf04 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -25,7 +25,7 @@ struct UnkStruct_x20 { struct UnkStruct_Shared unk; u16 field_18; - u8 tradeStatus:2; + u8 groupScheduledAnim:2; u8 field_1A_1:1; u8 field_1B; u8 field_1D; @@ -114,19 +114,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]; diff --git a/include/union_room_message.h b/include/union_room_message.h index b7de673ba..3ebf66252 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[]; @@ -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[]; @@ -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[]; -- cgit v1.2.3 From d522588538e39b8d8a6dc47b557dcc4ae322a093 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 13:51:38 -0500 Subject: Some more documentation of array sizes --- include/union_room.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/union_room.h b/include/union_room.h index f5a1ecf04..2c32760cb 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -9,6 +9,9 @@ #define UR_TRADE_NOTYPE 1 #define UR_TRADE_NOEGG 2 +#define UROOM_MAX_GROUP_COUNT 8 +#define UROOM_MAX_PARTY_SIZE 5 + struct UnkStruct_Shared { struct GFtgtGname gname; @@ -18,7 +21,7 @@ struct UnkStruct_Shared struct UnkStruct_x1C { struct UnkStruct_Shared unk0; - u8 unk18:1; + u8 active:1; }; struct UnkStruct_x20 -- cgit v1.2.3 From 7bd0a83d359beafc69a1a63cb51b11e98186a292 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 16:41:25 -0500 Subject: I'm so original with these commit names --- include/constants/easy_chat.h | 17 +-------------- include/link_rfu.h | 48 +++++++++++++++++++++++++++---------------- include/union_room.h | 2 +- include/union_room_message.h | 8 ++++---- 4 files changed, 36 insertions(+), 39 deletions(-) (limited to 'include') 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/link_rfu.h b/include/link_rfu.h index 0bcebd7ad..d25ed020e 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -102,14 +102,14 @@ // RfuTgtData.gname is read as these structs. struct GFtgtGnameSub { - u16 unk_00_0:4; - u16 unk_00_4:1; - u16 unk_00_5:1; + u16 language:4; + u16 hasNews:1; + u16 hasCard:1; u16 unk_00_6:1; u16 isChampion:1; u16 hasNationalDex:1; u16 gameClear:1; - u16 unk_01_2:4; + u16 version:4; u16 unk_01_6:2; u8 playerTrainerId[2]; }; @@ -214,16 +214,28 @@ typedef struct linkManagerTag /* 0x044 */ void (*MSC_callback)(u16); } LINK_MANAGER; -struct UnkRfuStruct_2_Sub_6c +#define RFU_COMMAND_0x8800 0x8800 +#define RFU_COMMAND_0x8900 0x8900 +#define RFU_COMMAND_0xa100 0xa100 +#define RFU_COMMAND_0x7700 0x7700 +#define RFU_COMMAND_0x7800 0x7800 +#define RFU_COMMAND_0x6600 0x6600 +#define RFU_COMMAND_0x5f00 0x5f00 +#define RFU_COMMAND_0x2f00 0x2f00 +#define RFU_COMMAND_0xbe00 0xbe00 +#define RFU_COMMAND_0xee00 0xee00 +#define RFU_COMMAND_0xed00 0xed00 + +struct RfuBlockSend { - /* 0x00 */ u16 unk_00; - /* 0x02 */ u16 count; + /* 0x00 */ u16 next; + /* 0x02 */ u16 count; // max 21 /* 0x04 */ const u8 *payload; - /* 0x08 */ u32 unk_08; - /* 0x0c */ u32 unk_0c; - /* 0x10 */ u8 unk_10; + /* 0x08 */ u32 receivedFlags; + /* 0x0c */ u32 failedFlags; + /* 0x10 */ u8 sending; /* 0x11 */ u8 owner; - /* 0x12 */ u8 unk_12; + /* 0x12 */ u8 receiving; }; struct UnkRfuStruct_2_Sub_124 @@ -264,7 +276,7 @@ struct UnkRfuStruct_Sub_Unused typedef struct UnkRfuStruct_2 { /* 0x000 */ void (*RfuFunc)(void); - /* 0x004 */ u16 unk_04; + /* 0x004 */ u16 state; /* 0x006 */ u8 filler_06[4]; /* 0x00a */ u16 linkman_msg; /* 0x00c */ u8 unk_0c; // parentChildMode? @@ -281,8 +293,8 @@ typedef struct UnkRfuStruct_2 /* 0x066 */ u8 unk_66; /* 0x067 */ u8 unk_67; /* 0x068 */ u8 filler_68[4]; - /* 0x06c */ struct UnkRfuStruct_2_Sub_6c unk_6c; - /* 0x080 */ struct UnkRfuStruct_2_Sub_6c unk_80[5]; + /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf; + /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5]; /* 0x0e4 */ u8 unk_e4[5]; /* 0x0e9 */ u8 unk_e9[5]; /* 0x0ee */ vu8 errorState; @@ -304,7 +316,7 @@ typedef struct UnkRfuStruct_2 /* 0x93d */ u8 unk_c85; /* 0x93e */ u8 unk_c86; /* 0x93f */ u8 recvCmds[5][7][2]; - /* 0x985 */ u8 unk_ccd; + /* 0x985 */ u8 parentId; /* 0x986 */ u8 unk_cce; // childId /* 0x987 */ u8 unk_ccf; /* 0x988 */ vu8 unk_cd0; @@ -423,16 +435,16 @@ void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); void RecordMixTrainerNames(void); void sub_80F8CFC(); void sub_80F8D14(); -void sub_80FAF74(bool32 a0, bool32 a1); +void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void sub_80F8FA0(void); -void sub_80FAFA0(u32 type, u32 species, u32 level); +void RfuUpdatePlayerGnameStateAndSend(u32 type, u32 species, u32 level); bool32 sub_80FBB0C(void); void sub_80FBC00(void); void sub_80FBD6C(u32 a0); void sub_80FC114(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); -bool8 sub_80FCC3C(struct GFtgtGname *gname, u8 *uname, u8 idx); +bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *gname, u8 *uname, u8 idx); bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx); bool32 GetRfuUnkCE8(void); void sub_80FA4A8(void); diff --git a/include/union_room.h b/include/union_room.h index 2c32760cb..d8f1a6dd9 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -160,7 +160,7 @@ struct UnionRoomTrade u32 personality; }; -extern struct GFtgtGnameSub gUnknown_203B064; +extern struct GFtgtGnameSub gPartnerTgtGnameSub; extern u16 gUnionRoomOfferedSpecies; extern u8 gUnionRoomRequestedMonType; diff --git a/include/union_room_message.h b/include/union_room_message.h index 3ebf66252..db24aca15 100644 --- a/include/union_room_message.h +++ b/include/union_room_message.h @@ -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[]; @@ -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[]; -- cgit v1.2.3 From e0d25c32898b1284297159a5d1c1c6422a040150 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 3 Feb 2020 20:09:14 -0500 Subject: Document wireless_communication_status_screen --- include/constants/union_room.h | 40 +++++++++++++++++++++------------------- include/link_rfu.h | 10 +++++----- include/strings.h | 11 +++++++++++ include/union_room.h | 16 ++++++++-------- 4 files changed, 45 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/constants/union_room.h b/include/constants/union_room.h index 04ffa3037..b4e08b1a8 100644 --- a/include/constants/union_room.h +++ b/include/constants/union_room.h @@ -5,29 +5,31 @@ #define UNION_ROOM_SPAWN_IN 1 #define UNION_ROOM_SPAWN_OUT 2 -#define UROOM_ACTIVITY_NONE 0 -#define UROOM_ACTIVITY_BATTLE 1 -#define UROOM_ACTIVITY_DBLBATTLE 2 -#define UROOM_ACTIVITY_MLTBATTLE 3 -#define UROOM_ACTIVITY_TRADE 4 -#define UROOM_ACTIVITY_CHAT 5 -#define UROOM_ACTIVITY_WCARD 6 -#define UROOM_ACTIVITY_WNEWS 7 -#define UROOM_ACTIVITY_CARD 8 -#define UROOM_ACTIVITY_PJUMP 9 -#define UROOM_ACTIVITY_BCRUSH 10 -#define UROOM_ACTIVITY_BPICK 11 -#define UROOM_ACTIVITY_SEARCH 12 -#define UROOM_ACTIVITY_SPINTRADE 13 -#define UROOM_ACTIVITY_ITEMTRADE 14 +#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 UROOM_ACTIVITY_ACCEPT 17 -#define UROOM_ACTIVITY_DECLINE 18 +#define ACTIVITY_ACCEPT 17 +#define ACTIVITY_DECLINE 18 // Duplicate IDs? -#define UROOM_ACTIVITY_WCARD2 21 -#define UROOM_ACTIVITY_WNEWS2 22 +#define ACTIVITY_WCARD2 21 +#define ACTIVITY_WNEWS2 22 + +#define IN_UNION_ROOM 0x40 // Used in UR_AddTextPrinterParameterized #define UR_COLOR_DKE_WHT_LTE 0 diff --git a/include/link_rfu.h b/include/link_rfu.h index d25ed020e..40d69201e 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -279,7 +279,7 @@ typedef struct UnkRfuStruct_2 /* 0x004 */ u16 state; /* 0x006 */ u8 filler_06[4]; /* 0x00a */ u16 linkman_msg; - /* 0x00c */ u8 unk_0c; // parentChildMode? + /* 0x00c */ u8 parent_child; /* 0x00d */ u8 playerCount; /* 0x00e */ u8 unk_0e; /* 0x00f */ u8 unk_0f; @@ -372,7 +372,7 @@ void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_Leader(u32 arg0); void sub_80F9E2C(void * data); -u8 sub_8116DE0(void); +u8 CreateTask_ListenToWireless(void); void sub_80FBB4C(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); @@ -392,7 +392,7 @@ bool32 LinkRfuMain1(void); bool32 LinkRfuMain2(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); -void sub_80F8DC0(void); +void LinkRfu_Shutdown(void); void sub_80FBB20(void); bool8 sub_80FA484(bool32 a0); void var_800D_set_xB(void); @@ -425,10 +425,10 @@ bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); void sub_80FA670(u8 a0, u16 a1, const u8 *a2); u32 sub_80FA6FC(u16 a0, const u8 *a1); void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2); -void sub_80FBB8C(u32 a0); +void InitializeRfuLinkManager_LinkLeader(u32 availSlots); void sub_80FBD4C(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); -void sub_80FBBD8(void); +void InitializeRfuLinkManager_JoinGroup(void); void sub_80FA6BC(void); void sub_80FBF54(const u8 *src, u16 trainerId); void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); diff --git a/include/strings.h b/include/strings.h index 5c8ffde4b..7ce955985 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1100,4 +1100,15 @@ 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[]; + #endif //GUARD_STRINGS_H diff --git a/include/union_room.h b/include/union_room.h index d8f1a6dd9..4ca58e03e 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -12,21 +12,21 @@ #define UROOM_MAX_GROUP_COUNT 8 #define UROOM_MAX_PARTY_SIZE 5 -struct UnkStruct_Shared +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; + struct UnionGnameUnamePair gname_uname; u8 active:1; }; struct UnkStruct_x20 { - struct UnkStruct_Shared unk; + struct UnionGnameUnamePair gname_uname; u16 field_18; u8 groupScheduledAnim:2; u8 field_1A_1:1; @@ -59,7 +59,7 @@ 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; @@ -68,8 +68,8 @@ struct UnkStruct_Leader u8 field_14; u8 field_15; u8 field_16; - u8 field_17; - u8 field_18; + u8 taskId_sub_8119EB8; + u8 activity; u8 field_19; u16 field_1A; }; @@ -88,7 +88,7 @@ struct UnkStruct_Group u8 field_F; u8 field_10; u8 field_11; - u8 field_12; + u8 cardOrNews; u8 field_13; u8 field_14; u8 field_15; -- cgit v1.2.3 From 4770fac9eb9696236fa998554a353f1f140a1ed4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 4 Feb 2020 14:16:45 -0500 Subject: More mevent documentation --- include/berry_crush.h | 2 +- include/dodrio_berry_picking.h | 2 +- include/event_data.h | 4 ++-- include/global.h | 19 ++++++++++--------- include/link.h | 4 ++-- include/link_rfu.h | 6 +++--- include/mevent.h | 35 ++++++++++++++++++++++++++--------- include/mevent_server.h | 1 + include/pokemon_jump.h | 2 +- include/script.h | 2 +- include/strings.h | 15 +++++++++++++++ 11 files changed, 63 insertions(+), 29 deletions(-) (limited to 'include') 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/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/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/global.h b/include/global.h index b12508ae5..8644fe364 100644 --- a/include/global.h +++ b/include/global.h @@ -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/link.h b/include/link.h index e41b89634..7b20c71b4 100644 --- a/include/link.h +++ b/include/link.h @@ -253,11 +253,11 @@ void sub_800A620(void); void sub_80FBB4C(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); diff --git a/include/link_rfu.h b/include/link_rfu.h index 40d69201e..92aceec59 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -295,7 +295,7 @@ typedef struct UnkRfuStruct_2 /* 0x068 */ u8 filler_68[4]; /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf; /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5]; - /* 0x0e4 */ u8 unk_e4[5]; + /* 0x0e4 */ u8 cmd5f00Ack[5]; /* 0x0e9 */ u8 unk_e9[5]; /* 0x0ee */ vu8 errorState; /* 0x0ef */ u8 unk_ef; @@ -365,7 +365,7 @@ void AddTextPrinterToWindow1(const u8 *str); bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src); void LinkRfu_FatalError(void); void MG_DrawCheckerboardPattern(void); -void task_add_05_task_del_08FA224_when_no_RfuFunc(void); +void Rfu_BeginBuildAndSendCommand5F(void); bool8 IsLinkRfuTaskFinished(void); void DestroyWirelessStatusIndicatorSprite(void); void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); @@ -413,7 +413,7 @@ void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void sub_80FAFE0(u8 a0); +void sub_80FAFE0(bool8 unk_0a_7); bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); bool8 sub_80F8F40(void); diff --git a/include/mevent.h b/include/mevent.h index 85782f20a..d9da3166d 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,8 +83,8 @@ 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 InitMEventData(void); +u16 MEvent_GetBattleCardCount(u32 command); void sub_8144714(u32 a0, u32 a1); u16 *GetMEventProfileECWordsMaybe(void); void sub_81446C4(void); 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/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/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/strings.h b/include/strings.h index 7ce955985..d468af4f3 100644 --- a/include/strings.h +++ b/include/strings.h @@ -1111,4 +1111,19 @@ 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 -- cgit v1.2.3 From 6af7391add68be30c6bd7d22803a3dd454e08a33 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 4 Feb 2020 17:01:57 -0500 Subject: More renaming in union_room.c --- include/link_rfu.h | 6 +++--- include/mevent.h | 2 +- include/union_room.h | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/link_rfu.h b/include/link_rfu.h index 92aceec59..dc96e3a77 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -433,8 +433,8 @@ void sub_80FA6BC(void); void sub_80FBF54(const u8 *src, u16 trainerId); void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); void RecordMixTrainerNames(void); -void sub_80F8CFC(); -void sub_80F8D14(); +void LinkRfu_CreateConnectionAsParent(); +void LinkRfu_StopManagerBeforeEnteringChat(); void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void sub_80F8FA0(void); @@ -445,7 +445,7 @@ void sub_80FBD6C(u32 a0); void sub_80FC114(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); bool8 LinkRfu_GetNameIfCompatible(struct GFtgtGname *gname, u8 *uname, u8 idx); -bool8 sub_80FCCF4(struct GFtgtGname *gname, u8 *uname, u8 idx); +bool8 LinkRfu_GetNameIfSerial7F7D(struct GFtgtGname *gname, u8 *uname, u8 idx); bool32 GetRfuUnkCE8(void); void sub_80FA4A8(void); void sub_80FB9D0(void); diff --git a/include/mevent.h b/include/mevent.h index d9da3166d..7f4925531 100644 --- a/include/mevent.h +++ b/include/mevent.h @@ -87,7 +87,7 @@ void InitMEventData(void); u16 MEvent_GetBattleCardCount(u32 command); void sub_8144714(u32 a0, u32 a1); u16 *GetMEventProfileECWordsMaybe(void); -void sub_81446C4(void); +void ResetReceivedWonderCardFlag(void); bool32 sub_81446D0(u16 a0); u16 GetWonderCardFlagId(void); diff --git a/include/union_room.h b/include/union_room.h index 4ca58e03e..3efca7867 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -61,14 +61,14 @@ struct UnkStruct_Leader u8 textState; u8 delayTimerAfterOk; u8 listWindowId; - u8 field_10; - u8 field_11; + u8 bButtonCancelWindowId; + u8 nPlayerModeWindowId; u8 listTaskId; u8 playerCount; - u8 field_14; + u8 messageWindowId; u8 field_15; u8 field_16; - u8 taskId_sub_8119EB8; + u8 listenTaskId; u8 activity; u8 field_19; u16 field_1A; @@ -87,11 +87,11 @@ struct UnkStruct_Group u8 listTaskId; u8 field_F; u8 field_10; - u8 field_11; + u8 listenTaskId; u8 cardOrNews; u8 field_13; u8 field_14; - u8 field_15; + u8 delayBeforePrint; }; struct UnionObj -- cgit v1.2.3 From 78caeff45b98bf3cce180d37606d5a5239fbb030 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 6 Feb 2020 10:44:22 -0500 Subject: Name remaining funcs in union_room.c --- include/constants/union_room.h | 3 +++ include/event_object_lock.h | 2 +- include/link_rfu.h | 32 ++++++++++++++++---------------- include/menu.h | 2 +- include/mevent.h | 4 ++-- include/union_room.h | 20 +++++++++----------- 6 files changed, 32 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/include/constants/union_room.h b/include/constants/union_room.h index b4e08b1a8..aaeb3b34d 100644 --- a/include/constants/union_room.h +++ b/include/constants/union_room.h @@ -25,6 +25,9 @@ #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 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/link_rfu.h b/include/link_rfu.h index dc96e3a77..472f5fa74 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -124,11 +124,11 @@ struct __attribute__((packed, aligned(2))) GFtgtGname u16 species:10; u16 type:6; u8 activity:7; - u8 unk_0a_7:1; + u8 started:1; u8 playerGender:1; u8 level:7; - u8 unk_0c; -}; + u8 padding; +}; // size: RFU_GNAME_SIZE struct Padded_U8 { @@ -333,7 +333,7 @@ typedef struct UnkRfuStruct_2 /* 0x99c */ u8 unk_ce4; /* 0x99d */ u8 unk_ce5; /* 0x99e */ u8 unk_ce6; - /* 0x99f */ u8 unk_ce7; + /* 0x99f */ u8 acceptSlot_flag; /* 0x9a0 */ bool8 unk_ce8; /* 0x9a1 */ u8 unk_ce9; /* 0x9a2 */ u8 unk_cea[RFU_CHILD_MAX]; @@ -371,7 +371,7 @@ void DestroyWirelessStatusIndicatorSprite(void); void MEvent_CreateTask_CardOrNewsWithFriend(u32 arg0); void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_Leader(u32 arg0); -void sub_80F9E2C(void * data); +void RfuPrepareSend0x2f00(void * data); u8 CreateTask_ListenToWireless(void); void sub_80FBB4C(void); void sub_80F86F4(void); @@ -412,26 +412,26 @@ bool8 RFU_queue_2_14_send(struct UnkRfuStruct_2_Sub_c1c *q1, u8 *q2); void RFU_queue_2_14_recv(struct UnkRfuStruct_2_Sub_c1c *q1, const u8 *q2); bool8 RFU_queue_20_70_send(struct UnkRfuStruct_2_Sub_124 * a0, u8 *a1); void RFU_queue_40_14_recv(struct UnkRfuStruct_2_Sub_9e8 * a0, u8 *a1); -void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 r2, s32 r3); -void sub_80FAFE0(bool8 unk_0a_7); +void InitHostRFUtgtGname(struct GFtgtGname *data, u8 activity, bool32 started, s32 child_sprite_genders); +void UpdateGameData_GroupLockedIn(bool8 started); bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); -bool8 sub_80F8F40(void); +bool8 LmanAcceptSlotFlagIsNotZero(void); void sub_80F8F5C(void); bool32 sub_80FA5D4(void); bool32 sub_80FC1CC(void); -bool32 sub_80F8F7C(bool32 a0); -bool32 sub_80FA634(u16 trainerId, const u8 *trainerName); -void sub_80FA670(u8 a0, u16 a1, const u8 *a2); -u32 sub_80FA6FC(u16 a0, const u8 *a1); +bool32 WaitRfuState(bool32 a0); +bool32 TrainerIdAndNameStillInPartnersList(u16 trainerId, const u8 *trainerName); +void SendByteToPartnerByIdAndName(u8 a0, u16 a1, const u8 *a2); +u32 WaitSendByteToPartnerByIdAndName(u16 a0, const u8 *a1); void SetHostRFUtgtGname(u8 activity, u32 child_sprite_genders, u32 a2); void InitializeRfuLinkManager_LinkLeader(u32 availSlots); -void sub_80FBD4C(const u8 *trainerName, u16 trainerId); +void RequestDisconnectSlotByTrainerNameAndId(const u8 *trainerName, u16 trainerId); void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void InitializeRfuLinkManager_JoinGroup(void); -void sub_80FA6BC(void); -void sub_80FBF54(const u8 *src, u16 trainerId); -void sub_80FB008(u8 activity, u32 child_sprite_genders, u32 a2); +void LinkRfuNIsend8(void); +void CreateTask_sub_80FBE80(const u8 *src, u16 trainerId); +void UpdateGameDataWithActivitySpriteGendersFlag(u8 activity, u32 child_sprite_genders, u32 started); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(); void LinkRfu_StopManagerBeforeEnteringChat(); 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 7f4925531..4f3e365f7 100644 --- a/include/mevent.h +++ b/include/mevent.h @@ -85,10 +85,10 @@ bool32 WonderCard_Test_Unk_08_6(void); u32 MENews_GetInput(u16 input); void InitMEventData(void); u16 MEvent_GetBattleCardCount(u32 command); -void sub_8144714(u32 a0, u32 a1); +void MEvent_RecordIdOfWonderCardSenderByEventType(u32 eventId, u32 trainerId); u16 *GetMEventProfileECWordsMaybe(void); void ResetReceivedWonderCardFlag(void); -bool32 sub_81446D0(u16 a0); +bool32 MEventHandleReceivedWonderCard(u16 cardId); u16 GetWonderCardFlagId(void); #endif //GUARD_MEVENT_H diff --git a/include/union_room.h b/include/union_room.h index 3efca7867..e24bcd480 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -29,11 +29,9 @@ struct UnkStruct_x20 struct UnionGnameUnamePair gname_uname; u16 field_18; u8 groupScheduledAnim:2; - u8 field_1A_1:1; + 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 @@ -80,17 +78,17 @@ 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 listenTaskId; u8 cardOrNews; - u8 field_13; - u8 field_14; + u8 field_13; // referenced but never set + u8 refreshTimer; u8 delayBeforePrint; }; @@ -164,6 +162,6 @@ extern struct GFtgtGnameSub gPartnerTgtGnameSub; extern u16 gUnionRoomOfferedSpecies; extern u8 gUnionRoomRequestedMonType; -void sub_81173C0(u16 battleFlags); +void StartUnionRoomBattle(u16 battleFlags); #endif //GUARD_UNION_ROOM_H -- cgit v1.2.3 From c0373e9e93ff07edebc120e317b6473c171a946a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 10 Feb 2020 11:11:25 -0500 Subject: Address review comments --- include/linkManager.h | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/link_rfu.h | 228 +------------------------------------------------ 2 files changed, 232 insertions(+), 227 deletions(-) create mode 100644 include/linkManager.h (limited to 'include') diff --git a/include/linkManager.h b/include/linkManager.h new file mode 100644 index 000000000..d2387644f --- /dev/null +++ b/include/linkManager.h @@ -0,0 +1,231 @@ +#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. + + +// 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/link_rfu.h b/include/link_rfu.h index 472f5fa74..96c595100 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,216 +3,7 @@ #include "global.h" #include "librfu.h" - -//----------------------------------------------------------------- -// Constant definition -//----------------------------------------------------------------- - -// Link Manager operation mode (specified by u8 parent_child argument of rfu_LMAN_establishConnection) -//#define MODE_CHILD 0 // Start Link Manager in CHILD mode -//#define MODE_PARENT 1 // Start Link Manager in PARENT mode -//Note: This value uses the item defined by AgbRFU_LL.h. -#define MODE_P_C_SWITCH 2 // Start Link Manager in parent-child switching mode. - - -// Error code returned by Link Manager API (rfu_LMAN_...return value of function) -#define LMAN_ERROR_MANAGER_BUSY 1 // Link Manager is already running. -#define LMAN_ERROR_AGB_CLK_SLAVE 2 // AGB is clock slave so link manager cannot run. -#define LMAN_ERROR_PID_NOT_FOUND 3 // Parent device information of the specified PID does not exist in rfuLinkStatus->partner[0-3]. -#define LMAN_ERROR_ILLEGAL_PARAMETER 4 // Specified argument is unusual. -#define LMAN_ERROR_NOW_LINK_RECOVERY 5 // New settings were ignored because link recovery was under way when current link recovery was ON and new settings turned link recovery OFF. -#define LMAN_ERROR_NOW_COMMUNICATION 6 // New settings were ignored because currently communicating with NI. -#define LMAN_ERROR_NOW_SEARCH_PARENT 7 // Parent search currently under way, so ignore new setting. - -// Details of messages and the related parameters returned by the u8 msg, u8 param_count, and lman.param[0-1] arguments of the LMAN callback generated by the operation of the Link Manager. -// msg name msg No. param qty param[0] param[1] Description -#define LMAN_MSG_INITIALIZE_COMPLETED 0x00 // 0 - - Generated when RFU reset and initial settings are completed -#define LMAN_MSG_NEW_CHILD_CONNECT_DETECTED 0x10 // 1 Bit indicating slot - Generated when new child device connection was detected at RFU level. -// with detected connection -#define LMAN_MSG_NEW_CHILD_CONNECT_ACCEPTED 0x11 // 1 Bit indicating slot - Generated when game identification information from child device connected at RFU level is received and accepted (game serial numbers match). -// where connection was accepted -#define LMAN_MSG_NEW_CHILD_CONNECT_REJECTED 0x12 // 1 Bit indicating slot - Generated when the connection from the child device connected at RFU level is rejected (game identification information reception failed or game serial numbers do not match). -// where connection was rejected -#define LMAN_MSG_SEARCH_CHILD_PERIOD_EXPIRED 0x13 // 0 - - Generated when SearchChild operation time expires. -#define LMAN_MSG_END_WAIT_CHILD_NAME 0x14 // 0 - - Generated when reception of game identification information from all child devices completes after the SearchChild operation time expires. -#define LMAN_MSG_PARENT_FOUND 0x20 // 1 Bit indicating - Generated when valid (game serial numbers match) parent devices are found during SearchParent. -// rfuLinkStatus->partner[x] index number storing the valid parent devices (game serial number matches) from among the discovered parent devices. -#define LMAN_MSG_SEARCH_PARENT_PERIOD_EXPIRED 0x21 // 0 - - Generated when SearchParent time expires. -#define LMAN_MSG_CONNECT_PARENT_SUCCESSED 0x22 // 1 Connected slot number - Generated when connection with parent device at RFU level succeeds. -#define LMAN_MSG_CONNECT_PARENT_FAILED 0x23 // 1 Connection failure reason - Generated when connection with parent device at RFU level fails. -#define LMAN_MSG_CHILD_NAME_SEND_COMPLETED 0x24 // 0 - - Generated when transmission of the child's game identification information to the parent device succeeds after connection with parent device at RFU level succeeds. -#define LMAN_MSG_CHILD_NAME_SEND_FAILED_AND_DISCONNECTED 0x25 // 0 - - Generated when transmission of the child's game identification information to the parent device fails after connection with parent device at RFU level succeeds. -#define LMAN_MSG_LINK_LOSS_DETECTED_AND_DISCONNECTED 0x30 // 1 Bit indicating slot - Generated when a link cut is detected and that slot disconnects. (Generated only when link recovery is OFF.) -// that was disconnected and where link cut was detected but link recover not attempted -#define LMAN_MSG_LINK_LOSS_DETECTED_AND_START_RECOVERY 0x31 // 1 Bit indicating slot - Generated when a link cut is detected and the link recovery process starts. (Generated only when link recovery is ON.) -// where link cut was detected and link recovery was started -#define LMAN_MSG_LINK_RECOVERY_SUCCESSED 0x32 // 1 Bit indicating slot - Generated when link recovery succeeds. (Generated only when link recovery is ON.) -// where link recovery succeeded -#define LMAN_MSG_LINK_RECOVERY_FAILED_AND_DISCONNECTED 0x33 // 1 Bit indicating slot - Generated when link recovery fails and that slot disconnects. (Generated only when link recovery is ON.) -// where link recovery failed and that disconnected -#define LMAN_MSG_LINK_DISCONNECTED_BY_USER 0x40 // 1 Generated on disconnection by execution of rfu_REQ_disconnect by disconnected user. -// Slot indicated in bits *Note: If rfu_REQ_disconnect is used for disconnection during link recovery in the child device, the link recovery is also suspended, but the only message returned is DISCONNECTED_BY_USER. -#define LMAN_MSG_CHANGE_AGB_CLOCK_SLAVE 0x41 // 0 - - Generated when the AGB-RFU clock switches to AGB clock slave after a successful connection or link recovery in the child device. (This message is not generated when the AGB switches to a clock slave when an MSC callback completes.) -#define LMAN_MSG_CHANGE_AGB_CLOCK_MASTER 0x45 // 0 - - Generated when the AGB-RFU intercommunication clock is switched to the AGB clock master in the child device. -#define LMAN_MSG_RFU_POWER_DOWN 0x42 // 0 - - Generated when the RFU enters power conservation mode with rfu_LMAN_powerDownRFU. -#define LMAN_MSG_MANAGER_STOPPED 0x43 // 0 - - Generated when the Link Manager is halted by rfu_LMAN_stopLMAN(0). (This message is not generated during SearchChild, SearchParent, ConnectParent, and LinkRecovery. A message (-PERIOD_EXPIRED, -SUCCESSED, -FAILED) corresponding to the operation completion is returned.) -#define LMAN_MSG_MANAGER_FORCED_STOPPED_AND_RFU_RESET 0x44 // 0 - - Generates when the Link Manager is forcibly halted by rfu_LMAN_stopLMAN(1) and RFU is reset. - -#define LMAN_MSG_RECV_DATA_REQ_COMPLETED 0x50 // 0 - - Generated when the execution of rfu_REQ_recvData completes. (This message is not notification of data reception from a RFU.) - -#define LMAN_MSG_REQ_API_ERROR 0xf0 // 2 REQ_commandID REQ_result REQ-API resulted in error. This message is also generated by an REQ-API executed by either the link manager or the user. -#define LMAN_MSG_WATCH_DOG_TIMER_ERROR 0xf1 // 0 - - Generated when a MSC callback does not occur even after 6 seconds pass when the AGB is the clock slave. -#define LMAN_MSG_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA 0xf2 // 0 - - Generated when an automatic starting DMA, such as HDMA, is issued at the same time the RFU attempts to send notification and to return the AGB to the clock master while the AGB is the clock slave and the exchange of that information (REQ command) fails. -#define LMAN_MSG_LMAN_API_ERROR_RETURN 0xf3 // 1 Return error code - Generated when LMAN-API execution returns an error. -#define LMAN_MSG_RFU_FATAL_ERROR 0xff // 0 - - Generated when the Link Manager cannot recongize a RFU because of the execution of rfu_REQBN_softReset_and_checkID. - - -// Value of lman.childClockSlave_flag -#define RFU_CHILD_CLOCK_SLAVE_OFF 0 // The child device is not operating in AGB clock slave mode. (The child device is in this mode in cases such as when the child has not established a connection or during link recovery.) -#define RFU_CHILD_CLOCK_SLAVE_ON 1 // The child device is operating in AGB clock slave mode. (Child automatically enters this mode when a connection is established.) -#define RFU_CHILD_CLOCK_SLAVE_OFF_REQ 2 // The child device has requested that AGB clock slave mode be halted. - -// State of Link Manager (values of lman.state, lman.next_state) -#define LMAN_STATE_READY 0x00 // Waiting -#define LMAN_STATE_SOFT_RESET_AND_CHECK_ID 0x01 // Requesting execution of rfu_REQBN_softResetAndCheckID (same as below) -#define LMAN_STATE_RESET 0x02 // rfu_REQ_reset -#define LMAN_STATE_CONFIG_SYSTEM 0x03 // rfu_REQ_configSystem -#define LMAN_STATE_CONFIG_GAME_DATA 0x04 // rfu_REQ_configGameData -#define LMAN_STATE_START_SEARCH_CHILD 0x05 // rfu_REQ_startSearchChild -#define LMAN_STATE_POLL_SEARCH_CHILD 0x06 // rfu_REQ_pollSearchChild -#define LMAN_STATE_END_SEARCH_CHILD 0x07 // rfu_REQ_endSearchChild -#define LMAN_STATE_WAIT_RECV_CHILD_NAME 0x08 // Awaiting reception of game name from connected child device. -#define LMAN_STATE_START_SEARCH_PARENT 0x09 // rfu_REQ_startSearchParent -#define LMAN_STATE_POLL_SEARCH_PARENT 0x0a // rfu_REQ_pollSearchParent -#define LMAN_STATE_END_SEARCH_PARENT 0x0b // rfu_REQ_endSearchParent -#define LMAN_STATE_START_CONNECT_PARENT 0x0c // rfu_REQ_startConnectParent -#define LMAN_STATE_POLL_CONNECT_PARENT 0x0d // rfu_REQ_pollConnectParent -#define LMAN_STATE_END_CONNECT_PARENT 0x0e // rfu_REQ_endConnectParent -#define LMAN_STATE_SEND_CHILD_NAME 0x0f // Sending child game name. -#define LMAN_STATE_START_LINK_RECOVERY 0x10 // rfu_REQ_CHILD_startConnectRecovery -#define LMAN_STATE_POLL_LINK_RECOVERY 0x11 // rfu_REQ_CHILD_pollConnectRecovery -#define LMAN_STATE_END_LINK_RECOVERY 0x12 // rfu_REQ_CHILD_endConnectRecovery -#define LMAN_STATE_MS_CHANGE 0x13 // rfu_REQ_changeMasterSlave -#define LMAN_STATE_WAIT_CLOCK_MASTER 0x14 // Waiting for AGB-RFU intercommunication clock to become AGB clock master. -#define LMAN_STATE_STOP_MODE 0x15 // rfu_REQ_stopMode -#define LMAN_STATE_BACK_STATE 0x16 // Following the completion of link-recovery processing, return the Link Manager state to the state present before link-recovery processing was initiated. -#define LMAN_FORCED_STOP_AND_RFU_RESET 0x17 // Attempt to forcibly stop Link Manager using rfu_LMAN_stopLMAN(1). -#define LMAN_STATE_WAIT_CHANGE_CLOCK_MASTER 0x18 // Attempt to return to AGB clock master after child fails in sending game name. - -// RfuTgtData.gname is read as these structs. -struct GFtgtGnameSub -{ - u16 language:4; - u16 hasNews:1; - u16 hasCard:1; - u16 unk_00_6:1; - u16 isChampion:1; - u16 hasNationalDex:1; - u16 gameClear:1; - u16 version:4; - u16 unk_01_6:2; - u8 playerTrainerId[2]; -}; - -struct __attribute__((packed, aligned(2))) GFtgtGname -{ - struct GFtgtGnameSub unk_00; - u8 child_sprite_gender[RFU_CHILD_MAX]; // u8 sprite_idx:3; - // u8 gender:1; - // u8 unk_4:3 - // u8 active:1 - u16 species:10; - u16 type:6; - u8 activity:7; - u8 started:1; - u8 playerGender:1; - u8 level:7; - u8 padding; -}; // size: RFU_GNAME_SIZE - -struct Padded_U8 -{ - u8 value; -}; - -// Parameter group used in initial setting run of the link manager (rfu_LMAN_initializeRFU) -typedef struct InitializeParametersTag { - // rfu_REQ_configSystem argument - u8 maxMFrame; // Maximum number of times to re-transmit of RFU level - u8 MC_TimerCount; // MC_Timer count (x16.7ms) - u16 availSlot_flag; // Use RFU-API constant "AVAIL_SLOT1-4" to specify the maximum number of child devices (1 - 4) that can be connected to a parent device. - - // rfu_REQB_configGameData argument - u8 mboot_flag; // Multiplayer boot flag - u16 serialNo; // Game serial number - u8 *gameName; // Game name - u8 *userName; // User name - - // ON/OFF flag for parent fast search operation by child. - u8 fastSearchParent_flag; // Flag indicating whether parent fast search operation to be performed by child. - - // Link recovery settings - u8 linkRecovery_enable; // Determines whether or not to execute the link recovery process when a link cut occurs - u16 linkRecovery_period; // Time to spend on the link recovery process (x 16.7 ms) Note: Runs for unlimited time when specifying 0. - - // Setting for NI-type data transmit/receive period - u16 NI_failCounter_limit; // Limit for failCounter during NI type data transmit/receive (x 16.7 ms) Note: Runs for unlimited time when specifying 0. -}INIT_PARAM; - - -// Timer that counts with the V-Blank cycle -typedef struct VblankTimerTag { - u8 active; // Timer ON/OFF (bits 0 - 3 indicate ON/OFF for each connected slot) - u16 count_max; // Maximum count value (x16.7ms) - u16 count[RFU_CHILD_MAX]; // Current count value (x 16.7 ms) for each connected slot -}VBL_TIMER; - -struct UnkLinkRfuStruct_02022B44 -{ - u8 fill_00[6]; - u16 unk_06; - u8 fill_08[6]; - vu8 unk_0e; - u8 unk_0f; - u8 fill_10[0x54]; - u16 unk_64; - u8 fill_66[0x1d]; - u8 unk_83; - u8 fill_84[0x58]; -}; - -typedef struct linkManagerTag -{ - /* 0x000 */ u8 acceptSlot_flag; - /* 0x001 */ u8 acceptCount; - /* 0x002 */ vu8 childClockSlave_flag; - /* 0x003 */ vu8 parentAck_flag; - /* 0x004 */ u8 state; - /* 0x005 */ u8 next_state; - /* 0x006 */ u8 parent_child; - /* 0x007 */ u8 pcswitch_flag; - /* 0x008 */ u8 RFU_powerOn_flag; - /* 0x009 */ u8 linkRecovery_enable; - /* 0x00a */ u8 linkRecovery_start_flag; - /* 0x00b */ u8 fastSearchParent_flag; - /* 0x00c */ u8 connectSlot_flag_old; - /* 0x00d */ u8 reserveDisconnectSlot_flag; - /* 0x00e */ u8 active; - /* 0x00f */ u8 msc_exe_flag; - /* 0x010 */ u8 child_slot; - /* 0x011 */ u8 state_bak[2]; - /* 0x014 */ u16 param[2]; - /* 0x018 */ u16 NI_failCounter_limit; - /* 0x01a */ u16 connect_period; - /* 0x01c */ u16 pcswitch_period_bak; - /* 0x01e */ u16 work; - /* 0x020 */ u16 *acceptable_serialNo_list; - /* 0x024 */ VBL_TIMER nameAcceptTimer; - /* 0x030 */ VBL_TIMER linkRecoveryTimer; - /* 0x03c */ INIT_PARAM *init_param; - /* 0x040 */ void (*LMAN_callback)(u8, u8); - /* 0x044 */ void (*MSC_callback)(u16); -} LINK_MANAGER; +#include "linkManager.h" #define RFU_COMMAND_0x8800 0x8800 #define RFU_COMMAND_0x8900 0x8900 @@ -340,26 +131,9 @@ typedef struct UnkRfuStruct_2 /* 0x9a6 */ u8 unk_cee[RFU_CHILD_MAX]; } GF_RFU_MANAGER; // size: 0x9AC -extern struct linkManagerTag lman; extern struct GFtgtGname gHostRFUtgtGnameBuffer; extern u8 gHostRFUtgtUnameBuffer[]; -// Official signatures -u32 rfu_LMAN_REQBN_softReset_and_checkID(void); -void rfu_LMAN_requestChangeAgbClockMaster(void); -void rfu_LMAN_initializeRFU(INIT_PARAM *init_params); -u8 rfu_LMAN_establishConnection(u8 parent_child, u16 connect_period, u16 name_accept_period, u16 *acceptable_serialNo_list); -void rfu_LMAN_stopManager(bool8 forced_stop_and_RFU_reset_flag); -void rfu_LMAN_setMSCCallback(void (*MSC_callback_p)(u16)); -void rfu_LMAN_REQ_sendData(bool8 clockChangeFlag); -void rfu_LMAN_powerDownRFU(void); -u8 rfu_LMAN_CHILD_connectParent(u16 parentId, u16 connect_period); -u8 rfu_LMAN_setLinkRecovery(u8 enable_flag, u16 recovery_period); -void rfu_LMAN_manager_entity(u32 rand); -void rfu_LMAN_syncVBlank(void); -u8 rfu_LMAN_initializeManager(void (*LMAN_callback_p)(u8, u8), void (*MSC_callback_p)(u16)); -void rfu_LMAN_forceChangeSP(void); - // GameFreak signatures void AddTextPrinterToWindow1(const u8 *str); bool32 MG_PrintTextOnWindow1AndWaitButton(u8 * cmdPtr, const u8 * src); -- cgit v1.2.3 From b9f1132aa65c8f79d6c2c93ad372146b0bbda094 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 10 Feb 2020 12:07:22 -0500 Subject: link_rfu.c --> AgbRfu_LinkManager.c --- include/AgbRfu_LinkManager.h | 231 +++++++++++++++++++++++++++++++++++++++++++ include/linkManager.h | 231 ------------------------------------------- include/link_rfu.h | 2 +- 3 files changed, 232 insertions(+), 232 deletions(-) create mode 100644 include/AgbRfu_LinkManager.h delete mode 100644 include/linkManager.h (limited to 'include') diff --git a/include/AgbRfu_LinkManager.h b/include/AgbRfu_LinkManager.h new file mode 100644 index 000000000..d2387644f --- /dev/null +++ b/include/AgbRfu_LinkManager.h @@ -0,0 +1,231 @@ +#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. + + +// 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/linkManager.h b/include/linkManager.h deleted file mode 100644 index d2387644f..000000000 --- a/include/linkManager.h +++ /dev/null @@ -1,231 +0,0 @@ -#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. - - -// 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/link_rfu.h b/include/link_rfu.h index 96c595100..52d3a4c9c 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,7 +3,7 @@ #include "global.h" #include "librfu.h" -#include "linkManager.h" +#include "AgbRfu_LinkManager.h" #define RFU_COMMAND_0x8800 0x8800 #define RFU_COMMAND_0x8900 0x8900 -- cgit v1.2.3 From 371f9fda6e16291eb2f7b99ab078b6a0efd60bd8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 10 Feb 2020 12:20:55 -0500 Subject: Annotate AgbRfu_LinkManager.c with local defines --- include/AgbRfu_LinkManager.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/AgbRfu_LinkManager.h b/include/AgbRfu_LinkManager.h index d2387644f..0970a4233 100644 --- a/include/AgbRfu_LinkManager.h +++ b/include/AgbRfu_LinkManager.h @@ -11,6 +11,20 @@ //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. -- cgit v1.2.3 From fafcdf3c60d34d09d6cac0058c5a679783cbb11c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 10 Feb 2020 13:19:15 -0500 Subject: Multiversion support for api buff size --- include/librfu.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/librfu.h b/include/librfu.h index 83523433c..50dd1c3db 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -88,9 +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) -// Sizes are 0x28 larger in v1028 +#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 -- cgit v1.2.3 From 354d837d6f680b44b7824e95a1363b387717807a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 11 Feb 2020 10:49:36 -0500 Subject: document digit_obj_util --- include/digit_obj_util.h | 24 ++++++++++++++++++++++++ include/unk_815C980.h | 24 ------------------------ 2 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 include/digit_obj_util.h delete mode 100644 include/unk_815C980.h (limited to 'include') 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/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 -- cgit v1.2.3 From 9ff146b0bcf3e5f2bbb0db9a21a147dde80d81fd Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 11 Feb 2020 13:43:14 -0500 Subject: document minigame_countdown.c --- include/sprite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') 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 -- cgit v1.2.3 From 11af7a07510e4d5c784a6c30691e07d4fce23a53 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 11 Feb 2020 13:49:19 -0500 Subject: Rename unk headers --- include/ereader_helpers.h | 11 +++++++++++ include/unk_810c3a4.h | 26 -------------------------- include/unk_815c27c.h | 11 ----------- include/vs_seeker.h | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 37 deletions(-) create mode 100644 include/ereader_helpers.h delete mode 100644 include/unk_810c3a4.h delete mode 100644 include/unk_815c27c.h (limited to 'include') diff --git a/include/ereader_helpers.h b/include/ereader_helpers.h new file mode 100644 index 000000000..748db7190 --- /dev/null +++ b/include/ereader_helpers.h @@ -0,0 +1,11 @@ +#ifndef GUARD_EREADER_HELPERS_H +#define GUARD_EREADER_HELPERS_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_EREADER_HELPERS_H 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_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..428278192 100644 --- a/include/vs_seeker.h +++ b/include/vs_seeker.h @@ -3,6 +3,28 @@ #include "global.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); + void Task_VsSeeker_0(u8 taskId); void sub_810CB90(void); void sub_810CDE8(void); -- cgit v1.2.3 From 325c5b3f11896b76b8e86c2e0ffab1189cca98b6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 11 Feb 2020 16:26:50 -0500 Subject: Document ereader_helpers.c --- include/ereader_helpers.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ereader_helpers.h b/include/ereader_helpers.h index 748db7190..dab97470a 100644 --- a/include/ereader_helpers.h +++ b/include/ereader_helpers.h @@ -1,11 +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, size_t, const void *, void *); +u16 EReaderHandleTransfer(u8 mode, size_t size, const void * src, void * dest); #endif //GUARD_EREADER_HELPERS_H -- cgit v1.2.3 From 32dc21b634c74c2287b94289fdfe08499c626302 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 11 Feb 2020 16:56:09 -0500 Subject: Remove defunct macros and move trainer tower pointers and dummy header --- include/vs_seeker.h | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'include') diff --git a/include/vs_seeker.h b/include/vs_seeker.h index 428278192..2d88417fa 100644 --- a/include/vs_seeker.h +++ b/include/vs_seeker.h @@ -3,25 +3,6 @@ #include "global.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); -- cgit v1.2.3 From aa4a979334036eb647cef5cd6a4ecd0bcad4b235 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 12 Feb 2020 15:32:14 -0500 Subject: More function documentation in union_room, link, link_rfu_2 --- include/constants/union_room.h | 3 +++ include/link.h | 16 ++++++++-------- include/link_rfu.h | 26 +++++++++++++------------- include/overworld.h | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/constants/union_room.h b/include/constants/union_room.h index aaeb3b34d..b23860645 100644 --- a/include/constants/union_room.h +++ b/include/constants/union_room.h @@ -54,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/link.h b/include/link.h index 7b20c71b4..e36ac8078 100644 --- a/include/link.h +++ b/include/link.h @@ -246,11 +246,11 @@ 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 Link_TryStartSend5FFF(void); @@ -264,19 +264,19 @@ 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 PrepareLocalLinkPlayerBlock(void); +void LinkPlayerFromBlock(u32 who); void SetLinkErrorFromRfu(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06); u8 sub_800A8D4(void); diff --git a/include/link_rfu.h b/include/link_rfu.h index 52d3a4c9c..86d55047d 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -87,21 +87,21 @@ typedef struct UnkRfuStruct_2 /* 0x06c */ struct RfuBlockSend cmd_8800_sendbuf; /* 0x080 */ struct RfuBlockSend cmd_8800_recvbuf[5]; /* 0x0e4 */ u8 cmd5f00Ack[5]; - /* 0x0e9 */ u8 unk_e9[5]; + /* 0x0e9 */ u8 cmd_6600_recvd[5]; /* 0x0ee */ vu8 errorState; /* 0x0ef */ u8 unk_ef; /* 0x0f0 */ u8 linkLossRecoveryState; /* 0x0f1 */ u8 unk_f1; /* 0x0f2 */ u16 unk_f2[6]; - /* 0x0fe */ u16 unk_fe; - /* 0x100 */ u16 unk_100; + /* 0x0fe */ u16 cmd_6600_timer; + /* 0x100 */ u16 cmd_6600_count; /* 0x102 */ u8 unk_102; /* 0x104 */ struct RfuTgtData unk_104; /* 0x124 */ struct UnkRfuStruct_2_Sub_124 unk_124; /* 0x6a0 */ struct UnkRfuStruct_2_Sub_9e8 unk_9e8; /* 0x8d4 */ struct UnkRfuStruct_2_Sub_c1c unk_c1c; /* 0x8f4 */ vu8 unk_c3c; - /* 0x8f5 */ u8 unk_c3d; + /* 0x8f5 */ u8 reconnectedParentIdx; /* 0x8f6 */ vu8 child_slot; /* 0x8f7 */ u8 unk_c3f[70]; /* 0x93d */ u8 unk_c85; @@ -118,12 +118,12 @@ typedef struct UnkRfuStruct_2 /* 0x993 */ vu8 unk_cdb; /* 0x994 */ vu8 unk_cdc; /* 0x995 */ u8 unk_cdd; - /* 0x996 */ u8 unk_cde[RFU_CHILD_MAX]; + /* 0x996 */ u8 linkPlayerIdx[RFU_CHILD_MAX]; /* 0x99a */ u8 bm_PartnerFlags; /* 0x99b */ u8 bm_DisconnectSlot; /* 0x99c */ u8 unk_ce4; /* 0x99d */ u8 unk_ce5; - /* 0x99e */ u8 unk_ce6; + /* 0x99e */ u8 unionRoomChatters; /* 0x99f */ u8 acceptSlot_flag; /* 0x9a0 */ bool8 unk_ce8; /* 0x9a1 */ u8 unk_ce9; @@ -147,7 +147,7 @@ void MEvent_CreateTask_CardOrNewsOverWireless(u32 arg0); void MEvent_CreateTask_Leader(u32 arg0); void RfuPrepareSend0x2f00(void * data); u8 CreateTask_ListenToWireless(void); -void sub_80FBB4C(void); +void LinkRfu_DestroyIdleTask(void); void sub_80F86F4(void); void sub_80FB128(bool32 a0); bool32 IsSendingKeysToRfu(void); @@ -161,13 +161,13 @@ u8 Rfu_GetBlockReceivedStatus(void); void Rfu_SetBlockReceivedFlag(u8 who); void Rfu_ResetBlockReceivedFlag(u8 who); bool8 Rfu_IsMaster(void); -void sub_80F85F8(void); +void ResetLinkRfuGFLayer(void); bool32 LinkRfuMain1(void); bool32 LinkRfuMain2(void); bool32 IsRfuRecvQueueEmpty(void); u32 GetRfuRecvQueueLength(void); void LinkRfu_Shutdown(void); -void sub_80FBB20(void); +void LinkRfu_CreateIdleTask(void); bool8 sub_80FA484(bool32 a0); void var_800D_set_xB(void); struct GFtgtGname *GetHostRFUtgtGname(void); @@ -191,7 +191,7 @@ void UpdateGameData_GroupLockedIn(bool8 started); bool32 RfuSerialNumberIsValid(u32 a0); bool8 sub_80FC1B0(void); bool8 LmanAcceptSlotFlagIsNotZero(void); -void sub_80F8F5C(void); +void LinkRfu_StopManagerAndFinalizeSlots(void); bool32 sub_80FA5D4(void); bool32 sub_80FC1CC(void); bool32 WaitRfuState(bool32 a0); @@ -204,7 +204,7 @@ void RequestDisconnectSlotByTrainerNameAndId(const u8 *trainerName, u16 trainerI void LinkRfu3_SetGnameUnameFromStaticBuffers(struct GFtgtGname *gname, u8 *uname); void InitializeRfuLinkManager_JoinGroup(void); void LinkRfuNIsend8(void); -void CreateTask_sub_80FBE80(const u8 *src, u16 trainerId); +void CreateTask_RfuReconnectWithParent(const u8 *src, u16 trainerId); void UpdateGameDataWithActivitySpriteGendersFlag(u8 activity, u32 child_sprite_genders, u32 started); void RecordMixTrainerNames(void); void LinkRfu_CreateConnectionAsParent(); @@ -213,8 +213,8 @@ void SetGnameBufferWonderFlags(bool32 hasNews, bool32 hasCard); void ClearAndInitHostRFUtgtGname(void); void sub_80F8FA0(void); void RfuUpdatePlayerGnameStateAndSend(u32 type, u32 species, u32 level); -bool32 sub_80FBB0C(void); -void sub_80FBC00(void); +bool32 IsUnionRoomListenTaskActive(void); +void InitializeRfuLinkManager_EnterUnionRoom(void); void sub_80FBD6C(u32 a0); void sub_80FC114(const u8 *name, struct GFtgtGname *structPtr, u8 a2); bool32 PlayerHasMetTrainerBefore(u16 id, u8 *name); diff --git a/include/overworld.h b/include/overworld.h index b783248ce..8242615c7 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -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); -- cgit v1.2.3