diff --git a/data/event_scripts.s b/data/event_scripts.s index 1a5e8c07b..0c0279a89 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -28,6 +28,7 @@ #include "constants/secret_bases.h" #include "constants/songs.h" #include "constants/species.h" +#include "constants/trade.h" #include "constants/trainer_hill.h" #include "constants/trainers.h" #include "constants/vars.h" diff --git a/data/maps/BattleFrontier_Lounge6/scripts.inc b/data/maps/BattleFrontier_Lounge6/scripts.inc index 2b14c43c5..8f695aee3 100644 --- a/data/maps/BattleFrontier_Lounge6/scripts.inc +++ b/data/maps/BattleFrontier_Lounge6/scripts.inc @@ -5,7 +5,7 @@ BattleFrontier_Lounge6_EventScript_264FED:: @ 8264FED lock faceplayer goto_if_set FLAG_BATTLE_FRONTIER_TRADE_DONE, BattleFrontier_Lounge6_EventScript_265083 - setvar VAR_0x8008, 3 + setvar VAR_0x8008, INGAME_TRADE_MEOWTH copyvar VAR_0x8004, VAR_0x8008 specialvar VAR_RESULT, GetInGameTradeSpeciesInfo copyvar VAR_0x8009, VAR_RESULT diff --git a/data/maps/FortreeCity_House1/scripts.inc b/data/maps/FortreeCity_House1/scripts.inc index 87aa7a643..e6a617677 100644 --- a/data/maps/FortreeCity_House1/scripts.inc +++ b/data/maps/FortreeCity_House1/scripts.inc @@ -5,7 +5,7 @@ FortreeCity_House1_EventScript_2162BB:: @ 82162BB lock faceplayer goto_if_set FLAG_FORTREE_NPC_TRADE_COMPLETED, FortreeCity_House1_EventScript_216355 - setvar VAR_0x8008, 1 + setvar VAR_0x8008, INGAME_TRADE_PLUSLE copyvar VAR_0x8004, VAR_0x8008 specialvar VAR_RESULT, GetInGameTradeSpeciesInfo copyvar VAR_0x8009, VAR_RESULT diff --git a/data/maps/PacifidlogTown_House3/scripts.inc b/data/maps/PacifidlogTown_House3/scripts.inc index 28f187da9..9633ddc8b 100644 --- a/data/maps/PacifidlogTown_House3/scripts.inc +++ b/data/maps/PacifidlogTown_House3/scripts.inc @@ -5,7 +5,7 @@ PacifidlogTown_House3_EventScript_203C11:: @ 8203C11 lock faceplayer goto_if_set FLAG_PACIFIDLOG_NPC_TRADE_COMPLETED, PacifidlogTown_House3_EventScript_203CAB - setvar VAR_0x8008, 2 + setvar VAR_0x8008, INGAME_TRADE_HORSEA copyvar VAR_0x8004, VAR_0x8008 specialvar VAR_RESULT, GetInGameTradeSpeciesInfo copyvar VAR_0x8009, VAR_RESULT diff --git a/data/maps/RustboroCity_House1/scripts.inc b/data/maps/RustboroCity_House1/scripts.inc index eb5655b1a..f0a0f4827 100644 --- a/data/maps/RustboroCity_House1/scripts.inc +++ b/data/maps/RustboroCity_House1/scripts.inc @@ -5,7 +5,7 @@ RustboroCity_House1_EventScript_21593F:: @ 821593F lock faceplayer goto_if_set FLAG_RUSTBORO_NPC_TRADE_COMPLETED, RustboroCity_House1_EventScript_2159D5 - setvar VAR_0x8008, 0 + setvar VAR_0x8008, INGAME_TRADE_SEEDOT copyvar VAR_0x8004, VAR_0x8008 specialvar VAR_RESULT, GetInGameTradeSpeciesInfo copyvar VAR_0x8009, VAR_RESULT diff --git a/gflib/text.h b/gflib/text.h index e37773475..3c34441dc 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -107,12 +107,19 @@ #define TEXT_COLOR_TRANSPARENT 0x0 #define TEXT_COLOR_WHITE 0x1 #define TEXT_COLOR_DARK_GREY 0x2 -// 0x3 +#define TEXT_COLOR_LIGHT_GREY 0x3 #define TEXT_COLOR_RED 0x4 -// 0x5 +#define TEXT_COLOR_LIGHT_RED 0x5 #define TEXT_COLOR_GREEN 0x6 -// 0x7 +#define TEXT_COLOR_LIGHT_GREEN 0x7 #define TEXT_COLOR_BLUE 0x8 +#define TEXT_COLOR_LIGHT_BLUE 0x9 +#define TEXT_DYNAMIC_COLOR_1 0xA // Usually white +#define TEXT_DYNAMIC_COLOR_2 0xB // Usually white w/ tinge of green +#define TEXT_DYNAMIC_COLOR_3 0xC // Usually white +#define TEXT_DYNAMIC_COLOR_4 0xD // Usually aquamarine +#define TEXT_DYNAMIC_COLOR_5 0xE // Usually blue-green +#define TEXT_DYNAMIC_COLOR_6 0xF // Usually cerulean #define PLACEHOLDER_ID_UNKNOWN 0x0 #define PLACEHOLDER_ID_PLAYER 0x1 diff --git a/graphics/unknown/unknown_DDD704.bin b/graphics/trade/menu_mon_box.bin similarity index 100% rename from graphics/unknown/unknown_DDD704.bin rename to graphics/trade/menu_mon_box.bin diff --git a/graphics/trade/ball.png b/graphics/trade/pokeball.png similarity index 100% rename from graphics/trade/ball.png rename to graphics/trade/pokeball.png diff --git a/graphics/unknown/unknown_DDB444.pal b/graphics/trade/unknown_DDB444.pal similarity index 100% rename from graphics/unknown/unknown_DDB444.pal rename to graphics/trade/unknown_DDB444.pal diff --git a/graphics/unknown/unknown_DDCF04.bin b/graphics/trade/unknown_DDCF04.bin similarity index 100% rename from graphics/unknown/unknown_DDCF04.bin rename to graphics/trade/unknown_DDCF04.bin diff --git a/include/battle_anim.h b/include/battle_anim.h index a7b71bd85..90104fe9c 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -151,7 +151,7 @@ void sub_80A78AC(struct Sprite *sprite); void sub_80A6BFC(struct BattleAnimBgData *unk, u8 unused); u8 sub_80A8394(u16 species, bool8 isBackpic, u8 a3, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, u32 a10); void sub_80A749C(struct Sprite *sprite); -void sub_80A6DEC(struct Sprite *sprite); +void TradeMenuBouncePartySprites(struct Sprite *sprite); void DestroyAnimVisualTaskAndDisableBlend(u8 taskId); void DestroySpriteAndFreeResources_(struct Sprite *sprite); void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId); diff --git a/include/constants/trade.h b/include/constants/trade.h new file mode 100644 index 000000000..4fb8966d0 --- /dev/null +++ b/include/constants/trade.h @@ -0,0 +1,116 @@ +#ifndef GUARD_CONSTANTS_TRADE_H +#define GUARD_CONSTANTS_TRADE_H + +#define TRADE_PLAYER 0 +#define TRADE_PARTNER 1 + +#define LINK_TRADE_TIMEOUT 300 + +// In-game Trade IDs +#define INGAME_TRADE_SEEDOT 0 +#define INGAME_TRADE_PLUSLE 1 +#define INGAME_TRADE_HORSEA 2 +#define INGAME_TRADE_MEOWTH 3 + +// Flag IDs for sending link data +#define INITIATE_TRADE 1 +#define CANCEL_TRADE 2 +#define WANTS_TO_TRADE 1 +#define WANTS_TO_CANCEL 2 +#define READY_FINISH_TRADE 1 +#define FINISH_TRADE 2 + +// Return values for CanTradeSelectedMon and CanTradeSelectedPartyMenuMon +#define CAN_TRADE_MON 0 +#define CANT_TRADE_LAST_MON 1 +#define CANT_TRADE_NATIONAL 2 +#define CANT_TRADE_EGG 3 +#define CANT_TRADE_INVALID_MON 4 +#define CANT_TRADE_EGG2 5 + +// Return values for CheckValidityOfTradeMons +#define PLAYER_MON_INVALID 0 +#define BOTH_MONS_VALID 1 +#define PARTNER_MON_INVALID 2 + +// Return values for GetGameProgressForLinkTrade +#define TRADE_BOTH_PLAYERS_READY 0 +#define TRADE_PLAYER_NOT_READY 1 +#define TRADE_PARTNER_NOT_READY 2 + +// Indexes for sTradeActionTexts +#define TRADE_TEXT_CANCEL 0 +#define TRADE_TEXT_CHOOSE_MON 1 +#define TRADE_TEXT_SUMMARY 2 +#define TRADE_TEXT_TRADE 3 +#define TRADE_TEXT_CANCEL_TRADE 4 +#define TRADE_TEXT_JP_QUIT 5 + +// Checked to confirm DrawTradeMenuParty has reached final state +#define DRAW_PARTY_FINISH 5 + +// Message indexes for sTradeMessages +#define TRADE_MSG_STANDBY 0 +#define TRADE_MSG_CANCELED 1 +#define TRADE_MSG_ONLY_MON1 2 +#define TRADE_MSG_ONLY_MON2 3 +#define TRADE_MSG_WAITING_FOR_FRIEND 4 +#define TRADE_MSG_FRIEND_WANTS_TO_TRADE 5 +#define TRADE_MSG_MON_CANT_BE_TRADED 6 +#define TRADE_MSG_EGG_CANT_BE_TRADED 7 +#define TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED 8 + +// IDs for QueueAction +#define QUEUE_SEND_DATA 0 +#define QUEUE_STANDBY 1 +#define QUEUE_ONLY_MON1 2 +#define QUEUE_ONLY_MON2 3 +#define QUEUE_UNUSED1 4 +#define QUEUE_UNUSED2 5 +#define QUEUE_MON_CANT_BE_TRADED 6 +#define QUEUE_EGG_CANT_BE_TRADED 7 +#define QUEUE_FRIENDS_MON_CANT_BE_TRADED 8 + +#define QUEUE_DELAY_MSG 3 +#define QUEUE_DELAY_DATA 5 + +// IDs for CallTradeMenuFunc +#define TRADEMENUFUNC_MAIN_MENU 0 +#define TRADEMENUFUNC_SELECTED_MON 1 +#define TRADEMENUFUNC_SHOW_MON_SUMMARY 2 +#define TRADEMENUFUNC_CONFIRM_OR_CANCEL_TRADE 3 +#define TRADEMENUFUNC_CANCEL_TRADE_PROMPT 4 +#define TRADEMENUFUNC_UNUSED_5 5 +#define TRADEMENUFUNC_BOTH_MONS_SELECTED 6 +#define TRADEMENUFUNC_CONFIRM_TRADE_PROMPT 7 +#define TRADEMENUFUNC_REDRAW_MAIN_MENU 8 +#define TRADEMENUFUNC_LINK_TRADE_FADE_OUT 9 +#define TRADEMENUFUNC_LINK_TRADE_WAIT_FADE 10 +#define TRADEMENUFUNC_CANCEL_TRADE_1 11 +#define TRADEMENUFUNC_CANCEL_TRADE_2 12 +#define TRADEMENUFUNC_START_LINK_TRADE 13 +#define TRADEMENUFUNC_DELAY_TRADE_CONFIRM 14 +#define TRADEMENUFUNC_UNUSED_15 15 +#define TRADEMENUFUNC_LINK_TRADE_WAIT_QUEUE 16 +#define TRADEMENUFUNC_PARTNER_MON_INVALID 17 +#define TRADEMENUFUNC_STANDBY 100 + +// Message indexes for sUnionRoomTradeMessages +#define UR_TRADE_MSG_NONE 0 +#define UR_TRADE_MSG_NOT_MON_PARTNER_WANTS 1 +#define UR_TRADE_MSG_NOT_EGG 2 +#define UR_TRADE_MSG_MON_CANT_BE_TRADED_1 3 +#define UR_TRADE_MSG_MON_CANT_BE_TRADED_2 4 +#define UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED 5 +#define UR_TRADE_MSG_EGG_CANT_BE_TRADED 6 +#define UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON 7 +#define UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_1 8 +#define UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_2 9 + +// Return values for CanRegisterMonForTradingBoard +#define CAN_REGISTER_MON 0 +#define CANT_REGISTER_MON 1 +#define CANT_REGISTER_EGG 2 + + +#endif //GUARD_CONSTANTS_TRADE_H diff --git a/include/graphics.h b/include/graphics.h index 5f5c579d2..a08d3760f 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4848,13 +4848,13 @@ extern const u32 gCableCarCord_Gfx[]; extern const u16 gCableCar_Pal[]; // Trade -extern const u16 gUnknown_08DDB3E4[]; -extern const u8 gUnknown_08DDB464[]; +extern const u16 gTradeMenu_Pal[]; +extern const u8 gTradeMenu_Gfx[]; extern const u16 gUnknown_08DDCF04[]; extern const u16 gTradeGba2_Pal[]; extern const u8 gTradeGba_Gfx[]; -extern const u16 gUnknown_08DDD704[]; -extern const u8 gUnknown_08DDC6E4[]; +extern const u16 gTradeMenuMonBox_Tilemap[]; +extern const u8 gTradeButtons_Gfx[]; extern const u16 gUnknown_08DDB444[]; // Party menu diff --git a/include/librfu.h b/include/librfu.h index 38c819835..55b5d264c 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -76,10 +76,10 @@ struct UnkLinkRfuStruct_02022B14Substruct u16 unk_00_4:1; u16 unk_00_5:1; u16 unk_00_6:1; - u16 unk_00_7:1; - u16 unk_01_0:1; - u16 unk_01_1:1; - u16 unk_01_2:4; + u16 isChampion:1; + u16 hasNationalDex:1; + u16 gameClear:1; // never read, redundant with isChampion + u16 unk_01_2:4; // always 3? u16 unk_01_6:2; u8 playerTrainerId[2]; }; @@ -93,7 +93,7 @@ struct __attribute__((packed, aligned(2))) UnkLinkRfuStruct_02022B14 u8 unk_0a_0:7; u8 unk_0a_7:1; u8 playerGender:1; - u8 unk_0b_1:7; + u8 level:7; u8 unk_0c; }; diff --git a/include/link.h b/include/link.h index 847ea38ba..499405fc1 100644 --- a/include/link.h +++ b/include/link.h @@ -48,6 +48,31 @@ #define EXTRACT_LINK_ERRORS(status) \ (((status) & LINK_STAT_ERRORS) >> LINK_STAT_ERRORS_SHIFT) +#define LINKCMD_SEND_LINK_TYPE 0x2222 +#define LINKCMD_0x2FFE 0x2FFE +#define LINKCMD_SEND_HELD_KEYS 0x4444 +#define LINKCMD_0x5555 0x5555 +#define LINKCMD_0x5566 0x5566 +#define LINKCMD_0x5FFF 0x5FFF +#define LINKCMD_0x6666 0x6666 +#define LINKCMD_0x7777 0x7777 +#define LINKCMD_CONT_BLOCK 0x8888 +#define LINKCMD_0xAAAA 0xAAAA +#define LINKCMD_0xAAAB 0xAAAB +#define LINKCMD_READY_TO_TRADE 0xAABB +#define LINKCMD_READY_FINISH_TRADE 0xABCD +#define LINKCMD_INIT_BLOCK 0xBBBB +#define LINKCMD_READY_CANCEL_TRADE 0xBBCC +#define LINKCMD_SEND_HELD_KEYS_2 0xCAFE +#define LINKCMD_0xCCCC 0xCCCC +#define LINKCMD_START_TRADE 0xCCDD +#define LINKCMD_CONFIRM_FINISH_TRADE 0xDCBA +#define LINKCMD_SET_MONS_TO_TRADE 0xDDDD +#define LINKCMD_0xDDEE 0xDDEE +#define LINKCMD_REQUEST_CANCEL 0xEEAA +#define LINKCMD_CANCEL_TRADE 0xEEBB +#define LINKCMD_0xEECC 0xEECC + #define LINKTYPE_0x1111 0x1111 // trade #define LINKTYPE_0x1122 0x1122 // trade #define LINKTYPE_0x1133 0x1133 // trade @@ -70,21 +95,6 @@ #define LINKTYPE_0x6601 0x6601 #define LINKTYPE_0x6602 0x6602 -#define LINKCMD_SEND_LINK_TYPE 0x2222 -#define LINKCMD_0x2FFE 0x2FFE -#define LINKCMD_SEND_HELD_KEYS 0x4444 -#define LINKCMD_0x5555 0x5555 -#define LINKCMD_0x5566 0x5566 -#define LINKCMD_0x5FFF 0x5FFF -#define LINKCMD_0x6666 0x6666 -#define LINKCMD_0x7777 0x7777 -#define LINKCMD_CONT_BLOCK 0x8888 -#define LINKCMD_0xAAAA 0xAAAA -#define LINKCMD_0xAAAB 0xAAAB -#define LINKCMD_INIT_BLOCK 0xBBBB -#define LINKCMD_SEND_HELD_KEYS_2 0xCAFE -#define LINKCMD_0xCCCC 0xCCCC - struct LinkStatus { u32 localId:2; @@ -117,8 +127,8 @@ enum EXCHANGE_COMPLETE, EXCHANGE_TIMED_OUT, EXCHANGE_IN_PROGRESS, - EXCHANGE_STAT_4, - EXCHANGE_STAT_5, + EXCHANGE_PLAYER_NOT_READY, + EXCHANGE_PARTNER_NOT_READY, EXCHANGE_STAT_6, EXCHANGE_STAT_7 }; @@ -142,7 +152,10 @@ struct LinkPlayer /* 0x00 */ u16 version; /* 0x02 */ u16 lp_field_2; /* 0x04 */ u32 trainerId; - /* 0x08 */ u8 name[11]; + /* 0x08 */ u8 name[PLAYER_NAME_LENGTH + 1]; + /* 0x10 */ u8 progressFlags; // (& 0x0F) is hasNationalDex, (& 0xF0) is hasClearedGame + /* 0x11 */ u8 neverRead; + /* 0x12 */ u8 progressFlagsCopy; /* 0x13 */ u8 gender; /* 0x14 */ u32 linkType; /* 0x18 */ u16 id; // battler id in battles diff --git a/include/link_rfu.h b/include/link_rfu.h index d6e1009e1..533e515c5 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -128,7 +128,7 @@ struct UnkRfuStruct_Sub_Unused struct UnkRfuStruct_2 { - /* 0x000 */ void (*unk_00)(void); + /* 0x000 */ void (*linkRfuCallback)(void); /* 0x004 */ u16 unk_04; /* 0x006 */ u8 filler_06[4]; /* 0x00a */ u16 unk_0a; @@ -224,11 +224,11 @@ void sub_800F804(void); void sub_800F850(void); u8 sub_800FCD8(void); bool32 sub_800FE84(const u8 *src, size_t size); -void Rfu_set_zero(void); +void ClearLinkRfuCallback(void); u8 sub_80104F4(void); u8 rfu_get_multiplayer_id(void); bool8 sub_8010100(u8 a0); -bool8 sub_8010500(void); +bool8 IsLinkRfuTaskFinished(void); bool8 Rfu_IsMaster(void); void task_add_05_task_del_08FA224_when_no_RfuFunc(void); void sub_8010434(void); diff --git a/include/party_menu.h b/include/party_menu.h index fc4020b27..cfd8840a7 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -93,17 +93,17 @@ u8 GetCursorSelectionMonId(void); u8 sub_81B1360(void); void sub_81B1370(u8 taskId); u8* GetMonNickname(struct Pokemon *mon, u8 *dest); -u8 sub_81B1B5C(const u8* str, u8 b); +u8 DisplayPartyMenuMessage(const u8* str, u8 b); bool8 sub_81B1BD4(void); void sub_81B1F18(u8 taskId, u8 slot, s8 c, s16 HPDifference, TaskFunc func); u8 pokemon_ailments_get_primary(u32 status); u8 GetMonAilment(struct Pokemon *mon); -void display_pokemon_menu_message(u32 stringID); +void DisplayPartyMenuStdMessage(u32 stringID); void sub_81B47E0(u8 taskId); bool8 FieldCallback_PrepareFadeInFromMenu(void); void sub_81B58A8(void); void LoadHeldItemIcons(void); -void sub_81B5D4C(u8 *a, u8 *b, u8 c); +void DrawHeldItemIconsForTrade(u8 *a, u8 *b, u8 c); void sub_81B617C(void); void ItemUseCB_Medicine(u8 taskId, TaskFunc task); void sub_81B67C8(u8 taskId, TaskFunc task); diff --git a/include/pokeball.h b/include/pokeball.h index 8e1d8b8ec..12b9b1eff 100644 --- a/include/pokeball.h +++ b/include/pokeball.h @@ -25,7 +25,7 @@ extern const struct SpriteTemplate gBallSpriteTemplates[]; u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow); void CreatePokeballSpriteToReleaseMon(u8 monSpriteId, u8 battler, u8 x, u8 y, u8 oamPriority, u8 subpriortiy, u8 g, u32 h, u16 species); -u8 sub_807671C(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h); +u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h); void sub_8076918(u8 battler); void DoHitAnimHealthboxEffect(u8 battler); void LoadBallGfx(u8 ballId); diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index 8af43c753..5018de37c 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -21,8 +21,8 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u u8 UpdateMonIconFrame(struct Sprite *sprite); void LoadMonIconPalette(u16 species); void sub_80D328C(struct Sprite *sprite); -void sub_80D3014(struct Sprite *sprite); -void sub_80D32C8(struct Sprite *sprite, u8 animNum); +void UpdateTradeMonIconFrame(struct Sprite *sprite); +void SetPartyHPBarSprite(struct Sprite *sprite, u8 animNum); u8 GetMonIconPaletteIndexFromSpecies(u16 species); #endif // GUARD_POKEMON_ICON_H diff --git a/include/pokemon_storage_system.h b/include/pokemon_storage_system.h index 4c319e59d..7b6a38678 100644 --- a/include/pokemon_storage_system.h +++ b/include/pokemon_storage_system.h @@ -25,7 +25,7 @@ struct PokemonStorage extern struct PokemonStorage *gPokemonStoragePtr; -void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4); +void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 bytesToBuffer); u8 CountMonsInBox(u8 boxId); s16 GetFirstFreeBoxSpot(u8 boxId); u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore); diff --git a/include/trade.h b/include/trade.h index 0c95e1e81..42bfc1482 100644 --- a/include/trade.h +++ b/include/trade.h @@ -2,25 +2,26 @@ #define GUARD_TRADE_H #include "link_rfu.h" +#include "constants/trade.h" // Exported type declarations // Exported RAM declarations -extern struct MailStruct gUnknown_020321C0[PARTY_SIZE]; -extern u8 gUnknown_02032298[2]; +extern struct MailStruct gTradeMail[PARTY_SIZE]; +extern u8 gSelectedTradeMonPositions[2]; // Exported ROM declarations -extern const struct WindowTemplate gUnknown_0833900C; +extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; -s32 sub_807A728(void); -void sub_80773AC(void); -void sub_807AE50(void); -int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16, u16, u8); -int sub_807A7E0(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6); -int sub_807A918(struct Pokemon*, u16); -void sub_807B140(void); -void sub_807B154(void); -void sub_807F19C(void); -void sub_807F1A8(u8, const u8 *, u8); +s32 GetGameProgressForLinkTrade(void); +void CB2_StartCreateTradeMenu(void); +void CB2_LinkTrade(void); +int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, u16, u16, u8); +int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 a2, u16 a3, u8 a4, u16 a5, u8 a6); +int CanTradeSelectedPartyMenuMon(struct Pokemon*, u16); +void InitTradeSequenceBgGpuRegs(void); +void LinkTradeDrawWindow(void); +void InitTradeBg(void); +void DrawTextOnTradeWindow(u8, const u8 *, u8); #endif //GUARD_TRADE_H diff --git a/include/union_room.h b/include/union_room.h index facc63986..54f09cbeb 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -135,7 +135,7 @@ union UnkUnion_Main struct UnkStruct_URoom *uRoom; }; -struct TradeUnkStruct +struct UnionRoomTrade { u16 field_0; u16 type; @@ -156,8 +156,8 @@ extern u8 gUnknown_02022C2C; extern union UnkUnion_Main gUnknown_02022C30; extern struct UnkLinkRfuStruct_02022B14Substruct gUnknown_02022C38; -extern u16 gUnknown_02022C3C; -extern u8 gUnknown_02022C3E; +extern u16 gUnionRoomOfferedSpecies; +extern u8 gUnionRoomRequestedMonType; // Exported ROM declarations diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 9a588a9ca..b8f9485b5 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -988,7 +988,7 @@ void sub_80A6DAC(bool8 arg0) } } -void sub_80A6DEC(struct Sprite *sprite) +void TradeMenuBouncePartySprites(struct Sprite *sprite) { sprite->data[1] = sprite->pos1.x; sprite->data[3] = sprite->pos1.y; diff --git a/src/battle_main.c b/src/battle_main.c index 26e9e91ae..a8f17dc3b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1491,7 +1491,7 @@ static void CB2_PreInitMultiBattle(void) case 3: if (gWirelessCommType) { - if (sub_8010500()) + if (IsLinkRfuTaskFinished()) { gBattleTypeFlags = *savedBattleTypeFlags; gMain.savedCallback = *savedCallback; diff --git a/src/cable_club.c b/src/cable_club.c index 4a0589668..1375789c3 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -125,9 +125,9 @@ static u32 sub_80B2478(u8 lower, u8 upper) return 1; case EXCHANGE_IN_PROGRESS: return 3; - case EXCHANGE_STAT_4: + case EXCHANGE_PLAYER_NOT_READY: return 7; - case EXCHANGE_STAT_5: + case EXCHANGE_PARTNER_NOT_READY: return 9; case EXCHANGE_STAT_6: ConvertIntToDecimalStringN(gStringVar1, GetLinkPlayerCount_2(), STR_CONV_MODE_LEFT_ALIGN, 1); @@ -1086,8 +1086,8 @@ static void sub_80B37FC(u8 taskId) task->data[0]++; break; case 2: - gUnknown_02032298[0] = 0; - gUnknown_02032298[1] = 0; + gSelectedTradeMonPositions[TRADE_PLAYER] = 0; + gSelectedTradeMonPositions[TRADE_PARTNER] = 0; m4aMPlayAllStop(); sub_800AC34(); task->data[0]++; @@ -1095,7 +1095,7 @@ static void sub_80B37FC(u8 taskId) case 3: if (!gReceivedRemoteLinkPlayers) { - SetMainCallback2(sub_80773AC); + SetMainCallback2(CB2_StartCreateTradeMenu); DestroyTask(taskId); } break; @@ -1111,7 +1111,7 @@ static void sub_80B3894(u8 taskId) case 0: ScriptContext2_Enable(); FadeScreen(1, 0); - Rfu_set_zero(); + ClearLinkRfuCallback(); data[0]++; break; case 1: @@ -1119,8 +1119,8 @@ static void sub_80B3894(u8 taskId) data[0]++; break; case 2: - gUnknown_02032298[0] = 0; - gUnknown_02032298[1] = 0; + gSelectedTradeMonPositions[TRADE_PLAYER] = 0; + gSelectedTradeMonPositions[TRADE_PARTNER] = 0; m4aMPlayAllStop(); sub_800ADF8(); data[0]++; diff --git a/src/data/trade.h b/src/data/trade.h new file mode 100644 index 000000000..9e96a54dd --- /dev/null +++ b/src/data/trade.h @@ -0,0 +1,1197 @@ +// Exists unused in RS as well +static const u32 sUnusedStructSizes[] = +{ + sizeof(struct SaveBlock2), + sizeof(struct SaveBlock1), + sizeof(struct MapHeader), + // 0x00000530, in RS + sizeof(struct MailStruct), //or EventObject / EventObjectGraphicsInfo + sizeof(struct Pokemon), //or TrainerCard + 0x00000528 // 0x000004D8, in RS +}; + +static const u16 sTradeMovesBoxTilemap[] = INCBIN_U16("graphics/trade/moves_box_map.bin"); +static const u16 sTradePartyBoxTilemap[] = INCBIN_U16("graphics/trade/party_box_map.bin"); +static const u8 sTradeStripesBG2Tilemap[] = INCBIN_U8("graphics/trade/stripes_bg2_map.bin"); +static const u8 sTradeStripesBG3Tilemap[] = INCBIN_U8("graphics/trade/stripes_bg3_map.bin"); +static const u8 sText_EmptyString[] = _(""); +static const u8 sText_UnusedTextFormat[] = _("{COLOR WHITE}{HIGHLIGHT TRANSPARENT}{SHADOW DARK_GREY}"); +const u8 gText_MaleSymbol4[] = _("♂"); +const u8 gText_FemaleSymbol4[] = _("♀"); +const u8 gText_GenderlessSymbol[] = _(""); +static const u8 sText_SpaceMove[] = _(" MOVE"); // unused +static const u8 sText_NewLine[] = _("\n"); +static const u8 sText_Slash[] = _("/"); +static const u8 sText_Lv[] = _("Lv. "); +static const u8 sText_ThreeDashes[] = _("---"); +static const u8 sText_FourQuestionMarks[] = _("????"); +static const u8 sText_832DAE4[] = _(""); +static const u8 sText_IsThisTradeOkay[] = _("Is this trade okay?"); +static const u8 sText_Cancel[] = _("CANCEL"); +static const u8 sText_ChooseAPkmn[] = _("Choose a POKéMON."); +static const u8 sText_Summary[] = _("SUMMARY"); +static const u8 sText_Trade[] = _("TRADE"); +static const u8 sText_CancelTrade[] = _("Cancel trade?"); +static const u8 sJPText_PressBButtonToQuit[] = _("Bボタン で もどります"); +static const u8 sText_Summary2[] = _("SUMMARY"); +static const u8 sText_Trade2[] = _("TRADE"); +static const u8 sText_CommunicationStandby[] = _("{COLOR DARK_GREY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GREY}Communication standby…\nPlease wait."); +static const u8 sText_TheTradeHasBeenCanceled[] = _("{COLOR DARK_GREY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GREY}The trade has\nbeen canceled."); +static const u8 sText_OnlyPkmnForBattle[] = _("That's your only\nPOKéMON for battle."); +static const u8 sText_WaitingForYourFriend[] = _("{COLOR DARK_GREY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GREY}Waiting for your friend\nto finish…"); +static const u8 sText_YourFriendWantsToTrade[] = _("Your friend wants\nto trade POKéMON."); + +static const struct OamData sTradeOamData_32x16 = +{ + .shape = SPRITE_SHAPE(32x16), + .size = SPRITE_SIZE(32x16), + .priority = 1 +}; + +static const struct OamData sTradeOamData_64x32 = +{ + .shape = SPRITE_SHAPE(64x32), + .size = SPRITE_SIZE(64x32), + .priority = 1 +}; + +static const union AnimCmd gSpriteAnim_832DC24[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_832DC2C[] = +{ + ANIMCMD_FRAME(32, 5), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_832DC34[] = +{ + gSpriteAnim_832DC24, + gSpriteAnim_832DC2C +}; + +static const struct SpriteSheet sTradeButtonsSpriteSheet = +{ + .data = gTradeButtons_Gfx, + .size = 0x800, + .tag = 300 +}; + +static const struct SpritePalette gUnknown_0832DC44 = +{ + .data = gUnknown_08DDB444, + .tag = 2345 +}; + +static const union AnimCmd gSpriteAnim_832DC4C[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_832DC54[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_832DC5C[] = +{ + ANIMCMD_FRAME(16, 5), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_832DC64[] = +{ + ANIMCMD_FRAME(24, 5), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_832DC6C[] = +{ + ANIMCMD_FRAME(32, 5), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_832DC74[] = +{ + ANIMCMD_FRAME(40, 5), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_832DC7C[] = +{ + gSpriteAnim_832DC4C, + gSpriteAnim_832DC54, + gSpriteAnim_832DC5C, + gSpriteAnim_832DC64, + gSpriteAnim_832DC6C, + gSpriteAnim_832DC74 +}; + +static const struct SpriteTemplate gSpriteTemplate_832DC94 = +{ + .tileTag = 300, + .paletteTag = 2345, + .oam = &sTradeOamData_64x32, + .anims = gSpriteAnimTable_832DC34, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const struct SpriteTemplate gSpriteTemplate_832DCAC = +{ + .tileTag = 200, + .paletteTag = 4925, + .oam = &sTradeOamData_32x16, + .anims = gSpriteAnimTable_832DC7C, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const u16 TradeScreenTextPalette[] = INCBIN_U16("graphics/trade/text.gbapal"); +static const struct SpritePalette gSpritePalette_TradeScreenText = +{ + .data = TradeScreenTextPalette, + .tag = 4925 +}; + +// This is used to determine the next mon to select when the D-Pad is +// pressed in a given direction. +// Note that the mons are laid out like this. +// 0-5 are the player's party and 6-11 are the trading partner's party. +// 12 is the cancel button. +// 0 1 6 7 +// 2 3 8 9 +// 4 5 10 11 +// 12 +// 1st array is the current positions +// 2nd array is directions of input +// 3rd array is the next positions to go to (unoccupied spaces are skipped over) +static const u8 sTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][PARTY_SIZE] = +{ + { + {4, 2, 12, 12, 0, 0}, // UP + {2, 4, 12, 12, 0, 0}, // DOWN + {7, 6, 1, 0, 0, 0}, // LEFT + {1, 6, 7, 0, 0, 0} // RIGHT + }, + { + {5, 3, 12, 12, 0, 0}, + {3, 5, 12, 12, 0, 0}, + {0, 7, 6, 1, 0, 0}, + {6, 7, 0, 1, 0, 0} + }, + { + {0, 0, 0, 0, 0, 0}, + {4, 0, 0, 0, 0, 0}, + {9, 8, 7, 6, 0, 0}, + {3, 1, 0, 0, 0, 0} + }, + { + {1, 1, 1, 1, 0, 0}, + {5, 1, 1, 1, 0, 0}, + {2, 9, 8, 7, 0, 0}, + {8, 9, 6, 6, 0, 0} + }, + { + {2, 2, 2, 2, 0, 0}, + {0, 0, 0, 0, 0, 0}, + {11, 10, 9, 8, 7, 6}, + {5, 3, 1, 0, 0, 0} + }, + { + {3, 3, 3, 3, 0, 0}, + {1, 1, 1, 1, 0, 0}, + {4, 4, 4, 4, 0, 0}, + {10, 8, 6, 0, 0, 0} + }, + { + {10, 8, 12, 0, 0, 0}, + {8, 10, 12, 0, 0, 0}, + {1, 0, 0, 0, 0, 0}, + {7, 0, 1, 0, 0, 0} + }, + { + {12, 0, 0, 0, 0, 0}, + {9, 12, 0, 0, 0, 0}, + {6, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0} + }, + { + {6, 0, 0, 0, 0, 0}, + {10, 6, 0, 0, 0, 0}, + {3, 2, 1, 0, 0, 0}, + {9, 7, 0, 0, 0, 0} + }, + { + {7, 0, 0, 0, 0, 0}, + {11, 12, 0, 0, 0, 0}, + {8, 0, 0, 0, 0, 0}, + {2, 1, 0, 0, 0, 0} + }, + { + {8, 0, 0, 0, 0, 0}, + {6, 0, 0, 0, 0, 0}, + {5, 4, 3, 2, 1, 0}, + {11, 9, 7, 0, 0, 0} + }, + { + {9, 0, 0, 0, 0, 0}, + {12, 0, 0, 0, 0, 0}, + {10, 0, 0, 0, 0, 0}, + {4, 2, 0, 0, 0, 0} + }, + { + {11, 9, 7, 6, 0, 0}, + {7, 6, 0, 0, 0, 0}, + {12, 0, 0, 0, 0, 0}, + {12, 0, 0, 0, 0, 0} + } +}; + +static const u8 sTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] = +{ + // Your party + {1, 5 }, + {8, 5 }, + {1, 10}, + {8, 10}, + {1, 15}, + {8, 15}, + + // Friend's party + {16, 5 }, + {23, 5 }, + {16, 10}, + {23, 10}, + {16, 15}, + {23, 15}, + + {23, 18} // CANCEL +}; + +static const u8 sTradeMonLevelCoords[][PARTY_SIZE][2] = +{ + { + // Your party + {5, 4}, + {12, 4}, + {5, 9}, + {12, 9}, + {5, 14}, + {12, 14}, + }, + { + // Friend's party + {20, 4}, + {27, 4}, + {20, 9}, + {27, 9}, + {20, 14}, + {27, 14} + } +}; + +static const u8 sTradeMonBoxCoords[][PARTY_SIZE][2] = +{ + { + // Your party + {1, 3}, + {8, 3}, + {1, 8}, + {8, 8}, + {1, 13}, + {8, 13}, + }, + { + // Friend's party + {16, 3}, + {23, 3}, + {16, 8}, + {23, 8}, + {16, 13}, + {23, 13} + } +}; + +static const u8 sUnref_0832DE6E[] = +{ + 0x00, 0x0e, + 0x0f, 0x1d, + 0x03, 0x05, + 0x03, 0x07, + 0x12, 0x05, + 0x12, 0x07, + 0x08, 0x07, + 0x16, 0x0c, + 0x08, 0x07, + 0x16, 0x0c, + 0x06, 0x07, + 0x18, 0x0c, + 0x06, 0x07, + 0x18, 0x0c, + 0x08, 0x07, + 0x16, 0x0c, + 0x07, 0x07, + 0x17, 0x0c +}; + +static const u8 *const sTradeActionTexts[] = +{ + [TRADE_TEXT_CANCEL] = sText_Cancel, + [TRADE_TEXT_CHOOSE_MON] = sText_ChooseAPkmn, + [TRADE_TEXT_SUMMARY] = sText_Summary, + [TRADE_TEXT_TRADE] = sText_Trade, + [TRADE_TEXT_CANCEL_TRADE] = sText_CancelTrade, + [TRADE_TEXT_JP_QUIT] = sJPText_PressBButtonToQuit +}; + +static const struct MenuAction sSelectTradeMonActions[] = +{ + {sText_Summary2, Task_DrawSelectionSummary}, + {sText_Trade2, Task_DrawSelectionTrade} +}; + +static const u8 *const sTradeMessages[] = +{ + [TRADE_MSG_STANDBY] = sText_CommunicationStandby, + [TRADE_MSG_CANCELED] = sText_TheTradeHasBeenCanceled, + [TRADE_MSG_ONLY_MON1] = sText_OnlyPkmnForBattle, + [TRADE_MSG_ONLY_MON2] = gText_OnlyPkmnForBattle, //identical text to above + [TRADE_MSG_WAITING_FOR_FRIEND] = sText_WaitingForYourFriend, + [TRADE_MSG_FRIEND_WANTS_TO_TRADE] = sText_YourFriendWantsToTrade, + [TRADE_MSG_MON_CANT_BE_TRADED] = gText_PkmnCantBeTradedNow, + [TRADE_MSG_EGG_CANT_BE_TRADED] = gText_EggCantBeTradedNow, + [TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED] = gText_OtherTrainersPkmnCantBeTraded +}; + +static const u8 sTradeTextColors[] = +{ + TEXT_COLOR_TRANSPARENT, //bg color + TEXT_COLOR_WHITE, //fg color + TEXT_COLOR_DARK_GREY //shadow color +}; + +static const struct BgTemplate sTradeMenuBgTemplates[] = +{ + { + .bg = 0, + .charBaseIndex = 2, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 5, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0 + }, + { + .bg = 2, + .charBaseIndex = 0, + .mapBaseIndex = 6, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, + { + .bg = 3, + .charBaseIndex = 0, + .mapBaseIndex = 7, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + }, +}; + +static const struct WindowTemplate sTradeMenuWindowTemplates[] = +{ + { + .bg = 0, + .tilemapLeft = 4, + .tilemapTop = 7, + .width = 22, + .height = 4, + .paletteNum = 15, + .baseBlock = 30 + }, + { + .bg = 0, + .tilemapLeft = 19, + .tilemapTop = 15, + .width = 10, + .height = 4, + .paletteNum = 15, + .baseBlock = 118 + }, + { + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 5, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 158 + }, + { + .bg = 0, + .tilemapLeft = 7, + .tilemapTop = 5, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 174 + }, + { + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 10, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 190 + }, + { + .bg = 0, + .tilemapLeft = 7, + .tilemapTop = 10, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 206 + }, + { + .bg = 0, + .tilemapLeft = 0, + .tilemapTop = 15, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 222 + }, + { + .bg = 0, + .tilemapLeft = 7, + .tilemapTop = 15, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 238 + }, + { + .bg = 0, + .tilemapLeft = 15, + .tilemapTop = 5, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 254 + }, + { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 5, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 270 + }, + { + .bg = 0, + .tilemapLeft = 15, + .tilemapTop = 10, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 286 + }, + { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 10, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 302 + }, + { + .bg = 0, + .tilemapLeft = 15, + .tilemapTop = 15, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 318 + }, + { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 15, + .width = 8, + .height = 2, + .paletteNum = 13, + .baseBlock = 334 + }, + { + .bg = 0, + .tilemapLeft = 2, + .tilemapTop = 5, + .width = 14, + .height = 2, + .paletteNum = 13, + .baseBlock = 350 + }, + { + .bg = 0, + .tilemapLeft = 3, + .tilemapTop = 8, + .width = 11, + .height = 8, + .paletteNum = 15, + .baseBlock = 378 + }, + { + .bg = 0, + .tilemapLeft = 17, + .tilemapTop = 5, + .width = 14, + .height = 2, + .paletteNum = 15, + .baseBlock = 466 + }, + { + .bg = 0, + .tilemapLeft = 18, + .tilemapTop = 8, + .width = 11, + .height = 8, + .paletteNum = 15, + .baseBlock = 494 + }, + DUMMY_WIN_TEMPLATE, +}; + +static const struct WindowTemplate sTradeYesNoWindowTemplate = +{ + .bg = 0, + .tilemapLeft = 23, + .tilemapTop = 13, + .width = 5, + .height = 4, + .paletteNum = 15, + .baseBlock = 582 +}; + +static const u8 sJPText_Shedinja[] = _("ヌケニン"); +static const u8 sTradeMenuPartyMonBoxDimensions[3][2] = +{ + [TRADE_PLAYER] = {4, 3}, + [TRADE_PARTNER] = {19, 3} +}; + +static const u16 sTradePal_PokeBall[] = INCBIN_U16("graphics/trade/pokeball.gbapal"); +static const u8 sTradeGfx_PokeBall[] = INCBIN_U8("graphics/trade/pokeball.4bpp"); +static const u8 sTradeGfx_PokeBallSymbol[] = INCBIN_U8("graphics/trade/pokeball_symbol.8bpp"); // unused? +static const u16 sTradeTilemap_Cable[] = INCBIN_U16("graphics/trade/cable_closeup_map.bin"); +static const u16 sTradeTilemap_PokeBallSymbol[] = INCBIN_U16("graphics/trade/pokeball_symbol_map.bin"); // unused? +static const u16 sUnref_083308C0[] = INCBIN_U16("graphics/trade/unknown_3308C0.gbapal"); +static const u16 sTradePal_Gba[] = INCBIN_U16("graphics/trade/gba.gbapal"); +static const u16 sTradePal_ShadowUnused[] = INCBIN_U16("graphics/trade/shadow.gbapal"); +static const u16 sTradePal_BlackUnused[] = INCBIN_U16("graphics/trade/black.gbapal"); +static const u16 sTradePal_Misc[] = INCBIN_U16("graphics/trade/misc.gbapal"); +static const u8 sTradeGfx_Glow1[] = INCBIN_U8("graphics/trade/glow1.4bpp"); +static const u8 sTradeGfx_Glow2[] = INCBIN_U8("graphics/trade/glow2.4bpp"); +static const u8 sTradeGfx_CableEnd[] = INCBIN_U8("graphics/trade/cable_end.4bpp"); +static const u8 sTradeGfx_GbaScreen[] = INCBIN_U8("graphics/trade/gba_screen.4bpp"); +const u16 gUnknown_08331F60[] = INCBIN_U16("graphics/trade/shadow_map.bin"); +static const u8 sTradeAffine_Gba[] = INCBIN_U8("graphics/trade/gba_affine.8bpp"); +static const u8 sFiller_08335760[64] = {}; +static const u8 sTradeAffineMap_GbaCable[] = INCBIN_U8("graphics/trade/gba_affine_map_cable.bin"); +static const u8 sTradeAffineMap_GbaWireless[] = INCBIN_U8("graphics/trade/gba_affine_map_wireless.bin"); +static const u16 sTradeTilemap_GbaWireless[] = INCBIN_U16("graphics/trade/gba_map_wireless.bin"); +static const u16 sTradeTilemap_GbaCable[] = INCBIN_U16("graphics/trade/gba_map_cable.bin"); +static const u32 gUnknown_083379A0[] = INCBIN_U32("graphics/trade/unknown_3379A0.bin.lz"); //some wireless tilemap +static const u16 sTradePal_WirelessSignalSend[] = INCBIN_U16("graphics/trade/wireless_signal_send.gbapal"); +static const u16 sTradePal_WirelessSignalReceive[] = INCBIN_U16("graphics/trade/wireless_signal_receive.gbapal"); +static const u16 sTradePal_Black[] = INCBIN_U16("graphics/trade/black.gbapal"); +static const u32 sTradeGfx_WirelessSignal[] = INCBIN_U32("graphics/trade/wireless_signal.4bpp.lz"); +static const u32 sTradeTilemap_WirelessSignal[] = INCBIN_U32("graphics/trade/wireless_signal.bin.lz"); + +static const struct OamData sTradeOamData_16x16 = +{ + .affineMode = 1, + .shape = SPRITE_SHAPE(16x16), + .size = SPRITE_SIZE(16x16) +}; + +static const union AnimCmd gSpriteAnim_8338C4C[] = +{ + ANIMCMD_FRAME( 0, 3), + ANIMCMD_FRAME( 4, 3), + ANIMCMD_FRAME( 8, 3), + ANIMCMD_FRAME(12, 3), + ANIMCMD_FRAME(16, 3), + ANIMCMD_FRAME(20, 3), + ANIMCMD_FRAME(24, 3), + ANIMCMD_FRAME(28, 3), + ANIMCMD_FRAME(32, 3), + ANIMCMD_FRAME(36, 3), + ANIMCMD_FRAME(40, 3), + ANIMCMD_FRAME(44, 3), + ANIMCMD_LOOP(1), + ANIMCMD_FRAME( 0, 3), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_8338C88[] = +{ + ANIMCMD_FRAME( 0, 3), + ANIMCMD_FRAME( 4, 3), + ANIMCMD_FRAME( 8, 3), + ANIMCMD_FRAME(12, 3), + ANIMCMD_FRAME(16, 3), + ANIMCMD_FRAME(20, 3), + ANIMCMD_FRAME(24, 3), + ANIMCMD_FRAME(28, 3), + ANIMCMD_FRAME(32, 3), + ANIMCMD_FRAME(36, 3), + ANIMCMD_FRAME(40, 3), + ANIMCMD_FRAME(44, 3), + ANIMCMD_LOOP(2), + ANIMCMD_FRAME( 0, 3), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_8338C88[] = +{ + gSpriteAnim_8338C4C, + gSpriteAnim_8338C88 +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8338CCC[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 0, 1), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8338CDC[] = +{ + AFFINEANIMCMD_FRAME(-8, 0, 0, 20), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8338CEC[] = +{ + AFFINEANIMCMD_FRAME(0x60, 0x100, 0, 0), + AFFINEANIMCMD_FRAME( 0, 0, 0, 5), + AFFINEANIMCMD_FRAME( 8, 0, 0, 20), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D0C[] = +{ + gSpriteAffineAnim_8338CCC, + gSpriteAffineAnim_8338CDC, + gSpriteAffineAnim_8338CEC +}; + +static const struct SpriteSheet sPokeBallSpriteSheet = +{ + .data = sTradeGfx_PokeBall, + .size = 0x600, + .tag = 5557 +}; + +static const struct SpritePalette sPokeBallSpritePalette = +{ + .data = sTradePal_PokeBall, + .tag = 5558 +}; + +static const struct SpriteTemplate gSpriteTemplate_8338D28 = +{ + .tileTag = 5557, + .paletteTag = 5558, + .oam = &sTradeOamData_16x16, + .anims = gSpriteAnimTable_8338C88, + .images = NULL, + .affineAnims = gSpriteAffineAnimTable_8338D0C, + .callback = sub_807E55C +}; + +static const struct OamData sTradeOamData_32x32 = +{ + .affineMode = 1, + .objMode = 1, + .shape = SPRITE_SHAPE(32x32), + .size = SPRITE_SIZE(32x32), + .priority = 1 +}; + +static const union AnimCmd gSpriteAnim_8338D48[] = +{ + ANIMCMD_FRAME(0, 5, .hFlip = TRUE, .vFlip = TRUE), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_8338D50[] = +{ + gSpriteAnim_8338D48 +}; + +static const union AffineAnimCmd gSpriteAffineAnim_8338D54[] = +{ + AFFINEANIMCMD_FRAME(-10, -10, 0, 5), + AFFINEANIMCMD_FRAME(10, 10, 0, 5), + AFFINEANIMCMD_JUMP(0) +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D6C[] = +{ + gSpriteAffineAnim_8338D54 +}; + +static const struct SpriteSheet sGlow1SpriteSheet = +{ + .data = sTradeGfx_Glow1, + .size = 0x200, + .tag = 5550 +}; + +static const struct SpritePalette sMiscTradeSpritePalette = +{ + .data = sTradePal_Misc, + .tag = 5551 +}; + +static const struct SpritePalette sGbaSpritePalette = +{ + .data = sTradePal_Gba, + .tag = 5555 +}; + +static const struct SpriteTemplate gUnknown_08338D88 = +{ + .tileTag = 5550, + .paletteTag = 5551, + .oam = &sTradeOamData_32x32, + .anims = gSpriteAnimTable_8338D50, + .images = NULL, + .affineAnims = gSpriteAffineAnimTable_8338D6C, + .callback = sub_807AA28 +}; + +static const struct OamData sTradeOamData_16x32 = +{ + .shape = SPRITE_SHAPE(16x32), + .size = SPRITE_SIZE(16x32), + .priority = 1 +}; + +static const union AnimCmd gSpriteAnim_8338DA8[] = +{ + ANIMCMD_FRAME(0, 5, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_8338DB0[] = +{ + ANIMCMD_FRAME(8, 5, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_8338DB8[] = +{ + gSpriteAnim_8338DA8, + gSpriteAnim_8338DB0 +}; + +static const struct SpriteSheet sGlow2SpriteSheet = +{ + .data = sTradeGfx_Glow2, + .size = 0x300, + .tag = 5552 +}; + +static const struct SpriteTemplate sGlowBallSpriteTemplate = +{ + .tileTag = 5552, + .paletteTag = 5551, + .oam = &sTradeOamData_16x32, + .anims = gSpriteAnimTable_8338DB8, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_807AA7C +}; + +static const struct OamData sTradeOamData_16x32_2 = +{ + .shape = SPRITE_SHAPE(16x32), + .size = SPRITE_SIZE(16x32), + .priority = 1 +}; + +static const union AnimCmd gSpriteAnim_8338DE8[] = +{ + ANIMCMD_FRAME(0, 10), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_8338DF0[] = +{ + gSpriteAnim_8338DE8 +}; + +static const struct SpriteSheet sCableEndSpriteSheet = +{ + .data = sTradeGfx_CableEnd, + .size = 0x100, + .tag = 5554 +}; + +static const struct SpriteTemplate gSpriteTemplate_8338DFC = +{ + .tileTag = 5554, + .paletteTag = 5555, + .oam = &sTradeOamData_16x32_2, + .anims = gSpriteAnimTable_8338DF0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_807AABC +}; + +static const struct OamData sTradeOamData_64x32_2 = +{ + .shape = SPRITE_SHAPE(64x32), + .size = SPRITE_SIZE(64x32), + .priority = 1 +}; + +static const union AnimCmd gSpriteAnim_8338E1C[] = +{ + ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(96, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_LOOP(8), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_8338E40[] = +{ + ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(96, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), + ANIMCMD_LOOP(2), + ANIMCMD_END +}; + +static const union AnimCmd *const gSpriteAnimTable_8338E64[] = +{ + gSpriteAnim_8338E1C +}; + +static const union AnimCmd *const gSpriteAnimTable_8338E68[] = +{ + gSpriteAnim_8338E40 +}; + +static const struct SpriteSheet sGbaScreenSpriteSheet = +{ + .data = sTradeGfx_GbaScreen, + .size = 0x1000, + .tag = 5556 +}; + +static const struct SpriteTemplate gSpriteTemplate_8338E74 = +{ + .tileTag = 5556, + .paletteTag = 5555, + .oam = &sTradeOamData_64x32_2, + .anims = gSpriteAnimTable_8338E64, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_807AB04 +}; + +static const struct SpriteTemplate gSpriteTemplate_8338E8C = +{ + .tileTag = 5556, + .paletteTag = 5555, + .oam = &sTradeOamData_64x32_2, + .anims = gSpriteAnimTable_8338E68, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_807AB04 +}; + +static const u16 gUnknown_08338EA4[] = INCBIN_U16("graphics/trade/unknown_338EA4.gbapal"); + +static const union AffineAnimCmd gSpriteAffineAnim_8338EBC[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_JUMP(0) +}; + +static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338ECC[] = +{ + gSpriteAffineAnim_8338EBC +}; + +static const struct InGameTrade sIngameTrades[] = +{ + [INGAME_TRADE_SEEDOT] = + { + .nickname = _("DOTS"), + .species = SPECIES_SEEDOT, + .ivs = {5, 4, 5, 4, 4, 4}, + .abilityNum = 1, + .otId = 38726, + .conditions = {30, 5, 5, 5, 5}, + .personality = 0x84, + .heldItem = ITEM_CHESTO_BERRY, + .mailNum = -1, + .otName = _("KOBE"), + .otGender = MALE, + .sheen = 10, + .requestedSpecies = SPECIES_RALTS + }, + [INGAME_TRADE_PLUSLE] = + { + .nickname = _("PLUSES"), + .species = SPECIES_PLUSLE, + .ivs = {4, 4, 4, 5, 5, 4}, + .abilityNum = 0, + .otId = 73996, + .conditions = {5, 5, 30, 5, 5}, + .personality = 0x6F, + .heldItem = ITEM_WOOD_MAIL, + .mailNum = 0, + .otName = _("ROMAN"), + .otGender = MALE, + .sheen = 10, + .requestedSpecies = SPECIES_VOLBEAT + }, + [INGAME_TRADE_HORSEA] = + { + .nickname = _("SEASOR"), + .species = SPECIES_HORSEA, + .ivs = {5, 4, 4, 4, 5, 4}, + .abilityNum = 0, + .otId = 46285, + .conditions = {5, 5, 5, 5, 30}, + .personality = 0x7F, + .heldItem = ITEM_WAVE_MAIL, + .mailNum = 1, + .otName = _("SKYLAR"), + .otGender = MALE, + .sheen = 10, + .requestedSpecies = SPECIES_BAGON + }, + [INGAME_TRADE_MEOWTH] = + { + .nickname = _("MEOWOW"), + .species = SPECIES_MEOWTH, + .ivs = {4, 5, 4, 5, 4, 4}, + .abilityNum = 0, + .otId = 91481, + .conditions = {5, 5, 5, 30, 5}, + .personality = 0x8B, + .heldItem = ITEM_RETRO_MAIL, + .mailNum = 2, + .otName = _("ISIS"), + .otGender = FEMALE, + .sheen = 10, + .requestedSpecies = SPECIES_SKITTY + } +}; + +static const u16 sIngameTradeMail[][MAIL_WORDS_COUNT + 1] = +{ + { + EC_WORD_BE, + EC_WORD_NICE, + EC_WORD_TO, + EC_POKEMON(PLUSLE), + EC_WORD_EXCL, + EC_POKEMON(VOLBEAT), + EC_WORD_WILL, + EC_WORD_BE, + EC_WORD_FANTASTIC + }, { + EC_WORD_I, + EC_WORD_WILL, + EC_WORD_MAKE, + EC_POKEMON(BAGON), + EC_WORD_TOUGH, + EC_WORD_PLEASE, + EC_WORD_TRAIN, + EC_POKEMON(HORSEA), + EC_WORD_WELL + }, { + EC_WORD_THANK_YOU, + EC_WORD_FOR, + EC_POKEMON(SKITTY), + EC_POKEMON2(MEOWTH), + EC_WORD_CRIES, + EC_WORD_IN, + EC_WORD_A, + EC_WORD_CUTE, + EC_WORD_WAY + } +}; + +static const struct WindowTemplate sTradeSequenceWindowTemplates[] = +{ + { + .bg = 0, + .tilemapLeft = 2, + .tilemapTop = 15, + .width = 26, + .height = 4, + .paletteNum = 0, + .baseBlock = 64 + }, + DUMMY_WIN_TEMPLATE +}; + +const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate = +{ + .bg = 0, + .tilemapLeft = 21, + .tilemapTop = 9, + .width = 5, + .height = 4, + .paletteNum = 15, + .baseBlock = 188 +}; + +static const struct BgTemplate sTradeSequenceBgTemplates[] = +{ + { + .bg = 0, + .charBaseIndex = 3, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 5, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, + { + .bg = 2, + .charBaseIndex = 1, + .mapBaseIndex = 18, + .screenSize = 1, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, + { + .bg = 3, + .charBaseIndex = 0, + .mapBaseIndex = 6, + .screenSize = 0, + .paletteMode = 0, + .priority = 3, + .baseTile = 0 + }, +}; + +static const s8 sTradeBallVerticalVelocityTable[] = +{ + 0, 0, 1, 0, + 1, 0, 1, 1, + 1, 1, 2, 2, + 2, 2, 3, 3, + 3, 3, 4, 4, + 4, 4, -4, -4, + -4, -3, -3, -3, + -3, -2, -2, -2, + -2, -1, -1, -1, + -1, 0, -1, 0, + -1, 0, 0, 0, + 0, 0, 1, 0, + 1, 0, 1, 1, + 1, 1, 2, 2, + 2, 2, 3, 3, + 3, 3, 4, 4, + 4, 4, -4, -3, + -3, -2, -2, -1, + -1, -1, 0, -1, + 0, 0, 0, 0, + 0, 0, 1, 0, + 1, 1, 1, 2, + 2, 3, 3, 4, + -4, -3, -2, -1, + -1, -1, 0, 0, + 0, 0, 1, 0, + 1, 1, 2, 3 +}; + +static const u8 sWirelessSignalTiming[][2] = +{ + {0, 1}, + {1, 1}, + {2, 1}, + {3, 1}, + {4, 1}, + {5, 2}, + {6, 2}, + {7, 2}, + {8, 2}, + {9, 2}, + {10, 3}, + {11, 3}, + {12, 3}, + {13, 4}, + {14, 5}, + {15, 2}, + {0, 1}, + {1, 1}, + {2, 1}, + {3, 1}, + {4, 1}, + {5, 2}, + {6, 2}, + {7, 2}, + {8, 2}, + {9, 2}, + {10, 3}, + {11, 3}, + {12, 3}, + {13, 4}, + {14, 5}, + {16, 1}, + {16, 255}, + {0, 0} +}; diff --git a/src/data/union_room.h b/src/data/union_room.h new file mode 100644 index 000000000..abe91b010 --- /dev/null +++ b/src/data/union_room.h @@ -0,0 +1,1044 @@ +// const rom data + +ALIGNED(4) const u8 gText_EmptyString[] = _(""); +ALIGNED(4) const u8 gText_Colon[] = _(":"); +ALIGNED(4) const u8 gText_UnkCtrlCodeF907[] = _("{ID}"); +ALIGNED(4) const u8 gText_PleaseStartOver[] = _("Please start over from the beginning."); +ALIGNED(4) const u8 gText_WirelessSearchCanceled[] = _("The WIRELESS COMMUNICATION\nSYSTEM search has been canceled."); +ALIGNED(4) const u8 unref_text_union_room_0[] = _("Awaiting communication\nfrom another player."); +ALIGNED(4) const u8 gText_AwaitingCommunication[] = _("{STR_VAR_1}! Awaiting\ncommunication from another player."); +ALIGNED(4) const u8 gText_AwaitingLink[] = _("{STR_VAR_1}! Awaiting link!\nPress START when everyone's ready."); +ALIGNED(4) const u8 gJPText_SingleBattle[] = _("シングルバトルを かいさいする"); +ALIGNED(4) const u8 gJPText_DoubleBattle[] = _("ダブルバトルを かいさいする"); +ALIGNED(4) const u8 gJPText_MultiBattle[] = _("マルチバトルを かいさいする"); +ALIGNED(4) const u8 gJPText_TradePokemon[] = _("ポケモンこうかんを かいさいする"); +ALIGNED(4) const u8 gJPText_Chat[] = _("チャットを かいさいする"); +ALIGNED(4) const u8 gJPText_DistWonderCard[] = _("ふしぎなカードをくばる"); +ALIGNED(4) const u8 gJPText_DistWonderNews[] = _("ふしぎなニュースをくばる"); +ALIGNED(4) const u8 unref_text_union_room_1[] = _("ふしぎなできごとを かいさいする"); +ALIGNED(4) const u8 gJPText_HoldPokemonJump[] = _("なわとびを かいさいする"); +ALIGNED(4) const u8 gJPText_HoldBerryCrush[] = _("きのみマッシャーを かいさいする"); +ALIGNED(4) const u8 gJPText_HoldBerryPicking[] = _("きのみどりを かいさいする"); +ALIGNED(4) const u8 gJPText_HoldSpinTrade[] = _("ぐるぐるこうかんを かいさいする"); +ALIGNED(4) const u8 gJPText_HoldSpinShop[] = _("ぐるぐるショップを かいさいする"); + +const u8 *const unref_text_ptrs_union_room_0[] = { + gJPText_SingleBattle, + gJPText_DoubleBattle, + gJPText_MultiBattle, + gJPText_TradePokemon, + gJPText_Chat, + gJPText_DistWonderCard, + gJPText_DistWonderNews, + gJPText_DistWonderCard, + gJPText_HoldPokemonJump, + gJPText_HoldBerryCrush, + gJPText_HoldBerryPicking, + gJPText_HoldBerryPicking, + gJPText_HoldSpinTrade, + gJPText_HoldSpinShop +}; + +const u8 gText_1PlayerNeeded[] = _("1 player\nneeded."); +const u8 gText_2PlayersNeeded[] = _("2 players\nneeded."); +const u8 gText_3PlayersNeeded[] = _("3 players\nneeded."); +const u8 gText_4PlayersNeeded[] = _("4 players\nneeded."); +const u8 gText_2PlayerMode[] = _("2-PLAYER\nMODE"); +const u8 gText_3PlayerMode[] = _("3-PLAYER\nMODE"); +const u8 gText_4PlayerMode[] = _("4-PLAYER\nMODE"); +const u8 gText_5PlayerMode[] = _("5-PLAYER\nMODE"); + +const u8 *const gUnknown_082EDB60[][5] = { + { + gText_1PlayerNeeded, + gText_2PlayerMode + }, { + gText_3PlayersNeeded, + gText_2PlayersNeeded, + gText_1PlayerNeeded, + gText_4PlayerMode + }, { + gText_1PlayerNeeded, + gText_2PlayerMode, + gText_3PlayerMode, + gText_4PlayerMode, + gText_5PlayerMode + }, { + gText_2PlayersNeeded, + gText_1PlayerNeeded, + gText_3PlayerMode, + gText_4PlayerMode, + gText_5PlayerMode + }, { + gText_1PlayerNeeded, + gText_2PlayerMode, + gText_3PlayerMode, + gText_4PlayerMode + } +}; + +ALIGNED(4) const u8 gUnknown_082EDBC4[] = _("{B_BUTTON}CANCEL"); +ALIGNED(4) const u8 unref_text_union_room_2[] = _("ため\nさんかしゃ ぼしゅうちゅう です!"); +ALIGNED(4) const u8 gUnknown_082EDBE8[] = _("{STR_VAR_2} contacted you for\n{STR_VAR_1}. Accept?"); +ALIGNED(4) const u8 gUnknown_082EDC0C[] = _("{STR_VAR_2} contacted you.\nWill you share {STR_VAR_1}?"); +ALIGNED(4) const u8 gUnknown_082EDC34[] = _("{STR_VAR_2} contacted you.\nAdd to the members?"); +ALIGNED(4) const u8 gUnknown_082EDC5C[] = _("{STR_VAR_1}!\nAre these members OK?"); +ALIGNED(4) const u8 gUnknown_082EDC78[] = _("Cancel {STR_VAR_1} MODE\nwith these members?"); +ALIGNED(4) const u8 gUnknown_082EDC9C[] = _("An “OK” was sent\nto {STR_VAR_1}."); +ALIGNED(4) const u8 gUnknown_082EDCB4[] = _("The other TRAINER doesn't appear\nto be available now…\p"); +ALIGNED(4) const u8 gUnknown_082EDCEC[] = _("You can't transmit with a TRAINER\nwho is too far away.\p"); +ALIGNED(4) const u8 gUnknown_082EDD24[] = _("The other TRAINER(S) is/are not\nready yet.\p"); + +const u8 *const gUnknown_082EDD50[] = { + gUnknown_082EDCEC, + gUnknown_082EDD24 +}; + +ALIGNED(4) const u8 gUnknown_082EDD58[] = _("The {STR_VAR_1} MODE with\nthese members will be canceled.{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EDD8C[] = _("There is a member who can no\nlonger remain available.\p"); + +const u8 *const gUnknown_082EDDC4[] = { + gUnknown_082EDCB4, + gUnknown_082EDD8C +}; + +ALIGNED(4) const u8 gUnknown_082EDDCC[] = _("The other TRAINER appears\nunavailable…\p"); +ALIGNED(4) const u8 gUnknown_082EDDF4[] = _("{STR_VAR_1} sent back an “OK”!"); +ALIGNED(4) const u8 gUnknown_082EDE0C[] = _("{STR_VAR_1} OK'd your registration as\na member."); +ALIGNED(4) const u8 gUnknown_082EDE34[] = _("{STR_VAR_1} replied, “No…”\p"); +ALIGNED(4) const u8 gUnknown_082EDE48[] = _("{STR_VAR_1}!\nAwaiting other members!"); +ALIGNED(4) const u8 gUnknown_082EDE64[] = _("Quit being a member?"); +ALIGNED(4) const u8 gUnknown_082EDE7C[] = _("You stopped being a member.\p"); + +const u8 *const gUnknown_082EDE9C[] = { + NULL, + gUnknown_082EDD8C, + gUnknown_082EDDCC, + NULL, + NULL, + NULL, + gUnknown_082EDE34, + NULL, + NULL, + gUnknown_082EDE7C +}; + +ALIGNED(4) const u8 gUnknown_082EDEC4[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been established."); +ALIGNED(4) const u8 gUnknown_082EDF04[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been dropped…"); +ALIGNED(4) const u8 gUnknown_082EDF40[] = _("The link with your friend has been\ndropped…"); +ALIGNED(4) const u8 gUnknown_082EDF6C[] = _("{STR_VAR_1} replied, “No…”"); + +const u8 *const gUnknown_082EDF80[] = { + NULL, + gUnknown_082EDF40, + gUnknown_082EDF40, + NULL, + NULL, + NULL, + gUnknown_082EDF6C, + NULL, + NULL, + NULL +}; + +ALIGNED(4) const u8 gUnknown_082EDFA8[] = _("Do you want the {STR_VAR_2}\nMODE?"); +ALIGNED(4) const u8 gUnknown_082EDFC4[] = _("Do you want the {STR_VAR_2}\nMODE?"); + +const u8 *const unref_text_ptrs_union_room_1[] = { + gUnknown_082EDFA8, + gUnknown_082EDFC4 +}; + +ALIGNED(4) const u8 unref_text_union_room_3[] = _("Communicating…\nPlease wait."); +ALIGNED(4) const u8 gUnknown_082EE004[] = _("Awaiting {STR_VAR_1}'s response about\nthe trade…"); +ALIGNED(4) const u8 gUnknown_082EE02C[] = _("Communicating{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); +ALIGNED(4) const u8 gUnknown_082EE098[] = _("Communicating with {STR_VAR_1}{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); +ALIGNED(4) const u8 gUnknown_082EE104[] = _("Please wait a while{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); + +const u8 *const gUnknown_082EE17C[] = { + gUnknown_082EE02C, + gUnknown_082EE098, + gUnknown_082EE104 +}; + +ALIGNED(4) const u8 gUnknown_082EE188[] = _("Hiya! Is there something that you\nwanted to do?"); +ALIGNED(4) const u8 gUnknown_082EE1B8[] = _("Hello!\nWould you like to do something?"); +ALIGNED(4) const u8 gUnknown_082EE1E0[] = _("{STR_VAR_1}: Hiya, we meet again!\nWhat are you up for this time?"); +ALIGNED(4) const u8 gUnknown_082EE218[] = _("{STR_VAR_1}: Oh! {PLAYER}, hello!\nWould you like to do something?"); + +const u8 *const gUnknown_082EE24C[][2] = { + { + gUnknown_082EE188, + gUnknown_082EE1B8 + }, { + gUnknown_082EE1E0, + gUnknown_082EE218 + } +}; + +ALIGNED(4) const u8 gUnknown_082EE25C[] = _("Want to do something?"); +ALIGNED(4) const u8 gUnknown_082EE274[] = _("Would you like to do something?"); +ALIGNED(4) const u8 gUnknown_082EE294[] = _("{STR_VAR_1}: What would you like to\ndo now?"); +ALIGNED(4) const u8 unref_text_union_room_4[] = _("{STR_VAR_1}: Want to do anything else?"); + +const u8 *const unref_text_ptrs_union_room_2[][2] = { + { + gUnknown_082EE25C, + gUnknown_082EE274 + }, { + gUnknown_082EE294, + gUnknown_082EE294 + } +}; + +ALIGNED(4) const u8 sText_SomebodyHasContactedYou[] = _("Somebody has contacted you.{PAUSE 60}"); +ALIGNED(4) const u8 sText_XHasContactedYou[] = _("{STR_VAR_1} has contacted you.{PAUSE 60}"); + +static const u8 *const gUnknown_082EE324[] = { + sText_SomebodyHasContactedYou, + sText_XHasContactedYou +}; + +ALIGNED(4) const u8 sUnionRoom_AwaitingResponseFromTrainer[] = _("Awaiting a response from\nthe other TRAINER…"); +ALIGNED(4) const u8 sUnionRoom_AwaitingResponseFromX[] = _("Awaiting a response from\n{STR_VAR_1}…"); + +static const u8 *const sUnionRoomTexts_AwaitingResponse[] = { + sUnionRoom_AwaitingResponseFromTrainer, + sUnionRoom_AwaitingResponseFromX +}; + +ALIGNED(4) const u8 sText_ShowTrainerCard[] = _("The other TRAINER showed\nyou their TRAINER CARD.\pWould you like to show your\nTRAINER CARD?"); +ALIGNED(4) const u8 sText_BattleChallenge[] = _("The other TRAINER challenges you\nto battle.\pWill you accept the battle\nchallenge?"); +ALIGNED(4) const u8 sText_ChatInvitation[] = _("The other TRAINER invites you\nto chat.\pWill you accept the chat\ninvitation?"); +ALIGNED(4) const u8 sText_OfferToTradeMon[] = _("There is an offer to trade your\nregistered Lv. {SPECIAL_F7 0x00} {SPECIAL_F7 0x01}\pin exchange for a\nLv. {SPECIAL_F7 0x02} {SPECIAL_F7 0x03}.\pWill you accept this trade\noffer?"); +ALIGNED(4) const u8 sText_OfferToTradeEgg[] = _("There is an offer to trade your\nregistered EGG.\lWill you accept this trade offer?"); +ALIGNED(4) const u8 sText_ChatDropped[] = _("The chat has been dropped.\p"); +ALIGNED(4) const u8 sText_OfferDeclined1[] = _("You declined the offer.\p"); +ALIGNED(4) const u8 sText_OfferDeclined2[] = _("You declined the offer.\p"); +ALIGNED(4) const u8 sText_ChatEnded[] = _("The chat was ended.\p"); + +// Unused +static const u8 *const sUnionRoomTexts_Invitation[] = { + sText_ShowTrainerCard, + sText_BattleChallenge, + sText_ChatInvitation, + sText_OfferToTradeMon +}; + +ALIGNED(4) const u8 sText_JoinChatMale[] = _("Oh, hey! We're in a chat right now.\nWant to join us?"); +ALIGNED(4) const u8 sText_PlayerJoinChatMale[] = _("{STR_VAR_1}: Hey, {PLAYER}!\nWe're having a chat right now.\lWant to join us?"); +ALIGNED(4) const u8 sText_JoinChatFemale[] = _("Oh, hi! We're having a chat now.\nWould you like to join us?"); +ALIGNED(4) const u8 sText_PlayerJoinChatFemale[] = _("{STR_VAR_1}: Oh, hi, {PLAYER}!\nWe're having a chat now.\lWould you like to join us?"); + +const u8 *const sUnionRoomTexts_JoinChat[][GENDER_COUNT] = { + { + sText_JoinChatMale, + sText_JoinChatFemale + }, { + sText_PlayerJoinChatMale, + sText_PlayerJoinChatFemale + } +}; + +ALIGNED(4) const u8 sText_TrainerAppearsBusy[] = _("……\nThe TRAINER appears to be busy…\p"); +ALIGNED(4) const u8 gUnknown_082EE6EC[] = _("A battle, huh?\nAll right, just give me some time."); +ALIGNED(4) const u8 gUnknown_082EE720[] = _("You want to chat, huh?\nSure, just wait a little."); +ALIGNED(4) const u8 gUnknown_082EE754[] = _("Sure thing! As my “Greetings,”\nhere's my TRAINER CARD."); +ALIGNED(4) const u8 gUnknown_082EE78C[] = _("A battle? Of course, but I need\ntime to get ready."); +ALIGNED(4) const u8 gUnknown_082EE7C0[] = _("Did you want to chat?\nOkay, but please wait a moment."); +ALIGNED(4) const u8 gUnknown_082EE7F8[] = _("As my introduction, I'll show you\nmy TRAINER CARD."); + +const u8 *const gUnknown_082EE82C[][4] = { + { + gUnknown_082EE6EC, + gUnknown_082EE720, + NULL, + gUnknown_082EE754 + }, { + gUnknown_082EE78C, + gUnknown_082EE7C0, + NULL, + gUnknown_082EE7F8 + } +}; + +ALIGNED(4) const u8 unref_text_union_room_5[] = _("You want to chat, huh?\nSure, just wait a little."); +ALIGNED(4) const u8 gUnknown_082EE880[] = _("Thanks for waiting!\nLet's get our battle started!{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EE8B8[] = _("All right!\nLet's chat!{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EE8D4[] = _("Sorry I made you wait!\nLet's get started!{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EE904[] = _("Sorry I made you wait!\nLet's chat.{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EE92C[] = _("The trade will be started.{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EE94C[] = _("The battle will be started.{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EE96C[] = _("Entering the chat…{PAUSE 60}"); + +const u8 *const gUnknown_082EE984[][2][3] = { + { + { + gUnknown_082EE94C, + gUnknown_082EE96C, + gUnknown_082EE92C + }, { + gUnknown_082EE94C, + gUnknown_082EE96C, + gUnknown_082EE92C + } + }, { + { + gUnknown_082EE880, + gUnknown_082EE8B8, + gUnknown_082EE92C + }, { + gUnknown_082EE8D4, + gUnknown_082EE904, + gUnknown_082EE92C + } + } +}; + +ALIGNED(4) const u8 gUnknown_082EE9B4[] = _("Sorry! My POKéMON don't seem to\nbe feeling too well right now.\lLet me battle you another time.\p"); +ALIGNED(4) const u8 gUnknown_082EEA14[] = _("I'm terribly sorry, but my POKéMON\naren't feeling well…\pLet's battle another time.\p"); + +const u8 *const gUnknown_082EEA68[] = { + gUnknown_082EE9B4, + gUnknown_082EEA14 +}; + +ALIGNED(4) const u8 gUnknown_082EEA70[] = _("Huh? My TRAINER CARD…\nWhere'd it go now?\lSorry! I'll show you another time!\p"); +ALIGNED(4) const u8 gUnknown_082EEAC0[] = _("Oh? Now where did I put my\nTRAINER CARD?…\lSorry! I'll show you later!\p"); + +const u8 *const gUnknown_082EEB08[] = { + gUnknown_082EEA70, + gUnknown_082EEAC0 +}; + +ALIGNED(4) const u8 gUnknown_082EEB10[] = _("If you want to do something with\nme, just give me a shout!\p"); +ALIGNED(4) const u8 gUnknown_082EEB4C[] = _("If you want to do something with\nme, don't be shy.\p"); + +const u8 *const gUnknown_082EEB80[] = { + gUnknown_082EEB10, + gUnknown_082EEB4C +}; + +ALIGNED(4) const u8 sText_TrainerBattleBusy[] = _("Whoops! Sorry, but I have to do\nsomething else.\lAnother time, okay?\p"); +ALIGNED(4) const u8 sText_NeedTwoMonsOfLevel30OrLower1[] = _("If you want to battle, you need\ntwo POKéMON that are below\lLv. 30.\p"); +ALIGNED(4) const u8 sText_NeedTwoMonsOfLevel30OrLower2[] = _("For a battle, you need two\nPOKéMON that are below Lv. 30.\p"); +ALIGNED(4) const u8 sText_DeclineBattleMale[] = _("Oh, all right.\nCome see me anytime, okay?\p"); +ALIGNED(4) const u8 sText_DeclineBattleFemale[] = _("Oh…\nPlease come by anytime.\p"); + +const u8 *const sUnionRoomTexts_DeclineBattle[GENDER_COUNT] = { + [MALE] = sText_DeclineBattleMale, + [FEMALE] = sText_DeclineBattleFemale +}; + +ALIGNED(4) const u8 gUnknown_082EECA4[] = _("Oh, sorry!\nI just can't right this instant.\lLet's chat another time.\p"); +ALIGNED(4) const u8 gUnknown_082EECEC[] = _("Oh, I'm sorry.\nI have too much to do right now.\lLet's chat some other time.\p"); + +const u8 *const gUnknown_082EED3C[] = { + gUnknown_082EECA4, + gUnknown_082EECEC +}; + +ALIGNED(4) const u8 gUnknown_082EED44[] = _("Whoa!\nI can tell you're pretty tough!\p"); +ALIGNED(4) const u8 gUnknown_082EED6C[] = _("You used that move?\nThat's good strategy!\p"); +ALIGNED(4) const u8 gUnknown_082EED98[] = _("Way to go!\nThat was an eye-opener!\p"); +ALIGNED(4) const u8 gUnknown_082EEDBC[] = _("Oh! How could you use that\nPOKéMON in that situation?\p"); +ALIGNED(4) const u8 gUnknown_082EEDF4[] = _("That POKéMON…\nIt's been raised really well!\p"); +ALIGNED(4) const u8 gUnknown_082EEE24[] = _("That's it!\nThis is the right move now!\p"); +ALIGNED(4) const u8 gUnknown_082EEE4C[] = _("That's awesome!\nYou can battle that way?\p"); +ALIGNED(4) const u8 gUnknown_082EEE78[] = _("You have exquisite timing for\nswitching POKéMON!\p"); + +const u8 *const gUnknown_082EEEAC[GENDER_COUNT][4] = { + [MALE] = + { + gUnknown_082EED44, + gUnknown_082EED6C, + gUnknown_082EED98, + gUnknown_082EEDBC + }, + [FEMALE] = + { + gUnknown_082EEDF4, + gUnknown_082EEE24, + gUnknown_082EEE4C, + gUnknown_082EEE78 + } +}; + +ALIGNED(4) const u8 gUnknown_082EEECC[] = _("Oh, I see!\nThis is educational!\p"); +ALIGNED(4) const u8 gUnknown_082EEEF0[] = _("Don't say anything funny anymore!\nI'm sore from laughing!\p"); +ALIGNED(4) const u8 gUnknown_082EEF2C[] = _("Oh?\nSomething like that happened.\p"); +ALIGNED(4) const u8 gUnknown_082EEF50[] = _("Hmhm… What?\nSo is this what you're saying?\p"); +ALIGNED(4) const u8 gUnknown_082EEF7C[] = _("Is that right?\nI didn't know that.\p"); +ALIGNED(4) const u8 gUnknown_082EEFA0[] = _("Ahaha!\nWhat is that about?\p"); +ALIGNED(4) const u8 gUnknown_082EEFBC[] = _("Yes, that's exactly it!\nThat's what I meant.\p"); +ALIGNED(4) const u8 gUnknown_082EEFEC[] = _("In other words…\nYes! That's right!\p"); + +const u8 *const gUnknown_082EF010[GENDER_COUNT][4] = { + [MALE] = + { + gUnknown_082EEECC, + gUnknown_082EEEF0, + gUnknown_082EEF2C, + gUnknown_082EEF50 + }, + [FEMALE] = + { + gUnknown_082EEF7C, + gUnknown_082EEFA0, + gUnknown_082EEFBC, + gUnknown_082EEFEC + } +}; + +ALIGNED(4) const u8 gUnknown_082EF030[] = _("I'm just showing my TRAINER CARD\nas my way of greeting.\p"); +ALIGNED(4) const u8 gUnknown_082EF06C[] = _("I hope I get to know you better!\p"); +ALIGNED(4) const u8 gUnknown_082EF090[] = _("We're showing each other our\nTRAINER CARDS to get acquainted.\p"); +ALIGNED(4) const u8 gUnknown_082EF0D0[] = _("Glad to meet you.\nPlease don't be a stranger!\p"); + +const u8 *const gUnknown_082EF100[GENDER_COUNT][2] = { + [MALE] = + { + gUnknown_082EF030, + gUnknown_082EF06C + }, + [FEMALE] = + { + gUnknown_082EF090, + gUnknown_082EF0D0 + } +}; + +ALIGNED(4) const u8 sText_MaleTraded1[] = _("Yeahah!\nI really wanted this POKéMON!\p"); +ALIGNED(4) const u8 sText_MaleTraded2[] = _("Finally, a trade got me that\nPOKéMON I'd wanted a long time.\p"); +ALIGNED(4) const u8 sText_FemaleTraded1[] = _("I'm trading POKéMON right now.\p"); +ALIGNED(4) const u8 sText_FemaleTraded2[] = _("I finally got that POKéMON I\nwanted in a trade!\p"); + +const u8 *const sUnionRoomTexts_Traded[GENDER_COUNT][4] = { + [MALE] = + { + sText_MaleTraded1, + sText_MaleTraded2 + }, + [FEMALE] = + { + sText_FemaleTraded1, + sText_FemaleTraded2 + } +}; + +ALIGNED(4) const u8 sText_XCheckedTradingBoard[] = _("{STR_VAR_1} checked the\nTRADING BOARD.\p"); +ALIGNED(4) const u8 sText_RegisterMonAtTradingBoard[] = _("Welcome to the TRADING BOARD.\pYou may register your POKéMON\nand offer it up for a trade.\pWould you like to register one of\nyour POKéMON?"); +ALIGNED(4) const u8 sText_TradingBoardInfo[] = _("This TRADING BOARD is used for\noffering a POKéMON for a trade.\pAll you need to do is register a\nPOKéMON for a trade.\pAnother TRAINER may offer a party\nPOKéMON in return for the trade.\pWe hope you will register POKéMON\nand trade them with many, many\lother TRAINERS.\pWould you like to register one of\nyour POKéMON?"); +ALIGNED(4) const u8 sText_ThankYouForRegistering[] = _("We have registered your POKéMON for\ntrade on the TRADING BOARD.\pThank you for using this service!\p"); // unused +ALIGNED(4) const u8 sText_NobodyHasRegistered[] = _("Nobody has registered any POKéMON\nfor trade on the TRADING BOARD.\p\n"); // unused +ALIGNED(4) const u8 sText_ChooseRequestedMonType[] = _("Please choose the type of POKéMON\nthat you would like in the trade.\n"); +ALIGNED(4) const u8 sText_WhichMonWillYouOffer[] = _("Which of your party POKéMON will\nyou offer in trade?\p"); +ALIGNED(4) const u8 sText_RegistrationCanceled[] = _("Registration has been canceled.\p"); +ALIGNED(4) const u8 sText_RegistraionCompleted[] = _("Registration has been completed.\p"); +ALIGNED(4) const u8 sText_TradeCanceled[] = _("The trade has been canceled.\p"); +ALIGNED(4) const u8 sText_CancelRegistrationOfMon[] = _("Cancel the registration of your\nLv. {STR_VAR_2} {STR_VAR_1}?"); +ALIGNED(4) const u8 sText_CancelRegistrationOfEgg[] = _("Cancel the registration of your\nEGG?"); +ALIGNED(4) const u8 sText_RegistrationCanceled2[] = _("The registration has been canceled.\p"); +ALIGNED(4) const u8 sText_TradeTrainersWillBeListed[] = _("TRAINERS wishing to make a trade\nwill be listed."); // unused +ALIGNED(4) const u8 sText_ChooseTrainerToTradeWith[] = _("Please choose the TRAINER with whom\nyou would like to trade POKéMON."); // unused +ALIGNED(4) const u8 sText_AskTrainerToMakeTrade[] = _("Would you like to ask {STR_VAR_1} to\nmake a trade?"); +ALIGNED(4) const u8 sText_AwaitingResponseFromTrainer[] = _("Awaiting a response from\nthe other TRAINER…"); // unused +ALIGNED(4) const u8 sText_NotRegisteredAMonForTrade[] = _("You have not registered a POKéMON\nfor trading.\p"); // unused +ALIGNED(4) const u8 sText_DontHaveTypeTrainerWants[] = _("You don't have a {STR_VAR_2}-type\nPOKéMON that {STR_VAR_1} wants.\p"); +ALIGNED(4) const u8 sText_DontHaveEggTrainerWants[] = _("You don't have an EGG that\n{STR_VAR_1} wants.\p"); +ALIGNED(4) const u8 sText_CantTradeMonRightNow[] = _("{STR_VAR_1} can't make a trade for\nyour POKéMON right now.\p"); +ALIGNED(4) const u8 sText_CantTradePartnersMonRightNow[] = _("You can't make a trade for\n{STR_VAR_1}'s POKéMON right now.\p"); + +// unused +const u8 *const sUnionRoomTexts_CantTradeRightNow[] = { + sText_CantTradeMonRightNow, + sText_CantTradePartnersMonRightNow +}; + +ALIGNED(4) const u8 sText_TradeOfferRejected[] = _("Your trade offer was rejected.\p"); +ALIGNED(4) const u8 sText_EggTrade[] = _("EGG TRADE"); +ALIGNED(4) const u8 gUnknown_082EF7DC[] = _("{DPAD_UPDOWN}CHOOSE {A_BUTTON}JOIN {B_BUTTON}CANCEL"); +ALIGNED(4) const u8 gUnknown_082EF7F8[] = _("Please choose a TRAINER."); +ALIGNED(4) const u8 gUnknown_082EF814[] = _("Please choose a TRAINER for\na SINGLE BATTLE."); +ALIGNED(4) const u8 gUnknown_082EF844[] = _("Please choose a TRAINER for\na DOUBLE BATTLE."); +ALIGNED(4) const u8 gUnknown_082EF874[] = _("Please choose the LEADER\nfor a MULTI BATTLE."); +ALIGNED(4) const u8 gUnknown_082EF8A4[] = _("Please choose the TRAINER to\ntrade with."); +ALIGNED(4) const u8 gUnknown_082EF8D0[] = _("Please choose the TRAINER who is\nsharing WONDER CARDS."); +ALIGNED(4) const u8 gUnknown_082EF908[] = _("Please choose the TRAINER who is\nsharing WONDER NEWS."); +ALIGNED(4) const u8 gUnknown_082EF940[] = _("Jump with mini POKéMON!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EF974[] = _("BERRY CRUSH!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EF99C[] = _("DODRIO BERRY-PICKING!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EF9CC[] = _("BERRY BLENDER!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EF9F8[] = _("RECORD CORNER!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFA24[] = _("COOLNESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFA50[] = _("BEAUTY CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFA7C[] = _("CUTENESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFAA8[] = _("SMARTNESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFAD8[] = _("TOUGHNESS CONTEST!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFB08[] = _("BATTLE TOWER LEVEL 50!\nPlease choose the LEADER."); +ALIGNED(4) const u8 gUnknown_082EFB3C[] = _("BATTLE TOWER OPEN LEVEL!\nPlease choose the LEADER."); + +const u8 *const gUnknown_082EFB70[] = { + gUnknown_082EF814, + gUnknown_082EF844, + gUnknown_082EF874, + gUnknown_082EF8A4, + gUnknown_082EF940, + gUnknown_082EF974, + gUnknown_082EF99C, + gUnknown_082EF8D0, + gUnknown_082EF908, + NULL, + NULL, + NULL, + gUnknown_082EF9F8, + gUnknown_082EF9CC, + NULL, + gUnknown_082EFA24, + gUnknown_082EFA50, + gUnknown_082EFA7C, + gUnknown_082EFAA8, + gUnknown_082EFAD8, + gUnknown_082EFB08, + gUnknown_082EFB3C +}; + +ALIGNED(4) const u8 gUnknown_082EFBC8[] = _("Searching for a WIRELESS\nCOMMUNICATION SYSTEM. Wait..."); +ALIGNED(4) const u8 unref_text_union_room_12[] = _("For a DOUBLE BATTLE, you must have\nat least two POKéMON.\p"); +ALIGNED(4) const u8 gUnknown_082EFC3C[] = _("Awaiting {STR_VAR_1}'s response…"); +ALIGNED(4) const u8 gUnknown_082EFC54[] = _("{STR_VAR_1} has been asked to register\nyou as a member. Please wait."); +ALIGNED(4) const u8 gUnknown_082EFC90[] = _("Awaiting a response from the\nWIRELESS COMMUNICATION SYSTEM."); +ALIGNED(4) const u8 unref_text_union_room_13[] = _("Please wait for other TRAINERS to\ngather and get ready."); +ALIGNED(4) const u8 gUnknown_082EFD04[] = _("No CARDS appear to be shared \nright now."); +ALIGNED(4) const u8 gUnknown_082EFD30[] = _("No NEWS appears to be shared\nright now."); + +const u8 *const gUnknown_082EFD58[] = { + gUnknown_082EFD04, + gUnknown_082EFD30 +}; + +ALIGNED(4) const u8 gUnknown_082EFD60[] = _("BATTLE"); +ALIGNED(4) const u8 gUnknown_082EFD68[] = _("CHAT"); +ALIGNED(4) const u8 gUnknown_082EFD70[] = _("GREETINGS"); +ALIGNED(4) const u8 gUnknown_082EFD7C[] = _("EXIT"); +ALIGNED(4) const u8 gUnknown_082EFD84[] = _("EXIT"); +ALIGNED(4) const u8 gUnknown_082EFD8C[] = _("INFO"); +ALIGNED(4) const u8 gUnknown_082EFD94[] = _("NAME{CLEAR_TO 0x3C}WANTED{CLEAR_TO 0x6E}OFFER{CLEAR_TO 0xC6}LV."); +ALIGNED(4) const u8 gUnknown_082EFDB0[] = _("SINGLE BATTLE"); +ALIGNED(4) const u8 gUnknown_082EFDC0[] = _("DOUBLE BATTLE"); +ALIGNED(4) const u8 gUnknown_082EFDD0[] = _("MULTI BATTLE"); +ALIGNED(4) const u8 gUnknown_082EFDE0[] = _("POKéMON TRADES"); +ALIGNED(4) const u8 gUnknown_082EFDF0[] = _("CHAT"); +ALIGNED(4) const u8 gUnknown_082EFDF8[] = _("CARDS"); +ALIGNED(4) const u8 gUnknown_082EFE00[] = _("WONDER CARDS"); +ALIGNED(4) const u8 gUnknown_082EFE10[] = _("WONDER NEWS"); +ALIGNED(4) const u8 gUnknown_082EFE1C[] = _("POKéMON JUMP"); +ALIGNED(4) const u8 gUnknown_082EFE2C[] = _("BERRY CRUSH"); +ALIGNED(4) const u8 gUnknown_082EFE38[] = _("BERRY-PICKING"); +ALIGNED(4) const u8 gUnknown_082EFE48[] = _("SEARCH"); +ALIGNED(4) const u8 gUnknown_082EFE50[] = _("BERRY BLENDER"); +ALIGNED(4) const u8 gUnknown_082EFE60[] = _("RECORD CORNER"); +ALIGNED(4) const u8 gUnknown_082EFE70[] = _("COOL CONTEST"); +ALIGNED(4) const u8 gUnknown_082EFE80[] = _("BEAUTY CONTEST"); +ALIGNED(4) const u8 gUnknown_082EFE90[] = _("CUTE CONTEST"); +ALIGNED(4) const u8 gUnknown_082EFEA0[] = _("SMART CONTEST"); +ALIGNED(4) const u8 gUnknown_082EFEB0[] = _("TOUGH CONTEST"); +ALIGNED(4) const u8 gUnknown_082EFEC0[] = _("BATTLE TOWER LV. 50"); +ALIGNED(4) const u8 gUnknown_082EFED4[] = _("BATTLE TOWER OPEN LEVEL"); +ALIGNED(4) const u8 gUnknown_082EFEEC[] = _("It's a NORMAL CARD."); +ALIGNED(4) const u8 gUnknown_082EFF00[] = _("It's a BRONZE CARD!"); +ALIGNED(4) const u8 gUnknown_082EFF14[] = _("It's a COPPER CARD!"); +ALIGNED(4) const u8 gUnknown_082EFF28[] = _("It's a SILVER CARD!"); +ALIGNED(4) const u8 gUnknown_082EFF3C[] = _("It's a GOLD CARD!"); + +const u8 *const gUnknown_082EFF50[] = { + gUnknown_082EFEEC, + gUnknown_082EFF00, + gUnknown_082EFF14, + gUnknown_082EFF28, + gUnknown_082EFF3C +}; + +ALIGNED(4) const u8 gUnknown_082EFF64[] = _("This is {SPECIAL_F7 0x00} {SPECIAL_F7 0x01}'s\nTRAINER CARD…\l{SPECIAL_F7 0x02}\pPOKéDEX: {SPECIAL_F7 0x03}\nTIME: {SPECIAL_F7 0x04}:{SPECIAL_F7 0x05}\p"); +ALIGNED(4) const u8 gUnknown_082EFFA4[] = _("BATTLES: WINS: {SPECIAL_F7 0x00} LOSSES: {SPECIAL_F7 0x02}\nTRADES: {SPECIAL_F7 0x03}\p“{SPECIAL_F7 0x04} {SPECIAL_F7 0x05}\n{SPECIAL_F7 0x06} {SPECIAL_F7 0x07}”\p"); +ALIGNED(4) const u8 gUnknown_082EFFDC[] = _("{SPECIAL_F7 0x01}: Glad to have met you!{PAUSE 60}"); +ALIGNED(4) const u8 gUnknown_082EFFFC[] = _("{SPECIAL_F7 0x01}: Glad to meet you!{PAUSE 60}"); + +const u8 *const gUnknown_082F0018[] = { + gUnknown_082EFFDC, + gUnknown_082EFFFC +}; + +ALIGNED(4) const u8 gUnknown_082F0020[] = _("Finished checking {SPECIAL_F7 0x01}'s\nTRAINER CARD.{PAUSE 60}"); + +const u8 *const gUnknown_082F0048[] = { + gText_EmptyString, + gUnknown_082EFDB0, + gUnknown_082EFDC0, + gUnknown_082EFDD0, + gUnknown_082EFDE0, + gUnknown_082EFDF0, + gUnknown_082EFE00, + gUnknown_082EFE10, + gUnknown_082EFDF8, + gUnknown_082EFE1C, + gUnknown_082EFE2C, + gUnknown_082EFE38, + gUnknown_082EFE48, + gText_EmptyString, + gUnknown_082EFED4, + gUnknown_082EFE60, + gUnknown_082EFE50, + gText_EmptyString, + gText_EmptyString, + gText_EmptyString, + gText_EmptyString, + gUnknown_082EFE00, + gUnknown_082EFE10, + gUnknown_082EFE70, + gUnknown_082EFE80, + gUnknown_082EFE90, + gUnknown_082EFEA0, + gUnknown_082EFEB0, + gUnknown_082EFEC0 +}; + +const struct WindowTemplate gUnknown_082F00BC = { + .bg = 0x00, + .tilemapLeft = 0x00, + .tilemapTop = 0x00, + .width = 0x1E, + .height = 0x02, + .paletteNum = 0x0F, + .baseBlock = 0x0008 +}; + +const u32 gUnknown_082F00C4[] = { + 0x0201, + 0x0202, + 0x0403, + 0x0204, + 0x2509, + 0x250a, + 0x350b, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x240f, + 0x2410, + 0x0000, + 0x2417, + 0x2418, + 0x2419, + 0x241a, + 0x241b, + 0x021c, + 0x020e +}; + +const struct WindowTemplate gUnknown_082F011C = { + .bg = 0x00, + .tilemapLeft = 0x01, + .tilemapTop = 0x03, + .width = 0x0d, + .height = 0x08, + .paletteNum = 0x0f, + .baseBlock = 0x0044 +}; + +const struct WindowTemplate gUnknown_082F0124 = { + .bg = 0x00, + .tilemapLeft = 0x01, + .tilemapTop = 0x03, + .width = 0x0d, + .height = 0x0a, + .paletteNum = 0x0f, + .baseBlock = 0x0044 +}; + +const struct WindowTemplate gUnknown_082F012C = { + .bg = 0x00, + .tilemapLeft = 0x10, + .tilemapTop = 0x03, + .width = 0x07, + .height = 0x04, + .paletteNum = 0x0f, + .baseBlock = 0x00c6 +}; + +const struct ListMenuItem gUnknown_082F0134[] = { + { gText_EmptyString, 0 }, + { gText_EmptyString, 1 }, + { gText_EmptyString, 2 }, + { gText_EmptyString, 3 }, + { gText_EmptyString, 4 } +}; + +const struct ListMenuTemplate gUnknown_082F015C = { + .items = gUnknown_082F0134, + .moveCursorFunc = NULL, + .itemPrintFunc = sub_8013278, + .totalItems = 5, + .maxShowed = 5, + .windowId = 0, + .header_X = 0, + .item_X = 0, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 0, + .fontId = 1, + .cursorKind = 1 +}; + +const struct WindowTemplate gUnknown_082F0174 = { + .bg = 0x00, + .tilemapLeft = 0x01, + .tilemapTop = 0x03, + .width = 0x11, + .height = 0x0a, + .paletteNum = 0x0f, + .baseBlock = 0x0044 +}; + +const struct WindowTemplate gUnknown_082F017C = { + .bg = 0x00, + .tilemapLeft = 0x14, + .tilemapTop = 0x03, + .width = 0x07, + .height = 0x04, + .paletteNum = 0x0f, + .baseBlock = 0x00ee +}; + +const struct ListMenuItem gUnknown_082F0184[] = { + { gText_EmptyString, 0 }, + { gText_EmptyString, 1 }, + { gText_EmptyString, 2 }, + { gText_EmptyString, 3 }, + { gText_EmptyString, 4 }, + { gText_EmptyString, 5 }, + { gText_EmptyString, 6 }, + { gText_EmptyString, 7 }, + { gText_EmptyString, 8 }, + { gText_EmptyString, 9 }, + { gText_EmptyString, 10 }, + { gText_EmptyString, 11 }, + { gText_EmptyString, 12 }, + { gText_EmptyString, 13 }, + { gText_EmptyString, 14 }, + { gText_EmptyString, 15 } +}; + +const struct ListMenuTemplate gUnknown_082F0204 = { + .items = gUnknown_082F0184, + .moveCursorFunc = ListMenuDefaultCursorMoveFunc, + .itemPrintFunc = sub_8013DF4, + .totalItems = 16, + .maxShowed = 5, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 1, + .fontId = 1, + .cursorKind = 0 +}; + +const struct WindowTemplate gUnknown_082F021C = { + .bg = 0x00, + .tilemapLeft = 0x14, + .tilemapTop = 0x05, + .width = 0x10, + .height = 0x08, + .paletteNum = 0x0f, + .baseBlock = 0x0001 +}; + +const struct ListMenuItem gUnknown_082F0224[] = { + { gUnknown_082EFD70, 0x208 }, + { gUnknown_082EFD60, 0x241 }, + { gUnknown_082EFD68, 0x245 }, + { gUnknown_082EFD7C, 0x040 } +}; + +const struct ListMenuTemplate gUnknown_082F0244 = { + .items = gUnknown_082F0224, + .moveCursorFunc = ListMenuDefaultCursorMoveFunc, + .itemPrintFunc = NULL, + .totalItems = 4, + .maxShowed = 4, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 0, + .fontId = 1, + .cursorKind = 0 +}; + +const struct WindowTemplate gUnknown_082F025C = { + .bg = 0x00, + .tilemapLeft = 0x12, + .tilemapTop = 0x07, + .width = 0x10, + .height = 0x06, + .paletteNum = 0x0f, + .baseBlock = 0x0001 +}; + +const struct ListMenuItem gUnknown_082F0264[] = { + { gText_Register, 1 }, + { gUnknown_082EFD8C, 2 }, + { gUnknown_082EFD7C, 3 } +}; + +const struct ListMenuTemplate gUnknown_082F027C = { + .items = gUnknown_082F0264, + .moveCursorFunc = ListMenuDefaultCursorMoveFunc, + .itemPrintFunc = NULL, + .totalItems = 3, + .maxShowed = 3, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 0, + .fontId = 1, + .cursorKind = 0 +}; + +const struct WindowTemplate gUnknown_082F0294 = { + .bg = 0x00, + .tilemapLeft = 0x14, + .tilemapTop = 0x01, + .width = 0x10, + .height = 0x0c, + .paletteNum = 0x0f, + .baseBlock = 0x0001 +}; + +static const struct ListMenuItem sTradingBoardTypes[] = { + { gTypeNames[TYPE_NORMAL], TYPE_NORMAL }, + { gTypeNames[TYPE_FIRE], TYPE_FIRE }, + { gTypeNames[TYPE_WATER], TYPE_WATER }, + { gTypeNames[TYPE_ELECTRIC], TYPE_ELECTRIC }, + { gTypeNames[TYPE_GRASS], TYPE_GRASS }, + { gTypeNames[TYPE_ICE], TYPE_ICE }, + { gTypeNames[TYPE_GROUND], TYPE_GROUND }, + { gTypeNames[TYPE_ROCK], TYPE_ROCK }, + { gTypeNames[TYPE_FLYING], TYPE_FLYING }, + { gTypeNames[TYPE_PSYCHIC], TYPE_PSYCHIC }, + { gTypeNames[TYPE_FIGHTING], TYPE_FIGHTING }, + { gTypeNames[TYPE_POISON], TYPE_POISON }, + { gTypeNames[TYPE_BUG], TYPE_BUG }, + { gTypeNames[TYPE_GHOST], TYPE_GHOST }, + { gTypeNames[TYPE_DRAGON], TYPE_DRAGON }, + { gTypeNames[TYPE_STEEL], TYPE_STEEL }, + { gTypeNames[TYPE_DARK], TYPE_DARK }, + { gUnknown_082EFD7C, NUMBER_OF_MON_TYPES } +}; + +const struct ListMenuTemplate sMenuTemplate_TradingBoardRequestType = { + .items = sTradingBoardTypes, + .moveCursorFunc = ListMenuDefaultCursorMoveFunc, + .itemPrintFunc = NULL, + .totalItems = NUMBER_OF_MON_TYPES, + .maxShowed = 6, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 0, + .fontId = 1, + .cursorKind = 0 +}; + +const struct WindowTemplate gUnknown_082F0344 = { + .bg = 0x00, + .tilemapLeft = 0x01, + .tilemapTop = 0x01, + .width = 0x1c, + .height = 0x02, + .paletteNum = 0x0d, + .baseBlock = 0x0001 +}; + +const struct WindowTemplate gUnknown_082F034C = { + .bg = 0x00, + .tilemapLeft = 0x01, + .tilemapTop = 0x05, + .width = 0x1c, + .height = 0x0c, + .paletteNum = 0x0d, + .baseBlock = 0x0039 +}; + +const struct ListMenuItem gUnknown_082F0354[] = { + { gText_EmptyString, -3 }, + { gText_EmptyString, 0 }, + { gText_EmptyString, 1 }, + { gText_EmptyString, 2 }, + { gText_EmptyString, 3 }, + { gText_EmptyString, 4 }, + { gText_EmptyString, 5 }, + { gText_EmptyString, 6 }, + { gText_EmptyString, 7 }, + { gUnknown_082EFD84, 8 } +}; + +const struct ListMenuTemplate gUnknown_082F03A4 = { + .items = gUnknown_082F0354, + .moveCursorFunc = ListMenuDefaultCursorMoveFunc, + .itemPrintFunc = sub_8017BE8, + .totalItems = 10, + .maxShowed = 6, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 14, + .fillValue = 15, + .cursorShadowPal = 13, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 0, + .fontId = 1, + .cursorKind = 0 +}; + +const struct WindowTemplate UnrefWindowTemplate_082F03B4 = { + .bg = 0x00, + .tilemapLeft = 0x01, + .tilemapTop = 0x05, + .width = 0x1c, + .height = 0x0c, + .paletteNum = 0x0d, + .baseBlock = 0x0039 +}; + +const struct ListMenuItem gUnknown_082F03C4[] = { + { gText_EmptyString, 0 }, + { gText_EmptyString, 1 }, + { gText_EmptyString, 2 }, + { gText_EmptyString, 3 }, + { gText_EmptyString, 4 }, + { gText_EmptyString, 5 }, + { gText_EmptyString, 6 }, + { gText_EmptyString, 7 }, + { gText_EmptyString, 8 }, + { gText_EmptyString, 9 }, + { gText_EmptyString, 10 }, + { gText_EmptyString, 11 }, + { gText_EmptyString, 12 }, + { gText_EmptyString, 13 }, + { gText_EmptyString, 14 }, + { gText_EmptyString, 15 } +}; + +const struct ListMenuTemplate UnrefListMenuTemplate_082F0444 = { + .items = gUnknown_082F03C4, + .moveCursorFunc = ListMenuDefaultCursorMoveFunc, + .itemPrintFunc = nullsub_14, + .totalItems = 16, + .maxShowed = 4, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = 1, + .fontId = 1, + .cursorKind = 0 +}; + +const struct UnkStruct_Shared gUnknown_082F045C = {0}; + +ALIGNED(4) const u8 gUnknown_082F0474[] = {0x01, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0478[] = {0x02, 0xff}; +ALIGNED(4) const u8 gUnknown_082F047C[] = {0x03, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0480[] = {0x04, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0484[] = {0x09, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0488[] = {0x0a, 0xff}; +ALIGNED(4) const u8 gUnknown_082F048C[] = {0x0b, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0490[] = {0x15, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0494[] = {0x16, 0xff}; +ALIGNED(4) const u8 gUnknown_082F0498[] = {0x40, 0x41, 0x44, 0x45, 0x48, 0x51, 0x52, 0x53, 0x54, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04A4[] = {0x0c, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04A8[] = {0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x15, 0x16, 0x0d, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04B4[] = {0x0f, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04B8[] = {0x10, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04BC[] = {0x17, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04C0[] = {0x18, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04C4[] = {0x19, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04C8[] = {0x1a, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04CC[] = {0x1b, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04D0[] = {0x1c, 0xff}; +ALIGNED(4) const u8 gUnknown_082F04D4[] = {0x0e, 0xff}; + +const u8 *const gUnknown_082F04D8[] = { + gUnknown_082F0474, + gUnknown_082F0478, + gUnknown_082F047C, + gUnknown_082F0480, + gUnknown_082F0484, + gUnknown_082F0488, + gUnknown_082F048C, + gUnknown_082F0490, + gUnknown_082F0494, + gUnknown_082F0498, + gUnknown_082F04A4, + gUnknown_082F04A8, + gUnknown_082F04B4, + gUnknown_082F04B8, + NULL, + gUnknown_082F04BC, + gUnknown_082F04C0, + gUnknown_082F04C4, + gUnknown_082F04C8, + gUnknown_082F04CC, + gUnknown_082F04D0, + gUnknown_082F04D4 +}; + +const u8 gUnknown_082F0530[] = { + 0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x15, + 0x16, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x00, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x0e, 0x00, 0x00 +}; diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 5ba979453..af560bc40 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -406,7 +406,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) gMain.state++; break; case 2: - sub_807F19C(); + InitTradeBg(); gMain.state++; break; case 3: @@ -438,7 +438,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) gSprites[ID].callback = SpriteCallbackDummy_2; gSprites[ID].oam.paletteNum = 2; gMain.state++; - sub_807B154(); + LinkTradeDrawWindow(); } break; case 6: @@ -452,7 +452,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) break; case 7: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); - sub_807B140(); + InitTradeSequenceBgGpuRegs(); ShowBg(0); ShowBg(1); SetMainCallback2(CB2_TradeEvolutionSceneUpdate); @@ -985,7 +985,7 @@ static void Task_TradeEvolutionScene(u8 taskID) { case 0: StringExpandPlaceholders(gStringVar4, gText_PkmnIsEvolving); - sub_807F1A8(0, gStringVar4, 1); + DrawTextOnTradeWindow(0, gStringVar4, 1); gTasks[taskID].tState++; break; case 1: @@ -1075,7 +1075,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (IsCryFinished()) { StringExpandPlaceholders(gStringVar4, gText_CongratsPkmnEvolved); - sub_807F1A8(0, gStringVar4, 1); + DrawTextOnTradeWindow(0, gStringVar4, 1); PlayFanfare(MUS_FANFA5); gTasks[taskID].tState++; SetMonData(mon, MON_DATA_SPECIES, (&gTasks[taskID].tPostEvoSpecies)); @@ -1110,7 +1110,7 @@ static void Task_TradeEvolutionScene(u8 taskID) else { PlayBGM(MUS_SHINKA); - sub_807F1A8(0, gText_CommunicationStandby5, 1); + DrawTextOnTradeWindow(0, gText_CommunicationStandby5, 1); gTasks[taskID].tState++; } } @@ -1144,7 +1144,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (EvoScene_IsMonAnimFinished(sEvoStructPtr->preEvoSpriteID)) { StringExpandPlaceholders(gStringVar4, gText_EllipsisQuestionMark); - sub_807F1A8(0, gStringVar4, 1); + DrawTextOnTradeWindow(0, gStringVar4, 1); gTasks[taskID].tEvoWasStopped = 1; gTasks[taskID].tState = 13; } @@ -1155,7 +1155,7 @@ static void Task_TradeEvolutionScene(u8 taskID) BufferMoveToLearnIntoBattleTextBuff2(); PlayFanfare(MUS_FANFA1); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_PKMNLEARNEDMOVE - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnsFirstMove = 0x40; // re-used as a counter gTasks[taskID].tState++; } @@ -1172,7 +1172,7 @@ static void Task_TradeEvolutionScene(u8 taskID) { BufferMoveToLearnIntoBattleTextBuff2(); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE1 - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState++; } break; @@ -1180,7 +1180,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!IsTextPrinterActive(0) && !IsSEPlaying()) { BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE2 - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState++; } break; @@ -1188,7 +1188,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!IsTextPrinterActive(0) && !IsSEPlaying()) { BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_TRYTOLEARNMOVE3 - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tData7 = 5; gTasks[taskID].tData8 = 9; gTasks[taskID].tLearnMoveState++; @@ -1197,7 +1197,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!IsTextPrinterActive(0) && !IsSEPlaying()) { LoadUserWindowBorderGfx(0, 0xA8, 0xE0); - CreateYesNoMenu(&gUnknown_0833900C, 0xA8, 0xE, 0); + CreateYesNoMenu(&gTradeEvolutionSceneYesNoWindowTemplate, 0xA8, 0xE, 0); sEvoCursorPos = 0; gTasks[taskID].tLearnMoveState++; sEvoCursorPos = 0; @@ -1209,7 +1209,7 @@ static void Task_TradeEvolutionScene(u8 taskID) case 0: sEvoCursorPos = 0; BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_EMPTYSTRING3 - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState = gTasks[taskID].tData7; if (gTasks[taskID].tLearnMoveState == 5) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); @@ -1218,7 +1218,7 @@ static void Task_TradeEvolutionScene(u8 taskID) case -1: sEvoCursorPos = 1; BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_EMPTYSTRING3 - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState = gTasks[taskID].tData8; break; } @@ -1254,7 +1254,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (IsHMMove2(move)) { BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_HMMOVESCANTBEFORGOTTEN - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState = 11; } else @@ -1264,7 +1264,7 @@ static void Task_TradeEvolutionScene(u8 taskID) RemoveMonPPBonus(mon, var); SetMonMoveSlot(mon, gMoveToLearn, var); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_123POOF - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState++; } } @@ -1274,7 +1274,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!IsTextPrinterActive(0) && !IsSEPlaying()) { BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_PKMNFORGOTMOVE - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tLearnMoveState++; } break; @@ -1282,20 +1282,20 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!IsTextPrinterActive(0) && !IsSEPlaying()) { BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_ANDELLIPSIS - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tState = 18; } break; case 9: BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_STOPLEARNINGMOVE - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tData7 = 10; gTasks[taskID].tData8 = 0; gTasks[taskID].tLearnMoveState = 3; break; case 10: BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[STRINGID_DIDNOTLEARNMOVE - BATTLESTRINGS_ID_ADDER]); - sub_807F1A8(0, gDisplayedStringBattle, 1); + DrawTextOnTradeWindow(0, gDisplayedStringBattle, 1); gTasks[taskID].tState = 13; break; case 11: diff --git a/src/fldeff_softboiled.c b/src/fldeff_softboiled.c index c18602c68..733263bbc 100644 --- a/src/fldeff_softboiled.c +++ b/src/fldeff_softboiled.c @@ -34,7 +34,7 @@ void sub_8161560(u8 taskId) gUnknown_0203CEC8.unkB = 0xA; gUnknown_0203CEC8.unkA = gUnknown_0203CEC8.slotId; sub_81B0FCC(GetCursorSelectionMonId(), 0x1); - display_pokemon_menu_message(0x5); + DisplayPartyMenuStdMessage(5); gTasks[taskId].func = sub_81B1370; } @@ -47,7 +47,7 @@ void sub_81615A8(u8 taskId) if(pokemonIndex > 6) { gUnknown_0203CEC8.unkB = 0; - display_pokemon_menu_message(0x0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; return; } @@ -73,7 +73,7 @@ static void sub_81616C0(u8 taskId) { GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.unkA], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_8161724; } @@ -88,7 +88,7 @@ static void sub_8161724(u8 taskId) sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); ClearStdWindowAndFrameToTransparent(0x6, FALSE); ClearWindowTilemap(0x6); - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } @@ -96,14 +96,14 @@ static void sub_8161784(u8 taskId) { if(sub_81B1BD4() == 1) return; - display_pokemon_menu_message(0x5); + DisplayPartyMenuStdMessage(5); gTasks[taskId].func = sub_81B1370; } static void sub_81617B8(u8 taskId) { PlaySE(SE_SELECT); - sub_81B1B5C(gText_CantBeUsedOnPkmn, 0); + DisplayPartyMenuMessage(gText_CantBeUsedOnPkmn, 0); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_8161784; } diff --git a/src/graphics.c b/src/graphics.c index 679f16af1..5f27cdea4 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1516,21 +1516,14 @@ asm(".space 0x20"); //blank palette?? #include "data/graphics/berry_fix.h" -// more trade stuff? - -const u16 gUnknown_08DDB3E4[] = INCBIN_U16("graphics/trade/menu.gbapal"); - -const u16 gUnknown_08DDB444[] = INCBIN_U16("graphics/unknown/unknown_DDB444.gbapal"); - -const u8 gUnknown_08DDB464[] = INCBIN_U8("graphics/trade/menu.4bpp"); - -const u8 gUnknown_08DDC6E4[] = INCBIN_U8("graphics/trade/buttons.4bpp"); - +// Trade +const u16 gTradeMenu_Pal[] = INCBIN_U16("graphics/trade/menu.gbapal"); +const u16 gUnknown_08DDB444[] = INCBIN_U16("graphics/trade/unknown_DDB444.gbapal"); +const u8 gTradeMenu_Gfx[] = INCBIN_U8("graphics/trade/menu.4bpp"); +const u8 gTradeButtons_Gfx[] = INCBIN_U8("graphics/trade/buttons.4bpp"); const u16 gUnused_DDCEE4[] = INCBIN_U16("graphics/unused/unused_DDCEE4.bin"); - -const u16 gUnknown_08DDCF04[] = INCBIN_U16("graphics/unknown/unknown_DDCF04.bin"); - -const u16 gUnknown_08DDD704[] = INCBIN_U16("graphics/unknown/unknown_DDD704.bin"); // textbox tilemap?? +const u16 gUnknown_08DDCF04[] = INCBIN_U16("graphics/trade/unknown_DDCF04.bin"); +const u16 gTradeMenuMonBox_Tilemap[] = INCBIN_U16("graphics/trade/menu_mon_box.bin"); const u16 gMessageBox_Pal[] = INCBIN_U16("graphics/text_window/message_box.gbapal"); const u8 gMessageBox_Gfx[] = INCBIN_U8("graphics/text_window/message_box.4bpp"); diff --git a/src/link.c b/src/link.c index edb4181e3..3ca8236ed 100644 --- a/src/link.c +++ b/src/link.c @@ -28,6 +28,7 @@ #include "link.h" #include "link_rfu.h" #include "constants/rgb.h" +#include "constants/trade.h" extern u16 gHeldKeyCodeToSend; @@ -316,10 +317,10 @@ static void InitLocalLinkPlayer(void) gLocalLinkPlayer.language = gGameLanguage; gLocalLinkPlayer.version = gGameVersion + 0x4000; gLocalLinkPlayer.lp_field_2 = 0x8000; - gLocalLinkPlayer.name[8] = IsNationalPokedexEnabled(); + gLocalLinkPlayer.progressFlags = IsNationalPokedexEnabled(); if (FlagGet(FLAG_IS_CHAMPION)) { - gLocalLinkPlayer.name[8] |= 0x10; + gLocalLinkPlayer.progressFlags |= 0x10; } } @@ -597,9 +598,9 @@ static void ProcessRecvCmds(u8 unused) *linkPlayer = block->linkPlayer; if ((linkPlayer->version & 0xFF) == VERSION_RUBY || (linkPlayer->version & 0xFF) == VERSION_SAPPHIRE) { - linkPlayer->name[10] = 0; - linkPlayer->name[9] = 0; - linkPlayer->name[8] = 0; + linkPlayer->progressFlagsCopy = 0; + linkPlayer->neverRead = 0; + linkPlayer->progressFlags = 0; } sub_800B524(linkPlayer); if (strcmp(block->magic1, gASCIIGameFreakInc) != 0 @@ -739,7 +740,7 @@ void ClearLinkCallback(void) { if (gWirelessCommType) { - Rfu_set_zero(); + ClearLinkRfuCallback(); } else { @@ -751,7 +752,7 @@ void ClearLinkCallback_2(void) { if (gWirelessCommType) { - Rfu_set_zero(); + ClearLinkRfuCallback(); } else { @@ -862,15 +863,15 @@ u8 GetLinkPlayerDataExchangeStatusTimed(int lower, int upper) { if (gLinkPlayers[0].linkType == 0x1133) { - switch (sub_807A728()) + switch (GetGameProgressForLinkTrade()) { - case 1: - sPlayerDataExchangeStatus = EXCHANGE_STAT_4; + case TRADE_PLAYER_NOT_READY: + sPlayerDataExchangeStatus = EXCHANGE_PLAYER_NOT_READY; break; - case 2: - sPlayerDataExchangeStatus = EXCHANGE_STAT_5; + case TRADE_PARTNER_NOT_READY: + sPlayerDataExchangeStatus = EXCHANGE_PARTNER_NOT_READY; break; - case 0: + case TRADE_BOTH_PLAYERS_READY: sPlayerDataExchangeStatus = EXCHANGE_COMPLETE; break; } @@ -1084,7 +1085,7 @@ bool8 IsLinkTaskFinished(void) { if (gWirelessCommType == TRUE) { - return sub_8010500(); + return IsLinkRfuTaskFinished(); } return gLinkCallback == NULL; } @@ -1909,7 +1910,7 @@ u8 sub_800B518(void) void sub_800B524(struct LinkPlayer *player) { - player->name[10] = player->name[8]; + player->progressFlagsCopy = player->progressFlags; ConvertInternationalString(player->name, player->language); } diff --git a/src/link_rfu.c b/src/link_rfu.c index f7f6c7d65..cedc6b2fb 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -2165,9 +2165,9 @@ void sub_800DD94(struct UnkLinkRfuStruct_02022B14 *data, u8 r9, bool32 r2, s32 r data->unk_00.unk_00_4 = 0; data->unk_00.unk_00_5 = 0; data->unk_00.unk_00_6 = 0; - data->unk_00.unk_00_7 = FlagGet(FLAG_IS_CHAMPION); - data->unk_00.unk_01_0 = IsNationalPokedexEnabled(); - data->unk_00.unk_01_1 = FlagGet(FLAG_SYS_GAME_CLEAR); + data->unk_00.isChampion = FlagGet(FLAG_IS_CHAMPION); + data->unk_00.hasNationalDex = IsNationalPokedexEnabled(); + data->unk_00.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR); } bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx) @@ -3169,7 +3169,7 @@ bool32 sub_800F4F0(void) sub_8011A64(2, 0x9000); rfu_clearAllSlot(); gReceivedRemoteLinkPlayers = FALSE; - gUnknown_03005000.unk_00 = 0; + gUnknown_03005000.linkRfuCallback = NULL; if (gUnknown_03005000.unk_ce4 == 1) { sub_8011A64(2, 0x9000); @@ -3264,17 +3264,17 @@ struct UnkLinkRfuStruct_02022B14 *sub_800F7DC(void) bool32 IsSendingKeysToRfu(void) { - return gUnknown_03005000.unk_00 == rfu_func_080F97B8; + return gUnknown_03005000.linkRfuCallback == rfu_func_080F97B8; } void sub_800F804(void) { - gUnknown_03005000.unk_00 = rfu_func_080F97B8; + gUnknown_03005000.linkRfuCallback = rfu_func_080F97B8; } -void Rfu_set_zero(void) +void ClearLinkRfuCallback(void) { - gUnknown_03005000.unk_00 = NULL; + gUnknown_03005000.linkRfuCallback = NULL; } void sub_800F820(void) @@ -3287,8 +3287,8 @@ void sub_800F820(void) void sub_800F850(void) { - if (gUnknown_03005000.unk_00 == NULL) - gUnknown_03005000.unk_00 = sub_800F820; + if (gUnknown_03005000.linkRfuCallback == NULL) + gUnknown_03005000.linkRfuCallback = sub_800F820; } static void sub_800F86C(u8 unused) @@ -3507,7 +3507,7 @@ void sub_800FE50(void *a0) bool32 sub_800FE84(const u8 *src, size_t size) { bool8 r4; - if (gUnknown_03005000.unk_00 != NULL) + if (gUnknown_03005000.linkRfuCallback != NULL) return FALSE; if (gSendCmd[0] != 0) return FALSE; @@ -3530,7 +3530,7 @@ bool32 sub_800FE84(const u8 *src, size_t size) gUnknown_03005000.unk_6c.unk_04 = gBlockSendBuffer; } sub_800FD14(0x8800); - gUnknown_03005000.unk_00 = rfufunc_80F9F44; + gUnknown_03005000.linkRfuCallback = rfufunc_80F9F44; gUnknown_03005000.unk_5b = 0; return TRUE; } @@ -3543,12 +3543,12 @@ static void rfufunc_80F9F44(void) if (gUnknown_03005000.unk_0c == 1) { if (++gUnknown_03005000.unk_5b > 2) - gUnknown_03005000.unk_00 = sub_800FFB0; + gUnknown_03005000.linkRfuCallback = sub_800FFB0; } else { if ((gRecvCmds[GetMultiplayerId()][0] & 0xff00) == 0x8800) - gUnknown_03005000.unk_00 = sub_800FFB0; + gUnknown_03005000.linkRfuCallback = sub_800FFB0; } } } @@ -3564,7 +3564,7 @@ static void sub_800FFB0(void) if (gUnknown_03005000.unk_6c.unk_02 <= gUnknown_03005000.unk_6c.unk_00) { gUnknown_03005000.unk_6c.unk_10 = 0; - gUnknown_03005000.unk_00 = rfufunc_80FA020; + gUnknown_03005000.linkRfuCallback = rfufunc_80FA020; } } @@ -3586,11 +3586,11 @@ static void rfufunc_80FA020(void) gUnknown_02022B44.unk_64++; } else - gUnknown_03005000.unk_00 = NULL; + gUnknown_03005000.linkRfuCallback = NULL; } } else - gUnknown_03005000.unk_00 = NULL; + gUnknown_03005000.linkRfuCallback = NULL; } bool8 sub_8010100(u8 a0) @@ -3606,7 +3606,7 @@ void sub_801011C(void) sub_800C048(); gReceivedRemoteLinkPlayers = 0; gUnknown_03005000.unk_ef = 1; - gUnknown_03005000.unk_00 = NULL; + gUnknown_03005000.linkRfuCallback = NULL; } void sub_8010148(void) @@ -3624,7 +3624,7 @@ void sub_8010168(void) gUnknown_03005000.unk_ce4 = 2; } else - gUnknown_03005000.unk_00 = sub_8010148; + gUnknown_03005000.linkRfuCallback = sub_8010148; } void LinkRfu_FatalError(void) @@ -3654,7 +3654,7 @@ void sub_80101CC(void) sub_8010168(); } else - gUnknown_03005000.unk_00 = sub_8010168; + gUnknown_03005000.linkRfuCallback = sub_8010168; } } @@ -3663,16 +3663,16 @@ void sub_801022C(void) if (gSendCmd[0] == 0 && gUnknown_03005000.unk_ce8 == 0) { sub_800FD14(0x5f00); - gUnknown_03005000.unk_00 = sub_80101CC; + gUnknown_03005000.linkRfuCallback = sub_80101CC; } } void sub_8010264(u8 taskId) { - if (gUnknown_03005000.unk_00 == NULL) + if (gUnknown_03005000.linkRfuCallback == NULL) { gUnknown_03005000.unk_cd9 = 1; - gUnknown_03005000.unk_00 = sub_801022C; + gUnknown_03005000.linkRfuCallback = sub_801022C; DestroyTask(taskId); } } @@ -3708,7 +3708,7 @@ void sub_80102B8(void) for (i = 0; i < MAX_RFU_PLAYERS; i++) gUnknown_03005000.unk_e9[i] = 0; gUnknown_03005000.unk_100++; - gUnknown_03005000.unk_00 = NULL; + gUnknown_03005000.linkRfuCallback = NULL; } gUnknown_03005000.unk_fe++; } @@ -3718,7 +3718,7 @@ void sub_8010358(void) if (gUnknown_03005000.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0) { sub_800FD14(0x6600); - gUnknown_03005000.unk_00 = sub_80102B8; + gUnknown_03005000.linkRfuCallback = sub_80102B8; } } @@ -3732,7 +3732,7 @@ void sub_8010390(void) if (gUnknown_03005000.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0) { sub_800FD14(0x6600); - gUnknown_03005000.unk_00 = sub_80102B8; + gUnknown_03005000.linkRfuCallback = sub_80102B8; } } else @@ -3748,7 +3748,7 @@ void sub_8010390(void) if (gUnknown_03005000.unk_124.unk_8c2 == 0 && gSendCmd[0] == 0) { sub_800FD14(0x6600); - gUnknown_03005000.unk_00 = sub_8010358; + gUnknown_03005000.linkRfuCallback = sub_8010358; } } } @@ -3756,9 +3756,9 @@ void sub_8010390(void) void sub_8010434(void) { - if (gUnknown_03005000.unk_00 == NULL) + if (gUnknown_03005000.linkRfuCallback == NULL) { - gUnknown_03005000.unk_00 = sub_8010390; + gUnknown_03005000.linkRfuCallback = sub_8010390; gUnknown_03005000.unk_fe = 0; } } @@ -3800,17 +3800,17 @@ u8 sub_80104F4(void) return gUnknown_03005000.playerCount; } -bool8 sub_8010500(void) +bool8 IsLinkRfuTaskFinished(void) { if (gUnknown_03005000.unk_f1 == 2) return FALSE; - return gUnknown_03005000.unk_00 ? FALSE : TRUE; + return gUnknown_03005000.linkRfuCallback ? FALSE : TRUE; } static void sub_8010528(void) { - if (gUnknown_03005000.unk_00) - gUnknown_03005000.unk_00(); + if (gUnknown_03005000.linkRfuCallback) + gUnknown_03005000.linkRfuCallback(); } bool8 sub_8010540(void) @@ -4255,11 +4255,11 @@ void sub_8010FA0(bool32 a0, bool32 a1) gUnknown_02022B14.unk_00.unk_00_5 = a1; } -void sub_8010FCC(u32 a0, u32 a1, u32 a2) +void sub_8010FCC(u32 type, u32 species, u32 level) { - gUnknown_02022B14.type = a0; - gUnknown_02022B14.species = a1; - gUnknown_02022B14.unk_0b_1 = a2; + gUnknown_02022B14.type = type; + gUnknown_02022B14.species = species; + gUnknown_02022B14.level = level; } u8 sub_801100C(s32 a0) @@ -4345,12 +4345,12 @@ void sub_80111B0(bool32 a0) void sub_80111DC(void) { sub_8011E94(gUnknown_03004140.unk_00, 1); - gUnknown_03005000.unk_00 = NULL; + gUnknown_03005000.linkRfuCallback = NULL; } void sub_80111FC(void) { - gUnknown_03005000.unk_00 = sub_80111DC; + gUnknown_03005000.linkRfuCallback = sub_80111DC; } void sub_801120C(u8 a0, u8 unused1) @@ -4979,7 +4979,7 @@ bool32 sub_801200C(s16 a1, struct UnkLinkRfuStruct_02022B14 *structPtr) return TRUE; } else if (structPtr->species != structPtr2->species - || structPtr->unk_0b_1 != structPtr2->unk_0b_1 + || structPtr->level != structPtr2->level || structPtr->type != structPtr2->type) { return TRUE; diff --git a/src/party_menu.c b/src/party_menu.c index cb6b53036..7f250ca1f 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -179,7 +179,7 @@ static void DisplayPartyPokemonGenderNidoranCheck(struct Pokemon *, struct Struc static void DisplayPartyPokemonHPCheck(struct Pokemon *, struct Struct203CEDC *, u8); static void DisplayPartyPokemonMaxHPCheck(struct Pokemon *, struct Struct203CEDC *, u8); static void DisplayPartyPokemonHPBarCheck(struct Pokemon *, struct Struct203CEDC *); -static void DisplayPartyPokemonOtherText(u8, struct Struct203CEDC *, u8); +static void DisplayPartyPokemonSelectionText(u8, struct Struct203CEDC *, u8); static u8 sub_81B8830(void); static bool8 GetBattleEntryEligibility(struct Pokemon *); static bool8 sub_81B218C(u8); @@ -207,7 +207,7 @@ static void sub_81B5F98(u8, u8); static u8 GetPartyBoxPalBitfield(u8, u8); static bool8 PartyBoxPal_ParnterOrDisqualifiedInArena(u8); static u8 sub_81B8F38(u8); -static void c3_0811FAB4(u8); +static void Task_ClosePartyMenuAndSetCB2(u8); static void sub_81B9080(void); static void sub_81B4F88(void); static void sub_81B15D0(u8, s8*); @@ -215,7 +215,7 @@ static void sub_81B140C(u8, s8*); static u16 PartyMenuButtonHandler(s8*); static s8* sub_81B13EC(void); static bool8 sub_81B15A4(u8*); -static void sub_81B302C(u8*); +static void PartyMenuRemoveWindow(u8*); static void sub_81B9140(void); static void sub_81B6794(u8); static void sub_81B7E4C(u8); @@ -236,7 +236,7 @@ static void UpdateCurrentPartySelection(s8*, s8); static void SetNewPartySelectTarget1(s8*, s8); static void SetNewPartySelectTarget2(s8*, s8); static s8 sub_81B1B00(s8, s8); -static void sub_81B3300(const u8*); +static void PartyMenuPrintText(const u8*); static void sub_81B1B8C(u8); static void DisplayPartyPokemonHPCheck(struct Pokemon*, struct Struct203CEDC*, u8); static void DisplayPartyPokemonHPBarCheck(struct Pokemon*, struct Struct203CEDC*); @@ -294,7 +294,7 @@ static void sub_81B5B38(u8, struct Pokemon*); static void UpdatePartyMonIconFrame(struct Sprite*); static void UpdatePartyMonIconFrameAndBounce(struct Sprite*); static void sub_81B5CB0(u16, struct Struct203CEDC*); -static void sub_81B5DF0(u8, u8); +static void CreateHeldItemSpriteForTrade(u8, bool8); static void SpriteCB_HeldItem(struct Sprite*); static void party_menu_get_status_condition_and_update_object(struct Pokemon*, struct Struct203CEDC*); static void party_menu_update_status_condition_object(u8, struct Struct203CEDC*); @@ -1196,17 +1196,17 @@ struct [FIELD_MOVE_SWEET_SCENT] = {SetUpFieldMove_SweetScent, 0x0d}, }; -static const u8 *const gUnknown_08615E0C[] = +static const u8 *const sUnionRoomTradeMessages[] = { - gText_NotPkmnOtherTrainerWants, - gText_ThatIsntAnEgg, - gText_PkmnCantBeTradedNow, - gText_PkmnCantBeTradedNow, - gText_OtherTrainersPkmnCantBeTraded, - gText_EggCantBeTradedNow, - gText_OtherTrainerCantAcceptPkmn, - gText_CantTradeWithTrainer, - gText_CantTradeWithTrainer, + [UR_TRADE_MSG_NOT_MON_PARTNER_WANTS - 1] = gText_NotPkmnOtherTrainerWants, + [UR_TRADE_MSG_NOT_EGG - 1] = gText_ThatIsntAnEgg, + [UR_TRADE_MSG_MON_CANT_BE_TRADED_1 - 1] = gText_PkmnCantBeTradedNow, + [UR_TRADE_MSG_MON_CANT_BE_TRADED_2 - 1] = gText_PkmnCantBeTradedNow, + [UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED - 1] = gText_OtherTrainersPkmnCantBeTraded, + [UR_TRADE_MSG_EGG_CANT_BE_TRADED -1] = gText_EggCantBeTradedNow, + [UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON - 1] = gText_OtherTrainerCantAcceptPkmn, + [UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_1 - 1] = gText_CantTradeWithTrainer, + [UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_2 - 1] = gText_CantTradeWithTrainer, }; static const u32 sHeldItemGfx[] = INCBIN_U32("graphics/interface/hold_icons.4bpp"); @@ -1752,7 +1752,7 @@ static bool8 PartyMenuSetup(void) break; case 20: CreateTask(gUnknown_0203CEC4->task, 0); - display_pokemon_menu_message(gUnknown_0203CEC4->messageId); + DisplayPartyMenuStdMessage(gUnknown_0203CEC4->messageId); gMain.state++; break; case 21: @@ -1988,7 +1988,7 @@ static void DisplayPartyPokemonSelectData(u8 slot, u8 stringID) DisplayPartyPokemonLevelCheck(mon, &gUnknown_0203CEDC[slot], 0); DisplayPartyPokemonGenderNidoranCheck(mon, &gUnknown_0203CEDC[slot], 0); } - DisplayPartyPokemonOtherText(stringID, &gUnknown_0203CEDC[slot], 0); + DisplayPartyPokemonSelectionText(stringID, &gUnknown_0203CEDC[slot], 0); } static void DisplayPartyPokemonSelectForBattle(u8 slot) @@ -2308,13 +2308,13 @@ static void sub_81B1288(struct Pokemon *partySlot, struct Pokemon *pokemon) Free(temp); } -static void sub_81B12C0(u8 taskId) +static void Task_ClosePartyMenu(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gTasks[taskId].func = c3_0811FAB4; + gTasks[taskId].func = Task_ClosePartyMenuAndSetCB2; } -static void c3_0811FAB4(u8 taskId) +static void Task_ClosePartyMenuAndSetCB2(u8 taskId) { if (!gPaletteFade.active) { @@ -2388,7 +2388,7 @@ static void sub_81B140C(u8 taskId, s8 *ptr) case 7: if (sub_81B15A4((u8*)ptr)) { - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81615A8(taskId); } break; @@ -2398,7 +2398,7 @@ static void sub_81B140C(u8 taskId, s8 *ptr) if (gUnknown_0203CEC8.unk8_0 == 1) gUnknown_0203CEC4->exitCallback = sub_81B9140; - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); gUnknown_03006328(taskId, sub_81B6794); } break; @@ -2406,7 +2406,7 @@ static void sub_81B140C(u8 taskId, s8 *ptr) if (sub_81B15A4((u8*)ptr)) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81B7E4C(taskId); } break; @@ -2414,7 +2414,7 @@ static void sub_81B140C(u8 taskId, s8 *ptr) if (sub_81B15A4((u8*)ptr)) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81B8474(taskId); } break; @@ -2423,7 +2423,7 @@ static void sub_81B140C(u8 taskId, s8 *ptr) if (sub_81B15A4((u8*)ptr)) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81B7FAC(taskId); } break; @@ -2433,7 +2433,7 @@ static void sub_81B140C(u8 taskId, s8 *ptr) break; case 8: PlaySE(SE_SELECT); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; case 10: if (sub_81B15A4((u8*)ptr)) @@ -2485,7 +2485,7 @@ static void sub_81B15D0(u8 taskId, s8 *ptr) gSpecialVar_0x8004 = 7; gUnknown_0203CEE8 = 0; *ptr = 7; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } break; } @@ -2503,9 +2503,9 @@ static bool8 sub_81B1660(u8 taskId) if (stringPtr == NULL) return FALSE; - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); StringExpandPlaceholders(gStringVar4, stringPtr); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B16D4; return TRUE; } @@ -2527,7 +2527,7 @@ static void sub_81B1708(u8 taskId) gUnknown_0203CEE8 = 0; gUnknown_0203CEC8.slotId = 7; sub_81B8558(); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); @@ -2782,11 +2782,11 @@ u8* GetMonNickname(struct Pokemon *mon, u8 *dest) return StringGetEnd10(dest); } -u8 sub_81B1B5C(const u8* str, u8 b) +u8 DisplayPartyMenuMessage(const u8* str, u8 b) { u8 taskId; - sub_81B3300(str); + PartyMenuPrintText(str); taskId = CreateTask(sub_81B1B8C, 1); gTasks[taskId].data[0] = b; return taskId; @@ -2814,7 +2814,7 @@ static void sub_81B1BE8(u8 taskId) { if (sub_81221EC() != TRUE) { - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } } @@ -2831,7 +2831,7 @@ static void sub_81B1C1C(u8 taskId) } else { - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } } @@ -2842,7 +2842,7 @@ static void sub_81B1C84(struct Pokemon *mon, u16 item, u8 c, u8 unused) GetMonNickname(mon, gStringVar1); CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_PkmnWasGivenItem); - sub_81B1B5C(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, c); schedule_bg_copy_tilemap_to_vram(2); } @@ -2851,7 +2851,7 @@ static void sub_81B1CD0(struct Pokemon *mon, u16 item, u8 c) GetMonNickname(mon, gStringVar1); CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_ReceivedItemFromPkmn); - sub_81B1B5C(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, c); schedule_bg_copy_tilemap_to_vram(2); } @@ -2860,7 +2860,7 @@ static void sub_81B1D1C(struct Pokemon *mon, u16 item, u8 c) GetMonNickname(mon, gStringVar1); CopyItemName(item, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_SwitchPkmnItem); - sub_81B1B5C(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, c); schedule_bg_copy_tilemap_to_vram(2); } @@ -2869,7 +2869,7 @@ static void sub_81B1D68(u16 item, u16 item2, u8 c) CopyItemName(item, gStringVar1); CopyItemName(item2, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_SwitchedPkmnItem); - sub_81B1B5C(gStringVar4, c); + DisplayPartyMenuMessage(gStringVar4, c); schedule_bg_copy_tilemap_to_vram(2); } @@ -3046,12 +3046,12 @@ static void sub_81B21AC(u8 taskId, u8 slot) { PlaySE(SE_SELECT); gSpecialVar_0x8004 = slot; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } else { PlaySE(SE_HAZURE); - sub_81B1B5C(gText_PkmnCantParticipate, 0); + DisplayPartyMenuMessage(gText_PkmnCantParticipate, 0); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B1C1C; } @@ -3059,7 +3059,7 @@ static void sub_81B21AC(u8 taskId, u8 slot) static void sub_81B2210(u8 taskId) { - sub_81B1B5C(gText_CancelParticipation, 1); + DisplayPartyMenuMessage(gText_CancelParticipation, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B2248; } @@ -3079,7 +3079,7 @@ static void sub_81B227C(u8 taskId) { case 0: gSpecialVar_0x8004 = 7; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); @@ -3531,7 +3531,7 @@ static void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct Struct203CEDC *pt CopyWindowToVram(ptr->windowId, 2); } -static void DisplayPartyPokemonOtherText(u8 stringID, struct Struct203CEDC *ptr, u8 c) +static void DisplayPartyPokemonSelectionText(u8 stringID, struct Struct203CEDC *ptr, u8 c) { if (c != 0) { @@ -3543,7 +3543,7 @@ static void DisplayPartyPokemonOtherText(u8 stringID, struct Struct203CEDC *ptr, AddTextPrinterParameterized3(ptr->windowId, 1, ptr->unk0->unk1C, ptr->unk0->unk1D, sFontColorTable[0], 0, sSelectionStringTable[stringID]); } -static void sub_81B302C(u8 *ptr) +static void PartyMenuRemoveWindow(u8 *ptr) { if (*ptr != 0xFF) { @@ -3554,12 +3554,12 @@ static void sub_81B302C(u8 *ptr) } } -void display_pokemon_menu_message(u32 stringID) +void DisplayPartyMenuStdMessage(u32 stringID) { u8 *windowPtr = &gUnknown_0203CEC4->windowId[1]; if (*windowPtr != 0xFF) - sub_81B302C(windowPtr); + PartyMenuRemoveWindow(windowPtr); if (stringID != 0x7F) { @@ -3660,7 +3660,7 @@ static u8 sub_81B31B0(u8 a) return gUnknown_0203CEC4->windowId[0]; } -static void sub_81B3300(const u8 *text) +static void PartyMenuPrintText(const u8 *text) { DrawStdFrameWithCustomTileAndPalette(6, FALSE, 0x4F, 13); gTextFlags.canABSpeedUpPrint = TRUE; @@ -3682,7 +3682,7 @@ static u8 sub_81B3364(void) static void sub_81B3394(void) { ClearWindowTilemap(gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); } static void sub_81B33B4(struct Pokemon *mons, u8 slotId, u8 b) @@ -3788,12 +3788,12 @@ static bool8 sub_81B3608(u8 taskId) u16 item; GetMonNickname(mon, gStringVar1); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); if (gUnknown_0203CEC8.unk8_0 != 12) { sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, sub_81B353C(mon)); sub_81B31B0(0); - display_pokemon_menu_message(21); + DisplayPartyMenuStdMessage(21); } else { @@ -3803,12 +3803,12 @@ static bool8 sub_81B3608(u8 taskId) sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, sub_81B353C(mon)); sub_81B31B0(1); CopyItemName(item, gStringVar2); - display_pokemon_menu_message(26); + DisplayPartyMenuStdMessage(26); } else { StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B469C; return FALSE; @@ -3845,11 +3845,11 @@ static void HandleMenuInput(u8 taskId) break; case MENU_B_PRESSED: PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[2]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[2]); sCursorOptions[gUnknown_0203CEC4->actions[gUnknown_0203CEC4->listSize - 1]].func(taskId); break; default: - sub_81B302C(&gUnknown_0203CEC4->windowId[2]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[2]); sCursorOptions[gUnknown_0203CEC4->actions[input]].func(taskId); break; } @@ -3860,7 +3860,7 @@ static void CursorCb_Summary(u8 taskId) { PlaySE(SE_SELECT); gUnknown_0203CEC4->exitCallback = sub_81B3828; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } static void sub_81B3828(void) @@ -3887,9 +3887,9 @@ static void CursorCb_Switch(u8 taskId) { PlaySE(SE_SELECT); gUnknown_0203CEC8.unkB = 8; - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - display_pokemon_menu_message(3); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + DisplayPartyMenuStdMessage(3); sub_81B0FCC(gUnknown_0203CEC8.slotId, 1); gUnknown_0203CEC8.unkA = gUnknown_0203CEC8.slotId; gTasks[taskId].func = sub_81B1370; @@ -4105,35 +4105,35 @@ static void swap_pokemon_and_oams(void) static void sub_81B407C(u8 taskId) { - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); gUnknown_0203CEC8.unkB = 0; sub_81B0FCC(gUnknown_0203CEC8.slotId, 0); gUnknown_0203CEC8.slotId = gUnknown_0203CEC8.unkA; sub_81B0FCC(gUnknown_0203CEC8.unkA, 1); - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } static void CursorCb_Cancel1(u8 taskId) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); if (gUnknown_0203CEC8.unk8_0 == 6) - display_pokemon_menu_message(15); + DisplayPartyMenuStdMessage(15); else - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } static void CursorCb_Item(u8 taskId) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, 8); sub_81B31B0(1); - display_pokemon_menu_message(24); + DisplayPartyMenuStdMessage(24); gTasks[taskId].data[0] = 0xFF; gTasks[taskId].func = HandleMenuInput; } @@ -4142,7 +4142,7 @@ static void CursorCb_Give(u8 taskId) { PlaySE(SE_SELECT); gUnknown_0203CEC4->exitCallback = sub_81B41C4; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } static void sub_81B41C4(void) @@ -4221,7 +4221,7 @@ static void sub_81B43DC(u8 taskId) { AddBagItem(gSpecialVar_ItemId, 1); pokemon_item_not_removed(gUnknown_0203CEFC); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); gTasks[taskId].func = sub_81B1C1C; } else if (ItemIsMail(gSpecialVar_ItemId)) @@ -4249,7 +4249,7 @@ static void sub_81B44FC(u8 taskId) if (sub_81B1BD4() != TRUE) { gUnknown_0203CEC4->exitCallback = sub_81B452C; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } @@ -4305,9 +4305,9 @@ static void sub_81B469C(u8 taskId) if (gUnknown_0203CEC8.unk8_0 == 12) { if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE) - DisplayPartyPokemonOtherText(11, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonSelectionText(11, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); else - DisplayPartyPokemonOtherText(12, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonSelectionText(12, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); } sub_81B1C1C(taskId); } @@ -4319,18 +4319,18 @@ static void CursorCb_TakeItem(u8 taskId) u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); switch (TryTakeMonItem(mon)) { case 0: GetMonNickname(mon, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); break; case 1: pokemon_item_not_removed(item); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); break; default: sub_81B1CD0(mon, item, 1); @@ -4346,20 +4346,20 @@ static void CursorCb_Toss(u8 taskId) u16 item = GetMonData(mon, MON_DATA_HELD_ITEM); PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); if (item == ITEM_NONE) { GetMonNickname(mon, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnNotHolding); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B469C; } else { CopyItemName(item, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_ThrowAwayItem); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B48A8; } } @@ -4382,7 +4382,7 @@ static void sub_81B48DC(u8 taskId) case 0: CopyItemName(GetMonData(mon, MON_DATA_HELD_ITEM), gStringVar1); StringExpandPlaceholders(gStringVar4, gText_ItemThrownAway); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); gTasks[taskId].func = sub_81B4988; break; case MENU_B_PRESSED: @@ -4403,7 +4403,7 @@ static void sub_81B4988(u8 taskId) SetMonData(mon, MON_DATA_HELD_ITEM, &item); sub_81B5C94(mon, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId]); - DisplayPartyPokemonOtherText(12, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonSelectionText(12, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); gTasks[taskId].func = sub_81B1C1C; } } @@ -4411,11 +4411,11 @@ static void sub_81B4988(u8 taskId) static void CursorCb_Mail(u8 taskId) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, 9); sub_81B31B0(2); - display_pokemon_menu_message(25); + DisplayPartyMenuStdMessage(25); gTasks[taskId].data[0] = 0xFF; gTasks[taskId].func = HandleMenuInput; } @@ -4424,7 +4424,7 @@ static void CursorCb_Read(u8 taskId) { PlaySE(SE_SELECT); gUnknown_0203CEC4->exitCallback = sub_81B4A98; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } static void sub_81B4A98(void) @@ -4441,9 +4441,9 @@ static void sub_81B4AE0(void) static void CursorCb_TakeMail(u8 taskId) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B1B5C(gText_SendMailToPC, 1); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + DisplayPartyMenuMessage(gText_SendMailToPC, 1); gTasks[taskId].func = sub_81B4B6C; } @@ -4463,19 +4463,19 @@ static void sub_81B4BA0(u8 taskId) case 0: if (TakeMailFromMon2(&gPlayerParty[gUnknown_0203CEC8.slotId]) != 0xFF) { - sub_81B1B5C(gText_MailSentToPC, 0); + DisplayPartyMenuMessage(gText_MailSentToPC, 0); gTasks[taskId].func = sub_81B469C; } else { - sub_81B1B5C(gText_PCMailboxFull, 0); + DisplayPartyMenuMessage(gText_PCMailboxFull, 0); gTasks[taskId].func = sub_81B1C1C; } break; case MENU_B_PRESSED: PlaySE(SE_SELECT); case 1: - sub_81B1B5C(gText_MailMessageWillBeLost, 1); + DisplayPartyMenuMessage(gText_MailMessageWillBeLost, 1); gTasks[taskId].func = sub_81B4C60; break; } @@ -4501,13 +4501,13 @@ static void sub_81B4C94(u8 taskId) if (AddBagItem(item, 1) == TRUE) { TakeMailFromMon(&gPlayerParty[gUnknown_0203CEC8.slotId]); - sub_81B1B5C(gText_MailTakenFromPkmn, 0); + DisplayPartyMenuMessage(gText_MailTakenFromPkmn, 0); gTasks[taskId].func = sub_81B469C; } else { pokemon_item_not_removed(item); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); gTasks[taskId].func = sub_81B1C1C; } break; @@ -4524,19 +4524,19 @@ static void CursorCb_Cancel2(u8 taskId) struct Pokemon *mon = &gPlayerParty[gUnknown_0203CEC8.slotId]; PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); sub_81B33B4(gPlayerParty, gUnknown_0203CEC8.slotId, sub_81B353C(mon)); if (gUnknown_0203CEC8.unk8_0 != 12) { sub_81B31B0(0); - display_pokemon_menu_message(21); + DisplayPartyMenuStdMessage(21); } else { sub_81B31B0(1); CopyItemName(GetMonData(mon, MON_DATA_HELD_ITEM), gStringVar2); - display_pokemon_menu_message(26); + DisplayPartyMenuStdMessage(26); } gTasks[taskId].data[0] = 0xFF; gTasks[taskId].func = HandleMenuInput; @@ -4545,15 +4545,15 @@ static void CursorCb_Cancel2(u8 taskId) static void CursorCb_SendMon(u8 taskId) { PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); if (sub_81B8A7C() == TRUE) { - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } else { - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); - sub_81B1B5C(gStringVar4, 1); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B1C1C; } } @@ -4563,8 +4563,8 @@ static void CursorCb_Enter(u8 taskId) u8 unk; u8 i; - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); unk = sub_81B8830(); for (i = 0; i < unk; i++) { @@ -4572,10 +4572,10 @@ static void CursorCb_Enter(u8 taskId) { PlaySE(SE_SELECT); gSelectedOrderFromParty[i] = gUnknown_0203CEC8.slotId + 1; - DisplayPartyPokemonOtherText(i + 2, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonSelectionText(i + 2, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); if (i == (unk - 1)) sub_81B4F88(); - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; return; } @@ -4583,7 +4583,7 @@ static void CursorCb_Enter(u8 taskId) ConvertIntToDecimalStringN(gStringVar1, unk, STR_CONV_MODE_LEFT_ALIGN, 1); StringExpandPlaceholders(gStringVar4, gText_NoMoreThanVar1Pkmn); PlaySE(SE_HAZURE); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B1C1C; } @@ -4600,8 +4600,8 @@ static void CursorCb_NoEntry(u8 taskId) u8 i, j; PlaySE(SE_SELECT); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); unk = sub_81B8830(); for (i = 0; i < unk; i++) { @@ -4613,46 +4613,47 @@ static void CursorCb_NoEntry(u8 taskId) break; } } - DisplayPartyPokemonOtherText(1, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); + DisplayPartyPokemonSelectionText(1, &gUnknown_0203CEDC[gUnknown_0203CEC8.slotId], 1); for (i = 0; i < (unk - 1); i++) { if (gSelectedOrderFromParty[i] != 0) - DisplayPartyPokemonOtherText(i + 2, &gUnknown_0203CEDC[gSelectedOrderFromParty[i] - 1], 1); + DisplayPartyPokemonSelectionText(i + 2, &gUnknown_0203CEDC[gSelectedOrderFromParty[i] - 1], 1); } - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } static void CursorCb_Store(u8 taskId) { PlaySE(SE_SELECT); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } +// Register mon for the Trading Board in Union Room static void CursorCb_Register(u8 taskId) { u16 species2 = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES); u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_OBEDIENCE); - switch (sub_807A8D0(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), species2, species, obedience)) + switch (CanRegisterMonForTradingBoard(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), species2, species, obedience)) { - case 1: + case CANT_REGISTER_MON: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); break; - case 2: + case CANT_REGISTER_EGG: StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); break; default: PlaySE(SE_SELECT); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); return; } PlaySE(SE_HAZURE); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); StringAppend(gStringVar4, gText_PauseUntilPress); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B1C1C; } @@ -4661,51 +4662,51 @@ static void CursorCb_Trade1(u8 taskId) u16 species2 = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES2); u16 species = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_SPECIES); u8 obedience = GetMonData(&gPlayerParty[gUnknown_0203CEC8.slotId], MON_DATA_OBEDIENCE); - u32 stringId = sub_807A7E0(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), gUnknown_02022C38, species2, gUnknown_02022C3C, gUnknown_02022C3E, species, obedience); + u32 stringId = GetUnionRoomTradeMessageId(*(struct UnkLinkRfuStruct_02022B14Substruct *)sub_800F7DC(), gUnknown_02022C38, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, obedience); - if (stringId != 0) + if (stringId != UR_TRADE_MSG_NONE) { - StringExpandPlaceholders(gStringVar4, gUnknown_08615E0C[stringId - 1]); + StringExpandPlaceholders(gStringVar4, sUnionRoomTradeMessages[stringId - 1]); PlaySE(SE_HAZURE); - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); StringAppend(gStringVar4, gText_PauseUntilPress); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B1C1C; } else { PlaySE(SE_SELECT); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } static void CursorCb_Trade2(u8 taskId) { - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); - switch (sub_807A918(gPlayerParty, gUnknown_0203CEC8.slotId)) + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); + switch (CanTradeSelectedPartyMenuMon(gPlayerParty, gUnknown_0203CEC8.slotId)) { - case 1: + case CANT_TRADE_LAST_MON: StringExpandPlaceholders(gStringVar4, gText_OnlyPkmnForBattle); break; - case 2: + case CANT_TRADE_NATIONAL: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); break; - case 3: + case CANT_TRADE_EGG: StringExpandPlaceholders(gStringVar4, gText_EggCantBeTradedNow); break; default: PlaySE(SE_SELECT); GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gJPText_PutVar1IntoSpinner); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B53FC; return; } PlaySE(SE_HAZURE); StringAppend(gStringVar4, gText_PauseUntilPress); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B1C1C; } @@ -4723,7 +4724,7 @@ static void sub_81B5430(u8 taskId) switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); @@ -4742,14 +4743,14 @@ static void CursorCb_FieldMove(u8 taskId) if (sFieldMoveCursorCallbacks[fieldMove].fieldMoveFunc == NULL) return; - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) { if (fieldMove == FIELD_MOVE_MILK_DRINK || fieldMove == FIELD_MOVE_SOFT_BOILED) - display_pokemon_menu_message(13); + DisplayPartyMenuStdMessage(13); else - display_pokemon_menu_message(sFieldMoveCursorCallbacks[fieldMove].msgId); + DisplayPartyMenuStdMessage(sFieldMoveCursorCallbacks[fieldMove].msgId); gTasks[taskId].func = task_brm_cancel_1_on_keypad_a_or_b; } @@ -4758,7 +4759,7 @@ static void CursorCb_FieldMove(u8 taskId) // All field moves before WATERFALL are HMs. if (fieldMove <= FIELD_MOVE_WATERFALL && FlagGet(FLAG_BADGE01_GET + fieldMove) != TRUE) { - sub_81B1B5C(gText_CantUseUntilNewBadge, 1); + DisplayPartyMenuMessage(gText_CantUseUntilNewBadge, 1); gTasks[taskId].func = sub_81B1C1C; } else if (sFieldMoveCursorCallbacks[fieldMove].fieldMoveFunc() == TRUE) @@ -4785,11 +4786,11 @@ static void CursorCb_FieldMove(u8 taskId) break; case FIELD_MOVE_FLY: gUnknown_0203CEC8.exitCallback = MCB2_FlyMap; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; default: gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; } } @@ -4804,7 +4805,7 @@ static void CursorCb_FieldMove(u8 taskId) sub_81B57DC(); break; default: - display_pokemon_menu_message(sFieldMoveCursorCallbacks[fieldMove].msgId); + DisplayPartyMenuStdMessage(sFieldMoveCursorCallbacks[fieldMove].msgId); break; } gTasks[taskId].func = task_brm_cancel_1_on_keypad_a_or_b; @@ -4814,7 +4815,7 @@ static void CursorCb_FieldMove(u8 taskId) static void sub_81B5674(u8 taskId) { - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); gTasks[taskId].func = sub_81B56A4; } @@ -4833,7 +4834,7 @@ static void sub_81B56D8(u8 taskId) { case 0: gUnknown_0203CEC8.exitCallback = CB2_ReturnToField; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); break; case MENU_B_PRESSED: PlaySE(SE_SELECT); @@ -4876,9 +4877,9 @@ static void task_brm_cancel_1_on_keypad_a_or_b(u8 taskId) static void sub_81B57DC(void) { if (FlagGet(FLAG_SYS_USE_FLASH) == TRUE) - display_pokemon_menu_message(12); + DisplayPartyMenuStdMessage(12); else - display_pokemon_menu_message(13); + DisplayPartyMenuStdMessage(13); } static void hm_surf_run_dp02scr(void) @@ -4901,9 +4902,9 @@ static bool8 SetUpFieldMove_Surf(void) static void sub_81B5864(void) { if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) - display_pokemon_menu_message(9); + DisplayPartyMenuStdMessage(9); else - display_pokemon_menu_message(8); + DisplayPartyMenuStdMessage(8); } static bool8 SetUpFieldMove_Fly(void) @@ -4973,7 +4974,7 @@ static void party_menu_link_mon_icon_anim(u16 species, u32 pid, struct Struct203 { if (species != SPECIES_NONE) { - ptr->monSpriteId = CreateMonIcon(species, sub_80D3014, ptr->unk4[0], ptr->unk4[1], 4, pid, bit); + ptr->monSpriteId = CreateMonIcon(species, UpdateTradeMonIconFrame, ptr->unk4[0], ptr->unk4[1], 4, pid, bit); gSprites[ptr->monSpriteId].oam.priority = priority; } } @@ -4983,19 +4984,19 @@ static void sub_81B5A8C(u8 spriteId, u16 hp, u16 maxhp) switch (GetHPBarLevel(hp, maxhp)) { case HP_BAR_FULL: - sub_80D32C8(&gSprites[spriteId], 0); + SetPartyHPBarSprite(&gSprites[spriteId], 0); break; case HP_BAR_GREEN: - sub_80D32C8(&gSprites[spriteId], 1); + SetPartyHPBarSprite(&gSprites[spriteId], 1); break; case HP_BAR_YELLOW: - sub_80D32C8(&gSprites[spriteId], 2); + SetPartyHPBarSprite(&gSprites[spriteId], 2); break; case HP_BAR_RED: - sub_80D32C8(&gSprites[spriteId], 3); + SetPartyHPBarSprite(&gSprites[spriteId], 3); break; default: - sub_80D32C8(&gSprites[spriteId], 4); + SetPartyHPBarSprite(&gSprites[spriteId], 4); break; } } @@ -5094,33 +5095,33 @@ void LoadHeldItemIcons(void) LoadSpritePalette(&sSpritePalette_HeldItem); } -void sub_81B5D4C(u8 *a, u8 *b, u8 c) +void DrawHeldItemIconsForTrade(u8 *partyCounts, u8 *partySpriteIds, u8 whichParty) { u16 i; u16 item; - switch (c) + switch (whichParty) { - case 0: - for (i = 0; i < a[0]; i++) + case TRADE_PLAYER: + for (i = 0; i < partyCounts[TRADE_PLAYER]; i++) { item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); if (item != ITEM_NONE) - sub_81B5DF0(b[i], ItemIsMail(item)); + CreateHeldItemSpriteForTrade(partySpriteIds[i], ItemIsMail(item)); } break; - case 1: - for (i = 0; i < a[1]; i++) + case TRADE_PARTNER: + for (i = 0; i < partyCounts[TRADE_PARTNER]; i++) { item = GetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM); if (item != ITEM_NONE) - sub_81B5DF0(b[i + 6], ItemIsMail(item)); + CreateHeldItemSpriteForTrade(partySpriteIds[i + PARTY_SIZE], ItemIsMail(item)); } break; } } -static void sub_81B5DF0(u8 spriteId, u8 isMail) +static void CreateHeldItemSpriteForTrade(u8 spriteId, bool8 isMail) { u8 subpriority = gSprites[spriteId].subpriority; u8 newSpriteId = CreateSprite(&sSpriteTemplate_HeldItem, 250, 170, subpriority - 1); @@ -5440,7 +5441,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) iTriedHonestlyIDid: gUnknown_0203CEE8 = 0; PlaySE(SE_SELECT); - sub_81B1B5C(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; return; @@ -5476,7 +5477,7 @@ void ItemUseCB_Medicine(u8 taskId, TaskFunc task) { GetMonNickname(mon, gStringVar1); GetMedicineItemEffectMessage(item); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -5486,7 +5487,7 @@ static void sub_81B672C(u8 taskId) { GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); schedule_bg_copy_tilemap_to_vram(2); HandleBattleLowHpMusicChange(); gTasks[taskId].func = sub_81B6794; @@ -5498,7 +5499,7 @@ static void sub_81B6794(u8 taskId) { if (gUnknown_0203CEE8 == 0) gUnknown_0203CEC4->exitCallback = NULL; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } @@ -5517,7 +5518,7 @@ void sub_81B67C8(u8 taskId, TaskFunc task) { gUnknown_0203CEE8 = 0; PlaySE(SE_SELECT); - sub_81B1B5C(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -5539,7 +5540,7 @@ void sub_81B67C8(u8 taskId, TaskFunc task) { StringExpandPlaceholders(gStringVar4, gText_PkmnAdoresBaseVar2Fell); } - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -5624,7 +5625,7 @@ static void ether_effect_related_3(u8 taskId) } else { - sub_81B302C(&gUnknown_0203CEC4->windowId[1]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); ether_effect_related_2(taskId); } } @@ -5648,7 +5649,7 @@ void dp05_ether(u8 taskId, TaskFunc task) else { PlaySE(SE_SELECT); - display_pokemon_menu_message(22); + DisplayPartyMenuStdMessage(22); sub_81B6A10(gUnknown_0203CEC8.slotId); gTasks[taskId].func = ether_effect_related_3; } @@ -5656,7 +5657,7 @@ void dp05_ether(u8 taskId, TaskFunc task) static void ether_effect_related_2(u8 taskId) { - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); gUnknown_0203CEC8.unkE = Menu_GetCursorPos(); ether_effect_related(taskId); } @@ -5665,8 +5666,8 @@ static void sub_81B6BB4(u8 taskId) { gTasks[taskId].func = sub_81B1370; gUnknown_0203CEC4->exitCallback = NULL; - sub_81B302C(&gUnknown_0203CEC4->windowId[0]); - display_pokemon_menu_message(5); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + DisplayPartyMenuStdMessage(5); } static void ether_effect_related(u8 taskId) @@ -5681,7 +5682,7 @@ static void ether_effect_related(u8 taskId) { gUnknown_0203CEE8 = 0; PlaySE(SE_SELECT); - sub_81B1B5C(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B6794; } @@ -5694,7 +5695,7 @@ static void ether_effect_related(u8 taskId) move = GetMonData(mon, MON_DATA_MOVE1 + *moveslot); StringCopy(gStringVar1, gMoveNames[move]); GetMedicineItemEffectMessage(item); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B6794; } @@ -5703,7 +5704,7 @@ static void ether_effect_related(u8 taskId) void dp05_pp_up(u8 taskId, TaskFunc task) { PlaySE(SE_SELECT); - display_pokemon_menu_message(23); + DisplayPartyMenuStdMessage(23); sub_81B6A10(gUnknown_0203CEC8.slotId); gTasks[taskId].func = ether_effect_related_3; } @@ -5741,7 +5742,7 @@ bool8 MonKnowsMove(struct Pokemon *mon, u16 move) static void sub_81B6D74(const u8 *str) { StringExpandPlaceholders(gStringVar4, str); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); } @@ -5804,7 +5805,7 @@ static void sub_81B6EB4(u8 taskId) GetMonNickname(mon, gStringVar1); StringCopy(gStringVar2, gMoveNames[move[0]]); StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B6F60; } @@ -5828,7 +5829,7 @@ static void sub_81B6F98(u8 taskId) { if (gUnknown_0203CEC8.unk10 == 2) gSpecialVar_Result = TRUE; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } } @@ -5847,7 +5848,7 @@ static void sub_81B7028(u8 taskId) switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - sub_81B1B5C(gText_WhichMoveToForget, 1); + DisplayPartyMenuMessage(gText_WhichMoveToForget, 1); gTasks[taskId].func = sub_81B7088; break; case MENU_B_PRESSED: @@ -5863,7 +5864,7 @@ static void sub_81B7088(u8 taskId) if (sub_81B1BD4() != TRUE) { gUnknown_0203CEC4->exitCallback = sub_81B70B8; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } @@ -5918,7 +5919,7 @@ static void sub_81B7230(u8 taskId) { StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); StringExpandPlaceholders(gStringVar4, gText_StopLearningMove2); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B7294; } @@ -5942,7 +5943,7 @@ static void sub_81B72C8(u8 taskId) GetMonNickname(mon, gStringVar1); StringCopy(gStringVar2, gMoveNames[gUnknown_0203CEC8.unkE]); StringExpandPlaceholders(gStringVar4, gText_MoveNotLearned); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); if (gUnknown_0203CEC8.unk10 == 1) { gTasks[taskId].func = sub_81B73E4; @@ -5993,7 +5994,7 @@ void dp05_rare_candy(u8 taskId, TaskFunc task) if (cannotUseEffect) { gUnknown_0203CEE8 = 0; - sub_81B1B5C(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -6006,7 +6007,7 @@ void dp05_rare_candy(u8 taskId, TaskFunc task) GetMonNickname(mon, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, GetMonData(mon, MON_DATA_LEVEL), STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_PkmnElevatedToLvVar2); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B75D4; } @@ -6134,7 +6135,7 @@ static void sub_81B787C(u8 taskId) GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); StringCopy(gStringVar2, gMoveNames[gMoveToLearn]); StringExpandPlaceholders(gStringVar4, gText_PkmnNeedsToReplaceMove); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gUnknown_0203CEC8.unkE = gMoveToLearn; gTasks[taskId].func = sub_81B6FF4; @@ -6145,7 +6146,7 @@ static void sub_81B7910(u8 taskId, u16 move) GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); StringCopy(gStringVar2, gMoveNames[move]); StringExpandPlaceholders(gStringVar4, gText_PkmnLearnedMove3); - sub_81B1B5C(gStringVar4, 1); + DisplayPartyMenuMessage(gStringVar4, 1); schedule_bg_copy_tilemap_to_vram(2); gUnknown_0203CEC8.unkE = move; gTasks[taskId].func = sub_81B6F60; @@ -6213,7 +6214,7 @@ static void task_sacred_ash_party_loop(u8 taskId) if (gUnknown_0203CEC4->data[1] == 0) { gUnknown_0203CEE8 = 0; - sub_81B1B5C(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, 1); schedule_bg_copy_tilemap_to_vram(2); } else @@ -6235,7 +6236,7 @@ static void sub_81B7C10(u8 taskId) { GetMonNickname(&gPlayerParty[gUnknown_0203CEC8.slotId], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_PkmnHPRestoredByVar2); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task_sacred_ash_party_loop; } @@ -6247,7 +6248,7 @@ void sub_81B7C74(u8 taskId, TaskFunc task) if (ExecuteTableBasedItemEffect__(gUnknown_0203CEC8.slotId, gSpecialVar_ItemId, 0)) { gUnknown_0203CEE8 = 0; - sub_81B1B5C(gText_WontHaveEffect, 1); + DisplayPartyMenuMessage(gText_WontHaveEffect, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = task; } @@ -6396,7 +6397,7 @@ static void sub_81B8044(u8 taskId) { sub_81B83F0(gUnknown_0203CEC8.unkC); gUnknown_0203CEC4->exitCallback = sub_81B814C; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } else { @@ -6425,7 +6426,7 @@ static void sub_81B8104(u8 taskId) if (sub_81B1BD4() != TRUE) { sub_81B5C94(&gPlayerParty[slot], &gUnknown_0203CEDC[slot]); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } @@ -6495,13 +6496,13 @@ static void sub_81B82D4(u8 taskId) { sub_81B841C(item); pokemon_item_not_removed(gUnknown_0203CEFC); - sub_81B1B5C(gStringVar4, 0); + DisplayPartyMenuMessage(gStringVar4, 0); gTasks[taskId].func = sub_81B8104; } else if (ItemIsMail(item)) { gUnknown_0203CEC4->exitCallback = sub_81B814C; - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } else { @@ -6520,7 +6521,7 @@ static void sub_81B82D4(u8 taskId) static void sub_81B83B8(u8 taskId) { - sub_81B1B5C(gText_RemoveMailBeforeItem, 1); + DisplayPartyMenuMessage(gText_RemoveMailBeforeItem, 1); schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B8104; } @@ -6555,13 +6556,13 @@ static void sub_81B8474(u8 taskId) mail = &gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]; if (GetMonData(mon, MON_DATA_HELD_ITEM) != ITEM_NONE) { - sub_81B1B5C(gText_PkmnHoldingItemCantHoldMail, 1); + DisplayPartyMenuMessage(gText_PkmnHoldingItemCantHoldMail, 1); } else { GiveMailToMon2(mon, mail); ClearMailStruct(mail); - sub_81B1B5C(gText_MailTransferredFromMailbox, 1); + DisplayPartyMenuMessage(gText_MailTransferredFromMailbox, 1); } schedule_bg_copy_tilemap_to_vram(2); gTasks[taskId].func = sub_81B8104; @@ -6678,13 +6679,13 @@ static void sub_81B879C(u8 taskId) if (msgId != 0xFF) { PlaySE(SE_HAZURE); - display_pokemon_menu_message(msgId); + DisplayPartyMenuStdMessage(msgId); gTasks[taskId].func = sub_81B87E8; } else { PlaySE(SE_SELECT); - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } } @@ -6693,7 +6694,7 @@ static void sub_81B87E8(u8 taskId) if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); - display_pokemon_menu_message(0); + DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; } } @@ -7161,7 +7162,7 @@ static void sub_81B9240(u8 taskId) s16 *data = gTasks[taskId].data; if (++data[0] == 0x100) - sub_81B12C0(taskId); + Task_ClosePartyMenu(taskId); } static void sub_81B9270(u8 spriteId, s16 x) diff --git a/src/pokeball.c b/src/pokeball.c index 793609ec2..f10bbd49c 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -1097,7 +1097,7 @@ static void sub_80765E0(struct Sprite *sprite) } } -u8 sub_807671C(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h) +u8 CreateTradePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 oamPriority, u8 subPriority, u8 g, u32 h) { u8 spriteId; diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index ee68de326..7d7dadccb 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -1184,7 +1184,7 @@ void FreeMonIconPalette(u16 species) FreeSpritePaletteByTag(gMonIconPaletteTable[palIndex].tag); } -void sub_80D3014(struct Sprite *sprite) +void UpdateTradeMonIconFrame(struct Sprite *sprite) { UpdateMonIconFrame(sprite); } @@ -1302,7 +1302,7 @@ void sub_80D328C(struct Sprite *sprite) DestroySprite(sprite); } -void sub_80D32C8(struct Sprite *sprite, u8 animNum) +void SetPartyHPBarSprite(struct Sprite *sprite, u8 animNum) { sprite->animNum = animNum; sprite->animDelayCounter = 0; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 560260745..69a0161e1 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1540,9 +1540,9 @@ static const u8 gHandCursorTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cu static const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp"); // code -void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4) +void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 bytesToBuffer) { - s32 i, val, val2; + s32 i, tileBytesToBuffer, remainingBytes; u16 windowId; u8 txtColor[3]; u8 *tileData1, *tileData2; @@ -1551,25 +1551,25 @@ void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4) winTemplate.width = 24; winTemplate.height = 2; windowId = AddWindow(&winTemplate); - FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3)); + FillWindowPixelBuffer(windowId, PIXEL_FILL(zero2)); tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA); tileData2 = (winTemplate.width * 32) + tileData1; - if (!arg2) - txtColor[0] = 0; + if (!zero1) + txtColor[0] = TEXT_COLOR_TRANSPARENT; else - txtColor[0] = arg3; - txtColor[1] = 0xF; - txtColor[2] = 0xE; + txtColor[0] = zero2; + txtColor[1] = TEXT_DYNAMIC_COLOR_6; + txtColor[2] = TEXT_DYNAMIC_COLOR_5; AddTextPrinterParameterized4(windowId, 1, 0, 1, 0, 0, txtColor, -1, string); - val = arg4; - if (val > 6u) - val = 6; - val2 = arg4 - 6; - if (val > 0) + tileBytesToBuffer = bytesToBuffer; + if (tileBytesToBuffer > 6u) + tileBytesToBuffer = 6; + remainingBytes = bytesToBuffer - 6; + if (tileBytesToBuffer > 0) { - for (i = val; i != 0; i--) + for (i = tileBytesToBuffer; i != 0; i--) { CpuCopy16(tileData1, dst, 0x80); CpuCopy16(tileData2, dst + 0x80, 0x80); @@ -1579,8 +1579,9 @@ void sub_80C6D80(const u8 *string, void *dst, u8 arg2, u8 arg3, s32 arg4) } } - if (val2 > 0) - CpuFill16((arg3 << 4) | arg3, dst, (u32)(val2) * 0x100); + // Never used. bytesToBuffer is always passed <= 6, so remainingBytes is always <= 0 here + if (remainingBytes > 0) + CpuFill16((zero2 << 4) | zero2, dst, (u32)(remainingBytes) * 0x100); RemoveWindow(windowId); } @@ -5518,7 +5519,7 @@ static void sub_80CCB50(u8 boxId) sPSSData->field_738 |= 0x10000 << tagIndex; StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); - sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2); + DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2); LoadSpriteSheet(&spriteSheet); r6 = sub_80CD00C(GetBoxNamePtr(boxId)); @@ -5554,7 +5555,7 @@ static void sub_80CCCFC(u8 boxId, s8 direction) } StringCopyPadded(sPSSData->field_21B8, GetBoxNamePtr(boxId), 0, 8); - sub_80C6D80(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2); + DrawTextWindowAndBufferTiles(sPSSData->field_21B8, sPSSData->field_2F8, 0, 0, 2); LoadSpriteSheet(&spriteSheet); LoadPalette(gUnknown_08577574[GetBoxWallpaper(boxId)], r8, 4); x = sub_80CD00C(GetBoxNamePtr(boxId)); diff --git a/src/trade.c b/src/trade.c index de2b354ca..bfbc24194 100644 --- a/src/trade.c +++ b/src/trade.c @@ -44,1359 +44,204 @@ #include "union_room.h" #include "util.h" #include "window.h" +#include "constants/contest.h" #include "constants/easy_chat.h" #include "constants/items.h" #include "constants/moves.h" +#include "constants/region_map_sections.h" +#include "constants/rgb.h" #include "constants/species.h" #include "constants/songs.h" -#include "constants/rgb.h" #define Trade_SendData(ptr) (SendBlock(bitmask_all_link_players_but_self(), ptr->linkData, 20)) struct InGameTrade { - /*0x00*/ u8 name[11]; + /*0x00*/ u8 nickname[POKEMON_NAME_LENGTH + 1]; /*0x0C*/ u16 species; - /*0x0E*/ u8 ivs[6]; - /*0x14*/ bool8 secondAbility; + /*0x0E*/ u8 ivs[NUM_STATS]; + /*0x14*/ u8 abilityNum; /*0x18*/ u32 otId; - /*0x1C*/ u8 stats[5]; + /*0x1C*/ u8 conditions[CONTEST_CATEGORIES_COUNT]; /*0x24*/ u32 personality; /*0x28*/ u16 heldItem; /*0x2A*/ u8 mailNum; /*0x2B*/ u8 otName[11]; /*0x36*/ u8 otGender; /*0x37*/ u8 sheen; - /*0x38*/ u16 playerSpecies; + /*0x38*/ u16 requestedSpecies; }; -static EWRAM_DATA u8 *gUnknown_02032184 = NULL; -static EWRAM_DATA u8 *gUnknown_02032188[14] = {NULL}; -EWRAM_DATA struct MailStruct gUnknown_020321C0[PARTY_SIZE] = {0}; -EWRAM_DATA u8 gUnknown_02032298[2] = {0}; +static EWRAM_DATA u8 *sMessageBoxAllocBuffer = NULL; + +// Bytes 0-2 are used for the player's name box +// Bytes 3-5 are used for the partner's name box +// Bytes 6-7 are used for the Cancel box +// Bytes 8-13 are used for the Choose a Pokemon box +static EWRAM_DATA u8 *sMessageBoxTileBuffers[14] = {NULL}; + +EWRAM_DATA struct MailStruct gTradeMail[PARTY_SIZE] = {0}; +EWRAM_DATA u8 gSelectedTradeMonPositions[2] = {0}; static EWRAM_DATA struct { - /*0x0000*/ u8 unk_0; - /*0x0001*/ u8 unk_1; + /*0x0000*/ u8 bg2hofs; + /*0x0001*/ u8 bg3hofs; /*0x0002*/ u8 filler_2[0x28 - 2]; - /*0x0028*/ u8 partyIcons[2][PARTY_SIZE]; - /*0x0034*/ u8 tradeMenuCursorSpriteIdx; - /*0x0035*/ u8 tradeMenuCursorPosition; + /*0x0028*/ u8 partySpriteIds[2][PARTY_SIZE]; + /*0x0034*/ u8 cursorSpriteIdx; + /*0x0035*/ u8 cursorPosition; /*0x0036*/ u8 partyCounts[2]; - /*0x0038*/ bool8 tradeMenuOptionsActive[12]; - /*0x0044*/ u8 unk_44; - /*0x0045*/ u8 unk_45[2][PARTY_SIZE]; - /*0x0051*/ u8 unk_51[2][PARTY_SIZE]; - /*0x005D*/ u8 unk_5D[2][PARTY_SIZE]; - /*0x0069*/ u8 unk_69; + /*0x0038*/ bool8 monPresent[PARTY_SIZE * 2]; + /*0x0044*/ bool8 neverRead_44; + /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; + /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; + /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; + /*0x0069*/ u8 bufferPartyState; /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; - /*0x006F*/ u8 unk_6F; - /*0x0070*/ u8 unk_70; + /*0x006F*/ u8 tradeMenuFunc; + /*0x0070*/ u8 neverRead_70; /*0x0071*/ u8 filler_71; - /*0x0072*/ u16 unk_72; - /*0x0074*/ u8 unk_74[2]; - /*0x0076*/ u8 unk_76[2]; - /*0x0078*/ u8 unk_78; - /*0x0079*/ u8 unk_79; - /*0x007A*/ u8 unk_7A; - /*0x007B*/ u8 unk_7B; + /*0x0072*/ u16 bottomTextTileStart; + /*0x0074*/ u8 drawPartyState[2]; + /*0x0076*/ u8 selectedMonIdx[2]; + /*0x0078*/ u8 playerLinkFlagChoseAction; + /*0x0079*/ u8 partnerLinkFlagChoseAction; + /*0x007A*/ u8 playerLinkFlagStatus; + /*0x007B*/ u8 partnerLinkFlagStatus; /*0x007C*/ u8 filler_7C[0x7E - 0x7C]; - /*0x007E*/ u8 unk_7E; - /*0x007F*/ u8 filler_7F; + /*0x007E*/ u8 partnerCursorPosition; + /*0x007F*/ u8 unused_7F; /*0x0080*/ u16 linkData[20]; - /*0x00A8*/ u8 unk_A8; - /*0x00A9*/ u8 unk_A9[11]; + /*0x00A8*/ u8 timer; + /*0x00A9*/ u8 giftRibbons[11]; /*0x00B4*/ u8 filler_B4[0x8D0-0xB4]; /*0x08D0*/ struct { - bool8 unk_0; - u16 unk_2; - u8 unk_4; - } unk_8D0[4]; + bool8 queued; + u16 queueDelay; + u8 actionId; + } queuedActions[4]; /*0x08F0*/ u16 tilemapBuffer[0x400]; -} *gUnknown_0203229C = {NULL}; +} *sTradeMenuData = {NULL}; static EWRAM_DATA struct { /*0x00*/ struct Pokemon mon; /*0x64*/ u32 timer; - /*0x68*/ u32 unk_68[2]; + /*0x68*/ u32 monPersonalities[2]; /*0x70*/ u8 filler_70[2]; - /*0x72*/ u8 unk_72; - /*0x73*/ u8 unk_73; + /*0x72*/ u8 playerLinkFlagFinishTrade; + /*0x73*/ u8 partnerLinkFlagFinishTrade; /*0x74*/ u16 linkData[10]; - /*0x88*/ u8 unk_88; - /*0x89*/ u8 unk_89; - /*0x8A*/ u16 unk_8A; - /*0x8C*/ u16 unk_8C; + /*0x88*/ u8 alwaysZero_88; + /*0x89*/ u8 alwaysZero_89; + /*0x8A*/ u16 linkTimeoutCounter; + /*0x8C*/ u16 neverRead_8C; /*0x8E*/ u8 pokePicSpriteIdxs[2]; - /*0x90*/ u8 unk_90; - /*0x91*/ u8 unk_91; - /*0x92*/ u8 unk_92; - /*0x93*/ u8 unk_93; + /*0x90*/ u8 unk_90; //sprite id + /*0x91*/ u8 unk_91; //sprite id + /*0x92*/ u8 unk_92; //sprite id + /*0x93*/ u8 sendTradeFinishState; /*0x94*/ u16 state; /*0x96*/ u8 filler_96[0xD2 - 0x96]; - /*0xD2*/ u8 unk_D2; - /*0xD3*/ u8 unk_D3; - /*0xD4*/ u16 unk_D4; - /*0xD6*/ u16 unk_D6; - /*0xD8*/ u16 unk_D8; - /*0xDA*/ u16 unk_DA; - /*0xDC*/ u16 unk_DC; - /*0xDE*/ u16 unk_DE; + /*0xD2*/ u8 pokeballSpriteId; + /*0xD3*/ u8 unk_D3; //sprite id + /*0xD4*/ u16 texX; + /*0xD6*/ u16 texY; + /*0xD8*/ u16 neverRead_D8; + /*0xDA*/ u16 neverRead_DA; + /*0xDC*/ u16 scrX; + /*0xDE*/ u16 scrY; /*0xE0*/ s16 bg1vofs; /*0xE2*/ s16 bg1hofs; /*0xE4*/ s16 bg2vofs; /*0xE6*/ s16 bg2hofs; - /*0xE8*/ u16 unk_E8; - /*0xEA*/ u16 unk_EA; - /*0xEC*/ u16 unk_EC; + /*0xE8*/ u16 sXY; + /*0xEA*/ u16 unk_EA; //sXY divisor + /*0xEC*/ u16 alpha; /*0xEE*/ bool8 isLinkTrade; - /*0xF0*/ u16 tradeSpecies[2]; + /*0xF0*/ u16 monSpecies[2]; /*0xF4*/ u16 cachedMapMusic; - /*0xF6*/ u8 unk_F6[3]; + /*0xF6*/ u8 textColors[3]; /*0xF9*/ u8 filler_F9; - /*0xFA*/ u8 unk_FA; - /*0xFB*/ u8 unk_FB; - /*0xFC*/ u8 unk_FC; - /*0xFD*/ u8 unk_FD; - /*0xFE*/ u8 unk_FE; -} *gUnknown_020322A0 = {NULL}; + /*0xFA*/ bool8 isCableTrade; + /*0xFB*/ u8 wirelessWinLeft; + /*0xFC*/ u8 wirelessWinTop; + /*0xFD*/ u8 wirelessWinRight; + /*0xFE*/ u8 wirelessWinBottom; +} *sTradeData = {NULL}; #if !defined(NONMATCHING) && MODERN #define static #endif -static bool32 sub_8077260(void); -static void sub_80773D0(void); -static void sub_807811C(void); -static void sub_807825C(void); -static void sub_80782B8(u8); -static void sub_8078388(void); -static bool8 shedinja_maker_maybe(void); -static void sub_8078C34(void); -static void sub_80795AC(void); -static void sub_807967C(u8); -static void sub_80796B4(u8); -static u8 sub_8079A3C(u8 *, u8, u8); -static void sub_8079AA4(u8 *, u8, u8); -static void sub_8079BE0(u8); -static void sub_8079C4C(u8, u8, u8, u8, u8, u8); -static void sub_8079E44(u8); -static void sub_8079F74(void); -static void sub_8079F88(u8); -static void sub_807A000(u8 taskId); -static void sub_807A024(u8 taskId); -static void sub_807A048(u16, u8); -static u32 sub_807A09C(void); -static void sub_807A0C4(void); -static void sub_807A19C(u8); -static bool8 sub_807A1F0(void); -static void sub_807A308(const u8 *, u8 *, u8); -static void sub_807A320(u8); -static void sub_807A468(u8); -static void sub_807A53C(void); -static void sub_807A5B0(void); -static u32 sub_807A5F4(struct Pokemon *, int, int); +static bool32 IsWirelessTrade(void); +static void CB2_CreateTradeMenu(void); +static void VBlankCB_TradeMenu(void); +static void CB2_TradeMenu(void); +static void LoadTradeBgGfx(u8); +static void SetTradePartyMonsVisible(void); +static bool8 BufferTradeParties(void); +static void CB1_SendOrReactToLinkTradeData(void); +static void CallTradeMenuFunc(void); +static void SetSelectedMon(u8); +static void DrawTradeMenuParty(u8); +static u8 GetMonNicknameWidth(u8 *, u8, u8); +static void BufferTradeMonMoves(u8 *, u8, u8); +static void PrintPartyNicknamesForTradeMenu(u8); +static void DrawTradeMenuPartyMonInfo(u8, u8, u8, u8, u8, u8); +static void DrawTradeMenuPartyInfo(u8); +static void PrintNicknamesForTradeMenu(void); +static void RedrawTradeMenuParty(u8); +static void Task_DrawSelectionSummary(u8 taskId); +static void Task_DrawSelectionTrade(u8 taskId); +static void QueueAction(u16, u8); +static u32 GetNumQueuedActions(void); +static void DoQueuedActions(void); +static void PrintTradeMessage(u8); +static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void); +static void DrawTextWindowAndBuffer6Bytes(const u8 *, u8 *, u8); +static void SetTradePartyLiveStatuses(u8); +static void GetTradePartyHPBarLevels(u8); +static void SetTradePartyHPBarSprites(void); +static void SaveTradeGiftRibbons(void); +static u32 CanTradeSelectedMon(struct Pokemon *, int, int); static void sub_807AA28(struct Sprite *sprite); static void sub_807AA7C(struct Sprite *sprite); static void sub_807AABC(struct Sprite *sprite); static void sub_807AAE0(struct Sprite *sprite); static void sub_807AB04(struct Sprite *sprite); -static void sub_807B170(void); -static void sub_807B60C(void); -static void sub_807B62C(u8); -static void sub_807BA94(void); -static void SetTradeSceneStrings(void); -static u8 sub_807BBC8(void); -static u8 sub_807BBEC(void); -static u8 sub_807CFC8(void); +static void InitTradeBgInternal(void); +static void CB2_UpdateInGameTrade(void); +static void SetTradeSequenceBgGpuRegs(u8); +static void LoadTradeSequenceSpriteSheetsAndPalettes(void); +static void BufferTradeSceneStrings(void); +static bool8 AnimateTradeSequence(void); +static bool8 AnimateTradeSequenceCable(void); +static bool8 AnimateTradeSequenceWireless(void); static void sub_807E55C(struct Sprite *sprite); static void sub_807E5D8(struct Sprite *sprite); static void sub_807E64C(struct Sprite *sprite); static void sub_807E6AC(struct Sprite *sprite); -static void sub_807E784(void); -static void sub_807E974(struct MailStruct *mail, const struct InGameTrade *trade); -static void sub_807EA2C(void); -static void sub_807EACC(void); -static void sub_807EB50(void); -static void c2_080543C4(void); -static void sub_807F110(u8); -static void sub_807F14C(void); -static void c3_08054588(u8); +static void BuffeInGameTradeMonName(void); +static void SetInGameTradeMail(struct MailStruct *mail, const struct InGameTrade *trade); +static void CB2_UpdateLinkTrade(void); +static void CB2_TryFinishTrade(void); +static void CB2_SaveAndEndTrade(void); +static void CB2_FreeTradeData(void); +static void Task_InGameTrade(u8); +static void CheckPartnersMonForRibbons(void); +static void Task_AnimateWirelessSignal(u8); static void c3_0805465C(u8); static void sub_807F39C(u8); -static void sub_807F464(void); +static void CB2_SaveAndEndWirelessTrade(void); -static const u32 sUnref_0832C6A8[] = -{ - 0x00000F2C, - 0x00003D88, - 0x0000001C, - 0x00000024, - 0x00000064, - 0x00000528 -}; -static const u16 gTradeMovesBoxTilemap[] = INCBIN_U16("graphics/trade/moves_box_map.bin"); -static const u16 gTradePartyBoxTilemap[] = INCBIN_U16("graphics/trade/party_box_map.bin"); -static const u8 gTradeStripesBG2Tilemap[] = INCBIN_U8("graphics/trade/stripes_bg2_map.bin"); -static const u8 gTradeStripesBG3Tilemap[] = INCBIN_U8("graphics/trade/stripes_bg3_map.bin"); -static const u8 gText_EmptyString7[] = _(""); -static const u8 gText_ClrWhtHltTrspntShdwDrkGry[] = _("{COLOR WHITE}{HIGHLIGHT TRANSPARENT}{SHADOW DARK_GREY}"); -const u8 gText_MaleSymbol4[] = _("♂"); -const u8 gText_FemaleSymbol4[] = _("♀"); -const u8 gText_GenderlessSymbol[] = _(""); -static const u8 gText_SpaceMove[] = _(" MOVE"); -static const u8 gText_NewLine3[] = _("\n"); -static const u8 gText_Slash2[] = _("/"); -static const u8 gText_Lv2[] = _("Lv. "); -static const u8 gText_ThreeDashes2[] = _("---"); -static const u8 gText_FourQuestionMarks[] = _("????"); -static const u8 gText_832DAE4[] = _(""); -static const u8 gText_IsThisTradeOkay[] = _("Is this trade okay?"); -static const u8 gText_Cancel6[] = _("CANCEL"); -static const u8 gText_ChooseAPkmn[] = _("Choose a POKéMON."); -static const u8 gText_Summary3[] = _("SUMMARY"); -static const u8 gText_Trade2[] = _("TRADE"); -static const u8 gText_CancelTrade[] = _("Cancel trade?"); -static const u8 gJPText_832DB2E[] = _("Bボタン で もどります"); -static const u8 gText_Summary4[] = _("SUMMARY"); -static const u8 gText_Trade3[] = _("TRADE"); -static const u8 gText_CommunicationStandby6[] = _("{COLOR DARK_GREY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GREY}Communication standby…\nPlease wait."); -static const u8 gText_TheTradeHasBeenCanceled[] = _("{COLOR DARK_GREY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GREY}The trade has\nbeen canceled."); -static const u8 gText_YourOnlyPkmnForBattle[] = _("That's your only\nPOKéMON for battle."); -static const u8 gText_WaitingForYourFriend[] = _("{COLOR DARK_GREY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GREY}Waiting for your friend\nto finish…"); -static const u8 gText_YourFriendWantsToTrade[] = _("Your friend wants\nto trade POKéMON."); +#include "data/trade.h" -static const struct OamData gOamData_832DC14 = -{ - .shape = SPRITE_SHAPE(32x16), - .size = SPRITE_SIZE(32x16), - .priority = 1 -}; - -static const struct OamData gOamData_832DC1C = -{ - .shape = SPRITE_SHAPE(64x32), - .size = SPRITE_SIZE(64x32), - .priority = 1 -}; - -static const union AnimCmd gSpriteAnim_832DC24[] = -{ - ANIMCMD_FRAME(0, 5), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_832DC2C[] = -{ - ANIMCMD_FRAME(32, 5), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_832DC34[] = -{ - gSpriteAnim_832DC24, - gSpriteAnim_832DC2C -}; - -static const struct SpriteSheet gUnknown_0832DC3C = -{ - .data = gUnknown_08DDC6E4, - .size = 0x800, - .tag = 300 -}; - -static const struct SpritePalette gUnknown_0832DC44 = -{ - .data = gUnknown_08DDB444, - .tag = 2345 -}; - -static const union AnimCmd gSpriteAnim_832DC4C[] = -{ - ANIMCMD_FRAME(0, 5), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_832DC54[] = -{ - ANIMCMD_FRAME(8, 5), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_832DC5C[] = -{ - ANIMCMD_FRAME(16, 5), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_832DC64[] = -{ - ANIMCMD_FRAME(24, 5), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_832DC6C[] = -{ - ANIMCMD_FRAME(32, 5), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_832DC74[] = -{ - ANIMCMD_FRAME(40, 5), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_832DC7C[] = -{ - gSpriteAnim_832DC4C, - gSpriteAnim_832DC54, - gSpriteAnim_832DC5C, - gSpriteAnim_832DC64, - gSpriteAnim_832DC6C, - gSpriteAnim_832DC74 -}; - -static const struct SpriteTemplate gSpriteTemplate_832DC94 = -{ - .tileTag = 300, - .paletteTag = 2345, - .oam = &gOamData_832DC1C, - .anims = gSpriteAnimTable_832DC34, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, -}; - -static const struct SpriteTemplate gSpriteTemplate_832DCAC = -{ - .tileTag = 200, - .paletteTag = 4925, - .oam = &gOamData_832DC14, - .anims = gSpriteAnimTable_832DC7C, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, -}; - -static const u16 TradeScreenTextPalette[] = INCBIN_U16("graphics/trade/text.gbapal"); -static const struct SpritePalette gSpritePalette_TradeScreenText = -{ - .data = TradeScreenTextPalette, - .tag = 4925 -}; - -// This is used to determine the next mon to select when the D-Pad is -// pressed in a given direction. -// Note that the mons are laid out like this. -// 0-5 are the player's party and 6-11 are the trading partner's party. -// 12 is the cancel button. -// 0 1 6 7 -// 2 3 8 9 -// 4 5 10 11 -// 12 -static const u8 gTradeNextSelectedMonTable[][4][6] = -{ - { - {4, 2, 12, 12, 0, 0}, - {2, 4, 12, 12, 0, 0}, - {7, 6, 1, 0, 0, 0}, - {1, 6, 7, 0, 0, 0} - }, - { - {5, 3, 12, 12, 0, 0}, - {3, 5, 12, 12, 0, 0}, - {0, 7, 6, 1, 0, 0}, - {6, 7, 0, 1, 0, 0} - }, - { - {0, 0, 0, 0, 0, 0}, - {4, 0, 0, 0, 0, 0}, - {9, 8, 7, 6, 0, 0}, - {3, 1, 0, 0, 0, 0} - }, - { - {1, 1, 1, 1, 0, 0}, - {5, 1, 1, 1, 0, 0}, - {2, 9, 8, 7, 0, 0}, - {8, 9, 6, 6, 0, 0} - }, - { - {2, 2, 2, 2, 0, 0}, - {0, 0, 0, 0, 0, 0}, - {11, 10, 9, 8, 7, 6}, - {5, 3, 1, 0, 0, 0} - }, - { - {3, 3, 3, 3, 0, 0}, - {1, 1, 1, 1, 0, 0}, - {4, 4, 4, 4, 0, 0}, - {10, 8, 6, 0, 0, 0} - }, - { - {10, 8, 12, 0, 0, 0}, - {8, 10, 12, 0, 0, 0}, - {1, 0, 0, 0, 0, 0}, - {7, 0, 1, 0, 0, 0} - }, - { - {12, 0, 0, 0, 0, 0}, - {9, 12, 0, 0, 0, 0}, - {6, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0} - }, - { - {6, 0, 0, 0, 0, 0}, - {10, 6, 0, 0, 0, 0}, - {3, 2, 1, 0, 0, 0}, - {9, 7, 0, 0, 0, 0} - }, - { - {7, 0, 0, 0, 0, 0}, - {11, 12, 0, 0, 0, 0}, - {8, 0, 0, 0, 0, 0}, - {2, 1, 0, 0, 0, 0} - }, - { - {8, 0, 0, 0, 0, 0}, - {6, 0, 0, 0, 0, 0}, - {5, 4, 3, 2, 1, 0}, - {11, 9, 7, 0, 0, 0} - }, - { - {9, 0, 0, 0, 0, 0}, - {12, 0, 0, 0, 0, 0}, - {10, 0, 0, 0, 0, 0}, - {4, 2, 0, 0, 0, 0} - }, - { - {11, 9, 7, 6, 0, 0}, - {7, 6, 0, 0, 0, 0}, - {12, 0, 0, 0, 0, 0}, - {12, 0, 0, 0, 0, 0} - } -}; - -static const u8 gTradeMonSpriteCoords[][2] = -{ - // Your party - {1, 5 }, - {8, 5 }, - {1, 10}, - {8, 10}, - {1, 15}, - {8, 15}, - - // Friend's party - {16, 5 }, - {23, 5 }, - {16, 10}, - {23, 10}, - {16, 15}, - {23, 15}, - - {23, 18} // CANCEL -}; - -static const u8 gTradeLevelDisplayCoords[][6][2] = -{ - { - // Your party - {5, 4}, - {12, 4}, - {5, 9}, - {12, 9}, - {5, 14}, - {12, 14}, - }, - { - // Friend's party - {20, 4}, - {27, 4}, - {20, 9}, - {27, 9}, - {20, 14}, - {27, 14} - } -}; - -static const u8 gTradeMonBoxCoords[][6][2] = -{ - { - // Your party - {1, 3}, - {8, 3}, - {1, 8}, - {8, 8}, - {1, 13}, - {8, 13}, - }, - { - // Friend's party - {16, 3}, - {23, 3}, - {16, 8}, - {23, 8}, - {16, 13}, - {23, 13} - } -}; - -static const u8 sUnref_0832DE6E[] = -{ - 0x00, 0x0e, - 0x0f, 0x1d, - 0x03, 0x05, - 0x03, 0x07, - 0x12, 0x05, - 0x12, 0x07, - 0x08, 0x07, - 0x16, 0x0c, - 0x08, 0x07, - 0x16, 0x0c, - 0x06, 0x07, - 0x18, 0x0c, - 0x06, 0x07, - 0x18, 0x0c, - 0x08, 0x07, - 0x16, 0x0c, - 0x07, 0x07, - 0x17, 0x0c -}; - -static const u8 *const gUnknown_0832DE94[] = -{ - gText_Cancel6, - gText_ChooseAPkmn, - gText_Summary3, - gText_Trade2, - gText_CancelTrade, - gJPText_832DB2E -}; - -static const struct MenuAction gUnknown_0832DEAC[] = -{ - {gText_Summary4, sub_807A000}, - {gText_Trade3, sub_807A024} -}; - -static const u8 *const gUnknown_0832DEBC[] = { - gText_CommunicationStandby6, - gText_TheTradeHasBeenCanceled, - gText_YourOnlyPkmnForBattle, - gText_OnlyPkmnForBattle, - gText_WaitingForYourFriend, - gText_YourFriendWantsToTrade, - gText_PkmnCantBeTradedNow, - gText_EggCantBeTradedNow, - gText_OtherTrainersPkmnCantBeTraded -}; - -static const u8 gUnknown_0832DEE0[] = { 0, 1, 2 }; - -static const struct BgTemplate gUnknown_0832DEE4[] = -{ - { - .bg = 0, - .charBaseIndex = 2, - .mapBaseIndex = 31, - .screenSize = 0, - .paletteMode = 0, - .priority = 0, - .baseTile = 0 - }, - { - .bg = 1, - .charBaseIndex = 0, - .mapBaseIndex = 5, - .screenSize = 0, - .paletteMode = 0, - .priority = 1, - .baseTile = 0 - }, - { - .bg = 2, - .charBaseIndex = 0, - .mapBaseIndex = 6, - .screenSize = 0, - .paletteMode = 0, - .priority = 2, - .baseTile = 0 - }, - { - .bg = 3, - .charBaseIndex = 0, - .mapBaseIndex = 7, - .screenSize = 0, - .paletteMode = 0, - .priority = 3, - .baseTile = 0 - }, -}; - -static const struct WindowTemplate gUnknown_0832DEF4[] = -{ - { - .bg = 0, - .tilemapLeft = 4, - .tilemapTop = 7, - .width = 22, - .height = 4, - .paletteNum = 15, - .baseBlock = 30 - }, - { - .bg = 0, - .tilemapLeft = 19, - .tilemapTop = 15, - .width = 10, - .height = 4, - .paletteNum = 15, - .baseBlock = 118 - }, - { - .bg = 0, - .tilemapLeft = 0, - .tilemapTop = 5, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 158 - }, - { - .bg = 0, - .tilemapLeft = 7, - .tilemapTop = 5, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 174 - }, - { - .bg = 0, - .tilemapLeft = 0, - .tilemapTop = 10, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 190 - }, - { - .bg = 0, - .tilemapLeft = 7, - .tilemapTop = 10, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 206 - }, - { - .bg = 0, - .tilemapLeft = 0, - .tilemapTop = 15, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 222 - }, - { - .bg = 0, - .tilemapLeft = 7, - .tilemapTop = 15, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 238 - }, - { - .bg = 0, - .tilemapLeft = 15, - .tilemapTop = 5, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 254 - }, - { - .bg = 0, - .tilemapLeft = 22, - .tilemapTop = 5, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 270 - }, - { - .bg = 0, - .tilemapLeft = 15, - .tilemapTop = 10, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 286 - }, - { - .bg = 0, - .tilemapLeft = 22, - .tilemapTop = 10, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 302 - }, - { - .bg = 0, - .tilemapLeft = 15, - .tilemapTop = 15, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 318 - }, - { - .bg = 0, - .tilemapLeft = 22, - .tilemapTop = 15, - .width = 8, - .height = 2, - .paletteNum = 13, - .baseBlock = 334 - }, - { - .bg = 0, - .tilemapLeft = 2, - .tilemapTop = 5, - .width = 14, - .height = 2, - .paletteNum = 13, - .baseBlock = 350 - }, - { - .bg = 0, - .tilemapLeft = 3, - .tilemapTop = 8, - .width = 11, - .height = 8, - .paletteNum = 15, - .baseBlock = 378 - }, - { - .bg = 0, - .tilemapLeft = 17, - .tilemapTop = 5, - .width = 14, - .height = 2, - .paletteNum = 15, - .baseBlock = 466 - }, - { - .bg = 0, - .tilemapLeft = 18, - .tilemapTop = 8, - .width = 11, - .height = 8, - .paletteNum = 15, - .baseBlock = 494 - }, - DUMMY_WIN_TEMPLATE, -}; - -static const struct WindowTemplate gUnknown_0832DF8C = -{ - .bg = 0, - .tilemapLeft = 23, - .tilemapTop = 13, - .width = 5, - .height = 4, - .paletteNum = 15, - .baseBlock = 582 -}; - -static const u8 gJPText_Shedinja[] = _("ヌケニン"); -static const u8 gUnknown_0832DF99[][2] = -{ - {4, 3}, - {19, 3}, - {0, 0} -}; - -static const u16 gTradeBallPalette[] = INCBIN_U16("graphics/trade/ball.gbapal"); -static const u8 gTradeBallTiles[] = INCBIN_U8("graphics/trade/ball.4bpp"); -static const u8 gUnknown_832E5C0[] = INCBIN_U8("graphics/trade/pokeball_symbol.8bpp"); -static const u16 gUnknown_0832FFC0[] = INCBIN_U16("graphics/trade/cable_closeup_map.bin"); -static const u16 gUnknown_083307C0[] = INCBIN_U16("graphics/trade/pokeball_symbol_map.bin"); -static const u16 sUnref_083308C0[] = INCBIN_U16("graphics/trade/unknown_3308C0.gbapal"); -static const u16 gUnknown_083308E0[] = INCBIN_U16("graphics/trade/gba.gbapal"); -static const u16 gUnref_08330900[] = INCBIN_U16("graphics/trade/shadow.gbapal"); -static const u16 gUnref_08330920[] = INCBIN_U16("graphics/trade/black.gbapal"); -static const u16 gUnknown_08330940[] = INCBIN_U16("graphics/trade/misc.gbapal"); -static const u8 gTradeGlow1Tiles[] = INCBIN_U8("graphics/trade/glow1.4bpp"); -static const u8 gTradeGlow2Tiles[] = INCBIN_U8("graphics/trade/glow2.4bpp"); -static const u8 gTradeCableEndTiles[] = INCBIN_U8("graphics/trade/cable_end.4bpp"); -static const u8 gTradeGBAScreenTiles[] = INCBIN_U8("graphics/trade/gba_screen.4bpp"); -const u16 gUnknown_08331F60[] = INCBIN_U16("graphics/trade/shadow_map.bin"); -static const u8 gUnknown_08332F60[] = INCBIN_U8("graphics/trade/gba_affine.8bpp"); -static const u8 sFiller_08335760[64] = {}; -static const u8 gUnknown_083357A0[] = INCBIN_U8("graphics/trade/gba_affine_map_cable.bin"); -static const u8 gUnknown_083358A0[] = INCBIN_U8("graphics/trade/gba_affine_map_wireless.bin"); -static const u16 gUnknown_083359A0[] = INCBIN_U16("graphics/trade/gba_map_wireless.bin"); -static const u16 gUnknown_083369A0[] = INCBIN_U16("graphics/trade/gba_map_cable.bin"); -static const u32 gUnknown_083379A0[] = INCBIN_U32("graphics/trade/unknown_3379A0.bin.lz"); -static const u16 gUnknown_08337AA0[] = INCBIN_U16("graphics/trade/wireless_signal_send.gbapal"); -static const u16 gUnknown_08337CA0[] = INCBIN_U16("graphics/trade/wireless_signal_receive.gbapal"); -static const u16 gUnknown_08337EA0[] = INCBIN_U16("graphics/trade/black.gbapal"); -static const u32 gUnknown_08337EC0[] = INCBIN_U32("graphics/trade/wireless_signal.4bpp.lz"); -static const u32 gUnknown_08338550[] = INCBIN_U32("graphics/trade/wireless_signal.bin.lz"); - -static const struct OamData gOamData_8338C44 = -{ - .affineMode = 1, - .shape = SPRITE_SHAPE(16x16), - .size = SPRITE_SIZE(16x16) -}; - -static const union AnimCmd gSpriteAnim_8338C4C[] = -{ - ANIMCMD_FRAME( 0, 3), - ANIMCMD_FRAME( 4, 3), - ANIMCMD_FRAME( 8, 3), - ANIMCMD_FRAME(12, 3), - ANIMCMD_FRAME(16, 3), - ANIMCMD_FRAME(20, 3), - ANIMCMD_FRAME(24, 3), - ANIMCMD_FRAME(28, 3), - ANIMCMD_FRAME(32, 3), - ANIMCMD_FRAME(36, 3), - ANIMCMD_FRAME(40, 3), - ANIMCMD_FRAME(44, 3), - ANIMCMD_LOOP(1), - ANIMCMD_FRAME( 0, 3), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_8338C88[] = -{ - ANIMCMD_FRAME( 0, 3), - ANIMCMD_FRAME( 4, 3), - ANIMCMD_FRAME( 8, 3), - ANIMCMD_FRAME(12, 3), - ANIMCMD_FRAME(16, 3), - ANIMCMD_FRAME(20, 3), - ANIMCMD_FRAME(24, 3), - ANIMCMD_FRAME(28, 3), - ANIMCMD_FRAME(32, 3), - ANIMCMD_FRAME(36, 3), - ANIMCMD_FRAME(40, 3), - ANIMCMD_FRAME(44, 3), - ANIMCMD_LOOP(2), - ANIMCMD_FRAME( 0, 3), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_8338C88[] = -{ - gSpriteAnim_8338C4C, - gSpriteAnim_8338C88 -}; - -static const union AffineAnimCmd gSpriteAffineAnim_8338CCC[] = -{ - AFFINEANIMCMD_FRAME(0, 0, 0, 1), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd gSpriteAffineAnim_8338CDC[] = -{ - AFFINEANIMCMD_FRAME(-8, 0, 0, 20), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd gSpriteAffineAnim_8338CEC[] = -{ - AFFINEANIMCMD_FRAME(0x60, 0x100, 0, 0), - AFFINEANIMCMD_FRAME( 0, 0, 0, 5), - AFFINEANIMCMD_FRAME( 8, 0, 0, 20), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D0C[] = -{ - gSpriteAffineAnim_8338CCC, - gSpriteAffineAnim_8338CDC, - gSpriteAffineAnim_8338CEC -}; - -static const struct SpriteSheet gUnknown_08338D18 = -{ - .data = gTradeBallTiles, - .size = 0x600, - .tag = 5557 -}; - -static const struct SpritePalette gUnknown_08338D20 = -{ - .data = gTradeBallPalette, - .tag = 5558 -}; - -static const struct SpriteTemplate gSpriteTemplate_8338D28 = -{ - .tileTag = 5557, - .paletteTag = 5558, - .oam = &gOamData_8338C44, - .anims = gSpriteAnimTable_8338C88, - .images = NULL, - .affineAnims = gSpriteAffineAnimTable_8338D0C, - .callback = sub_807E55C -}; - -static const struct OamData gOamData_8338D40 = -{ - .affineMode = 1, - .objMode = 1, - .shape = SPRITE_SHAPE(32x32), - .size = SPRITE_SIZE(32x32), - .priority = 1 -}; - -static const union AnimCmd gSpriteAnim_8338D48[] = -{ - ANIMCMD_FRAME(0, 5, .hFlip = TRUE, .vFlip = TRUE), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_8338D50[] = -{ - gSpriteAnim_8338D48 -}; - -static const union AffineAnimCmd gSpriteAffineAnim_8338D54[] = -{ - AFFINEANIMCMD_FRAME(-10, -10, 0, 5), - AFFINEANIMCMD_FRAME(10, 10, 0, 5), - AFFINEANIMCMD_JUMP(0) -}; - -static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D6C[] = -{ - gSpriteAffineAnim_8338D54 -}; - -static const struct SpriteSheet gUnknown_08338D70 = -{ - .data = gTradeGlow1Tiles, - .size = 0x200, - .tag = 5550 -}; - -static const struct SpritePalette gUnknown_08338D78 = -{ - .data = gUnknown_08330940, - .tag = 5551 -}; - -static const struct SpritePalette gUnknown_08338D80 = -{ - .data = gUnknown_083308E0, - .tag = 5555 -}; - -static const struct SpriteTemplate gUnknown_08338D88 = -{ - .tileTag = 5550, - .paletteTag = 5551, - .oam = &gOamData_8338D40, - .anims = gSpriteAnimTable_8338D50, - .images = NULL, - .affineAnims = gSpriteAffineAnimTable_8338D6C, - .callback = sub_807AA28 -}; - -static const struct OamData gOamData_8338DA0 = -{ - .shape = SPRITE_SHAPE(16x32), - .size = SPRITE_SIZE(16x32), - .priority = 1 -}; - -static const union AnimCmd gSpriteAnim_8338DA8[] = -{ - ANIMCMD_FRAME(0, 5, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_8338DB0[] = -{ - ANIMCMD_FRAME(8, 5, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_8338DB8[] = -{ - gSpriteAnim_8338DA8, - gSpriteAnim_8338DB0 -}; - -static const struct SpriteSheet gUnknown_08338DC0 = -{ - .data = gTradeGlow2Tiles, - .size = 0x300, - .tag = 5552 -}; - -static const struct SpriteTemplate gSpriteTemplate_8338DC8 = -{ - .tileTag = 5552, - .paletteTag = 5551, - .oam = &gOamData_8338DA0, - .anims = gSpriteAnimTable_8338DB8, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_807AA7C -}; - -static const struct OamData gOamData_8338DE0 = -{ - .shape = SPRITE_SHAPE(16x32), - .size = SPRITE_SIZE(16x32), - .priority = 1 -}; - -static const union AnimCmd gSpriteAnim_8338DE8[] = -{ - ANIMCMD_FRAME(0, 10), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_8338DF0[] = -{ - gSpriteAnim_8338DE8 -}; - -static const struct SpriteSheet gUnknown_08338DF4 = -{ - .data = gTradeCableEndTiles, - .size = 0x100, - .tag = 5554 -}; - -static const struct SpriteTemplate gSpriteTemplate_8338DFC = -{ - .tileTag = 5554, - .paletteTag = 5555, - .oam = &gOamData_8338DE0, - .anims = gSpriteAnimTable_8338DF0, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_807AABC -}; - -static const struct OamData gOamData_8338E14 = -{ - .shape = SPRITE_SHAPE(64x32), - .size = SPRITE_SIZE(64x32), - .priority = 1 -}; - -static const union AnimCmd gSpriteAnim_8338E1C[] = -{ - ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(96, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_LOOP(8), - ANIMCMD_END -}; - -static const union AnimCmd gSpriteAnim_8338E40[] = -{ - ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(96, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(64, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME(32, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_FRAME( 0, 2, .vFlip = TRUE, .hFlip = TRUE), - ANIMCMD_LOOP(2), - ANIMCMD_END -}; - -static const union AnimCmd *const gSpriteAnimTable_8338E64[] = -{ - gSpriteAnim_8338E1C -}; - -static const union AnimCmd *const gSpriteAnimTable_8338E68[] = -{ - gSpriteAnim_8338E40 -}; - -static const struct SpriteSheet gUnknown_08338E6C = -{ - .data = gTradeGBAScreenTiles, - .size = 0x1000, - .tag = 5556 -}; - -static const struct SpriteTemplate gSpriteTemplate_8338E74 = -{ - .tileTag = 5556, - .paletteTag = 5555, - .oam = &gOamData_8338E14, - .anims = gSpriteAnimTable_8338E64, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_807AB04 -}; - -static const struct SpriteTemplate gSpriteTemplate_8338E8C = -{ - .tileTag = 5556, - .paletteTag = 5555, - .oam = &gOamData_8338E14, - .anims = gSpriteAnimTable_8338E68, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_807AB04 -}; - -static const u16 gUnknown_08338EA4[] = INCBIN_U16("graphics/trade/unknown_338EA4.gbapal"); - -static const union AffineAnimCmd gSpriteAffineAnim_8338EBC[] = -{ - AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), - AFFINEANIMCMD_JUMP(0) -}; - -static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338ECC[] = -{ - gSpriteAffineAnim_8338EBC -}; - -static const struct InGameTrade gIngameTrades[] = -{ - { - _("DOTS"), SPECIES_SEEDOT, - 5, 4, 5, 4, 4, 4, - TRUE, 38726, - 30, 5, 5, 5, 5, - 0x84, - ITEM_CHESTO_BERRY, -1, - _("KOBE"), MALE, 10, - SPECIES_RALTS - }, { - _("PLUSES"), SPECIES_PLUSLE, - 4, 4, 4, 5, 5, 4, - FALSE, 73996, - 5, 5, 30, 5, 5, - 0x6F, - ITEM_WOOD_MAIL, 0, - _("ROMAN"), MALE, 10, - SPECIES_VOLBEAT - }, { - _("SEASOR"), - SPECIES_HORSEA, - 5, 4, 4, 4, 5, 4, - FALSE, 46285, - 5, 5, 5, 5, 30, - 0x7F, - ITEM_WAVE_MAIL, 1, - _("SKYLAR"), MALE, 10, - SPECIES_BAGON - }, { - _("MEOWOW"), - SPECIES_MEOWTH, - 4, 5, 4, 5, 4, 4, - FALSE, 91481, - 5, 5, 5, 30, 5, - 0x8B, - ITEM_RETRO_MAIL, 2, - _("ISIS"), FEMALE, 10, - SPECIES_SKITTY - } -}; - -static const u16 gIngameTradeMail[][10] = -{ - { - EC_WORD_BE, - EC_WORD_NICE, - EC_WORD_TO, - EC_POKEMON(PLUSLE), - EC_WORD_EXCL, - EC_POKEMON(VOLBEAT), - EC_WORD_WILL, - EC_WORD_BE, - EC_WORD_FANTASTIC, - 0 - }, { - EC_WORD_I, - EC_WORD_WILL, - EC_WORD_MAKE, - EC_POKEMON(BAGON), - EC_WORD_TOUGH, - EC_WORD_PLEASE, - EC_WORD_TRAIN, - EC_POKEMON(HORSEA), - EC_WORD_WELL, - 0 - }, { - EC_WORD_THANK_YOU, - EC_WORD_FOR, - EC_POKEMON(SKITTY), - EC_POKEMON2(MEOWTH), - EC_WORD_CRIES, - EC_WORD_IN, - EC_WORD_A, - EC_WORD_CUTE, - EC_WORD_WAY, - 0 - } -}; - -static const struct WindowTemplate gUnknown_08338FFC[] = -{ - { - .bg = 0, - .tilemapLeft = 2, - .tilemapTop = 15, - .width = 26, - .height = 4, - .paletteNum = 0, - .baseBlock = 64 - }, - DUMMY_WIN_TEMPLATE -}; - -const struct WindowTemplate gUnknown_0833900C = -{ - .bg = 0, - .tilemapLeft = 21, - .tilemapTop = 9, - .width = 5, - .height = 4, - .paletteNum = 15, - .baseBlock = 188 -}; - -static const struct BgTemplate gUnknown_08339014[] = -{ - { - .bg = 0, - .charBaseIndex = 3, - .mapBaseIndex = 31, - .screenSize = 0, - .paletteMode = 0, - .priority = 0, - .baseTile = 0 - }, - { - .bg = 1, - .charBaseIndex = 0, - .mapBaseIndex = 5, - .screenSize = 0, - .paletteMode = 0, - .priority = 2, - .baseTile = 0 - }, - { - .bg = 2, - .charBaseIndex = 1, - .mapBaseIndex = 18, - .screenSize = 1, - .paletteMode = 0, - .priority = 2, - .baseTile = 0 - }, - { - .bg = 3, - .charBaseIndex = 0, - .mapBaseIndex = 6, - .screenSize = 0, - .paletteMode = 0, - .priority = 3, - .baseTile = 0 - }, -}; - -static const s8 gTradeBallVerticalVelocityTable[] = -{ - 0, 0, 1, 0, - 1, 0, 1, 1, - 1, 1, 2, 2, - 2, 2, 3, 3, - 3, 3, 4, 4, - 4, 4, -4, -4, - -4, -3, -3, -3, - -3, -2, -2, -2, - -2, -1, -1, -1, - -1, 0, -1, 0, - -1, 0, 0, 0, - 0, 0, 1, 0, - 1, 0, 1, 1, - 1, 1, 2, 2, - 2, 2, 3, 3, - 3, 3, 4, 4, - 4, 4, -4, -3, - -3, -2, -2, -1, - -1, -1, 0, -1, - 0, 0, 0, 0, - 0, 0, 1, 0, - 1, 1, 1, 2, - 2, 3, 3, 4, - -4, -3, -2, -1, - -1, -1, 0, 0, - 0, 0, 1, 0, - 1, 1, 2, 3 -}; - -static const u8 gUnknown_08339090[][2] = -{ - {0, 1}, - {1, 1}, - {2, 1}, - {3, 1}, - {4, 1}, - {5, 2}, - {6, 2}, - {7, 2}, - {8, 2}, - {9, 2}, - {10, 3}, - {11, 3}, - {12, 3}, - {13, 4}, - {14, 5}, - {15, 2}, - {0, 1}, - {1, 1}, - {2, 1}, - {3, 1}, - {4, 1}, - {5, 2}, - {6, 2}, - {7, 2}, - {8, 2}, - {9, 2}, - {10, 3}, - {11, 3}, - {12, 3}, - {13, 4}, - {14, 5}, - {16, 1}, - {16, -1}, - {0, 0} -}; - -static bool8 sub_8077170(const void *a0, u32 a1) +static bool8 SendLinkData(const void *linkData, u32 size) { if (gUnknown_02022C2C == 29) { - rfu_NI_setSendData(gUnknown_03004140.unk_00, 84, a0, a1); + rfu_NI_setSendData(gUnknown_03004140.unk_00, 84, linkData, size); return TRUE; } else { - return SendBlock(0, a0, a1); + return SendBlock(0, linkData, size); } } @@ -1410,13 +255,9 @@ static bool32 sub_80771BC(void) if (gUnknown_02022C2C == 29) { if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) - { return TRUE; - } else - { return FALSE; - } } else { @@ -1429,40 +270,28 @@ static u32 _GetBlockReceivedStatus(void) return GetBlockReceivedStatus(); } -static void sub_8077210(void) +static void TradeResetReceivedFlags(void) { - if (sub_8077260()) - { + if (IsWirelessTrade()) rfu_clearSlot(12, gUnknown_03004140.unk_00); - } else - { ResetBlockReceivedFlags(); - } } -static void sub_8077234(u32 a0) +static void TradeResetReceivedFlag(u32 who) { - if (sub_8077260()) - { + if (IsWirelessTrade()) rfu_clearSlot(12, gUnknown_03004140.unk_00); - } else - { - ResetBlockReceivedFlag(a0); - } + ResetBlockReceivedFlag(who); } -static bool32 sub_8077260(void) +static bool32 IsWirelessTrade(void) { if (gWirelessCommType && gUnknown_02022C2C == 29) - { return TRUE; - } else - { return FALSE; - } } static void sub_8077288(u8 unused) @@ -1475,7 +304,7 @@ static bool32 _IsLinkTaskFinished(void) return IsLinkTaskFinished(); } -static void sub_80772A4(void) +static void InitTradeMenu(void) { ResetSpriteData(); FreeAllSpritePalettes(); @@ -1484,14 +313,14 @@ static void sub_80772A4(void) gPaletteFade.bufferTransferDisabled = TRUE; - SetVBlankCallback(sub_807811C); + SetVBlankCallback(VBlankCB_TradeMenu); LoadPalette(gUnknown_0860F074, 0xF0, 20); LoadPalette(gUnknown_0860F074, 0xD0, 20); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0832DEE4, ARRAY_COUNT(gUnknown_0832DEE4)); - SetBgTilemapBuffer(1, gUnknown_0203229C->tilemapBuffer); + InitBgsFromTemplates(0, sTradeMenuBgTemplates, ARRAY_COUNT(sTradeMenuBgTemplates)); + SetBgTilemapBuffer(1, sTradeMenuData->tilemapBuffer); - if (InitWindows(gUnknown_0832DEF4)) + if (InitWindows(sTradeMenuWindowTemplates)) { u32 i; @@ -1507,25 +336,25 @@ static void sub_80772A4(void) LoadUserWindowBorderGfx_(0, 20, 0xC0); LoadUserWindowBorderGfx(2, 1, 0xE0); LoadMonIconPalettes(); - gUnknown_0203229C->unk_69 = 0; - gUnknown_0203229C->unk_6F = 0; - gUnknown_0203229C->unk_70 = 0; - gUnknown_0203229C->unk_74[0] = 0; - gUnknown_0203229C->unk_74[1] = 0; - gUnknown_0203229C->unk_7A = 0; - gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->bufferPartyState = 0; + sTradeMenuData->tradeMenuFunc = 0; + sTradeMenuData->neverRead_70 = 0; + sTradeMenuData->drawPartyState[TRADE_PLAYER] = 0; + sTradeMenuData->drawPartyState[TRADE_PARTNER] = 0; + sTradeMenuData->playerLinkFlagStatus = 0; + sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->timer = 0; } } -void sub_80773AC(void) +void CB2_StartCreateTradeMenu(void) { - SetMainCallback2(sub_80773D0); + SetMainCallback2(CB2_CreateTradeMenu); gMain.callback1 = NULL; gEnemyPartyCount = 0; } -static void sub_80773D0(void) +static void CB2_CreateTradeMenu(void) { int i; struct SpriteTemplate temp; @@ -1535,13 +364,13 @@ static void sub_80773D0(void) switch (gMain.state) { case 0: - gUnknown_0203229C = AllocZeroed(sizeof(*gUnknown_0203229C)); - sub_80772A4(); - gUnknown_02032184 = AllocZeroed(0xE00); + sTradeMenuData = AllocZeroed(sizeof(*sTradeMenuData)); + InitTradeMenu(); + sMessageBoxAllocBuffer = AllocZeroed(ARRAY_COUNT(sMessageBoxTileBuffers) * 256); - for (i = 0; i < 14; i++) + for (i = 0; i < (int)ARRAY_COUNT(sMessageBoxTileBuffers); i++) { - gUnknown_02032188[i] = &gUnknown_02032184[i * 256]; + sMessageBoxTileBuffers[i] = &sMessageBoxAllocBuffer[i * 256]; } gMain.state++; @@ -1551,16 +380,16 @@ static void sub_80773D0(void) for (i = 0; i < PARTY_SIZE; i++) { - CreateMon(&gEnemyParty[i], SPECIES_NONE, 0, 0x20, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateMon(&gEnemyParty[i], SPECIES_NONE, 0, 32, FALSE, 0, OT_ID_PLAYER_ID, 0); } - sub_807A19C(0); + PrintTradeMessage(TRADE_MSG_STANDBY); ShowBg(0); if (!gReceivedRemoteLinkPlayers) { gLinkType = LINKTYPE_0x1122; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->timer = 0; if (gWirelessCommType) { @@ -1581,10 +410,10 @@ static void sub_80773D0(void) } break; case 2: - gUnknown_0203229C->unk_A8++; - if (gUnknown_0203229C->unk_A8 > 11) + sTradeMenuData->timer++; + if (sTradeMenuData->timer > 11) { - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->timer = 0; gMain.state++; } break; @@ -1593,7 +422,7 @@ static void sub_80773D0(void) { if (IsLinkMaster()) { - if (++gUnknown_0203229C->unk_A8 > 30) + if (++sTradeMenuData->timer > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -1611,7 +440,7 @@ static void sub_80773D0(void) sub_8011BD0(); CalculatePlayerPartyCount(); gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->timer = 0; if (gWirelessCommType) { sub_801048C(TRUE); @@ -1622,7 +451,7 @@ static void sub_80773D0(void) case 5: if (gWirelessCommType) { - if (sub_8010500()) + if (IsLinkRfuTaskFinished()) { gMain.state++; LoadWirelessStatusIndicatorSpriteGfx(); @@ -1635,9 +464,9 @@ static void sub_80773D0(void) } break; case 6: - if (shedinja_maker_maybe()) + if (BufferTradeParties()) { - sub_807A5B0(); + SaveTradeGiftRibbons(); gMain.state++; } break; @@ -1645,28 +474,28 @@ static void sub_80773D0(void) CalculateEnemyPartyCount(); SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0); - gUnknown_0203229C->partyCounts[0] = gPlayerPartyCount; - gUnknown_0203229C->partyCounts[1] = gEnemyPartyCount; + sTradeMenuData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; + sTradeMenuData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; - for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - gUnknown_0203229C->partyIcons[0][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), - sub_80D3014, - (gTradeMonSpriteCoords[i][0] * 8) + 14, - (gTradeMonSpriteCoords[i][1] * 8) - 12, + sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + UpdateTradeMonIconFrame, + (sTradeMonSpriteCoords[i][0] * 8) + 14, + (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), TRUE); } - for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - gUnknown_0203229C->partyIcons[1][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - sub_80D3014, - (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, - (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, + sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + UpdateTradeMonIconFrame, + (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, + (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), FALSE); @@ -1675,24 +504,24 @@ static void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 0); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PLAYER); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 1); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PARTNER); gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[0], 0, 0, 3); + DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, gUnknown_02032188[3], 0, 0, 3); - sub_80C6D80(gUnknown_0832DE94[0], gUnknown_02032188[6], 0, 0, 2); - sub_807A308(gUnknown_0832DE94[1], gUnknown_02032188[8], 24); + DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); + DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->timer = 0; break; case 11: - if (sub_807A1F0()) + if (LoadTradeMenuSpriteSheetsAndPalettes()) gMain.state++; break; case 12: @@ -1728,31 +557,31 @@ static void sub_80773D0(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - gUnknown_0203229C->tradeMenuCursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); - gUnknown_0203229C->tradeMenuCursorPosition = 0; + sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, sTradeMonSpriteCoords[0][0] * 8 + 32, sTradeMonSpriteCoords[0][1] * 8, 2); + sTradeMenuData->cursorPosition = 0; gMain.state++; rbox_fill_rectangle(0); break; case 14: - sub_807A320(0); - sub_8079BE0(0); - gUnknown_0203229C->unk_0 = 0; - gUnknown_0203229C->unk_1 = 0; - sub_8078388(); + SetTradePartyLiveStatuses(TRADE_PLAYER); + PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); + sTradeMenuData->bg2hofs = 0; + sTradeMenuData->bg3hofs = 0; + SetTradePartyMonsVisible(); gMain.state++; PlayBGM(MUS_P_SCHOOL); break; case 15: - sub_807A320(1); - sub_8079BE0(1); + SetTradePartyLiveStatuses(TRADE_PARTNER); + PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); gMain.state++; // fallthrough case 16: - sub_80782B8(0); + LoadTradeBgGfx(0); gMain.state++; break; case 17: - sub_80782B8(1); + LoadTradeBgGfx(1); gMain.state++; break; case 18: @@ -1761,23 +590,23 @@ static void sub_80773D0(void) break; case 19: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - sub_80782B8(2); + LoadTradeBgGfx(2); gMain.state++; break; case 20: - sub_807A468(0); + GetTradePartyHPBarLevels(TRADE_PLAYER); gMain.state++; break; case 21: - sub_807A468(1); - sub_807A53C(); + GetTradePartyHPBarLevels(TRADE_PARTNER); + SetTradePartyHPBarSprites(); gMain.state++; break; case 22: if (!gPaletteFade.active) { - gMain.callback1 = sub_8078C34; - SetMainCallback2(sub_807825C); + gMain.callback1 = CB1_SendOrReactToLinkTradeData; + SetMainCallback2(CB2_TradeMenu); } break; } @@ -1789,7 +618,7 @@ static void sub_80773D0(void) UpdatePaletteFade(); } -static void sub_8077B74(void) +static void CB2_ReturnToTradeMenu(void) { int i; struct SpriteTemplate temp; @@ -1799,12 +628,12 @@ static void sub_8077B74(void) switch (gMain.state) { case 0: - sub_80772A4(); + InitTradeMenu(); gMain.state++; break; case 1: gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->timer = 0; break; case 2: gMain.state++; @@ -1829,31 +658,31 @@ static void sub_8077B74(void) break; case 7: CalculateEnemyPartyCount(); - gUnknown_0203229C->partyCounts[0] = gPlayerPartyCount; - gUnknown_0203229C->partyCounts[1] = gEnemyPartyCount; + sTradeMenuData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; + sTradeMenuData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; ClearWindowTilemap(0); - sub_8079BE0(0); - sub_8079BE0(1); + PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); + PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); - for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - gUnknown_0203229C->partyIcons[0][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - sub_80D3014, - (gTradeMonSpriteCoords[i][0] * 8) + 14, - (gTradeMonSpriteCoords[i][1] * 8) - 12, + sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + UpdateTradeMonIconFrame, + (sTradeMonSpriteCoords[i][0] * 8) + 14, + (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), TRUE); } - for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - gUnknown_0203229C->partyIcons[1][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - sub_80D3014, - (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, - (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, + sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + UpdateTradeMonIconFrame, + (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, + (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), FALSE); @@ -1862,24 +691,24 @@ static void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 0); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PLAYER); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 1); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PARTNER); gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[0], 0, 0, 3); + DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, gUnknown_02032188[3], 0, 0, 3); - sub_80C6D80(gUnknown_0832DE94[0], gUnknown_02032188[6], 0, 0, 2); - sub_807A308(gUnknown_0832DE94[1], gUnknown_02032188[8], 24); + DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); + DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->timer = 0; break; case 11: - if (sub_807A1F0()) + if (LoadTradeMenuSpriteSheetsAndPalettes()) gMain.state++; break; case 12: @@ -1915,23 +744,23 @@ static void sub_8077B74(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - if (gUnknown_0203229C->tradeMenuCursorPosition < PARTY_SIZE) - gUnknown_0203229C->tradeMenuCursorPosition = gLastViewedMonIndex; + if (sTradeMenuData->cursorPosition < PARTY_SIZE) + sTradeMenuData->cursorPosition = gLastViewedMonIndex; else - gUnknown_0203229C->tradeMenuCursorPosition = gLastViewedMonIndex + PARTY_SIZE; + sTradeMenuData->cursorPosition = gLastViewedMonIndex + PARTY_SIZE; - gUnknown_0203229C->tradeMenuCursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[gUnknown_0203229C->tradeMenuCursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[gUnknown_0203229C->tradeMenuCursorPosition][1] * 8, 2); + sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, sTradeMonSpriteCoords[sTradeMenuData->cursorPosition][0] * 8 + 32, sTradeMonSpriteCoords[sTradeMenuData->cursorPosition][1] * 8, 2); gMain.state = 16; break; case 16: - sub_80782B8(0); + LoadTradeBgGfx(0); gMain.state++; break; case 17: - sub_80782B8(1); - gUnknown_0203229C->unk_0 = 0; - gUnknown_0203229C->unk_1 = 0; - sub_8078388(); + LoadTradeBgGfx(1); + sTradeMenuData->bg2hofs = 0; + sTradeMenuData->bg3hofs = 0; + SetTradePartyMonsVisible(); gMain.state++; break; case 18: @@ -1942,20 +771,20 @@ static void sub_8077B74(void) break; case 19: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - sub_80782B8(2); + LoadTradeBgGfx(2); gMain.state++; break; case 20: gMain.state++; break; case 21: - sub_807A53C(); + SetTradePartyHPBarSprites(); gMain.state++; break; case 22: if (!gPaletteFade.active) { - SetMainCallback2(sub_807825C); + SetMainCallback2(CB2_TradeMenu); } break; } @@ -1966,81 +795,81 @@ static void sub_8077B74(void) UpdatePaletteFade(); } -static void sub_807811C(void) +static void VBlankCB_TradeMenu(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static void sub_8078130(void) +static void LinkTradeFadeOut(void) { - if (++gUnknown_0203229C->unk_A8 > 15) + if (++sTradeMenuData->timer > 15) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 10; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE; } } -static void sub_807816C(void) +static void LinkTradeWaitForFade(void) { if (!gPaletteFade.active) { - gUnknown_02032298[0] = gUnknown_0203229C->tradeMenuCursorPosition; - gUnknown_02032298[1] = gUnknown_0203229C->unk_7E; + gSelectedTradeMonPositions[TRADE_PLAYER] = sTradeMenuData->cursorPosition; + gSelectedTradeMonPositions[TRADE_PARTNER] = sTradeMenuData->partnerCursorPosition; if (gWirelessCommType) { - gUnknown_0203229C->unk_6F = 16; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_QUEUE; } else { sub_800ABF4(32); - gUnknown_0203229C->unk_6F = 13; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_START_LINK_TRADE; } } } -static void sub_80781C8(void) +static void SetLinkTradeCallbacks(void) { - gMain.savedCallback = sub_80773AC; + gMain.savedCallback = CB2_StartCreateTradeMenu; + // Wireless Link Trade if (gWirelessCommType) { - if (sub_8010500()) + if (IsLinkRfuTaskFinished()) { - Free(gUnknown_02032184); + Free(sMessageBoxAllocBuffer); FreeAllWindowBuffers(); - Free(gUnknown_0203229C); + Free(sTradeMenuData); gMain.callback1 = NULL; DestroyWirelessStatusIndicatorSprite(); - SetMainCallback2(sub_807AE50); + SetMainCallback2(CB2_LinkTrade); } } + // Cable Link Trade else { if (!gReceivedRemoteLinkPlayers) { - Free(gUnknown_02032184); + Free(sMessageBoxAllocBuffer); FreeAllWindowBuffers(); - Free(gUnknown_0203229C); + Free(sTradeMenuData); gMain.callback1 = NULL; - SetMainCallback2(sub_807AE50); + SetMainCallback2(CB2_LinkTrade); } } } -static void sub_807825C(void) +static void CB2_TradeMenu(void) { - u8 temp; + CallTradeMenuFunc(); + DoQueuedActions(); + DrawTradeMenuParty(TRADE_PLAYER); + DrawTradeMenuParty(TRADE_PARTNER); - sub_80795AC(); - sub_807A0C4(); - sub_80796B4(0); - sub_80796B4(1); - - SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_0203229C->unk_0++); - SetGpuReg(REG_OFFSET_BG3HOFS, gUnknown_0203229C->unk_1--); + SetGpuReg(REG_OFFSET_BG2HOFS, sTradeMenuData->bg2hofs++); + SetGpuReg(REG_OFFSET_BG3HOFS, sTradeMenuData->bg3hofs--); RunTextPrintersAndIsPrinter0Active(); RunTasks(); @@ -2049,22 +878,22 @@ static void sub_807825C(void) UpdatePaletteFade(); } -static void sub_80782B8(u8 a0) +static void LoadTradeBgGfx(u8 state) { int i; - switch (a0) + switch (state) { case 0: - LoadPalette(gUnknown_08DDB3E4, 0, 0x60); - LoadBgTiles(1, gUnknown_08DDB464, 0x1280, 0); + LoadPalette(gTradeMenu_Pal, 0, 0x60); + LoadBgTiles(1, gTradeMenu_Gfx, 0x1280, 0); CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDCF04, 0, 0, 32, 20, 0); - LoadBgTilemap(2, gTradeStripesBG2Tilemap, 0x800, 0); + LoadBgTilemap(2, sTradeStripesBG2Tilemap, 0x800, 0); break; case 1: - LoadBgTilemap(3, gTradeStripesBG3Tilemap, 0x800, 0); - sub_8079E44(0); - sub_8079E44(1); + LoadBgTilemap(3, sTradeStripesBG3Tilemap, 0x800, 0); + DrawTradeMenuPartyInfo(TRADE_PLAYER); + DrawTradeMenuPartyInfo(TRADE_PARTNER); CopyBgTilemapBufferToVram(1); break; case 2: @@ -2080,34 +909,34 @@ static void sub_80782B8(u8 a0) } } -static void sub_8078388(void) +static void SetTradePartyMonsVisible(void) { int i; for (i = 0; i < PARTY_SIZE; i++) { - if (i < gUnknown_0203229C->partyCounts[0]) + if (i < sTradeMenuData->partyCounts[TRADE_PLAYER]) { - gSprites[gUnknown_0203229C->partyIcons[0][i]].invisible = FALSE; - gUnknown_0203229C->tradeMenuOptionsActive[i] = TRUE; + gSprites[sTradeMenuData->partySpriteIds[TRADE_PLAYER][i]].invisible = FALSE; + sTradeMenuData->monPresent[i] = TRUE; } else { - gUnknown_0203229C->tradeMenuOptionsActive[i] = FALSE; + sTradeMenuData->monPresent[i] = FALSE; } - if (i < gUnknown_0203229C->partyCounts[1]) + if (i < sTradeMenuData->partyCounts[TRADE_PARTNER]) { - gSprites[gUnknown_0203229C->partyIcons[1][i]].invisible = FALSE; - gUnknown_0203229C->tradeMenuOptionsActive[i + PARTY_SIZE] = TRUE; + gSprites[sTradeMenuData->partySpriteIds[TRADE_PARTNER][i]].invisible = FALSE; + sTradeMenuData->monPresent[i + PARTY_SIZE] = TRUE; } else { - gUnknown_0203229C->tradeMenuOptionsActive[i + PARTY_SIZE] = FALSE; + sTradeMenuData->monPresent[i + PARTY_SIZE] = FALSE; } } - gUnknown_0203229C->unk_44 = 1; + sTradeMenuData->neverRead_44 = TRUE; } // why not just use memcpy? @@ -2123,30 +952,30 @@ static void Trade_Memcpy(void *dataDest, const void *dataSrc, u32 count) } } -static bool8 shedinja_maker_maybe(void) +static bool8 BufferTradeParties(void) { u8 id = GetMultiplayerId(); int i; struct Pokemon *mon; - switch (gUnknown_0203229C->unk_69) + switch (sTradeMenuData->bufferPartyState) { case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); - gUnknown_0203229C->unk_69++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->bufferPartyState++; + sTradeMenuData->timer = 0; break; case 1: if (sub_80771BC()) { if (_GetBlockReceivedStatus() == 0) { - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; } else { - sub_8077210(); - gUnknown_0203229C->unk_69++; + TradeResetReceivedFlags(); + sTradeMenuData->bufferPartyState++; } } break; @@ -2155,90 +984,90 @@ static bool8 shedinja_maker_maybe(void) { sub_80771AC(1); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 4: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon)); - sub_8077210(); - gUnknown_0203229C->unk_69++; + TradeResetReceivedFlags(); + sTradeMenuData->bufferPartyState++; } break; case 5: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon)); - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 7: if (id == 0) { sub_80771AC(1); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 8: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200); - sub_8077210(); - gUnknown_0203229C->unk_69++; + TradeResetReceivedFlags(); + sTradeMenuData->bufferPartyState++; } break; case 9: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200); - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 11: if (id == 0) { sub_80771AC(1); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 12: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200); - sub_8077210(); - gUnknown_0203229C->unk_69++; + TradeResetReceivedFlags(); + sTradeMenuData->bufferPartyState++; } break; case 13: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220); - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 15: if (id == 0) { sub_80771AC(3); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 16: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(gUnknown_020321C0, gBlockRecvBuffer[id ^ 1], 216); - sub_8077210(); - gUnknown_0203229C->unk_69++; + Trade_Memcpy(gTradeMail, gBlockRecvBuffer[id ^ 1], 216); + TradeResetReceivedFlags(); + sTradeMenuData->bufferPartyState++; } break; case 17: - Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, 11); - gUnknown_0203229C->unk_69++; + Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, ARRAY_COUNT(sTradeMenuData->giftRibbons)); + sTradeMenuData->bufferPartyState++; break; case 19: if (id == 0) { sub_80771AC(4); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->bufferPartyState++; break; case 20: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(gUnknown_0203229C->unk_A9, gBlockRecvBuffer[id ^ 1], 11); - sub_8077210(); - gUnknown_0203229C->unk_69++; + Trade_Memcpy(sTradeMenuData->giftRibbons, gBlockRecvBuffer[id ^ 1], ARRAY_COUNT(sTradeMenuData->giftRibbons)); + TradeResetReceivedFlags(); + sTradeMenuData->bufferPartyState++; } break; case 21: @@ -2253,7 +1082,7 @@ static bool8 shedinja_maker_maybe(void) { GetMonData(mon, MON_DATA_NICKNAME, name); - if (!StringCompareWithoutExtCtrlCodes(name, gJPText_Shedinja)) + if (!StringCompareWithoutExtCtrlCodes(name, sJPText_Shedinja)) { SetMonData(mon, MON_DATA_NICKNAME, gSpeciesNames[SPECIES_SHEDINJA]); } @@ -2261,189 +1090,198 @@ static bool8 shedinja_maker_maybe(void) } } return TRUE; + // Delay until next state case 2: case 6: case 10: case 14: case 18: - gUnknown_0203229C->unk_A8++; - if (gUnknown_0203229C->unk_A8 > 10) + sTradeMenuData->timer++; + if (sTradeMenuData->timer > 10) { - gUnknown_0203229C->unk_A8 = 0; - gUnknown_0203229C->unk_69++; + sTradeMenuData->timer = 0; + sTradeMenuData->bufferPartyState++; } break; } return FALSE; } -static void sub_80787B8(void) +static void PrintAndBufferIsThisTradeOkay(void) { - sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (gUnknown_0203229C->unk_72 * 32)), 24); + DrawTextWindowAndBuffer6Bytes(sText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->bottomTextTileStart * 32)), 24); } -static void sub_80787E0(u8 a0, u8 a1) +// mpId is unused +static void UpdateLinkTradeFlags(u8 mpId, u8 status) { - if (a1 & 1) + if (status & 1) { switch (gBlockRecvBuffer[0][0]) { - case 0xEEAA: - gUnknown_0203229C->unk_78 = 2; + case LINKCMD_REQUEST_CANCEL: + sTradeMenuData->playerLinkFlagChoseAction = WANTS_TO_CANCEL; break; - case 0xAABB: - gUnknown_0203229C->unk_78 = 1; + case LINKCMD_READY_TO_TRADE: + sTradeMenuData->playerLinkFlagChoseAction = WANTS_TO_TRADE; break; - case 0xBBBB: - gUnknown_0203229C->unk_7A = 1; + case LINKCMD_INIT_BLOCK: + sTradeMenuData->playerLinkFlagStatus = INITIATE_TRADE; break; - case 0xBBCC: - gUnknown_0203229C->unk_7A = 2; + case LINKCMD_READY_CANCEL_TRADE: + sTradeMenuData->playerLinkFlagStatus = CANCEL_TRADE; break; } - sub_8077234(0); + TradeResetReceivedFlag(0); } - if (a1 & 2) + if (status & 2) { switch (gBlockRecvBuffer[1][0]) { - case 0xEEAA: - gUnknown_0203229C->unk_79 = 2; + case LINKCMD_REQUEST_CANCEL: + sTradeMenuData->partnerLinkFlagChoseAction = WANTS_TO_CANCEL; break; - case 0xAABB: - gUnknown_0203229C->unk_7E = gBlockRecvBuffer[1][1] + 6; - gUnknown_0203229C->unk_79 = 1; + case LINKCMD_READY_TO_TRADE: + sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; + sTradeMenuData->partnerLinkFlagChoseAction = WANTS_TO_TRADE; break; - case 0xBBBB: - gUnknown_0203229C->unk_7B = 1; + case LINKCMD_INIT_BLOCK: + sTradeMenuData->partnerLinkFlagStatus = INITIATE_TRADE; break; - case 0xBBCC: - gUnknown_0203229C->unk_7B = 2; + case LINKCMD_READY_CANCEL_TRADE: + sTradeMenuData->partnerLinkFlagStatus = CANCEL_TRADE; break; } - sub_8077234(1); + TradeResetReceivedFlag(1); } } -static void sub_8078900(u8 a0, u8 a1) +// mpId is unused +static void ReactToLinkTradeData(u8 mpId, u8 status) { - if (a1 & 1) + if (status & 1) { switch (gBlockRecvBuffer[0][0]) { - case 0xEEBB: + case LINKCMD_CANCEL_TRADE: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sub_807A19C(4); - gUnknown_0203229C->unk_6F = 11; + PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1; break; - case 0xEECC: - sub_807A19C(5); - gUnknown_0203229C->unk_6F = 8; + case LINKCMD_0xEECC: + PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; - case 0xDDDD: - gUnknown_0203229C->unk_7E = gBlockRecvBuffer[0][1] + 6; + case LINKCMD_SET_MONS_TO_TRADE: + sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[0][1] + 6; rbox_fill_rectangle(0); - sub_807967C(gUnknown_0203229C->tradeMenuCursorPosition); - sub_807967C(gUnknown_0203229C->unk_7E); - gUnknown_0203229C->unk_6F = 7; + SetSelectedMon(sTradeMenuData->cursorPosition); + SetSelectedMon(sTradeMenuData->partnerCursorPosition); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CONFIRM_TRADE_PROMPT; break; - case 0xCCDD: + case LINKCMD_START_TRADE: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 10; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE; break; - case 0xDDEE: - sub_807A19C(1); - gUnknown_0203229C->unk_6F = 8; + case LINKCMD_0xDDEE: + PrintTradeMessage(TRADE_MSG_CANCELED); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } - sub_8077234(0); + TradeResetReceivedFlag(0); } - if (a1 & 2) - sub_8077234(1); + if (status & 2) + TradeResetReceivedFlag(1); } -static void sub_80789FC(void) +static void QueueLinkTradeData(void) { - if (gUnknown_0203229C->unk_78 && gUnknown_0203229C->unk_79) + if (sTradeMenuData->playerLinkFlagChoseAction && sTradeMenuData->partnerLinkFlagChoseAction) { - if (gUnknown_0203229C->unk_78 == 1 && gUnknown_0203229C->unk_79 == 1) + if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_TRADE + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { - gUnknown_0203229C->unk_6F = 6; - gUnknown_0203229C->linkData[0] = 0xDDDD; - gUnknown_0203229C->linkData[1] = gUnknown_0203229C->tradeMenuCursorPosition; - sub_807A048(5, 0); - gUnknown_0203229C->unk_78 = gUnknown_0203229C->unk_79 = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_BOTH_MONS_SELECTED; + sTradeMenuData->linkData[0] = LINKCMD_SET_MONS_TO_TRADE; + sTradeMenuData->linkData[1] = sTradeMenuData->cursorPosition; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; } - else if (gUnknown_0203229C->unk_78 == 1 && gUnknown_0203229C->unk_79 == 2) + else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_TRADE + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { - sub_807A19C(1); - gUnknown_0203229C->linkData[0] = 0xEECC; - gUnknown_0203229C->linkData[1] = 0; - sub_807A048(5, 0); - gUnknown_0203229C->unk_7A = gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_78 = gUnknown_0203229C->unk_79 = 0; - gUnknown_0203229C->unk_6F = 8; + PrintTradeMessage(TRADE_MSG_CANCELED); + sTradeMenuData->linkData[0] = LINKCMD_0xEECC; + sTradeMenuData->linkData[1] = 0; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } - else if (gUnknown_0203229C->unk_78 == 2 && gUnknown_0203229C->unk_79 == 1) + else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { - sub_807A19C(5); - gUnknown_0203229C->linkData[0] = 0xDDEE; - gUnknown_0203229C->linkData[1] = 0; - sub_807A048(5, 0); - gUnknown_0203229C->unk_7A = gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_78 = gUnknown_0203229C->unk_79 = 0; - gUnknown_0203229C->unk_6F = 8; + PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); + sTradeMenuData->linkData[0] = LINKCMD_0xDDEE; + sTradeMenuData->linkData[1] = 0; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } - else if (gUnknown_0203229C->unk_78 == 2 && gUnknown_0203229C->unk_79 == 2) + else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { - gUnknown_0203229C->linkData[0] = 0xEEBB; - gUnknown_0203229C->linkData[1] = 0; - sub_807A048(5, 0); + sTradeMenuData->linkData[0] = LINKCMD_CANCEL_TRADE; + sTradeMenuData->linkData[1] = 0; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_78 = gUnknown_0203229C->unk_79 = 0; - gUnknown_0203229C->unk_6F = 11; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1; } } - if (gUnknown_0203229C->unk_7A && gUnknown_0203229C->unk_7B) + if (sTradeMenuData->playerLinkFlagStatus && sTradeMenuData->partnerLinkFlagStatus) { - if (gUnknown_0203229C->unk_7A == 1 && gUnknown_0203229C->unk_7B == 1) + if (sTradeMenuData->playerLinkFlagStatus == INITIATE_TRADE + && sTradeMenuData->partnerLinkFlagStatus == INITIATE_TRADE) { - gUnknown_0203229C->linkData[0] = 0xCCDD; - gUnknown_0203229C->linkData[1] = 0; - sub_807A048(5, 0); - gUnknown_0203229C->unk_7A = 0; - gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_6F = 9; + sTradeMenuData->linkData[0] = LINKCMD_START_TRADE; + sTradeMenuData->linkData[1] = 0; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeMenuData->playerLinkFlagStatus = 0; + sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_FADE_OUT; } - if (gUnknown_0203229C->unk_7A == 2 || gUnknown_0203229C->unk_7B == 2) + if (sTradeMenuData->playerLinkFlagStatus == CANCEL_TRADE + || sTradeMenuData->partnerLinkFlagStatus == CANCEL_TRADE) { - sub_807A19C(1); - gUnknown_0203229C->linkData[0] = 0xDDEE; - gUnknown_0203229C->linkData[1] = 0; - sub_807A048(5, 0); - gUnknown_0203229C->unk_7A = 0; - gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_6F = 8; + PrintTradeMessage(TRADE_MSG_CANCELED); + sTradeMenuData->linkData[0] = LINKCMD_0xDDEE; + sTradeMenuData->linkData[1] = 0; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeMenuData->playerLinkFlagStatus = 0; + sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } } } -static void sub_8078BFC(u16 *a0, u16 a1, u16 a2) +static void _SetLinkData(u16 *linkData, u16 linkCmd, u16 cursorPosition) { - a0[0] = a1; - a0[1] = a2; - sub_807A048(5, 0); + linkData[0] = linkCmd; + linkData[1] = cursorPosition; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); } -static void sub_8078C10(u16 a0, u16 a1) +static void SetLinkData(u16 linkCmd, u16 cursorPosition) { - sub_8078BFC(gUnknown_0203229C->linkData, a0, a1); + _SetLinkData(sTradeMenuData->linkData, linkCmd, cursorPosition); } -static void sub_8078C34(void) +static void CB1_SendOrReactToLinkTradeData(void) { u8 mpId = GetMultiplayerId(); u8 status; @@ -2451,25 +1289,25 @@ static void sub_8078C34(void) if ((status = _GetBlockReceivedStatus())) { if (mpId == 0) - sub_80787E0(mpId, status); + UpdateLinkTradeFlags(mpId, status); else - sub_8078900(mpId, status); + ReactToLinkTradeData(mpId, status); } if (mpId == 0) - sub_80789FC(); + QueueLinkTradeData(); } -static u8 sub_8078C6C(u8 oldPosition, u8 direction) +static u8 GetNewTradeMenuPosition(u8 oldPosition, u8 direction) { int i; u8 newPosition = 0; for (i = 0; i < PARTY_SIZE; i++) { - if (gUnknown_0203229C->tradeMenuOptionsActive[gTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) + if (sTradeMenuData->monPresent[sTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) { - newPosition = gTradeNextSelectedMonTable[oldPosition][direction][i]; + newPosition = sTradeNextSelectedMonTable[oldPosition][direction][i]; break; } } @@ -2477,258 +1315,247 @@ static u8 sub_8078C6C(u8 oldPosition, u8 direction) return newPosition; } -static void TradeMenuMoveCursor(u8 *tradeMenuCursorPosition, u8 direction) +static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) { - u8 newPosition = sub_8078C6C(*tradeMenuCursorPosition, direction); + u8 newPosition = GetNewTradeMenuPosition(*cursorPosition, direction); - if (newPosition == 12) // CANCEL + if (newPosition == (PARTY_SIZE * 2)) // CANCEL { - StartSpriteAnim(&gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx], 1); - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].pos1.x = 224; - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].pos1.y = 160; + StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 1); + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = 224; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = 160; } else { - StartSpriteAnim(&gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx], 0); - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].pos1.x = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; + StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 0); + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = sTradeMonSpriteCoords[newPosition][0] * 8 + 32; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = sTradeMonSpriteCoords[newPosition][1] * 8; } - if (*tradeMenuCursorPosition != newPosition) + if (*cursorPosition != newPosition) { PlaySE(SE_SELECT); } - *tradeMenuCursorPosition = newPosition; + *cursorPosition = newPosition; } -static void sub_8078D78(void) +static void SetReadyToTrade(void) { - sub_807A19C(0); - gUnknown_0203229C->unk_6F = 100; + PrintTradeMessage(TRADE_MSG_STANDBY); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; if (GetMultiplayerId() == 1) - { - sub_8078C10(0xAABB, gUnknown_0203229C->tradeMenuCursorPosition); - } + SetLinkData(LINKCMD_READY_TO_TRADE, sTradeMenuData->cursorPosition); else - { - gUnknown_0203229C->unk_78 = 1; - } + sTradeMenuData->playerLinkFlagChoseAction = WANTS_TO_TRADE; } -static void sub_8078DBC(void) +static void TradeMenuProcessInput(void) { if (gMain.newAndRepeatedKeys & DPAD_UP) { - TradeMenuMoveCursor(&gUnknown_0203229C->tradeMenuCursorPosition, 0); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 0); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - TradeMenuMoveCursor(&gUnknown_0203229C->tradeMenuCursorPosition, 1); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 1); } else if (gMain.newAndRepeatedKeys & DPAD_LEFT) { - TradeMenuMoveCursor(&gUnknown_0203229C->tradeMenuCursorPosition, 2); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 2); } else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { - TradeMenuMoveCursor(&gUnknown_0203229C->tradeMenuCursorPosition, 3); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 3); } if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - if (gUnknown_0203229C->tradeMenuCursorPosition < 6) + // Cursor is in player's party + if (sTradeMenuData->cursorPosition < PARTY_SIZE) { DrawTextBorderOuter(1, 1, 14); FillWindowPixelBuffer(1, PIXEL_FILL(1)); - PrintMenuTable(1, 2, gUnknown_0832DEAC); + PrintMenuTable(1, ARRAY_COUNT(sSelectTradeMonActions), sSelectTradeMonActions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); PutWindowTilemap(1); CopyWindowToVram(1, 3); - gUnknown_0203229C->unk_6F = 1; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SELECTED_MON; } - else if (gUnknown_0203229C->tradeMenuCursorPosition < 12) + // Cursor is in partner's party + else if (sTradeMenuData->cursorPosition < PARTY_SIZE * 2) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 2; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; } - else if (gUnknown_0203229C->tradeMenuCursorPosition == 12) + // Cursor is on Cancel + else if (sTradeMenuData->cursorPosition == PARTY_SIZE * 2) { - CreateYesNoMenu(&gUnknown_0832DF8C, 1, 14, 0); - gUnknown_0203229C->unk_6F = 4; - sub_807A308(gUnknown_0832DE94[4], (void *)(OBJ_VRAM0 + gUnknown_0203229C->unk_72 * 32), 24); + CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_PROMPT; + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeMenuData->bottomTextTileStart * 32), 24); } } } -static void sub_8078EF8(void) +static void TradeMenuChooseMon(void) { - sub_8079F74(); - gUnknown_0203229C->unk_6F = 0; - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = FALSE; - sub_807A308(gUnknown_0832DE94[1], (void *)(OBJ_VRAM0 + gUnknown_0203229C->unk_72 * 32), 24); + PrintNicknamesForTradeMenu(); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_MAIN_MENU; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeMenuData->bottomTextTileStart * 32), 24); } -static void sub_8078F50(void) +static void TradeMenuProcessInput_SelectedMon(void) { switch (Menu_ProcessInputNoWrap()) { - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - sub_8078EF8(); + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + TradeMenuChooseMon(); + break; + case MENU_NOTHING_CHOSEN: + break; + case 0: // Summary + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; + break; + case 1: // Trade + switch (CanTradeSelectedMon(gPlayerParty, gPlayerPartyCount, sTradeMenuData->cursorPosition)) + { + case CAN_TRADE_MON: + SetReadyToTrade(); + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; break; - case MENU_NOTHING_CHOSEN: + case CANT_TRADE_LAST_MON: + QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; - case 0: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 2; + case CANT_TRADE_NATIONAL: + case CANT_TRADE_INVALID_MON: + QueueAction(QUEUE_DELAY_MSG, QUEUE_MON_CANT_BE_TRADED); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; - case 1: - switch (sub_807A5F4(gPlayerParty, gPlayerPartyCount, gUnknown_0203229C->tradeMenuCursorPosition)) - { - case 0: - sub_8078D78(); - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = TRUE; - break; - case 1: - sub_807A048(3, 3); - gUnknown_0203229C->unk_6F = 8; - break; - case 2: - case 4: - sub_807A048(3, 6); - gUnknown_0203229C->unk_6F = 8; - break; - case 3: - case 5: - sub_807A048(3, 7); - gUnknown_0203229C->unk_6F = 8; - break; - } + case CANT_TRADE_EGG: + case CANT_TRADE_EGG2: + QueueAction(QUEUE_DELAY_MSG, QUEUE_EGG_CANT_BE_TRADED); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; + } + break; } } -static void sub_8079034(void) +static void ChooseMonAfterButtonPress(void) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); - sub_8078EF8(); + TradeMenuChooseMon(); } } -static void sub_807905C(void) +static void TradeMenuShowMonSummaryScreen(void) { if (!gPaletteFade.active) { - if (gUnknown_0203229C->tradeMenuCursorPosition < PARTY_SIZE) - { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gUnknown_0203229C->tradeMenuCursorPosition, gUnknown_0203229C->partyCounts[0] - 1, sub_8077B74); - } + // Player's party + if (sTradeMenuData->cursorPosition < PARTY_SIZE) + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, sTradeMenuData->cursorPosition, sTradeMenuData->partyCounts[TRADE_PLAYER] - 1, CB2_ReturnToTradeMenu); + // Partner's party else - { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, gUnknown_0203229C->tradeMenuCursorPosition - PARTY_SIZE, gUnknown_0203229C->partyCounts[1] - 1, sub_8077B74); - } + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, sTradeMenuData->cursorPosition - PARTY_SIZE, sTradeMenuData->partyCounts[TRADE_PARTNER] - 1, CB2_ReturnToTradeMenu); FreeAllWindowBuffers(); } } -static u8 sub_80790D4(u8 *a0, u8 a1, u8 a2, u8 a3) +static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 playerMonIdx, u8 partnerMonIdx) { int i; - u16 species; - u8 res = 0; + u16 partnerSpecies; + u8 hasLiveMon = 0; - for (i = 0; i < a1; i++) + // Make sure mon to be traded isn't player's last alive mon + for (i = 0; i < playerPartyCount; i++) { - if (a2 != i) - { - res += a0[i]; - } - } - - a3 %= PARTY_SIZE; - species = GetMonData(&gEnemyParty[a3], MON_DATA_SPECIES); - - if (species == SPECIES_DEOXYS || species == SPECIES_MEW) - { - if (!GetMonData(&gEnemyParty[a3], MON_DATA_OBEDIENCE)) - { - return 2; - } + if (playerMonIdx != i) + hasLiveMon += aliveMons[i]; + } + partnerMonIdx %= PARTY_SIZE; + partnerSpecies = GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_SPECIES); + + // Partner cant trade illegitimate Deoxys or Mew + if (partnerSpecies == SPECIES_DEOXYS || partnerSpecies == SPECIES_MEW) + { + if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_OBEDIENCE)) + return PARTNER_MON_INVALID; } + // Partner cant trade Egg or non-Hoenn mon if player doesn't have National Dex if (!IsNationalPokedexEnabled()) { - if (gUnknown_0203229C->unk_51[1][a3] || !IsSpeciesInHoennDex(species)) - { - return 2; - } + if (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(partnerSpecies)) + return PARTNER_MON_INVALID; } - if (res) - { - res = 1; - } + if (hasLiveMon) + hasLiveMon = BOTH_MONS_VALID; - return res; + return hasLiveMon; //PLAYER_MON_INVALID or BOTH_MONS_VALID } -static bool32 sub_8079174(void) +// Returns TRUE if the partner's selected mon is invalid, FALSE otherwise +static bool32 CheckMonsBeforeTrade(void) { int i; - u8 arr[12]; + u8 aliveMons[PARTY_SIZE * 2]; - for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { - arr[i] = gUnknown_0203229C->unk_45[0][i]; + aliveMons[i] = sTradeMenuData->isLiveMon[TRADE_PLAYER][i]; } - switch (sub_80790D4(arr, gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->tradeMenuCursorPosition, gUnknown_0203229C->unk_7E)) + switch (CheckValidityOfTradeMons(aliveMons, sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->cursorPosition, sTradeMenuData->partnerCursorPosition)) { - case 0: - sub_807A048(3, 3); - sub_8078C10(0xBBCC, 0); - break; - case 1: - sub_807A048(3, 1); - sub_8078C10(0xBBBB, 0); - break; - case 2: - sub_807A048(3, 8); - return TRUE; + case PLAYER_MON_INVALID: + QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); + SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); + break; + case BOTH_MONS_VALID: + QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); + SetLinkData(LINKCMD_INIT_BLOCK, 0); + break; + case PARTNER_MON_INVALID: + QueueAction(QUEUE_DELAY_MSG, QUEUE_FRIENDS_MON_CANT_BE_TRADED); + return TRUE; } return FALSE; } -static void sub_8079218(void) +static void ConfirmOrCancelTrade(void) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - if (!sub_8079174()) - { - gUnknown_0203229C->unk_6F = 100; - } - else - { - gUnknown_0203229C->unk_6F = 17; - } - PutWindowTilemap(17); - break; - case 1: - case MENU_B_PRESSED: - sub_807A048(3, 1); - if (sub_80771BC()) - sub_8078C10(0xBBCC, 0); - gUnknown_0203229C->unk_6F = 100; - PutWindowTilemap(17); - break; + case 0: // Confirm Trade + if (!CheckMonsBeforeTrade()) + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; + else + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_PARTNER_MON_INVALID; + + PutWindowTilemap(17); + break; + case 1: // Cancel Trade + case MENU_B_PRESSED: + QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); + if (sub_80771BC()) + SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; + PutWindowTilemap(17); + break; } } @@ -2736,65 +1563,66 @@ static void sub_807929C(void) { int i; - for (i = 0; i < gUnknown_0203229C->partyCounts[1] - 4; i++) + for (i = 0; i < sTradeMenuData->partyCounts[1] - 4; i++) { PutWindowTilemap(i + 12); CopyWindowToVram(i + 12, 1); } } -static void sub_80792E4(void) +static void CancelTradeYesNo(void) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - sub_807A19C(4); - sub_8078C10(0xEEAA, 0); - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = TRUE; - gUnknown_0203229C->unk_6F = 100; - sub_807929C(); - break; - case 1: - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - sub_8078EF8(); - break; + case 0: // YES, Cancel + PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); + SetLinkData(LINKCMD_REQUEST_CANCEL, 0); + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; + sub_807929C(); + break; + case 1: // NO, Continue + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + TradeMenuChooseMon(); + break; } } -static void sub_807935C(void) +static void SetBothSelectedMons(void) { if (GetMultiplayerId() == 0) { rbox_fill_rectangle(0); - sub_807967C(gUnknown_0203229C->tradeMenuCursorPosition); - sub_807967C(gUnknown_0203229C->unk_7E); + SetSelectedMon(sTradeMenuData->cursorPosition); + SetSelectedMon(sTradeMenuData->partnerCursorPosition); } - gUnknown_0203229C->unk_6F = 7; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CONFIRM_TRADE_PROMPT; } -static void sub_8079398(void) +static void ConfirmTradePrompt(void) { - if (gUnknown_0203229C->unk_74[0] == 5 && gUnknown_0203229C->unk_74[1] == 5) + if (sTradeMenuData->drawPartyState[TRADE_PLAYER] == DRAW_PARTY_FINISH + && sTradeMenuData->drawPartyState[TRADE_PARTNER] == DRAW_PARTY_FINISH) { - sub_80787B8(); - gUnknown_0203229C->unk_6F = 14; + PrintAndBufferIsThisTradeOkay(); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_DELAY_TRADE_CONFIRM; } } -static void Wait2SecondsAndCreateYesNoMenu(void) +static void DelayTradeConfirmation(void) { - gUnknown_0203229C->unk_A8++; + sTradeMenuData->timer++; - if (gUnknown_0203229C->unk_A8 > 120) + if (sTradeMenuData->timer > 120) { - CreateYesNoMenu(&gUnknown_0832DF8C, 1, 14, 0); - gUnknown_0203229C->unk_A8 = 0; - gUnknown_0203229C->unk_6F = 3; + CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); + sTradeMenuData->timer = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CONFIRM_OR_CANCEL_TRADE; } } -static void sub_8079408(void) +static void RedrawTradeMenuAfterPressA(void) { int i; @@ -2810,14 +1638,14 @@ static void sub_8079408(void) rbox_fill_rectangle(i + 14); } - sub_8079F88(0); - sub_8079F88(1); - gUnknown_0203229C->unk_6F = 0; - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = FALSE; + RedrawTradeMenuParty(TRADE_PLAYER); + RedrawTradeMenuParty(TRADE_PARTNER); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_MAIN_MENU; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; } } -static void sub_8079490(void) +static void CancelTrade_1(void) { if (!gPaletteFade.active) { @@ -2830,18 +1658,18 @@ static void sub_8079490(void) sub_800ABF4(12); } - gUnknown_0203229C->unk_6F = 12; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_2; } } -static void sub_80794CC(void) +static void CancelTrade_2(void) { if (gWirelessCommType) { - if (sub_80771BC() && sub_807A09C() == 0) + if (sub_80771BC() && GetNumQueuedActions() == 0) { - Free(gUnknown_02032184); - Free(gUnknown_0203229C); + Free(sMessageBoxAllocBuffer); + Free(sTradeMenuData); FreeAllWindowBuffers(); DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); @@ -2851,177 +1679,183 @@ static void sub_80794CC(void) { if (!gReceivedRemoteLinkPlayers) { - Free(gUnknown_02032184); - Free(gUnknown_0203229C); + Free(sMessageBoxAllocBuffer); + Free(sTradeMenuData); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); } } } -static void sub_8079550(void) +static void LinkTradeWaitForQueue(void) { - if (!sub_801048C(FALSE) && sub_807A09C() == 0) + if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0) { sub_800ADF8(); - gUnknown_0203229C->unk_6F = 13; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_START_LINK_TRADE; } } -static void sub_807957C(void) +static void PartnersMonWasInvalid(void) { if (gMain.newKeys & A_BUTTON) { - sub_8078C10(0xBBCC, 0); - gUnknown_0203229C->unk_6F = 100; + SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; } } -static void sub_80795AC(void) +static void CallTradeMenuFunc(void) { - switch (gUnknown_0203229C->unk_6F) + switch (sTradeMenuData->tradeMenuFunc) { - case 0: - sub_8078DBC(); - break; - case 1: - sub_8078F50(); - break; - case 2: - sub_807905C(); - break; - case 3: - sub_8079218(); - break; - case 4: - sub_80792E4(); - break; - case 6: - sub_807935C(); - break; - case 7: - sub_8079398(); - break; - case 8: - sub_8079408(); - break; - case 9: - sub_8078130(); - break; - case 10: - sub_807816C(); - break; - case 11: - sub_8079490(); - break; - case 12: - sub_80794CC(); - break; - case 13: - sub_80781C8(); - break; - case 14: - Wait2SecondsAndCreateYesNoMenu(); - break; - case 15: - sub_8079034(); - break; - case 16: - sub_8079550(); - break; - case 17: - sub_807957C(); - break; + case TRADEMENUFUNC_MAIN_MENU: + TradeMenuProcessInput(); + break; + case TRADEMENUFUNC_SELECTED_MON: + TradeMenuProcessInput_SelectedMon(); + break; + case TRADEMENUFUNC_SHOW_MON_SUMMARY: + TradeMenuShowMonSummaryScreen(); + break; + case TRADEMENUFUNC_CONFIRM_OR_CANCEL_TRADE: + ConfirmOrCancelTrade(); + break; + case TRADEMENUFUNC_CANCEL_TRADE_PROMPT: + CancelTradeYesNo(); + break; + case TRADEMENUFUNC_BOTH_MONS_SELECTED: + SetBothSelectedMons(); + break; + case TRADEMENUFUNC_CONFIRM_TRADE_PROMPT: + ConfirmTradePrompt(); + break; + case TRADEMENUFUNC_REDRAW_MAIN_MENU: + RedrawTradeMenuAfterPressA(); + break; + case TRADEMENUFUNC_LINK_TRADE_FADE_OUT: + LinkTradeFadeOut(); + break; + case TRADEMENUFUNC_LINK_TRADE_WAIT_FADE: + LinkTradeWaitForFade(); + break; + case TRADEMENUFUNC_CANCEL_TRADE_1: + CancelTrade_1(); + break; + case TRADEMENUFUNC_CANCEL_TRADE_2: + CancelTrade_2(); + break; + case TRADEMENUFUNC_START_LINK_TRADE: + SetLinkTradeCallbacks(); + break; + case TRADEMENUFUNC_DELAY_TRADE_CONFIRM: + DelayTradeConfirmation(); + break; + case TRADEMENUFUNC_UNUSED_15: + ChooseMonAfterButtonPress(); + break; + case TRADEMENUFUNC_LINK_TRADE_WAIT_QUEUE: + LinkTradeWaitForQueue(); + break; + case TRADEMENUFUNC_PARTNER_MON_INVALID: + PartnersMonWasInvalid(); + break; + //case TRADEMENUFUNC_STANDBY: is nop } } -static void sub_807967C(u8 a0) +static void SetSelectedMon(u8 cursorPosition) { - u8 whichParty = a0 / PARTY_SIZE; + //cursorPosition 0-5 are the player's mons, 6-11 are the partner's + u8 whichParty = cursorPosition / PARTY_SIZE; - if (gUnknown_0203229C->unk_74[whichParty] == 0) + if (sTradeMenuData->drawPartyState[whichParty] == 0) { - gUnknown_0203229C->unk_74[whichParty] = 1; - gUnknown_0203229C->unk_76[whichParty] = a0; + sTradeMenuData->drawPartyState[whichParty] = 1; + sTradeMenuData->selectedMonIdx[whichParty] = cursorPosition; } } -static void sub_80796B4(u8 a0) +static void DrawTradeMenuParty(u8 whichParty) { s8 nameStringWidth; u8 nickname[20]; u8 movesString[56]; u8 i; u8 partyIdx; - u8 whichParty; - u8 monIdx = gUnknown_0203229C->unk_76[a0]; + u8 selectedMonParty; + u8 selectedMonIdx = sTradeMenuData->selectedMonIdx[whichParty]; - whichParty = 1; - if (gUnknown_0203229C->unk_76[a0] < PARTY_SIZE) - whichParty = 0; - partyIdx = monIdx % PARTY_SIZE; + selectedMonParty = TRADE_PARTNER; + if (sTradeMenuData->selectedMonIdx[whichParty] < PARTY_SIZE) + selectedMonParty = TRADE_PLAYER; + partyIdx = selectedMonIdx % PARTY_SIZE; nameStringWidth = 0; - switch (gUnknown_0203229C->unk_74[a0]) + switch (sTradeMenuData->drawPartyState[whichParty]) { case 1: - for (i = 0; i < gUnknown_0203229C->partyCounts[a0]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { - gSprites[gUnknown_0203229C->partyIcons[0][i + (whichParty * PARTY_SIZE)]].invisible = TRUE; + gSprites[sTradeMenuData->partySpriteIds[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; } for (i = 0; i < 6; i++) { - ClearWindowTilemap(i + (a0 * 6 + 2)); + ClearWindowTilemap(i + (whichParty * PARTY_SIZE + 2)); } - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].invisible = FALSE; - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[0] = 20; - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12; - StoreSpriteCallbackInData6(&gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]], sub_80D3014); - gUnknown_0203229C->unk_74[a0]++; - sub_80A6DEC(&gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]]); - CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, a0 * 15, 0, 15, 17, 0); + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].invisible = FALSE; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], UpdateTradeMonIconFrame); + sTradeMenuData->drawPartyState[whichParty]++; + TradeMenuBouncePartySprites(&gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); + CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); - if (whichParty == 0) - sub_8079F74(); + if (selectedMonParty == TRADE_PLAYER) + PrintNicknamesForTradeMenu(); break; case 2: - if (gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].callback == sub_80D3014) - gUnknown_0203229C->unk_74[a0] = 3; + if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == UpdateTradeMonIconFrame) + sTradeMenuData->drawPartyState[whichParty] = 3; break; case 3: - CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, whichParty * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, sTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12; - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.x = 0; - gSprites[gUnknown_0203229C->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.y = 0; - nameStringWidth = sub_8079A3C(nickname, whichParty, partyIdx); - AddTextPrinterParameterized3((a0 * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, gUnknown_0832DEE0, 0, nickname); - sub_8079AA4(movesString, whichParty, partyIdx); - AddTextPrinterParameterized4((a0 * 2) + 15, 1, 0, 0, 0, 0, gUnknown_0832DEE0, 0, movesString); - PutWindowTilemap((a0 * 2) + 14); - CopyWindowToVram((a0 * 2) + 14, 3); - PutWindowTilemap((a0 * 2) + 15); - CopyWindowToVram((a0 * 2) + 15, 3); - gUnknown_0203229C->unk_74[a0]++; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (sTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.x = 0; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.y = 0; + nameStringWidth = GetMonNicknameWidth(nickname, selectedMonParty, partyIdx); + AddTextPrinterParameterized3((whichParty * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, sTradeTextColors, 0, nickname); + BufferTradeMonMoves(movesString, selectedMonParty, partyIdx); + AddTextPrinterParameterized4((whichParty * 2) + 15, 1, 0, 0, 0, 0, sTradeTextColors, 0, movesString); + PutWindowTilemap((whichParty * 2) + 14); + CopyWindowToVram((whichParty * 2) + 14, 3); + PutWindowTilemap((whichParty * 2) + 15); + CopyWindowToVram((whichParty * 2) + 15, 3); + sTradeMenuData->drawPartyState[whichParty]++; break; case 4: - sub_8079C4C(a0, partyIdx, gUnknown_0832DF99[a0][0] + 4, gUnknown_0832DF99[a0][1] + 1, gUnknown_0832DF99[a0][0], gUnknown_0832DF99[a0][1]); - gUnknown_0203229C->unk_74[a0]++; + DrawTradeMenuPartyMonInfo(whichParty, partyIdx, + sTradeMenuPartyMonBoxDimensions[whichParty][0] + 4, + sTradeMenuPartyMonBoxDimensions[whichParty][1] + 1, + sTradeMenuPartyMonBoxDimensions[whichParty][0], + sTradeMenuPartyMonBoxDimensions[whichParty][1]); + sTradeMenuData->drawPartyState[whichParty]++; break; } } -static u8 sub_8079A3C(u8 *str, u8 whichParty, u8 monIdx) +static u8 GetMonNicknameWidth(u8 *str, u8 whichParty, u8 monIdx) { u8 nickname[12]; - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) GetMonData(&gPlayerParty[monIdx], MON_DATA_NICKNAME, nickname); else GetMonData(&gEnemyParty[monIdx], MON_DATA_NICKNAME, nickname); @@ -3030,104 +1864,104 @@ static u8 sub_8079A3C(u8 *str, u8 whichParty, u8 monIdx) return GetStringWidth(0, str, GetFontAttribute(0, FONTATTR_LETTER_SPACING)); } -static void sub_8079AA4(u8 *a0, u8 a1, u8 a2) +static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) { u16 moves[MAX_MON_MOVES]; u16 i; - if (!gUnknown_0203229C->unk_51[a1][a2]) + if (!sTradeMenuData->isEgg[whichParty][partyIdx]) { for (i = 0; i < MAX_MON_MOVES; i++) { - if (!a1) + if (whichParty == TRADE_PLAYER) { - moves[i] = GetMonData(&gPlayerParty[a2], i + MON_DATA_MOVE1, NULL); + moves[i] = GetMonData(&gPlayerParty[partyIdx], i + MON_DATA_MOVE1, NULL); } else { - moves[i] = GetMonData(&gEnemyParty[a2], i + MON_DATA_MOVE1, NULL); + moves[i] = GetMonData(&gEnemyParty[partyIdx], i + MON_DATA_MOVE1, NULL); } } - StringCopy(a0, gText_EmptyString7); + StringCopy(str, sText_EmptyString); for (i = 0; i < MAX_MON_MOVES; i++) { if (moves[i] != MOVE_NONE) { - StringAppend(a0, gMoveNames[moves[i]]); + StringAppend(str, gMoveNames[moves[i]]); } - StringAppend(a0, gText_NewLine3); + StringAppend(str, sText_NewLine); } } else { - StringCopy(a0, gText_EmptyString7); - StringAppend(a0, gText_FourQuestionMarks); + StringCopy(str, sText_EmptyString); + StringAppend(str, sText_FourQuestionMarks); } } -static void sub_8079B84(u8 whichParty, u8 windowId, u8 *str) +static void PrintMonNicknameForTradeMenu(u8 whichParty, u8 windowId, u8 *nickname) { u8 xPos; windowId += (whichParty * PARTY_SIZE) + 2; - xPos = GetStringCenterAlignXOffset(0, str, 64); - AddTextPrinterParameterized3(windowId, 0, xPos, 4, gUnknown_0832DEE0, 0, str); + xPos = GetStringCenterAlignXOffset(0, nickname, 64); + AddTextPrinterParameterized3(windowId, 0, xPos, 4, sTradeTextColors, 0, nickname); PutWindowTilemap(windowId); CopyWindowToVram(windowId, 3); } -static void sub_8079BE0(u8 whichParty) +static void PrintPartyNicknamesForTradeMenu(u8 whichParty) { u8 i; - u8 sp[20]; - u8 sp14[32]; - struct Pokemon *mons = whichParty == 0 ? gPlayerParty : gEnemyParty; + u8 nickname[20]; + u8 str[32]; + struct Pokemon *party = (whichParty == TRADE_PLAYER) ? gPlayerParty : gEnemyParty; - for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { - GetMonData(&mons[i], MON_DATA_NICKNAME, sp); - StringCopy10(sp14, sp); - sub_8079B84(whichParty, i, sp14); + GetMonData(&party[i], MON_DATA_NICKNAME, nickname); + StringCopy10(str, nickname); + PrintMonNicknameForTradeMenu(whichParty, i, str); } } -static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5) +static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 width, u8 height) { u8 level; - u32 r2; + u32 symbolTile; u8 gender; u8 nickname[12]; - CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDD704, a4, a5, 6, 3, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMenuMonBox_Tilemap, width, height, 6, 3, 0); CopyBgTilemapBufferToVram(1); - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) level = GetMonData(&gPlayerParty[monIdx], MON_DATA_LEVEL, NULL); else level = GetMonData(&gEnemyParty[monIdx], MON_DATA_LEVEL, NULL); - if (gUnknown_0203229C->unk_51[whichParty][monIdx] == 0) + if (!sTradeMenuData->isEgg[whichParty][monIdx]) { if (level / 10 != 0) - gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32)] = (level / 10) + 0x60; + sTradeMenuData->tilemapBuffer[x + (y * 32)] = (level / 10) + 0x60; - gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) + 1] = (level % 10) + 0x70; + sTradeMenuData->tilemapBuffer[x + (y * 32) + 1] = (level % 10) + 0x70; } else { - gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) - 32] = gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) - 33]; - gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) - 31] = gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) - 36] | 0x400; + sTradeMenuData->tilemapBuffer[x + (y * 32) - 32] = sTradeMenuData->tilemapBuffer[x + (y * 32) - 33]; + sTradeMenuData->tilemapBuffer[x + (y * 32) - 31] = sTradeMenuData->tilemapBuffer[x + (y * 32) - 36] | 0x400; } - if (gUnknown_0203229C->unk_51[whichParty][monIdx] != 0) + if (sTradeMenuData->isEgg[whichParty][monIdx]) { - r2 = 0x480; + symbolTile = 0x480; } else { - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) { gender = GetMonGender(&gPlayerParty[monIdx]); GetMonData(&gPlayerParty[monIdx], MON_DATA_NICKNAME, nickname); @@ -3140,41 +1974,45 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5) switch (gender) { - case MON_MALE: - r2 = !NameHasGenderSymbol(nickname, MON_MALE) ? 0x84 : 0x83; - break; - case MON_FEMALE: - r2 = !NameHasGenderSymbol(nickname, MON_FEMALE) ? 0x85 : 0x83; - break; - default: - r2 = 0x83; - break; + case MON_MALE: + symbolTile = !NameHasGenderSymbol(nickname, MON_MALE) ? 0x84 : 0x83; + break; + case MON_FEMALE: + symbolTile = !NameHasGenderSymbol(nickname, MON_FEMALE) ? 0x85 : 0x83; + break; + default: + symbolTile = 0x83; + break; } } - gUnknown_0203229C->tilemapBuffer[(a3 - 1) * 32 + a2 + 1] = r2; + sTradeMenuData->tilemapBuffer[(y - 1) * 32 + x + 1] = symbolTile; } // Very close but loop preamble not working. #ifdef NONMATCHING -static void sub_8079E44(u8 whichParty) +static void DrawTradeMenuPartyInfo(u8 whichParty) { int i; - for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { - sub_8079C4C(whichParty, i, gTradeLevelDisplayCoords[whichParty][i][0], gTradeLevelDisplayCoords[whichParty][i][1], gTradeMonBoxCoords[whichParty][i][0], gTradeMonBoxCoords[whichParty][i][1]); + DrawTradeMenuPartyMonInfo(whichParty, i, + sTradeMonLevelCoords[whichParty][i][0], + sTradeMonLevelCoords[whichParty][i][1], + sTradeMonBoxCoords[whichParty][i][0], + sTradeMonBoxCoords[whichParty][i][1]); } } #else NAKED -static void sub_8079E44(u8 whichParty) +static void DrawTradeMenuPartyInfo(u8 whichParty) { asm_unified("push {r4-r7,lr}\n\ sub sp, 0x8\n\ lsls r0, 24\n\ lsrs r6, r0, 24\n\ movs r7, 0\n\ - ldr r0, =gUnknown_0203229C\n\ + ldr r0, =sTradeMenuData\n\ ldr r0, [r0]\n\ adds r0, 0x36\n\ adds r0, r6\n\ @@ -3183,10 +2021,10 @@ static void sub_8079E44(u8 whichParty) bge _08079E94\n\ lsls r0, r6, 1\n\ adds r0, r6\n\ - ldr r1, =gTradeLevelDisplayCoords\n\ + ldr r1, =sTradeMonLevelCoords\n\ lsls r0, 2\n\ adds r5, r0, r1\n\ - ldr r1, =gTradeMonBoxCoords\n\ + ldr r1, =sTradeMonBoxCoords\n\ adds r4, r0, r1\n\ _08079E6A:\n\ lsls r1, r7, 24\n\ @@ -3198,11 +2036,11 @@ _08079E6A:\n\ ldrb r0, [r4, 0x1]\n\ str r0, [sp, 0x4]\n\ adds r0, r6, 0\n\ - bl sub_8079C4C\n\ + bl DrawTradeMenuPartyMonInfo\n\ adds r5, 0x2\n\ adds r4, 0x2\n\ adds r7, 0x1\n\ - ldr r0, =gUnknown_0203229C\n\ + ldr r0, =sTradeMenuData\n\ ldr r0, [r0]\n\ adds r0, 0x36\n\ adds r0, r6\n\ @@ -3218,405 +2056,388 @@ _08079E94:\n\ } #endif // NONMATCHING -static void sub_8079EA8(u8 whichParty) +static void ResetTradeMenuPartyPositions(u8 whichParty) { int i; - for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { - gSprites[gUnknown_0203229C->partyIcons[whichParty][i]].invisible = FALSE; - gSprites[gUnknown_0203229C->partyIcons[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; - gSprites[gUnknown_0203229C->partyIcons[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; - gSprites[gUnknown_0203229C->partyIcons[whichParty][i]].pos2.x = 0; - gSprites[gUnknown_0203229C->partyIcons[whichParty][i]].pos2.y = 0; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].invisible = FALSE; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos1.x = sTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos1.y = sTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos2.x = 0; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos2.y = 0; } } -static void sub_8079F74(void) +static void PrintNicknamesForTradeMenu(void) { rbox_fill_rectangle(1); - sub_8079BE0(1); + //PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); ? + PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); } -static void sub_8079F88(u8 a0) +static void RedrawTradeMenuParty(u8 whichParty) { - CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, a0 * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - sub_8079E44(a0); - sub_8079BE0(a0); - sub_8079EA8(a0); - sub_807A308(gUnknown_0832DE94[1], (void *)(OBJ_VRAM0 + (gUnknown_0203229C->unk_72 * 32)), 24); - gUnknown_0203229C->unk_74[a0] = 0; + DrawTradeMenuPartyInfo(whichParty); + PrintPartyNicknamesForTradeMenu(whichParty); + ResetTradeMenuPartyPositions(whichParty); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeMenuData->bottomTextTileStart * 32)), 24); + sTradeMenuData->drawPartyState[whichParty] = 0; } -static void sub_807A000(u8 taskId) +static void Task_DrawSelectionSummary(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); CopyBgTilemapBufferToVram(0); } -static void sub_807A024(u8 taskId) +static void Task_DrawSelectionTrade(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); CopyBgTilemapBufferToVram(0); } -static void sub_807A048(u16 a0, u8 a1) +static void QueueAction(u16 delay, u8 actionId) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->queuedActions); i++) { - if (!gUnknown_0203229C->unk_8D0[i].unk_0) + if (!sTradeMenuData->queuedActions[i].queued) { - gUnknown_0203229C->unk_8D0[i].unk_2 = a0; - gUnknown_0203229C->unk_8D0[i].unk_4 = a1; - gUnknown_0203229C->unk_8D0[i].unk_0 = TRUE; + sTradeMenuData->queuedActions[i].queueDelay = delay; + sTradeMenuData->queuedActions[i].actionId = actionId; + sTradeMenuData->queuedActions[i].queued = TRUE; break; } } } -static u32 sub_807A09C(void) +static u32 GetNumQueuedActions(void) { - u32 acc = 0; + u32 numActions = 0; int i; - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->queuedActions); i++) { - acc += gUnknown_0203229C->unk_8D0[i].unk_0; + numActions += sTradeMenuData->queuedActions[i].queued; } - return acc; + return numActions; } -static void sub_807A0C4(void) +static void DoQueuedActions(void) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->queuedActions); i++) { - if (gUnknown_0203229C->unk_8D0[i].unk_0) + if (sTradeMenuData->queuedActions[i].queued) { - if (gUnknown_0203229C->unk_8D0[i].unk_2) + if (sTradeMenuData->queuedActions[i].queueDelay) { - gUnknown_0203229C->unk_8D0[i].unk_2--; + sTradeMenuData->queuedActions[i].queueDelay--; } else { - switch (gUnknown_0203229C->unk_8D0[i].unk_4) + switch (sTradeMenuData->queuedActions[i].actionId) { - case 0: - sub_8077170(gUnknown_0203229C->linkData, 20); - break; - case 1: - sub_807A19C(0); - break; - case 2: - sub_807A19C(2); - break; - case 3: - case 4: - case 5: - sub_807A19C(3); - break; - case 6: - sub_807A19C(6); - break; - case 7: - sub_807A19C(7); - break; - case 8: - sub_807A19C(8); - break; + case QUEUE_SEND_DATA: + SendLinkData(sTradeMenuData->linkData, 20); + break; + case QUEUE_STANDBY: + PrintTradeMessage(TRADE_MSG_STANDBY); + break; + case QUEUE_ONLY_MON1: + PrintTradeMessage(TRADE_MSG_ONLY_MON1); + break; + case QUEUE_ONLY_MON2: + case QUEUE_UNUSED1: + case QUEUE_UNUSED2: + PrintTradeMessage(TRADE_MSG_ONLY_MON2); + break; + case QUEUE_MON_CANT_BE_TRADED: + PrintTradeMessage(TRADE_MSG_MON_CANT_BE_TRADED); + break; + case QUEUE_EGG_CANT_BE_TRADED: + PrintTradeMessage(TRADE_MSG_EGG_CANT_BE_TRADED); + break; + case QUEUE_FRIENDS_MON_CANT_BE_TRADED: + PrintTradeMessage(TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED); + break; } - gUnknown_0203229C->unk_8D0[i].unk_0 = 0; + sTradeMenuData->queuedActions[i].queued = FALSE; } } } } -static void sub_807A19C(u8 a0) +static void PrintTradeMessage(u8 messageId) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, gUnknown_0832DEBC[a0], 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, 1, sTradeMessages[messageId], 0, 1, TEXT_SPEED_FF, NULL); DrawTextBorderOuter(0, 20, 12); PutWindowTilemap(0); CopyWindowToVram(0, 3); } -static bool8 sub_807A1F0(void) +static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) { struct SpriteSheet sheet; - if (gUnknown_0203229C->unk_A8 < 14) + if (sTradeMenuData->timer < (int)ARRAY_COUNT(sMessageBoxTileBuffers)) { - sheet.data = gUnknown_02032188[gUnknown_0203229C->unk_A8]; + sheet.data = sMessageBoxTileBuffers[sTradeMenuData->timer]; sheet.size = 0x100; - sheet.tag = 200 + gUnknown_0203229C->unk_A8; + sheet.tag = 200 + sTradeMenuData->timer; } - switch (gUnknown_0203229C->unk_A8) + switch (sTradeMenuData->timer) { - case 0 ... 7: - LoadSpriteSheet(&sheet); - gUnknown_0203229C->unk_A8++; - break; - case 8: - gUnknown_0203229C->unk_72 = LoadSpriteSheet(&sheet); - gUnknown_0203229C->unk_A8++; - break; - case 9 ... 13: - LoadSpriteSheet(&sheet); - gUnknown_0203229C->unk_A8++; - break; - case 14: - LoadSpritePalette(&gSpritePalette_TradeScreenText); - gUnknown_0203229C->unk_A8++; - break; - case 15: - LoadSpritePalette(&gUnknown_0832DC44); - gUnknown_0203229C->unk_A8++; - break; - case 16: - LoadSpriteSheet(&gUnknown_0832DC3C); - gUnknown_0203229C->unk_A8++; - break; - case 17: - gUnknown_0203229C->unk_A8 = 0; - return TRUE; + case 0 ... 7: + LoadSpriteSheet(&sheet); + sTradeMenuData->timer++; + break; + case 8: + sTradeMenuData->bottomTextTileStart = LoadSpriteSheet(&sheet); + sTradeMenuData->timer++; + break; + case 9 ... 13: + LoadSpriteSheet(&sheet); + sTradeMenuData->timer++; + break; + case 14: + LoadSpritePalette(&gSpritePalette_TradeScreenText); + sTradeMenuData->timer++; + break; + case 15: + LoadSpritePalette(&gUnknown_0832DC44); + sTradeMenuData->timer++; + break; + case 16: + LoadSpriteSheet(&sTradeButtonsSpriteSheet); + sTradeMenuData->timer++; + break; + case 17: + sTradeMenuData->timer = 0; + return TRUE; } return FALSE; } -static void sub_807A308(const u8 *a0, u8 *a1, u8 unused) +static void DrawTextWindowAndBuffer6Bytes(const u8 *str, u8 *dest, u8 unused) { - sub_80C6D80(a0, a1, 0, 0, 6); + DrawTextWindowAndBufferTiles(str, dest, 0, 0, 6); } -static void sub_807A320(u8 who) +static void SetTradePartyLiveStatuses(u8 whichParty) { int i; - switch (who) + switch (whichParty) { - case 0: - for (i = 0; i < gUnknown_0203229C->partyCounts[who]; i++) + case TRADE_PLAYER: + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE) { - if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE) - { - gUnknown_0203229C->unk_45[who][i] = 0; - gUnknown_0203229C->unk_51[who][i] = 1; - } - else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) - { - gUnknown_0203229C->unk_45[who][i] = 0; - gUnknown_0203229C->unk_51[who][i] = 0; - } - else - { - gUnknown_0203229C->unk_45[who][i] = 1; - gUnknown_0203229C->unk_51[who][i] = 0; - } + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = TRUE; } - break; - case 1: - for (i = 0; i < gUnknown_0203229C->partyCounts[who]; i++) + else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) { - if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) - { - gUnknown_0203229C->unk_45[who][i] = 0; - gUnknown_0203229C->unk_51[who][i] = 1; - } - else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) - { - gUnknown_0203229C->unk_45[who][i] = 0; - gUnknown_0203229C->unk_51[who][i] = 0; - } - else - { - gUnknown_0203229C->unk_45[who][i] = 1; - gUnknown_0203229C->unk_51[who][i] = 0; - } + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } - break; + else + { + sTradeMenuData->isLiveMon[whichParty][i] = TRUE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; + } + } + break; + case TRADE_PARTNER: + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + { + if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) + { + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = TRUE; + } + else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) + { + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; + } + else + { + sTradeMenuData->isLiveMon[whichParty][i] = TRUE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; + } + } + break; } } -static void sub_807A468(u8 who) +static void GetTradePartyHPBarLevels(u8 who) { u16 i, curHp, maxHp; switch (who) { - case 0: - for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) - { - curHp = GetMonData(&gPlayerParty[i], MON_DATA_HP); - maxHp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); - gUnknown_0203229C->unk_5D[0][i] = GetHPBarLevel(curHp, maxHp); - } - break; - case 1: - for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) - { - curHp = GetMonData(&gEnemyParty[i], MON_DATA_HP); - maxHp = GetMonData(&gEnemyParty[i], MON_DATA_MAX_HP); - gUnknown_0203229C->unk_5D[1][i] = GetHPBarLevel(curHp, maxHp); - } - break; + case TRADE_PLAYER: + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) + { + curHp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + maxHp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); + sTradeMenuData->hpBarLevels[TRADE_PLAYER][i] = GetHPBarLevel(curHp, maxHp); + } + break; + case TRADE_PARTNER: + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) + { + curHp = GetMonData(&gEnemyParty[i], MON_DATA_HP); + maxHp = GetMonData(&gEnemyParty[i], MON_DATA_MAX_HP); + sTradeMenuData->hpBarLevels[TRADE_PARTNER][i] = GetHPBarLevel(curHp, maxHp); + } + break; } } -static void sub_807A53C(void) +static void SetTradePartyHPBarSprites(void) { int i, j; for (i = 0; i < 2; i++) { - for (j = 0; j < gUnknown_0203229C->partyCounts[i]; j++) + for (j = 0; j < sTradeMenuData->partyCounts[i]; j++) { - sub_80D32C8(&gSprites[gUnknown_0203229C->partyIcons[i][j]], 4 - gUnknown_0203229C->unk_5D[i][j]); + SetPartyHPBarSprite(&gSprites[sTradeMenuData->partySpriteIds[i][j]], 4 - sTradeMenuData->hpBarLevels[i][j]); } } } -static void sub_807A5B0(void) +static void SaveTradeGiftRibbons(void) { int i; - for (i = 0; i < 11; i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->giftRibbons); i++) { - if (gSaveBlock1Ptr->giftRibbons[i] == 0 && gUnknown_0203229C->unk_A9[i] != 0) + if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenuData->giftRibbons[i] != 0) { - if (gUnknown_0203229C->unk_A9[i] < 64) - gSaveBlock1Ptr->giftRibbons[i] = gUnknown_0203229C->unk_A9[i]; + if (sTradeMenuData->giftRibbons[i] < 64) + gSaveBlock1Ptr->giftRibbons[i] = sTradeMenuData->giftRibbons[i]; } } } -static u32 sub_807A5F4(struct Pokemon *monList, int a1, int monIdx) +static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int monIdx) { - int i, sum; + int i, numMonsLeft; struct LinkPlayer *player; - u32 species[6]; - u32 species2[6]; + u32 species[PARTY_SIZE]; + u32 species2[PARTY_SIZE]; - for (i = 0; i < a1; i++) + for (i = 0; i < partyCount; i++) { - species2[i] = GetMonData(&monList[i], MON_DATA_SPECIES2); - species[i] = GetMonData(&monList[i], MON_DATA_SPECIES); + species2[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES2); + species[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES); } + // Cant trade Eggs or non-Hoenn mons if player doesn't have National Dex if (!IsNationalPokedexEnabled()) { if (species2[monIdx] == SPECIES_EGG) - { - return 3; - } + return CANT_TRADE_EGG; if (!IsSpeciesInHoennDex(species2[monIdx])) - { - return 2; - } + return CANT_TRADE_NATIONAL; } player = &gLinkPlayers[GetMultiplayerId() ^ 1]; if ((player->version & 0xFF) != VERSION_RUBY && (player->version & 0xFF) != VERSION_SAPPHIRE) { - if ((player->name[10] & 0xF) == 0) + // Does partner not have National Dex + if (!(player->progressFlagsCopy & 0xF)) { if (species2[monIdx] == SPECIES_EGG) - { - return 5; - } + return CANT_TRADE_EGG2; if (!IsSpeciesInHoennDex(species2[monIdx])) - { - return 4; - } + return CANT_TRADE_INVALID_MON; } } if (species[monIdx] == SPECIES_DEOXYS || species[monIdx] == SPECIES_MEW) { - if (!GetMonData(&monList[monIdx], MON_DATA_OBEDIENCE)) - { - return 4; - } + if (!GetMonData(&playerParty[monIdx], MON_DATA_OBEDIENCE)) + return CANT_TRADE_INVALID_MON; } - for (i = 0; i < a1; i++) + // Make Eggs not count for numMonsLeft + for (i = 0; i < partyCount; i++) { if (species2[i] == SPECIES_EGG) - { species2[i] = SPECIES_NONE; - } } - for (sum = 0, i = 0; i < a1; i++) + // Count alive mons in party, excluding selected trade mon + for (numMonsLeft = 0, i = 0; i < partyCount; i++) { if (i != monIdx) - { - sum += species2[i]; - } + numMonsLeft += species2[i]; } - if (sum != 0) - { - return 0; - } + if (numMonsLeft != 0) + return CAN_TRADE_MON; else - { - return 1; - } + return CANT_TRADE_LAST_MON; } -s32 sub_807A728(void) +s32 GetGameProgressForLinkTrade(void) { - s32 val; + // isGameFrLg could have been a bool but they use 2 and > 0 instead + // possible other checks (for other game versions?) were planned/removed + s32 isGameFrLg; u16 version; if (gReceivedRemoteLinkPlayers != 0) { - val = 0; + isGameFrLg = 0; version = (gLinkPlayers[GetMultiplayerId() ^ 1].version & 0xFF); if (version == VERSION_RUBY || version == VERSION_SAPPHIRE || version == VERSION_EMERALD) - { - // this value could actually be anything 0 or less - val = 0; - } + isGameFrLg = 0; else if (version == VERSION_FIRE_RED || version == VERSION_LEAF_GREEN) - { - val = 2; - } + isGameFrLg = 2; - if (val > 0) + // If trading with FRLG, both players must be champion + if (isGameFrLg > 0) { - if (gLinkPlayers[GetMultiplayerId()].name[10] & 0xF0) + // Is player champion + if (gLinkPlayers[GetMultiplayerId()].progressFlagsCopy & 0xF0) { - if (val == 2) + if (isGameFrLg == 2) //unnecessary check, isGameFrLg always 2 here { - if (gLinkPlayers[GetMultiplayerId() ^ 1].name[10] & 0xF0) - { - return 0; - } + // Is partner champion + if (gLinkPlayers[GetMultiplayerId() ^ 1].progressFlagsCopy & 0xF0) + return TRADE_BOTH_PLAYERS_READY; else - { - return 2; - } + return TRADE_PARTNER_NOT_READY; } } else { - return 1; + return TRADE_PLAYER_NOT_READY; } } } - return 0; + return TRADE_BOTH_PLAYERS_READY; } static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isObedientBitSet) @@ -3629,122 +2450,116 @@ static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isObedientBitSet) return FALSE; } -int sub_807A7E0(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 species1, u16 species2, u8 type, u16 species3, u8 isObedientBitSet) +int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct rfuPlayer, struct UnkLinkRfuStruct_02022B14Substruct rfuPartner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, u8 isObedientBitSet) { - u8 r9 = a0.unk_01_0; - u8 r2 = a0.unk_00_7; - u8 r10 = a1.unk_01_0; - u8 r0 = a1.unk_00_7; - u8 r1 = a1.unk_01_2; + bool8 playerHasNationalDex = rfuPlayer.hasNationalDex; + bool8 playerIsChampion = rfuPlayer.isChampion; + bool8 partnerHasNationalDex = rfuPartner.hasNationalDex; + bool8 partnerIsChampion = rfuPartner.isChampion; + u8 r1 = rfuPartner.unk_01_2; if (r1 != 3) { - if (!r2) + if (!playerIsChampion) { - return 8; + return UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_1; } - else if (!r0) + else if (!partnerIsChampion) { - return 9; + return UR_TRADE_MSG_CANT_TRADE_WITH_PARTNER_2; } } - if (IsDeoxysOrMewUntradable(species3, isObedientBitSet)) + if (IsDeoxysOrMewUntradable(playerSpecies, isObedientBitSet)) { - return 4; + return UR_TRADE_MSG_MON_CANT_BE_TRADED_2; } - if (species2 == SPECIES_EGG) + if (partnerSpecies == SPECIES_EGG) { - if (species1 != species2) + if (playerSpecies2 != partnerSpecies) { - return 2; + return UR_TRADE_MSG_NOT_EGG; } } else { - if (gBaseStats[species1].type1 != type && gBaseStats[species1].type2 != type) + if (gBaseStats[playerSpecies2].type1 != requestedType && gBaseStats[playerSpecies2].type2 != requestedType) { - return 1; + return UR_TRADE_MSG_NOT_MON_PARTNER_WANTS; } } - if (species1 == SPECIES_EGG && species1 != species2) + if (playerSpecies2 == SPECIES_EGG && playerSpecies2 != partnerSpecies) { - return 3; + return UR_TRADE_MSG_MON_CANT_BE_TRADED_1; } - if (!r9) + if (!playerHasNationalDex) { - if (species1 == SPECIES_EGG) + if (playerSpecies2 == SPECIES_EGG) { - return 6; + return UR_TRADE_MSG_EGG_CANT_BE_TRADED; } - if (!IsSpeciesInHoennDex(species1)) + if (!IsSpeciesInHoennDex(playerSpecies2)) { - return 4; + return UR_TRADE_MSG_MON_CANT_BE_TRADED_2; } - if (!IsSpeciesInHoennDex(species2)) + if (!IsSpeciesInHoennDex(partnerSpecies)) { - return 5; + return UR_TRADE_MSG_PARTNERS_MON_CANT_BE_TRADED; } } - if (!r10 && !IsSpeciesInHoennDex(species1)) + if (!partnerHasNationalDex && !IsSpeciesInHoennDex(playerSpecies2)) { - return 7; + return UR_TRADE_MSG_PARTNER_CANT_ACCEPT_MON; } - return 0; + return UR_TRADE_MSG_NONE; } -int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species, u16 a2, u8 a3) +int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct rfuPlayer, u16 species2, u16 species, u8 isObedientBitSet) { - u8 unk = a0.unk_01_0; + bool8 hasNationalDex = rfuPlayer.hasNationalDex; - if (IsDeoxysOrMewUntradable(a2, a3)) - { - return 1; - } + if (IsDeoxysOrMewUntradable(species, isObedientBitSet)) + return CANT_REGISTER_MON; - if (unk) - { - return 0; - } + if (hasNationalDex) + return CAN_REGISTER_MON; - if (species == SPECIES_EGG) - { - return 2; - } + // Eggs can only be traded if the player has the National Dex + if (species2 == SPECIES_EGG) + return CANT_REGISTER_EGG; - if (IsSpeciesInHoennDex(species)) - { - return 0; - } + if (IsSpeciesInHoennDex(species2)) + return CAN_REGISTER_MON; - return 1; + return CANT_REGISTER_MON; } // r6/r7 flip. Ugh. #ifdef NONMATCHING -int sub_807A918(struct Pokemon *mon, u16 monIdx) +int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) { - int i, version, versions, unk, unk2; + int i, version, versions, canTradeAnyMon, numMonsLeft; int speciesArray[PARTY_SIZE]; + // Make Eggs not count for numMonsLeft for (i = 0; i < gPlayerPartyCount; i++) { speciesArray[i] = GetMonData(&mon[i], MON_DATA_SPECIES2); if (speciesArray[i] == SPECIES_EGG) { - speciesArray[i] = 0; + speciesArray[i] = SPECIES_NONE; } } + canTradeAnyMon = TRUE; versions = 0; - unk = 1; for (i = 0; i < GetLinkPlayerCount(); i++) { version = gLinkPlayers[i].version & 0xFF; @@ -3762,51 +2577,41 @@ int sub_807A918(struct Pokemon *mon, u16 monIdx) for (i = 0; i < GetLinkPlayerCount(); i++) { struct LinkPlayer *player = &gLinkPlayers[i]; - if ((player->name[8] & 0xF) == 0) - { - unk = 0; - } - if (versions && (player->name[8] / 16)) - { - unk = 0; - } + // Does player not have National Dex + if (!(player->progressFlags & 0xF)) + canTradeAnyMon = FALSE; + + if (versions && (player->progressFlags / 16)) + canTradeAnyMon = FALSE; } - if (unk == 0) + if (canTradeAnyMon == FALSE) { if (!IsSpeciesInHoennDex(speciesArray[monIdx])) - { - return 2; - } + return CANT_TRADE_NATIONAL; if (speciesArray[monIdx] == SPECIES_NONE) - { - return 3; - } + return CANT_TRADE_EGG; } - unk2 = 0; + numMonsLeft = 0; for (i = 0; i < gPlayerPartyCount; i++) { if (monIdx != i) { - unk2 += speciesArray[i]; + numMonsLeft += speciesArray[i]; } } - if (!unk2) - { - return 1; - } + if (!numMonsLeft) + return CANT_TRADE_LAST_MON; else - { - return 0; - } + return CAN_TRADE_MON; } #else NAKED -int sub_807A918(struct Pokemon *mon, u16 a1) +int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 a1) { asm_unified("push {r4-r7,lr}\n\ mov r7, r8\n\ @@ -4009,11 +2814,11 @@ static void sub_807AB04(struct Sprite *sprite) } } -static void sub_807AB28(void) +static void SetTradeBGAffine(void) { struct BgAffineDstData affine; - DoBgAffineSet(&affine, gUnknown_020322A0->unk_D4 * 0x100, gUnknown_020322A0->unk_D6 * 0x100, gUnknown_020322A0->unk_DC, gUnknown_020322A0->unk_DE, gUnknown_020322A0->unk_E8, gUnknown_020322A0->unk_E8, gUnknown_020322A0->unk_EC); + DoBgAffineSet(&affine, sTradeData->texX * 0x100, sTradeData->texY * 0x100, sTradeData->scrX, sTradeData->scrY, sTradeData->sXY, sTradeData->sXY, sTradeData->alpha); SetGpuReg(REG_OFFSET_BG2PA, affine.pa); SetGpuReg(REG_OFFSET_BG2PB, affine.pb); SetGpuReg(REG_OFFSET_BG2PC, affine.pc); @@ -4024,233 +2829,233 @@ static void sub_807AB28(void) SetGpuReg(REG_OFFSET_BG2Y_H, affine.dy >> 16); } -static void sub_807ABCC(void) +static void SetTradeGpuRegs(void) { u16 dispcnt; - SetGpuReg(REG_OFFSET_BG1VOFS, gUnknown_020322A0->bg1vofs); - SetGpuReg(REG_OFFSET_BG1HOFS, gUnknown_020322A0->bg1hofs); + SetGpuReg(REG_OFFSET_BG1VOFS, sTradeData->bg1vofs); + SetGpuReg(REG_OFFSET_BG1HOFS, sTradeData->bg1hofs); dispcnt = GetGpuReg(REG_OFFSET_DISPCNT); if ((dispcnt & 7) == DISPCNT_MODE_0) { - SetGpuReg(REG_OFFSET_BG2VOFS, gUnknown_020322A0->bg2vofs); - SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_020322A0->bg2hofs); + SetGpuReg(REG_OFFSET_BG2VOFS, sTradeData->bg2vofs); + SetGpuReg(REG_OFFSET_BG2HOFS, sTradeData->bg2hofs); } else { - sub_807AB28(); + SetTradeBGAffine(); } } -static void sub_807AC24(void) +static void VBlankCB_Trade(void) { - sub_807ABCC(); + SetTradeGpuRegs(); LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -static void sub_807AC3C(void) +static void ClearLinkTimeoutCounter(void) { - gUnknown_020322A0->unk_8A = 0; - gUnknown_020322A0->unk_88 = 0; - gUnknown_020322A0->unk_89 = 0; + sTradeData->linkTimeoutCounter = 0; + sTradeData->alwaysZero_88 = 0; + sTradeData->alwaysZero_89 = 0; } -static void sub_807AC64(void) +static void CheckForLinkTimeout(void) { - if (gUnknown_020322A0->unk_88 == gUnknown_020322A0->unk_89) - gUnknown_020322A0->unk_8A++; + if (sTradeData->alwaysZero_88 == sTradeData->alwaysZero_89) + sTradeData->linkTimeoutCounter++; else - gUnknown_020322A0->unk_8A = 0; + sTradeData->linkTimeoutCounter = 0; - if (gUnknown_020322A0->unk_8A > 300) + if (sTradeData->linkTimeoutCounter > LINK_TRADE_TIMEOUT) { CloseLink(); SetMainCallback2(CB2_LinkError); - gUnknown_020322A0->unk_8A = 0; - gUnknown_020322A0->unk_89 = 0; - gUnknown_020322A0->unk_88 = 0; + sTradeData->linkTimeoutCounter = 0; + sTradeData->alwaysZero_89 = 0; + sTradeData->alwaysZero_88 = 0; } - gUnknown_020322A0->unk_89 = gUnknown_020322A0->unk_88; + sTradeData->alwaysZero_89 = sTradeData->alwaysZero_88; } -static u32 sub_807ACDC(void) +static u32 TradeGetMultiplayerId(void) { if (gReceivedRemoteLinkPlayers) return GetMultiplayerId(); return 0; } -static void sub_807ACFC(u8 whichParty, u8 a1) +static void LoadTradeMonPic(u8 whichParty, u8 state) { int pos = 0; struct Pokemon *mon = NULL; u16 species; u32 personality; - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) { - mon = &gPlayerParty[gUnknown_02032298[0]]; - pos = 1; + mon = &gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]]; + pos = B_POSITION_OPPONENT_LEFT; } - if (whichParty == 1) + if (whichParty == TRADE_PARTNER) { - mon = &gEnemyParty[gUnknown_02032298[1] % PARTY_SIZE]; - pos = 3; + mon = &gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE]; + pos = B_POSITION_OPPONENT_RIGHT; } - switch (a1) + switch (state) { - case 0: - species = GetMonData(mon, MON_DATA_SPECIES2); - personality = GetMonData(mon, MON_DATA_PERSONALITY); + case 0: + species = GetMonData(mon, MON_DATA_SPECIES2); + personality = GetMonData(mon, MON_DATA_PERSONALITY); - if (whichParty == 0) - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality); - else - HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[whichParty * 2 + 1], species, personality); + if (whichParty == TRADE_PLAYER) + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality); + else + HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[whichParty * 2 + 1], species, personality); - LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); - gUnknown_020322A0->tradeSpecies[whichParty] = species; - gUnknown_020322A0->unk_68[whichParty] = personality; - break; - case 1: - SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, pos); - gUnknown_020322A0->pokePicSpriteIdxs[whichParty] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[whichParty]].invisible = TRUE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; - break; + LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); + sTradeData->monSpecies[whichParty] = species; + sTradeData->monPersonalities[whichParty] = personality; + break; + case 1: + SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, pos); + sTradeData->pokePicSpriteIdxs[whichParty] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); + gSprites[sTradeData->pokePicSpriteIdxs[whichParty]].invisible = TRUE; + gSprites[sTradeData->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; + break; } } -void sub_807AE50(void) +void CB2_LinkTrade(void) { switch (gMain.state) { - case 0: - if (!gReceivedRemoteLinkPlayers) - { - gLinkType = LINKTYPE_0x1144; - CloseLink(); - } - gUnknown_020322A0 = AllocZeroed(sizeof(*gUnknown_020322A0)); - AllocateMonSpritesGfx(); - ResetTasks(); - ResetSpriteData(); - FreeAllSpritePalettes(); - SetVBlankCallback(sub_807AC24); - sub_807B170(); - sub_807AC3C(); + case 0: + if (!gReceivedRemoteLinkPlayers) + { + gLinkType = LINKTYPE_0x1144; + CloseLink(); + } + sTradeData = AllocZeroed(sizeof(*sTradeData)); + AllocateMonSpritesGfx(); + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + SetVBlankCallback(VBlankCB_Trade); + InitTradeBgInternal(); + ClearLinkTimeoutCounter(); + gMain.state++; + sTradeData->neverRead_8C = 0; + sTradeData->state = 0; + sTradeData->isLinkTrade = TRUE; + sTradeData->texX = 64; + sTradeData->texY = 64; + sTradeData->neverRead_D8 = 0; + sTradeData->neverRead_DA = 0; + sTradeData->scrX = 120; + sTradeData->scrY = 80; + sTradeData->sXY = 256; + sTradeData->alpha = 0; + break; + case 1: + if (!gReceivedRemoteLinkPlayers) + { + sTradeData->isCableTrade = TRUE; + OpenLink(); gMain.state++; - gUnknown_020322A0->unk_8C = 0; - gUnknown_020322A0->state = 0; - gUnknown_020322A0->isLinkTrade = TRUE; - gUnknown_020322A0->unk_D4 = 64; - gUnknown_020322A0->unk_D6 = 64; - gUnknown_020322A0->unk_D8 = 0; - gUnknown_020322A0->unk_DA = 0; - gUnknown_020322A0->unk_DC = 120; - gUnknown_020322A0->unk_DE = 80; - gUnknown_020322A0->unk_E8 = 256; - gUnknown_020322A0->unk_EC = 0; - break; - case 1: - if (!gReceivedRemoteLinkPlayers) + sTradeData->timer = 0; + } + else + { + gMain.state = 4; + } + break; + case 2: + if (++sTradeData->timer > 60) + { + sTradeData->timer = 0; + gMain.state++; + } + break; + case 3: + if (IsLinkMaster()) + { + if (GetLinkPlayerCount_2() >= GetSavedPlayerCount()) { - gUnknown_020322A0->unk_FA = 1; - OpenLink(); - gMain.state++; - gUnknown_020322A0->timer = 0; - } - else - { - gMain.state = 4; - } - break; - case 2: - if (++gUnknown_020322A0->timer > 60) - { - gUnknown_020322A0->timer = 0; - gMain.state++; - } - break; - case 3: - if (IsLinkMaster()) - { - if (GetLinkPlayerCount_2() >= GetSavedPlayerCount()) + if (++sTradeData->timer > 30) { - if (++gUnknown_020322A0->timer > 30) - { - CheckShouldAdvanceLinkState(); - gMain.state++; - } - } - else - { - sub_807AC64(); + CheckShouldAdvanceLinkState(); + gMain.state++; } } else { - gMain.state++; + CheckForLinkTimeout(); } - break; - case 4: - sub_807AC64(); - if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) - gMain.state++; - break; - case 5: - gUnknown_020322A0->unk_72 = 0; - gUnknown_020322A0->unk_73 = 0; - gUnknown_020322A0->unk_93 = 0; - sub_807ACFC(0, 0); + } + else + { gMain.state++; - break; - case 6: - sub_807ACFC(0, 1); + } + break; + case 4: + CheckForLinkTimeout(); + if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) gMain.state++; - break; - case 7: - sub_807ACFC(1, 0); - gMain.state++; - break; - case 8: - sub_807ACFC(1, 1); - sub_807B154(); - gMain.state++; - break; - case 9: - sub_807BA94(); - LoadSpriteSheet(&gUnknown_08338D18); - LoadSpritePalette(&gUnknown_08338D20); - gMain.state++; - break; - case 10: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - ShowBg(0); - gMain.state++; - break; - case 11: - sub_807B140(); - SetTradeSceneStrings(); - gMain.state++; - break; - case 12: - if (!gPaletteFade.active) + break; + case 5: + sTradeData->playerLinkFlagFinishTrade = 0; + sTradeData->partnerLinkFlagFinishTrade = 0; + sTradeData->sendTradeFinishState = 0; + LoadTradeMonPic(TRADE_PLAYER, 0); + gMain.state++; + break; + case 6: + LoadTradeMonPic(TRADE_PLAYER, 1); + gMain.state++; + break; + case 7: + LoadTradeMonPic(TRADE_PARTNER, 0); + gMain.state++; + break; + case 8: + LoadTradeMonPic(TRADE_PARTNER, 1); + LinkTradeDrawWindow(); + gMain.state++; + break; + case 9: + LoadTradeSequenceSpriteSheetsAndPalettes(); + LoadSpriteSheet(&sPokeBallSpriteSheet); + LoadSpritePalette(&sPokeBallSpritePalette); + gMain.state++; + break; + case 10: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + ShowBg(0); + gMain.state++; + break; + case 11: + InitTradeSequenceBgGpuRegs(); + BufferTradeSceneStrings(); + gMain.state++; + break; + case 12: + if (!gPaletteFade.active) + { + if (gWirelessCommType) { - if (gWirelessCommType) - { - LoadWirelessStatusIndicatorSpriteGfx(); - CreateWirelessStatusIndicatorSprite(0, 0); - } - SetMainCallback2(sub_807EA2C); + LoadWirelessStatusIndicatorSpriteGfx(); + CreateWirelessStatusIndicatorSprite(0, 0); } - break; + SetMainCallback2(CB2_UpdateLinkTrade); + } + break; } RunTasks(); RunTextPrinters(); @@ -4259,24 +3064,24 @@ void sub_807AE50(void) UpdatePaletteFade(); } -void sub_807B140(void) +void InitTradeSequenceBgGpuRegs(void) { - sub_807B62C(5); - sub_807B62C(0); + SetTradeSequenceBgGpuRegs(5); + SetTradeSequenceBgGpuRegs(0); } -void sub_807B154(void) +void LinkTradeDrawWindow(void) { FillWindowPixelBuffer(0, PIXEL_FILL(15)); PutWindowTilemap(0); CopyWindowToVram(0, 3); } -static void sub_807B170(void) +static void InitTradeBgInternal(void) { SetGpuReg(REG_OFFSET_DISPCNT, 0); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_08339014, ARRAY_COUNT(gUnknown_08339014)); + InitBgsFromTemplates(0, sTradeSequenceBgTemplates, ARRAY_COUNT(sTradeSequenceBgTemplates)); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); SetBgTilemapBuffer(0, Alloc(0x800)); @@ -4287,88 +3092,87 @@ static void sub_807B170(void) LZDecompressWram(gBattleTextboxTilemap, gDecompressionBuffer); CopyToBgTilemapBuffer(0, gDecompressionBuffer, 0x800, 0); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); - InitWindows(gUnknown_08338FFC); + InitWindows(sTradeSequenceWindowTemplates); DecompressAndLoadBgGfxUsingHeap(0, gBattleTextboxTiles, 0, 0, 0); LZDecompressWram(gBattleTextboxTilemap, gDecompressionBuffer); CopyToBgTilemapBuffer(0, gDecompressionBuffer, 0x800, 0); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); } -// In-game trade init -static void sub_807B270(void) +static void CB2_InGameTrade(void) { u8 otName[11]; switch (gMain.state) { - case 0: - gUnknown_02032298[0] = gSpecialVar_0x8005; - gUnknown_02032298[1] = 6; - StringCopy(gLinkPlayers[0].name, gSaveBlock2Ptr->playerName); - GetMonData(&gEnemyParty[0], MON_DATA_OT_NAME, otName); - StringCopy(gLinkPlayers[1].name, otName); - gLinkPlayers[0].language = LANGUAGE_ENGLISH; - gLinkPlayers[1].language = GetMonData(&gEnemyParty[0], MON_DATA_LANGUAGE); - gUnknown_020322A0 = AllocZeroed(sizeof(*gUnknown_020322A0)); - AllocateMonSpritesGfx(); - ResetTasks(); - ResetSpriteData(); - FreeAllSpritePalettes(); - SetVBlankCallback(sub_807AC24); - sub_807B170(); - gUnknown_020322A0->isLinkTrade = FALSE; - gUnknown_020322A0->unk_8C = 0; - gUnknown_020322A0->state = 0; - gUnknown_020322A0->unk_D4 = 64; - gUnknown_020322A0->unk_D6 = 64; - gUnknown_020322A0->unk_D8 = 0; - gUnknown_020322A0->unk_DA = 0; - gUnknown_020322A0->unk_DC = 120; - gUnknown_020322A0->unk_DE = 80; - gUnknown_020322A0->unk_E8 = 256; - gUnknown_020322A0->unk_EC = 0; - gUnknown_020322A0->timer = 0; - gMain.state = 5; - break; - case 5: - sub_807ACFC(0, 0); - gMain.state++; - break; - case 6: - sub_807ACFC(0, 1); - gMain.state++; - break; - case 7: - sub_807ACFC(1, 0); - ShowBg(0); - gMain.state++; - break; - case 8: - sub_807ACFC(1, 1); - FillWindowPixelBuffer(0, PIXEL_FILL(15)); - PutWindowTilemap(0); - CopyWindowToVram(0, 3); - gMain.state++; - break; - case 9: - sub_807BA94(); - LoadSpriteSheet(&gUnknown_08338D18); - LoadSpritePalette(&gUnknown_08338D20); - gMain.state++; - break; - case 10: - ShowBg(0); - gMain.state++; - break; - case 11: - sub_807B62C(5); - sub_807B62C(0); - SetTradeSceneStrings(); - gMain.state++; - break; - case 12: - SetMainCallback2(sub_807B60C); - break; + case 0: + gSelectedTradeMonPositions[TRADE_PLAYER] = gSpecialVar_0x8005; + gSelectedTradeMonPositions[TRADE_PARTNER] = PARTY_SIZE; + StringCopy(gLinkPlayers[0].name, gSaveBlock2Ptr->playerName); + GetMonData(&gEnemyParty[0], MON_DATA_OT_NAME, otName); + StringCopy(gLinkPlayers[1].name, otName); + gLinkPlayers[0].language = LANGUAGE_ENGLISH; + gLinkPlayers[1].language = GetMonData(&gEnemyParty[0], MON_DATA_LANGUAGE); + sTradeData = AllocZeroed(sizeof(*sTradeData)); + AllocateMonSpritesGfx(); + ResetTasks(); + ResetSpriteData(); + FreeAllSpritePalettes(); + SetVBlankCallback(VBlankCB_Trade); + InitTradeBgInternal(); + sTradeData->isLinkTrade = FALSE; + sTradeData->neverRead_8C = 0; + sTradeData->state = 0; + sTradeData->texX = 64; + sTradeData->texY = 64; + sTradeData->neverRead_D8 = 0; + sTradeData->neverRead_DA = 0; + sTradeData->scrX = 120; + sTradeData->scrY = 80; + sTradeData->sXY = 256; + sTradeData->alpha = 0; + sTradeData->timer = 0; + gMain.state = 5; + break; + case 5: + LoadTradeMonPic(TRADE_PLAYER, 0); + gMain.state++; + break; + case 6: + LoadTradeMonPic(TRADE_PLAYER, 1); + gMain.state++; + break; + case 7: + LoadTradeMonPic(TRADE_PARTNER, 0); + ShowBg(0); + gMain.state++; + break; + case 8: + LoadTradeMonPic(TRADE_PARTNER, 1); + FillWindowPixelBuffer(0, PIXEL_FILL(15)); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); + gMain.state++; + break; + case 9: + LoadTradeSequenceSpriteSheetsAndPalettes(); + LoadSpriteSheet(&sPokeBallSpriteSheet); + LoadSpritePalette(&sPokeBallSpritePalette); + gMain.state++; + break; + case 10: + ShowBg(0); + gMain.state++; + break; + case 11: + SetTradeSequenceBgGpuRegs(5); + SetTradeSequenceBgGpuRegs(0); + BufferTradeSceneStrings(); + gMain.state++; + break; + case 12: + SetMainCallback2(CB2_UpdateInGameTrade); + break; } RunTasks(); @@ -4378,7 +3182,7 @@ static void sub_807B270(void) UpdatePaletteFade(); } -static void sub_807B464(u8 partyIdx) +static void UpdatePokedexForReceivedMon(u8 partyIdx) { struct Pokemon *mon = &gPlayerParty[partyIdx]; @@ -4392,7 +3196,8 @@ static void sub_807B464(u8 partyIdx) } } -static void sub_807B4C4(void) +// Functionally nop after commented code +static void TryEnableNationalDexFromLinkPartner(void) { u8 mpId = GetMultiplayerId(); // Originally in Ruby but commented out @@ -4400,56 +3205,55 @@ static void sub_807B4C4(void) EnableNationalPokedex();*/ } -static void sub_807B4D0(u8 a0, u8 a1) +static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx) { u8 friendship; - struct Pokemon *playerMon = &gPlayerParty[a0]; + struct Pokemon *playerMon = &gPlayerParty[playerPartyIdx]; u16 playerMail = GetMonData(playerMon, MON_DATA_MAIL); - struct Pokemon *partnerMon = &gEnemyParty[a1]; + struct Pokemon *partnerMon = &gEnemyParty[partnerPartyIdx]; u16 partnerMail = GetMonData(partnerMon, MON_DATA_MAIL); if (playerMail != 0xFF) ClearMailStruct(&gSaveBlock1Ptr->mail[playerMail]); - // This is where the actual trade happens!! - gUnknown_020322A0->mon = *playerMon; + sTradeData->mon = *playerMon; *playerMon = *partnerMon; - *partnerMon = gUnknown_020322A0->mon; + *partnerMon = sTradeData->mon; friendship = 70; if (!GetMonData(playerMon, MON_DATA_IS_EGG)) SetMonData(playerMon, MON_DATA_FRIENDSHIP, &friendship); if (partnerMail != 0xFF) - GiveMailToMon2(playerMon, &gUnknown_020321C0[partnerMail]); + GiveMailToMon2(playerMon, &gTradeMail[partnerMail]); - sub_807B464(a0); + UpdatePokedexForReceivedMon(playerPartyIdx); if (gReceivedRemoteLinkPlayers) - sub_807B4C4(); + TryEnableNationalDexFromLinkPartner(); } -static void sub_807B5B8(void) +static void TrySendTradeFinishData(void) { - switch (gUnknown_020322A0->unk_93) + switch (sTradeData->sendTradeFinishState) { - case 1: - if (IsLinkTaskFinished()) - { - Trade_SendData(gUnknown_020322A0); - gUnknown_020322A0->unk_93++; - } - // fallthrough - case 2: - gUnknown_020322A0->unk_93 = 0; - break; + case 1: + if (IsLinkTaskFinished()) + { + Trade_SendData(sTradeData); + sTradeData->sendTradeFinishState++; + } + // fallthrough + case 2: + sTradeData->sendTradeFinishState = 0; + break; } } -static void sub_807B60C(void) +static void CB2_UpdateInGameTrade(void) { - sub_807BBC8(); + AnimateTradeSequence(); RunTasks(); RunTextPrinters(); AnimateSprites(); @@ -4457,1244 +3261,1238 @@ static void sub_807B60C(void) UpdatePaletteFade(); } -static void sub_807B62C(u8 a0) +static void SetTradeSequenceBgGpuRegs(u8 state) { - switch (a0) + switch (state) { - case 0: - gUnknown_020322A0->bg2vofs = 0; - gUnknown_020322A0->bg2hofs = 180; - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG0_ON | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | - BGCNT_CHARBASE(1) | - BGCNT_16COLOR | - BGCNT_SCREENBASE(18) | - BGCNT_TXT512x256); - LoadPalette(gTradeGba2_Pal, 16, 0x60); - DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(1), 0x1420, 0x1000); - DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); - break; - case 1: - gUnknown_020322A0->bg1hofs = 0; - gUnknown_020322A0->bg1vofs = 348; - SetGpuReg(REG_OFFSET_BG1VOFS, 348); - SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | - BGCNT_CHARBASE(0) | - BGCNT_16COLOR | - BGCNT_SCREENBASE(5) | - BGCNT_TXT256x512); - SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | - BGCNT_CHARBASE(1) | - BGCNT_16COLOR | - BGCNT_SCREENBASE(18) | - BGCNT_TXT256x512); + case 0: + sTradeData->bg2vofs = 0; + sTradeData->bg2hofs = 180; + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG0_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(1) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_TXT512x256); + LoadPalette(gTradeGba2_Pal, 16, 0x60); + DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(1), 0x1420, 0x1000); + DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); + break; + case 1: + sTradeData->bg1hofs = 0; + sTradeData->bg1vofs = 348; + SetGpuReg(REG_OFFSET_BG1VOFS, 348); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(0) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(5) | + BGCNT_TXT256x512); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(1) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_TXT256x512); - if (gUnknown_020322A0->unk_FA) - { - DmaCopy16Defvars(3, gUnknown_083369A0, (void *) BG_SCREEN_ADDR(5), 0x1000); - } - else - { - DmaCopy16Defvars(3, gUnknown_083359A0, (void *) BG_SCREEN_ADDR(5), 0x1000); - } + if (sTradeData->isCableTrade) + { + DmaCopy16Defvars(3, sTradeTilemap_GbaCable, (void *) BG_SCREEN_ADDR(5), 0x1000); + } + else + { + DmaCopy16Defvars(3, sTradeTilemap_GbaWireless, (void *) BG_SCREEN_ADDR(5), 0x1000); + } - DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(0), 0x1420, 0x1000); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(0), 0x1420, 0x1000); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + break; + case 2: + sTradeData->bg1vofs = 0; + sTradeData->bg1hofs = 0; + if (!sTradeData->isCableTrade) + { + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_OBJ_ON); - break; - case 2: - gUnknown_020322A0->bg1vofs = 0; - gUnknown_020322A0->bg1hofs = 0; - if (!gUnknown_020322A0->unk_FA) - { - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_OBJ_ON); - LZ77UnCompVram(gUnknown_083379A0, (void *) BG_SCREEN_ADDR(5)); - BlendPalettes(0x8, 16, RGB_BLACK); - } - else - { - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_OBJ_ON); - DmaCopy16Defvars(3, gUnknown_0832FFC0, (void *) BG_SCREEN_ADDR(5), 0x800); - BlendPalettes(0x1, 16, RGB_BLACK); - } - break; - case 3: - LoadPalette(gUnknown_08337EA0, 48, 0x20); - LZ77UnCompVram(gUnknown_08337EC0, (void *) BG_CHAR_ADDR(1)); - LZ77UnCompVram(gUnknown_08338550, (void *) BG_SCREEN_ADDR(18)); - gUnknown_020322A0->bg2vofs = 80; - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + LZ77UnCompVram(gUnknown_083379A0, (void *) BG_SCREEN_ADDR(5)); + BlendPalettes(0x8, 16, RGB_BLACK); + } + else + { + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | - DISPCNT_BG2_ON | DISPCNT_OBJ_ON); - break; - case 4: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | - BGCNT_CHARBASE(1) | - BGCNT_256COLOR | - BGCNT_SCREENBASE(18) | - BGCNT_AFF128x128); - gUnknown_020322A0->unk_D4 = 64; - gUnknown_020322A0->unk_D6 = 92; - gUnknown_020322A0->unk_E8 = 32; - gUnknown_020322A0->unk_EA = 1024; - gUnknown_020322A0->unk_EC = 0; + DmaCopy16Defvars(3, sTradeTilemap_Cable, (void *) BG_SCREEN_ADDR(5), 0x800); + BlendPalettes(0x1, 16, RGB_BLACK); + } + break; + case 3: + LoadPalette(sTradePal_Black, 48, 0x20); + LZ77UnCompVram(sTradeGfx_WirelessSignal, (void *) BG_CHAR_ADDR(1)); + LZ77UnCompVram(sTradeTilemap_WirelessSignal, (void *) BG_SCREEN_ADDR(18)); + sTradeData->bg2vofs = 80; + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + break; + case 4: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | + BGCNT_CHARBASE(1) | + BGCNT_256COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_AFF128x128); + sTradeData->texX = 64; + sTradeData->texY = 92; + sTradeData->sXY = 32; + sTradeData->unk_EA = 1024; + sTradeData->alpha = 0; - DmaCopyLarge16(3, gUnknown_08332F60, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); + DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (gUnknown_020322A0->unk_FA) - { - DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); - } - else - { - DmaCopy16Defvars(3, gUnknown_083358A0, (void *) BG_SCREEN_ADDR(18), 0x100); - } - break; - case 5: - gUnknown_020322A0->bg1vofs = 0; - gUnknown_020322A0->bg1hofs = 0; - break; - case 6: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | - BGCNT_CHARBASE(1) | - BGCNT_256COLOR | - BGCNT_SCREENBASE(18) | - BGCNT_AFF128x128); - gUnknown_020322A0->unk_D4 = 64; - gUnknown_020322A0->unk_D6 = 92; - gUnknown_020322A0->unk_E8 = 256; - gUnknown_020322A0->unk_EA = 128; - gUnknown_020322A0->unk_DC = 120; - gUnknown_020322A0->unk_DE = 80; - gUnknown_020322A0->unk_EC = 0; + if (sTradeData->isCableTrade) + { + DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); + } + else + { + DmaCopy16Defvars(3, sTradeAffineMap_GbaWireless, (void *) BG_SCREEN_ADDR(18), 0x100); + } + break; + case 5: + sTradeData->bg1vofs = 0; + sTradeData->bg1hofs = 0; + break; + case 6: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(3) | + BGCNT_CHARBASE(1) | + BGCNT_256COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_AFF128x128); + sTradeData->texX = 64; + sTradeData->texY = 92; + sTradeData->sXY = 256; + sTradeData->unk_EA = 128; + sTradeData->scrX = 120; + sTradeData->scrY = 80; + sTradeData->alpha = 0; - DmaCopyLarge16(3, gUnknown_08332F60, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); + DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (gUnknown_020322A0->unk_FA) - { - DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); - } - else - { - DmaCopy16Defvars(3, gUnknown_083358A0, (void *) BG_SCREEN_ADDR(18), 0x100); - } - break; - case 7: - gUnknown_020322A0->bg2vofs = 0; - gUnknown_020322A0->bg2hofs = 0; - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | - BGCNT_CHARBASE(1) | - BGCNT_16COLOR | - BGCNT_SCREENBASE(18) | - BGCNT_TXT512x256); - LoadPalette(gTradeGba2_Pal, 16, 0x60); - DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(1), 0x1420, 0x1000); - DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); - break; + if (sTradeData->isCableTrade) + { + DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); + } + else + { + DmaCopy16Defvars(3, sTradeAffineMap_GbaWireless, (void *) BG_SCREEN_ADDR(18), 0x100); + } + break; + case 7: + sTradeData->bg2vofs = 0; + sTradeData->bg2hofs = 0; + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | + BGCNT_CHARBASE(1) | + BGCNT_16COLOR | + BGCNT_SCREENBASE(18) | + BGCNT_TXT512x256); + LoadPalette(gTradeGba2_Pal, 16, 0x60); + DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(1), 0x1420, 0x1000); + DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); + break; } } -static void sub_807BA94(void) +static void LoadTradeSequenceSpriteSheetsAndPalettes(void) { - LoadSpriteSheet(&gUnknown_08338D70); - LoadSpriteSheet(&gUnknown_08338DC0); - LoadSpriteSheet(&gUnknown_08338DF4); - LoadSpriteSheet(&gUnknown_08338E6C); - LoadSpritePalette(&gUnknown_08338D78); - LoadSpritePalette(&gUnknown_08338D80); + LoadSpriteSheet(&sGlow1SpriteSheet); + LoadSpriteSheet(&sGlow2SpriteSheet); + LoadSpriteSheet(&sCableEndSpriteSheet); + LoadSpriteSheet(&sGbaScreenSpriteSheet); + LoadSpritePalette(&sMiscTradeSpritePalette); + LoadSpritePalette(&sGbaSpritePalette); } -static void SetTradeSceneStrings(void) +// Buffers "[Pokemon] will be sent to [Trainer]" strings +static void BufferTradeSceneStrings(void) { - /*Sets the variable strings printed on the - *actual trading screen. For use in strings - *like "[Pokemon] will be sent to [Trainer]." - */ u8 mpId; u8 name[20]; const struct InGameTrade *ingameTrade; - if (gUnknown_020322A0->isLinkTrade) + if (sTradeData->isLinkTrade) { mpId = GetMultiplayerId(); StringCopy(gStringVar1, gLinkPlayers[mpId ^ 1].name); - GetMonData(&gEnemyParty[gUnknown_02032298[1] % PARTY_SIZE], MON_DATA_NICKNAME, name); + GetMonData(&gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE], MON_DATA_NICKNAME, name); StringCopy10(gStringVar3, name); - GetMonData(&gPlayerParty[gUnknown_02032298[0]], MON_DATA_NICKNAME, name); + GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], MON_DATA_NICKNAME, name); StringCopy10(gStringVar2, name); } else { - ingameTrade = &gIngameTrades[gSpecialVar_0x8004]; + ingameTrade = &sIngameTrades[gSpecialVar_0x8004]; StringCopy(gStringVar1, ingameTrade->otName); - StringCopy10(gStringVar3, ingameTrade->name); + StringCopy10(gStringVar3, ingameTrade->nickname); GetMonData(&gPlayerParty[gSpecialVar_0x8005], MON_DATA_NICKNAME, name); StringCopy10(gStringVar2, name); } } -static u8 sub_807BBC8(void) +// returns TRUE if it was a link trade, FALSE if it was an in-game trade +static bool8 AnimateTradeSequence(void) { - if (gUnknown_020322A0->unk_FA) - { - return sub_807BBEC(); - } + if (sTradeData->isCableTrade) + return AnimateTradeSequenceCable(); else - { - return sub_807CFC8(); - } + return AnimateTradeSequenceWireless(); } -static bool8 sub_807BBEC(void) +static bool8 AnimateTradeSequenceCable(void) { u16 evoTarget; - switch (gUnknown_020322A0->state) + switch (sTradeData->state) { - case 0: - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = -180; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[0]].y_offset; - gUnknown_020322A0->state++; - gUnknown_020322A0->cachedMapMusic = GetCurrentMapMusic(); - PlayNewMapMusic(MUS_SHINKA); - break; - case 1: - if (gUnknown_020322A0->bg2hofs > 0) - { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x += 3; - gUnknown_020322A0->bg2hofs -= 3; - } - else - { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = 0; - gUnknown_020322A0->bg2hofs = 0; - gUnknown_020322A0->state = 10; - } - break; - case 10: - StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); - sub_807F1A8(0, gStringVar4, 0); + case 0: + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = -180; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y = gMonFrontPicCoords[sTradeData->monSpecies[TRADE_PLAYER]].y_offset; + sTradeData->state++; + sTradeData->cachedMapMusic = GetCurrentMapMusic(); + PlayNewMapMusic(MUS_SHINKA); + break; + case 1: + if (sTradeData->bg2hofs > 0) + { + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; + sTradeData->bg2hofs -= 3; + } + else + { + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = 0; + sTradeData->bg2hofs = 0; + sTradeData->state = 10; + } + break; + case 10: + StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); + DrawTextOnTradeWindow(0, gStringVar4, 0); - if (gUnknown_020322A0->tradeSpecies[0] != SPECIES_EGG) - { - PlayCry1(gUnknown_020322A0->tradeSpecies[0], 0); - } + if (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) + { + PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); + } - gUnknown_020322A0->state = 11; - gUnknown_020322A0->timer = 0; - break; - case 11: - if (++gUnknown_020322A0->timer == 80) - { - gUnknown_020322A0->unk_D2 = sub_807671C(gUnknown_020322A0->pokePicSpriteIdxs[0], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); - gUnknown_020322A0->state++; - StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); - sub_807F1A8(0, gStringVar4, 0); - } - break; - case 12: - if (gSprites[gUnknown_020322A0->unk_D2].callback == SpriteCallbackDummy) - { - gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); - gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E5D8; - DestroySprite(&gSprites[gUnknown_020322A0->unk_D2]); - gUnknown_020322A0->state++; - } - break; - case 13: - // The game waits here for the sprite to finish its animation sequence. - break; - case 14: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 20; - break; - case 20: - if (!gPaletteFade.active) - { - sub_807B62C(4); - FillWindowPixelBuffer(0, PIXEL_FILL(15)); - CopyWindowToVram(0, 3); - gUnknown_020322A0->state++; - } - break; - case 21: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 22: - if (!gPaletteFade.active) - { - gUnknown_020322A0->state = 23; - } - break; - case 23: - if (gUnknown_020322A0->unk_EA > 0x100) - { - gUnknown_020322A0->unk_EA -= 0x34; - } - else - { - sub_807B62C(1); - gUnknown_020322A0->unk_EA = 0x80; - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; - } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; - break; - case 24: - if (++gUnknown_020322A0->timer > 20) - { - sub_807AB28(); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - gUnknown_020322A0->state++; - } - break; - case 25: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) - { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | - BLDCNT_TGT2_BG1 | - BLDCNT_TGT2_BG2); - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 4)); - gUnknown_020322A0->state++; - } - break; - case 26: - if (--gUnknown_020322A0->bg1vofs == 316) - { - gUnknown_020322A0->state++; - } - if (gUnknown_020322A0->bg1vofs == 328) - { - gUnknown_020322A0->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); - } - break; - case 27: - gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); - StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1); - gUnknown_020322A0->state++; - break; - case 28: - if ((gUnknown_020322A0->bg1vofs -= 2) == 166) - { - gUnknown_020322A0->state = 200; - } - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_OBJ_ON); - break; - case 200: - gSprites[gUnknown_020322A0->unk_90].pos1.y -= 2; - gSprites[gUnknown_020322A0->unk_91].pos1.y -= 2; - if (gSprites[gUnknown_020322A0->unk_90].pos1.y < -8) - { - gUnknown_020322A0->state = 29; - } - break; - case 29: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 30; - break; - case 30: - if (!gPaletteFade.active) - { - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - sub_807B62C(2); - gUnknown_020322A0->state++; - } - break; - case 31: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); - gUnknown_020322A0->state++; - break; - case 32: - if (!gPaletteFade.active) - { - PlaySE(SE_TK_WARPOUT); - gUnknown_020322A0->state++; - } - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - break; - case 33: - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -90) - { - gSprites[gUnknown_020322A0->unk_90].data[1] = 1; - gSprites[gUnknown_020322A0->unk_91].data[1] = 1; - gUnknown_020322A0->state++; - } - break; - case 34: - BlendPalettes(0x1, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 35: + sTradeData->state = 11; + sTradeData->timer = 0; + break; + case 11: + if (++sTradeData->timer == 80) + { + sTradeData->pokeballSpriteId = CreateTradePokeballSprite(sTradeData->pokePicSpriteIdxs[0], gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeData->state++; + StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); + DrawTextOnTradeWindow(0, gStringVar4, 0); + } + break; + case 12: + if (gSprites[sTradeData->pokeballSpriteId].callback == SpriteCallbackDummy) + { + sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[sTradeData->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[sTradeData->pokeballSpriteId]); + sTradeData->state++; + } + break; + case 13: + // The game waits here for the sprite to finish its animation sequence. + break; + case 14: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeData->state = 20; + break; + case 20: + if (!gPaletteFade.active) + { + SetTradeSequenceBgGpuRegs(4); + FillWindowPixelBuffer(0, PIXEL_FILL(15)); + CopyWindowToVram(0, 3); + sTradeData->state++; + } + break; + case 21: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + sTradeData->state++; + break; + case 22: + if (!gPaletteFade.active) + { + sTradeData->state = 23; + } + break; + case 23: + if (sTradeData->unk_EA > 0x100) + { + sTradeData->unk_EA -= 0x34; + } + else + { + SetTradeSequenceBgGpuRegs(1); + sTradeData->unk_EA = 0x80; + sTradeData->state++; + sTradeData->timer = 0; + } + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; + break; + case 24: + if (++sTradeData->timer > 20) + { + SetTradeBGAffine(); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state++; + } + break; + case 25: + if (gSprites[sTradeData->unk_91].animEnded) + { + DestroySprite(&gSprites[sTradeData->unk_91]); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | + BLDCNT_TGT2_BG1 | + BLDCNT_TGT2_BG2); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 4)); + sTradeData->state++; + } + break; + case 26: + if (--sTradeData->bg1vofs == 316) + { + sTradeData->state++; + } + if (sTradeData->bg1vofs == 328) + { + sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + } + break; + case 27: + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); + sTradeData->unk_91 = CreateSprite(&sGlowBallSpriteTemplate, 128, 80, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeData->state++; + break; + case 28: + if ((sTradeData->bg1vofs -= 2) == 166) + { + sTradeData->state = 200; + } + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + break; + case 200: + gSprites[sTradeData->unk_90].pos1.y -= 2; + gSprites[sTradeData->unk_91].pos1.y -= 2; + if (gSprites[sTradeData->unk_90].pos1.y < -8) + { + sTradeData->state = 29; + } + break; + case 29: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); + sTradeData->state = 30; + break; + case 30: + if (!gPaletteFade.active) + { + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + SetTradeSequenceBgGpuRegs(2); + sTradeData->state++; + } + break; + case 31: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + sTradeData->unk_90 = CreateSprite(&sGlowBallSpriteTemplate, 111, 170, 0); + sTradeData->unk_91 = CreateSprite(&sGlowBallSpriteTemplate, 129, -10, 0); + sTradeData->state++; + break; + case 32: + if (!gPaletteFade.active) + { + PlaySE(SE_TK_WARPOUT); + sTradeData->state++; + } + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + break; + case 33: + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -90) + { + gSprites[sTradeData->unk_90].data[1] = 1; + gSprites[sTradeData->unk_91].data[1] = 1; + sTradeData->state++; + } + break; + case 34: + BlendPalettes(0x1, 16, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 35: + BlendPalettes(0x1, 0, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 36: + BlendPalettes(0x1, 16, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 37: + if (!IsMonSpriteNotFlipped(sTradeData->monSpecies[TRADE_PLAYER])) + { + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + } + else + { + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + } + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.x = 60; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 180; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.y = 192; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = -32; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = FALSE; + sTradeData->state++; + break; + case 38: + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y += 3; + if (gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -160 && gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y >= -163) + { + PlaySE(SE_TK_WARPIN); + } + if (gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -222) + { + gSprites[sTradeData->unk_90].data[1] = 0; + gSprites[sTradeData->unk_91].data[1] = 0; + sTradeData->state++; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = TRUE; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = TRUE; BlendPalettes(0x1, 0, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 36: - BlendPalettes(0x1, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 37: - if (!IsMonSpriteNotFlipped(gUnknown_020322A0->tradeSpecies[0])) - { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.affineMode = 3; - CalcCenterToCornerVec(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0, 3, 3); - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); - } - else - { - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); - } - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0); - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.x = 60; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 180; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.y = 192; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = -32; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = FALSE; - gUnknown_020322A0->state++; - break; - case 38: - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y -= 3; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y += 3; - if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y >= -163) - { - PlaySE(SE_TK_WARPIN); - } - if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -222) - { - gSprites[gUnknown_020322A0->unk_90].data[1] = 0; - gSprites[gUnknown_020322A0->unk_91].data[1] = 0; - gUnknown_020322A0->state++; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = TRUE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = TRUE; - BlendPalettes(0x1, 0, RGB_WHITEALPHA); - } - break; - case 39: - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -222) - { - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - gUnknown_020322A0->state++; - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - } - break; - case 40: - if (!gPaletteFade.active) - { - gUnknown_020322A0->state++; - sub_807B62C(1); - gUnknown_020322A0->bg1vofs = 166; - gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); - StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1); - } - break; - case 41: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 42: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_OBJ_ON); - if (!gPaletteFade.active) - { - gUnknown_020322A0->state++; - } - break; - case 43: - gSprites[gUnknown_020322A0->unk_90].pos2.y += 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - if (gSprites[gUnknown_020322A0->unk_90].pos2.y + gSprites[gUnknown_020322A0->unk_90].pos1.y == 64) - { - gUnknown_020322A0->state++; - } - break; - case 44: - if ((gUnknown_020322A0->bg1vofs += 2) > 316) - { - gUnknown_020322A0->bg1vofs = 316; - gUnknown_020322A0->state++; - } - break; - case 45: - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; - break; - case 46: - if (++gUnknown_020322A0->timer == 10) - { - gUnknown_020322A0->state++; - } - break; - case 47: - if (++gUnknown_020322A0->bg1vofs > 348) - { - gUnknown_020322A0->bg1vofs = 348; - gUnknown_020322A0->state++; - } - if (gUnknown_020322A0->bg1vofs == 328 && gUnknown_020322A0->unk_FA) - { - gUnknown_020322A0->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); - gSprites[gUnknown_020322A0->unk_92].callback = sub_807AAE0; - } - break; - case 48: - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - gUnknown_020322A0->state = 50; - break; - case 50: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) - { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - sub_807B62C(6); - gUnknown_020322A0->state++; - PlaySE(SE_W028); - } - break; - case 51: - if (gUnknown_020322A0->unk_EA < 0x400) - { - gUnknown_020322A0->unk_EA += 0x34; - } - else - { - gUnknown_020322A0->unk_EA = 0x400; - gUnknown_020322A0->state++; - } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; - break; - case 52: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 60; - break; + } + break; + case 39: + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -222) + { + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); + sTradeData->state++; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + } + break; + case 40: + if (!gPaletteFade.active) + { + sTradeData->state++; + SetTradeSequenceBgGpuRegs(1); + sTradeData->bg1vofs = 166; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); + sTradeData->unk_91 = CreateSprite(&sGlowBallSpriteTemplate, 128, -20, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + } + break; + case 41: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + sTradeData->state++; + break; + case 42: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + if (!gPaletteFade.active) + { + sTradeData->state++; + } + break; + case 43: + gSprites[sTradeData->unk_90].pos2.y += 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y + gSprites[sTradeData->unk_90].pos1.y == 64) + { + sTradeData->state++; + } + break; + case 44: + if ((sTradeData->bg1vofs += 2) > 316) + { + sTradeData->bg1vofs = 316; + sTradeData->state++; + } + break; + case 45: + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeData->state++; + sTradeData->timer = 0; + break; + case 46: + if (++sTradeData->timer == 10) + { + sTradeData->state++; + } + break; + case 47: + if (++sTradeData->bg1vofs > 348) + { + sTradeData->bg1vofs = 348; + sTradeData->state++; + } + if (sTradeData->bg1vofs == 328 && sTradeData->isCableTrade) + { + sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + gSprites[sTradeData->unk_92].callback = sub_807AAE0; + } + break; + case 48: + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state = 50; + break; + case 50: + if (gSprites[sTradeData->unk_91].animEnded) + { + DestroySprite(&gSprites[sTradeData->unk_91]); + SetTradeSequenceBgGpuRegs(6); + sTradeData->state++; + PlaySE(SE_W028); + } + break; + case 51: + if (sTradeData->unk_EA < 0x400) + { + sTradeData->unk_EA += 0x34; + } + else + { + sTradeData->unk_EA = 0x400; + sTradeData->state++; + } + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; + break; + case 52: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeData->state = 60; + break; - case 60: - if (!gPaletteFade.active) + case 60: + if (!gPaletteFade.active) + { + SetTradeSequenceBgGpuRegs(5); + SetTradeSequenceBgGpuRegs(7); + gPaletteFade.bufferTransferDisabled = TRUE; + sTradeData->state++; + } + break; + case 61: + gPaletteFade.bufferTransferDisabled = FALSE; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + sTradeData->state++; + break; + case 62: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + if (!gPaletteFade.active) + { + sTradeData->state++; + } + break; + case 63: + sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); + gSprites[sTradeData->unk_D3].data[3] = 74; + gSprites[sTradeData->unk_D3].callback = sub_807E6AC; + StartSpriteAnim(&gSprites[sTradeData->unk_D3], 1); + StartSpriteAffineAnim(&gSprites[sTradeData->unk_D3], 2); + BlendPalettes(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); + sTradeData->state++; + sTradeData->timer = 0; + break; + case 64: + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 65: + if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy) + { + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); + sTradeData->state++; + } + break; + case 66: + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 120; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = gMonFrontPicCoords[sTradeData->monSpecies[TRADE_PARTNER]].y_offset + 60; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.x = 0; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y = 0; + StartSpriteAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + CreatePokeballSpriteToReleaseMon(sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->monSpecies[TRADE_PARTNER]); + FreeSpriteOamMatrix(&gSprites[sTradeData->unk_D3]); + DestroySprite(&gSprites[sTradeData->unk_D3]); + sTradeData->state++; + break; + case 67: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG0_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + StringExpandPlaceholders(gStringVar4, gText_XSentOverY); + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->state = 167; + sTradeData->timer = 0; + break; + // 167 and 267 are extra cases added in for animations + case 167: + if (++sTradeData->timer > 60) + { + sTradeData->state = 267; + sTradeData->timer = 0; + } + break; + case 267: + if (IsCryFinished()) + { + sTradeData->state = 68; + } + break; + case 68: + if (++sTradeData->timer == 10) + { + PlayFanfare(MUS_FANFA5); + } + if (sTradeData->timer == 250) + { + sTradeData->state++; + StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->timer = 0; + } + break; + case 69: + if (++sTradeData->timer == 60) + { + sTradeData->state++; + } + break; + case 70: + CheckPartnersMonForRibbons(); + sTradeData->state++; + break; + case 71: + if (sTradeData->isLinkTrade) + { + return TRUE; + } + else if (gMain.newKeys & A_BUTTON) + { + sTradeData->state++; + } + break; + case 72: // Only if in-game trade + TradeMons(gSpecialVar_0x8005, 0); + gCB2_AfterEvolution = CB2_UpdateInGameTrade; + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); + if (evoTarget != SPECIES_NONE) + { + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + } + sTradeData->state++; + break; + case 73: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeData->state++; + break; + case 74: + if (!gPaletteFade.active) + { + PlayNewMapMusic(sTradeData->cachedMapMusic); + if (sTradeData) { - sub_807B62C(5); - sub_807B62C(7); - gPaletteFade.bufferTransferDisabled = TRUE; - gUnknown_020322A0->state++; + FreeAllWindowBuffers(); + Free(GetBgTilemapBuffer(3)); + Free(GetBgTilemapBuffer(1)); + Free(GetBgTilemapBuffer(0)); + FreeMonSpritesGfx(); + FREE_AND_SET_NULL(sTradeData); } - break; - case 61: - gPaletteFade.bufferTransferDisabled = FALSE; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 62: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - if (!gPaletteFade.active) - { - gUnknown_020322A0->state++; - } - break; - case 63: - gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); - gSprites[gUnknown_020322A0->unk_D3].data[3] = 74; - gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E6AC; - StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_D3], 1); - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->unk_D3], 2); - BlendPalettes(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; - break; - case 64: - BeginNormalPaletteFade(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 65: - if (gSprites[gUnknown_020322A0->unk_D3].callback == SpriteCallbackDummy) - { - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[gUnknown_020322A0->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], gUnknown_020322A0->tradeSpecies[1], gUnknown_020322A0->unk_68[1]); - gUnknown_020322A0->state++; - } - break; - case 66: - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 120; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[1]].y_offset + 60; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.x = 0; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y = 0; - StartSpriteAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0); - CreatePokeballSpriteToReleaseMon(gUnknown_020322A0->pokePicSpriteIdxs[1], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, gUnknown_020322A0->tradeSpecies[1]); - FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->unk_D3]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_D3]); - gUnknown_020322A0->state++; - break; - case 67: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG0_ON | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - StringExpandPlaceholders(gStringVar4, gText_XSentOverY); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->state = 167; - gUnknown_020322A0->timer = 0; - break; - // 167 and 267 are extra cases added in for animations - case 167: - if (++gUnknown_020322A0->timer > 60) - { - gUnknown_020322A0->state = 267; - gUnknown_020322A0->timer = 0; - } - break; - case 267: - if (IsCryFinished()) - { - gUnknown_020322A0->state = 68; - } - break; - case 68: - if (++gUnknown_020322A0->timer == 10) - { - PlayFanfare(MUS_FANFA5); - } - if (gUnknown_020322A0->timer == 250) - { - gUnknown_020322A0->state++; - StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->timer = 0; - } - break; - case 69: - if (++gUnknown_020322A0->timer == 60) - { - gUnknown_020322A0->state++; - } - break; - case 70: - sub_807F14C(); - gUnknown_020322A0->state++; - break; - case 71: - if (gUnknown_020322A0->isLinkTrade) - { - return TRUE; - } - else if (gMain.newKeys & A_BUTTON) - { - gUnknown_020322A0->state++; - } - break; - case 72: // Only if in-game trade - sub_807B4D0(gSpecialVar_0x8005, 0); - gCB2_AfterEvolution = sub_807B60C; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gUnknown_02032298[0]], TRUE, ITEM_NONE); - if (evoTarget != SPECIES_NONE) - { - TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); - } - gUnknown_020322A0->state++; - break; - case 73: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 74: - if (!gPaletteFade.active) - { - PlayNewMapMusic(gUnknown_020322A0->cachedMapMusic); - if (gUnknown_020322A0) - { - FreeAllWindowBuffers(); - Free(GetBgTilemapBuffer(3)); - Free(GetBgTilemapBuffer(1)); - Free(GetBgTilemapBuffer(0)); - FreeMonSpritesGfx(); - FREE_AND_SET_NULL(gUnknown_020322A0); - } - SetMainCallback2(CB2_ReturnToField); - sub_807E784(); - } - break; + SetMainCallback2(CB2_ReturnToField); + BuffeInGameTradeMonName(); + } + break; } return FALSE; } -static bool8 sub_807CFC8(void) +static bool8 AnimateTradeSequenceWireless(void) { u16 evoTarget; - switch (gUnknown_020322A0->state) + switch (sTradeData->state) { - case 0: - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = -180; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[0]].y_offset; - gUnknown_020322A0->state++; - gUnknown_020322A0->cachedMapMusic = GetCurrentMapMusic(); - PlayNewMapMusic(MUS_SHINKA); - break; - case 1: - if (gUnknown_020322A0->bg2hofs > 0) - { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x += 3; - gUnknown_020322A0->bg2hofs -= 3; - } - else - { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = 0; - gUnknown_020322A0->bg2hofs = 0; - gUnknown_020322A0->state = 10; - } - break; - case 10: - StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); - sub_807F1A8(0, gStringVar4, 0); + case 0: + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = -180; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y = gMonFrontPicCoords[sTradeData->monSpecies[TRADE_PLAYER]].y_offset; + sTradeData->state++; + sTradeData->cachedMapMusic = GetCurrentMapMusic(); + PlayNewMapMusic(MUS_SHINKA); + break; + case 1: + if (sTradeData->bg2hofs > 0) + { + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; + sTradeData->bg2hofs -= 3; + } + else + { + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = 0; + sTradeData->bg2hofs = 0; + sTradeData->state = 10; + } + break; + case 10: + StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); + DrawTextOnTradeWindow(0, gStringVar4, 0); - if (gUnknown_020322A0->tradeSpecies[0] != SPECIES_EGG) - { - PlayCry1(gUnknown_020322A0->tradeSpecies[0], 0); - } + if (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) + { + PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); + } - gUnknown_020322A0->state = 11; - gUnknown_020322A0->timer = 0; - break; - case 11: - if (++gUnknown_020322A0->timer == 80) - { - gUnknown_020322A0->unk_D2 = sub_807671C(gUnknown_020322A0->pokePicSpriteIdxs[0], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); - gUnknown_020322A0->state++; - StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); - sub_807F1A8(0, gStringVar4, 0); - } - break; - case 12: - if (gSprites[gUnknown_020322A0->unk_D2].callback == SpriteCallbackDummy) - { - gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); - gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E5D8; - DestroySprite(&gSprites[gUnknown_020322A0->unk_D2]); - gUnknown_020322A0->state++; - } - break; - case 13: - // The game waits here for the sprite to finish its animation sequence. - break; - case 14: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 20; - break; - case 20: - if (!gPaletteFade.active) - { - sub_807B62C(4); - FillWindowPixelBuffer(0, PIXEL_FILL(15)); - CopyWindowToVram(0, 3); - gUnknown_020322A0->state++; - } - break; - case 21: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 22: - if (!gPaletteFade.active) - { - gUnknown_020322A0->state = 23; - } - break; - case 23: - if (gUnknown_020322A0->unk_EA > 0x100) - { - gUnknown_020322A0->unk_EA -= 0x34; - } - else - { - sub_807B62C(1); - gUnknown_020322A0->unk_EA = 0x80; - gUnknown_020322A0->state = 124; - gUnknown_020322A0->timer = 0; - } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; - break; - case 124: - if (++gUnknown_020322A0->timer > 20) - { - sub_807B62C(3); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); - gUnknown_020322A0->state++; - } - break; - case 125: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) - { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | - BLDCNT_TGT1_OBJ | - BLDCNT_EFFECT_BLEND | - BLDCNT_TGT2_BG2); - SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 4)); - CreateTask(c3_08054588, 5); - gUnknown_020322A0->state++; - } - break; - case 126: - if (!FuncIsActiveTask(c3_08054588)) - { - gUnknown_020322A0->state = 26; - } - break; - case 26: - if (--gUnknown_020322A0->bg1vofs == 316) - { - gUnknown_020322A0->state++; - } - break; - case 27: - gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); - gSprites[gUnknown_020322A0->unk_90].callback = sub_807AA4C; - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0); - StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1); - gUnknown_020322A0->state++; - break; - case 28: - if ((gUnknown_020322A0->bg1vofs -= 3) == 166) - { - gUnknown_020322A0->state = 200; - } - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_OBJ_ON); - break; - case 200: - gSprites[gUnknown_020322A0->unk_90].pos1.y -= 2; - gSprites[gUnknown_020322A0->unk_91].pos1.y -= 2; - if (gSprites[gUnknown_020322A0->unk_90].pos1.y < -8) - { - gUnknown_020322A0->state = 29; - } - break; - case 29: + sTradeData->state = 11; + sTradeData->timer = 0; + break; + case 11: + if (++sTradeData->timer == 80) + { + sTradeData->pokeballSpriteId = CreateTradePokeballSprite(sTradeData->pokePicSpriteIdxs[0], gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeData->state++; + StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); + DrawTextOnTradeWindow(0, gStringVar4, 0); + } + break; + case 12: + if (gSprites[sTradeData->pokeballSpriteId].callback == SpriteCallbackDummy) + { + sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[sTradeData->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[sTradeData->pokeballSpriteId]); + sTradeData->state++; + } + break; + case 13: + // The game waits here for the sprite to finish its animation sequence. + break; + case 14: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeData->state = 20; + break; + case 20: + if (!gPaletteFade.active) + { + SetTradeSequenceBgGpuRegs(4); + FillWindowPixelBuffer(0, PIXEL_FILL(15)); + CopyWindowToVram(0, 3); + sTradeData->state++; + } + break; + case 21: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + sTradeData->state++; + break; + case 22: + if (!gPaletteFade.active) + { + sTradeData->state = 23; + } + break; + case 23: + if (sTradeData->unk_EA > 0x100) + { + sTradeData->unk_EA -= 0x34; + } + else + { + SetTradeSequenceBgGpuRegs(1); + sTradeData->unk_EA = 0x80; + sTradeData->state = 124; + sTradeData->timer = 0; + } + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; + break; + case 124: + if (++sTradeData->timer > 20) + { + SetTradeSequenceBgGpuRegs(3); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); + sTradeData->state++; + } + break; + case 125: + if (gSprites[sTradeData->unk_91].animEnded) + { + DestroySprite(&gSprites[sTradeData->unk_91]); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | + BLDCNT_TGT1_OBJ | + BLDCNT_EFFECT_BLEND | + BLDCNT_TGT2_BG2); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 4)); + CreateTask(Task_AnimateWirelessSignal, 5); + sTradeData->state++; + } + break; + case 126: + if (!FuncIsActiveTask(Task_AnimateWirelessSignal)) + { + sTradeData->state = 26; + } + break; + case 26: + if (--sTradeData->bg1vofs == 316) + { + sTradeData->state++; + } + break; + case 27: + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); + gSprites[sTradeData->unk_90].callback = sub_807AA4C; + sTradeData->unk_91 = CreateSprite(&sGlowBallSpriteTemplate, 120, 80, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeData->state++; + break; + case 28: + if ((sTradeData->bg1vofs -= 3) == 166) + { + sTradeData->state = 200; + } + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + break; + case 200: + gSprites[sTradeData->unk_90].pos1.y -= 2; + gSprites[sTradeData->unk_91].pos1.y -= 2; + if (gSprites[sTradeData->unk_90].pos1.y < -8) + { + sTradeData->state = 29; + } + break; + case 29: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); + sTradeData->state = 30; + break; + case 30: + if (!gPaletteFade.active) + { + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + SetTradeSequenceBgGpuRegs(2); + sTradeData->state++; + } + break; + case 31: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + sTradeData->unk_90 = CreateSprite(&sGlowBallSpriteTemplate, 111, 170, 0); + sTradeData->unk_91 = CreateSprite(&sGlowBallSpriteTemplate, 129, -10, 0); + sTradeData->state++; + break; + case 32: + if (!gPaletteFade.active) + { + PlaySE(SE_TK_WARPOUT); + sTradeData->state++; + } + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + break; + case 33: + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -90) + { + gSprites[sTradeData->unk_90].data[1] = 1; + gSprites[sTradeData->unk_91].data[1] = 1; + sTradeData->state++; + CreateTask(c3_0805465C, 5); + } + break; + case 34: + BlendPalettes(0x8, 16, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 35: + BlendPalettes(0x8, 16, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 36: + BlendPalettes(0x8, 16, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 37: + if (!IsMonSpriteNotFlipped(sTradeData->monSpecies[TRADE_PLAYER])) + { + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + } + else + { + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + } + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.x = 40; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 200; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.y = 192; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = -32; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = FALSE; + sTradeData->state++; + break; + case 38: + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y += 3; + if (gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -160 && gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y >= -163) + { + PlaySE(SE_TK_WARPIN); + } + if (gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -222) + { + gSprites[sTradeData->unk_90].data[1] = 0; + gSprites[sTradeData->unk_91].data[1] = 0; + sTradeData->state++; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = TRUE; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = TRUE; + CreateTask(sub_807F39C, 5); + } + break; + case 39: + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -222) + { BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 30; - break; - case 30: - if (!gPaletteFade.active) + sTradeData->state++; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + } + break; + case 40: + if (!gPaletteFade.active) + { + sTradeData->state++; + SetTradeSequenceBgGpuRegs(1); + sTradeData->bg1vofs = 166; + SetTradeSequenceBgGpuRegs(3); + sTradeData->bg2vofs = 412; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); + gSprites[sTradeData->unk_90].callback = sub_807AA4C; + sTradeData->unk_91 = CreateSprite(&sGlowBallSpriteTemplate, 120, -20, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + } + break; + case 41: + BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + sTradeData->state++; + break; + case 42: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_OBJ_ON); + if (!gPaletteFade.active) + { + sTradeData->state++; + } + break; + case 43: + gSprites[sTradeData->unk_90].pos2.y += 4; + gSprites[sTradeData->unk_91].pos2.y += 4; + if (gSprites[sTradeData->unk_90].pos2.y + gSprites[sTradeData->unk_90].pos1.y == 64) + { + sTradeData->state = 144; + sTradeData->timer = 0; + } + break; + case 144: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG1_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + sTradeData->bg1vofs += 3; + sTradeData->bg2vofs += 3; + if (++sTradeData->timer == 10) + { + u8 taskId = CreateTask(Task_AnimateWirelessSignal, 5); + gTasks[taskId].data[2] = TRUE; + } + if (sTradeData->bg1vofs > 316) + { + sTradeData->bg1vofs = 316; + sTradeData->state++; + } + break; + case 145: + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeData->state++; + sTradeData->timer = 0; + break; + case 146: + if (!FuncIsActiveTask(Task_AnimateWirelessSignal)) + { + sTradeData->state = 46; + sTradeData->timer = 0; + } + break; + case 46: + if (++sTradeData->timer == 10) + { + sTradeData->state++; + } + break; + case 47: + if (++sTradeData->bg1vofs > 348) + { + sTradeData->bg1vofs = 348; + sTradeData->state++; + } + break; + case 48: + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state = 50; + break; + case 50: + if (gSprites[sTradeData->unk_91].animEnded) + { + DestroySprite(&gSprites[sTradeData->unk_91]); + SetTradeSequenceBgGpuRegs(6); + sTradeData->state++; + PlaySE(SE_W028); + } + break; + case 51: + if (sTradeData->unk_EA < 0x400) + { + sTradeData->unk_EA += 0x34; + } + else + { + sTradeData->unk_EA = 0x400; + sTradeData->state++; + } + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; + break; + case 52: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeData->state = 60; + break; + case 60: + if (!gPaletteFade.active) + { + SetTradeSequenceBgGpuRegs(5); + SetTradeSequenceBgGpuRegs(7); + gPaletteFade.bufferTransferDisabled = TRUE; + sTradeData->state++; + } + break; + case 61: + gPaletteFade.bufferTransferDisabled = FALSE; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + sTradeData->state++; + break; + case 62: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + if (!gPaletteFade.active) + { + sTradeData->state++; + } + break; + case 63: + sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); + gSprites[sTradeData->unk_D3].data[3] = 74; + gSprites[sTradeData->unk_D3].callback = sub_807E6AC; + StartSpriteAnim(&gSprites[sTradeData->unk_D3], 1); + StartSpriteAffineAnim(&gSprites[sTradeData->unk_D3], 2); + BlendPalettes(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); + sTradeData->state++; + sTradeData->timer = 0; + break; + case 64: + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeData->state++; + break; + case 65: + if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy) + { + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); + sTradeData->state++; + } + break; + case 66: + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 120; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = gMonFrontPicCoords[sTradeData->monSpecies[TRADE_PARTNER]].y_offset + 60; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.x = 0; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y = 0; + StartSpriteAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + CreatePokeballSpriteToReleaseMon(sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->monSpecies[TRADE_PARTNER]); + FreeSpriteOamMatrix(&gSprites[sTradeData->unk_D3]); + DestroySprite(&gSprites[sTradeData->unk_D3]); + sTradeData->state++; + break; + case 67: + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | + DISPCNT_OBJ_1D_MAP | + DISPCNT_BG0_ON | + DISPCNT_BG2_ON | + DISPCNT_OBJ_ON); + StringExpandPlaceholders(gStringVar4, gText_XSentOverY); + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->state = 167; + sTradeData->timer = 0; + break; + // 167 and 267 are extra cases added in for animations + case 167: + if (++sTradeData->timer > 60) + { + sTradeData->state = 267; + sTradeData->timer = 0; + } + break; + case 267: + if (IsCryFinished()) + { + sTradeData->state = 68; + } + break; + case 68: + if (++sTradeData->timer == 10) + { + PlayFanfare(MUS_FANFA5); + } + if (sTradeData->timer == 250) + { + sTradeData->state++; + StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->timer = 0; + } + break; + case 69: + if (++sTradeData->timer == 60) + { + sTradeData->state++; + } + break; + case 70: + CheckPartnersMonForRibbons(); + sTradeData->state++; + break; + case 71: + if (sTradeData->isLinkTrade) + { + return TRUE; + } + else if (gMain.newKeys & A_BUTTON) + { + sTradeData->state++; + } + break; + case 72: // Only if in-game trade + TradeMons(gSpecialVar_0x8005, 0); + gCB2_AfterEvolution = CB2_UpdateInGameTrade; + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); + if (evoTarget != SPECIES_NONE) + { + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + } + sTradeData->state++; + break; + case 73: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeData->state++; + break; + case 74: + if (!gPaletteFade.active) + { + PlayNewMapMusic(sTradeData->cachedMapMusic); + if (sTradeData) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - sub_807B62C(2); - gUnknown_020322A0->state++; + FreeAllWindowBuffers(); + Free(GetBgTilemapBuffer(3)); + Free(GetBgTilemapBuffer(1)); + Free(GetBgTilemapBuffer(0)); + FreeMonSpritesGfx(); + FREE_AND_SET_NULL(sTradeData); } - break; - case 31: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); - gUnknown_020322A0->state++; - break; - case 32: - if (!gPaletteFade.active) - { - PlaySE(SE_TK_WARPOUT); - gUnknown_020322A0->state++; - } - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - break; - case 33: - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -90) - { - gSprites[gUnknown_020322A0->unk_90].data[1] = 1; - gSprites[gUnknown_020322A0->unk_91].data[1] = 1; - gUnknown_020322A0->state++; - CreateTask(c3_0805465C, 5); - } - break; - case 34: - BlendPalettes(0x8, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 35: - BlendPalettes(0x8, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 36: - BlendPalettes(0x8, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 37: - if (!IsMonSpriteNotFlipped(gUnknown_020322A0->tradeSpecies[0])) - { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].oam.affineMode = 3; - CalcCenterToCornerVec(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0, 3, 3); - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); - } - else - { - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); - } - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0); - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.x = 40; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 200; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos1.y = 192; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = -32; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = FALSE; - gUnknown_020322A0->state++; - break; - case 38: - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y -= 3; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y += 3; - if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y >= -163) - { - PlaySE(SE_TK_WARPIN); - } - if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -222) - { - gSprites[gUnknown_020322A0->unk_90].data[1] = 0; - gSprites[gUnknown_020322A0->unk_91].data[1] = 0; - gUnknown_020322A0->state++; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].invisible = TRUE; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].invisible = TRUE; - CreateTask(sub_807F39C, 5); - } - break; - case 39: - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; - if (gSprites[gUnknown_020322A0->unk_90].pos2.y <= -222) - { - BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - gUnknown_020322A0->state++; - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - } - break; - case 40: - if (!gPaletteFade.active) - { - gUnknown_020322A0->state++; - sub_807B62C(1); - gUnknown_020322A0->bg1vofs = 166; - sub_807B62C(3); - gUnknown_020322A0->bg2vofs = 412; - gUnknown_020322A0->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); - gSprites[gUnknown_020322A0->unk_90].callback = sub_807AA4C; - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0); - StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_91], 1); - } - break; - case 41: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 42: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_OBJ_ON); - if (!gPaletteFade.active) - { - gUnknown_020322A0->state++; - } - break; - case 43: - gSprites[gUnknown_020322A0->unk_90].pos2.y += 4; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 4; - if (gSprites[gUnknown_020322A0->unk_90].pos2.y + gSprites[gUnknown_020322A0->unk_90].pos1.y == 64) - { - gUnknown_020322A0->state = 144; - gUnknown_020322A0->timer = 0; - } - break; - case 144: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG1_ON | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - gUnknown_020322A0->bg1vofs += 3; - gUnknown_020322A0->bg2vofs += 3; - if (++gUnknown_020322A0->timer == 10) - { - u8 taskId = CreateTask(c3_08054588, 5); - gTasks[taskId].data[2] = 1; - } - if (gUnknown_020322A0->bg1vofs > 316) - { - gUnknown_020322A0->bg1vofs = 316; - gUnknown_020322A0->state++; - } - break; - case 145: - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; - break; - case 146: - if (!FuncIsActiveTask(c3_08054588)) - { - gUnknown_020322A0->state = 46; - gUnknown_020322A0->timer = 0; - } - break; - case 46: - if (++gUnknown_020322A0->timer == 10) - { - gUnknown_020322A0->state++; - } - break; - case 47: - if (++gUnknown_020322A0->bg1vofs > 348) - { - gUnknown_020322A0->bg1vofs = 348; - gUnknown_020322A0->state++; - } - break; - case 48: - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - gUnknown_020322A0->state = 50; - break; - case 50: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) - { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - sub_807B62C(6); - gUnknown_020322A0->state++; - PlaySE(SE_W028); - } - break; - case 51: - if (gUnknown_020322A0->unk_EA < 0x400) - { - gUnknown_020322A0->unk_EA += 0x34; - } - else - { - gUnknown_020322A0->unk_EA = 0x400; - gUnknown_020322A0->state++; - } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; - break; - case 52: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 60; - break; - case 60: - if (!gPaletteFade.active) - { - sub_807B62C(5); - sub_807B62C(7); - gPaletteFade.bufferTransferDisabled = TRUE; - gUnknown_020322A0->state++; - } - break; - case 61: - gPaletteFade.bufferTransferDisabled = FALSE; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 62: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - if (!gPaletteFade.active) - { - gUnknown_020322A0->state++; - } - break; - case 63: - gUnknown_020322A0->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); - gSprites[gUnknown_020322A0->unk_D3].data[3] = 74; - gSprites[gUnknown_020322A0->unk_D3].callback = sub_807E6AC; - StartSpriteAnim(&gSprites[gUnknown_020322A0->unk_D3], 1); - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->unk_D3], 2); - BlendPalettes(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; - break; - case 64: - BeginNormalPaletteFade(1 << (16 + gSprites[gUnknown_020322A0->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - gUnknown_020322A0->state++; - break; - case 65: - if (gSprites[gUnknown_020322A0->unk_D3].callback == SpriteCallbackDummy) - { - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[gUnknown_020322A0->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], gUnknown_020322A0->tradeSpecies[1], gUnknown_020322A0->unk_68[1]); - gUnknown_020322A0->state++; - } - break; - case 66: - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.x = 120; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[gUnknown_020322A0->tradeSpecies[1]].y_offset + 60; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.x = 0; - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].pos2.y = 0; - StartSpriteAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]], 0); - CreatePokeballSpriteToReleaseMon(gUnknown_020322A0->pokePicSpriteIdxs[1], gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, gUnknown_020322A0->tradeSpecies[1]); - FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->unk_D3]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_D3]); - gUnknown_020322A0->state++; - break; - case 67: - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | - DISPCNT_BG0_ON | - DISPCNT_BG2_ON | - DISPCNT_OBJ_ON); - StringExpandPlaceholders(gStringVar4, gText_XSentOverY); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->state = 167; - gUnknown_020322A0->timer = 0; - break; - // 167 and 267 are extra cases added in for animations - case 167: - if (++gUnknown_020322A0->timer > 60) - { - gUnknown_020322A0->state = 267; - gUnknown_020322A0->timer = 0; - } - break; - case 267: - if (IsCryFinished()) - { - gUnknown_020322A0->state = 68; - } - break; - case 68: - if (++gUnknown_020322A0->timer == 10) - { - PlayFanfare(MUS_FANFA5); - } - if (gUnknown_020322A0->timer == 250) - { - gUnknown_020322A0->state++; - StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->timer = 0; - } - break; - case 69: - if (++gUnknown_020322A0->timer == 60) - { - gUnknown_020322A0->state++; - } - break; - case 70: - sub_807F14C(); - gUnknown_020322A0->state++; - break; - case 71: - if (gUnknown_020322A0->isLinkTrade) - { - return TRUE; - } - else if (gMain.newKeys & A_BUTTON) - { - gUnknown_020322A0->state++; - } - break; - case 72: // Only if in-game trade - sub_807B4D0(gSpecialVar_0x8005, 0); - gCB2_AfterEvolution = sub_807B60C; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gUnknown_02032298[0]], TRUE, ITEM_NONE); - if (evoTarget != SPECIES_NONE) - { - TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); - } - gUnknown_020322A0->state++; - break; - case 73: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state++; - break; - case 74: - if (!gPaletteFade.active) - { - PlayNewMapMusic(gUnknown_020322A0->cachedMapMusic); - if (gUnknown_020322A0) - { - FreeAllWindowBuffers(); - Free(GetBgTilemapBuffer(3)); - Free(GetBgTilemapBuffer(1)); - Free(GetBgTilemapBuffer(0)); - FreeMonSpritesGfx(); - FREE_AND_SET_NULL(gUnknown_020322A0); - } - SetMainCallback2(CB2_ReturnToField); - sub_807E784(); - } - break; + SetMainCallback2(CB2_ReturnToField); + BuffeInGameTradeMonName(); + } + break; } return FALSE; } -static void c2_08053788(void) +static void CB2_TryTradeEvolution(void) { u16 evoTarget; switch (gMain.state) { - case 0: - gMain.state = 4; - gSoftResetDisabled = TRUE; - break; - case 4: - gCB2_AfterEvolution = sub_807EB50; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gUnknown_02032298[0]], TRUE, ITEM_NONE); - if (evoTarget != SPECIES_NONE) - TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); - else if (sub_8077260()) - SetMainCallback2(sub_807F464); - else - SetMainCallback2(sub_807EB50); - gUnknown_02032298[0] = 255; - break; + case 0: + gMain.state = 4; + gSoftResetDisabled = TRUE; + break; + case 4: + gCB2_AfterEvolution = CB2_SaveAndEndTrade; + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); + if (evoTarget != SPECIES_NONE) + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + else if (IsWirelessTrade()) + SetMainCallback2(CB2_SaveAndEndWirelessTrade); + else + SetMainCallback2(CB2_SaveAndEndTrade); + gSelectedTradeMonPositions[TRADE_PLAYER] = 255; + break; } if (!HasLinkErrorOccurred()) RunTasks(); @@ -5703,29 +4501,26 @@ static void c2_08053788(void) UpdatePaletteFade(); } -static void sub_807E4DC(void) +static void UpdateTradeFinishFlags(void) { u8 blockReceivedStatus; - sub_807ACDC(); + TradeGetMultiplayerId(); // no effect call, ret val ignored blockReceivedStatus = GetBlockReceivedStatus(); if (blockReceivedStatus & 0x01) { - if (gBlockRecvBuffer[0][0] == 0xDCBA) - { - SetMainCallback2(c2_08053788); - } - if (gBlockRecvBuffer[0][0] == 0xABCD) - { - gUnknown_020322A0->unk_72 = 1; - } + if (gBlockRecvBuffer[0][0] == LINKCMD_CONFIRM_FINISH_TRADE) + SetMainCallback2(CB2_TryTradeEvolution); + + if (gBlockRecvBuffer[0][0] == LINKCMD_READY_FINISH_TRADE) + sTradeData->playerLinkFlagFinishTrade = READY_FINISH_TRADE; + ResetBlockReceivedFlag(0); } if (blockReceivedStatus & 0x02) { - if (gBlockRecvBuffer[1][0] == 0xABCD) - { - gUnknown_020322A0->unk_73 = 1; - } + if (gBlockRecvBuffer[1][0] == LINKCMD_READY_FINISH_TRADE) + sTradeData->partnerLinkFlagFinishTrade = READY_FINISH_TRADE; + ResetBlockReceivedFlag(1); } } @@ -5753,7 +4548,7 @@ static void sub_807E55C(struct Sprite *sprite) static void sub_807E5D8(struct Sprite *sprite) { - sprite->pos2.y += gTradeBallVerticalVelocityTable[sprite->data[0]]; + sprite->pos2.y += sTradeBallVerticalVelocityTable[sprite->data[0]]; if (sprite->data[0] == 22) PlaySE(SE_KON); if (++ sprite->data[0] == 44) @@ -5771,11 +4566,11 @@ static void sub_807E64C(struct Sprite *sprite) StartSpriteAffineAnim(sprite, 1); if (++ sprite->data[1] > 20) { - sprite->pos2.y -= gTradeBallVerticalVelocityTable[sprite->data[0]]; + sprite->pos2.y -= sTradeBallVerticalVelocityTable[sprite->data[0]]; if (++ sprite->data[0] == 23) { DestroySprite(sprite); - gUnknown_020322A0->state = 14; // Resume the master trade animation + sTradeData->state = 14; // Resume the master trade animation } } } @@ -5799,7 +4594,7 @@ static void sub_807E6AC(struct Sprite *sprite) PlaySE(SE_KON3); if (sprite->data[0] == 0x6b) PlaySE(SE_KON4); - sprite->pos2.y += gTradeBallVerticalVelocityTable[sprite->data[0]]; + sprite->pos2.y += sTradeBallVerticalVelocityTable[sprite->data[0]]; if (++sprite->data[0] == 0x6c) sprite->callback = SpriteCallbackDummy; } @@ -5807,16 +4602,16 @@ static void sub_807E6AC(struct Sprite *sprite) u16 GetInGameTradeSpeciesInfo(void) { - const struct InGameTrade *inGameTrade = &gIngameTrades[gSpecialVar_0x8004]; - StringCopy(gStringVar1, gSpeciesNames[inGameTrade->playerSpecies]); + const struct InGameTrade *inGameTrade = &sIngameTrades[gSpecialVar_0x8004]; + StringCopy(gStringVar1, gSpeciesNames[inGameTrade->requestedSpecies]); StringCopy(gStringVar2, gSpeciesNames[inGameTrade->species]); - return inGameTrade->playerSpecies; + return inGameTrade->requestedSpecies; } -static void sub_807E784(void) +static void BuffeInGameTradeMonName(void) { u8 nickname[32]; - const struct InGameTrade *inGameTrade = &gIngameTrades[gSpecialVar_0x8004]; + const struct InGameTrade *inGameTrade = &sIngameTrades[gSpecialVar_0x8004]; GetMonData(&gPlayerParty[gSpecialVar_0x8005], MON_DATA_NICKNAME, nickname); StringCopy10(gStringVar1, nickname); StringCopy(gStringVar2, gSpeciesNames[inGameTrade->species]); @@ -5824,11 +4619,11 @@ static void sub_807E784(void) static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) { - const struct InGameTrade *inGameTrade = &gIngameTrades[whichInGameTrade]; + const struct InGameTrade *inGameTrade = &sIngameTrades[whichInGameTrade]; u8 level = GetMonData(&gPlayerParty[whichPlayerMon], MON_DATA_LEVEL); struct MailStruct mail; - u8 metLocation = 0xFE; + u8 metLocation = METLOC_IN_GAME_TRADE; u8 isMail; struct Pokemon *pokemon = &gEnemyParty[0]; @@ -5840,15 +4635,15 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) SetMonData(pokemon, MON_DATA_SPEED_IV, &inGameTrade->ivs[3]); SetMonData(pokemon, MON_DATA_SPATK_IV, &inGameTrade->ivs[4]); SetMonData(pokemon, MON_DATA_SPDEF_IV, &inGameTrade->ivs[5]); - SetMonData(pokemon, MON_DATA_NICKNAME, inGameTrade->name); + SetMonData(pokemon, MON_DATA_NICKNAME, inGameTrade->nickname); SetMonData(pokemon, MON_DATA_OT_NAME, inGameTrade->otName); SetMonData(pokemon, MON_DATA_OT_GENDER, &inGameTrade->otGender); - SetMonData(pokemon, MON_DATA_ABILITY_NUM, &inGameTrade->secondAbility); - SetMonData(pokemon, MON_DATA_BEAUTY, &inGameTrade->stats[1]); - SetMonData(pokemon, MON_DATA_CUTE, &inGameTrade->stats[2]); - SetMonData(pokemon, MON_DATA_COOL, &inGameTrade->stats[0]); - SetMonData(pokemon, MON_DATA_SMART, &inGameTrade->stats[3]); - SetMonData(pokemon, MON_DATA_TOUGH, &inGameTrade->stats[4]); + SetMonData(pokemon, MON_DATA_ABILITY_NUM, &inGameTrade->abilityNum); + SetMonData(pokemon, MON_DATA_BEAUTY, &inGameTrade->conditions[1]); + SetMonData(pokemon, MON_DATA_CUTE, &inGameTrade->conditions[2]); + SetMonData(pokemon, MON_DATA_COOL, &inGameTrade->conditions[0]); + SetMonData(pokemon, MON_DATA_SMART, &inGameTrade->conditions[3]); + SetMonData(pokemon, MON_DATA_TOUGH, &inGameTrade->conditions[4]); SetMonData(pokemon, MON_DATA_SHEEN, &inGameTrade->sheen); SetMonData(pokemon, MON_DATA_MET_LOCATION, &metLocation); @@ -5857,8 +4652,8 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) { if (ItemIsMail(inGameTrade->heldItem)) { - sub_807E974(&mail, inGameTrade); - gUnknown_020321C0[0] = mail; + SetInGameTradeMail(&mail, inGameTrade); + gTradeMail[0] = mail; SetMonData(pokemon, MON_DATA_MAIL, &isMail); SetMonData(pokemon, MON_DATA_HELD_ITEM, &inGameTrade->heldItem); } @@ -5870,12 +4665,12 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) CalculateMonStats(&gEnemyParty[0]); } -static void sub_807E974(struct MailStruct *mail, const struct InGameTrade *trade) { +static void SetInGameTradeMail(struct MailStruct *mail, const struct InGameTrade *trade) { s32 i; - for (i = 0; i < 9; i++) + for (i = 0; i < MAIL_WORDS_COUNT; i++) { - mail->words[i] = gIngameTradeMail[trade->mailNum][i]; + mail->words[i] = sIngameTradeMail[trade->mailNum][i]; } StringCopy(mail->playerName, trade->otName); @@ -5901,22 +4696,22 @@ void CreateInGameTradePokemon(void) _CreateInGameTradePokemon(gSpecialVar_0x8005, gSpecialVar_0x8004); } -static void sub_807EA2C(void) +static void CB2_UpdateLinkTrade(void) { - if (sub_807BBC8() == TRUE) + if (AnimateTradeSequence() == TRUE) { - DestroySprite(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]]); - FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]]); - sub_807B4D0(gUnknown_02032298[0], gUnknown_02032298[1] % 6); - if (!sub_8077260()) + DestroySprite(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]]); + FreeSpriteOamMatrix(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]]); + TradeMons(gSelectedTradeMonPositions[TRADE_PLAYER], gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE); + if (!IsWirelessTrade()) { - gUnknown_020322A0->linkData[0] = 0xABCD; - gUnknown_020322A0->unk_93 = 1; + sTradeData->linkData[0] = LINKCMD_READY_FINISH_TRADE; + sTradeData->sendTradeFinishState = 1; } - SetMainCallback2(sub_807EACC); + SetMainCallback2(CB2_TryFinishTrade); } - sub_807B5B8(); - sub_807E4DC(); + TrySendTradeFinishData(); + UpdateTradeFinishFlags(); RunTasks(); RunTextPrinters(); AnimateSprites(); @@ -5924,22 +4719,24 @@ static void sub_807EA2C(void) UpdatePaletteFade(); } -static void sub_807EACC(void) +static void CB2_TryFinishTrade(void) { - u8 mpId = sub_807ACDC(); - if (sub_8077260()) + u8 mpId = TradeGetMultiplayerId(); + if (IsWirelessTrade()) { - SetMainCallback2(c2_08053788); + SetMainCallback2(CB2_TryTradeEvolution); } else { - sub_807E4DC(); - if (mpId == 0 && gUnknown_020322A0->unk_72 == 1 && gUnknown_020322A0->unk_73 == 1) + UpdateTradeFinishFlags(); + if (mpId == 0 + && sTradeData->playerLinkFlagFinishTrade == READY_FINISH_TRADE + && sTradeData->partnerLinkFlagFinishTrade == READY_FINISH_TRADE) { - gUnknown_020322A0->linkData[0] = 0xDCBA; - Trade_SendData(gUnknown_020322A0); - gUnknown_020322A0->unk_72 = 2; - gUnknown_020322A0->unk_73 = 2; + sTradeData->linkData[0] = LINKCMD_CONFIRM_FINISH_TRADE; + Trade_SendData(sTradeData); + sTradeData->playerLinkFlagFinishTrade = FINISH_TRADE; + sTradeData->partnerLinkFlagFinishTrade = FINISH_TRADE; } } RunTasks(); @@ -5948,159 +4745,159 @@ static void sub_807EACC(void) UpdatePaletteFade(); } -static void sub_807EB50(void) +static void CB2_SaveAndEndTrade(void) { switch (gMain.state) { - case 0: + case 0: + gMain.state++; + StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); + DrawTextOnTradeWindow(0, gStringVar4, 0); + break; + case 1: + sub_8077288(0); + gMain.state = 100; + sTradeData->timer = 0; + break; + case 100: + if (++sTradeData->timer > 180) + { + gMain.state = 101; + sTradeData->timer = 0; + } + if (_IsLinkTaskFinished()) + { + gMain.state = 2; + } + break; + case 101: + if (_IsLinkTaskFinished()) + { + gMain.state = 2; + } + break; + case 2: + gMain.state = 50; + StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); + DrawTextOnTradeWindow(0, gStringVar4, 0); + break; + case 50: + if (!InUnionRoom()) + IncrementGameStat(GAME_STAT_POKEMON_TRADES); + if (gWirelessCommType) + { + sub_801B990(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId); + } + SetContinueGameWarpStatusToDynamicWarp(); + sub_8153380(); + gMain.state++; + sTradeData->timer = 0; + break; + case 51: + if (++sTradeData->timer == 5) + { gMain.state++; - StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); - sub_807F1A8(0, gStringVar4, 0); - break; - case 1: - sub_8077288(0); - gMain.state = 100; - gUnknown_020322A0->timer = 0; - break; - case 100: - if (++gUnknown_020322A0->timer > 180) + } + break; + case 52: + if (sub_81533AC()) + { + ClearContinueGameWarpStatus2(); + gMain.state = 4; + } + else + { + sTradeData->timer = 0; + gMain.state = 51; + } + break; + case 4: + sub_81533E0(); + gMain.state = 40; + sTradeData->timer = 0; + break; + case 40: + if (++sTradeData->timer > 50) + { + if (GetMultiplayerId() == 0) { - gMain.state = 101; - gUnknown_020322A0->timer = 0; - } - if (_IsLinkTaskFinished()) - { - gMain.state = 2; - } - break; - case 101: - if (_IsLinkTaskFinished()) - { - gMain.state = 2; - } - break; - case 2: - gMain.state = 50; - StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); - sub_807F1A8(0, gStringVar4, 0); - break; - case 50: - if (!InUnionRoom()) - IncrementGameStat(GAME_STAT_POKEMON_TRADES); - if (gWirelessCommType) - { - sub_801B990(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId); - } - SetContinueGameWarpStatusToDynamicWarp(); - sub_8153380(); - gMain.state++; - gUnknown_020322A0->timer = 0; - break; - case 51: - if (++gUnknown_020322A0->timer == 5) - { - gMain.state++; - } - break; - case 52: - if (sub_81533AC()) - { - ClearContinueGameWarpStatus2(); - gMain.state = 4; + sTradeData->timer = Random() % 30; } else { - gUnknown_020322A0->timer = 0; - gMain.state = 51; + sTradeData->timer = 0; } - break; - case 4: - sub_81533E0(); - gMain.state = 40; - gUnknown_020322A0->timer = 0; - break; - case 40: - if (++gUnknown_020322A0->timer > 50) + gMain.state = 41; + } + break; + case 41: + if (sTradeData->timer == 0) + { + sub_8077288(1); + gMain.state = 42; + } + else + { + sTradeData->timer--; + } + break; + case 42: + if (_IsLinkTaskFinished()) + { + sub_8153408(); + gMain.state = 5; + } + break; + case 5: + if (++sTradeData->timer > 60) + { + gMain.state++; + sub_8077288(2); + } + break; + case 6: + if (_IsLinkTaskFinished()) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gMain.state ++; + } + break; + case 7: + if (!gPaletteFade.active) + { + FadeOutBGM(3); + gMain.state++; + } + break; + case 8: + if (IsBGMStopped() == TRUE) + { + if (gWirelessCommType && gMain.savedCallback == CB2_StartCreateTradeMenu) { - if (GetMultiplayerId() == 0) - { - gUnknown_020322A0->timer = Random() % 30; - } - else - { - gUnknown_020322A0->timer = 0; - } - gMain.state = 41; - } - break; - case 41: - if (gUnknown_020322A0->timer == 0) - { - sub_8077288(1); - gMain.state = 42; + sub_8077288(3); } else { - gUnknown_020322A0->timer--; + sub_800AC34(); } - break; - case 42: + gMain.state++; + } + break; + case 9: + if (gWirelessCommType && gMain.savedCallback == CB2_StartCreateTradeMenu) + { if (_IsLinkTaskFinished()) - { - sub_8153408(); - gMain.state = 5; - } - break; - case 5: - if (++gUnknown_020322A0->timer > 60) - { - gMain.state++; - sub_8077288(2); - } - break; - case 6: - if (_IsLinkTaskFinished()) - { - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gMain.state ++; - } - break; - case 7: - if (!gPaletteFade.active) - { - FadeOutBGM(3); - gMain.state++; - } - break; - case 8: - if (IsBGMStopped() == TRUE) - { - if (gWirelessCommType && gMain.savedCallback == sub_80773AC) - { - sub_8077288(3); - } - else - { - sub_800AC34(); - } - gMain.state++; - } - break; - case 9: - if (gWirelessCommType && gMain.savedCallback == sub_80773AC) - { - if (_IsLinkTaskFinished()) - { - gSoftResetDisabled = FALSE; - SetMainCallback2(c2_080543C4); - } - } - else if (!gReceivedRemoteLinkPlayers) { gSoftResetDisabled = FALSE; - SetMainCallback2(c2_080543C4); + SetMainCallback2(CB2_FreeTradeData); } - break; + } + else if (!gReceivedRemoteLinkPlayers) + { + gSoftResetDisabled = FALSE; + SetMainCallback2(CB2_FreeTradeData); + } + break; } if (!HasLinkErrorOccurred()) { @@ -6111,7 +4908,7 @@ static void sub_807EB50(void) UpdatePaletteFade(); } -static void c2_080543C4(void) +static void CB2_FreeTradeData(void) { if (!gPaletteFade.active) { @@ -6120,7 +4917,7 @@ static void c2_080543C4(void) Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(gUnknown_020322A0); + FREE_AND_SET_NULL(sTradeData); if (gWirelessCommType) DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(gMain.savedCallback); @@ -6134,95 +4931,103 @@ static void c2_080543C4(void) void DoInGameTradeScene(void) { ScriptContext2_Enable(); - CreateTask(sub_807F110, 10); + CreateTask(Task_InGameTrade, 10); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); } -static void sub_807F110(u8 taskId) +static void Task_InGameTrade(u8 taskId) { if (!gPaletteFade.active) { - SetMainCallback2(sub_807B270); + SetMainCallback2(CB2_InGameTrade); gFieldCallback = FieldCallback_ReturnToEventScript2; DestroyTask(taskId); } } -static void sub_807F14C(void) +static void CheckPartnersMonForRibbons(void) { u8 i; u8 numRibbons = 0; for (i = 0; i < 12; i ++) { - numRibbons += GetMonData(&gEnemyParty[gUnknown_02032298[1] % 6], MON_DATA_CHAMPION_RIBBON + i); + numRibbons += GetMonData(&gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE], MON_DATA_CHAMPION_RIBBON + i); } if (numRibbons != 0) FlagSet(FLAG_SYS_RIBBON_GET); } -void sub_807F19C(void) +void InitTradeBg(void) { - sub_807B170(); + InitTradeBgInternal(); } -void sub_807F1A8(u8 windowId, const u8 *str, u8 speed) +void DrawTextOnTradeWindow(u8 windowId, const u8 *str, u8 speed) { FillWindowPixelBuffer(windowId, PIXEL_FILL(15)); - gUnknown_020322A0->unk_F6[0] = 15; - gUnknown_020322A0->unk_F6[1] = 1; - gUnknown_020322A0->unk_F6[2] = 6; - AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, gUnknown_020322A0->unk_F6, speed, str); + sTradeData->textColors[0] = TEXT_DYNAMIC_COLOR_6; + sTradeData->textColors[1] = TEXT_COLOR_WHITE; + sTradeData->textColors[2] = TEXT_COLOR_GREEN; + AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, sTradeData->textColors, speed, str); CopyWindowToVram(windowId, 3); } -static void c3_08054588(u8 taskId) +#define idx data[0] +#define counter data[1] +#define signalComingBack data[2] + +static void Task_AnimateWirelessSignal(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 unk = gUnknown_08339090[data[0]][0] * 16; + u16 paletteIdx = sWirelessSignalTiming[idx][0] * 16; - if (!data[2]) + if (!signalComingBack) { - if (unk == 0x100) - LoadPalette(gUnknown_08337EA0, 0x30, 32); + if (paletteIdx == 256) + LoadPalette(sTradePal_Black, 0x30, 32); else - LoadPalette(&gUnknown_08337AA0[unk], 0x30, 32); + LoadPalette(&sTradePal_WirelessSignalSend[paletteIdx], 0x30, 32); } else { - if (unk == 0x100) - LoadPalette(gUnknown_08337EA0, 0x30, 32); + if (paletteIdx == 256) + LoadPalette(sTradePal_Black, 0x30, 32); else - LoadPalette(&gUnknown_08337CA0[unk], 0x30, 32); + LoadPalette(&sTradePal_WirelessSignalReceive[paletteIdx], 0x30, 32); } - if (gUnknown_08339090[data[0]][0] == 0 && data[1] == 0) + if (sWirelessSignalTiming[idx][0] == 0 && counter == 0) PlaySE(SE_W215); - if (data[1] == gUnknown_08339090[data[0]][1]) + if (counter == sWirelessSignalTiming[idx][1]) { - data[0]++; - data[1] = 0; - if (gUnknown_08339090[data[0]][1] == 0xFF) + idx++; + counter = 0; + if (sWirelessSignalTiming[idx][1] == 0xFF) { DestroyTask(taskId); } } else { - data[1]++; + counter++; } } +#undef idx +#undef counter +#undef signalComingBack + static void c3_0805465C(u8 taskId) { s16 *data = gTasks[taskId].data; if (data[0] == 0) { - gUnknown_020322A0->unk_FB = gUnknown_020322A0->unk_FD = 120; - gUnknown_020322A0->unk_FC = 0; - gUnknown_020322A0->unk_FE = 160; + sTradeData->wirelessWinLeft = sTradeData->wirelessWinRight = 120; + sTradeData->wirelessWinTop = 0; + sTradeData->wirelessWinBottom = 160; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | @@ -6230,14 +5035,14 @@ static void c3_0805465C(u8 taskId) WININ_WIN0_OBJ); } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(gUnknown_020322A0->unk_FB, gUnknown_020322A0->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(gUnknown_020322A0->unk_FC, gUnknown_020322A0->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->wirelessWinLeft, sTradeData->wirelessWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->wirelessWinTop, sTradeData->wirelessWinBottom)); data[0]++; - gUnknown_020322A0->unk_FB -= 5; - gUnknown_020322A0->unk_FD += 5; + sTradeData->wirelessWinLeft -= 5; + sTradeData->wirelessWinRight += 5; - if (gUnknown_020322A0->unk_FB < 80) + if (sTradeData->wirelessWinLeft < 80) { DestroyTask(taskId); } @@ -6249,24 +5054,24 @@ static void sub_807F39C(u8 taskId) if (data[0] == 0) { - gUnknown_020322A0->unk_FB = 80; - gUnknown_020322A0->unk_FD = 160; + sTradeData->wirelessWinLeft = 80; + sTradeData->wirelessWinRight = 160; SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | WININ_WIN0_BG1 | WININ_WIN0_OBJ); } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(gUnknown_020322A0->unk_FB, gUnknown_020322A0->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(gUnknown_020322A0->unk_FC, gUnknown_020322A0->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->wirelessWinLeft, sTradeData->wirelessWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->wirelessWinTop, sTradeData->wirelessWinBottom)); - if (gUnknown_020322A0->unk_FB != 120) + if (sTradeData->wirelessWinLeft != 120) { data[0]++; - gUnknown_020322A0->unk_FB += 5; - gUnknown_020322A0->unk_FD -= 5; + sTradeData->wirelessWinLeft += 5; + sTradeData->wirelessWinRight -= 5; - if (gUnknown_020322A0->unk_FB >= 116) + if (sTradeData->wirelessWinLeft >= 116) BlendPalettes(0x8, 0, RGB_WHITEALPHA); } else @@ -6276,114 +5081,108 @@ static void sub_807F39C(u8 taskId) } } -static void sub_807F464(void) +static void CB2_SaveAndEndWirelessTrade(void) { switch (gMain.state) { - case 0: - gMain.state = 1; - StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); - sub_807F1A8(0, gStringVar4, 0); - break; - case 1: - sub_8077288(0); - gMain.state = 2; - gUnknown_020322A0->timer = 0; - break; - case 2: - if (_IsLinkTaskFinished()) - { - gMain.state = 3; - StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); - sub_807F1A8(0, gStringVar4, 0); - IncrementGameStat(GAME_STAT_POKEMON_TRADES); - sub_8153380(); - gUnknown_020322A0->timer = 0; - } - break; - case 3: - if (++gUnknown_020322A0->timer == 5) - { - gMain.state = 4; - } - break; - case 4: - if (sub_81533AC()) - { - gMain.state = 5; - } + case 0: + gMain.state = 1; + StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); + DrawTextOnTradeWindow(0, gStringVar4, 0); + break; + case 1: + sub_8077288(0); + gMain.state = 2; + sTradeData->timer = 0; + break; + case 2: + if (_IsLinkTaskFinished()) + { + gMain.state = 3; + StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); + DrawTextOnTradeWindow(0, gStringVar4, 0); + IncrementGameStat(GAME_STAT_POKEMON_TRADES); + sub_8153380(); + sTradeData->timer = 0; + } + break; + case 3: + if (++sTradeData->timer == 5) + gMain.state = 4; + break; + case 4: + if (sub_81533AC()) + { + gMain.state = 5; + } + else + { + sTradeData->timer = 0; + gMain.state = 3; + } + break; + case 5: + sub_81533E0(); + gMain.state = 6; + sTradeData->timer = 0; + break; + case 6: + if (++sTradeData->timer > 10) + { + if (GetMultiplayerId() == 0) + sTradeData->timer = Random() % 30; else - { - gUnknown_020322A0->timer = 0; - gMain.state = 3; - } - break; - case 5: - sub_81533E0(); - gMain.state = 6; - gUnknown_020322A0->timer = 0; - break; - case 6: - if (++gUnknown_020322A0->timer > 10) - { - if (GetMultiplayerId() == 0) - { - gUnknown_020322A0->timer = Random() % 30; - } - else - { - gUnknown_020322A0->timer = 0; - } - gMain.state = 7; - } - break; - case 7: - if (gUnknown_020322A0->timer == 0) - { - sub_8077288(1); - gMain.state = 8; - } - else - { - gUnknown_020322A0->timer--; - } - break; - case 8: - if (_IsLinkTaskFinished()) - { - sub_8153408(); - gMain.state = 9; - } - break; - case 9: - if (++gUnknown_020322A0->timer > 60) - { - gMain.state++; - sub_8077288(2); - } - break; - case 10: - if (_IsLinkTaskFinished()) - { - FadeOutBGM(3); - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gMain.state = 11; - } - break; - case 11: - if (!gPaletteFade.active && IsBGMStopped() == TRUE) - { - sub_8077288(3); - gMain.state = 12; - } - break; - case 12: - if (_IsLinkTaskFinished()) - { - gSoftResetDisabled = FALSE; - SetMainCallback2(c2_080543C4); - } - break; + sTradeData->timer = 0; + gMain.state = 7; + } + break; + case 7: + if (sTradeData->timer == 0) + { + sub_8077288(1); + gMain.state = 8; + } + else + { + sTradeData->timer--; + } + break; + case 8: + if (_IsLinkTaskFinished()) + { + sub_8153408(); + gMain.state = 9; + } + break; + case 9: + if (++sTradeData->timer > 60) + { + gMain.state++; + sub_8077288(2); + } + break; + case 10: + if (_IsLinkTaskFinished()) + { + FadeOutBGM(3); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + gMain.state = 11; + } + break; + case 11: + if (!gPaletteFade.active && IsBGMStopped() == TRUE) + { + sub_8077288(3); + gMain.state = 12; + } + break; + case 12: + if (_IsLinkTaskFinished()) + { + gSoftResetDisabled = FALSE; + SetMainCallback2(CB2_FreeTradeData); + } + break; } if (!HasLinkErrorOccurred()) diff --git a/src/union_room.c b/src/union_room.c index af2a552f3..f259a38f0 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -57,9 +57,9 @@ EWRAM_DATA u8 gUnknown_02022C2D = 0; EWRAM_DATA union UnkUnion_Main gUnknown_02022C30 = {}; EWRAM_DATA u32 gFiller_02022C34 = 0; EWRAM_DATA struct UnkLinkRfuStruct_02022B14Substruct gUnknown_02022C38 = {}; -EWRAM_DATA u16 gUnknown_02022C3C = 0; -EWRAM_DATA u8 gUnknown_02022C3E = 0; -EWRAM_DATA struct TradeUnkStruct gUnknown_02022C40 = {}; +EWRAM_DATA u16 gUnionRoomOfferedSpecies = 0; +EWRAM_DATA u8 gUnionRoomRequestedMonType = 0; +static EWRAM_DATA struct UnionRoomTrade sUnionRoomTrade = {}; // IWRAM vars static struct UnkStruct_Leader *gUnknown_03000DA0; @@ -97,8 +97,8 @@ void sub_8013BD8(struct UnkStruct_Group *arg0, s32 id); void sub_80173D4(void); void sub_80177B8(u8 arg0, u8 arg1, u8 arg2, struct UnkStruct_x20 *arg3, u8 arg4, u8 id); bool32 sub_8017678(struct UnkStruct_Shared *arg0, struct UnkStruct_Shared *arg1); -u32 sub_8018120(struct TradeUnkStruct *arg0, u8 multiplayerId); -void sub_801807C(struct TradeUnkStruct *arg0); +static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *arg0, u8 multiplayerId); +static void ResetUnionRoomTrade(struct UnionRoomTrade *arg0); void sub_801AC54(void); void sub_80149D8(void); void MG_DrawTextBorder(u8 windowId); @@ -106,8 +106,8 @@ s8 mevent_message_print_and_prompt_yes_no(u8 *textState, u8 *arg1, u8 arg2, cons bool32 sub_8016F1C(struct UnkLinkRfuStruct_02022B14 *arg0, s16 arg1); u8 sub_8016DF0(struct UnkStruct_Main4 *arg0, struct UnkStruct_Main4 *arg1, u32 arg2); void sub_8019F2C(void); -bool32 sub_80180A0(u32 monId, struct TradeUnkStruct *arg1); -void sub_80180E8(u32 monId, struct TradeUnkStruct *arg1); +static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trade); +static void RegisterTradeMon(u32 monId, struct UnionRoomTrade *arg1); void sub_80181CC(void); bool32 sub_8017940(void); u8 sub_8016B00(void); @@ -123,7 +123,7 @@ void sub_801818C(bool32 arg0); s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate); s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6); s32 sub_8017CB0(struct UnkStruct_x20 * arg, s32 arg1); -bool32 sub_8018024(void); +bool32 HasAtLeastTwoMonsOfLevel30OrLower(void); u32 sub_8017984(s32 arg0); void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2); void sub_8017D9C(u8 *dst, s32 arg1, u32 playerGender); @@ -141,1045 +141,7 @@ void sub_8013DF4(u8 windowId, s32 itemId, u8 y); void sub_8017BE8(u8 windowId, s32 itemId, u8 y); void nullsub_14(u8 windowId, s32 itemId, u8 y); -// const rom data - -ALIGNED(4) const u8 gText_EmptyString[] = _(""); -ALIGNED(4) const u8 gText_Colon[] = _(":"); -ALIGNED(4) const u8 gText_UnkCtrlCodeF907[] = _("{ID}"); -ALIGNED(4) const u8 gText_PleaseStartOver[] = _("Please start over from the beginning."); -ALIGNED(4) const u8 gText_WirelessSearchCanceled[] = _("The WIRELESS COMMUNICATION\nSYSTEM search has been canceled."); -ALIGNED(4) const u8 unref_text_union_room_0[] = _("Awaiting communication\nfrom another player."); -ALIGNED(4) const u8 gText_AwaitingCommunication[] = _("{STR_VAR_1}! Awaiting\ncommunication from another player."); -ALIGNED(4) const u8 gText_AwaitingLink[] = _("{STR_VAR_1}! Awaiting link!\nPress START when everyone's ready."); -ALIGNED(4) const u8 gJPText_SingleBattle[] = _("シングルバトルを かいさいする"); -ALIGNED(4) const u8 gJPText_DoubleBattle[] = _("ダブルバトルを かいさいする"); -ALIGNED(4) const u8 gJPText_MultiBattle[] = _("マルチバトルを かいさいする"); -ALIGNED(4) const u8 gJPText_TradePokemon[] = _("ポケモンこうかんを かいさいする"); -ALIGNED(4) const u8 gJPText_Chat[] = _("チャットを かいさいする"); -ALIGNED(4) const u8 gJPText_DistWonderCard[] = _("ふしぎなカードをくばる"); -ALIGNED(4) const u8 gJPText_DistWonderNews[] = _("ふしぎなニュースをくばる"); -ALIGNED(4) const u8 unref_text_union_room_1[] = _("ふしぎなできごとを かいさいする"); -ALIGNED(4) const u8 gJPText_HoldPokemonJump[] = _("なわとびを かいさいする"); -ALIGNED(4) const u8 gJPText_HoldBerryCrush[] = _("きのみマッシャーを かいさいする"); -ALIGNED(4) const u8 gJPText_HoldBerryPicking[] = _("きのみどりを かいさいする"); -ALIGNED(4) const u8 gJPText_HoldSpinTrade[] = _("ぐるぐるこうかんを かいさいする"); -ALIGNED(4) const u8 gJPText_HoldSpinShop[] = _("ぐるぐるショップを かいさいする"); - -const u8 *const unref_text_ptrs_union_room_0[] = { - gJPText_SingleBattle, - gJPText_DoubleBattle, - gJPText_MultiBattle, - gJPText_TradePokemon, - gJPText_Chat, - gJPText_DistWonderCard, - gJPText_DistWonderNews, - gJPText_DistWonderCard, - gJPText_HoldPokemonJump, - gJPText_HoldBerryCrush, - gJPText_HoldBerryPicking, - gJPText_HoldBerryPicking, - gJPText_HoldSpinTrade, - gJPText_HoldSpinShop -}; - -const u8 gText_1PlayerNeeded[] = _("1 player\nneeded."); -const u8 gText_2PlayersNeeded[] = _("2 players\nneeded."); -const u8 gText_3PlayersNeeded[] = _("3 players\nneeded."); -const u8 gText_4PlayersNeeded[] = _("4 players\nneeded."); -const u8 gText_2PlayerMode[] = _("2-PLAYER\nMODE"); -const u8 gText_3PlayerMode[] = _("3-PLAYER\nMODE"); -const u8 gText_4PlayerMode[] = _("4-PLAYER\nMODE"); -const u8 gText_5PlayerMode[] = _("5-PLAYER\nMODE"); - -const u8 *const gUnknown_082EDB60[][5] = { - { - gText_1PlayerNeeded, - gText_2PlayerMode, - NULL, - NULL, - NULL - }, { - gText_3PlayersNeeded, - gText_2PlayersNeeded, - gText_1PlayerNeeded, - gText_4PlayerMode, - NULL - }, { - gText_1PlayerNeeded, - gText_2PlayerMode, - gText_3PlayerMode, - gText_4PlayerMode, - gText_5PlayerMode - }, { - gText_2PlayersNeeded, - gText_1PlayerNeeded, - gText_3PlayerMode, - gText_4PlayerMode, - gText_5PlayerMode - }, { - gText_1PlayerNeeded, - gText_2PlayerMode, - gText_3PlayerMode, - gText_4PlayerMode, - NULL - } -}; - -ALIGNED(4) const u8 gUnknown_082EDBC4[] = _("{B_BUTTON}CANCEL"); -ALIGNED(4) const u8 unref_text_union_room_2[] = _("ため\nさんかしゃ ぼしゅうちゅう です!"); -ALIGNED(4) const u8 gUnknown_082EDBE8[] = _("{STR_VAR_2} contacted you for\n{STR_VAR_1}. Accept?"); -ALIGNED(4) const u8 gUnknown_082EDC0C[] = _("{STR_VAR_2} contacted you.\nWill you share {STR_VAR_1}?"); -ALIGNED(4) const u8 gUnknown_082EDC34[] = _("{STR_VAR_2} contacted you.\nAdd to the members?"); -ALIGNED(4) const u8 gUnknown_082EDC5C[] = _("{STR_VAR_1}!\nAre these members OK?"); -ALIGNED(4) const u8 gUnknown_082EDC78[] = _("Cancel {STR_VAR_1} MODE\nwith these members?"); -ALIGNED(4) const u8 gUnknown_082EDC9C[] = _("An “OK” was sent\nto {STR_VAR_1}."); -ALIGNED(4) const u8 gUnknown_082EDCB4[] = _("The other TRAINER doesn't appear\nto be available now…\p"); -ALIGNED(4) const u8 gUnknown_082EDCEC[] = _("You can't transmit with a TRAINER\nwho is too far away.\p"); -ALIGNED(4) const u8 gUnknown_082EDD24[] = _("The other TRAINER(S) is/are not\nready yet.\p"); - -const u8 *const gUnknown_082EDD50[] = { - gUnknown_082EDCEC, - gUnknown_082EDD24 -}; - -ALIGNED(4) const u8 gUnknown_082EDD58[] = _("The {STR_VAR_1} MODE with\nthese members will be canceled.{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EDD8C[] = _("There is a member who can no\nlonger remain available.\p"); - -const u8 *const gUnknown_082EDDC4[] = { - gUnknown_082EDCB4, - gUnknown_082EDD8C -}; - -ALIGNED(4) const u8 gUnknown_082EDDCC[] = _("The other TRAINER appears\nunavailable…\p"); -ALIGNED(4) const u8 gUnknown_082EDDF4[] = _("{STR_VAR_1} sent back an “OK”!"); -ALIGNED(4) const u8 gUnknown_082EDE0C[] = _("{STR_VAR_1} OK'd your registration as\na member."); -ALIGNED(4) const u8 gUnknown_082EDE34[] = _("{STR_VAR_1} replied, “No…”\p"); -ALIGNED(4) const u8 gUnknown_082EDE48[] = _("{STR_VAR_1}!\nAwaiting other members!"); -ALIGNED(4) const u8 gUnknown_082EDE64[] = _("Quit being a member?"); -ALIGNED(4) const u8 gUnknown_082EDE7C[] = _("You stopped being a member.\p"); - -const u8 *const gUnknown_082EDE9C[] = { - NULL, - gUnknown_082EDD8C, - gUnknown_082EDDCC, - NULL, - NULL, - NULL, - gUnknown_082EDE34, - NULL, - NULL, - gUnknown_082EDE7C -}; - -ALIGNED(4) const u8 gUnknown_082EDEC4[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been established."); -ALIGNED(4) const u8 gUnknown_082EDF04[] = _("The WIRELESS COMMUNICATION\nSYSTEM link has been dropped…"); -ALIGNED(4) const u8 gUnknown_082EDF40[] = _("The link with your friend has been\ndropped…"); -ALIGNED(4) const u8 gUnknown_082EDF6C[] = _("{STR_VAR_1} replied, “No…”"); - -const u8 *const gUnknown_082EDF80[] = { - NULL, - gUnknown_082EDF40, - gUnknown_082EDF40, - NULL, - NULL, - NULL, - gUnknown_082EDF6C, - NULL, - NULL, - NULL -}; - -ALIGNED(4) const u8 gUnknown_082EDFA8[] = _("Do you want the {STR_VAR_2}\nMODE?"); -ALIGNED(4) const u8 gUnknown_082EDFC4[] = _("Do you want the {STR_VAR_2}\nMODE?"); - -const u8 *const unref_text_ptrs_union_room_1[] = { - gUnknown_082EDFA8, - gUnknown_082EDFC4 -}; - -ALIGNED(4) const u8 unref_text_union_room_3[] = _("Communicating…\nPlease wait."); -ALIGNED(4) const u8 gUnknown_082EE004[] = _("Awaiting {STR_VAR_1}'s response about\nthe trade…"); -ALIGNED(4) const u8 gUnknown_082EE02C[] = _("Communicating{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); -ALIGNED(4) const u8 gUnknown_082EE098[] = _("Communicating with {STR_VAR_1}{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); -ALIGNED(4) const u8 gUnknown_082EE104[] = _("Please wait a while{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.\n{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}.{PAUSE 15}."); - -const u8 *const gUnknown_082EE17C[] = { - gUnknown_082EE02C, - gUnknown_082EE098, - gUnknown_082EE104 -}; - -ALIGNED(4) const u8 gUnknown_082EE188[] = _("Hiya! Is there something that you\nwanted to do?"); -ALIGNED(4) const u8 gUnknown_082EE1B8[] = _("Hello!\nWould you like to do something?"); -ALIGNED(4) const u8 gUnknown_082EE1E0[] = _("{STR_VAR_1}: Hiya, we meet again!\nWhat are you up for this time?"); -ALIGNED(4) const u8 gUnknown_082EE218[] = _("{STR_VAR_1}: Oh! {PLAYER}, hello!\nWould you like to do something?"); - -const u8 *const gUnknown_082EE24C[][2] = { - { - gUnknown_082EE188, - gUnknown_082EE1B8 - }, { - gUnknown_082EE1E0, - gUnknown_082EE218 - } -}; - -ALIGNED(4) const u8 gUnknown_082EE25C[] = _("Want to do something?"); -ALIGNED(4) const u8 gUnknown_082EE274[] = _("Would you like to do something?"); -ALIGNED(4) const u8 gUnknown_082EE294[] = _("{STR_VAR_1}: What would you like to\ndo now?"); -ALIGNED(4) const u8 unref_text_union_room_4[] = _("{STR_VAR_1}: Want to do anything else?"); - -const u8 *const unref_text_ptrs_union_room_2[][2] = { - { - gUnknown_082EE25C, - gUnknown_082EE274 - }, { - gUnknown_082EE294, - gUnknown_082EE294 - } -}; - -ALIGNED(4) const u8 gUnknown_082EE2E8[] = _("Somebody has contacted you.{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE308[] = _("{STR_VAR_1} has contacted you.{PAUSE 60}"); - -const u8 *const gUnknown_082EE324[] = { - gUnknown_082EE2E8, - gUnknown_082EE308 -}; - -ALIGNED(4) const u8 gUnknown_082EE32C[] = _("Awaiting a response from\nthe other TRAINER…"); -ALIGNED(4) const u8 gUnknown_082EE358[] = _("Awaiting a response from\n{STR_VAR_1}…"); - -const u8 *const gUnknown_082EE378[] = { - gUnknown_082EE32C, - gUnknown_082EE358 -}; - -ALIGNED(4) const u8 gUnknown_082EE380[] = _("The other TRAINER showed\nyou their TRAINER CARD.\pWould you like to show your\nTRAINER CARD?"); -ALIGNED(4) const u8 gUnknown_082EE3DC[] = _("The other TRAINER challenges you\nto battle.\pWill you accept the battle\nchallenge?"); -ALIGNED(4) const u8 gUnknown_082EE430[] = _("The other TRAINER invites you\nto chat.\pWill you accept the chat\ninvitation?"); -ALIGNED(4) const u8 gUnknown_082EE47C[] = _("There is an offer to trade your\nregistered Lv. {SPECIAL_F7 0x00} {SPECIAL_F7 0x01}\pin exchange for a\nLv. {SPECIAL_F7 0x02} {SPECIAL_F7 0x03}.\pWill you accept this trade\noffer?"); -ALIGNED(4) const u8 gUnknown_082EE4F0[] = _("There is an offer to trade your\nregistered EGG.\lWill you accept this trade offer?"); -ALIGNED(4) const u8 gUnknown_082EE544[] = _("The chat has been dropped.\p"); -ALIGNED(4) const u8 gUnknown_082EE560[] = _("You declined the offer.\p"); -ALIGNED(4) const u8 gUnknown_082EE57C[] = _("You declined the offer.\p"); -ALIGNED(4) const u8 gUnknown_082EE598[] = _("The chat was ended.\p"); - -const u8 *const unref_text_ptrs_union_room_3[] = { - gUnknown_082EE380, - gUnknown_082EE3DC, - gUnknown_082EE430, - gUnknown_082EE47C -}; - -ALIGNED(4) const u8 gUnknown_082EE5C0[] = _("Oh, hey! We're in a chat right now.\nWant to join us?"); -ALIGNED(4) const u8 gUnknown_082EE5F8[] = _("{STR_VAR_1}: Hey, {PLAYER}!\nWe're having a chat right now.\lWant to join us?"); -ALIGNED(4) const u8 gUnknown_082EE638[] = _("Oh, hi! We're having a chat now.\nWould you like to join us?"); -ALIGNED(4) const u8 gUnknown_082EE674[] = _("{STR_VAR_1}: Oh, hi, {PLAYER}!\nWe're having a chat now.\lWould you like to join us?"); - -const u8 *const gUnknown_082EE6B8[][2] = { - { - gUnknown_082EE5C0, - gUnknown_082EE638 - }, { - gUnknown_082EE5F8, - gUnknown_082EE674 - } -}; - -ALIGNED(4) const u8 gUnknown_082EE6C8[] = _("……\nThe TRAINER appears to be busy…\p"); -ALIGNED(4) const u8 gUnknown_082EE6EC[] = _("A battle, huh?\nAll right, just give me some time."); -ALIGNED(4) const u8 gUnknown_082EE720[] = _("You want to chat, huh?\nSure, just wait a little."); -ALIGNED(4) const u8 gUnknown_082EE754[] = _("Sure thing! As my “Greetings,”\nhere's my TRAINER CARD."); -ALIGNED(4) const u8 gUnknown_082EE78C[] = _("A battle? Of course, but I need\ntime to get ready."); -ALIGNED(4) const u8 gUnknown_082EE7C0[] = _("Did you want to chat?\nOkay, but please wait a moment."); -ALIGNED(4) const u8 gUnknown_082EE7F8[] = _("As my introduction, I'll show you\nmy TRAINER CARD."); - -const u8 *const gUnknown_082EE82C[][4] = { - { - gUnknown_082EE6EC, - gUnknown_082EE720, - NULL, - gUnknown_082EE754 - }, { - gUnknown_082EE78C, - gUnknown_082EE7C0, - NULL, - gUnknown_082EE7F8 - } -}; - -ALIGNED(4) const u8 unref_text_union_room_5[] = _("You want to chat, huh?\nSure, just wait a little."); -ALIGNED(4) const u8 gUnknown_082EE880[] = _("Thanks for waiting!\nLet's get our battle started!{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE8B8[] = _("All right!\nLet's chat!{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE8D4[] = _("Sorry I made you wait!\nLet's get started!{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE904[] = _("Sorry I made you wait!\nLet's chat.{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE92C[] = _("The trade will be started.{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE94C[] = _("The battle will be started.{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EE96C[] = _("Entering the chat…{PAUSE 60}"); - -const u8 *const gUnknown_082EE984[][2][3] = { - { - { - gUnknown_082EE94C, - gUnknown_082EE96C, - gUnknown_082EE92C - }, { - gUnknown_082EE94C, - gUnknown_082EE96C, - gUnknown_082EE92C - } - }, { - { - gUnknown_082EE880, - gUnknown_082EE8B8, - gUnknown_082EE92C - }, { - gUnknown_082EE8D4, - gUnknown_082EE904, - gUnknown_082EE92C - } - } -}; - -ALIGNED(4) const u8 gUnknown_082EE9B4[] = _("Sorry! My POKéMON don't seem to\nbe feeling too well right now.\lLet me battle you another time.\p"); -ALIGNED(4) const u8 gUnknown_082EEA14[] = _("I'm terribly sorry, but my POKéMON\naren't feeling well…\pLet's battle another time.\p"); - -const u8 *const gUnknown_082EEA68[] = { - gUnknown_082EE9B4, - gUnknown_082EEA14 -}; - -ALIGNED(4) const u8 gUnknown_082EEA70[] = _("Huh? My TRAINER CARD…\nWhere'd it go now?\lSorry! I'll show you another time!\p"); -ALIGNED(4) const u8 gUnknown_082EEAC0[] = _("Oh? Now where did I put my\nTRAINER CARD?…\lSorry! I'll show you later!\p"); - -const u8 *const gUnknown_082EEB08[] = { - gUnknown_082EEA70, - gUnknown_082EEAC0 -}; - -ALIGNED(4) const u8 gUnknown_082EEB10[] = _("If you want to do something with\nme, just give me a shout!\p"); -ALIGNED(4) const u8 gUnknown_082EEB4C[] = _("If you want to do something with\nme, don't be shy.\p"); - -const u8 *const gUnknown_082EEB80[] = { - gUnknown_082EEB10, - gUnknown_082EEB4C -}; - -ALIGNED(4) const u8 gUnknown_082EEB88[] = _("Whoops! Sorry, but I have to do\nsomething else.\lAnother time, okay?\p"); -ALIGNED(4) const u8 gUnknown_082EEBD0[] = _("If you want to battle, you need\ntwo POKéMON that are below\lLv. 30.\p"); -ALIGNED(4) const u8 gUnknown_082EEC14[] = _("For a battle, you need two\nPOKéMON that are below Lv. 30.\p"); -ALIGNED(4) const u8 gUnknown_082EEC50[] = _("Oh, all right.\nCome see me anytime, okay?\p"); -ALIGNED(4) const u8 gUnknown_082EEC7C[] = _("Oh…\nPlease come by anytime.\p"); - -const u8 *const gUnknown_082EEC9C[] = { - gUnknown_082EEC50, - gUnknown_082EEC7C -}; - -ALIGNED(4) const u8 gUnknown_082EECA4[] = _("Oh, sorry!\nI just can't right this instant.\lLet's chat another time.\p"); -ALIGNED(4) const u8 gUnknown_082EECEC[] = _("Oh, I'm sorry.\nI have too much to do right now.\lLet's chat some other time.\p"); - -const u8 *const gUnknown_082EED3C[] = { - gUnknown_082EECA4, - gUnknown_082EECEC -}; - -ALIGNED(4) const u8 gUnknown_082EED44[] = _("Whoa!\nI can tell you're pretty tough!\p"); -ALIGNED(4) const u8 gUnknown_082EED6C[] = _("You used that move?\nThat's good strategy!\p"); -ALIGNED(4) const u8 gUnknown_082EED98[] = _("Way to go!\nThat was an eye-opener!\p"); -ALIGNED(4) const u8 gUnknown_082EEDBC[] = _("Oh! How could you use that\nPOKéMON in that situation?\p"); -ALIGNED(4) const u8 gUnknown_082EEDF4[] = _("That POKéMON…\nIt's been raised really well!\p"); -ALIGNED(4) const u8 gUnknown_082EEE24[] = _("That's it!\nThis is the right move now!\p"); -ALIGNED(4) const u8 gUnknown_082EEE4C[] = _("That's awesome!\nYou can battle that way?\p"); -ALIGNED(4) const u8 gUnknown_082EEE78[] = _("You have exquisite timing for\nswitching POKéMON!\p"); - -const u8 *const gUnknown_082EEEAC[][4] = { - { - gUnknown_082EED44, - gUnknown_082EED6C, - gUnknown_082EED98, - gUnknown_082EEDBC - }, { - gUnknown_082EEDF4, - gUnknown_082EEE24, - gUnknown_082EEE4C, - gUnknown_082EEE78 - } -}; - -ALIGNED(4) const u8 gUnknown_082EEECC[] = _("Oh, I see!\nThis is educational!\p"); -ALIGNED(4) const u8 gUnknown_082EEEF0[] = _("Don't say anything funny anymore!\nI'm sore from laughing!\p"); -ALIGNED(4) const u8 gUnknown_082EEF2C[] = _("Oh?\nSomething like that happened.\p"); -ALIGNED(4) const u8 gUnknown_082EEF50[] = _("Hmhm… What?\nSo is this what you're saying?\p"); -ALIGNED(4) const u8 gUnknown_082EEF7C[] = _("Is that right?\nI didn't know that.\p"); -ALIGNED(4) const u8 gUnknown_082EEFA0[] = _("Ahaha!\nWhat is that about?\p"); -ALIGNED(4) const u8 gUnknown_082EEFBC[] = _("Yes, that's exactly it!\nThat's what I meant.\p"); -ALIGNED(4) const u8 gUnknown_082EEFEC[] = _("In other words…\nYes! That's right!\p"); - -const u8 *const gUnknown_082EF010[][4] = { - { - gUnknown_082EEECC, - gUnknown_082EEEF0, - gUnknown_082EEF2C, - gUnknown_082EEF50 - }, { - gUnknown_082EEF7C, - gUnknown_082EEFA0, - gUnknown_082EEFBC, - gUnknown_082EEFEC - } -}; - -ALIGNED(4) const u8 gUnknown_082EF030[] = _("I'm just showing my TRAINER CARD\nas my way of greeting.\p"); -ALIGNED(4) const u8 gUnknown_082EF06C[] = _("I hope I get to know you better!\p"); -ALIGNED(4) const u8 gUnknown_082EF090[] = _("We're showing each other our\nTRAINER CARDS to get acquainted.\p"); -ALIGNED(4) const u8 gUnknown_082EF0D0[] = _("Glad to meet you.\nPlease don't be a stranger!\p"); - -const u8 *const gUnknown_082EF100[][2] = { - { - gUnknown_082EF030, - gUnknown_082EF06C - }, { - gUnknown_082EF090, - gUnknown_082EF0D0 - } -}; - -ALIGNED(4) const u8 gUnknown_082EF110[] = _("Yeahah!\nI really wanted this POKéMON!\p"); -ALIGNED(4) const u8 gUnknown_082EF138[] = _("Finally, a trade got me that\nPOKéMON I'd wanted a long time.\p"); -ALIGNED(4) const u8 gUnknown_082EF178[] = _("I'm trading POKéMON right now.\p"); -ALIGNED(4) const u8 gUnknown_082EF198[] = _("I finally got that POKéMON I\nwanted in a trade!\p"); - -const u8 *const gUnknown_082EF1CC[][4] = { - { - gUnknown_082EF110, - gUnknown_082EF138, - NULL, - NULL - }, { - gUnknown_082EF178, - gUnknown_082EF198, - NULL, - NULL - } -}; - -ALIGNED(4) const u8 gUnknown_082EF1EC[] = _("{STR_VAR_1} checked the\nTRADING BOARD.\p"); -ALIGNED(4) const u8 gUnknown_082EF20C[] = _("Welcome to the TRADING BOARD.\pYou may register your POKéMON\nand offer it up for a trade.\pWould you like to register one of\nyour POKéMON?"); -ALIGNED(4) const u8 gUnknown_082EF298[] = _("This TRADING BOARD is used for\noffering a POKéMON for a trade.\pAll you need to do is register a\nPOKéMON for a trade.\pAnother TRAINER may offer a party\nPOKéMON in return for the trade.\pWe hope you will register POKéMON\nand trade them with many, many\lother TRAINERS.\pWould you like to register one of\nyour POKéMON?"); -ALIGNED(4) const u8 unref_text_union_room_6[] = _("We have registered your POKéMON for\ntrade on the TRADING BOARD.\pThank you for using this service!\p"); -ALIGNED(4) const u8 unref_text_union_room_7[] = _("Nobody has registered any POKéMON\nfor trade on the TRADING BOARD.\p\n"); -ALIGNED(4) const u8 gUnknown_082EF47C[] = _("Please choose the type of POKéMON\nthat you would like in the trade.\n"); -ALIGNED(4) const u8 gUnknown_082EF4C4[] = _("Which of your party POKéMON will\nyou offer in trade?\p"); -ALIGNED(4) const u8 gUnknown_082EF4FC[] = _("Registration has been canceled.\p"); -ALIGNED(4) const u8 gUnknown_082EF520[] = _("Registration has been completed.\p"); -ALIGNED(4) const u8 gUnknown_082EF544[] = _("The trade has been canceled.\p"); -ALIGNED(4) const u8 gUnknown_082EF564[] = _("Cancel the registration of your\nLv. {STR_VAR_2} {STR_VAR_1}?"); -ALIGNED(4) const u8 gUnknown_082EF590[] = _("Cancel the registration of your\nEGG?"); -ALIGNED(4) const u8 gUnknown_082EF5B8[] = _("The registration has been canceled.\p"); -ALIGNED(4) const u8 unref_text_union_room_8[] = _("TRAINERS wishing to make a trade\nwill be listed."); -ALIGNED(4) const u8 unref_text_union_room_9[] = _("Please choose the TRAINER with whom\nyou would like to trade POKéMON."); -ALIGNED(4) const u8 gUnknown_082EF65C[] = _("Would you like to ask {STR_VAR_1} to\nmake a trade?"); -ALIGNED(4) const u8 unref_text_union_room_10[] = _("Awaiting a response from\nthe other TRAINER…"); -ALIGNED(4) const u8 unref_text_union_room_11[] = _("You have not registered a POKéMON\nfor trading.\p"); -ALIGNED(4) const u8 gUnknown_082EF6E4[] = _("You don't have a {STR_VAR_2}-type\nPOKéMON that {STR_VAR_1} wants.\p"); -ALIGNED(4) const u8 gUnknown_082EF718[] = _("You don't have an EGG that\n{STR_VAR_1} wants.\p"); -ALIGNED(4) const u8 gUnknown_082EF740[] = _("{STR_VAR_1} can't make a trade for\nyour POKéMON right now.\p"); -ALIGNED(4) const u8 gUnknown_082EF774[] = _("You can't make a trade for\n{STR_VAR_1}'s POKéMON right now.\p"); - -const u8 *const unref_text_ptrs_union_room_4[] = { - gUnknown_082EF740, - gUnknown_082EF774 -}; - -ALIGNED(4) const u8 gUnknown_082EF7B0[] = _("Your trade offer was rejected.\p"); -ALIGNED(4) const u8 gUnknown_082EF7D0[] = _("EGG TRADE"); -ALIGNED(4) const u8 gUnknown_082EF7DC[] = _("{DPAD_UPDOWN}CHOOSE {A_BUTTON}JOIN {B_BUTTON}CANCEL"); -ALIGNED(4) const u8 gUnknown_082EF7F8[] = _("Please choose a TRAINER."); -ALIGNED(4) const u8 gUnknown_082EF814[] = _("Please choose a TRAINER for\na SINGLE BATTLE."); -ALIGNED(4) const u8 gUnknown_082EF844[] = _("Please choose a TRAINER for\na DOUBLE BATTLE."); -ALIGNED(4) const u8 gUnknown_082EF874[] = _("Please choose the LEADER\nfor a MULTI BATTLE."); -ALIGNED(4) const u8 gUnknown_082EF8A4[] = _("Please choose the TRAINER to\ntrade with."); -ALIGNED(4) const u8 gUnknown_082EF8D0[] = _("Please choose the TRAINER who is\nsharing WONDER CARDS."); -ALIGNED(4) const u8 gUnknown_082EF908[] = _("Please choose the TRAINER who is\nsharing WONDER NEWS."); -ALIGNED(4) const u8 gUnknown_082EF940[] = _("Jump with mini POKéMON!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF974[] = _("BERRY CRUSH!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF99C[] = _("DODRIO BERRY-PICKING!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF9CC[] = _("BERRY BLENDER!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EF9F8[] = _("RECORD CORNER!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFA24[] = _("COOLNESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFA50[] = _("BEAUTY CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFA7C[] = _("CUTENESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFAA8[] = _("SMARTNESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFAD8[] = _("TOUGHNESS CONTEST!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFB08[] = _("BATTLE TOWER LEVEL 50!\nPlease choose the LEADER."); -ALIGNED(4) const u8 gUnknown_082EFB3C[] = _("BATTLE TOWER OPEN LEVEL!\nPlease choose the LEADER."); - -const u8 *const gUnknown_082EFB70[] = { - gUnknown_082EF814, - gUnknown_082EF844, - gUnknown_082EF874, - gUnknown_082EF8A4, - gUnknown_082EF940, - gUnknown_082EF974, - gUnknown_082EF99C, - gUnknown_082EF8D0, - gUnknown_082EF908, - NULL, - NULL, - NULL, - gUnknown_082EF9F8, - gUnknown_082EF9CC, - NULL, - gUnknown_082EFA24, - gUnknown_082EFA50, - gUnknown_082EFA7C, - gUnknown_082EFAA8, - gUnknown_082EFAD8, - gUnknown_082EFB08, - gUnknown_082EFB3C -}; - -ALIGNED(4) const u8 gUnknown_082EFBC8[] = _("Searching for a WIRELESS\nCOMMUNICATION SYSTEM. Wait..."); -ALIGNED(4) const u8 unref_text_union_room_12[] = _("For a DOUBLE BATTLE, you must have\nat least two POKéMON.\p"); -ALIGNED(4) const u8 gUnknown_082EFC3C[] = _("Awaiting {STR_VAR_1}'s response…"); -ALIGNED(4) const u8 gUnknown_082EFC54[] = _("{STR_VAR_1} has been asked to register\nyou as a member. Please wait."); -ALIGNED(4) const u8 gUnknown_082EFC90[] = _("Awaiting a response from the\nWIRELESS COMMUNICATION SYSTEM."); -ALIGNED(4) const u8 unref_text_union_room_13[] = _("Please wait for other TRAINERS to\ngather and get ready."); -ALIGNED(4) const u8 gUnknown_082EFD04[] = _("No CARDS appear to be shared \nright now."); -ALIGNED(4) const u8 gUnknown_082EFD30[] = _("No NEWS appears to be shared\nright now."); - -const u8 *const gUnknown_082EFD58[] = { - gUnknown_082EFD04, - gUnknown_082EFD30 -}; - -ALIGNED(4) const u8 gUnknown_082EFD60[] = _("BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFD68[] = _("CHAT"); -ALIGNED(4) const u8 gUnknown_082EFD70[] = _("GREETINGS"); -ALIGNED(4) const u8 gUnknown_082EFD7C[] = _("EXIT"); -ALIGNED(4) const u8 gUnknown_082EFD84[] = _("EXIT"); -ALIGNED(4) const u8 gUnknown_082EFD8C[] = _("INFO"); -ALIGNED(4) const u8 gUnknown_082EFD94[] = _("NAME{CLEAR_TO 0x3C}WANTED{CLEAR_TO 0x6E}OFFER{CLEAR_TO 0xC6}LV."); -ALIGNED(4) const u8 gUnknown_082EFDB0[] = _("SINGLE BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFDC0[] = _("DOUBLE BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFDD0[] = _("MULTI BATTLE"); -ALIGNED(4) const u8 gUnknown_082EFDE0[] = _("POKéMON TRADES"); -ALIGNED(4) const u8 gUnknown_082EFDF0[] = _("CHAT"); -ALIGNED(4) const u8 gUnknown_082EFDF8[] = _("CARDS"); -ALIGNED(4) const u8 gUnknown_082EFE00[] = _("WONDER CARDS"); -ALIGNED(4) const u8 gUnknown_082EFE10[] = _("WONDER NEWS"); -ALIGNED(4) const u8 gUnknown_082EFE1C[] = _("POKéMON JUMP"); -ALIGNED(4) const u8 gUnknown_082EFE2C[] = _("BERRY CRUSH"); -ALIGNED(4) const u8 gUnknown_082EFE38[] = _("BERRY-PICKING"); -ALIGNED(4) const u8 gUnknown_082EFE48[] = _("SEARCH"); -ALIGNED(4) const u8 gUnknown_082EFE50[] = _("BERRY BLENDER"); -ALIGNED(4) const u8 gUnknown_082EFE60[] = _("RECORD CORNER"); -ALIGNED(4) const u8 gUnknown_082EFE70[] = _("COOL CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFE80[] = _("BEAUTY CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFE90[] = _("CUTE CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFEA0[] = _("SMART CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFEB0[] = _("TOUGH CONTEST"); -ALIGNED(4) const u8 gUnknown_082EFEC0[] = _("BATTLE TOWER LV. 50"); -ALIGNED(4) const u8 gUnknown_082EFED4[] = _("BATTLE TOWER OPEN LEVEL"); -ALIGNED(4) const u8 gUnknown_082EFEEC[] = _("It's a NORMAL CARD."); -ALIGNED(4) const u8 gUnknown_082EFF00[] = _("It's a BRONZE CARD!"); -ALIGNED(4) const u8 gUnknown_082EFF14[] = _("It's a COPPER CARD!"); -ALIGNED(4) const u8 gUnknown_082EFF28[] = _("It's a SILVER CARD!"); -ALIGNED(4) const u8 gUnknown_082EFF3C[] = _("It's a GOLD CARD!"); - -const u8 *const gUnknown_082EFF50[] = { - gUnknown_082EFEEC, - gUnknown_082EFF00, - gUnknown_082EFF14, - gUnknown_082EFF28, - gUnknown_082EFF3C -}; - -ALIGNED(4) const u8 gUnknown_082EFF64[] = _("This is {SPECIAL_F7 0x00} {SPECIAL_F7 0x01}'s\nTRAINER CARD…\l{SPECIAL_F7 0x02}\pPOKéDEX: {SPECIAL_F7 0x03}\nTIME: {SPECIAL_F7 0x04}:{SPECIAL_F7 0x05}\p"); -ALIGNED(4) const u8 gUnknown_082EFFA4[] = _("BATTLES: WINS: {SPECIAL_F7 0x00} LOSSES: {SPECIAL_F7 0x02}\nTRADES: {SPECIAL_F7 0x03}\p“{SPECIAL_F7 0x04} {SPECIAL_F7 0x05}\n{SPECIAL_F7 0x06} {SPECIAL_F7 0x07}”\p"); -ALIGNED(4) const u8 gUnknown_082EFFDC[] = _("{SPECIAL_F7 0x01}: Glad to have met you!{PAUSE 60}"); -ALIGNED(4) const u8 gUnknown_082EFFFC[] = _("{SPECIAL_F7 0x01}: Glad to meet you!{PAUSE 60}"); - -const u8 *const gUnknown_082F0018[] = { - gUnknown_082EFFDC, - gUnknown_082EFFFC -}; - -ALIGNED(4) const u8 gUnknown_082F0020[] = _("Finished checking {SPECIAL_F7 0x01}'s\nTRAINER CARD.{PAUSE 60}"); - -const u8 *const gUnknown_082F0048[] = { - gText_EmptyString, - gUnknown_082EFDB0, - gUnknown_082EFDC0, - gUnknown_082EFDD0, - gUnknown_082EFDE0, - gUnknown_082EFDF0, - gUnknown_082EFE00, - gUnknown_082EFE10, - gUnknown_082EFDF8, - gUnknown_082EFE1C, - gUnknown_082EFE2C, - gUnknown_082EFE38, - gUnknown_082EFE48, - gText_EmptyString, - gUnknown_082EFED4, - gUnknown_082EFE60, - gUnknown_082EFE50, - gText_EmptyString, - gText_EmptyString, - gText_EmptyString, - gText_EmptyString, - gUnknown_082EFE00, - gUnknown_082EFE10, - gUnknown_082EFE70, - gUnknown_082EFE80, - gUnknown_082EFE90, - gUnknown_082EFEA0, - gUnknown_082EFEB0, - gUnknown_082EFEC0 -}; - -const struct WindowTemplate gUnknown_082F00BC = { - .bg = 0x00, - .tilemapLeft = 0x00, - .tilemapTop = 0x00, - .width = 0x1E, - .height = 0x02, - .paletteNum = 0x0F, - .baseBlock = 0x0008 -}; - -const u32 gUnknown_082F00C4[] = { - 0x0201, - 0x0202, - 0x0403, - 0x0204, - 0x2509, - 0x250a, - 0x350b, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x240f, - 0x2410, - 0x0000, - 0x2417, - 0x2418, - 0x2419, - 0x241a, - 0x241b, - 0x021c, - 0x020e -}; - -const struct WindowTemplate gUnknown_082F011C = { - .bg = 0x00, - .tilemapLeft = 0x01, - .tilemapTop = 0x03, - .width = 0x0d, - .height = 0x08, - .paletteNum = 0x0f, - .baseBlock = 0x0044 -}; - -const struct WindowTemplate gUnknown_082F0124 = { - .bg = 0x00, - .tilemapLeft = 0x01, - .tilemapTop = 0x03, - .width = 0x0d, - .height = 0x0a, - .paletteNum = 0x0f, - .baseBlock = 0x0044 -}; - -const struct WindowTemplate gUnknown_082F012C = { - .bg = 0x00, - .tilemapLeft = 0x10, - .tilemapTop = 0x03, - .width = 0x07, - .height = 0x04, - .paletteNum = 0x0f, - .baseBlock = 0x00c6 -}; - -const struct ListMenuItem gUnknown_082F0134[] = { - { gText_EmptyString, 0 }, - { gText_EmptyString, 1 }, - { gText_EmptyString, 2 }, - { gText_EmptyString, 3 }, - { gText_EmptyString, 4 } -}; - -const struct ListMenuTemplate gUnknown_082F015C = { - .items = gUnknown_082F0134, - .moveCursorFunc = NULL, - .itemPrintFunc = sub_8013278, - .totalItems = 5, - .maxShowed = 5, - .windowId = 0, - .header_X = 0, - .item_X = 0, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 2, - .fillValue = 1, - .cursorShadowPal = 3, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 0, - .fontId = 1, - .cursorKind = 1 -}; - -const struct WindowTemplate gUnknown_082F0174 = { - .bg = 0x00, - .tilemapLeft = 0x01, - .tilemapTop = 0x03, - .width = 0x11, - .height = 0x0a, - .paletteNum = 0x0f, - .baseBlock = 0x0044 -}; - -const struct WindowTemplate gUnknown_082F017C = { - .bg = 0x00, - .tilemapLeft = 0x14, - .tilemapTop = 0x03, - .width = 0x07, - .height = 0x04, - .paletteNum = 0x0f, - .baseBlock = 0x00ee -}; - -const struct ListMenuItem gUnknown_082F0184[] = { - { gText_EmptyString, 0 }, - { gText_EmptyString, 1 }, - { gText_EmptyString, 2 }, - { gText_EmptyString, 3 }, - { gText_EmptyString, 4 }, - { gText_EmptyString, 5 }, - { gText_EmptyString, 6 }, - { gText_EmptyString, 7 }, - { gText_EmptyString, 8 }, - { gText_EmptyString, 9 }, - { gText_EmptyString, 10 }, - { gText_EmptyString, 11 }, - { gText_EmptyString, 12 }, - { gText_EmptyString, 13 }, - { gText_EmptyString, 14 }, - { gText_EmptyString, 15 } -}; - -const struct ListMenuTemplate gUnknown_082F0204 = { - .items = gUnknown_082F0184, - .moveCursorFunc = ListMenuDefaultCursorMoveFunc, - .itemPrintFunc = sub_8013DF4, - .totalItems = 16, - .maxShowed = 5, - .windowId = 0, - .header_X = 0, - .item_X = 8, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 2, - .fillValue = 1, - .cursorShadowPal = 3, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 1, - .fontId = 1, - .cursorKind = 0 -}; - -const struct WindowTemplate gUnknown_082F021C = { - .bg = 0x00, - .tilemapLeft = 0x14, - .tilemapTop = 0x05, - .width = 0x10, - .height = 0x08, - .paletteNum = 0x0f, - .baseBlock = 0x0001 -}; - -const struct ListMenuItem gUnknown_082F0224[] = { - { gUnknown_082EFD70, 0x208 }, - { gUnknown_082EFD60, 0x241 }, - { gUnknown_082EFD68, 0x245 }, - { gUnknown_082EFD7C, 0x040 } -}; - -const struct ListMenuTemplate gUnknown_082F0244 = { - .items = gUnknown_082F0224, - .moveCursorFunc = ListMenuDefaultCursorMoveFunc, - .itemPrintFunc = NULL, - .totalItems = 4, - .maxShowed = 4, - .windowId = 0, - .header_X = 0, - .item_X = 8, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 2, - .fillValue = 1, - .cursorShadowPal = 3, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 0, - .fontId = 1, - .cursorKind = 0 -}; - -const struct WindowTemplate gUnknown_082F025C = { - .bg = 0x00, - .tilemapLeft = 0x12, - .tilemapTop = 0x07, - .width = 0x10, - .height = 0x06, - .paletteNum = 0x0f, - .baseBlock = 0x0001 -}; - -const struct ListMenuItem gUnknown_082F0264[] = { - { gText_Register, 1 }, - { gUnknown_082EFD8C, 2 }, - { gUnknown_082EFD7C, 3 } -}; - -const struct ListMenuTemplate gUnknown_082F027C = { - .items = gUnknown_082F0264, - .moveCursorFunc = ListMenuDefaultCursorMoveFunc, - .itemPrintFunc = NULL, - .totalItems = 3, - .maxShowed = 3, - .windowId = 0, - .header_X = 0, - .item_X = 8, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 2, - .fillValue = 1, - .cursorShadowPal = 3, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 0, - .fontId = 1, - .cursorKind = 0 -}; - -const struct WindowTemplate gUnknown_082F0294 = { - .bg = 0x00, - .tilemapLeft = 0x14, - .tilemapTop = 0x01, - .width = 0x10, - .height = 0x0c, - .paletteNum = 0x0f, - .baseBlock = 0x0001 -}; - -const struct ListMenuItem gUnknown_082F029C[] = { - { gTypeNames[TYPE_NORMAL], TYPE_NORMAL }, - { gTypeNames[TYPE_FIRE], TYPE_FIRE }, - { gTypeNames[TYPE_WATER], TYPE_WATER }, - { gTypeNames[TYPE_ELECTRIC], TYPE_ELECTRIC }, - { gTypeNames[TYPE_GRASS], TYPE_GRASS }, - { gTypeNames[TYPE_ICE], TYPE_ICE }, - { gTypeNames[TYPE_GROUND], TYPE_GROUND }, - { gTypeNames[TYPE_ROCK], TYPE_ROCK }, - { gTypeNames[TYPE_FLYING], TYPE_FLYING }, - { gTypeNames[TYPE_PSYCHIC], TYPE_PSYCHIC }, - { gTypeNames[TYPE_FIGHTING], TYPE_FIGHTING }, - { gTypeNames[TYPE_POISON], TYPE_POISON }, - { gTypeNames[TYPE_BUG], TYPE_BUG }, - { gTypeNames[TYPE_GHOST], TYPE_GHOST }, - { gTypeNames[TYPE_DRAGON], TYPE_DRAGON }, - { gTypeNames[TYPE_STEEL], TYPE_STEEL }, - { gTypeNames[TYPE_DARK], TYPE_DARK }, - { gUnknown_082EFD7C, NUMBER_OF_MON_TYPES } -}; - -const struct ListMenuTemplate gUnknown_082F032C = { - .items = gUnknown_082F029C, - .moveCursorFunc = ListMenuDefaultCursorMoveFunc, - .itemPrintFunc = NULL, - .totalItems = NUMBER_OF_MON_TYPES, - .maxShowed = 6, - .windowId = 0, - .header_X = 0, - .item_X = 8, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 2, - .fillValue = 1, - .cursorShadowPal = 3, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 0, - .fontId = 1, - .cursorKind = 0 -}; - -const struct WindowTemplate gUnknown_082F0344 = { - .bg = 0x00, - .tilemapLeft = 0x01, - .tilemapTop = 0x01, - .width = 0x1c, - .height = 0x02, - .paletteNum = 0x0d, - .baseBlock = 0x0001 -}; - -const struct WindowTemplate gUnknown_082F034C = { - .bg = 0x00, - .tilemapLeft = 0x01, - .tilemapTop = 0x05, - .width = 0x1c, - .height = 0x0c, - .paletteNum = 0x0d, - .baseBlock = 0x0039 -}; - -const struct ListMenuItem gUnknown_082F0354[] = { - { gText_EmptyString, -3 }, - { gText_EmptyString, 0 }, - { gText_EmptyString, 1 }, - { gText_EmptyString, 2 }, - { gText_EmptyString, 3 }, - { gText_EmptyString, 4 }, - { gText_EmptyString, 5 }, - { gText_EmptyString, 6 }, - { gText_EmptyString, 7 }, - { gUnknown_082EFD84, 8 } -}; - -const struct ListMenuTemplate gUnknown_082F03A4 = { - .items = gUnknown_082F0354, - .moveCursorFunc = ListMenuDefaultCursorMoveFunc, - .itemPrintFunc = sub_8017BE8, - .totalItems = 10, - .maxShowed = 6, - .windowId = 0, - .header_X = 0, - .item_X = 8, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 14, - .fillValue = 15, - .cursorShadowPal = 13, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 0, - .fontId = 1, - .cursorKind = 0 -}; - -const struct WindowTemplate UnrefWindowTemplate_082F03B4 = { - .bg = 0x00, - .tilemapLeft = 0x01, - .tilemapTop = 0x05, - .width = 0x1c, - .height = 0x0c, - .paletteNum = 0x0d, - .baseBlock = 0x0039 -}; - -const struct ListMenuItem gUnknown_082F03C4[] = { - { gText_EmptyString, 0 }, - { gText_EmptyString, 1 }, - { gText_EmptyString, 2 }, - { gText_EmptyString, 3 }, - { gText_EmptyString, 4 }, - { gText_EmptyString, 5 }, - { gText_EmptyString, 6 }, - { gText_EmptyString, 7 }, - { gText_EmptyString, 8 }, - { gText_EmptyString, 9 }, - { gText_EmptyString, 10 }, - { gText_EmptyString, 11 }, - { gText_EmptyString, 12 }, - { gText_EmptyString, 13 }, - { gText_EmptyString, 14 }, - { gText_EmptyString, 15 } -}; - -const struct ListMenuTemplate UnrefListMenuTemplate_082F0444 = { - .items = gUnknown_082F03C4, - .moveCursorFunc = ListMenuDefaultCursorMoveFunc, - .itemPrintFunc = nullsub_14, - .totalItems = 16, - .maxShowed = 4, - .windowId = 0, - .header_X = 0, - .item_X = 8, - .cursor_X = 0, - .upText_Y = 1, - .cursorPal = 2, - .fillValue = 1, - .cursorShadowPal = 3, - .lettersSpacing = 0, - .itemVerticalPadding = 0, - .scrollMultiple = 1, - .fontId = 1, - .cursorKind = 0 -}; - -const struct UnkStruct_Shared gUnknown_082F045C = {0}; - -ALIGNED(4) const u8 gUnknown_082F0474[] = {0x01, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0478[] = {0x02, 0xff}; -ALIGNED(4) const u8 gUnknown_082F047C[] = {0x03, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0480[] = {0x04, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0484[] = {0x09, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0488[] = {0x0a, 0xff}; -ALIGNED(4) const u8 gUnknown_082F048C[] = {0x0b, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0490[] = {0x15, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0494[] = {0x16, 0xff}; -ALIGNED(4) const u8 gUnknown_082F0498[] = {0x40, 0x41, 0x44, 0x45, 0x48, 0x51, 0x52, 0x53, 0x54, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04A4[] = {0x0c, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04A8[] = {0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x15, 0x16, 0x0d, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04B4[] = {0x0f, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04B8[] = {0x10, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04BC[] = {0x17, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04C0[] = {0x18, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04C4[] = {0x19, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04C8[] = {0x1a, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04CC[] = {0x1b, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04D0[] = {0x1c, 0xff}; -ALIGNED(4) const u8 gUnknown_082F04D4[] = {0x0e, 0xff}; - -const u8 *const gUnknown_082F04D8[] = { - gUnknown_082F0474, - gUnknown_082F0478, - gUnknown_082F047C, - gUnknown_082F0480, - gUnknown_082F0484, - gUnknown_082F0488, - gUnknown_082F048C, - gUnknown_082F0490, - gUnknown_082F0494, - gUnknown_082F0498, - gUnknown_082F04A4, - gUnknown_082F04A8, - gUnknown_082F04B4, - gUnknown_082F04B8, - NULL, - gUnknown_082F04BC, - gUnknown_082F04C0, - gUnknown_082F04C4, - gUnknown_082F04C8, - gUnknown_082F04CC, - gUnknown_082F04D0, - gUnknown_082F04D4 -}; - -const u8 gUnknown_082F0530[] = { - 0x01, 0x02, 0x03, 0x04, 0x09, 0x0a, 0x0b, 0x15, - 0x16, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x00, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x0e, 0x00, 0x00 -}; +#include "data/union_room.h" // code void nullsub_89(u8 taskId) @@ -1640,11 +602,11 @@ void sub_8013078(u8 *dst, u8 caseId) { case 65: case 68: - StringExpandPlaceholders(dst, gUnknown_082EE560); + StringExpandPlaceholders(dst, sText_OfferDeclined1); break; case 69: case 72: - StringExpandPlaceholders(dst, gUnknown_082EE57C); + StringExpandPlaceholders(dst, sText_OfferDeclined2); break; } } @@ -2117,7 +1079,7 @@ u32 sub_8013B8C(struct UnkStruct_Group *arg0, s32 id) { if (!(gSaveBlock2Ptr->specialSaveWarpFlags & 0x80)) return 1; - else if (structPtr->unk.field_0.unk_00.unk_00_7) + else if (structPtr->unk.field_0.unk_00.isChampion) return 0; } else @@ -2306,22 +1268,22 @@ u8 sub_8013E44(void) return ret; } -void sub_8013F60(u8 taskId) +static void Task_CreateTradeMenu(u8 taskId) { - sub_80773AC(); + CB2_StartCreateTradeMenu(); DestroyTask(taskId); } u8 sub_8013F78(void) { - u8 taskId = CreateTask(sub_8013F60, 0); + u8 taskId = CreateTask(Task_CreateTradeMenu, 0); return taskId; } void sub_8013F90(u8 taskId) { - u32 monId = sub_8018120(&gUnknown_02022C40, GetMultiplayerId()); + u32 monId = GetPartyPositionOfRegisteredMon(&sUnionRoomTrade, GetMultiplayerId()); switch (gTasks[taskId].data[0]) { @@ -2346,13 +1308,13 @@ void sub_8013F90(u8 taskId) case 3: if (GetBlockReceivedStatus() == 3) { - memcpy(gUnknown_020321C0, gBlockRecvBuffer[GetMultiplayerId() ^ 1], sizeof(struct MailStruct) * PARTY_SIZE); + memcpy(gTradeMail, gBlockRecvBuffer[GetMultiplayerId() ^ 1], sizeof(struct MailStruct) * PARTY_SIZE); ResetBlockReceivedFlags(); - gUnknown_02032298[0] = monId; - gUnknown_02032298[1] = 6; + gSelectedTradeMonPositions[TRADE_PLAYER] = monId; + gSelectedTradeMonPositions[TRADE_PARTNER] = PARTY_SIZE; gMain.savedCallback = CB2_ReturnToField; - SetMainCallback2(sub_807AE50); - sub_801807C(&gUnknown_02022C40); + SetMainCallback2(CB2_LinkTrade); + ResetUnionRoomTrade(&sUnionRoomTrade); DestroyTask(taskId); } break; @@ -2628,7 +1590,7 @@ void sub_8014790(u8 taskId) if (gUnknown_02022C2C == 29) { DestroyTask(taskId); - SetMainCallback2(sub_80773AC); + SetMainCallback2(CB2_StartCreateTradeMenu); } else { @@ -3335,7 +2297,7 @@ void sub_80156E0(u8 taskId) break; case 2: sub_8010F84(0x40, 0, 0); - sub_8010FCC(gUnknown_02022C40.type, gUnknown_02022C40.playerSpecies, gUnknown_02022C40.playerLevel); + sub_8010FCC(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); sub_800B488(); OpenLink(); sub_8011C84(); @@ -3346,22 +2308,22 @@ void sub_80156E0(u8 taskId) data->state = 3; break; case 3: - if ((sub_81B1360() == 8 || sub_81B1360() == 9) && gUnknown_02022C40.field_0 != 0) + if ((sub_81B1360() == 8 || sub_81B1360() == 9) && sUnionRoomTrade.field_0 != 0) { id = GetCursorSelectionMonId(); - switch (gUnknown_02022C40.field_0) + switch (sUnionRoomTrade.field_0) { case 1: sub_8011090(0x54, 0, 1); if (id >= PARTY_SIZE) { - sub_801807C(&gUnknown_02022C40); + ResetUnionRoomTrade(&sUnionRoomTrade); sub_8010FCC(0, 0, 0); - sub_801568C(gUnknown_082EF4FC); + sub_801568C(sText_RegistrationCanceled); } - else if (!sub_80180A0(GetCursorSelectionMonId(), &gUnknown_02022C40)) + else if (!RegisterTradeMonAndGetIsEgg(GetCursorSelectionMonId(), &sUnionRoomTrade)) { - sub_8015664(0x34, gUnknown_082EF47C); + sub_8015664(0x34, sText_ChooseRequestedMonType); } else { @@ -3370,21 +2332,21 @@ void sub_80156E0(u8 taskId) break; case 2: sub_80156C8(data); - taskData[1] = gUnknown_02022C40.field_8; + taskData[1] = sUnionRoomTrade.field_8; if (id >= PARTY_SIZE) { - sub_801568C(gUnknown_082EF544); + sub_801568C(sText_TradeCanceled); } else { sub_8011090(0x54, 0, 1); gUnknown_02022C2C = 0x44; - sub_80180E8(GetCursorSelectionMonId(), &gUnknown_02022C40); + RegisterTradeMon(GetCursorSelectionMonId(), &sUnionRoomTrade); data->state = 51; } break; } - gUnknown_02022C40.field_0 = 0; + sUnionRoomTrade.field_0 = 0; } else { @@ -3492,9 +2454,9 @@ void sub_80156E0(u8 taskId) case 1: case 2: if (sub_8011B90() == TRUE) - sub_801568C(gUnknown_082EE6C8); + sub_801568C(sText_TrainerAppearsBusy); else - sub_8015664(30, gUnknown_082EE6C8); + sub_8015664(30, sText_TrainerAppearsBusy); gUnknown_02022C2C = 0x40; break; @@ -3552,9 +2514,9 @@ void sub_80156E0(u8 taskId) { gUnknown_02022C2C = var5; gUnknown_02022C2D = (u32)(var5) >> 8; - if (gUnknown_02022C2C == 0x41 && !sub_8018024()) + if (gUnknown_02022C2C == 0x41 && !HasAtLeastTwoMonsOfLevel30OrLower()) { - sub_8015664(5, gUnknown_082EEBD0); + sub_8015664(5, sText_NeedTwoMonsOfLevel30OrLower1); } else { @@ -3567,7 +2529,7 @@ void sub_80156E0(u8 taskId) } break; case 28: - StringCopy(gStringVar4, gUnknown_082EEB88); + StringCopy(gStringVar4, sText_TrainerBattleBusy); data->state = 36; break; case 27: @@ -3586,15 +2548,15 @@ void sub_80156E0(u8 taskId) break; case 31: data->field_4C[0] = 0x44; - data->field_4C[1] = gUnknown_02022C40.species; - data->field_4C[2] = gUnknown_02022C40.level; + data->field_4C[1] = sUnionRoomTrade.species; + data->field_4C[2] = sUnionRoomTrade.level; sub_800FE50(data->field_4C); data->state = 29; break; case 29: if (gReceivedRemoteLinkPlayers == 0) { - StringCopy(gStringVar4, gUnknown_082EEB88); + StringCopy(gStringVar4, sText_TrainerBattleBusy); data->state = 28; } else @@ -3642,7 +2604,7 @@ void sub_80156E0(u8 taskId) { StringCopy(gStringVar1, gLinkPlayers[GetMultiplayerId() ^ 1].name); id = sub_800E540(gLinkPlayers[1].trainerId, gLinkPlayers[1].name); - StringExpandPlaceholders(gStringVar4, gUnknown_082EE378[id]); + StringExpandPlaceholders(gStringVar4, sUnionRoomTexts_AwaitingResponse[id]); data->state = 33; } else @@ -3666,7 +2628,7 @@ void sub_80156E0(u8 taskId) case 1: case -1: playerGender = sub_8017CF8(taskData[1], data->field_0); - sub_801568C(gUnknown_082EEC9C[playerGender]); + sub_801568C(sUnionRoomTexts_DeclineBattle[playerGender]); break; } break; @@ -3751,7 +2713,7 @@ void sub_80156E0(u8 taskId) if (sub_80168DC(data) && gMain.newKeys & B_BUTTON) { sub_8011DE0(1); - StringCopy(gStringVar4, gUnknown_082EE598); + StringCopy(gStringVar4, sText_ChatEnded); data->state = 36; } break; @@ -3772,12 +2734,12 @@ void sub_80156E0(u8 taskId) taskData[3] = 0; if (gUnknown_02022C2C == 0x41) { - if (!sub_8018024()) + if (!HasAtLeastTwoMonsOfLevel30OrLower()) { data->field_4C[0] = 0x52; sub_800FE50(data->field_4C); data->state = 10; - StringCopy(gStringVar4, gUnknown_082EEC14); + StringCopy(gStringVar4, sText_NeedTwoMonsOfLevel30OrLower2); } else { @@ -3867,19 +2829,19 @@ void sub_80156E0(u8 taskId) { if (sub_800F7DC()->species == SPECIES_EGG) { - StringCopy(gStringVar4, gUnknown_082EF590); + StringCopy(gStringVar4, sText_CancelRegistrationOfEgg); } else { StringCopy(gStringVar1, gSpeciesNames[sub_800F7DC()->species]); - ConvertIntToDecimalStringN(gStringVar2, sub_800F7DC()->unk_0b_1, STR_CONV_MODE_LEFT_ALIGN, 3); - StringExpandPlaceholders(gStringVar4, gUnknown_082EF564); + ConvertIntToDecimalStringN(gStringVar2, sub_800F7DC()->level, STR_CONV_MODE_LEFT_ALIGN, 3); + StringExpandPlaceholders(gStringVar4, sText_CancelRegistrationOfMon); } sub_8015664(44, gStringVar4); } break; case 43: - if (PrintOnTextbox(&data->textState, gUnknown_082EF20C)) + if (PrintOnTextbox(&data->textState, sText_RegisterMonAtTradingBoard)) data->state = 47; break; case 47: @@ -3895,11 +2857,11 @@ void sub_80156E0(u8 taskId) { switch (var5) { - case 1: - sub_8015664(53, gUnknown_082EF4C4); + case 1: // REGISTER + sub_8015664(53, sText_WhichMonWillYouOffer); break; - case 2: - sub_8015664(47, gUnknown_082EF298); + case 2: // INFO + sub_8015664(47, sText_TradingBoardInfo); break; } } @@ -3912,33 +2874,33 @@ void sub_80156E0(u8 taskId) case 54: if (!gPaletteFade.active) { - gUnknown_02022C40.field_0 = 1; + sUnionRoomTrade.field_0 = 1; gFieldCallback = sub_80AF128; sub_81B8904(8, CB2_ReturnToField); } break; case 52: - var5 = sub_8017178(&data->textState, &data->field_1D, &data->field_1E, &gUnknown_082F0294, &gUnknown_082F032C); + var5 = sub_8017178(&data->textState, &data->field_1D, &data->field_1E, &gUnknown_082F0294, &sMenuTemplate_TradingBoardRequestType); if (var5 != -1) { switch (var5) { case -2: case 18: - sub_801807C(&gUnknown_02022C40); + ResetUnionRoomTrade(&sUnionRoomTrade); sub_8010FCC(0, 0, 0); - sub_801568C(gUnknown_082EF4FC); + sub_801568C(sText_RegistrationCanceled); break; default: - gUnknown_02022C40.type = var5; + sUnionRoomTrade.type = var5; data->state = 55; break; } } break; case 55: - sub_8010FCC(gUnknown_02022C40.type, gUnknown_02022C40.playerSpecies, gUnknown_02022C40.playerLevel); - sub_801568C(gUnknown_082EF520); + sub_8010FCC(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); + sub_801568C(sText_RegistraionCompleted); break; case 44: switch (sub_80170B8(&data->textState, FALSE)) @@ -3954,16 +2916,16 @@ void sub_80156E0(u8 taskId) } break; case 56: - if (PrintOnTextbox(&data->textState, gUnknown_082EF5B8)) + if (PrintOnTextbox(&data->textState, sText_RegistrationCanceled2)) { sub_8010FCC(0, 0, 0); - sub_801807C(&gUnknown_02022C40); + ResetUnionRoomTrade(&sUnionRoomTrade); sub_801818C(TRUE); data->state = 4; } break; case 45: - if (PrintOnTextbox(&data->textState, gUnknown_082EF1EC)) + if (PrintOnTextbox(&data->textState, sText_XCheckedTradingBoard)) data->state = 46; break; case 46: @@ -3987,18 +2949,18 @@ void sub_80156E0(u8 taskId) { case 0: sub_8018404(gStringVar1, &data->field_0->arr[var5]); - sub_8015664(49, gUnknown_082EF65C); + sub_8015664(49, sText_AskTrainerToMakeTrade); taskData[1] = var5; break; case 1: sub_8018404(gStringVar1, &data->field_0->arr[var5]); StringCopy(gStringVar2, gTypeNames[data->field_0->arr[var5].unk.field_0.type]); - sub_8015664(46, gUnknown_082EF6E4); + sub_8015664(46, sText_DontHaveTypeTrainerWants); break; case 2: sub_8018404(gStringVar1, &data->field_0->arr[var5]); StringCopy(gStringVar2, gTypeNames[data->field_0->arr[var5].unk.field_0.type]); - sub_8015664(46, gUnknown_082EF718); + sub_8015664(46, sText_DontHaveEggTrainerWants); break; } break; @@ -4019,16 +2981,16 @@ void sub_80156E0(u8 taskId) } break; case 50: - if (PrintOnTextbox(&data->textState, gUnknown_082EF4C4)) + if (PrintOnTextbox(&data->textState, sText_WhichMonWillYouOffer)) { - gUnknown_02022C40.field_0 = 2; + sUnionRoomTrade.field_0 = 2; memcpy(&gUnknown_02022C38, &data->field_0->arr[taskData[1]].unk.field_0.unk_00, sizeof(gUnknown_02022C38)); - gUnknown_02022C3E = data->field_0->arr[taskData[1]].unk.field_0.type; - gUnknown_02022C3C = data->field_0->arr[taskData[1]].unk.field_0.species; + gUnionRoomRequestedMonType = data->field_0->arr[taskData[1]].unk.field_0.type; + gUnionRoomOfferedSpecies = data->field_0->arr[taskData[1]].unk.field_0.species; gFieldCallback = sub_80AF128; sub_81B8904(9, CB2_ReturnToField); sub_80156B0(data); - gUnknown_02022C40.field_8 = taskData[1]; + sUnionRoomTrade.field_8 = taskData[1]; } break; case 51: @@ -4898,7 +3860,7 @@ s32 sub_80179D4(struct UnkStruct_Main0 *arg0, u8 arg1, u8 arg2, u32 playerGender r2 = sub_800E540(ReadAsU16(r5->unk.field_0.unk_00.playerTrainerId), gStringVar1); if (r5->unk.field_0.unk_0a_0 == 0x45) { - StringExpandPlaceholders(gStringVar4, gUnknown_082EE6B8[r2][playerGender]); + StringExpandPlaceholders(gStringVar4, sUnionRoomTexts_JoinChat[r2][playerGender]); return 2; } else @@ -4920,7 +3882,7 @@ s32 sub_80179D4(struct UnkStruct_Main0 *arg0, u8 arg1, u8 arg2, u32 playerGender StringExpandPlaceholders(gStringVar4, gUnknown_082EEEAC[playerGender][Random() % 4]); break; case 4: - StringExpandPlaceholders(gStringVar4, gUnknown_082EF1CC[playerGender][Random() % 2]); + StringExpandPlaceholders(gStringVar4, sUnionRoomTexts_Traded[playerGender][Random() % 2]); break; case 5: StringExpandPlaceholders(gStringVar4, gUnknown_082EF010[playerGender][Random() % 4]); @@ -4929,7 +3891,7 @@ s32 sub_80179D4(struct UnkStruct_Main0 *arg0, u8 arg1, u8 arg2, u32 playerGender StringExpandPlaceholders(gStringVar4, gUnknown_082EF100[playerGender][Random() % 2]); break; default: - StringExpandPlaceholders(gStringVar4, gUnknown_082EE6C8); + StringExpandPlaceholders(gStringVar4, sText_TrainerAppearsBusy); break; } return 0; @@ -4946,12 +3908,12 @@ void sub_8017B3C(u8 arg0, u8 arg1, struct UnkLinkRfuStruct_02022B14 * arg2, cons u8 sp8[4]; u16 r8 = arg2->species; u8 r7 = arg2->type; - u8 r9 = arg2->unk_0b_1; + u8 r9 = arg2->level; sub_80173E0(arg0, 1, str, 8, arg1, arg4); if (r8 == SPECIES_EGG) { - sub_80173E0(arg0, 1, gUnknown_082EF7D0, 0x44, arg1, arg4); + sub_80173E0(arg0, 1, sText_EggTrade, 0x44, arg1, arg4); } else { @@ -5062,7 +4024,7 @@ void sub_8017D9C(u8 *dst, s32 arg1, u32 playerGender) StringExpandPlaceholders(dst, gUnknown_082EED3C[playerGender]); break; case 0x44: - StringExpandPlaceholders(dst, gUnknown_082EF7B0); + StringExpandPlaceholders(dst, sText_TradeOfferRejected); break; case 0x48: StringExpandPlaceholders(dst, gUnknown_082EEB08[playerGender]); @@ -5098,16 +4060,16 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) switch (arg2[0]) { case 0x41: - StringExpandPlaceholders(dst, gUnknown_082EE3DC); + StringExpandPlaceholders(dst, sText_BattleChallenge); result = 1; break; case 0x45: - StringExpandPlaceholders(dst, gUnknown_082EE430); + StringExpandPlaceholders(dst, sText_ChatInvitation); result = 1; break; case 0x44: - ConvertIntToDecimalStringN(arg3->field_58 + 0x00, gUnknown_02022C40.playerLevel, STR_CONV_MODE_LEFT_ALIGN, 3); - StringCopy(arg3->field_58 + 0x10, gSpeciesNames[gUnknown_02022C40.playerSpecies]); + ConvertIntToDecimalStringN(arg3->field_58 + 0x00, sUnionRoomTrade.playerLevel, STR_CONV_MODE_LEFT_ALIGN, 3); + StringCopy(arg3->field_58 + 0x10, gSpeciesNames[sUnionRoomTrade.playerSpecies]); for (i = 0; i < 4; i++) { if (gUnknown_03007890->unk_14[i].unk_04 == 2) @@ -5120,7 +4082,7 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) } if (species == SPECIES_EGG) { - StringCopy(dst, gUnknown_082EE4F0); + StringCopy(dst, sText_OfferToTradeEgg); } else { @@ -5128,16 +4090,16 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) { DynamicPlaceholderTextUtil_SetPlaceholderPtr(i, arg3->field_58 + 0x10 * i); } - DynamicPlaceholderTextUtil_ExpandPlaceholders(dst, gUnknown_082EE47C); + DynamicPlaceholderTextUtil_ExpandPlaceholders(dst, sText_OfferToTradeMon); } result = 1; break; case 0x48: - StringExpandPlaceholders(dst, gUnknown_082EE380); + StringExpandPlaceholders(dst, sText_ShowTrainerCard); result = 1; break; case 0x40: - StringExpandPlaceholders(dst, gUnknown_082EE544); + StringExpandPlaceholders(dst, sText_ChatDropped); result = 2; break; } @@ -5170,14 +4132,14 @@ bool32 InUnionRoom(void) ? TRUE : FALSE; } -bool32 sub_8018024(void) +bool32 HasAtLeastTwoMonsOfLevel30OrLower(void) { s32 i; s32 count = 0; for (i = 0; i < gPlayerPartyCount; i++) { - if ( GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= 30 + if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= 30 && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) { count++; @@ -5185,16 +4147,12 @@ bool32 sub_8018024(void) } if (count > 1) - { return TRUE; - } else - { return FALSE; - } } -void sub_801807C(struct TradeUnkStruct *arg0) +static void ResetUnionRoomTrade(struct UnionRoomTrade *arg0) { arg0->field_0 = 0; arg0->type = 0; @@ -5208,32 +4166,28 @@ void sub_801807C(struct TradeUnkStruct *arg0) void Script_ResetUnionRoomTrade(void) { - sub_801807C(&gUnknown_02022C40); + ResetUnionRoomTrade(&sUnionRoomTrade); } -bool32 sub_80180A0(u32 monId, struct TradeUnkStruct *arg1) +static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trade) { - arg1->playerSpecies = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); - arg1->playerLevel = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); - arg1->playerPersonality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); - if (arg1->playerSpecies == SPECIES_EGG) - { + trade->playerSpecies = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + trade->playerLevel = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + trade->playerPersonality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); + if (trade->playerSpecies == SPECIES_EGG) return TRUE; - } else - { return FALSE; - } } -void sub_80180E8(u32 monId, struct TradeUnkStruct *arg1) +static void RegisterTradeMon(u32 monId, struct UnionRoomTrade *trade) { - arg1->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); - arg1->level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); - arg1->personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); + trade->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + trade->level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); + trade->personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); } -u32 sub_8018120(struct TradeUnkStruct *arg0, u8 multiplayerId) +static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *trade, u8 multiplayerId) { u16 response = 0; u16 species; @@ -5242,15 +4196,17 @@ u32 sub_8018120(struct TradeUnkStruct *arg0, u8 multiplayerId) u16 cur_species; s32 i; + // player if (multiplayerId == 0) { - species = arg0->playerSpecies; - personality = arg0->playerPersonality; + species = trade->playerSpecies; + personality = trade->playerPersonality; } + // partner else { - species = arg0->species; - personality = arg0->personality; + species = trade->species; + personality = trade->personality; } for (i = 0; i < gPlayerPartyCount; i++) @@ -5280,7 +4236,7 @@ void sub_801818C(bool32 arg0) gUnknown_02022C2C = 0; if (arg0) { - sub_8010FCC(gUnknown_02022C40.type, gUnknown_02022C40.playerSpecies, gUnknown_02022C40.playerLevel); + sub_8010FCC(sUnionRoomTrade.type, sUnionRoomTrade.playerSpecies, sUnionRoomTrade.playerLevel); sub_8011090(0x40, 0, 0); } }