From c3c8fb40cfab23b5db845ce4b2bd3e626a5506dc Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 3 Oct 2019 01:16:22 -0400 Subject: [PATCH 01/11] Move trade data, some trade.c clean up documentation --- data/event_scripts.s | 1 + data/maps/BattleFrontier_Lounge6/scripts.inc | 2 +- data/maps/FortreeCity_House1/scripts.inc | 2 +- data/maps/PacifidlogTown_House3/scripts.inc | 2 +- data/maps/RustboroCity_House1/scripts.inc | 2 +- include/constants/trade.h | 13 + include/graphics.h | 6 +- include/trade.h | 2 +- src/cable_club.c | 8 +- src/data/trade.h | 1186 ++++++++++++++ src/graphics.c | 9 +- src/trade.c | 1480 ++---------------- src/union_room.c | 4 +- 13 files changed, 1377 insertions(+), 1340 deletions(-) create mode 100644 include/constants/trade.h create mode 100644 src/data/trade.h diff --git a/data/event_scripts.s b/data/event_scripts.s index d22613f40..9a9e98565 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -27,6 +27,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/include/constants/trade.h b/include/constants/trade.h new file mode 100644 index 000000000..1afa3b263 --- /dev/null +++ b/include/constants/trade.h @@ -0,0 +1,13 @@ +#ifndef GUARD_CONSTANTS_TRADE_H +#define GUARD_CONSTANTS_TRADE_H + +#define TRADE_PLAYER 0 +#define TRADE_PARTNER 1 +#define TRADE_PARTICIPANT_COUNT 2 + +#define INGAME_TRADE_SEEDOT 0 +#define INGAME_TRADE_PLUSLE 1 +#define INGAME_TRADE_HORSEA 2 +#define INGAME_TRADE_MEOWTH 3 + +#endif //GUARD_CONSTANTS_TRADE_H diff --git a/include/graphics.h b/include/graphics.h index 5f5c579d2..967af3d6a 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 u8 gTradeButtons_Gfx[]; extern const u16 gUnknown_08DDB444[]; // Party menu diff --git a/include/trade.h b/include/trade.h index 0c95e1e81..861ac490d 100644 --- a/include/trade.h +++ b/include/trade.h @@ -7,7 +7,7 @@ // Exported RAM declarations extern struct MailStruct gUnknown_020321C0[PARTY_SIZE]; -extern u8 gUnknown_02032298[2]; +extern u8 gSelectedTradeMonPositions[2]; // Exported ROM declarations extern const struct WindowTemplate gUnknown_0833900C; diff --git a/src/cable_club.c b/src/cable_club.c index 303cc76d1..ba051dbd2 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -1084,8 +1084,8 @@ static void sub_80B37FC(u8 taskId) task->data[0]++; break; case 2: - gUnknown_02032298[0] = 0; - gUnknown_02032298[1] = 0; + gSelectedTradeMonPositions[0] = 0; + gSelectedTradeMonPositions[1] = 0; m4aMPlayAllStop(); sub_800AC34(); task->data[0]++; @@ -1117,8 +1117,8 @@ static void sub_80B3894(u8 taskId) data[0]++; break; case 2: - gUnknown_02032298[0] = 0; - gUnknown_02032298[1] = 0; + gSelectedTradeMonPositions[0] = 0; + gSelectedTradeMonPositions[1] = 0; m4aMPlayAllStop(); sub_800ADF8(); data[0]++; diff --git a/src/data/trade.h b/src/data/trade.h new file mode 100644 index 000000000..97e0cdfe1 --- /dev/null +++ b/src/data/trade.h @@ -0,0 +1,1186 @@ +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."); + +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 = 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 = &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 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 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 + }, { + 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 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} +}; diff --git a/src/graphics.c b/src/graphics.c index 679f16af1..77a12b081 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1518,13 +1518,10 @@ asm(".space 0x20"); //blank palette?? // more trade stuff? -const u16 gUnknown_08DDB3E4[] = INCBIN_U16("graphics/trade/menu.gbapal"); - +const u16 gTradeMenu_Pal[] = 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"); +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"); diff --git a/src/trade.c b/src/trade.c index 196d9659c..3c09fce41 100644 --- a/src/trade.c +++ b/src/trade.c @@ -44,56 +44,60 @@ #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" +#include "constants/trade.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}; +EWRAM_DATA u8 gSelectedTradeMonPositions[TRADE_PARTICIPANT_COUNT] = {0}; static EWRAM_DATA struct { /*0x0000*/ u8 unk_0; /*0x0001*/ u8 unk_1; /*0x0002*/ u8 filler_2[0x28 - 2]; - /*0x0028*/ u8 partyIcons[2][PARTY_SIZE]; + /*0x0028*/ u8 partyIcons[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; /*0x0034*/ u8 tradeMenuCursorSpriteIdx; /*0x0035*/ u8 tradeMenuCursorPosition; - /*0x0036*/ u8 partyCounts[2]; + /*0x0036*/ u8 partyCounts[TRADE_PARTICIPANT_COUNT]; /*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]; + /*0x0044*/ u8 neverRead_44; + /*0x0045*/ u8 unk_45[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; + /*0x0051*/ bool8 isEgg[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; + /*0x005D*/ u8 unk_5D[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; /*0x0069*/ u8 unk_69; /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; /*0x006F*/ u8 unk_6F; /*0x0070*/ u8 unk_70; /*0x0071*/ u8 filler_71; /*0x0072*/ u16 unk_72; - /*0x0074*/ u8 unk_74[2]; - /*0x0076*/ u8 unk_76[2]; + /*0x0074*/ u8 unk_74[TRADE_PARTICIPANT_COUNT]; + /*0x0076*/ u8 tradeMonIdx[TRADE_PARTICIPANT_COUNT]; /*0x0078*/ u8 unk_78; /*0x0079*/ u8 unk_79; /*0x007A*/ u8 unk_7A; @@ -173,7 +177,7 @@ 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 BufferTradeMonMoves(u8 *, u8, u8); static void sub_8079BE0(u8); static void sub_8079C4C(u8, u8, u8, u8, u8, u8); static void sub_8079E44(u8); @@ -222,1170 +226,7 @@ static void c3_0805465C(u8); static void sub_807F39C(u8); static void sub_807F464(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."); - -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} -}; +#include "data/trade.h" static bool8 sub_8077170(const void *a0, u32 a1) { @@ -1510,8 +351,8 @@ static void sub_80772A4(void) 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_74[TRADE_PLAYER] = 0; + gUnknown_0203229C->unk_74[TRADE_PARTNER] = 0; gUnknown_0203229C->unk_7A = 0; gUnknown_0203229C->unk_7B = 0; gUnknown_0203229C->unk_A8 = 0; @@ -1651,7 +492,7 @@ static void sub_80773D0(void) for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - gUnknown_0203229C->partyIcons[0][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + gUnknown_0203229C->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -1663,7 +504,7 @@ static void sub_80773D0(void) for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - gUnknown_0203229C->partyIcons[1][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + gUnknown_0203229C->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -1675,11 +516,11 @@ static void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 0); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 0); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 1); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 1); gMain.state++; break; case 10: @@ -1734,8 +575,8 @@ static void sub_80773D0(void) rbox_fill_rectangle(0); break; case 14: - sub_807A320(0); - sub_8079BE0(0); + sub_807A320(TRADE_PLAYER); + sub_8079BE0(TRADE_PLAYER); gUnknown_0203229C->unk_0 = 0; gUnknown_0203229C->unk_1 = 0; sub_8078388(); @@ -1743,8 +584,8 @@ static void sub_80773D0(void) PlayBGM(MUS_P_SCHOOL); break; case 15: - sub_807A320(1); - sub_8079BE0(1); + sub_807A320(TRADE_PARTNER); + sub_8079BE0(TRADE_PARTNER); gMain.state++; // fallthrough case 16: @@ -1832,13 +673,13 @@ static void sub_8077B74(void) gUnknown_0203229C->partyCounts[0] = gPlayerPartyCount; gUnknown_0203229C->partyCounts[1] = gEnemyPartyCount; ClearWindowTilemap(0); - sub_8079BE0(0); - sub_8079BE0(1); + sub_8079BE0(TRADE_PLAYER); + sub_8079BE0(TRADE_PARTNER); for (i = 0; i < gUnknown_0203229C->partyCounts[0]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - gUnknown_0203229C->partyIcons[0][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + gUnknown_0203229C->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -1850,7 +691,7 @@ static void sub_8077B74(void) for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - gUnknown_0203229C->partyIcons[1][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + gUnknown_0203229C->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -1862,11 +703,11 @@ static void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 0); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 0); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[0], 1); + sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 1); gMain.state++; break; case 10: @@ -1986,8 +827,8 @@ static void sub_807816C(void) { if (!gPaletteFade.active) { - gUnknown_02032298[0] = gUnknown_0203229C->tradeMenuCursorPosition; - gUnknown_02032298[1] = gUnknown_0203229C->unk_7E; + gSelectedTradeMonPositions[0] = gUnknown_0203229C->tradeMenuCursorPosition; + gSelectedTradeMonPositions[1] = gUnknown_0203229C->unk_7E; if (gWirelessCommType) { @@ -2036,8 +877,8 @@ static void sub_807825C(void) sub_80795AC(); sub_807A0C4(); - sub_80796B4(0); - sub_80796B4(1); + sub_80796B4(TRADE_PLAYER); + sub_80796B4(TRADE_PARTNER); SetGpuReg(REG_OFFSET_BG2HOFS, gUnknown_0203229C->unk_0++); SetGpuReg(REG_OFFSET_BG3HOFS, gUnknown_0203229C->unk_1--); @@ -2056,15 +897,15 @@ static void sub_80782B8(u8 a0) switch (a0) { 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); break; case 1: LoadBgTilemap(3, gTradeStripesBG3Tilemap, 0x800, 0); - sub_8079E44(0); - sub_8079E44(1); + sub_8079E44(TRADE_PLAYER); + sub_8079E44(TRADE_PARTNER); CopyBgTilemapBufferToVram(1); break; case 2: @@ -2088,7 +929,7 @@ static void sub_8078388(void) { if (i < gUnknown_0203229C->partyCounts[0]) { - gSprites[gUnknown_0203229C->partyIcons[0][i]].invisible = FALSE; + gSprites[gUnknown_0203229C->partyIcons[TRADE_PLAYER][i]].invisible = FALSE; gUnknown_0203229C->tradeMenuOptionsActive[i] = TRUE; } else @@ -2098,7 +939,7 @@ static void sub_8078388(void) if (i < gUnknown_0203229C->partyCounts[1]) { - gSprites[gUnknown_0203229C->partyIcons[1][i]].invisible = FALSE; + gSprites[gUnknown_0203229C->partyIcons[TRADE_PARTNER][i]].invisible = FALSE; gUnknown_0203229C->tradeMenuOptionsActive[i + PARTY_SIZE] = TRUE; } else @@ -2107,7 +948,7 @@ static void sub_8078388(void) } } - gUnknown_0203229C->unk_44 = 1; + gUnknown_0203229C->neverRead_44 = 1; } // why not just use memcpy? @@ -2664,7 +1505,7 @@ static u8 sub_80790D4(u8 *a0, u8 a1, u8 a2, u8 a3) if (!IsNationalPokedexEnabled()) { - if (gUnknown_0203229C->unk_51[1][a3] || !IsSpeciesInHoennDex(species)) + if (gUnknown_0203229C->isEgg[TRADE_PARTNER][a3] || !IsSpeciesInHoennDex(species)) { return 2; } @@ -2775,7 +1616,8 @@ static void sub_807935C(void) static void sub_8079398(void) { - if (gUnknown_0203229C->unk_74[0] == 5 && gUnknown_0203229C->unk_74[1] == 5) + if (gUnknown_0203229C->unk_74[TRADE_PLAYER] == 5 + && gUnknown_0203229C->unk_74[TRADE_PARTNER] == 5) { sub_80787B8(); gUnknown_0203229C->unk_6F = 14; @@ -2810,8 +1652,8 @@ static void sub_8079408(void) rbox_fill_rectangle(i + 14); } - sub_8079F88(0); - sub_8079F88(1); + sub_8079F88(TRADE_PLAYER); + sub_8079F88(TRADE_PARTNER); gUnknown_0203229C->unk_6F = 0; gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = FALSE; } @@ -2935,14 +1777,15 @@ static void sub_80795AC(void) } } -static void sub_807967C(u8 a0) +static void sub_807967C(u8 monIdx) { - u8 whichParty = a0 / PARTY_SIZE; + //monIdx 0-5 are the player's mons, 6-11 are the partner's + u8 whichParty = monIdx / PARTY_SIZE; if (gUnknown_0203229C->unk_74[whichParty] == 0) { gUnknown_0203229C->unk_74[whichParty] = 1; - gUnknown_0203229C->unk_76[whichParty] = a0; + gUnknown_0203229C->tradeMonIdx[whichParty] = monIdx; } } @@ -2954,11 +1797,11 @@ static void sub_80796B4(u8 a0) u8 i; u8 partyIdx; u8 whichParty; - u8 monIdx = gUnknown_0203229C->unk_76[a0]; + u8 monIdx = gUnknown_0203229C->tradeMonIdx[a0]; - whichParty = 1; - if (gUnknown_0203229C->unk_76[a0] < PARTY_SIZE) - whichParty = 0; + whichParty = TRADE_PARTNER; + if (gUnknown_0203229C->tradeMonIdx[a0] < PARTY_SIZE) + whichParty = TRADE_PLAYER; partyIdx = monIdx % PARTY_SIZE; nameStringWidth = 0; @@ -2986,7 +1829,7 @@ static void sub_80796B4(u8 a0) CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) sub_8079F74(); break; case 2: @@ -3002,7 +1845,7 @@ static void sub_80796B4(u8 a0) 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); + BufferTradeMonMoves(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); @@ -3030,41 +1873,41 @@ 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 (!gUnknown_0203229C->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, gText_EmptyString7); 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, gText_NewLine3); } } else { - StringCopy(a0, gText_EmptyString7); - StringAppend(a0, gText_FourQuestionMarks); + StringCopy(str, gText_EmptyString7); + StringAppend(str, gText_FourQuestionMarks); } } @@ -3083,7 +1926,7 @@ static void sub_8079BE0(u8 whichParty) u8 i; u8 sp[20]; u8 sp14[32]; - struct Pokemon *mons = whichParty == 0 ? gPlayerParty : gEnemyParty; + struct Pokemon *mons = whichParty == TRADE_PLAYER ? gPlayerParty : gEnemyParty; for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) { @@ -3103,12 +1946,12 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5) CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDD704, a4, a5, 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 (!gUnknown_0203229C->isEgg[whichParty][monIdx]) { if (level / 10 != 0) gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32)] = (level / 10) + 0x60; @@ -3121,13 +1964,13 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5) gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) - 31] = gUnknown_0203229C->tilemapBuffer[a2 + (a3 * 32) - 36] | 0x400; } - if (gUnknown_0203229C->unk_51[whichParty][monIdx] != 0) + if (gUnknown_0203229C->isEgg[whichParty][monIdx]) { r2 = 0x480; } else { - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) { gender = GetMonGender(&gPlayerParty[monIdx]); GetMonData(&gPlayerParty[monIdx], MON_DATA_NICKNAME, nickname); @@ -3235,7 +2078,7 @@ static void sub_8079EA8(u8 whichParty) static void sub_8079F74(void) { rbox_fill_rectangle(1); - sub_8079BE0(1); + sub_8079BE0(TRADE_PARTNER); } static void sub_8079F88(u8 a0) @@ -3395,52 +2238,52 @@ static void sub_807A308(const u8 *a0, u8 *a1, u8 unused) sub_80C6D80(a0, a1, 0, 0, 6); } -static void sub_807A320(u8 who) +static void sub_807A320(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 < gUnknown_0203229C->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; - } + gUnknown_0203229C->unk_45[whichParty][i] = 0; + gUnknown_0203229C->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; - } + gUnknown_0203229C->unk_45[whichParty][i] = 0; + gUnknown_0203229C->isEgg[whichParty][i] = FALSE; } - break; + else + { + gUnknown_0203229C->unk_45[whichParty][i] = 1; + gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + } + } + break; + case TRADE_PARTNER: + for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) + { + if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) + { + gUnknown_0203229C->unk_45[whichParty][i] = 0; + gUnknown_0203229C->isEgg[whichParty][i] = TRUE; + } + else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) + { + gUnknown_0203229C->unk_45[whichParty][i] = 0; + gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + } + else + { + gUnknown_0203229C->unk_45[whichParty][i] = 1; + gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + } + } + break; } } @@ -3473,7 +2316,7 @@ static void sub_807A53C(void) { int i, j; - for (i = 0; i < 2; i++) + for (i = 0; i < TRADE_PARTICIPANT_COUNT; i++) { for (j = 0; j < gUnknown_0203229C->partyCounts[i]; j++) { @@ -4091,15 +2934,15 @@ static void sub_807ACFC(u8 whichParty, u8 a1) u16 species; u32 personality; - if (whichParty == 0) + if (whichParty == TRADE_PLAYER) { - mon = &gPlayerParty[gUnknown_02032298[0]]; + mon = &gPlayerParty[gSelectedTradeMonPositions[0]]; pos = 1; } - if (whichParty == 1) + if (whichParty == TRADE_PARTNER) { - mon = &gEnemyParty[gUnknown_02032298[1] % PARTY_SIZE]; + mon = &gEnemyParty[gSelectedTradeMonPositions[1] % PARTY_SIZE]; pos = 3; } @@ -4109,7 +2952,7 @@ static void sub_807ACFC(u8 whichParty, u8 a1) species = GetMonData(mon, MON_DATA_SPECIES2); personality = GetMonData(mon, MON_DATA_PERSONALITY); - if (whichParty == 0) + 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); @@ -4208,19 +3051,19 @@ void sub_807AE50(void) gUnknown_020322A0->unk_72 = 0; gUnknown_020322A0->unk_73 = 0; gUnknown_020322A0->unk_93 = 0; - sub_807ACFC(0, 0); + sub_807ACFC(TRADE_PLAYER, 0); gMain.state++; break; case 6: - sub_807ACFC(0, 1); + sub_807ACFC(TRADE_PLAYER, 1); gMain.state++; break; case 7: - sub_807ACFC(1, 0); + sub_807ACFC(TRADE_PARTNER, 0); gMain.state++; break; case 8: - sub_807ACFC(1, 1); + sub_807ACFC(TRADE_PARTNER, 1); sub_807B154(); gMain.state++; break; @@ -4302,8 +3145,8 @@ static void sub_807B270(void) switch (gMain.state) { case 0: - gUnknown_02032298[0] = gSpecialVar_0x8005; - gUnknown_02032298[1] = 6; + gSelectedTradeMonPositions[0] = gSpecialVar_0x8005; + gSelectedTradeMonPositions[1] = 6; StringCopy(gLinkPlayers[0].name, gSaveBlock2Ptr->playerName); GetMonData(&gEnemyParty[0], MON_DATA_OT_NAME, otName); StringCopy(gLinkPlayers[1].name, otName); @@ -4331,20 +3174,20 @@ static void sub_807B270(void) gMain.state = 5; break; case 5: - sub_807ACFC(0, 0); + sub_807ACFC(TRADE_PLAYER, 0); gMain.state++; break; case 6: - sub_807ACFC(0, 1); + sub_807ACFC(TRADE_PLAYER, 1); gMain.state++; break; case 7: - sub_807ACFC(1, 0); + sub_807ACFC(TRADE_PARTNER, 0); ShowBg(0); gMain.state++; break; case 8: - sub_807ACFC(1, 1); + sub_807ACFC(TRADE_PARTNER, 1); FillWindowPixelBuffer(0, PIXEL_FILL(15)); PutWindowTilemap(0); CopyWindowToVram(0, 3); @@ -4627,12 +3470,9 @@ static void sub_807BA94(void) LoadSpritePalette(&gUnknown_08338D80); } +/// Buffers "[Pokemon] will be sent to [Trainer]" strings static void SetTradeSceneStrings(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; @@ -4641,16 +3481,16 @@ static void SetTradeSceneStrings(void) { mpId = GetMultiplayerId(); StringCopy(gStringVar1, gLinkPlayers[mpId ^ 1].name); - GetMonData(&gEnemyParty[gUnknown_02032298[1] % PARTY_SIZE], MON_DATA_NICKNAME, name); + GetMonData(&gEnemyParty[gSelectedTradeMonPositions[1] % PARTY_SIZE], MON_DATA_NICKNAME, name); StringCopy10(gStringVar3, name); - GetMonData(&gPlayerParty[gUnknown_02032298[0]], MON_DATA_NICKNAME, name); + GetMonData(&gPlayerParty[gSelectedTradeMonPositions[0]], 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); } @@ -5128,10 +3968,10 @@ static bool8 sub_807BBEC(void) 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); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[0]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[0]); } gUnknown_020322A0->state++; break; @@ -5643,10 +4483,10 @@ static bool8 sub_807CFC8(void) 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); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[0]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[0]); } gUnknown_020322A0->state++; break; @@ -5686,14 +4526,14 @@ static void c2_08053788(void) break; case 4: gCB2_AfterEvolution = sub_807EB50; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gUnknown_02032298[0]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[0]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) - TradeEvolutionScene(&gPlayerParty[gUnknown_02032298[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gUnknown_02032298[0]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[0]); else if (sub_8077260()) SetMainCallback2(sub_807F464); else SetMainCallback2(sub_807EB50); - gUnknown_02032298[0] = 255; + gSelectedTradeMonPositions[0] = 255; break; } if (!HasLinkErrorOccurred()) @@ -5807,16 +4647,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) { 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 +4664,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 +4680,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); @@ -5907,7 +4747,7 @@ static void sub_807EA2C(void) { DestroySprite(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]]); FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]]); - sub_807B4D0(gUnknown_02032298[0], gUnknown_02032298[1] % 6); + sub_807B4D0(gSelectedTradeMonPositions[0], gSelectedTradeMonPositions[1] % PARTY_SIZE); if (!sub_8077260()) { gUnknown_020322A0->linkData[0] = 0xABCD; @@ -6154,7 +4994,7 @@ static void sub_807F14C(void) 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[1] % PARTY_SIZE], MON_DATA_CHAMPION_RIBBON + i); } if (numRibbons != 0) FlagSet(FLAG_SYS_RIBBON_GET); diff --git a/src/union_room.c b/src/union_room.c index 8ae111926..98efa61d5 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -2347,8 +2347,8 @@ void sub_8013F90(u8 taskId) { memcpy(gUnknown_020321C0, gBlockRecvBuffer[GetMultiplayerId() ^ 1], sizeof(struct MailStruct) * PARTY_SIZE); ResetBlockReceivedFlags(); - gUnknown_02032298[0] = monId; - gUnknown_02032298[1] = 6; + gSelectedTradeMonPositions[0] = monId; + gSelectedTradeMonPositions[1] = PARTY_SIZE; gMain.savedCallback = CB2_ReturnToField; SetMainCallback2(sub_807AE50); sub_801807C(&gUnknown_02022C40); From 4a7f06188557e4bbc7bdcfa6656d9e8dec29929a Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 3 Oct 2019 19:39:37 -0400 Subject: [PATCH 02/11] Document some of trade --- gflib/text.h | 13 +- include/constants/trade.h | 31 +- include/pokemon_icon.h | 2 +- include/trade.h | 3 +- src/cable_club.c | 8 +- src/data/trade.h | 133 +-- src/evolution_scene.c | 32 +- src/graphics.c | 6 +- src/party_menu.c | 10 +- src/pokemon_icon.c | 2 +- src/pokemon_storage_system.c | 12 +- src/trade.c | 1993 +++++++++++++++++----------------- src/union_room.c | 4 +- 13 files changed, 1147 insertions(+), 1102 deletions(-) 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/include/constants/trade.h b/include/constants/trade.h index 1afa3b263..a12ee7fca 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -3,11 +3,40 @@ #define TRADE_PLAYER 0 #define TRADE_PARTNER 1 -#define TRADE_PARTICIPANT_COUNT 2 #define INGAME_TRADE_SEEDOT 0 #define INGAME_TRADE_PLUSLE 1 #define INGAME_TRADE_HORSEA 2 #define INGAME_TRADE_MEOWTH 3 +#define INGAME_TRADE_MAIL_LENGTH 9 + +#define PLAYER_MON_INVALID 0 +#define PLAYER_MON_VALID 1 +#define PARTNER_MON_INVALID 2 + +#define MON_VALID 0 + + +#define TRADE_ACTION_TEXT_CANCEL 0 +#define TRADE_ACTION_TEXT_CHOOSE_MON 1 +#define TRADE_ACTION_TEXT_SUMMARY 2 +#define TRADE_ACTION_TEXT_TRADE 3 +#define TRADE_ACTION_TEXT_CANCEL_TRADE 4 +#define TRADE_ACTION_TEXT_JP_QUIT 5 + +#define MENU_ACTION_SUMMARY 0 +#define MENU_ACTION_TRADE 1 + +#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 + + #endif //GUARD_CONSTANTS_TRADE_H diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index 8af43c753..efc0028a1 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -22,7 +22,7 @@ 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 SetPartyHPBarSprite(struct Sprite *sprite, u8 animNum); u8 GetMonIconPaletteIndexFromSpecies(u16 species); #endif // GUARD_POKEMON_ICON_H diff --git a/include/trade.h b/include/trade.h index 861ac490d..218a5be2f 100644 --- a/include/trade.h +++ b/include/trade.h @@ -2,6 +2,7 @@ #define GUARD_TRADE_H #include "link_rfu.h" +#include "constants/trade.h" // Exported type declarations @@ -21,6 +22,6 @@ 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); +void DrawTextOnTradeWindow(u8, const u8 *, u8); #endif //GUARD_TRADE_H diff --git a/src/cable_club.c b/src/cable_club.c index ba051dbd2..53ad59533 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -1084,8 +1084,8 @@ static void sub_80B37FC(u8 taskId) task->data[0]++; break; case 2: - gSelectedTradeMonPositions[0] = 0; - gSelectedTradeMonPositions[1] = 0; + gSelectedTradeMonPositions[TRADE_PLAYER] = 0; + gSelectedTradeMonPositions[TRADE_PARTNER] = 0; m4aMPlayAllStop(); sub_800AC34(); task->data[0]++; @@ -1117,8 +1117,8 @@ static void sub_80B3894(u8 taskId) data[0]++; break; case 2: - gSelectedTradeMonPositions[0] = 0; - gSelectedTradeMonPositions[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 index 97e0cdfe1..adb7a3240 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -7,6 +7,7 @@ static const u32 sUnref_0832C6A8[] = 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"); @@ -24,19 +25,19 @@ 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."); +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 gOamData_832DC14 = { @@ -336,35 +337,41 @@ static const u8 sUnref_0832DE6E[] = 0x17, 0x0c }; -static const u8 *const gUnknown_0832DE94[] = +static const u8 *const sTradeActionTexts[] = { - gText_Cancel6, - gText_ChooseAPkmn, - gText_Summary3, - gText_Trade2, - gText_CancelTrade, - gJPText_832DB2E + [TRADE_ACTION_TEXT_CANCEL] = sText_Cancel, + [TRADE_ACTION_TEXT_CHOOSE_MON] = sText_ChooseAPkmn, + [TRADE_ACTION_TEXT_SUMMARY] = sText_Summary, + [TRADE_ACTION_TEXT_TRADE] = sText_Trade, + [TRADE_ACTION_TEXT_CANCEL_TRADE] = sText_CancelTrade, + [TRADE_ACTION_TEXT_JP_QUIT] = sJPText_PressBButtonToQuit }; -static const struct MenuAction gUnknown_0832DEAC[] = +static const struct MenuAction sSelectTradeMonActions[] = { - {gText_Summary4, sub_807A000}, - {gText_Trade3, sub_807A024} + [MENU_ACTION_SUMMARY] = {sText_Summary2, sub_807A000}, + [MENU_ACTION_TRADE] = {sText_Trade2, 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 *const sTradeMessageTexts[] = +{ + [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 gUnknown_0832DEE0[] = { 0, 1, 2 }; +static const u8 sTradeTextColors[] = +{ + TEXT_COLOR_TRANSPARENT, //bg color + TEXT_COLOR_WHITE, //fg color + TEXT_COLOR_DARK_GREY //shadow color +}; static const struct BgTemplate gUnknown_0832DEE4[] = { @@ -573,7 +580,7 @@ static const struct WindowTemplate gUnknown_0832DEF4[] = DUMMY_WIN_TEMPLATE, }; -static const struct WindowTemplate gUnknown_0832DF8C = +static const struct WindowTemplate sTradeYesNoWindowTemplate = { .bg = 0, .tilemapLeft = 23, @@ -584,7 +591,7 @@ static const struct WindowTemplate gUnknown_0832DF8C = .baseBlock = 582 }; -static const u8 gJPText_Shedinja[] = _("ヌケニン"); +static const u8 sJPText_Shedinja[] = _("ヌケニン"); static const u8 gUnknown_0832DF99[][2] = { {4, 3}, @@ -592,20 +599,20 @@ static const u8 gUnknown_0832DF99[][2] = {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 sTradePal_Ball[] = INCBIN_U16("graphics/trade/ball.gbapal"); +static const u8 sTradeGfx_Ball[] = INCBIN_U8("graphics/trade/ball.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 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"); +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 gUnknown_08332F60[] = INCBIN_U8("graphics/trade/gba_affine.8bpp"); static const u8 sFiller_08335760[64] = {}; @@ -614,11 +621,11 @@ static const u8 gUnknown_083358A0[] = INCBIN_U8("graphics/trade/gba_affine_map_w 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 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 gOamData_8338C44 = { @@ -700,14 +707,14 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D0C[] = static const struct SpriteSheet gUnknown_08338D18 = { - .data = gTradeBallTiles, + .data = sTradeGfx_Ball, .size = 0x600, .tag = 5557 }; static const struct SpritePalette gUnknown_08338D20 = { - .data = gTradeBallPalette, + .data = sTradePal_Ball, .tag = 5558 }; @@ -756,20 +763,20 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D6C[] = static const struct SpriteSheet gUnknown_08338D70 = { - .data = gTradeGlow1Tiles, + .data = sTradeGfx_Glow1, .size = 0x200, .tag = 5550 }; static const struct SpritePalette gUnknown_08338D78 = { - .data = gUnknown_08330940, + .data = sTradePal_Misc, .tag = 5551 }; static const struct SpritePalette gUnknown_08338D80 = { - .data = gUnknown_083308E0, + .data = sTradePal_Gba, .tag = 5555 }; @@ -811,7 +818,7 @@ static const union AnimCmd *const gSpriteAnimTable_8338DB8[] = static const struct SpriteSheet gUnknown_08338DC0 = { - .data = gTradeGlow2Tiles, + .data = sTradeGfx_Glow2, .size = 0x300, .tag = 5552 }; @@ -847,7 +854,7 @@ static const union AnimCmd *const gSpriteAnimTable_8338DF0[] = static const struct SpriteSheet gUnknown_08338DF4 = { - .data = gTradeCableEndTiles, + .data = sTradeGfx_CableEnd, .size = 0x100, .tag = 5554 }; @@ -908,7 +915,7 @@ static const union AnimCmd *const gSpriteAnimTable_8338E68[] = static const struct SpriteSheet gUnknown_08338E6C = { - .data = gTradeGBAScreenTiles, + .data = sTradeGfx_GbaScreen, .size = 0x1000, .tag = 5556 }; @@ -1016,7 +1023,7 @@ static const struct InGameTrade sIngameTrades[] = } }; -static const u16 gIngameTradeMail[][10] = +static const u16 sIngameTradeMail[][INGAME_TRADE_MAIL_LENGTH + 1] = { { EC_WORD_BE, diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 5ba979453..ec970d5e5 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -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++; @@ -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/graphics.c b/src/graphics.c index 77a12b081..99d9a22d9 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1516,17 +1516,13 @@ asm(".space 0x20"); //blank palette?? #include "data/graphics/berry_fix.h" -// more trade stuff? - +// Trade const u16 gTradeMenu_Pal[] = INCBIN_U16("graphics/trade/menu.gbapal"); const u16 gUnknown_08DDB444[] = INCBIN_U16("graphics/unknown/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 gMessageBox_Pal[] = INCBIN_U16("graphics/text_window/message_box.gbapal"); diff --git a/src/party_menu.c b/src/party_menu.c index b3938ef2a..827819ce0 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4983,19 +4983,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; } } diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c index ee68de326..ef1377a72 100644 --- a/src/pokemon_icon.c +++ b/src/pokemon_icon.c @@ -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..a1a614041 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1540,7 +1540,7 @@ 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 sub_80C6D80(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 arg4) { s32 i, val, val2; u16 windowId; @@ -1551,14 +1551,14 @@ 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[0] = zero2; txtColor[1] = 0xF; txtColor[2] = 0xE; AddTextPrinterParameterized4(windowId, 1, 0, 1, 0, 0, txtColor, -1, string); @@ -1580,7 +1580,7 @@ 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); + CpuFill16((zero2 << 4) | zero2, dst, (u32)(val2) * 0x100); RemoveWindow(windowId); } diff --git a/src/trade.c b/src/trade.c index 3c09fce41..0d6e59b06 100644 --- a/src/trade.c +++ b/src/trade.c @@ -52,8 +52,6 @@ #include "constants/rgb.h" #include "constants/species.h" #include "constants/songs.h" -#include "constants/trade.h" - #define Trade_SendData(ptr) (SendBlock(bitmask_all_link_players_but_self(), ptr->linkData, 20)) @@ -76,34 +74,34 @@ struct InGameTrade { 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 gSelectedTradeMonPositions[TRADE_PARTICIPANT_COUNT] = {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[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; - /*0x0034*/ u8 tradeMenuCursorSpriteIdx; - /*0x0035*/ u8 tradeMenuCursorPosition; - /*0x0036*/ u8 partyCounts[TRADE_PARTICIPANT_COUNT]; + /*0x0028*/ u8 partyIcons[2][PARTY_SIZE]; + /*0x0034*/ u8 cursorSpriteIdx; + /*0x0035*/ u8 cursorPosition; + /*0x0036*/ u8 partyCounts[2]; /*0x0038*/ bool8 tradeMenuOptionsActive[12]; /*0x0044*/ u8 neverRead_44; - /*0x0045*/ u8 unk_45[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; - /*0x0051*/ bool8 isEgg[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; - /*0x005D*/ u8 unk_5D[TRADE_PARTICIPANT_COUNT][PARTY_SIZE]; + /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; + /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; + /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; /*0x0069*/ u8 unk_69; /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; /*0x006F*/ u8 unk_6F; /*0x0070*/ u8 unk_70; /*0x0071*/ u8 filler_71; /*0x0072*/ u16 unk_72; - /*0x0074*/ u8 unk_74[TRADE_PARTICIPANT_COUNT]; - /*0x0076*/ u8 tradeMonIdx[TRADE_PARTICIPANT_COUNT]; + /*0x0074*/ u8 unk_74[2]; //state var for sub_80796B4 + /*0x0076*/ u8 selectedMonIdx[2]; /*0x0078*/ u8 unk_78; /*0x0079*/ u8 unk_79; /*0x007A*/ u8 unk_7A; /*0x007B*/ u8 unk_7B; /*0x007C*/ u8 filler_7C[0x7E - 0x7C]; - /*0x007E*/ u8 unk_7E; + /*0x007E*/ u8 partnerCursorPosition; /*0x007F*/ u8 filler_7F; /*0x0080*/ u16 linkData[20]; /*0x00A8*/ u8 unk_A8; @@ -112,10 +110,10 @@ static EWRAM_DATA struct { /*0x08D0*/ struct { bool8 unk_0; u16 unk_2; - u8 unk_4; + u8 monValidity; } unk_8D0[4]; /*0x08F0*/ u16 tilemapBuffer[0x400]; -} *gUnknown_0203229C = {NULL}; +} *sTradeMenuData = {NULL}; static EWRAM_DATA struct { /*0x00*/ struct Pokemon mon; /*0x64*/ u32 timer; @@ -153,14 +151,14 @@ static EWRAM_DATA struct { /*0xEE*/ bool8 isLinkTrade; /*0xF0*/ u16 tradeSpecies[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}; +} *sTradeData = {NULL}; #if !defined(NONMATCHING) && MODERN #define static @@ -174,11 +172,11 @@ 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 SetSelectedMon(u8); static void sub_80796B4(u8); static u8 sub_8079A3C(u8 *, u8, u8); static void BufferTradeMonMoves(u8 *, u8, u8); -static void sub_8079BE0(u8); +static void PrintPartyNicknamesForTradeMenu(u8); static void sub_8079C4C(u8, u8, u8, u8, u8, u8); static void sub_8079E44(u8); static void sub_8079F74(void); @@ -188,12 +186,12 @@ 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 void PrintTradeMessage(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 GetTradePartyHPBarLevels(u8); +static void SetTradePartyHPBarSprites(void); static void sub_807A5B0(void); static u32 sub_807A5F4(struct Pokemon *, int, int); static void sub_807AA28(struct Sprite *sprite); @@ -214,13 +212,13 @@ 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 SetInGameTradeMail(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 CheckPartnersMonForRibbons(void); static void c3_08054588(u8); static void c3_0805465C(u8); static void sub_807F39C(u8); @@ -228,16 +226,16 @@ static void sub_807F464(void); #include "data/trade.h" -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); } } @@ -330,7 +328,7 @@ static void sub_80772A4(void) LoadPalette(gUnknown_0860F074, 0xD0, 20); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_0832DEE4, ARRAY_COUNT(gUnknown_0832DEE4)); - SetBgTilemapBuffer(1, gUnknown_0203229C->tilemapBuffer); + SetBgTilemapBuffer(1, sTradeMenuData->tilemapBuffer); if (InitWindows(gUnknown_0832DEF4)) { @@ -348,14 +346,14 @@ 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[TRADE_PLAYER] = 0; - gUnknown_0203229C->unk_74[TRADE_PARTNER] = 0; - gUnknown_0203229C->unk_7A = 0; - gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_69 = 0; + sTradeMenuData->unk_6F = 0; + sTradeMenuData->unk_70 = 0; + sTradeMenuData->unk_74[TRADE_PLAYER] = 0; + sTradeMenuData->unk_74[TRADE_PARTNER] = 0; + sTradeMenuData->unk_7A = 0; + sTradeMenuData->unk_7B = 0; + sTradeMenuData->unk_A8 = 0; } } @@ -376,9 +374,9 @@ static void sub_80773D0(void) switch (gMain.state) { case 0: - gUnknown_0203229C = AllocZeroed(sizeof(*gUnknown_0203229C)); + sTradeMenuData = AllocZeroed(sizeof(*sTradeMenuData)); sub_80772A4(); - gUnknown_02032184 = AllocZeroed(0xE00); + gUnknown_02032184 = AllocZeroed(14 * 256); for (i = 0; i < 14; i++) { @@ -395,13 +393,13 @@ static void sub_80773D0(void) CreateMon(&gEnemyParty[i], SPECIES_NONE, 0, 0x20, FALSE, 0, OT_ID_PLAYER_ID, 0); } - sub_807A19C(0); + PrintTradeMessage(TRADE_MSG_STANDBY); ShowBg(0); if (!gReceivedRemoteLinkPlayers) { gLinkType = 0x1122; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; if (gWirelessCommType) { @@ -422,10 +420,10 @@ static void sub_80773D0(void) } break; case 2: - gUnknown_0203229C->unk_A8++; - if (gUnknown_0203229C->unk_A8 > 11) + sTradeMenuData->unk_A8++; + if (sTradeMenuData->unk_A8 > 11) { - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; gMain.state++; } break; @@ -434,7 +432,7 @@ static void sub_80773D0(void) { if (IsLinkMaster()) { - if (++gUnknown_0203229C->unk_A8 > 30) + if (++sTradeMenuData->unk_A8 > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -452,7 +450,7 @@ static void sub_80773D0(void) sub_8011BD0(); CalculatePlayerPartyCount(); gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; if (gWirelessCommType) { sub_801048C(TRUE); @@ -486,13 +484,13 @@ 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[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + sTradeMenuData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -501,10 +499,10 @@ static void sub_80773D0(void) 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[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenuData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -516,21 +514,21 @@ static void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 0); + sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 0); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 1); + sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 1); gMain.state++; break; case 10: sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[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); + sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], gUnknown_02032188[6], 0, 0, 2); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], gUnknown_02032188[8], 24); gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; break; case 11: if (sub_807A1F0()) @@ -569,23 +567,23 @@ 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, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); + sTradeMenuData->cursorPosition = 0; gMain.state++; rbox_fill_rectangle(0); break; case 14: sub_807A320(TRADE_PLAYER); - sub_8079BE0(TRADE_PLAYER); - gUnknown_0203229C->unk_0 = 0; - gUnknown_0203229C->unk_1 = 0; + PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); + sTradeMenuData->bg2hofs = 0; + sTradeMenuData->bg3hofs = 0; sub_8078388(); gMain.state++; PlayBGM(MUS_P_SCHOOL); break; case 15: sub_807A320(TRADE_PARTNER); - sub_8079BE0(TRADE_PARTNER); + PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); gMain.state++; // fallthrough case 16: @@ -606,12 +604,12 @@ static void sub_80773D0(void) 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: @@ -645,7 +643,7 @@ static void sub_8077B74(void) break; case 1: gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; break; case 2: gMain.state++; @@ -670,16 +668,16 @@ 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(TRADE_PLAYER); - sub_8079BE0(TRADE_PARTNER); + 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[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenuData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -688,10 +686,10 @@ static void sub_8077B74(void) 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[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenuData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -703,21 +701,21 @@ static void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 0); + sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 0); gMain.state++; break; case 9: - sub_81B5D4C(&gUnknown_0203229C->partyCounts[0], gUnknown_0203229C->partyIcons[TRADE_PLAYER], 1); + sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 1); gMain.state++; break; case 10: sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[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); + sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], gUnknown_02032188[6], 0, 0, 2); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], gUnknown_02032188[8], 24); gMain.state++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; break; case 11: if (sub_807A1F0()) @@ -756,12 +754,12 @@ 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, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][1] * 8, 2); gMain.state = 16; break; case 16: @@ -770,8 +768,8 @@ static void sub_8077B74(void) break; case 17: sub_80782B8(1); - gUnknown_0203229C->unk_0 = 0; - gUnknown_0203229C->unk_1 = 0; + sTradeMenuData->bg2hofs = 0; + sTradeMenuData->bg3hofs = 0; sub_8078388(); gMain.state++; break; @@ -790,7 +788,7 @@ static void sub_8077B74(void) gMain.state++; break; case 21: - sub_807A53C(); + SetTradePartyHPBarSprites(); gMain.state++; break; case 22: @@ -816,10 +814,10 @@ static void sub_807811C(void) static void sub_8078130(void) { - if (++gUnknown_0203229C->unk_A8 > 15) + if (++sTradeMenuData->unk_A8 > 15) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 10; + sTradeMenuData->unk_6F = 10; } } @@ -827,17 +825,17 @@ static void sub_807816C(void) { if (!gPaletteFade.active) { - gSelectedTradeMonPositions[0] = gUnknown_0203229C->tradeMenuCursorPosition; - gSelectedTradeMonPositions[1] = gUnknown_0203229C->unk_7E; + gSelectedTradeMonPositions[TRADE_PLAYER] = sTradeMenuData->cursorPosition; + gSelectedTradeMonPositions[TRADE_PARTNER] = sTradeMenuData->partnerCursorPosition; if (gWirelessCommType) { - gUnknown_0203229C->unk_6F = 16; + sTradeMenuData->unk_6F = 16; } else { sub_800ABF4(32); - gUnknown_0203229C->unk_6F = 13; + sTradeMenuData->unk_6F = 13; } } } @@ -852,7 +850,7 @@ static void sub_80781C8(void) { Free(gUnknown_02032184); FreeAllWindowBuffers(); - Free(gUnknown_0203229C); + Free(sTradeMenuData); gMain.callback1 = NULL; DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(sub_807AE50); @@ -864,7 +862,7 @@ static void sub_80781C8(void) { Free(gUnknown_02032184); FreeAllWindowBuffers(); - Free(gUnknown_0203229C); + Free(sTradeMenuData); gMain.callback1 = NULL; SetMainCallback2(sub_807AE50); } @@ -880,8 +878,8 @@ static void sub_807825C(void) sub_80796B4(TRADE_PLAYER); sub_80796B4(TRADE_PARTNER); - 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(); @@ -927,28 +925,28 @@ static void sub_8078388(void) for (i = 0; i < PARTY_SIZE; i++) { - if (i < gUnknown_0203229C->partyCounts[0]) + if (i < sTradeMenuData->partyCounts[TRADE_PLAYER]) { - gSprites[gUnknown_0203229C->partyIcons[TRADE_PLAYER][i]].invisible = FALSE; - gUnknown_0203229C->tradeMenuOptionsActive[i] = TRUE; + gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][i]].invisible = FALSE; + sTradeMenuData->tradeMenuOptionsActive[i] = TRUE; } else { - gUnknown_0203229C->tradeMenuOptionsActive[i] = FALSE; + sTradeMenuData->tradeMenuOptionsActive[i] = FALSE; } - if (i < gUnknown_0203229C->partyCounts[1]) + if (i < sTradeMenuData->partyCounts[TRADE_PARTNER]) { - gSprites[gUnknown_0203229C->partyIcons[TRADE_PARTNER][i]].invisible = FALSE; - gUnknown_0203229C->tradeMenuOptionsActive[i + PARTY_SIZE] = TRUE; + gSprites[sTradeMenuData->partyIcons[TRADE_PARTNER][i]].invisible = FALSE; + sTradeMenuData->tradeMenuOptionsActive[i + PARTY_SIZE] = TRUE; } else { - gUnknown_0203229C->tradeMenuOptionsActive[i + PARTY_SIZE] = FALSE; + sTradeMenuData->tradeMenuOptionsActive[i + PARTY_SIZE] = FALSE; } } - gUnknown_0203229C->neverRead_44 = 1; + sTradeMenuData->neverRead_44 = 1; } // why not just use memcpy? @@ -970,24 +968,24 @@ static bool8 shedinja_maker_maybe(void) int i; struct Pokemon *mon; - switch (gUnknown_0203229C->unk_69) + switch (sTradeMenuData->unk_69) { case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); - gUnknown_0203229C->unk_69++; - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_69++; + sTradeMenuData->unk_A8 = 0; break; case 1: if (sub_80771BC()) { if (_GetBlockReceivedStatus() == 0) { - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } else { sub_8077210(); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } } break; @@ -996,90 +994,90 @@ static bool8 shedinja_maker_maybe(void) { sub_80771AC(1); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 4: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon)); sub_8077210(); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } break; case 5: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon)); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 7: if (id == 0) { sub_80771AC(1); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 8: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200); sub_8077210(); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } break; case 9: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 11: if (id == 0) { sub_80771AC(1); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 12: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200); sub_8077210(); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } break; case 13: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 15: if (id == 0) { sub_80771AC(3); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 16: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(gUnknown_020321C0, gBlockRecvBuffer[id ^ 1], 216); sub_8077210(); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } break; case 17: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, 11); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 19: if (id == 0) { sub_80771AC(4); } - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; break; case 20: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(gUnknown_0203229C->unk_A9, gBlockRecvBuffer[id ^ 1], 11); + Trade_Memcpy(sTradeMenuData->unk_A9, gBlockRecvBuffer[id ^ 1], 11); sub_8077210(); - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_69++; } break; case 21: @@ -1094,7 +1092,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]); } @@ -1107,11 +1105,11 @@ static bool8 shedinja_maker_maybe(void) case 10: case 14: case 18: - gUnknown_0203229C->unk_A8++; - if (gUnknown_0203229C->unk_A8 > 10) + sTradeMenuData->unk_A8++; + if (sTradeMenuData->unk_A8 > 10) { - gUnknown_0203229C->unk_A8 = 0; - gUnknown_0203229C->unk_69++; + sTradeMenuData->unk_A8 = 0; + sTradeMenuData->unk_69++; } break; } @@ -1120,7 +1118,7 @@ static bool8 shedinja_maker_maybe(void) static void sub_80787B8(void) { - sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (gUnknown_0203229C->unk_72 * 32)), 24); + sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); } static void sub_80787E0(u8 a0, u8 a1) @@ -1130,16 +1128,16 @@ static void sub_80787E0(u8 a0, u8 a1) switch (gBlockRecvBuffer[0][0]) { case 0xEEAA: - gUnknown_0203229C->unk_78 = 2; + sTradeMenuData->unk_78 = 2; break; case 0xAABB: - gUnknown_0203229C->unk_78 = 1; + sTradeMenuData->unk_78 = 1; break; case 0xBBBB: - gUnknown_0203229C->unk_7A = 1; + sTradeMenuData->unk_7A = 1; break; case 0xBBCC: - gUnknown_0203229C->unk_7A = 2; + sTradeMenuData->unk_7A = 2; break; } sub_8077234(0); @@ -1150,17 +1148,17 @@ static void sub_80787E0(u8 a0, u8 a1) switch (gBlockRecvBuffer[1][0]) { case 0xEEAA: - gUnknown_0203229C->unk_79 = 2; + sTradeMenuData->unk_79 = 2; break; case 0xAABB: - gUnknown_0203229C->unk_7E = gBlockRecvBuffer[1][1] + 6; - gUnknown_0203229C->unk_79 = 1; + sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; + sTradeMenuData->unk_79 = 1; break; case 0xBBBB: - gUnknown_0203229C->unk_7B = 1; + sTradeMenuData->unk_7B = 1; break; case 0xBBCC: - gUnknown_0203229C->unk_7B = 2; + sTradeMenuData->unk_7B = 2; break; } sub_8077234(1); @@ -1175,27 +1173,27 @@ static void sub_8078900(u8 a0, u8 a1) { case 0xEEBB: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sub_807A19C(4); - gUnknown_0203229C->unk_6F = 11; + PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); + sTradeMenuData->unk_6F = 11; break; case 0xEECC: - sub_807A19C(5); - gUnknown_0203229C->unk_6F = 8; + PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); + sTradeMenuData->unk_6F = 8; break; case 0xDDDD: - gUnknown_0203229C->unk_7E = gBlockRecvBuffer[0][1] + 6; + 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->unk_6F = 7; break; case 0xCCDD: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 10; + sTradeMenuData->unk_6F = 10; break; case 0xDDEE: - sub_807A19C(1); - gUnknown_0203229C->unk_6F = 8; + PrintTradeMessage(TRADE_MSG_CANCELED); + sTradeMenuData->unk_6F = 8; } sub_8077234(0); } @@ -1206,82 +1204,82 @@ static void sub_8078900(u8 a0, u8 a1) static void sub_80789FC(void) { - if (gUnknown_0203229C->unk_78 && gUnknown_0203229C->unk_79) + if (sTradeMenuData->unk_78 && sTradeMenuData->unk_79) { - if (gUnknown_0203229C->unk_78 == 1 && gUnknown_0203229C->unk_79 == 1) + if (sTradeMenuData->unk_78 == 1 && sTradeMenuData->unk_79 == 1) { - gUnknown_0203229C->unk_6F = 6; - gUnknown_0203229C->linkData[0] = 0xDDDD; - gUnknown_0203229C->linkData[1] = gUnknown_0203229C->tradeMenuCursorPosition; + sTradeMenuData->unk_6F = 6; + sTradeMenuData->linkData[0] = 0xDDDD; + sTradeMenuData->linkData[1] = sTradeMenuData->cursorPosition; sub_807A048(5, 0); - gUnknown_0203229C->unk_78 = gUnknown_0203229C->unk_79 = 0; + sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; } - else if (gUnknown_0203229C->unk_78 == 1 && gUnknown_0203229C->unk_79 == 2) + else if (sTradeMenuData->unk_78 == 1 && sTradeMenuData->unk_79 == 2) { - sub_807A19C(1); - gUnknown_0203229C->linkData[0] = 0xEECC; - gUnknown_0203229C->linkData[1] = 0; + PrintTradeMessage(TRADE_MSG_CANCELED); + sTradeMenuData->linkData[0] = 0xEECC; + sTradeMenuData->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; + sTradeMenuData->unk_7A = sTradeMenuData->unk_7B = 0; + sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; + sTradeMenuData->unk_6F = 8; } - else if (gUnknown_0203229C->unk_78 == 2 && gUnknown_0203229C->unk_79 == 1) + else if (sTradeMenuData->unk_78 == 2 && sTradeMenuData->unk_79 == 1) { - sub_807A19C(5); - gUnknown_0203229C->linkData[0] = 0xDDEE; - gUnknown_0203229C->linkData[1] = 0; + PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); + sTradeMenuData->linkData[0] = 0xDDEE; + sTradeMenuData->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; + sTradeMenuData->unk_7A = sTradeMenuData->unk_7B = 0; + sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; + sTradeMenuData->unk_6F = 8; } - else if (gUnknown_0203229C->unk_78 == 2 && gUnknown_0203229C->unk_79 == 2) + else if (sTradeMenuData->unk_78 == 2 && sTradeMenuData->unk_79 == 2) { - gUnknown_0203229C->linkData[0] = 0xEEBB; - gUnknown_0203229C->linkData[1] = 0; + sTradeMenuData->linkData[0] = 0xEEBB; + sTradeMenuData->linkData[1] = 0; sub_807A048(5, 0); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_78 = gUnknown_0203229C->unk_79 = 0; - gUnknown_0203229C->unk_6F = 11; + sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; + sTradeMenuData->unk_6F = 11; } } - if (gUnknown_0203229C->unk_7A && gUnknown_0203229C->unk_7B) + if (sTradeMenuData->unk_7A && sTradeMenuData->unk_7B) { - if (gUnknown_0203229C->unk_7A == 1 && gUnknown_0203229C->unk_7B == 1) + if (sTradeMenuData->unk_7A == 1 && sTradeMenuData->unk_7B == 1) { - gUnknown_0203229C->linkData[0] = 0xCCDD; - gUnknown_0203229C->linkData[1] = 0; + sTradeMenuData->linkData[0] = 0xCCDD; + sTradeMenuData->linkData[1] = 0; sub_807A048(5, 0); - gUnknown_0203229C->unk_7A = 0; - gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_6F = 9; + sTradeMenuData->unk_7A = 0; + sTradeMenuData->unk_7B = 0; + sTradeMenuData->unk_6F = 9; } - if (gUnknown_0203229C->unk_7A == 2 || gUnknown_0203229C->unk_7B == 2) + if (sTradeMenuData->unk_7A == 2 || sTradeMenuData->unk_7B == 2) { - sub_807A19C(1); - gUnknown_0203229C->linkData[0] = 0xDDEE; - gUnknown_0203229C->linkData[1] = 0; + PrintTradeMessage(TRADE_MSG_CANCELED); + sTradeMenuData->linkData[0] = 0xDDEE; + sTradeMenuData->linkData[1] = 0; sub_807A048(5, 0); - gUnknown_0203229C->unk_7A = 0; - gUnknown_0203229C->unk_7B = 0; - gUnknown_0203229C->unk_6F = 8; + sTradeMenuData->unk_7A = 0; + sTradeMenuData->unk_7B = 0; + sTradeMenuData->unk_6F = 8; } } } -static void sub_8078BFC(u16 *a0, u16 a1, u16 a2) +static void sub_8078BFC(u16 *linkData, u16 linkFlag, u16 cursorPosition) { - a0[0] = a1; - a0[1] = a2; + linkData[0] = linkFlag; + linkData[1] = cursorPosition; sub_807A048(5, 0); } -static void sub_8078C10(u16 a0, u16 a1) +static void SetLinkData(u16 linkFlag, u16 cursorPosition) { - sub_8078BFC(gUnknown_0203229C->linkData, a0, a1); + sub_8078BFC(sTradeMenuData->linkData, linkFlag, cursorPosition); } static void sub_8078C34(void) @@ -1308,7 +1306,7 @@ static u8 sub_8078C6C(u8 oldPosition, u8 direction) for (i = 0; i < PARTY_SIZE; i++) { - if (gUnknown_0203229C->tradeMenuOptionsActive[gTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) + if (sTradeMenuData->tradeMenuOptionsActive[gTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) { newPosition = gTradeNextSelectedMonTable[oldPosition][direction][i]; break; @@ -1318,43 +1316,43 @@ 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 = sub_8078C6C(*cursorPosition, direction); if (newPosition == 12) // 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 = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; } - if (*tradeMenuCursorPosition != newPosition) + if (*cursorPosition != newPosition) { PlaySE(SE_SELECT); } - *tradeMenuCursorPosition = newPosition; + *cursorPosition = newPosition; } static void sub_8078D78(void) { - sub_807A19C(0); - gUnknown_0203229C->unk_6F = 100; + PrintTradeMessage(TRADE_MSG_STANDBY); + sTradeMenuData->unk_6F = 100; if (GetMultiplayerId() == 1) { - sub_8078C10(0xAABB, gUnknown_0203229C->tradeMenuCursorPosition); + SetLinkData(0xAABB, sTradeMenuData->cursorPosition); } else { - gUnknown_0203229C->unk_78 = 1; + sTradeMenuData->unk_78 = 1; } } @@ -1362,45 +1360,48 @@ static void sub_8078DBC(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->unk_6F = 1; } - 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->unk_6F = 2; } - 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->unk_6F = 4; + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); } } } @@ -1408,12 +1409,12 @@ static void sub_8078DBC(void) static void sub_8078EF8(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); + sTradeMenuData->unk_6F = 0; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); } -static void sub_8078F50(void) +static void TradeMenuProcessInput_SelectedMon(void) { switch (Menu_ProcessInputNoWrap()) { @@ -1423,30 +1424,30 @@ static void sub_8078F50(void) break; case MENU_NOTHING_CHOSEN: break; - case 0: + case MENU_ACTION_SUMMARY: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_0203229C->unk_6F = 2; + sTradeMenuData->unk_6F = 2; break; - case 1: - switch (sub_807A5F4(gPlayerParty, gPlayerPartyCount, gUnknown_0203229C->tradeMenuCursorPosition)) + case MENU_ACTION_TRADE: + switch (sub_807A5F4(gPlayerParty, gPlayerPartyCount, sTradeMenuData->cursorPosition)) { case 0: sub_8078D78(); - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = TRUE; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; break; case 1: sub_807A048(3, 3); - gUnknown_0203229C->unk_6F = 8; + sTradeMenuData->unk_6F = 8; break; case 2: case 4: sub_807A048(3, 6); - gUnknown_0203229C->unk_6F = 8; + sTradeMenuData->unk_6F = 8; break; case 3: case 5: sub_807A048(3, 7); - gUnknown_0203229C->unk_6F = 8; + sTradeMenuData->unk_6F = 8; break; } break; @@ -1466,80 +1467,82 @@ static void sub_807905C(void) { if (!gPaletteFade.active) { - if (gUnknown_0203229C->tradeMenuCursorPosition < PARTY_SIZE) + if (sTradeMenuData->cursorPosition < PARTY_SIZE) { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, gUnknown_0203229C->tradeMenuCursorPosition, gUnknown_0203229C->partyCounts[0] - 1, sub_8077B74); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, sTradeMenuData->cursorPosition, sTradeMenuData->partyCounts[TRADE_PLAYER] - 1, sub_8077B74); } 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, sub_8077B74); } 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; + 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) + if (playerMonIdx != i) { - res += a0[i]; + hasLiveMon += aliveMons[i]; } } + partnerMonIdx %= PARTY_SIZE; + species = GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_SPECIES); - a3 %= PARTY_SIZE; - species = GetMonData(&gEnemyParty[a3], MON_DATA_SPECIES); - + // Partner cant trade illegitimate Deoxys or Mew if (species == SPECIES_DEOXYS || species == SPECIES_MEW) { - if (!GetMonData(&gEnemyParty[a3], MON_DATA_OBEDIENCE)) + if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_OBEDIENCE)) { - return 2; + return PARTNER_MON_INVALID; } } + // Partner cant trade Egg or non-Hoenn mon if player doesn't have National Dex if (!IsNationalPokedexEnabled()) { - if (gUnknown_0203229C->isEgg[TRADE_PARTNER][a3] || !IsSpeciesInHoennDex(species)) + if (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) { - return 2; + return PARTNER_MON_INVALID; } } - if (res) + if (hasLiveMon) { - res = 1; + hasLiveMon = PLAYER_MON_VALID; } - return res; + return hasLiveMon; //PLAYER_MON_INVALID or PLAYER_MON_VALID } static bool32 sub_8079174(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: + case PLAYER_MON_INVALID: sub_807A048(3, 3); - sub_8078C10(0xBBCC, 0); + SetLinkData(0xBBCC, 0); break; - case 1: + case PLAYER_MON_VALID: sub_807A048(3, 1); - sub_8078C10(0xBBBB, 0); + SetLinkData(0xBBBB, 0); break; - case 2: + case PARTNER_MON_INVALID: sub_807A048(3, 8); return TRUE; } @@ -1554,11 +1557,11 @@ static void sub_8079218(void) case 0: if (!sub_8079174()) { - gUnknown_0203229C->unk_6F = 100; + sTradeMenuData->unk_6F = 100; } else { - gUnknown_0203229C->unk_6F = 17; + sTradeMenuData->unk_6F = 17; } PutWindowTilemap(17); break; @@ -1566,8 +1569,8 @@ static void sub_8079218(void) case MENU_B_PRESSED: sub_807A048(3, 1); if (sub_80771BC()) - sub_8078C10(0xBBCC, 0); - gUnknown_0203229C->unk_6F = 100; + SetLinkData(0xBBCC, 0); + sTradeMenuData->unk_6F = 100; PutWindowTilemap(17); break; } @@ -1577,7 +1580,7 @@ static void sub_807929C(void) { int i; - for (i = 0; i < gUnknown_0203229C->partyCounts[1] - 4; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER] - 4; i++) { PutWindowTilemap(i + 12); CopyWindowToVram(i + 12, 1); @@ -1589,10 +1592,10 @@ static void sub_80792E4(void) switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: - sub_807A19C(4); - sub_8078C10(0xEEAA, 0); - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = TRUE; - gUnknown_0203229C->unk_6F = 100; + PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); + SetLinkData(0xEEAA, 0); + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; + sTradeMenuData->unk_6F = 100; sub_807929C(); break; case 1: @@ -1608,31 +1611,31 @@ static void sub_807935C(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->unk_6F = 7; } static void sub_8079398(void) { - if (gUnknown_0203229C->unk_74[TRADE_PLAYER] == 5 - && gUnknown_0203229C->unk_74[TRADE_PARTNER] == 5) + if (sTradeMenuData->unk_74[TRADE_PLAYER] == 5 + && sTradeMenuData->unk_74[TRADE_PARTNER] == 5) { sub_80787B8(); - gUnknown_0203229C->unk_6F = 14; + sTradeMenuData->unk_6F = 14; } } static void Wait2SecondsAndCreateYesNoMenu(void) { - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_A8++; - if (gUnknown_0203229C->unk_A8 > 120) + if (sTradeMenuData->unk_A8 > 120) { - CreateYesNoMenu(&gUnknown_0832DF8C, 1, 14, 0); - gUnknown_0203229C->unk_A8 = 0; - gUnknown_0203229C->unk_6F = 3; + CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); + sTradeMenuData->unk_A8 = 0; + sTradeMenuData->unk_6F = 3; } } @@ -1654,8 +1657,8 @@ static void sub_8079408(void) sub_8079F88(TRADE_PLAYER); sub_8079F88(TRADE_PARTNER); - gUnknown_0203229C->unk_6F = 0; - gSprites[gUnknown_0203229C->tradeMenuCursorSpriteIdx].invisible = FALSE; + sTradeMenuData->unk_6F = 0; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; } } @@ -1672,7 +1675,7 @@ static void sub_8079490(void) sub_800ABF4(12); } - gUnknown_0203229C->unk_6F = 12; + sTradeMenuData->unk_6F = 12; } } @@ -1683,7 +1686,7 @@ static void sub_80794CC(void) if (sub_80771BC() && sub_807A09C() == 0) { Free(gUnknown_02032184); - Free(gUnknown_0203229C); + Free(sTradeMenuData); FreeAllWindowBuffers(); DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); @@ -1694,7 +1697,7 @@ static void sub_80794CC(void) if (!gReceivedRemoteLinkPlayers) { Free(gUnknown_02032184); - Free(gUnknown_0203229C); + Free(sTradeMenuData); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); } @@ -1706,7 +1709,7 @@ static void sub_8079550(void) if (!sub_801048C(FALSE) && sub_807A09C() == 0) { sub_800ADF8(); - gUnknown_0203229C->unk_6F = 13; + sTradeMenuData->unk_6F = 13; } } @@ -1714,20 +1717,21 @@ static void sub_807957C(void) { if (gMain.newKeys & A_BUTTON) { - sub_8078C10(0xBBCC, 0); - gUnknown_0203229C->unk_6F = 100; + SetLinkData(0xBBCC, 0); + sTradeMenuData->unk_6F = 100; } } +//TODO: static void sub_80795AC(void) { - switch (gUnknown_0203229C->unk_6F) + switch (sTradeMenuData->unk_6F) { case 0: sub_8078DBC(); break; case 1: - sub_8078F50(); + TradeMenuProcessInput_SelectedMon(); break; case 2: sub_807905C(); @@ -1777,15 +1781,15 @@ static void sub_80795AC(void) } } -static void sub_807967C(u8 monIdx) +static void SetSelectedMon(u8 cursorPosition) { - //monIdx 0-5 are the player's mons, 6-11 are the partner's - u8 whichParty = monIdx / 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->unk_74[whichParty] == 0) { - gUnknown_0203229C->unk_74[whichParty] = 1; - gUnknown_0203229C->tradeMonIdx[whichParty] = monIdx; + sTradeMenuData->unk_74[whichParty] = 1; + sTradeMenuData->selectedMonIdx[whichParty] = cursorPosition; } } @@ -1797,34 +1801,34 @@ static void sub_80796B4(u8 a0) u8 i; u8 partyIdx; u8 whichParty; - u8 monIdx = gUnknown_0203229C->tradeMonIdx[a0]; + u8 selectedMonIdx = sTradeMenuData->selectedMonIdx[a0]; whichParty = TRADE_PARTNER; - if (gUnknown_0203229C->tradeMonIdx[a0] < PARTY_SIZE) + if (sTradeMenuData->selectedMonIdx[a0] < PARTY_SIZE) whichParty = TRADE_PLAYER; - partyIdx = monIdx % PARTY_SIZE; + partyIdx = selectedMonIdx % PARTY_SIZE; nameStringWidth = 0; - switch (gUnknown_0203229C->unk_74[a0]) + switch (sTradeMenuData->unk_74[a0]) { case 1: - for (i = 0; i < gUnknown_0203229C->partyCounts[a0]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[a0]; i++) { - gSprites[gUnknown_0203229C->partyIcons[0][i + (whichParty * PARTY_SIZE)]].invisible = TRUE; + gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][i + (whichParty * PARTY_SIZE)]].invisible = TRUE; } for (i = 0; i < 6; i++) { - ClearWindowTilemap(i + (a0 * 6 + 2)); + ClearWindowTilemap(i + (a0 * 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)]]); + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].invisible = FALSE; + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[0] = 20; + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12; + StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][partyIdx + (whichParty * PARTY_SIZE)]], sub_80D3014); + sTradeMenuData->unk_74[a0]++; + sub_80A6DEC(&gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][partyIdx + (whichParty * PARTY_SIZE)]]); CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, a0 * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); @@ -1833,29 +1837,29 @@ static void sub_80796B4(u8 a0) sub_8079F74(); 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->partyIcons[TRADE_PLAYER][partyIdx + (whichParty * PARTY_SIZE)]].callback == sub_80D3014) + sTradeMenuData->unk_74[a0] = 3; break; case 3: CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, whichParty * 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; + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12; + gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.x = 0; + gSprites[sTradeMenuData->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); + AddTextPrinterParameterized3((a0 * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, sTradeTextColors, 0, nickname); BufferTradeMonMoves(movesString, whichParty, partyIdx); - AddTextPrinterParameterized4((a0 * 2) + 15, 1, 0, 0, 0, 0, gUnknown_0832DEE0, 0, movesString); + AddTextPrinterParameterized4((a0 * 2) + 15, 1, 0, 0, 0, 0, sTradeTextColors, 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]++; + sTradeMenuData->unk_74[a0]++; 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]++; + sTradeMenuData->unk_74[a0]++; break; } } @@ -1878,7 +1882,7 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) u16 moves[MAX_MON_MOVES]; u16 i; - if (!gUnknown_0203229C->isEgg[whichParty][partyIdx]) + if (!sTradeMenuData->isEgg[whichParty][partyIdx]) { for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1911,39 +1915,39 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) } } -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 == TRADE_PLAYER ? 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 sub_8079C4C(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 width, u8 height) { u8 level; u32 r2; u8 gender; u8 nickname[12]; - CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDD704, a4, a5, 6, 3, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDD704, width, height, 6, 3, 0); CopyBgTilemapBufferToVram(1); if (whichParty == TRADE_PLAYER) @@ -1951,20 +1955,20 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5) else level = GetMonData(&gEnemyParty[monIdx], MON_DATA_LEVEL, NULL); - if (!gUnknown_0203229C->isEgg[whichParty][monIdx]) + 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->isEgg[whichParty][monIdx]) + if (sTradeMenuData->isEgg[whichParty][monIdx]) { r2 = 0x480; } @@ -1994,7 +1998,7 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 a2, u8 a3, u8 a4, u8 a5) break; } } - gUnknown_0203229C->tilemapBuffer[(a3 - 1) * 32 + a2 + 1] = r2; + sTradeMenuData->tilemapBuffer[(y - 1) * 32 + x + 1] = r2; } // Very close but loop preamble not working. @@ -2003,7 +2007,7 @@ static void sub_8079E44(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]); } @@ -2017,7 +2021,7 @@ static void sub_8079E44(u8 whichParty) 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\ @@ -2045,7 +2049,7 @@ _08079E6A:\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\ @@ -2065,31 +2069,31 @@ static void sub_8079EA8(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->partyIcons[whichParty][i]].invisible = FALSE; + gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; + gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; + gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos2.x = 0; + gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos2.y = 0; } } static void sub_8079F74(void) { rbox_fill_rectangle(1); - sub_8079BE0(TRADE_PARTNER); + PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); } -static void sub_8079F88(u8 a0) +static void sub_8079F88(u8 whichParty) { - CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, a0 * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, 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; + sub_8079E44(whichParty); + PrintPartyNicknamesForTradeMenu(whichParty); + sub_8079EA8(whichParty); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); + sTradeMenuData->unk_74[whichParty] = 0; } static void sub_807A000(u8 taskId) @@ -2104,17 +2108,18 @@ static void sub_807A024(u8 taskId) CopyBgTilemapBufferToVram(0); } -static void sub_807A048(u16 a0, u8 a1) +//TODO: a1 here is the case var for the switch in sub_807A0C4 +static void sub_807A048(u16 a0, u8 validity) { int i; for (i = 0; i < 4; i++) { - if (!gUnknown_0203229C->unk_8D0[i].unk_0) + if (sTradeMenuData->unk_8D0[i].unk_0 == FALSE) { - 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->unk_8D0[i].unk_2 = a0; //TODO: always 3 or 5 + sTradeMenuData->unk_8D0[i].monValidity = validity; + sTradeMenuData->unk_8D0[i].unk_0 = TRUE; break; } } @@ -2127,7 +2132,7 @@ static u32 sub_807A09C(void) for (i = 0; i < 4; i++) { - acc += gUnknown_0203229C->unk_8D0[i].unk_0; + acc += sTradeMenuData->unk_8D0[i].unk_0; } return acc; @@ -2139,50 +2144,50 @@ static void sub_807A0C4(void) for (i = 0; i < 4; i++) { - if (gUnknown_0203229C->unk_8D0[i].unk_0) + if (sTradeMenuData->unk_8D0[i].unk_0) { - if (gUnknown_0203229C->unk_8D0[i].unk_2) + if (sTradeMenuData->unk_8D0[i].unk_2) { - gUnknown_0203229C->unk_8D0[i].unk_2--; + sTradeMenuData->unk_8D0[i].unk_2--; } else { - switch (gUnknown_0203229C->unk_8D0[i].unk_4) + switch (sTradeMenuData->unk_8D0[i].monValidity) { case 0: - sub_8077170(gUnknown_0203229C->linkData, 20); + SendLinkData(sTradeMenuData->linkData, 20); break; case 1: - sub_807A19C(0); + PrintTradeMessage(TRADE_MSG_STANDBY); break; case 2: - sub_807A19C(2); + PrintTradeMessage(TRADE_MSG_ONLY_MON1); break; case 3: case 4: case 5: - sub_807A19C(3); + PrintTradeMessage(TRADE_MSG_ONLY_MON2); break; case 6: - sub_807A19C(6); + PrintTradeMessage(TRADE_MSG_MON_CANT_BE_TRADED); break; case 7: - sub_807A19C(7); + PrintTradeMessage(TRADE_MSG_EGG_CANT_BE_TRADED); break; case 8: - sub_807A19C(8); + PrintTradeMessage(TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED); break; } - gUnknown_0203229C->unk_8D0[i].unk_0 = 0; + sTradeMenuData->unk_8D0[i].unk_0 = 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, sTradeMessageTexts[messageId], 0, 1, TEXT_SPEED_FF, NULL); DrawTextBorderOuter(0, 20, 12); PutWindowTilemap(0); CopyWindowToVram(0, 3); @@ -2192,41 +2197,41 @@ static bool8 sub_807A1F0(void) { struct SpriteSheet sheet; - if (gUnknown_0203229C->unk_A8 < 14) + if (sTradeMenuData->unk_A8 < 14) { - sheet.data = gUnknown_02032188[gUnknown_0203229C->unk_A8]; + sheet.data = gUnknown_02032188[sTradeMenuData->unk_A8]; sheet.size = 0x100; - sheet.tag = 200 + gUnknown_0203229C->unk_A8; + sheet.tag = 200 + sTradeMenuData->unk_A8; } - switch (gUnknown_0203229C->unk_A8) + switch (sTradeMenuData->unk_A8) { case 0 ... 7: LoadSpriteSheet(&sheet); - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_A8++; break; case 8: - gUnknown_0203229C->unk_72 = LoadSpriteSheet(&sheet); - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_72 = LoadSpriteSheet(&sheet); + sTradeMenuData->unk_A8++; break; case 9 ... 13: LoadSpriteSheet(&sheet); - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_A8++; break; case 14: LoadSpritePalette(&gSpritePalette_TradeScreenText); - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_A8++; break; case 15: LoadSpritePalette(&gUnknown_0832DC44); - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_A8++; break; case 16: LoadSpriteSheet(&gUnknown_0832DC3C); - gUnknown_0203229C->unk_A8++; + sTradeMenuData->unk_A8++; break; case 17: - gUnknown_0203229C->unk_A8 = 0; + sTradeMenuData->unk_A8 = 0; return TRUE; } @@ -2245,82 +2250,82 @@ static void sub_807A320(u8 whichParty) switch (whichParty) { case TRADE_PLAYER: - for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE) { - gUnknown_0203229C->unk_45[whichParty][i] = 0; - gUnknown_0203229C->isEgg[whichParty][i] = TRUE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = TRUE; } else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) { - gUnknown_0203229C->unk_45[whichParty][i] = 0; - gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } else { - gUnknown_0203229C->unk_45[whichParty][i] = 1; - gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = TRUE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } } break; case TRADE_PARTNER: - for (i = 0; i < gUnknown_0203229C->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) { - gUnknown_0203229C->unk_45[whichParty][i] = 0; - gUnknown_0203229C->isEgg[whichParty][i] = TRUE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = TRUE; } else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) { - gUnknown_0203229C->unk_45[whichParty][i] = 0; - gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } else { - gUnknown_0203229C->unk_45[whichParty][i] = 1; - gUnknown_0203229C->isEgg[whichParty][i] = FALSE; + 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++) + 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); - gUnknown_0203229C->unk_5D[0][i] = GetHPBarLevel(curHp, maxHp); + sTradeMenuData->hpBarLevels[TRADE_PLAYER][i] = GetHPBarLevel(curHp, maxHp); } break; - case 1: - for (i = 0; i < gUnknown_0203229C->partyCounts[1]; i++) + 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); - gUnknown_0203229C->unk_5D[1][i] = GetHPBarLevel(curHp, maxHp); + 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 < TRADE_PARTICIPANT_COUNT; i++) + 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->partyIcons[i][j]], 4 - sTradeMenuData->hpBarLevels[i][j]); } } } @@ -2331,25 +2336,25 @@ static void sub_807A5B0(void) for (i = 0; i < 11; i++) { - if (gSaveBlock1Ptr->giftRibbons[i] == 0 && gUnknown_0203229C->unk_A9[i] != 0) + if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenuData->unk_A9[i] != 0) { - if (gUnknown_0203229C->unk_A9[i] < 64) - gSaveBlock1Ptr->giftRibbons[i] = gUnknown_0203229C->unk_A9[i]; + if (sTradeMenuData->unk_A9[i] < 64) + gSaveBlock1Ptr->giftRibbons[i] = sTradeMenuData->unk_A9[i]; } } } -static u32 sub_807A5F4(struct Pokemon *monList, int a1, int monIdx) +static u32 sub_807A5F4(struct Pokemon *playerParty, int partyCount, int monIdx) { int i, sum; 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); } if (!IsNationalPokedexEnabled()) @@ -2385,13 +2390,13 @@ static u32 sub_807A5F4(struct Pokemon *monList, int a1, int monIdx) if (species[monIdx] == SPECIES_DEOXYS || species[monIdx] == SPECIES_MEW) { - if (!GetMonData(&monList[monIdx], MON_DATA_OBEDIENCE)) + if (!GetMonData(&playerParty[monIdx], MON_DATA_OBEDIENCE)) { return 4; } } - for (i = 0; i < a1; i++) + for (i = 0; i < partyCount; i++) { if (species2[i] == SPECIES_EGG) { @@ -2399,7 +2404,7 @@ static u32 sub_807A5F4(struct Pokemon *monList, int a1, int monIdx) } } - for (sum = 0, i = 0; i < a1; i++) + for (sum = 0, i = 0; i < partyCount; i++) { if (i != monIdx) { @@ -2856,7 +2861,7 @@ static void sub_807AB28(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->unk_D4 * 0x100, sTradeData->unk_D6 * 0x100, sTradeData->unk_DC, sTradeData->unk_DE, sTradeData->unk_E8, sTradeData->unk_E8, sTradeData->unk_EC); SetGpuReg(REG_OFFSET_BG2PA, affine.pa); SetGpuReg(REG_OFFSET_BG2PB, affine.pb); SetGpuReg(REG_OFFSET_BG2PC, affine.pc); @@ -2871,14 +2876,14 @@ static void sub_807ABCC(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 { @@ -2896,28 +2901,28 @@ static void sub_807AC24(void) static void sub_807AC3C(void) { - gUnknown_020322A0->unk_8A = 0; - gUnknown_020322A0->unk_88 = 0; - gUnknown_020322A0->unk_89 = 0; + sTradeData->unk_8A = 0; + sTradeData->unk_88 = 0; + sTradeData->unk_89 = 0; } static void sub_807AC64(void) { - if (gUnknown_020322A0->unk_88 == gUnknown_020322A0->unk_89) - gUnknown_020322A0->unk_8A++; + if (sTradeData->unk_88 == sTradeData->unk_89) + sTradeData->unk_8A++; else - gUnknown_020322A0->unk_8A = 0; + sTradeData->unk_8A = 0; - if (gUnknown_020322A0->unk_8A > 300) + if (sTradeData->unk_8A > 300) { CloseLink(); SetMainCallback2(CB2_LinkError); - gUnknown_020322A0->unk_8A = 0; - gUnknown_020322A0->unk_89 = 0; - gUnknown_020322A0->unk_88 = 0; + sTradeData->unk_8A = 0; + sTradeData->unk_89 = 0; + sTradeData->unk_88 = 0; } - gUnknown_020322A0->unk_89 = gUnknown_020322A0->unk_88; + sTradeData->unk_89 = sTradeData->unk_88; } static u32 sub_807ACDC(void) @@ -2936,13 +2941,13 @@ static void sub_807ACFC(u8 whichParty, u8 a1) if (whichParty == TRADE_PLAYER) { - mon = &gPlayerParty[gSelectedTradeMonPositions[0]]; + mon = &gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]]; pos = 1; } if (whichParty == TRADE_PARTNER) { - mon = &gEnemyParty[gSelectedTradeMonPositions[1] % PARTY_SIZE]; + mon = &gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE]; pos = 3; } @@ -2958,14 +2963,14 @@ static void sub_807ACFC(u8 whichParty, u8 a1) 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; + sTradeData->tradeSpecies[whichParty] = species; + sTradeData->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; + sTradeData->pokePicSpriteIdxs[whichParty] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); + gSprites[sTradeData->pokePicSpriteIdxs[whichParty]].invisible = TRUE; + gSprites[sTradeData->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; break; } } @@ -2980,7 +2985,7 @@ void sub_807AE50(void) gLinkType = 0x1144; CloseLink(); } - gUnknown_020322A0 = AllocZeroed(sizeof(*gUnknown_020322A0)); + sTradeData = AllocZeroed(sizeof(*sTradeData)); AllocateMonSpritesGfx(); ResetTasks(); ResetSpriteData(); @@ -2989,25 +2994,25 @@ void sub_807AE50(void) sub_807B170(); sub_807AC3C(); 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; + sTradeData->unk_8C = 0; + sTradeData->state = 0; + sTradeData->isLinkTrade = TRUE; + sTradeData->unk_D4 = 64; + sTradeData->unk_D6 = 64; + sTradeData->unk_D8 = 0; + sTradeData->unk_DA = 0; + sTradeData->unk_DC = 120; + sTradeData->unk_DE = 80; + sTradeData->unk_E8 = 256; + sTradeData->unk_EC = 0; break; case 1: if (!gReceivedRemoteLinkPlayers) { - gUnknown_020322A0->unk_FA = 1; + sTradeData->unk_FA = 1; OpenLink(); gMain.state++; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; } else { @@ -3015,9 +3020,9 @@ void sub_807AE50(void) } break; case 2: - if (++gUnknown_020322A0->timer > 60) + if (++sTradeData->timer > 60) { - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; gMain.state++; } break; @@ -3026,7 +3031,7 @@ void sub_807AE50(void) { if (GetLinkPlayerCount_2() >= GetSavedPlayerCount()) { - if (++gUnknown_020322A0->timer > 30) + if (++sTradeData->timer > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -3048,9 +3053,9 @@ void sub_807AE50(void) gMain.state++; break; case 5: - gUnknown_020322A0->unk_72 = 0; - gUnknown_020322A0->unk_73 = 0; - gUnknown_020322A0->unk_93 = 0; + sTradeData->unk_72 = 0; + sTradeData->unk_73 = 0; + sTradeData->unk_93 = 0; sub_807ACFC(TRADE_PLAYER, 0); gMain.state++; break; @@ -3145,32 +3150,32 @@ static void sub_807B270(void) switch (gMain.state) { case 0: - gSelectedTradeMonPositions[0] = gSpecialVar_0x8005; - gSelectedTradeMonPositions[1] = 6; + 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); - gUnknown_020322A0 = AllocZeroed(sizeof(*gUnknown_020322A0)); + sTradeData = AllocZeroed(sizeof(*sTradeData)); 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; + sTradeData->isLinkTrade = FALSE; + sTradeData->unk_8C = 0; + sTradeData->state = 0; + sTradeData->unk_D4 = 64; + sTradeData->unk_D6 = 64; + sTradeData->unk_D8 = 0; + sTradeData->unk_DA = 0; + sTradeData->unk_DC = 120; + sTradeData->unk_DE = 80; + sTradeData->unk_E8 = 256; + sTradeData->unk_EC = 0; + sTradeData->timer = 0; gMain.state = 5; break; case 5: @@ -3257,9 +3262,9 @@ static void sub_807B4D0(u8 a0, u8 a1) 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)) @@ -3275,17 +3280,17 @@ static void sub_807B4D0(u8 a0, u8 a1) static void sub_807B5B8(void) { - switch (gUnknown_020322A0->unk_93) + switch (sTradeData->unk_93) { case 1: if (IsLinkTaskFinished()) { - Trade_SendData(gUnknown_020322A0); - gUnknown_020322A0->unk_93++; + Trade_SendData(sTradeData); + sTradeData->unk_93++; } // fallthrough case 2: - gUnknown_020322A0->unk_93 = 0; + sTradeData->unk_93 = 0; break; } } @@ -3305,8 +3310,8 @@ static void sub_807B62C(u8 a0) switch (a0) { case 0: - gUnknown_020322A0->bg2vofs = 0; - gUnknown_020322A0->bg2hofs = 180; + sTradeData->bg2vofs = 0; + sTradeData->bg2hofs = 180; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | @@ -3322,8 +3327,8 @@ static void sub_807B62C(u8 a0) DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); break; case 1: - gUnknown_020322A0->bg1hofs = 0; - gUnknown_020322A0->bg1vofs = 348; + sTradeData->bg1hofs = 0; + sTradeData->bg1vofs = 348; SetGpuReg(REG_OFFSET_BG1VOFS, 348); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | @@ -3336,7 +3341,7 @@ static void sub_807B62C(u8 a0) BGCNT_SCREENBASE(18) | BGCNT_TXT256x512); - if (gUnknown_020322A0->unk_FA) + if (sTradeData->unk_FA) { DmaCopy16Defvars(3, gUnknown_083369A0, (void *) BG_SCREEN_ADDR(5), 0x1000); } @@ -3352,9 +3357,9 @@ static void sub_807B62C(u8 a0) DISPCNT_OBJ_ON); break; case 2: - gUnknown_020322A0->bg1vofs = 0; - gUnknown_020322A0->bg1hofs = 0; - if (!gUnknown_020322A0->unk_FA) + sTradeData->bg1vofs = 0; + sTradeData->bg1hofs = 0; + if (!sTradeData->unk_FA) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3369,15 +3374,15 @@ static void sub_807B62C(u8 a0) DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | DISPCNT_OBJ_ON); - DmaCopy16Defvars(3, gUnknown_0832FFC0, (void *) BG_SCREEN_ADDR(5), 0x800); + DmaCopy16Defvars(3, sTradeTilemap_Cable, (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; + 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 | @@ -3394,15 +3399,15 @@ static void sub_807B62C(u8 a0) 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; + sTradeData->unk_D4 = 64; + sTradeData->unk_D6 = 92; + sTradeData->unk_E8 = 32; + sTradeData->unk_EA = 1024; + sTradeData->unk_EC = 0; DmaCopyLarge16(3, gUnknown_08332F60, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (gUnknown_020322A0->unk_FA) + if (sTradeData->unk_FA) { DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); } @@ -3412,8 +3417,8 @@ static void sub_807B62C(u8 a0) } break; case 5: - gUnknown_020322A0->bg1vofs = 0; - gUnknown_020322A0->bg1hofs = 0; + sTradeData->bg1vofs = 0; + sTradeData->bg1hofs = 0; break; case 6: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | @@ -3425,17 +3430,17 @@ static void sub_807B62C(u8 a0) 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; + sTradeData->unk_D4 = 64; + sTradeData->unk_D6 = 92; + sTradeData->unk_E8 = 256; + sTradeData->unk_EA = 128; + sTradeData->unk_DC = 120; + sTradeData->unk_DE = 80; + sTradeData->unk_EC = 0; DmaCopyLarge16(3, gUnknown_08332F60, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (gUnknown_020322A0->unk_FA) + if (sTradeData->unk_FA) { DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); } @@ -3445,8 +3450,8 @@ static void sub_807B62C(u8 a0) } break; case 7: - gUnknown_020322A0->bg2vofs = 0; - gUnknown_020322A0->bg2hofs = 0; + sTradeData->bg2vofs = 0; + sTradeData->bg2hofs = 0; SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(1) | @@ -3477,13 +3482,13 @@ static void SetTradeSceneStrings(void) u8 name[20]; const struct InGameTrade *ingameTrade; - if (gUnknown_020322A0->isLinkTrade) + if (sTradeData->isLinkTrade) { mpId = GetMultiplayerId(); StringCopy(gStringVar1, gLinkPlayers[mpId ^ 1].name); - GetMonData(&gEnemyParty[gSelectedTradeMonPositions[1] % PARTY_SIZE], MON_DATA_NICKNAME, name); + GetMonData(&gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE], MON_DATA_NICKNAME, name); StringCopy10(gStringVar3, name); - GetMonData(&gPlayerParty[gSelectedTradeMonPositions[0]], MON_DATA_NICKNAME, name); + GetMonData(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], MON_DATA_NICKNAME, name); StringCopy10(gStringVar2, name); } else @@ -3498,7 +3503,7 @@ static void SetTradeSceneStrings(void) static u8 sub_807BBC8(void) { - if (gUnknown_020322A0->unk_FA) + if (sTradeData->unk_FA) { return sub_807BBEC(); } @@ -3512,57 +3517,57 @@ static bool8 sub_807BBEC(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(); + gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = -180; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[sTradeData->tradeSpecies[0]].y_offset; + sTradeData->state++; + sTradeData->cachedMapMusic = GetCurrentMapMusic(); PlayNewMapMusic(MUS_SHINKA); break; case 1: - if (gUnknown_020322A0->bg2hofs > 0) + if (sTradeData->bg2hofs > 0) { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x += 3; - gUnknown_020322A0->bg2hofs -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x += 3; + sTradeData->bg2hofs -= 3; } else { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = 0; - gUnknown_020322A0->bg2hofs = 0; - gUnknown_020322A0->state = 10; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = 0; + sTradeData->bg2hofs = 0; + sTradeData->state = 10; } break; case 10: StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); - if (gUnknown_020322A0->tradeSpecies[0] != SPECIES_EGG) + if (sTradeData->tradeSpecies[0] != SPECIES_EGG) { - PlayCry1(gUnknown_020322A0->tradeSpecies[0], 0); + PlayCry1(sTradeData->tradeSpecies[0], 0); } - gUnknown_020322A0->state = 11; - gUnknown_020322A0->timer = 0; + sTradeData->state = 11; + sTradeData->timer = 0; break; case 11: - if (++gUnknown_020322A0->timer == 80) + if (++sTradeData->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++; + sTradeData->unk_D2 = sub_807671C(sTradeData->pokePicSpriteIdxs[0], gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); } break; case 12: - if (gSprites[gUnknown_020322A0->unk_D2].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->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++; + sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[sTradeData->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[sTradeData->unk_D2]); + sTradeData->state++; } break; case 13: @@ -3570,7 +3575,7 @@ static bool8 sub_807BBEC(void) break; case 14: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 20; + sTradeData->state = 20; break; case 20: if (!gPaletteFade.active) @@ -3578,72 +3583,72 @@ static bool8 sub_807BBEC(void) sub_807B62C(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); CopyWindowToVram(0, 3); - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 21: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 22: if (!gPaletteFade.active) { - gUnknown_020322A0->state = 23; + sTradeData->state = 23; } break; case 23: - if (gUnknown_020322A0->unk_EA > 0x100) + if (sTradeData->unk_EA > 0x100) { - gUnknown_020322A0->unk_EA -= 0x34; + sTradeData->unk_EA -= 0x34; } else { sub_807B62C(1); - gUnknown_020322A0->unk_EA = 0x80; - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; + sTradeData->unk_EA = 0x80; + sTradeData->state++; + sTradeData->timer = 0; } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; + sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; break; case 24: - if (++gUnknown_020322A0->timer > 20) + if (++sTradeData->timer > 20) { sub_807AB28(); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - gUnknown_020322A0->state++; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state++; } break; case 25: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + 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)); - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 26: - if (--gUnknown_020322A0->bg1vofs == 316) + if (--sTradeData->bg1vofs == 316) { - gUnknown_020322A0->state++; + sTradeData->state++; } - if (gUnknown_020322A0->bg1vofs == 328) + if (sTradeData->bg1vofs == 328) { - gUnknown_020322A0->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + sTradeData->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++; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeData->state++; break; case 28: - if ((gUnknown_020322A0->bg1vofs -= 2) == 166) + if ((sTradeData->bg1vofs -= 2) == 166) { - gUnknown_020322A0->state = 200; + sTradeData->state = 200; } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3651,126 +3656,126 @@ static bool8 sub_807BBEC(void) 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) + gSprites[sTradeData->unk_90].pos1.y -= 2; + gSprites[sTradeData->unk_91].pos1.y -= 2; + if (gSprites[sTradeData->unk_90].pos1.y < -8) { - gUnknown_020322A0->state = 29; + sTradeData->state = 29; } break; case 29: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 30; + sTradeData->state = 30; break; case 30: if (!gPaletteFade.active) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(2); - gUnknown_020322A0->state++; + sTradeData->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++; + sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + sTradeData->state++; break; case 32: if (!gPaletteFade.active) { PlaySE(SE_TK_WARPOUT); - gUnknown_020322A0->state++; + sTradeData->state++; } - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->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[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -90) { - gSprites[gUnknown_020322A0->unk_90].data[1] = 1; - gSprites[gUnknown_020322A0->unk_91].data[1] = 1; - gUnknown_020322A0->state++; + gSprites[sTradeData->unk_90].data[1] = 1; + gSprites[sTradeData->unk_91].data[1] = 1; + sTradeData->state++; } break; case 34: BlendPalettes(0x1, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 35: BlendPalettes(0x1, 0, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 36: BlendPalettes(0x1, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 37: - if (!IsMonSpriteNotFlipped(gUnknown_020322A0->tradeSpecies[0])) + if (!IsMonSpriteNotFlipped(sTradeData->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); + gSprites[sTradeData->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0); } else { - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); + StartSpriteAffineAnim(&gSprites[sTradeData->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++; + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.x = 60; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 180; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.y = 192; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = -32; + gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[1]].invisible = FALSE; + sTradeData->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) + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y += 3; + if (gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y >= -163) { PlaySE(SE_TK_WARPIN); } - if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -222) + if (gSprites[sTradeData->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; + gSprites[sTradeData->unk_90].data[1] = 0; + gSprites[sTradeData->unk_91].data[1] = 0; + sTradeData->state++; + gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = TRUE; + gSprites[sTradeData->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) + 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++; - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + sTradeData->state++; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); } break; case 40: if (!gPaletteFade.active) { - gUnknown_020322A0->state++; + sTradeData->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); + sTradeData->bg1vofs = 166; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); } break; case 41: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 42: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3779,76 +3784,76 @@ static bool8 sub_807BBEC(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - gUnknown_020322A0->state++; + sTradeData->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) + 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) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 44: - if ((gUnknown_020322A0->bg1vofs += 2) > 316) + if ((sTradeData->bg1vofs += 2) > 316) { - gUnknown_020322A0->bg1vofs = 316; - gUnknown_020322A0->state++; + sTradeData->bg1vofs = 316; + sTradeData->state++; } break; case 45: - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeData->state++; + sTradeData->timer = 0; break; case 46: - if (++gUnknown_020322A0->timer == 10) + if (++sTradeData->timer == 10) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 47: - if (++gUnknown_020322A0->bg1vofs > 348) + if (++sTradeData->bg1vofs > 348) { - gUnknown_020322A0->bg1vofs = 348; - gUnknown_020322A0->state++; + sTradeData->bg1vofs = 348; + sTradeData->state++; } - if (gUnknown_020322A0->bg1vofs == 328 && gUnknown_020322A0->unk_FA) + if (sTradeData->bg1vofs == 328 && sTradeData->unk_FA) { - gUnknown_020322A0->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); - gSprites[gUnknown_020322A0->unk_92].callback = sub_807AAE0; + sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + gSprites[sTradeData->unk_92].callback = sub_807AAE0; } break; case 48: - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - gUnknown_020322A0->state = 50; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state = 50; break; case 50: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(6); - gUnknown_020322A0->state++; + sTradeData->state++; PlaySE(SE_W028); } break; case 51: - if (gUnknown_020322A0->unk_EA < 0x400) + if (sTradeData->unk_EA < 0x400) { - gUnknown_020322A0->unk_EA += 0x34; + sTradeData->unk_EA += 0x34; } else { - gUnknown_020322A0->unk_EA = 0x400; - gUnknown_020322A0->state++; + sTradeData->unk_EA = 0x400; + sTradeData->state++; } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; + sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; break; case 52: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 60; + sTradeData->state = 60; break; case 60: @@ -3857,13 +3862,13 @@ static bool8 sub_807BBEC(void) sub_807B62C(5); sub_807B62C(7); gPaletteFade.bufferTransferDisabled = TRUE; - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 61: gPaletteFade.bufferTransferDisabled = FALSE; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 62: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3872,40 +3877,40 @@ static bool8 sub_807BBEC(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - gUnknown_020322A0->state++; + sTradeData->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; + 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[gUnknown_020322A0->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeData->state++; break; case 65: - if (gSprites[gUnknown_020322A0->unk_D3].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->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++; + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], sTradeData->tradeSpecies[1], sTradeData->unk_68[1]); + sTradeData->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++; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 120; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[sTradeData->tradeSpecies[1]].y_offset + 60; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.x = 0; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y = 0; + StartSpriteAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); + CreatePokeballSpriteToReleaseMon(sTradeData->pokePicSpriteIdxs[1], gSprites[sTradeData->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->tradeSpecies[1]); + FreeSpriteOamMatrix(&gSprites[sTradeData->unk_D3]); + DestroySprite(&gSprites[sTradeData->unk_D3]); + sTradeData->state++; break; case 67: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3914,83 +3919,83 @@ static bool8 sub_807BBEC(void) DISPCNT_BG2_ON | DISPCNT_OBJ_ON); StringExpandPlaceholders(gStringVar4, gText_XSentOverY); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->state = 167; - gUnknown_020322A0->timer = 0; + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->state = 167; + sTradeData->timer = 0; break; // 167 and 267 are extra cases added in for animations case 167: - if (++gUnknown_020322A0->timer > 60) + if (++sTradeData->timer > 60) { - gUnknown_020322A0->state = 267; - gUnknown_020322A0->timer = 0; + sTradeData->state = 267; + sTradeData->timer = 0; } break; case 267: if (IsCryFinished()) { - gUnknown_020322A0->state = 68; + sTradeData->state = 68; } break; case 68: - if (++gUnknown_020322A0->timer == 10) + if (++sTradeData->timer == 10) { PlayFanfare(MUS_FANFA5); } - if (gUnknown_020322A0->timer == 250) + if (sTradeData->timer == 250) { - gUnknown_020322A0->state++; + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->timer = 0; + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->timer = 0; } break; case 69: - if (++gUnknown_020322A0->timer == 60) + if (++sTradeData->timer == 60) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 70: - sub_807F14C(); - gUnknown_020322A0->state++; + CheckPartnersMonForRibbons(); + sTradeData->state++; break; case 71: - if (gUnknown_020322A0->isLinkTrade) + if (sTradeData->isLinkTrade) { return TRUE; } else if (gMain.newKeys & A_BUTTON) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 72: // Only if in-game trade sub_807B4D0(gSpecialVar_0x8005, 0); gCB2_AfterEvolution = sub_807B60C; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[0]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[0]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[TRADE_PLAYER]); } - gUnknown_020322A0->state++; + sTradeData->state++; break; case 73: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 74: if (!gPaletteFade.active) { - PlayNewMapMusic(gUnknown_020322A0->cachedMapMusic); - if (gUnknown_020322A0) + PlayNewMapMusic(sTradeData->cachedMapMusic); + if (sTradeData) { FreeAllWindowBuffers(); Free(GetBgTilemapBuffer(3)); Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(gUnknown_020322A0); + FREE_AND_SET_NULL(sTradeData); } SetMainCallback2(CB2_ReturnToField); sub_807E784(); @@ -4004,57 +4009,57 @@ static bool8 sub_807CFC8(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(); + gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = -180; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[sTradeData->tradeSpecies[0]].y_offset; + sTradeData->state++; + sTradeData->cachedMapMusic = GetCurrentMapMusic(); PlayNewMapMusic(MUS_SHINKA); break; case 1: - if (gUnknown_020322A0->bg2hofs > 0) + if (sTradeData->bg2hofs > 0) { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x += 3; - gUnknown_020322A0->bg2hofs -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x += 3; + sTradeData->bg2hofs -= 3; } else { - gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.x = 0; - gUnknown_020322A0->bg2hofs = 0; - gUnknown_020322A0->state = 10; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = 0; + sTradeData->bg2hofs = 0; + sTradeData->state = 10; } break; case 10: StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); - if (gUnknown_020322A0->tradeSpecies[0] != SPECIES_EGG) + if (sTradeData->tradeSpecies[0] != SPECIES_EGG) { - PlayCry1(gUnknown_020322A0->tradeSpecies[0], 0); + PlayCry1(sTradeData->tradeSpecies[0], 0); } - gUnknown_020322A0->state = 11; - gUnknown_020322A0->timer = 0; + sTradeData->state = 11; + sTradeData->timer = 0; break; case 11: - if (++gUnknown_020322A0->timer == 80) + if (++sTradeData->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++; + sTradeData->unk_D2 = sub_807671C(sTradeData->pokePicSpriteIdxs[0], gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); } break; case 12: - if (gSprites[gUnknown_020322A0->unk_D2].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->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++; + sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[sTradeData->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[sTradeData->unk_D2]); + sTradeData->state++; } break; case 13: @@ -4062,7 +4067,7 @@ static bool8 sub_807CFC8(void) break; case 14: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 20; + sTradeData->state = 20; break; case 20: if (!gPaletteFade.active) @@ -4070,77 +4075,77 @@ static bool8 sub_807CFC8(void) sub_807B62C(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); CopyWindowToVram(0, 3); - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 21: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 22: if (!gPaletteFade.active) { - gUnknown_020322A0->state = 23; + sTradeData->state = 23; } break; case 23: - if (gUnknown_020322A0->unk_EA > 0x100) + if (sTradeData->unk_EA > 0x100) { - gUnknown_020322A0->unk_EA -= 0x34; + sTradeData->unk_EA -= 0x34; } else { sub_807B62C(1); - gUnknown_020322A0->unk_EA = 0x80; - gUnknown_020322A0->state = 124; - gUnknown_020322A0->timer = 0; + sTradeData->unk_EA = 0x80; + sTradeData->state = 124; + sTradeData->timer = 0; } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; + sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; break; case 124: - if (++gUnknown_020322A0->timer > 20) + if (++sTradeData->timer > 20) { sub_807B62C(3); - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); - gUnknown_020322A0->state++; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); + sTradeData->state++; } break; case 125: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + 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(c3_08054588, 5); - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 126: if (!FuncIsActiveTask(c3_08054588)) { - gUnknown_020322A0->state = 26; + sTradeData->state = 26; } break; case 26: - if (--gUnknown_020322A0->bg1vofs == 316) + if (--sTradeData->bg1vofs == 316) { - gUnknown_020322A0->state++; + sTradeData->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++; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); + gSprites[sTradeData->unk_90].callback = sub_807AA4C; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeData->state++; break; case 28: - if ((gUnknown_020322A0->bg1vofs -= 3) == 166) + if ((sTradeData->bg1vofs -= 3) == 166) { - gUnknown_020322A0->state = 200; + sTradeData->state = 200; } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -4148,130 +4153,130 @@ static bool8 sub_807CFC8(void) 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) + gSprites[sTradeData->unk_90].pos1.y -= 2; + gSprites[sTradeData->unk_91].pos1.y -= 2; + if (gSprites[sTradeData->unk_90].pos1.y < -8) { - gUnknown_020322A0->state = 29; + sTradeData->state = 29; } break; case 29: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 30; + sTradeData->state = 30; break; case 30: if (!gPaletteFade.active) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(2); - gUnknown_020322A0->state++; + sTradeData->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++; + sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + sTradeData->state++; break; case 32: if (!gPaletteFade.active) { PlaySE(SE_TK_WARPOUT); - gUnknown_020322A0->state++; + sTradeData->state++; } - gSprites[gUnknown_020322A0->unk_90].pos2.y -= 3; - gSprites[gUnknown_020322A0->unk_91].pos2.y += 3; + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->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[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -90) { - gSprites[gUnknown_020322A0->unk_90].data[1] = 1; - gSprites[gUnknown_020322A0->unk_91].data[1] = 1; - gUnknown_020322A0->state++; + 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); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 35: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 36: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 37: - if (!IsMonSpriteNotFlipped(gUnknown_020322A0->tradeSpecies[0])) + if (!IsMonSpriteNotFlipped(sTradeData->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); + gSprites[sTradeData->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0); } else { - StartSpriteAffineAnim(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]], 0); + StartSpriteAffineAnim(&gSprites[sTradeData->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++; + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.x = 40; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 200; + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.y = 192; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = -32; + gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; + gSprites[sTradeData->pokePicSpriteIdxs[1]].invisible = FALSE; + sTradeData->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) + gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y += 3; + if (gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y >= -163) { PlaySE(SE_TK_WARPIN); } - if (gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]].pos2.y < -222) + if (gSprites[sTradeData->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; + gSprites[sTradeData->unk_90].data[1] = 0; + gSprites[sTradeData->unk_91].data[1] = 0; + sTradeData->state++; + gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = TRUE; + gSprites[sTradeData->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) + 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++; - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + sTradeData->state++; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); } break; case 40: if (!gPaletteFade.active) { - gUnknown_020322A0->state++; + sTradeData->state++; sub_807B62C(1); - gUnknown_020322A0->bg1vofs = 166; + sTradeData->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); + sTradeData->bg2vofs = 412; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); + gSprites[sTradeData->unk_90].callback = sub_807AA4C; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); } break; case 41: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 42: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4280,16 +4285,16 @@ static bool8 sub_807CFC8(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - gUnknown_020322A0->state++; + sTradeData->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) + 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) { - gUnknown_020322A0->state = 144; - gUnknown_020322A0->timer = 0; + sTradeData->state = 144; + sTradeData->timer = 0; } break; case 144: @@ -4298,73 +4303,73 @@ static bool8 sub_807CFC8(void) DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON); - gUnknown_020322A0->bg1vofs += 3; - gUnknown_020322A0->bg2vofs += 3; - if (++gUnknown_020322A0->timer == 10) + sTradeData->bg1vofs += 3; + sTradeData->bg2vofs += 3; + if (++sTradeData->timer == 10) { u8 taskId = CreateTask(c3_08054588, 5); gTasks[taskId].data[2] = 1; } - if (gUnknown_020322A0->bg1vofs > 316) + if (sTradeData->bg1vofs > 316) { - gUnknown_020322A0->bg1vofs = 316; - gUnknown_020322A0->state++; + sTradeData->bg1vofs = 316; + sTradeData->state++; } break; case 145: - DestroySprite(&gSprites[gUnknown_020322A0->unk_90]); - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); - gUnknown_020322A0->state++; - gUnknown_020322A0->timer = 0; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeData->state++; + sTradeData->timer = 0; break; case 146: if (!FuncIsActiveTask(c3_08054588)) { - gUnknown_020322A0->state = 46; - gUnknown_020322A0->timer = 0; + sTradeData->state = 46; + sTradeData->timer = 0; } break; case 46: - if (++gUnknown_020322A0->timer == 10) + if (++sTradeData->timer == 10) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 47: - if (++gUnknown_020322A0->bg1vofs > 348) + if (++sTradeData->bg1vofs > 348) { - gUnknown_020322A0->bg1vofs = 348; - gUnknown_020322A0->state++; + sTradeData->bg1vofs = 348; + sTradeData->state++; } break; case 48: - gUnknown_020322A0->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - gUnknown_020322A0->state = 50; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state = 50; break; case 50: - if (gSprites[gUnknown_020322A0->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[gUnknown_020322A0->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(6); - gUnknown_020322A0->state++; + sTradeData->state++; PlaySE(SE_W028); } break; case 51: - if (gUnknown_020322A0->unk_EA < 0x400) + if (sTradeData->unk_EA < 0x400) { - gUnknown_020322A0->unk_EA += 0x34; + sTradeData->unk_EA += 0x34; } else { - gUnknown_020322A0->unk_EA = 0x400; - gUnknown_020322A0->state++; + sTradeData->unk_EA = 0x400; + sTradeData->state++; } - gUnknown_020322A0->unk_E8 = 0x8000 / gUnknown_020322A0->unk_EA; + sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; break; case 52: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state = 60; + sTradeData->state = 60; break; case 60: if (!gPaletteFade.active) @@ -4372,13 +4377,13 @@ static bool8 sub_807CFC8(void) sub_807B62C(5); sub_807B62C(7); gPaletteFade.bufferTransferDisabled = TRUE; - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 61: gPaletteFade.bufferTransferDisabled = FALSE; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 62: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4387,40 +4392,40 @@ static bool8 sub_807CFC8(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - gUnknown_020322A0->state++; + sTradeData->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; + 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[gUnknown_020322A0->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - gUnknown_020322A0->state++; + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeData->state++; break; case 65: - if (gSprites[gUnknown_020322A0->unk_D3].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->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++; + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], sTradeData->tradeSpecies[1], sTradeData->unk_68[1]); + sTradeData->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++; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 120; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[sTradeData->tradeSpecies[1]].y_offset + 60; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.x = 0; + gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y = 0; + StartSpriteAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); + CreatePokeballSpriteToReleaseMon(sTradeData->pokePicSpriteIdxs[1], gSprites[sTradeData->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->tradeSpecies[1]); + FreeSpriteOamMatrix(&gSprites[sTradeData->unk_D3]); + DestroySprite(&gSprites[sTradeData->unk_D3]); + sTradeData->state++; break; case 67: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4429,83 +4434,83 @@ static bool8 sub_807CFC8(void) DISPCNT_BG2_ON | DISPCNT_OBJ_ON); StringExpandPlaceholders(gStringVar4, gText_XSentOverY); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->state = 167; - gUnknown_020322A0->timer = 0; + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->state = 167; + sTradeData->timer = 0; break; // 167 and 267 are extra cases added in for animations case 167: - if (++gUnknown_020322A0->timer > 60) + if (++sTradeData->timer > 60) { - gUnknown_020322A0->state = 267; - gUnknown_020322A0->timer = 0; + sTradeData->state = 267; + sTradeData->timer = 0; } break; case 267: if (IsCryFinished()) { - gUnknown_020322A0->state = 68; + sTradeData->state = 68; } break; case 68: - if (++gUnknown_020322A0->timer == 10) + if (++sTradeData->timer == 10) { PlayFanfare(MUS_FANFA5); } - if (gUnknown_020322A0->timer == 250) + if (sTradeData->timer == 250) { - gUnknown_020322A0->state++; + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); - sub_807F1A8(0, gStringVar4, 0); - gUnknown_020322A0->timer = 0; + DrawTextOnTradeWindow(0, gStringVar4, 0); + sTradeData->timer = 0; } break; case 69: - if (++gUnknown_020322A0->timer == 60) + if (++sTradeData->timer == 60) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 70: - sub_807F14C(); - gUnknown_020322A0->state++; + CheckPartnersMonForRibbons(); + sTradeData->state++; break; case 71: - if (gUnknown_020322A0->isLinkTrade) + if (sTradeData->isLinkTrade) { return TRUE; } else if (gMain.newKeys & A_BUTTON) { - gUnknown_020322A0->state++; + sTradeData->state++; } break; case 72: // Only if in-game trade sub_807B4D0(gSpecialVar_0x8005, 0); gCB2_AfterEvolution = sub_807B60C; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[0]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[0]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[TRADE_PLAYER]); } - gUnknown_020322A0->state++; + sTradeData->state++; break; case 73: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gUnknown_020322A0->state++; + sTradeData->state++; break; case 74: if (!gPaletteFade.active) { - PlayNewMapMusic(gUnknown_020322A0->cachedMapMusic); - if (gUnknown_020322A0) + PlayNewMapMusic(sTradeData->cachedMapMusic); + if (sTradeData) { FreeAllWindowBuffers(); Free(GetBgTilemapBuffer(3)); Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(gUnknown_020322A0); + FREE_AND_SET_NULL(sTradeData); } SetMainCallback2(CB2_ReturnToField); sub_807E784(); @@ -4526,14 +4531,14 @@ static void c2_08053788(void) break; case 4: gCB2_AfterEvolution = sub_807EB50; - evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[0]], TRUE, ITEM_NONE); + evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[0]], evoTarget, gUnknown_020322A0->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[0]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[TRADE_PLAYER]); else if (sub_8077260()) SetMainCallback2(sub_807F464); else SetMainCallback2(sub_807EB50); - gSelectedTradeMonPositions[0] = 255; + gSelectedTradeMonPositions[TRADE_PLAYER] = 255; break; } if (!HasLinkErrorOccurred()) @@ -4556,7 +4561,7 @@ static void sub_807E4DC(void) } if (gBlockRecvBuffer[0][0] == 0xABCD) { - gUnknown_020322A0->unk_72 = 1; + sTradeData->unk_72 = 1; } ResetBlockReceivedFlag(0); } @@ -4564,7 +4569,7 @@ static void sub_807E4DC(void) { if (gBlockRecvBuffer[1][0] == 0xABCD) { - gUnknown_020322A0->unk_73 = 1; + sTradeData->unk_73 = 1; } ResetBlockReceivedFlag(1); } @@ -4615,7 +4620,7 @@ static void sub_807E64C(struct Sprite *sprite) if (++ sprite->data[0] == 23) { DestroySprite(sprite); - gUnknown_020322A0->state = 14; // Resume the master trade animation + sTradeData->state = 14; // Resume the master trade animation } } } @@ -4697,7 +4702,7 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) { if (ItemIsMail(inGameTrade->heldItem)) { - sub_807E974(&mail, inGameTrade); + SetInGameTradeMail(&mail, inGameTrade); gUnknown_020321C0[0] = mail; SetMonData(pokemon, MON_DATA_MAIL, &isMail); SetMonData(pokemon, MON_DATA_HELD_ITEM, &inGameTrade->heldItem); @@ -4710,12 +4715,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 < INGAME_TRADE_MAIL_LENGTH; i++) { - mail->words[i] = gIngameTradeMail[trade->mailNum][i]; + mail->words[i] = sIngameTradeMail[trade->mailNum][i]; } StringCopy(mail->playerName, trade->otName); @@ -4745,13 +4750,13 @@ static void sub_807EA2C(void) { if (sub_807BBC8() == TRUE) { - DestroySprite(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[0]]); - FreeSpriteOamMatrix(&gSprites[gUnknown_020322A0->pokePicSpriteIdxs[1]]); - sub_807B4D0(gSelectedTradeMonPositions[0], gSelectedTradeMonPositions[1] % PARTY_SIZE); + DestroySprite(&gSprites[sTradeData->pokePicSpriteIdxs[0]]); + FreeSpriteOamMatrix(&gSprites[sTradeData->pokePicSpriteIdxs[1]]); + sub_807B4D0(gSelectedTradeMonPositions[TRADE_PLAYER], gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE); if (!sub_8077260()) { - gUnknown_020322A0->linkData[0] = 0xABCD; - gUnknown_020322A0->unk_93 = 1; + sTradeData->linkData[0] = 0xABCD; + sTradeData->unk_93 = 1; } SetMainCallback2(sub_807EACC); } @@ -4774,12 +4779,12 @@ static void sub_807EACC(void) else { sub_807E4DC(); - if (mpId == 0 && gUnknown_020322A0->unk_72 == 1 && gUnknown_020322A0->unk_73 == 1) + if (mpId == 0 && sTradeData->unk_72 == 1 && sTradeData->unk_73 == 1) { - gUnknown_020322A0->linkData[0] = 0xDCBA; - Trade_SendData(gUnknown_020322A0); - gUnknown_020322A0->unk_72 = 2; - gUnknown_020322A0->unk_73 = 2; + sTradeData->linkData[0] = 0xDCBA; + Trade_SendData(sTradeData); + sTradeData->unk_72 = 2; + sTradeData->unk_73 = 2; } } RunTasks(); @@ -4795,18 +4800,18 @@ static void sub_807EB50(void) case 0: gMain.state++; StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 1: sub_8077288(0); gMain.state = 100; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; break; case 100: - if (++gUnknown_020322A0->timer > 180) + if (++sTradeData->timer > 180) { gMain.state = 101; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; } if (_IsLinkTaskFinished()) { @@ -4822,7 +4827,7 @@ static void sub_807EB50(void) case 2: gMain.state = 50; StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 50: if (!InUnionRoom()) @@ -4834,10 +4839,10 @@ static void sub_807EB50(void) SetContinueGameWarpStatusToDynamicWarp(); sub_8153380(); gMain.state++; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; break; case 51: - if (++gUnknown_020322A0->timer == 5) + if (++sTradeData->timer == 5) { gMain.state++; } @@ -4850,38 +4855,38 @@ static void sub_807EB50(void) } else { - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; gMain.state = 51; } break; case 4: sub_81533E0(); gMain.state = 40; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; break; case 40: - if (++gUnknown_020322A0->timer > 50) + if (++sTradeData->timer > 50) { if (GetMultiplayerId() == 0) { - gUnknown_020322A0->timer = Random() % 30; + sTradeData->timer = Random() % 30; } else { - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; } gMain.state = 41; } break; case 41: - if (gUnknown_020322A0->timer == 0) + if (sTradeData->timer == 0) { sub_8077288(1); gMain.state = 42; } else { - gUnknown_020322A0->timer--; + sTradeData->timer--; } break; case 42: @@ -4892,7 +4897,7 @@ static void sub_807EB50(void) } break; case 5: - if (++gUnknown_020322A0->timer > 60) + if (++sTradeData->timer > 60) { gMain.state++; sub_8077288(2); @@ -4960,7 +4965,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); @@ -4988,13 +4993,13 @@ static void sub_807F110(u8 taskId) } } -static void sub_807F14C(void) +static void CheckPartnersMonForRibbons(void) { u8 i; u8 numRibbons = 0; - for (i = 0; i < 12; i ++) + for (i = 0; i < 12; i ++) //TODO: MON_DATA_GIFT_RIBBON_7 - (MON_DATA_CHAMPION_RIBBON - 1) { - numRibbons += GetMonData(&gEnemyParty[gSelectedTradeMonPositions[1] % PARTY_SIZE], 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); @@ -5005,13 +5010,13 @@ void sub_807F19C(void) sub_807B170(); } -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); } @@ -5024,16 +5029,16 @@ static void c3_08054588(u8 taskId) if (!data[2]) { if (unk == 0x100) - LoadPalette(gUnknown_08337EA0, 0x30, 32); + LoadPalette(sTradePal_Black, 0x30, 32); else - LoadPalette(&gUnknown_08337AA0[unk], 0x30, 32); + LoadPalette(&sTradePal_WirelessSignalSend[unk], 0x30, 32); } else { if (unk == 0x100) - LoadPalette(gUnknown_08337EA0, 0x30, 32); + LoadPalette(sTradePal_Black, 0x30, 32); else - LoadPalette(&gUnknown_08337CA0[unk], 0x30, 32); + LoadPalette(&sTradePal_WirelessSignalReceive[unk], 0x30, 32); } if (gUnknown_08339090[data[0]][0] == 0 && data[1] == 0) @@ -5060,9 +5065,9 @@ static void c3_0805465C(u8 taskId) if (data[0] == 0) { - gUnknown_020322A0->unk_FB = gUnknown_020322A0->unk_FD = 120; - gUnknown_020322A0->unk_FC = 0; - gUnknown_020322A0->unk_FE = 160; + sTradeData->unk_FB = sTradeData->unk_FD = 120; + sTradeData->unk_FC = 0; + sTradeData->unk_FE = 160; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | @@ -5070,14 +5075,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->unk_FB, sTradeData->unk_FD)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); data[0]++; - gUnknown_020322A0->unk_FB -= 5; - gUnknown_020322A0->unk_FD += 5; + sTradeData->unk_FB -= 5; + sTradeData->unk_FD += 5; - if (gUnknown_020322A0->unk_FB < 80) + if (sTradeData->unk_FB < 80) { DestroyTask(taskId); } @@ -5089,24 +5094,24 @@ static void sub_807F39C(u8 taskId) if (data[0] == 0) { - gUnknown_020322A0->unk_FB = 80; - gUnknown_020322A0->unk_FD = 160; + sTradeData->unk_FB = 80; + sTradeData->unk_FD = 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->unk_FB, sTradeData->unk_FD)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); - if (gUnknown_020322A0->unk_FB != 120) + if (sTradeData->unk_FB != 120) { data[0]++; - gUnknown_020322A0->unk_FB += 5; - gUnknown_020322A0->unk_FD -= 5; + sTradeData->unk_FB += 5; + sTradeData->unk_FD -= 5; - if (gUnknown_020322A0->unk_FB >= 116) + if (sTradeData->unk_FB >= 116) BlendPalettes(0x8, 0, RGB_WHITEALPHA); } else @@ -5123,26 +5128,26 @@ static void sub_807F464(void) case 0: gMain.state = 1; StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 1: sub_8077288(0); gMain.state = 2; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; break; case 2: if (_IsLinkTaskFinished()) { gMain.state = 3; StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); - sub_807F1A8(0, gStringVar4, 0); + DrawTextOnTradeWindow(0, gStringVar4, 0); IncrementGameStat(GAME_STAT_POKEMON_TRADES); sub_8153380(); - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; } break; case 3: - if (++gUnknown_020322A0->timer == 5) + if (++sTradeData->timer == 5) { gMain.state = 4; } @@ -5154,38 +5159,38 @@ static void sub_807F464(void) } else { - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; gMain.state = 3; } break; case 5: sub_81533E0(); gMain.state = 6; - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; break; case 6: - if (++gUnknown_020322A0->timer > 10) + if (++sTradeData->timer > 10) { if (GetMultiplayerId() == 0) { - gUnknown_020322A0->timer = Random() % 30; + sTradeData->timer = Random() % 30; } else { - gUnknown_020322A0->timer = 0; + sTradeData->timer = 0; } gMain.state = 7; } break; case 7: - if (gUnknown_020322A0->timer == 0) + if (sTradeData->timer == 0) { sub_8077288(1); gMain.state = 8; } else { - gUnknown_020322A0->timer--; + sTradeData->timer--; } break; case 8: @@ -5196,7 +5201,7 @@ static void sub_807F464(void) } break; case 9: - if (++gUnknown_020322A0->timer > 60) + if (++sTradeData->timer > 60) { gMain.state++; sub_8077288(2); diff --git a/src/union_room.c b/src/union_room.c index 98efa61d5..908e57423 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -2347,8 +2347,8 @@ void sub_8013F90(u8 taskId) { memcpy(gUnknown_020321C0, gBlockRecvBuffer[GetMultiplayerId() ^ 1], sizeof(struct MailStruct) * PARTY_SIZE); ResetBlockReceivedFlags(); - gSelectedTradeMonPositions[0] = monId; - gSelectedTradeMonPositions[1] = PARTY_SIZE; + gSelectedTradeMonPositions[TRADE_PLAYER] = monId; + gSelectedTradeMonPositions[TRADE_PARTNER] = PARTY_SIZE; gMain.savedCallback = CB2_ReturnToField; SetMainCallback2(sub_807AE50); sub_801807C(&gUnknown_02022C40); From 2b0c9442864c8f7a138bd601d3dc17f3ecc9e586 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 4 Oct 2019 07:42:45 -0400 Subject: [PATCH 03/11] Document more of trade --- include/battle_anim.h | 2 +- include/trade.h | 2 +- src/battle_anim_mons.c | 2 +- src/data/trade.h | 19 +- src/trade.c | 1919 ++++++++++++++++++++-------------------- src/union_room.c | 2 +- 6 files changed, 975 insertions(+), 971 deletions(-) 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/trade.h b/include/trade.h index 218a5be2f..e4d2a4897 100644 --- a/include/trade.h +++ b/include/trade.h @@ -7,7 +7,7 @@ // Exported type declarations // Exported RAM declarations -extern struct MailStruct gUnknown_020321C0[PARTY_SIZE]; +extern struct MailStruct gTradeMail[PARTY_SIZE]; extern u8 gSelectedTradeMonPositions[2]; // 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/data/trade.h b/src/data/trade.h index adb7a3240..686c22ca4 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -592,11 +592,10 @@ static const struct WindowTemplate sTradeYesNoWindowTemplate = }; static const u8 sJPText_Shedinja[] = _("ヌケニン"); -static const u8 gUnknown_0832DF99[][2] = +static const u8 sTradeMenuPartyMonBoxDimensions[3][2] = { - {4, 3}, - {19, 3}, - {0, 0} + [TRADE_PLAYER] = {4, 3}, + [TRADE_PARTNER] = {19, 3} }; static const u16 sTradePal_Ball[] = INCBIN_U16("graphics/trade/ball.gbapal"); @@ -614,13 +613,13 @@ 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 gUnknown_08332F60[] = INCBIN_U8("graphics/trade/gba_affine.8bpp"); +static const u8 sTradeAffine_Gba[] = 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 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"); diff --git a/src/trade.c b/src/trade.c index 0d6e59b06..019aab2c4 100644 --- a/src/trade.c +++ b/src/trade.c @@ -71,9 +71,9 @@ struct InGameTrade { /*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}; +static EWRAM_DATA u8 *sTradeStringAllocBuffer = NULL; +static EWRAM_DATA u8 *sTradeStringBuffer[14] = {NULL}; +EWRAM_DATA struct MailStruct gTradeMail[PARTY_SIZE] = {0}; EWRAM_DATA u8 gSelectedTradeMonPositions[2] = {0}; static EWRAM_DATA struct { /*0x0000*/ u8 bg2hofs; @@ -83,29 +83,29 @@ static EWRAM_DATA struct { /*0x0034*/ u8 cursorSpriteIdx; /*0x0035*/ u8 cursorPosition; /*0x0036*/ u8 partyCounts[2]; - /*0x0038*/ bool8 tradeMenuOptionsActive[12]; + /*0x0038*/ bool8 monPresent[PARTY_SIZE * 2]; /*0x0044*/ u8 neverRead_44; /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; - /*0x0069*/ u8 unk_69; + /*0x0069*/ u8 unk_69; //state var /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; - /*0x006F*/ u8 unk_6F; - /*0x0070*/ u8 unk_70; + /*0x006F*/ u8 unk_6F; //state var for sub_80795AC + /*0x0070*/ u8 neverRead_70; /*0x0071*/ u8 filler_71; - /*0x0072*/ u16 unk_72; - /*0x0074*/ u8 unk_74[2]; //state var for sub_80796B4 + /*0x0072*/ u16 unk_72; //sheet + /*0x0074*/ u8 drawPartyState[2]; /*0x0076*/ u8 selectedMonIdx[2]; - /*0x0078*/ u8 unk_78; - /*0x0079*/ u8 unk_79; - /*0x007A*/ u8 unk_7A; - /*0x007B*/ u8 unk_7B; + /*0x0078*/ u8 unk_78; //recv buffer block flag + /*0x0079*/ u8 unk_79; //recv buffer block flag + /*0x007A*/ u8 unk_7A; //recv buffer block flag + /*0x007B*/ u8 unk_7B; //recv buffer block flag /*0x007C*/ u8 filler_7C[0x7E - 0x7C]; /*0x007E*/ u8 partnerCursorPosition; - /*0x007F*/ u8 filler_7F; + /*0x007F*/ u8 unused_7F; /*0x0080*/ u16 linkData[20]; - /*0x00A8*/ u8 unk_A8; - /*0x00A9*/ u8 unk_A9[11]; + /*0x00A8*/ u8 unk_A8; //state var for sub_807A1F0 + /*0x00A9*/ u8 unk_A9[11]; //ribbons /*0x00B4*/ u8 filler_B4[0x8D0-0xB4]; /*0x08D0*/ struct { bool8 unk_0; @@ -113,11 +113,11 @@ static EWRAM_DATA struct { u8 monValidity; } unk_8D0[4]; /*0x08F0*/ u16 tilemapBuffer[0x400]; -} *sTradeMenuData = {NULL}; +} *sTradeData = {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; @@ -125,45 +125,45 @@ static EWRAM_DATA struct { /*0x88*/ u8 unk_88; /*0x89*/ u8 unk_89; /*0x8A*/ u16 unk_8A; - /*0x8C*/ u16 unk_8C; + /*0x8C*/ u16 neverRead_8C; /*0x8E*/ u8 pokePicSpriteIdxs[2]; - /*0x90*/ u8 unk_90; - /*0x91*/ u8 unk_91; - /*0x92*/ u8 unk_92; + /*0x90*/ u8 unk_90; //sprite id + /*0x91*/ u8 unk_91; //sprite id + /*0x92*/ u8 unk_92; //sprite id /*0x93*/ u8 unk_93; /*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 unk_D2; //sprite id + /*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 textColors[3]; /*0xF9*/ u8 filler_F9; - /*0xFA*/ u8 unk_FA; + /*0xFA*/ bool8 isCableLink; /*0xFB*/ u8 unk_FB; /*0xFC*/ u8 unk_FC; /*0xFD*/ u8 unk_FD; /*0xFE*/ u8 unk_FE; -} *sTradeData = {NULL}; +} *sTradeWindowData = {NULL}; #if !defined(NONMATCHING) && MODERN #define static #endif -static bool32 sub_8077260(void); +static bool32 IsWirelessTrade(void); static void sub_80773D0(void); static void sub_807811C(void); static void sub_807825C(void); @@ -173,11 +173,11 @@ static bool8 shedinja_maker_maybe(void); static void sub_8078C34(void); static void sub_80795AC(void); static void SetSelectedMon(u8); -static void sub_80796B4(u8); +static void DrawTradeMenuParty(u8); static u8 sub_8079A3C(u8 *, u8, u8); static void BufferTradeMonMoves(u8 *, u8, u8); static void PrintPartyNicknamesForTradeMenu(u8); -static void sub_8079C4C(u8, u8, u8, u8, u8, u8); +static void DrawTradeMenuPartyMonInfo(u8, u8, u8, u8, u8, u8); static void sub_8079E44(u8); static void sub_8079F74(void); static void sub_8079F88(u8); @@ -204,9 +204,9 @@ 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 bool8 sub_807BBC8(void); +static bool8 sub_807BBEC(void); +static bool8 sub_807CFC8(void); static void sub_807E55C(struct Sprite *sprite); static void sub_807E5D8(struct Sprite *sprite); static void sub_807E64C(struct Sprite *sprite); @@ -217,7 +217,7 @@ 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 Task_InGameTrade(u8); static void CheckPartnersMonForRibbons(void); static void c3_08054588(u8); static void c3_0805465C(u8); @@ -268,9 +268,9 @@ 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); } @@ -280,19 +280,19 @@ static void sub_8077210(void) } } -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) { @@ -314,7 +314,7 @@ static bool32 _IsLinkTaskFinished(void) return IsLinkTaskFinished(); } -static void sub_80772A4(void) +static void InitTradeMenu(void) { ResetSpriteData(); FreeAllSpritePalettes(); @@ -328,7 +328,7 @@ static void sub_80772A4(void) LoadPalette(gUnknown_0860F074, 0xD0, 20); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_0832DEE4, ARRAY_COUNT(gUnknown_0832DEE4)); - SetBgTilemapBuffer(1, sTradeMenuData->tilemapBuffer); + SetBgTilemapBuffer(1, sTradeData->tilemapBuffer); if (InitWindows(gUnknown_0832DEF4)) { @@ -346,14 +346,14 @@ static void sub_80772A4(void) LoadUserWindowBorderGfx_(0, 20, 0xC0); LoadUserWindowBorderGfx(2, 1, 0xE0); LoadMonIconPalettes(); - sTradeMenuData->unk_69 = 0; - sTradeMenuData->unk_6F = 0; - sTradeMenuData->unk_70 = 0; - sTradeMenuData->unk_74[TRADE_PLAYER] = 0; - sTradeMenuData->unk_74[TRADE_PARTNER] = 0; - sTradeMenuData->unk_7A = 0; - sTradeMenuData->unk_7B = 0; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_69 = 0; + sTradeData->unk_6F = 0; + sTradeData->neverRead_70 = 0; + sTradeData->drawPartyState[TRADE_PLAYER] = 0; + sTradeData->drawPartyState[TRADE_PARTNER] = 0; + sTradeData->unk_7A = 0; + sTradeData->unk_7B = 0; + sTradeData->unk_A8 = 0; } } @@ -374,13 +374,13 @@ static void sub_80773D0(void) switch (gMain.state) { case 0: - sTradeMenuData = AllocZeroed(sizeof(*sTradeMenuData)); - sub_80772A4(); - gUnknown_02032184 = AllocZeroed(14 * 256); + sTradeData = AllocZeroed(sizeof(*sTradeData)); + InitTradeMenu(); + sTradeStringAllocBuffer = AllocZeroed(14 * 256); for (i = 0; i < 14; i++) { - gUnknown_02032188[i] = &gUnknown_02032184[i * 256]; + sTradeStringBuffer[i] = &sTradeStringAllocBuffer[i * 256]; } gMain.state++; @@ -399,7 +399,7 @@ static void sub_80773D0(void) if (!gReceivedRemoteLinkPlayers) { gLinkType = 0x1122; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; if (gWirelessCommType) { @@ -420,10 +420,10 @@ static void sub_80773D0(void) } break; case 2: - sTradeMenuData->unk_A8++; - if (sTradeMenuData->unk_A8 > 11) + sTradeData->unk_A8++; + if (sTradeData->unk_A8 > 11) { - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; gMain.state++; } break; @@ -432,7 +432,7 @@ static void sub_80773D0(void) { if (IsLinkMaster()) { - if (++sTradeMenuData->unk_A8 > 30) + if (++sTradeData->unk_A8 > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -450,7 +450,7 @@ static void sub_80773D0(void) sub_8011BD0(); CalculatePlayerPartyCount(); gMain.state++; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; if (gWirelessCommType) { sub_801048C(TRUE); @@ -484,13 +484,13 @@ static void sub_80773D0(void) CalculateEnemyPartyCount(); SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0); - sTradeMenuData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; - sTradeMenuData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; + sTradeData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; + sTradeData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeMenuData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + sTradeData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -499,10 +499,10 @@ static void sub_80773D0(void) TRUE); } - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) + for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeMenuData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -514,21 +514,21 @@ static void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 0); + sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 0); gMain.state++; break; case 9: - sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 1); + sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 1); gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[0], 0, 0, 3); + sub_80C6D80(gSaveBlock2Ptr->playerName, sTradeStringBuffer[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, gUnknown_02032188[3], 0, 0, 3); - sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], gUnknown_02032188[6], 0, 0, 2); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], gUnknown_02032188[8], 24); + sub_80C6D80(gLinkPlayers[id ^ 1].name, sTradeStringBuffer[3], 0, 0, 3); + sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sTradeStringBuffer[6], 0, 0, 2); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sTradeStringBuffer[8], 24); gMain.state++; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; break; case 11: if (sub_807A1F0()) @@ -567,16 +567,16 @@ static void sub_80773D0(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); - sTradeMenuData->cursorPosition = 0; + sTradeData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); + sTradeData->cursorPosition = 0; gMain.state++; rbox_fill_rectangle(0); break; case 14: sub_807A320(TRADE_PLAYER); PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); - sTradeMenuData->bg2hofs = 0; - sTradeMenuData->bg3hofs = 0; + sTradeData->bg2hofs = 0; + sTradeData->bg3hofs = 0; sub_8078388(); gMain.state++; PlayBGM(MUS_P_SCHOOL); @@ -638,12 +638,12 @@ static void sub_8077B74(void) switch (gMain.state) { case 0: - sub_80772A4(); + InitTradeMenu(); gMain.state++; break; case 1: gMain.state++; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; break; case 2: gMain.state++; @@ -668,16 +668,16 @@ static void sub_8077B74(void) break; case 7: CalculateEnemyPartyCount(); - sTradeMenuData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; - sTradeMenuData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; + sTradeData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; + sTradeData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; ClearWindowTilemap(0); PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeMenuData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -686,10 +686,10 @@ static void sub_8077B74(void) TRUE); } - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) + for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeMenuData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -701,21 +701,21 @@ static void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 0); + sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 0); gMain.state++; break; case 9: - sub_81B5D4C(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partyIcons[TRADE_PLAYER], 1); + sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 1); gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, gUnknown_02032188[0], 0, 0, 3); + sub_80C6D80(gSaveBlock2Ptr->playerName, sTradeStringBuffer[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, gUnknown_02032188[3], 0, 0, 3); - sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], gUnknown_02032188[6], 0, 0, 2); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], gUnknown_02032188[8], 24); + sub_80C6D80(gLinkPlayers[id ^ 1].name, sTradeStringBuffer[3], 0, 0, 3); + sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sTradeStringBuffer[6], 0, 0, 2); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sTradeStringBuffer[8], 24); gMain.state++; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; break; case 11: if (sub_807A1F0()) @@ -754,12 +754,12 @@ static void sub_8077B74(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - if (sTradeMenuData->cursorPosition < PARTY_SIZE) - sTradeMenuData->cursorPosition = gLastViewedMonIndex; + if (sTradeData->cursorPosition < PARTY_SIZE) + sTradeData->cursorPosition = gLastViewedMonIndex; else - sTradeMenuData->cursorPosition = gLastViewedMonIndex + PARTY_SIZE; + sTradeData->cursorPosition = gLastViewedMonIndex + PARTY_SIZE; - sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][1] * 8, 2); + sTradeData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[sTradeData->cursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[sTradeData->cursorPosition][1] * 8, 2); gMain.state = 16; break; case 16: @@ -768,8 +768,8 @@ static void sub_8077B74(void) break; case 17: sub_80782B8(1); - sTradeMenuData->bg2hofs = 0; - sTradeMenuData->bg3hofs = 0; + sTradeData->bg2hofs = 0; + sTradeData->bg3hofs = 0; sub_8078388(); gMain.state++; break; @@ -814,10 +814,10 @@ static void sub_807811C(void) static void sub_8078130(void) { - if (++sTradeMenuData->unk_A8 > 15) + if (++sTradeData->unk_A8 > 15) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeMenuData->unk_6F = 10; + sTradeData->unk_6F = 10; } } @@ -825,17 +825,17 @@ static void sub_807816C(void) { if (!gPaletteFade.active) { - gSelectedTradeMonPositions[TRADE_PLAYER] = sTradeMenuData->cursorPosition; - gSelectedTradeMonPositions[TRADE_PARTNER] = sTradeMenuData->partnerCursorPosition; + gSelectedTradeMonPositions[TRADE_PLAYER] = sTradeData->cursorPosition; + gSelectedTradeMonPositions[TRADE_PARTNER] = sTradeData->partnerCursorPosition; if (gWirelessCommType) { - sTradeMenuData->unk_6F = 16; + sTradeData->unk_6F = 16; } else { sub_800ABF4(32); - sTradeMenuData->unk_6F = 13; + sTradeData->unk_6F = 13; } } } @@ -848,9 +848,9 @@ static void sub_80781C8(void) { if (sub_8010500()) { - Free(gUnknown_02032184); + Free(sTradeStringAllocBuffer); FreeAllWindowBuffers(); - Free(sTradeMenuData); + Free(sTradeData); gMain.callback1 = NULL; DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(sub_807AE50); @@ -860,9 +860,9 @@ static void sub_80781C8(void) { if (!gReceivedRemoteLinkPlayers) { - Free(gUnknown_02032184); + Free(sTradeStringAllocBuffer); FreeAllWindowBuffers(); - Free(sTradeMenuData); + Free(sTradeData); gMain.callback1 = NULL; SetMainCallback2(sub_807AE50); } @@ -875,11 +875,11 @@ static void sub_807825C(void) sub_80795AC(); sub_807A0C4(); - sub_80796B4(TRADE_PLAYER); - sub_80796B4(TRADE_PARTNER); + DrawTradeMenuParty(TRADE_PLAYER); + DrawTradeMenuParty(TRADE_PARTNER); - SetGpuReg(REG_OFFSET_BG2HOFS, sTradeMenuData->bg2hofs++); - SetGpuReg(REG_OFFSET_BG3HOFS, sTradeMenuData->bg3hofs--); + SetGpuReg(REG_OFFSET_BG2HOFS, sTradeData->bg2hofs++); + SetGpuReg(REG_OFFSET_BG3HOFS, sTradeData->bg3hofs--); RunTextPrintersAndIsPrinter0Active(); RunTasks(); @@ -925,28 +925,28 @@ static void sub_8078388(void) for (i = 0; i < PARTY_SIZE; i++) { - if (i < sTradeMenuData->partyCounts[TRADE_PLAYER]) + if (i < sTradeData->partyCounts[TRADE_PLAYER]) { - gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][i]].invisible = FALSE; - sTradeMenuData->tradeMenuOptionsActive[i] = TRUE; + gSprites[sTradeData->partyIcons[TRADE_PLAYER][i]].invisible = FALSE; + sTradeData->monPresent[i] = TRUE; } else { - sTradeMenuData->tradeMenuOptionsActive[i] = FALSE; + sTradeData->monPresent[i] = FALSE; } - if (i < sTradeMenuData->partyCounts[TRADE_PARTNER]) + if (i < sTradeData->partyCounts[TRADE_PARTNER]) { - gSprites[sTradeMenuData->partyIcons[TRADE_PARTNER][i]].invisible = FALSE; - sTradeMenuData->tradeMenuOptionsActive[i + PARTY_SIZE] = TRUE; + gSprites[sTradeData->partyIcons[TRADE_PARTNER][i]].invisible = FALSE; + sTradeData->monPresent[i + PARTY_SIZE] = TRUE; } else { - sTradeMenuData->tradeMenuOptionsActive[i + PARTY_SIZE] = FALSE; + sTradeData->monPresent[i + PARTY_SIZE] = FALSE; } } - sTradeMenuData->neverRead_44 = 1; + sTradeData->neverRead_44 = 1; } // why not just use memcpy? @@ -968,24 +968,24 @@ static bool8 shedinja_maker_maybe(void) int i; struct Pokemon *mon; - switch (sTradeMenuData->unk_69) + switch (sTradeData->unk_69) { case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); - sTradeMenuData->unk_69++; - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_69++; + sTradeData->unk_A8 = 0; break; case 1: if (sub_80771BC()) { if (_GetBlockReceivedStatus() == 0) { - sTradeMenuData->unk_69++; + sTradeData->unk_69++; } else { - sub_8077210(); - sTradeMenuData->unk_69++; + TradeResetReceivedFlags(); + sTradeData->unk_69++; } } break; @@ -994,90 +994,90 @@ static bool8 shedinja_maker_maybe(void) { sub_80771AC(1); } - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 4: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon)); - sub_8077210(); - sTradeMenuData->unk_69++; + TradeResetReceivedFlags(); + sTradeData->unk_69++; } break; case 5: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon)); - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 7: if (id == 0) { sub_80771AC(1); } - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 8: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200); - sub_8077210(); - sTradeMenuData->unk_69++; + TradeResetReceivedFlags(); + sTradeData->unk_69++; } break; case 9: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200); - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 11: if (id == 0) { sub_80771AC(1); } - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 12: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200); - sub_8077210(); - sTradeMenuData->unk_69++; + TradeResetReceivedFlags(); + sTradeData->unk_69++; } break; case 13: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220); - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 15: if (id == 0) { sub_80771AC(3); } - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 16: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(gUnknown_020321C0, gBlockRecvBuffer[id ^ 1], 216); - sub_8077210(); - sTradeMenuData->unk_69++; + Trade_Memcpy(gTradeMail, gBlockRecvBuffer[id ^ 1], 216); + TradeResetReceivedFlags(); + sTradeData->unk_69++; } break; case 17: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, 11); - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 19: if (id == 0) { sub_80771AC(4); } - sTradeMenuData->unk_69++; + sTradeData->unk_69++; break; case 20: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(sTradeMenuData->unk_A9, gBlockRecvBuffer[id ^ 1], 11); - sub_8077210(); - sTradeMenuData->unk_69++; + Trade_Memcpy(sTradeData->unk_A9, gBlockRecvBuffer[id ^ 1], 11); + TradeResetReceivedFlags(); + sTradeData->unk_69++; } break; case 21: @@ -1105,11 +1105,11 @@ static bool8 shedinja_maker_maybe(void) case 10: case 14: case 18: - sTradeMenuData->unk_A8++; - if (sTradeMenuData->unk_A8 > 10) + sTradeData->unk_A8++; + if (sTradeData->unk_A8 > 10) { - sTradeMenuData->unk_A8 = 0; - sTradeMenuData->unk_69++; + sTradeData->unk_A8 = 0; + sTradeData->unk_69++; } break; } @@ -1118,7 +1118,7 @@ static bool8 shedinja_maker_maybe(void) static void sub_80787B8(void) { - sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); + sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); } static void sub_80787E0(u8 a0, u8 a1) @@ -1128,19 +1128,19 @@ static void sub_80787E0(u8 a0, u8 a1) switch (gBlockRecvBuffer[0][0]) { case 0xEEAA: - sTradeMenuData->unk_78 = 2; + sTradeData->unk_78 = 2; break; case 0xAABB: - sTradeMenuData->unk_78 = 1; + sTradeData->unk_78 = 1; break; case 0xBBBB: - sTradeMenuData->unk_7A = 1; + sTradeData->unk_7A = 1; break; case 0xBBCC: - sTradeMenuData->unk_7A = 2; + sTradeData->unk_7A = 2; break; } - sub_8077234(0); + TradeResetReceivedFlag(TRADE_PLAYER); } if (a1 & 2) @@ -1148,20 +1148,20 @@ static void sub_80787E0(u8 a0, u8 a1) switch (gBlockRecvBuffer[1][0]) { case 0xEEAA: - sTradeMenuData->unk_79 = 2; + sTradeData->unk_79 = 2; break; case 0xAABB: - sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; - sTradeMenuData->unk_79 = 1; + sTradeData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; + sTradeData->unk_79 = 1; break; case 0xBBBB: - sTradeMenuData->unk_7B = 1; + sTradeData->unk_7B = 1; break; case 0xBBCC: - sTradeMenuData->unk_7B = 2; + sTradeData->unk_7B = 2; break; } - sub_8077234(1); + TradeResetReceivedFlag(TRADE_PARTNER); } } @@ -1174,98 +1174,98 @@ static void sub_8078900(u8 a0, u8 a1) case 0xEEBB: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); - sTradeMenuData->unk_6F = 11; + sTradeData->unk_6F = 11; break; case 0xEECC: PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); - sTradeMenuData->unk_6F = 8; + sTradeData->unk_6F = 8; break; case 0xDDDD: - sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[0][1] + 6; + sTradeData->partnerCursorPosition = gBlockRecvBuffer[0][1] + 6; rbox_fill_rectangle(0); - SetSelectedMon(sTradeMenuData->cursorPosition); - SetSelectedMon(sTradeMenuData->partnerCursorPosition); - sTradeMenuData->unk_6F = 7; + SetSelectedMon(sTradeData->cursorPosition); + SetSelectedMon(sTradeData->partnerCursorPosition); + sTradeData->unk_6F = 7; break; case 0xCCDD: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeMenuData->unk_6F = 10; + sTradeData->unk_6F = 10; break; case 0xDDEE: PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeMenuData->unk_6F = 8; + sTradeData->unk_6F = 8; } - sub_8077234(0); + TradeResetReceivedFlag(TRADE_PLAYER); } if (a1 & 2) - sub_8077234(1); + TradeResetReceivedFlag(TRADE_PARTNER); } static void sub_80789FC(void) { - if (sTradeMenuData->unk_78 && sTradeMenuData->unk_79) + if (sTradeData->unk_78 && sTradeData->unk_79) { - if (sTradeMenuData->unk_78 == 1 && sTradeMenuData->unk_79 == 1) + if (sTradeData->unk_78 == 1 && sTradeData->unk_79 == 1) { - sTradeMenuData->unk_6F = 6; - sTradeMenuData->linkData[0] = 0xDDDD; - sTradeMenuData->linkData[1] = sTradeMenuData->cursorPosition; + sTradeData->unk_6F = 6; + sTradeData->linkData[0] = 0xDDDD; + sTradeData->linkData[1] = sTradeData->cursorPosition; sub_807A048(5, 0); - sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; + sTradeData->unk_78 = sTradeData->unk_79 = 0; } - else if (sTradeMenuData->unk_78 == 1 && sTradeMenuData->unk_79 == 2) + else if (sTradeData->unk_78 == 1 && sTradeData->unk_79 == 2) { PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeMenuData->linkData[0] = 0xEECC; - sTradeMenuData->linkData[1] = 0; + sTradeData->linkData[0] = 0xEECC; + sTradeData->linkData[1] = 0; sub_807A048(5, 0); - sTradeMenuData->unk_7A = sTradeMenuData->unk_7B = 0; - sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; - sTradeMenuData->unk_6F = 8; + sTradeData->unk_7A = sTradeData->unk_7B = 0; + sTradeData->unk_78 = sTradeData->unk_79 = 0; + sTradeData->unk_6F = 8; } - else if (sTradeMenuData->unk_78 == 2 && sTradeMenuData->unk_79 == 1) + else if (sTradeData->unk_78 == 2 && sTradeData->unk_79 == 1) { PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); - sTradeMenuData->linkData[0] = 0xDDEE; - sTradeMenuData->linkData[1] = 0; + sTradeData->linkData[0] = 0xDDEE; + sTradeData->linkData[1] = 0; sub_807A048(5, 0); - sTradeMenuData->unk_7A = sTradeMenuData->unk_7B = 0; - sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; - sTradeMenuData->unk_6F = 8; + sTradeData->unk_7A = sTradeData->unk_7B = 0; + sTradeData->unk_78 = sTradeData->unk_79 = 0; + sTradeData->unk_6F = 8; } - else if (sTradeMenuData->unk_78 == 2 && sTradeMenuData->unk_79 == 2) + else if (sTradeData->unk_78 == 2 && sTradeData->unk_79 == 2) { - sTradeMenuData->linkData[0] = 0xEEBB; - sTradeMenuData->linkData[1] = 0; + sTradeData->linkData[0] = 0xEEBB; + sTradeData->linkData[1] = 0; sub_807A048(5, 0); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeMenuData->unk_78 = sTradeMenuData->unk_79 = 0; - sTradeMenuData->unk_6F = 11; + sTradeData->unk_78 = sTradeData->unk_79 = 0; + sTradeData->unk_6F = 11; } } - if (sTradeMenuData->unk_7A && sTradeMenuData->unk_7B) + if (sTradeData->unk_7A && sTradeData->unk_7B) { - if (sTradeMenuData->unk_7A == 1 && sTradeMenuData->unk_7B == 1) + if (sTradeData->unk_7A == 1 && sTradeData->unk_7B == 1) { - sTradeMenuData->linkData[0] = 0xCCDD; - sTradeMenuData->linkData[1] = 0; + sTradeData->linkData[0] = 0xCCDD; + sTradeData->linkData[1] = 0; sub_807A048(5, 0); - sTradeMenuData->unk_7A = 0; - sTradeMenuData->unk_7B = 0; - sTradeMenuData->unk_6F = 9; + sTradeData->unk_7A = 0; + sTradeData->unk_7B = 0; + sTradeData->unk_6F = 9; } - if (sTradeMenuData->unk_7A == 2 || sTradeMenuData->unk_7B == 2) + if (sTradeData->unk_7A == 2 || sTradeData->unk_7B == 2) { PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeMenuData->linkData[0] = 0xDDEE; - sTradeMenuData->linkData[1] = 0; + sTradeData->linkData[0] = 0xDDEE; + sTradeData->linkData[1] = 0; sub_807A048(5, 0); - sTradeMenuData->unk_7A = 0; - sTradeMenuData->unk_7B = 0; - sTradeMenuData->unk_6F = 8; + sTradeData->unk_7A = 0; + sTradeData->unk_7B = 0; + sTradeData->unk_6F = 8; } } } @@ -1279,7 +1279,7 @@ static void sub_8078BFC(u16 *linkData, u16 linkFlag, u16 cursorPosition) static void SetLinkData(u16 linkFlag, u16 cursorPosition) { - sub_8078BFC(sTradeMenuData->linkData, linkFlag, cursorPosition); + sub_8078BFC(sTradeData->linkData, linkFlag, cursorPosition); } static void sub_8078C34(void) @@ -1306,7 +1306,7 @@ static u8 sub_8078C6C(u8 oldPosition, u8 direction) for (i = 0; i < PARTY_SIZE; i++) { - if (sTradeMenuData->tradeMenuOptionsActive[gTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) + if (sTradeData->monPresent[gTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) { newPosition = gTradeNextSelectedMonTable[oldPosition][direction][i]; break; @@ -1322,15 +1322,15 @@ static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) if (newPosition == 12) // CANCEL { - StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 1); - gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = 224; - gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = 160; + StartSpriteAnim(&gSprites[sTradeData->cursorSpriteIdx], 1); + gSprites[sTradeData->cursorSpriteIdx].pos1.x = 224; + gSprites[sTradeData->cursorSpriteIdx].pos1.y = 160; } else { - StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 0); - gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; - gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; + StartSpriteAnim(&gSprites[sTradeData->cursorSpriteIdx], 0); + gSprites[sTradeData->cursorSpriteIdx].pos1.x = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; + gSprites[sTradeData->cursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; } if (*cursorPosition != newPosition) @@ -1344,15 +1344,15 @@ static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) static void sub_8078D78(void) { PrintTradeMessage(TRADE_MSG_STANDBY); - sTradeMenuData->unk_6F = 100; + sTradeData->unk_6F = 100; if (GetMultiplayerId() == 1) { - SetLinkData(0xAABB, sTradeMenuData->cursorPosition); + SetLinkData(0xAABB, sTradeData->cursorPosition); } else { - sTradeMenuData->unk_78 = 1; + sTradeData->unk_78 = 1; } } @@ -1360,19 +1360,19 @@ static void sub_8078DBC(void) { if (gMain.newAndRepeatedKeys & DPAD_UP) { - TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 0); + TradeMenuMoveCursor(&sTradeData->cursorPosition, 0); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 1); + TradeMenuMoveCursor(&sTradeData->cursorPosition, 1); } else if (gMain.newAndRepeatedKeys & DPAD_LEFT) { - TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 2); + TradeMenuMoveCursor(&sTradeData->cursorPosition, 2); } else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { - TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 3); + TradeMenuMoveCursor(&sTradeData->cursorPosition, 3); } if (gMain.newKeys & A_BUTTON) @@ -1380,7 +1380,7 @@ static void sub_8078DBC(void) PlaySE(SE_SELECT); // Cursor is in player's party - if (sTradeMenuData->cursorPosition < PARTY_SIZE) + if (sTradeData->cursorPosition < PARTY_SIZE) { DrawTextBorderOuter(1, 1, 14); FillWindowPixelBuffer(1, PIXEL_FILL(1)); @@ -1388,20 +1388,20 @@ static void sub_8078DBC(void) InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); PutWindowTilemap(1); CopyWindowToVram(1, 3); - sTradeMenuData->unk_6F = 1; + sTradeData->unk_6F = 1; } // Cursor is in partner's party - else if (sTradeMenuData->cursorPosition < PARTY_SIZE * 2) + else if (sTradeData->cursorPosition < PARTY_SIZE * 2) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeMenuData->unk_6F = 2; + sTradeData->unk_6F = 2; } // Cursor is on Cancel - else if (sTradeMenuData->cursorPosition == PARTY_SIZE * 2) + else if (sTradeData->cursorPosition == PARTY_SIZE * 2) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); - sTradeMenuData->unk_6F = 4; - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); + sTradeData->unk_6F = 4; + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); } } } @@ -1409,9 +1409,9 @@ static void sub_8078DBC(void) static void sub_8078EF8(void) { sub_8079F74(); - sTradeMenuData->unk_6F = 0; - gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); + sTradeData->unk_6F = 0; + gSprites[sTradeData->cursorSpriteIdx].invisible = FALSE; + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); } static void TradeMenuProcessInput_SelectedMon(void) @@ -1426,28 +1426,28 @@ static void TradeMenuProcessInput_SelectedMon(void) break; case MENU_ACTION_SUMMARY: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeMenuData->unk_6F = 2; + sTradeData->unk_6F = 2; break; case MENU_ACTION_TRADE: - switch (sub_807A5F4(gPlayerParty, gPlayerPartyCount, sTradeMenuData->cursorPosition)) + switch (sub_807A5F4(gPlayerParty, gPlayerPartyCount, sTradeData->cursorPosition)) { case 0: sub_8078D78(); - gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; + gSprites[sTradeData->cursorSpriteIdx].invisible = TRUE; break; case 1: sub_807A048(3, 3); - sTradeMenuData->unk_6F = 8; + sTradeData->unk_6F = 8; break; case 2: case 4: sub_807A048(3, 6); - sTradeMenuData->unk_6F = 8; + sTradeData->unk_6F = 8; break; case 3: case 5: sub_807A048(3, 7); - sTradeMenuData->unk_6F = 8; + sTradeData->unk_6F = 8; break; } break; @@ -1463,17 +1463,19 @@ static void sub_8079034(void) } } -static void sub_807905C(void) +static void TradeMenuShowMonSummaryScreen(void) { if (!gPaletteFade.active) { - if (sTradeMenuData->cursorPosition < PARTY_SIZE) + // Player's party + if (sTradeData->cursorPosition < PARTY_SIZE) { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, sTradeMenuData->cursorPosition, sTradeMenuData->partyCounts[TRADE_PLAYER] - 1, sub_8077B74); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, sTradeData->cursorPosition, sTradeData->partyCounts[TRADE_PLAYER] - 1, sub_8077B74); } + // Partner's party else { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, sTradeMenuData->cursorPosition - PARTY_SIZE, sTradeMenuData->partyCounts[TRADE_PARTNER] - 1, sub_8077B74); + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, sTradeData->cursorPosition - PARTY_SIZE, sTradeData->partyCounts[TRADE_PARTNER] - 1, sub_8077B74); } FreeAllWindowBuffers(); } @@ -1508,7 +1510,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player // Partner cant trade Egg or non-Hoenn mon if player doesn't have National Dex if (!IsNationalPokedexEnabled()) { - if (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) + if (sTradeData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) { return PARTNER_MON_INVALID; } @@ -1527,12 +1529,12 @@ static bool32 sub_8079174(void) int i; u8 aliveMons[PARTY_SIZE * 2]; - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) { - aliveMons[i] = sTradeMenuData->isLiveMon[TRADE_PLAYER][i]; + aliveMons[i] = sTradeData->isLiveMon[TRADE_PLAYER][i]; } - switch (CheckValidityOfTradeMons(aliveMons, sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->cursorPosition, sTradeMenuData->partnerCursorPosition)) + switch (CheckValidityOfTradeMons(aliveMons, sTradeData->partyCounts[TRADE_PLAYER], sTradeData->cursorPosition, sTradeData->partnerCursorPosition)) { case PLAYER_MON_INVALID: sub_807A048(3, 3); @@ -1557,11 +1559,11 @@ static void sub_8079218(void) case 0: if (!sub_8079174()) { - sTradeMenuData->unk_6F = 100; + sTradeData->unk_6F = 100; } else { - sTradeMenuData->unk_6F = 17; + sTradeData->unk_6F = 17; } PutWindowTilemap(17); break; @@ -1570,7 +1572,7 @@ static void sub_8079218(void) sub_807A048(3, 1); if (sub_80771BC()) SetLinkData(0xBBCC, 0); - sTradeMenuData->unk_6F = 100; + sTradeData->unk_6F = 100; PutWindowTilemap(17); break; } @@ -1580,7 +1582,7 @@ static void sub_807929C(void) { int i; - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER] - 4; i++) + for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER] - 4; i++) { PutWindowTilemap(i + 12); CopyWindowToVram(i + 12, 1); @@ -1594,8 +1596,8 @@ static void sub_80792E4(void) case 0: PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); SetLinkData(0xEEAA, 0); - gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; - sTradeMenuData->unk_6F = 100; + gSprites[sTradeData->cursorSpriteIdx].invisible = TRUE; + sTradeData->unk_6F = 100; sub_807929C(); break; case 1: @@ -1611,31 +1613,31 @@ static void sub_807935C(void) if (GetMultiplayerId() == 0) { rbox_fill_rectangle(0); - SetSelectedMon(sTradeMenuData->cursorPosition); - SetSelectedMon(sTradeMenuData->partnerCursorPosition); + SetSelectedMon(sTradeData->cursorPosition); + SetSelectedMon(sTradeData->partnerCursorPosition); } - sTradeMenuData->unk_6F = 7; + sTradeData->unk_6F = 7; } static void sub_8079398(void) { - if (sTradeMenuData->unk_74[TRADE_PLAYER] == 5 - && sTradeMenuData->unk_74[TRADE_PARTNER] == 5) + if (sTradeData->drawPartyState[TRADE_PLAYER] == 5 + && sTradeData->drawPartyState[TRADE_PARTNER] == 5) { sub_80787B8(); - sTradeMenuData->unk_6F = 14; + sTradeData->unk_6F = 14; } } static void Wait2SecondsAndCreateYesNoMenu(void) { - sTradeMenuData->unk_A8++; + sTradeData->unk_A8++; - if (sTradeMenuData->unk_A8 > 120) + if (sTradeData->unk_A8 > 120) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); - sTradeMenuData->unk_A8 = 0; - sTradeMenuData->unk_6F = 3; + sTradeData->unk_A8 = 0; + sTradeData->unk_6F = 3; } } @@ -1657,8 +1659,8 @@ static void sub_8079408(void) sub_8079F88(TRADE_PLAYER); sub_8079F88(TRADE_PARTNER); - sTradeMenuData->unk_6F = 0; - gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; + sTradeData->unk_6F = 0; + gSprites[sTradeData->cursorSpriteIdx].invisible = FALSE; } } @@ -1675,7 +1677,7 @@ static void sub_8079490(void) sub_800ABF4(12); } - sTradeMenuData->unk_6F = 12; + sTradeData->unk_6F = 12; } } @@ -1685,8 +1687,8 @@ static void sub_80794CC(void) { if (sub_80771BC() && sub_807A09C() == 0) { - Free(gUnknown_02032184); - Free(sTradeMenuData); + Free(sTradeStringAllocBuffer); + Free(sTradeData); FreeAllWindowBuffers(); DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); @@ -1696,8 +1698,8 @@ static void sub_80794CC(void) { if (!gReceivedRemoteLinkPlayers) { - Free(gUnknown_02032184); - Free(sTradeMenuData); + Free(sTradeStringAllocBuffer); + Free(sTradeData); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); } @@ -1709,7 +1711,7 @@ static void sub_8079550(void) if (!sub_801048C(FALSE) && sub_807A09C() == 0) { sub_800ADF8(); - sTradeMenuData->unk_6F = 13; + sTradeData->unk_6F = 13; } } @@ -1718,14 +1720,14 @@ static void sub_807957C(void) if (gMain.newKeys & A_BUTTON) { SetLinkData(0xBBCC, 0); - sTradeMenuData->unk_6F = 100; + sTradeData->unk_6F = 100; } } //TODO: static void sub_80795AC(void) { - switch (sTradeMenuData->unk_6F) + switch (sTradeData->unk_6F) { case 0: sub_8078DBC(); @@ -1734,7 +1736,7 @@ static void sub_80795AC(void) TradeMenuProcessInput_SelectedMon(); break; case 2: - sub_807905C(); + TradeMenuShowMonSummaryScreen(); break; case 3: sub_8079218(); @@ -1786,80 +1788,84 @@ static void SetSelectedMon(u8 cursorPosition) //cursorPosition 0-5 are the player's mons, 6-11 are the partner's u8 whichParty = cursorPosition / PARTY_SIZE; - if (sTradeMenuData->unk_74[whichParty] == 0) + if (sTradeData->drawPartyState[whichParty] == 0) { - sTradeMenuData->unk_74[whichParty] = 1; - sTradeMenuData->selectedMonIdx[whichParty] = cursorPosition; + sTradeData->drawPartyState[whichParty] = 1; + sTradeData->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 selectedMonIdx = sTradeMenuData->selectedMonIdx[a0]; + u8 selectedMonParty; + u8 selectedMonIdx = sTradeData->selectedMonIdx[whichParty]; - whichParty = TRADE_PARTNER; - if (sTradeMenuData->selectedMonIdx[a0] < PARTY_SIZE) - whichParty = TRADE_PLAYER; + selectedMonParty = TRADE_PARTNER; + if (sTradeData->selectedMonIdx[whichParty] < PARTY_SIZE) + selectedMonParty = TRADE_PLAYER; partyIdx = selectedMonIdx % PARTY_SIZE; nameStringWidth = 0; - switch (sTradeMenuData->unk_74[a0]) + switch (sTradeData->drawPartyState[whichParty]) { case 1: - for (i = 0; i < sTradeMenuData->partyCounts[a0]; i++) + for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { - gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][i + (whichParty * PARTY_SIZE)]].invisible = TRUE; + gSprites[sTradeData->partyIcons[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; } for (i = 0; i < 6; i++) { - ClearWindowTilemap(i + (a0 * PARTY_SIZE + 2)); + ClearWindowTilemap(i + (whichParty * PARTY_SIZE + 2)); } - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].invisible = FALSE; - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[0] = 20; - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12; - StoreSpriteCallbackInData6(&gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][partyIdx + (whichParty * PARTY_SIZE)]], sub_80D3014); - sTradeMenuData->unk_74[a0]++; - sub_80A6DEC(&gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][partyIdx + (whichParty * PARTY_SIZE)]]); - CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, a0 * 15, 0, 15, 17, 0); + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].invisible = FALSE; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + StoreSpriteCallbackInData6(&gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], sub_80D3014); + sTradeData->drawPartyState[whichParty]++; + TradeMenuBouncePartySprites(&gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); + CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); - if (whichParty == TRADE_PLAYER) + if (selectedMonParty == TRADE_PLAYER) sub_8079F74(); break; case 2: - if (gSprites[sTradeMenuData->partyIcons[TRADE_PLAYER][partyIdx + (whichParty * PARTY_SIZE)]].callback == sub_80D3014) - sTradeMenuData->unk_74[a0] = 3; + if (gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == sub_80D3014) + sTradeData->drawPartyState[whichParty] = 3; break; case 3: - CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, whichParty * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[whichParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[whichParty * PARTY_SIZE][1] * 8) - 12; - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.x = 0; - gSprites[sTradeMenuData->partyIcons[0][partyIdx + (whichParty * PARTY_SIZE)]].pos2.y = 0; - nameStringWidth = sub_8079A3C(nickname, whichParty, partyIdx); - AddTextPrinterParameterized3((a0 * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, sTradeTextColors, 0, nickname); - BufferTradeMonMoves(movesString, whichParty, partyIdx); - AddTextPrinterParameterized4((a0 * 2) + 15, 1, 0, 0, 0, 0, sTradeTextColors, 0, movesString); - PutWindowTilemap((a0 * 2) + 14); - CopyWindowToVram((a0 * 2) + 14, 3); - PutWindowTilemap((a0 * 2) + 15); - CopyWindowToVram((a0 * 2) + 15, 3); - sTradeMenuData->unk_74[a0]++; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.x = 0; + gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.y = 0; + nameStringWidth = sub_8079A3C(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); + sTradeData->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]); - sTradeMenuData->unk_74[a0]++; + DrawTradeMenuPartyMonInfo(whichParty, partyIdx, + sTradeMenuPartyMonBoxDimensions[whichParty][0] + 4, + sTradeMenuPartyMonBoxDimensions[whichParty][1] + 1, + sTradeMenuPartyMonBoxDimensions[whichParty][0], + sTradeMenuPartyMonBoxDimensions[whichParty][1]); + sTradeData->drawPartyState[whichParty]++; break; } } @@ -1882,7 +1888,7 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) u16 moves[MAX_MON_MOVES]; u16 i; - if (!sTradeMenuData->isEgg[whichParty][partyIdx]) + if (!sTradeData->isEgg[whichParty][partyIdx]) { for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1932,7 +1938,7 @@ static void PrintPartyNicknamesForTradeMenu(u8 whichParty) u8 str[32]; struct Pokemon *party = (whichParty == TRADE_PLAYER) ? gPlayerParty : gEnemyParty; - for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { GetMonData(&party[i], MON_DATA_NICKNAME, nickname); StringCopy10(str, nickname); @@ -1940,7 +1946,7 @@ static void PrintPartyNicknamesForTradeMenu(u8 whichParty) } } -static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 width, u8 height) +static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 width, u8 height) { u8 level; u32 r2; @@ -1955,20 +1961,20 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 width, u8 heigh else level = GetMonData(&gEnemyParty[monIdx], MON_DATA_LEVEL, NULL); - if (!sTradeMenuData->isEgg[whichParty][monIdx]) + if (!sTradeData->isEgg[whichParty][monIdx]) { if (level / 10 != 0) - sTradeMenuData->tilemapBuffer[x + (y * 32)] = (level / 10) + 0x60; + sTradeData->tilemapBuffer[x + (y * 32)] = (level / 10) + 0x60; - sTradeMenuData->tilemapBuffer[x + (y * 32) + 1] = (level % 10) + 0x70; + sTradeData->tilemapBuffer[x + (y * 32) + 1] = (level % 10) + 0x70; } else { - 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; + sTradeData->tilemapBuffer[x + (y * 32) - 32] = sTradeData->tilemapBuffer[x + (y * 32) - 33]; + sTradeData->tilemapBuffer[x + (y * 32) - 31] = sTradeData->tilemapBuffer[x + (y * 32) - 36] | 0x400; } - if (sTradeMenuData->isEgg[whichParty][monIdx]) + if (sTradeData->isEgg[whichParty][monIdx]) { r2 = 0x480; } @@ -1998,7 +2004,7 @@ static void sub_8079C4C(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 width, u8 heigh break; } } - sTradeMenuData->tilemapBuffer[(y - 1) * 32 + x + 1] = r2; + sTradeData->tilemapBuffer[(y - 1) * 32 + x + 1] = r2; } // Very close but loop preamble not working. @@ -2007,9 +2013,9 @@ static void sub_8079E44(u8 whichParty) { int i; - for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeData->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, gTradeLevelDisplayCoords[whichParty][i][0], gTradeLevelDisplayCoords[whichParty][i][1], gTradeMonBoxCoords[whichParty][i][0], gTradeMonBoxCoords[whichParty][i][1]); } } #else @@ -2021,7 +2027,7 @@ static void sub_8079E44(u8 whichParty) lsls r0, 24\n\ lsrs r6, r0, 24\n\ movs r7, 0\n\ - ldr r0, =sTradeMenuData\n\ + ldr r0, =sTradeData\n\ ldr r0, [r0]\n\ adds r0, 0x36\n\ adds r0, r6\n\ @@ -2045,11 +2051,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, =sTradeMenuData\n\ + ldr r0, =sTradeData\n\ ldr r0, [r0]\n\ adds r0, 0x36\n\ adds r0, r6\n\ @@ -2065,17 +2071,17 @@ _08079E94:\n\ } #endif // NONMATCHING -static void sub_8079EA8(u8 whichParty) +static void InitTradeMenuPartyPositions(u8 whichParty) { int i; - for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { - gSprites[sTradeMenuData->partyIcons[whichParty][i]].invisible = FALSE; - gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; - gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; - gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos2.x = 0; - gSprites[sTradeMenuData->partyIcons[whichParty][i]].pos2.y = 0; + gSprites[sTradeData->partyIcons[whichParty][i]].invisible = FALSE; + gSprites[sTradeData->partyIcons[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; + gSprites[sTradeData->partyIcons[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; + gSprites[sTradeData->partyIcons[whichParty][i]].pos2.x = 0; + gSprites[sTradeData->partyIcons[whichParty][i]].pos2.y = 0; } } @@ -2091,9 +2097,9 @@ static void sub_8079F88(u8 whichParty) CopyBgTilemapBufferToVram(1); sub_8079E44(whichParty); PrintPartyNicknamesForTradeMenu(whichParty); - sub_8079EA8(whichParty); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); - sTradeMenuData->unk_74[whichParty] = 0; + InitTradeMenuPartyPositions(whichParty); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); + sTradeData->drawPartyState[whichParty] = 0; } static void sub_807A000(u8 taskId) @@ -2115,11 +2121,11 @@ static void sub_807A048(u16 a0, u8 validity) for (i = 0; i < 4; i++) { - if (sTradeMenuData->unk_8D0[i].unk_0 == FALSE) + if (sTradeData->unk_8D0[i].unk_0 == FALSE) { - sTradeMenuData->unk_8D0[i].unk_2 = a0; //TODO: always 3 or 5 - sTradeMenuData->unk_8D0[i].monValidity = validity; - sTradeMenuData->unk_8D0[i].unk_0 = TRUE; + sTradeData->unk_8D0[i].unk_2 = a0; //TODO: always 3 or 5 + sTradeData->unk_8D0[i].monValidity = validity; + sTradeData->unk_8D0[i].unk_0 = TRUE; break; } } @@ -2132,7 +2138,7 @@ static u32 sub_807A09C(void) for (i = 0; i < 4; i++) { - acc += sTradeMenuData->unk_8D0[i].unk_0; + acc += sTradeData->unk_8D0[i].unk_0; } return acc; @@ -2144,18 +2150,18 @@ static void sub_807A0C4(void) for (i = 0; i < 4; i++) { - if (sTradeMenuData->unk_8D0[i].unk_0) + if (sTradeData->unk_8D0[i].unk_0) { - if (sTradeMenuData->unk_8D0[i].unk_2) + if (sTradeData->unk_8D0[i].unk_2) { - sTradeMenuData->unk_8D0[i].unk_2--; + sTradeData->unk_8D0[i].unk_2--; } else { - switch (sTradeMenuData->unk_8D0[i].monValidity) + switch (sTradeData->unk_8D0[i].monValidity) { case 0: - SendLinkData(sTradeMenuData->linkData, 20); + SendLinkData(sTradeData->linkData, 20); break; case 1: PrintTradeMessage(TRADE_MSG_STANDBY); @@ -2178,7 +2184,7 @@ static void sub_807A0C4(void) PrintTradeMessage(TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED); break; } - sTradeMenuData->unk_8D0[i].unk_0 = FALSE; + sTradeData->unk_8D0[i].unk_0 = FALSE; } } } @@ -2197,50 +2203,50 @@ static bool8 sub_807A1F0(void) { struct SpriteSheet sheet; - if (sTradeMenuData->unk_A8 < 14) + if (sTradeData->unk_A8 < 14) { - sheet.data = gUnknown_02032188[sTradeMenuData->unk_A8]; + sheet.data = sTradeStringBuffer[sTradeData->unk_A8]; sheet.size = 0x100; - sheet.tag = 200 + sTradeMenuData->unk_A8; + sheet.tag = 200 + sTradeData->unk_A8; } - switch (sTradeMenuData->unk_A8) + switch (sTradeData->unk_A8) { case 0 ... 7: LoadSpriteSheet(&sheet); - sTradeMenuData->unk_A8++; + sTradeData->unk_A8++; break; case 8: - sTradeMenuData->unk_72 = LoadSpriteSheet(&sheet); - sTradeMenuData->unk_A8++; + sTradeData->unk_72 = LoadSpriteSheet(&sheet); + sTradeData->unk_A8++; break; case 9 ... 13: LoadSpriteSheet(&sheet); - sTradeMenuData->unk_A8++; + sTradeData->unk_A8++; break; case 14: LoadSpritePalette(&gSpritePalette_TradeScreenText); - sTradeMenuData->unk_A8++; + sTradeData->unk_A8++; break; case 15: LoadSpritePalette(&gUnknown_0832DC44); - sTradeMenuData->unk_A8++; + sTradeData->unk_A8++; break; case 16: LoadSpriteSheet(&gUnknown_0832DC3C); - sTradeMenuData->unk_A8++; + sTradeData->unk_A8++; break; case 17: - sTradeMenuData->unk_A8 = 0; + sTradeData->unk_A8 = 0; return TRUE; } return FALSE; } -static void sub_807A308(const u8 *a0, u8 *a1, u8 unused) +static void sub_807A308(const u8 *str, u8 *dest, u8 unused) { - sub_80C6D80(a0, a1, 0, 0, 6); + sub_80C6D80(str, dest, 0, 0, 6); } static void sub_807A320(u8 whichParty) @@ -2250,42 +2256,42 @@ static void sub_807A320(u8 whichParty) switch (whichParty) { case TRADE_PLAYER: - for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE) { - sTradeMenuData->isLiveMon[whichParty][i] = FALSE; - sTradeMenuData->isEgg[whichParty][i] = TRUE; + sTradeData->isLiveMon[whichParty][i] = FALSE; + sTradeData->isEgg[whichParty][i] = TRUE; } else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) { - sTradeMenuData->isLiveMon[whichParty][i] = FALSE; - sTradeMenuData->isEgg[whichParty][i] = FALSE; + sTradeData->isLiveMon[whichParty][i] = FALSE; + sTradeData->isEgg[whichParty][i] = FALSE; } else { - sTradeMenuData->isLiveMon[whichParty][i] = TRUE; - sTradeMenuData->isEgg[whichParty][i] = FALSE; + sTradeData->isLiveMon[whichParty][i] = TRUE; + sTradeData->isEgg[whichParty][i] = FALSE; } } break; case TRADE_PARTNER: - for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) { - sTradeMenuData->isLiveMon[whichParty][i] = FALSE; - sTradeMenuData->isEgg[whichParty][i] = TRUE; + sTradeData->isLiveMon[whichParty][i] = FALSE; + sTradeData->isEgg[whichParty][i] = TRUE; } else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) { - sTradeMenuData->isLiveMon[whichParty][i] = FALSE; - sTradeMenuData->isEgg[whichParty][i] = FALSE; + sTradeData->isLiveMon[whichParty][i] = FALSE; + sTradeData->isEgg[whichParty][i] = FALSE; } else { - sTradeMenuData->isLiveMon[whichParty][i] = TRUE; - sTradeMenuData->isEgg[whichParty][i] = FALSE; + sTradeData->isLiveMon[whichParty][i] = TRUE; + sTradeData->isEgg[whichParty][i] = FALSE; } } break; @@ -2299,19 +2305,19 @@ static void GetTradePartyHPBarLevels(u8 who) switch (who) { case TRADE_PLAYER: - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeData->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); + sTradeData->hpBarLevels[TRADE_PLAYER][i] = GetHPBarLevel(curHp, maxHp); } break; case TRADE_PARTNER: - for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) + for (i = 0; i < sTradeData->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); + sTradeData->hpBarLevels[TRADE_PARTNER][i] = GetHPBarLevel(curHp, maxHp); } break; } @@ -2323,9 +2329,9 @@ static void SetTradePartyHPBarSprites(void) for (i = 0; i < 2; i++) { - for (j = 0; j < sTradeMenuData->partyCounts[i]; j++) + for (j = 0; j < sTradeData->partyCounts[i]; j++) { - SetPartyHPBarSprite(&gSprites[sTradeMenuData->partyIcons[i][j]], 4 - sTradeMenuData->hpBarLevels[i][j]); + SetPartyHPBarSprite(&gSprites[sTradeData->partyIcons[i][j]], 4 - sTradeData->hpBarLevels[i][j]); } } } @@ -2336,10 +2342,10 @@ static void sub_807A5B0(void) for (i = 0; i < 11; i++) { - if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenuData->unk_A9[i] != 0) + if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeData->unk_A9[i] != 0) { - if (sTradeMenuData->unk_A9[i] < 64) - gSaveBlock1Ptr->giftRibbons[i] = sTradeMenuData->unk_A9[i]; + if (sTradeData->unk_A9[i] < 64) + gSaveBlock1Ptr->giftRibbons[i] = sTradeData->unk_A9[i]; } } } @@ -2548,11 +2554,11 @@ int sub_807A7E0(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuS return 0; } -int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species, u16 a2, u8 a3) +int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species2, u16 species, u8 isObedientBitSet) { u8 unk = a0.unk_01_0; - if (IsDeoxysOrMewUntradable(a2, a3)) + if (IsDeoxysOrMewUntradable(species, isObedientBitSet)) { return 1; } @@ -2562,12 +2568,12 @@ int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species, u16 a return 0; } - if (species == SPECIES_EGG) + if (species2 == SPECIES_EGG) { return 2; } - if (IsSpeciesInHoennDex(species)) + if (IsSpeciesInHoennDex(species2)) { return 0; } @@ -2861,7 +2867,7 @@ static void sub_807AB28(void) { struct BgAffineDstData affine; - DoBgAffineSet(&affine, sTradeData->unk_D4 * 0x100, sTradeData->unk_D6 * 0x100, sTradeData->unk_DC, sTradeData->unk_DE, sTradeData->unk_E8, sTradeData->unk_E8, sTradeData->unk_EC); + DoBgAffineSet(&affine, sTradeWindowData->texX * 0x100, sTradeWindowData->texY * 0x100, sTradeWindowData->scrX, sTradeWindowData->scrY, sTradeWindowData->sXY, sTradeWindowData->sXY, sTradeWindowData->alpha); SetGpuReg(REG_OFFSET_BG2PA, affine.pa); SetGpuReg(REG_OFFSET_BG2PB, affine.pb); SetGpuReg(REG_OFFSET_BG2PC, affine.pc); @@ -2876,14 +2882,14 @@ static void sub_807ABCC(void) { u16 dispcnt; - SetGpuReg(REG_OFFSET_BG1VOFS, sTradeData->bg1vofs); - SetGpuReg(REG_OFFSET_BG1HOFS, sTradeData->bg1hofs); + SetGpuReg(REG_OFFSET_BG1VOFS, sTradeWindowData->bg1vofs); + SetGpuReg(REG_OFFSET_BG1HOFS, sTradeWindowData->bg1hofs); dispcnt = GetGpuReg(REG_OFFSET_DISPCNT); if ((dispcnt & 7) == DISPCNT_MODE_0) { - SetGpuReg(REG_OFFSET_BG2VOFS, sTradeData->bg2vofs); - SetGpuReg(REG_OFFSET_BG2HOFS, sTradeData->bg2hofs); + SetGpuReg(REG_OFFSET_BG2VOFS, sTradeWindowData->bg2vofs); + SetGpuReg(REG_OFFSET_BG2HOFS, sTradeWindowData->bg2hofs); } else { @@ -2901,31 +2907,31 @@ static void sub_807AC24(void) static void sub_807AC3C(void) { - sTradeData->unk_8A = 0; - sTradeData->unk_88 = 0; - sTradeData->unk_89 = 0; + sTradeWindowData->unk_8A = 0; + sTradeWindowData->unk_88 = 0; + sTradeWindowData->unk_89 = 0; } static void sub_807AC64(void) { - if (sTradeData->unk_88 == sTradeData->unk_89) - sTradeData->unk_8A++; + if (sTradeWindowData->unk_88 == sTradeWindowData->unk_89) + sTradeWindowData->unk_8A++; else - sTradeData->unk_8A = 0; + sTradeWindowData->unk_8A = 0; - if (sTradeData->unk_8A > 300) + if (sTradeWindowData->unk_8A > 300) { CloseLink(); SetMainCallback2(CB2_LinkError); - sTradeData->unk_8A = 0; - sTradeData->unk_89 = 0; - sTradeData->unk_88 = 0; + sTradeWindowData->unk_8A = 0; + sTradeWindowData->unk_89 = 0; + sTradeWindowData->unk_88 = 0; } - sTradeData->unk_89 = sTradeData->unk_88; + sTradeWindowData->unk_89 = sTradeWindowData->unk_88; } -static u32 sub_807ACDC(void) +static u32 TradeGetMultiplayerId(void) { if (gReceivedRemoteLinkPlayers) return GetMultiplayerId(); @@ -2963,14 +2969,14 @@ static void sub_807ACFC(u8 whichParty, u8 a1) HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[whichParty * 2 + 1], species, personality); LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); - sTradeData->tradeSpecies[whichParty] = species; - sTradeData->unk_68[whichParty] = personality; + sTradeWindowData->monSpecies[whichParty] = species; + sTradeWindowData->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; + sTradeWindowData->pokePicSpriteIdxs[whichParty] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); + gSprites[sTradeWindowData->pokePicSpriteIdxs[whichParty]].invisible = TRUE; + gSprites[sTradeWindowData->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; break; } } @@ -2985,7 +2991,7 @@ void sub_807AE50(void) gLinkType = 0x1144; CloseLink(); } - sTradeData = AllocZeroed(sizeof(*sTradeData)); + sTradeWindowData = AllocZeroed(sizeof(*sTradeWindowData)); AllocateMonSpritesGfx(); ResetTasks(); ResetSpriteData(); @@ -2994,25 +3000,25 @@ void sub_807AE50(void) sub_807B170(); sub_807AC3C(); gMain.state++; - sTradeData->unk_8C = 0; - sTradeData->state = 0; - sTradeData->isLinkTrade = TRUE; - sTradeData->unk_D4 = 64; - sTradeData->unk_D6 = 64; - sTradeData->unk_D8 = 0; - sTradeData->unk_DA = 0; - sTradeData->unk_DC = 120; - sTradeData->unk_DE = 80; - sTradeData->unk_E8 = 256; - sTradeData->unk_EC = 0; + sTradeWindowData->neverRead_8C = 0; + sTradeWindowData->state = 0; + sTradeWindowData->isLinkTrade = TRUE; + sTradeWindowData->texX = 64; + sTradeWindowData->texY = 64; + sTradeWindowData->neverRead_D8 = 0; + sTradeWindowData->neverRead_DA = 0; + sTradeWindowData->scrX = 120; + sTradeWindowData->scrY = 80; + sTradeWindowData->sXY = 256; + sTradeWindowData->alpha = 0; break; case 1: if (!gReceivedRemoteLinkPlayers) { - sTradeData->unk_FA = 1; + sTradeWindowData->isCableLink = TRUE; OpenLink(); gMain.state++; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } else { @@ -3020,9 +3026,9 @@ void sub_807AE50(void) } break; case 2: - if (++sTradeData->timer > 60) + if (++sTradeWindowData->timer > 60) { - sTradeData->timer = 0; + sTradeWindowData->timer = 0; gMain.state++; } break; @@ -3031,7 +3037,7 @@ void sub_807AE50(void) { if (GetLinkPlayerCount_2() >= GetSavedPlayerCount()) { - if (++sTradeData->timer > 30) + if (++sTradeWindowData->timer > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -3053,9 +3059,9 @@ void sub_807AE50(void) gMain.state++; break; case 5: - sTradeData->unk_72 = 0; - sTradeData->unk_73 = 0; - sTradeData->unk_93 = 0; + sTradeWindowData->unk_72 = 0; + sTradeWindowData->unk_73 = 0; + sTradeWindowData->unk_93 = 0; sub_807ACFC(TRADE_PLAYER, 0); gMain.state++; break; @@ -3142,8 +3148,7 @@ static void sub_807B170(void) LoadCompressedPalette(gBattleTextboxPalette, 0, 0x20); } -// In-game trade init -static void sub_807B270(void) +static void CB2_InGameTrade(void) { u8 otName[11]; @@ -3157,25 +3162,25 @@ static void sub_807B270(void) StringCopy(gLinkPlayers[1].name, otName); gLinkPlayers[0].language = LANGUAGE_ENGLISH; gLinkPlayers[1].language = GetMonData(&gEnemyParty[0], MON_DATA_LANGUAGE); - sTradeData = AllocZeroed(sizeof(*sTradeData)); + sTradeWindowData = AllocZeroed(sizeof(*sTradeWindowData)); AllocateMonSpritesGfx(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); SetVBlankCallback(sub_807AC24); sub_807B170(); - sTradeData->isLinkTrade = FALSE; - sTradeData->unk_8C = 0; - sTradeData->state = 0; - sTradeData->unk_D4 = 64; - sTradeData->unk_D6 = 64; - sTradeData->unk_D8 = 0; - sTradeData->unk_DA = 0; - sTradeData->unk_DC = 120; - sTradeData->unk_DE = 80; - sTradeData->unk_E8 = 256; - sTradeData->unk_EC = 0; - sTradeData->timer = 0; + sTradeWindowData->isLinkTrade = FALSE; + sTradeWindowData->neverRead_8C = 0; + sTradeWindowData->state = 0; + sTradeWindowData->texX = 64; + sTradeWindowData->texY = 64; + sTradeWindowData->neverRead_D8 = 0; + sTradeWindowData->neverRead_DA = 0; + sTradeWindowData->scrX = 120; + sTradeWindowData->scrY = 80; + sTradeWindowData->sXY = 256; + sTradeWindowData->alpha = 0; + sTradeWindowData->timer = 0; gMain.state = 5; break; case 5: @@ -3226,7 +3231,7 @@ static void sub_807B270(void) UpdatePaletteFade(); } -static void sub_807B464(u8 partyIdx) +static void UpdatePokedexForReceivedMon(u8 partyIdx) { struct Pokemon *mon = &gPlayerParty[partyIdx]; @@ -3240,7 +3245,8 @@ static void sub_807B464(u8 partyIdx) } } -static void sub_807B4C4(void) +// Functionally nop after commented code +static void EnableNationalDexFromLinkPlayer(void) { u8 mpId = GetMultiplayerId(); // Originally in Ruby but commented out @@ -3248,49 +3254,48 @@ 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!! - sTradeData->mon = *playerMon; + sTradeWindowData->mon = *playerMon; *playerMon = *partnerMon; - *partnerMon = sTradeData->mon; + *partnerMon = sTradeWindowData->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(); + EnableNationalDexFromLinkPlayer(); } static void sub_807B5B8(void) { - switch (sTradeData->unk_93) + switch (sTradeWindowData->unk_93) { case 1: if (IsLinkTaskFinished()) { - Trade_SendData(sTradeData); - sTradeData->unk_93++; + Trade_SendData(sTradeWindowData); + sTradeWindowData->unk_93++; } // fallthrough case 2: - sTradeData->unk_93 = 0; + sTradeWindowData->unk_93 = 0; break; } } @@ -3310,8 +3315,8 @@ static void sub_807B62C(u8 a0) switch (a0) { case 0: - sTradeData->bg2vofs = 0; - sTradeData->bg2hofs = 180; + sTradeWindowData->bg2vofs = 0; + sTradeWindowData->bg2hofs = 180; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | @@ -3327,8 +3332,8 @@ static void sub_807B62C(u8 a0) DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); break; case 1: - sTradeData->bg1hofs = 0; - sTradeData->bg1vofs = 348; + sTradeWindowData->bg1hofs = 0; + sTradeWindowData->bg1vofs = 348; SetGpuReg(REG_OFFSET_BG1VOFS, 348); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | @@ -3341,13 +3346,13 @@ static void sub_807B62C(u8 a0) BGCNT_SCREENBASE(18) | BGCNT_TXT256x512); - if (sTradeData->unk_FA) + if (sTradeWindowData->isCableLink) { - DmaCopy16Defvars(3, gUnknown_083369A0, (void *) BG_SCREEN_ADDR(5), 0x1000); + DmaCopy16Defvars(3, sTradeTilemap_GbaCable, (void *) BG_SCREEN_ADDR(5), 0x1000); } else { - DmaCopy16Defvars(3, gUnknown_083359A0, (void *) BG_SCREEN_ADDR(5), 0x1000); + DmaCopy16Defvars(3, sTradeTilemap_GbaWireless, (void *) BG_SCREEN_ADDR(5), 0x1000); } DmaCopyLarge16(3, gTradeGba_Gfx, (void *) BG_CHAR_ADDR(0), 0x1420, 0x1000); @@ -3357,9 +3362,9 @@ static void sub_807B62C(u8 a0) DISPCNT_OBJ_ON); break; case 2: - sTradeData->bg1vofs = 0; - sTradeData->bg1hofs = 0; - if (!sTradeData->unk_FA) + sTradeWindowData->bg1vofs = 0; + sTradeWindowData->bg1hofs = 0; + if (!sTradeWindowData->isCableLink) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3382,7 +3387,7 @@ static void sub_807B62C(u8 a0) LoadPalette(sTradePal_Black, 48, 0x20); LZ77UnCompVram(sTradeGfx_WirelessSignal, (void *) BG_CHAR_ADDR(1)); LZ77UnCompVram(sTradeTilemap_WirelessSignal, (void *) BG_SCREEN_ADDR(18)); - sTradeData->bg2vofs = 80; + sTradeWindowData->bg2vofs = 80; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | @@ -3399,26 +3404,26 @@ static void sub_807B62C(u8 a0) BGCNT_256COLOR | BGCNT_SCREENBASE(18) | BGCNT_AFF128x128); - sTradeData->unk_D4 = 64; - sTradeData->unk_D6 = 92; - sTradeData->unk_E8 = 32; - sTradeData->unk_EA = 1024; - sTradeData->unk_EC = 0; + sTradeWindowData->texX = 64; + sTradeWindowData->texY = 92; + sTradeWindowData->sXY = 32; + sTradeWindowData->unk_EA = 1024; + sTradeWindowData->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 (sTradeData->unk_FA) + if (sTradeWindowData->isCableLink) { - DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); + DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); } else { - DmaCopy16Defvars(3, gUnknown_083358A0, (void *) BG_SCREEN_ADDR(18), 0x100); + DmaCopy16Defvars(3, sTradeAffineMap_GbaWireless, (void *) BG_SCREEN_ADDR(18), 0x100); } break; case 5: - sTradeData->bg1vofs = 0; - sTradeData->bg1hofs = 0; + sTradeWindowData->bg1vofs = 0; + sTradeWindowData->bg1hofs = 0; break; case 6: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | @@ -3430,28 +3435,28 @@ static void sub_807B62C(u8 a0) BGCNT_256COLOR | BGCNT_SCREENBASE(18) | BGCNT_AFF128x128); - sTradeData->unk_D4 = 64; - sTradeData->unk_D6 = 92; - sTradeData->unk_E8 = 256; - sTradeData->unk_EA = 128; - sTradeData->unk_DC = 120; - sTradeData->unk_DE = 80; - sTradeData->unk_EC = 0; + sTradeWindowData->texX = 64; + sTradeWindowData->texY = 92; + sTradeWindowData->sXY = 256; + sTradeWindowData->unk_EA = 128; + sTradeWindowData->scrX = 120; + sTradeWindowData->scrY = 80; + sTradeWindowData->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 (sTradeData->unk_FA) + if (sTradeWindowData->isCableLink) { - DmaCopy16Defvars(3, gUnknown_083357A0, (void *) BG_SCREEN_ADDR(18), 0x100); + DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); } else { - DmaCopy16Defvars(3, gUnknown_083358A0, (void *) BG_SCREEN_ADDR(18), 0x100); + DmaCopy16Defvars(3, sTradeAffineMap_GbaWireless, (void *) BG_SCREEN_ADDR(18), 0x100); } break; case 7: - sTradeData->bg2vofs = 0; - sTradeData->bg2hofs = 0; + sTradeWindowData->bg2vofs = 0; + sTradeWindowData->bg2hofs = 0; SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(1) | @@ -3482,7 +3487,7 @@ static void SetTradeSceneStrings(void) u8 name[20]; const struct InGameTrade *ingameTrade; - if (sTradeData->isLinkTrade) + if (sTradeWindowData->isLinkTrade) { mpId = GetMultiplayerId(); StringCopy(gStringVar1, gLinkPlayers[mpId ^ 1].name); @@ -3501,9 +3506,9 @@ static void SetTradeSceneStrings(void) } } -static u8 sub_807BBC8(void) +static bool8 sub_807BBC8(void) { - if (sTradeData->unk_FA) + if (sTradeWindowData->isCableLink) { return sub_807BBEC(); } @@ -3517,57 +3522,57 @@ static bool8 sub_807BBEC(void) { u16 evoTarget; - switch (sTradeData->state) + switch (sTradeWindowData->state) { case 0: - gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = -180; - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[sTradeData->tradeSpecies[0]].y_offset; - sTradeData->state++; - sTradeData->cachedMapMusic = GetCurrentMapMusic(); + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = -180; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PLAYER]].y_offset; + sTradeWindowData->state++; + sTradeWindowData->cachedMapMusic = GetCurrentMapMusic(); PlayNewMapMusic(MUS_SHINKA); break; case 1: - if (sTradeData->bg2hofs > 0) + if (sTradeWindowData->bg2hofs > 0) { - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x += 3; - sTradeData->bg2hofs -= 3; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; + sTradeWindowData->bg2hofs -= 3; } else { - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = 0; - sTradeData->bg2hofs = 0; - sTradeData->state = 10; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = 0; + sTradeWindowData->bg2hofs = 0; + sTradeWindowData->state = 10; } break; case 10: StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); DrawTextOnTradeWindow(0, gStringVar4, 0); - if (sTradeData->tradeSpecies[0] != SPECIES_EGG) + if (sTradeWindowData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) { - PlayCry1(sTradeData->tradeSpecies[0], 0); + PlayCry1(sTradeWindowData->monSpecies[TRADE_PLAYER], 0); } - sTradeData->state = 11; - sTradeData->timer = 0; + sTradeWindowData->state = 11; + sTradeWindowData->timer = 0; break; case 11: - if (++sTradeData->timer == 80) + if (++sTradeWindowData->timer == 80) { - sTradeData->unk_D2 = sub_807671C(sTradeData->pokePicSpriteIdxs[0], gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); - sTradeData->state++; + sTradeWindowData->unk_D2 = sub_807671C(sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeWindowData->state++; StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); DrawTextOnTradeWindow(0, gStringVar4, 0); } break; case 12: - if (gSprites[sTradeData->unk_D2].callback == SpriteCallbackDummy) + if (gSprites[sTradeWindowData->unk_D2].callback == SpriteCallbackDummy) { - sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); - gSprites[sTradeData->unk_D3].callback = sub_807E5D8; - DestroySprite(&gSprites[sTradeData->unk_D2]); - sTradeData->state++; + sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[sTradeWindowData->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[sTradeWindowData->unk_D2]); + sTradeWindowData->state++; } break; case 13: @@ -3575,7 +3580,7 @@ static bool8 sub_807BBEC(void) break; case 14: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state = 20; + sTradeWindowData->state = 20; break; case 20: if (!gPaletteFade.active) @@ -3583,72 +3588,72 @@ static bool8 sub_807BBEC(void) sub_807B62C(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); CopyWindowToVram(0, 3); - sTradeData->state++; + sTradeWindowData->state++; } break; case 21: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 22: if (!gPaletteFade.active) { - sTradeData->state = 23; + sTradeWindowData->state = 23; } break; case 23: - if (sTradeData->unk_EA > 0x100) + if (sTradeWindowData->unk_EA > 0x100) { - sTradeData->unk_EA -= 0x34; + sTradeWindowData->unk_EA -= 0x34; } else { sub_807B62C(1); - sTradeData->unk_EA = 0x80; - sTradeData->state++; - sTradeData->timer = 0; + sTradeWindowData->unk_EA = 0x80; + sTradeWindowData->state++; + sTradeWindowData->timer = 0; } - sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; + sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; break; case 24: - if (++sTradeData->timer > 20) + if (++sTradeWindowData->timer > 20) { sub_807AB28(); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - sTradeData->state++; + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeWindowData->state++; } break; case 25: - if (gSprites[sTradeData->unk_91].animEnded) + if (gSprites[sTradeWindowData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeData->unk_91]); + DestroySprite(&gSprites[sTradeWindowData->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++; + sTradeWindowData->state++; } break; case 26: - if (--sTradeData->bg1vofs == 316) + if (--sTradeWindowData->bg1vofs == 316) { - sTradeData->state++; + sTradeWindowData->state++; } - if (sTradeData->bg1vofs == 328) + if (sTradeWindowData->bg1vofs == 328) { - sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + sTradeWindowData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); } break; case 27: - sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); - StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); - sTradeData->state++; + sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); + StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); + sTradeWindowData->state++; break; case 28: - if ((sTradeData->bg1vofs -= 2) == 166) + if ((sTradeWindowData->bg1vofs -= 2) == 166) { - sTradeData->state = 200; + sTradeWindowData->state = 200; } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3656,126 +3661,126 @@ static bool8 sub_807BBEC(void) 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) + gSprites[sTradeWindowData->unk_90].pos1.y -= 2; + gSprites[sTradeWindowData->unk_91].pos1.y -= 2; + if (gSprites[sTradeWindowData->unk_90].pos1.y < -8) { - sTradeData->state = 29; + sTradeWindowData->state = 29; } break; case 29: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - sTradeData->state = 30; + sTradeWindowData->state = 30; break; case 30: if (!gPaletteFade.active) { - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); + DestroySprite(&gSprites[sTradeWindowData->unk_90]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); sub_807B62C(2); - sTradeData->state++; + sTradeWindowData->state++; } break; case 31: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); - sTradeData->state++; + sTradeWindowData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + sTradeWindowData->state++; break; case 32: if (!gPaletteFade.active) { PlaySE(SE_TK_WARPOUT); - sTradeData->state++; + sTradeWindowData->state++; } - gSprites[sTradeData->unk_90].pos2.y -= 3; - gSprites[sTradeData->unk_91].pos2.y += 3; + gSprites[sTradeWindowData->unk_90].pos2.y -= 3; + gSprites[sTradeWindowData->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[sTradeWindowData->unk_90].pos2.y -= 3; + gSprites[sTradeWindowData->unk_91].pos2.y += 3; + if (gSprites[sTradeWindowData->unk_90].pos2.y <= -90) { - gSprites[sTradeData->unk_90].data[1] = 1; - gSprites[sTradeData->unk_91].data[1] = 1; - sTradeData->state++; + gSprites[sTradeWindowData->unk_90].data[1] = 1; + gSprites[sTradeWindowData->unk_91].data[1] = 1; + sTradeWindowData->state++; } break; case 34: BlendPalettes(0x1, 16, RGB_WHITEALPHA); - sTradeData->state++; + sTradeWindowData->state++; break; case 35: BlendPalettes(0x1, 0, RGB_WHITEALPHA); - sTradeData->state++; + sTradeWindowData->state++; break; case 36: BlendPalettes(0x1, 16, RGB_WHITEALPHA); - sTradeData->state++; + sTradeWindowData->state++; break; case 37: - if (!IsMonSpriteNotFlipped(sTradeData->tradeSpecies[0])) + if (!IsMonSpriteNotFlipped(sTradeWindowData->monSpecies[TRADE_PLAYER])) { - gSprites[sTradeData->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; - gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.affineMode = 3; - CalcCenterToCornerVec(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0, 3, 3); - StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0); + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); } else { - StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0); + StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); } - StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.x = 60; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 180; - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.y = 192; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = -32; - gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[sTradeData->pokePicSpriteIdxs[1]].invisible = FALSE; - sTradeData->state++; + StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.x = 60; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 180; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.y = 192; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = -32; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = FALSE; + sTradeWindowData->state++; break; case 38: - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y -= 3; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y += 3; - if (gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y >= -163) + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y -= 3; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y += 3; + if (gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -160 && gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y >= -163) { PlaySE(SE_TK_WARPIN); } - if (gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y < -222) + if (gSprites[sTradeWindowData->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[0]].invisible = TRUE; - gSprites[sTradeData->pokePicSpriteIdxs[1]].invisible = TRUE; + gSprites[sTradeWindowData->unk_90].data[1] = 0; + gSprites[sTradeWindowData->unk_91].data[1] = 0; + sTradeWindowData->state++; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = TRUE; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = TRUE; BlendPalettes(0x1, 0, RGB_WHITEALPHA); } 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) + gSprites[sTradeWindowData->unk_90].pos2.y -= 3; + gSprites[sTradeWindowData->unk_91].pos2.y += 3; + if (gSprites[sTradeWindowData->unk_90].pos2.y <= -222) { BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - sTradeData->state++; - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeWindowData->state++; + DestroySprite(&gSprites[sTradeWindowData->unk_90]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); } break; case 40: if (!gPaletteFade.active) { - sTradeData->state++; + sTradeWindowData->state++; sub_807B62C(1); - sTradeData->bg1vofs = 166; - sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); - StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeWindowData->bg1vofs = 166; + sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); + StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); } break; case 41: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 42: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3784,76 +3789,76 @@ static bool8 sub_807BBEC(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeData->state++; + sTradeWindowData->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) + gSprites[sTradeWindowData->unk_90].pos2.y += 3; + gSprites[sTradeWindowData->unk_91].pos2.y += 3; + if (gSprites[sTradeWindowData->unk_90].pos2.y + gSprites[sTradeWindowData->unk_90].pos1.y == 64) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 44: - if ((sTradeData->bg1vofs += 2) > 316) + if ((sTradeWindowData->bg1vofs += 2) > 316) { - sTradeData->bg1vofs = 316; - sTradeData->state++; + sTradeWindowData->bg1vofs = 316; + sTradeWindowData->state++; } break; case 45: - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); - sTradeData->state++; - sTradeData->timer = 0; + DestroySprite(&gSprites[sTradeWindowData->unk_90]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); + sTradeWindowData->state++; + sTradeWindowData->timer = 0; break; case 46: - if (++sTradeData->timer == 10) + if (++sTradeWindowData->timer == 10) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 47: - if (++sTradeData->bg1vofs > 348) + if (++sTradeWindowData->bg1vofs > 348) { - sTradeData->bg1vofs = 348; - sTradeData->state++; + sTradeWindowData->bg1vofs = 348; + sTradeWindowData->state++; } - if (sTradeData->bg1vofs == 328 && sTradeData->unk_FA) + if (sTradeWindowData->bg1vofs == 328 && sTradeWindowData->isCableLink) { - sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); - gSprites[sTradeData->unk_92].callback = sub_807AAE0; + sTradeWindowData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + gSprites[sTradeWindowData->unk_92].callback = sub_807AAE0; } break; case 48: - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - sTradeData->state = 50; + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeWindowData->state = 50; break; case 50: - if (gSprites[sTradeData->unk_91].animEnded) + if (gSprites[sTradeWindowData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeData->unk_91]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); sub_807B62C(6); - sTradeData->state++; + sTradeWindowData->state++; PlaySE(SE_W028); } break; case 51: - if (sTradeData->unk_EA < 0x400) + if (sTradeWindowData->unk_EA < 0x400) { - sTradeData->unk_EA += 0x34; + sTradeWindowData->unk_EA += 0x34; } else { - sTradeData->unk_EA = 0x400; - sTradeData->state++; + sTradeWindowData->unk_EA = 0x400; + sTradeWindowData->state++; } - sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; + sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; break; case 52: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state = 60; + sTradeWindowData->state = 60; break; case 60: @@ -3862,13 +3867,13 @@ static bool8 sub_807BBEC(void) sub_807B62C(5); sub_807B62C(7); gPaletteFade.bufferTransferDisabled = TRUE; - sTradeData->state++; + sTradeWindowData->state++; } break; case 61: gPaletteFade.bufferTransferDisabled = FALSE; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 62: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3877,40 +3882,40 @@ static bool8 sub_807BBEC(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeData->state++; + sTradeWindowData->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; + sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); + gSprites[sTradeWindowData->unk_D3].data[3] = 74; + gSprites[sTradeWindowData->unk_D3].callback = sub_807E6AC; + StartSpriteAnim(&gSprites[sTradeWindowData->unk_D3], 1); + StartSpriteAffineAnim(&gSprites[sTradeWindowData->unk_D3], 2); + BlendPalettes(1 << (16 + gSprites[sTradeWindowData->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); + sTradeWindowData->state++; + sTradeWindowData->timer = 0; break; case 64: - BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - sTradeData->state++; + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeWindowData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeWindowData->state++; break; case 65: - if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy) + if (gSprites[sTradeWindowData->unk_D3].callback == SpriteCallbackDummy) { - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], sTradeData->tradeSpecies[1], sTradeData->unk_68[1]); - sTradeData->state++; + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeWindowData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeWindowData->monSpecies[TRADE_PARTNER], sTradeWindowData->monPersonalities[TRADE_PARTNER]); + sTradeWindowData->state++; } break; case 66: - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 120; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[sTradeData->tradeSpecies[1]].y_offset + 60; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.x = 0; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y = 0; - StartSpriteAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); - CreatePokeballSpriteToReleaseMon(sTradeData->pokePicSpriteIdxs[1], gSprites[sTradeData->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->tradeSpecies[1]); - FreeSpriteOamMatrix(&gSprites[sTradeData->unk_D3]); - DestroySprite(&gSprites[sTradeData->unk_D3]); - sTradeData->state++; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 120; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PARTNER]].y_offset + 60; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.x = 0; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y = 0; + StartSpriteAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + CreatePokeballSpriteToReleaseMon(sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeWindowData->monSpecies[TRADE_PARTNER]); + FreeSpriteOamMatrix(&gSprites[sTradeWindowData->unk_D3]); + DestroySprite(&gSprites[sTradeWindowData->unk_D3]); + sTradeWindowData->state++; break; case 67: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3920,82 +3925,82 @@ static bool8 sub_807BBEC(void) DISPCNT_OBJ_ON); StringExpandPlaceholders(gStringVar4, gText_XSentOverY); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeData->state = 167; - sTradeData->timer = 0; + sTradeWindowData->state = 167; + sTradeWindowData->timer = 0; break; // 167 and 267 are extra cases added in for animations case 167: - if (++sTradeData->timer > 60) + if (++sTradeWindowData->timer > 60) { - sTradeData->state = 267; - sTradeData->timer = 0; + sTradeWindowData->state = 267; + sTradeWindowData->timer = 0; } break; case 267: if (IsCryFinished()) { - sTradeData->state = 68; + sTradeWindowData->state = 68; } break; case 68: - if (++sTradeData->timer == 10) + if (++sTradeWindowData->timer == 10) { PlayFanfare(MUS_FANFA5); } - if (sTradeData->timer == 250) + if (sTradeWindowData->timer == 250) { - sTradeData->state++; + sTradeWindowData->state++; StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } break; case 69: - if (++sTradeData->timer == 60) + if (++sTradeWindowData->timer == 60) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 70: CheckPartnersMonForRibbons(); - sTradeData->state++; + sTradeWindowData->state++; break; case 71: - if (sTradeData->isLinkTrade) + if (sTradeWindowData->isLinkTrade) { return TRUE; } else if (gMain.newKeys & A_BUTTON) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 72: // Only if in-game trade - sub_807B4D0(gSpecialVar_0x8005, 0); + TradeMons(gSpecialVar_0x8005, 0); gCB2_AfterEvolution = sub_807B60C; evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[TRADE_PLAYER]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); } - sTradeData->state++; + sTradeWindowData->state++; break; case 73: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 74: if (!gPaletteFade.active) { - PlayNewMapMusic(sTradeData->cachedMapMusic); - if (sTradeData) + PlayNewMapMusic(sTradeWindowData->cachedMapMusic); + if (sTradeWindowData) { FreeAllWindowBuffers(); Free(GetBgTilemapBuffer(3)); Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeData); + FREE_AND_SET_NULL(sTradeWindowData); } SetMainCallback2(CB2_ReturnToField); sub_807E784(); @@ -4009,57 +4014,57 @@ static bool8 sub_807CFC8(void) { u16 evoTarget; - switch (sTradeData->state) + switch (sTradeWindowData->state) { case 0: - gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = -180; - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y = gMonFrontPicCoords[sTradeData->tradeSpecies[0]].y_offset; - sTradeData->state++; - sTradeData->cachedMapMusic = GetCurrentMapMusic(); + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = -180; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PLAYER]].y_offset; + sTradeWindowData->state++; + sTradeWindowData->cachedMapMusic = GetCurrentMapMusic(); PlayNewMapMusic(MUS_SHINKA); break; case 1: - if (sTradeData->bg2hofs > 0) + if (sTradeWindowData->bg2hofs > 0) { - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x += 3; - sTradeData->bg2hofs -= 3; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; + sTradeWindowData->bg2hofs -= 3; } else { - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.x = 0; - sTradeData->bg2hofs = 0; - sTradeData->state = 10; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = 0; + sTradeWindowData->bg2hofs = 0; + sTradeWindowData->state = 10; } break; case 10: StringExpandPlaceholders(gStringVar4, gText_XWillBeSentToY); DrawTextOnTradeWindow(0, gStringVar4, 0); - if (sTradeData->tradeSpecies[0] != SPECIES_EGG) + if (sTradeWindowData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) { - PlayCry1(sTradeData->tradeSpecies[0], 0); + PlayCry1(sTradeWindowData->monSpecies[TRADE_PLAYER], 0); } - sTradeData->state = 11; - sTradeData->timer = 0; + sTradeWindowData->state = 11; + sTradeWindowData->timer = 0; break; case 11: - if (++sTradeData->timer == 80) + if (++sTradeWindowData->timer == 80) { - sTradeData->unk_D2 = sub_807671C(sTradeData->pokePicSpriteIdxs[0], gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); - sTradeData->state++; + sTradeWindowData->unk_D2 = sub_807671C(sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeWindowData->state++; StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); DrawTextOnTradeWindow(0, gStringVar4, 0); } break; case 12: - if (gSprites[sTradeData->unk_D2].callback == SpriteCallbackDummy) + if (gSprites[sTradeWindowData->unk_D2].callback == SpriteCallbackDummy) { - sTradeData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); - gSprites[sTradeData->unk_D3].callback = sub_807E5D8; - DestroySprite(&gSprites[sTradeData->unk_D2]); - sTradeData->state++; + sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); + gSprites[sTradeWindowData->unk_D3].callback = sub_807E5D8; + DestroySprite(&gSprites[sTradeWindowData->unk_D2]); + sTradeWindowData->state++; } break; case 13: @@ -4067,7 +4072,7 @@ static bool8 sub_807CFC8(void) break; case 14: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state = 20; + sTradeWindowData->state = 20; break; case 20: if (!gPaletteFade.active) @@ -4075,77 +4080,77 @@ static bool8 sub_807CFC8(void) sub_807B62C(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); CopyWindowToVram(0, 3); - sTradeData->state++; + sTradeWindowData->state++; } break; case 21: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 22: if (!gPaletteFade.active) { - sTradeData->state = 23; + sTradeWindowData->state = 23; } break; case 23: - if (sTradeData->unk_EA > 0x100) + if (sTradeWindowData->unk_EA > 0x100) { - sTradeData->unk_EA -= 0x34; + sTradeWindowData->unk_EA -= 0x34; } else { sub_807B62C(1); - sTradeData->unk_EA = 0x80; - sTradeData->state = 124; - sTradeData->timer = 0; + sTradeWindowData->unk_EA = 0x80; + sTradeWindowData->state = 124; + sTradeWindowData->timer = 0; } - sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; + sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; break; case 124: - if (++sTradeData->timer > 20) + if (++sTradeWindowData->timer > 20) { sub_807B62C(3); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); - sTradeData->state++; + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); + sTradeWindowData->state++; } break; case 125: - if (gSprites[sTradeData->unk_91].animEnded) + if (gSprites[sTradeWindowData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeData->unk_91]); + DestroySprite(&gSprites[sTradeWindowData->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); - sTradeData->state++; + sTradeWindowData->state++; } break; case 126: if (!FuncIsActiveTask(c3_08054588)) { - sTradeData->state = 26; + sTradeWindowData->state = 26; } break; case 26: - if (--sTradeData->bg1vofs == 316) + if (--sTradeWindowData->bg1vofs == 316) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 27: - sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); - gSprites[sTradeData->unk_90].callback = sub_807AA4C; - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0); - StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); - sTradeData->state++; + sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); + gSprites[sTradeWindowData->unk_90].callback = sub_807AA4C; + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0); + StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); + sTradeWindowData->state++; break; case 28: - if ((sTradeData->bg1vofs -= 3) == 166) + if ((sTradeWindowData->bg1vofs -= 3) == 166) { - sTradeData->state = 200; + sTradeWindowData->state = 200; } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -4153,130 +4158,130 @@ static bool8 sub_807CFC8(void) 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) + gSprites[sTradeWindowData->unk_90].pos1.y -= 2; + gSprites[sTradeWindowData->unk_91].pos1.y -= 2; + if (gSprites[sTradeWindowData->unk_90].pos1.y < -8) { - sTradeData->state = 29; + sTradeWindowData->state = 29; } break; case 29: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - sTradeData->state = 30; + sTradeWindowData->state = 30; break; case 30: if (!gPaletteFade.active) { - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); + DestroySprite(&gSprites[sTradeWindowData->unk_90]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); sub_807B62C(2); - sTradeData->state++; + sTradeWindowData->state++; } break; case 31: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); - sTradeData->state++; + sTradeWindowData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + sTradeWindowData->state++; break; case 32: if (!gPaletteFade.active) { PlaySE(SE_TK_WARPOUT); - sTradeData->state++; + sTradeWindowData->state++; } - gSprites[sTradeData->unk_90].pos2.y -= 3; - gSprites[sTradeData->unk_91].pos2.y += 3; + gSprites[sTradeWindowData->unk_90].pos2.y -= 3; + gSprites[sTradeWindowData->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[sTradeWindowData->unk_90].pos2.y -= 3; + gSprites[sTradeWindowData->unk_91].pos2.y += 3; + if (gSprites[sTradeWindowData->unk_90].pos2.y <= -90) { - gSprites[sTradeData->unk_90].data[1] = 1; - gSprites[sTradeData->unk_91].data[1] = 1; - sTradeData->state++; + gSprites[sTradeWindowData->unk_90].data[1] = 1; + gSprites[sTradeWindowData->unk_91].data[1] = 1; + sTradeWindowData->state++; CreateTask(c3_0805465C, 5); } break; case 34: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - sTradeData->state++; + sTradeWindowData->state++; break; case 35: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - sTradeData->state++; + sTradeWindowData->state++; break; case 36: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - sTradeData->state++; + sTradeWindowData->state++; break; case 37: - if (!IsMonSpriteNotFlipped(sTradeData->tradeSpecies[0])) + if (!IsMonSpriteNotFlipped(sTradeWindowData->monSpecies[TRADE_PLAYER])) { - gSprites[sTradeData->pokePicSpriteIdxs[0]].affineAnims = gSpriteAffineAnimTable_8338ECC; - gSprites[sTradeData->pokePicSpriteIdxs[0]].oam.affineMode = 3; - CalcCenterToCornerVec(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0, 3, 3); - StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0); + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].affineAnims = gSpriteAffineAnimTable_8338ECC; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0, 3, 3); + StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); } else { - StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[0]], 0); + StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); } - StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.x = 40; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 200; - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos1.y = 192; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = -32; - gSprites[sTradeData->pokePicSpriteIdxs[0]].invisible = FALSE; - gSprites[sTradeData->pokePicSpriteIdxs[1]].invisible = FALSE; - sTradeData->state++; + StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.x = 40; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 200; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.y = 192; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = -32; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = FALSE; + sTradeWindowData->state++; break; case 38: - gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y -= 3; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y += 3; - if (gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y < -160 && gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y >= -163) + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y -= 3; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y += 3; + if (gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -160 && gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y >= -163) { PlaySE(SE_TK_WARPIN); } - if (gSprites[sTradeData->pokePicSpriteIdxs[0]].pos2.y < -222) + if (gSprites[sTradeWindowData->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[0]].invisible = TRUE; - gSprites[sTradeData->pokePicSpriteIdxs[1]].invisible = TRUE; + gSprites[sTradeWindowData->unk_90].data[1] = 0; + gSprites[sTradeWindowData->unk_91].data[1] = 0; + sTradeWindowData->state++; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = TRUE; + gSprites[sTradeWindowData->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) + gSprites[sTradeWindowData->unk_90].pos2.y -= 3; + gSprites[sTradeWindowData->unk_91].pos2.y += 3; + if (gSprites[sTradeWindowData->unk_90].pos2.y <= -222) { BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - sTradeData->state++; - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeWindowData->state++; + DestroySprite(&gSprites[sTradeWindowData->unk_90]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); } break; case 40: if (!gPaletteFade.active) { - sTradeData->state++; + sTradeWindowData->state++; sub_807B62C(1); - sTradeData->bg1vofs = 166; + sTradeWindowData->bg1vofs = 166; sub_807B62C(3); - sTradeData->bg2vofs = 412; - sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); - gSprites[sTradeData->unk_90].callback = sub_807AA4C; - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0); - StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeWindowData->bg2vofs = 412; + sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); + gSprites[sTradeWindowData->unk_90].callback = sub_807AA4C; + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0); + StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); } break; case 41: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 42: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4285,16 +4290,16 @@ static bool8 sub_807CFC8(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeData->state++; + sTradeWindowData->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) + gSprites[sTradeWindowData->unk_90].pos2.y += 4; + gSprites[sTradeWindowData->unk_91].pos2.y += 4; + if (gSprites[sTradeWindowData->unk_90].pos2.y + gSprites[sTradeWindowData->unk_90].pos1.y == 64) { - sTradeData->state = 144; - sTradeData->timer = 0; + sTradeWindowData->state = 144; + sTradeWindowData->timer = 0; } break; case 144: @@ -4303,73 +4308,73 @@ static bool8 sub_807CFC8(void) DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON); - sTradeData->bg1vofs += 3; - sTradeData->bg2vofs += 3; - if (++sTradeData->timer == 10) + sTradeWindowData->bg1vofs += 3; + sTradeWindowData->bg2vofs += 3; + if (++sTradeWindowData->timer == 10) { u8 taskId = CreateTask(c3_08054588, 5); gTasks[taskId].data[2] = 1; } - if (sTradeData->bg1vofs > 316) + if (sTradeWindowData->bg1vofs > 316) { - sTradeData->bg1vofs = 316; - sTradeData->state++; + sTradeWindowData->bg1vofs = 316; + sTradeWindowData->state++; } break; case 145: - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); - sTradeData->state++; - sTradeData->timer = 0; + DestroySprite(&gSprites[sTradeWindowData->unk_90]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); + sTradeWindowData->state++; + sTradeWindowData->timer = 0; break; case 146: if (!FuncIsActiveTask(c3_08054588)) { - sTradeData->state = 46; - sTradeData->timer = 0; + sTradeWindowData->state = 46; + sTradeWindowData->timer = 0; } break; case 46: - if (++sTradeData->timer == 10) + if (++sTradeWindowData->timer == 10) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 47: - if (++sTradeData->bg1vofs > 348) + if (++sTradeWindowData->bg1vofs > 348) { - sTradeData->bg1vofs = 348; - sTradeData->state++; + sTradeWindowData->bg1vofs = 348; + sTradeWindowData->state++; } break; case 48: - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - sTradeData->state = 50; + sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeWindowData->state = 50; break; case 50: - if (gSprites[sTradeData->unk_91].animEnded) + if (gSprites[sTradeWindowData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeData->unk_91]); + DestroySprite(&gSprites[sTradeWindowData->unk_91]); sub_807B62C(6); - sTradeData->state++; + sTradeWindowData->state++; PlaySE(SE_W028); } break; case 51: - if (sTradeData->unk_EA < 0x400) + if (sTradeWindowData->unk_EA < 0x400) { - sTradeData->unk_EA += 0x34; + sTradeWindowData->unk_EA += 0x34; } else { - sTradeData->unk_EA = 0x400; - sTradeData->state++; + sTradeWindowData->unk_EA = 0x400; + sTradeWindowData->state++; } - sTradeData->unk_E8 = 0x8000 / sTradeData->unk_EA; + sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; break; case 52: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state = 60; + sTradeWindowData->state = 60; break; case 60: if (!gPaletteFade.active) @@ -4377,13 +4382,13 @@ static bool8 sub_807CFC8(void) sub_807B62C(5); sub_807B62C(7); gPaletteFade.bufferTransferDisabled = TRUE; - sTradeData->state++; + sTradeWindowData->state++; } break; case 61: gPaletteFade.bufferTransferDisabled = FALSE; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 62: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4392,40 +4397,40 @@ static bool8 sub_807CFC8(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeData->state++; + sTradeWindowData->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; + sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); + gSprites[sTradeWindowData->unk_D3].data[3] = 74; + gSprites[sTradeWindowData->unk_D3].callback = sub_807E6AC; + StartSpriteAnim(&gSprites[sTradeWindowData->unk_D3], 1); + StartSpriteAffineAnim(&gSprites[sTradeWindowData->unk_D3], 2); + BlendPalettes(1 << (16 + gSprites[sTradeWindowData->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); + sTradeWindowData->state++; + sTradeWindowData->timer = 0; break; case 64: - BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - sTradeData->state++; + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeWindowData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeWindowData->state++; break; case 65: - if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy) + if (gSprites[sTradeWindowData->unk_D3].callback == SpriteCallbackDummy) { - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->tradeSpecies[1]], gMonSpritesGfxPtr->sprites[3], sTradeData->tradeSpecies[1], sTradeData->unk_68[1]); - sTradeData->state++; + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeWindowData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeWindowData->monSpecies[TRADE_PARTNER], sTradeWindowData->monPersonalities[TRADE_PARTNER]); + sTradeWindowData->state++; } break; case 66: - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.x = 120; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos1.y = gMonFrontPicCoords[sTradeData->tradeSpecies[1]].y_offset + 60; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.x = 0; - gSprites[sTradeData->pokePicSpriteIdxs[1]].pos2.y = 0; - StartSpriteAnim(&gSprites[sTradeData->pokePicSpriteIdxs[1]], 0); - CreatePokeballSpriteToReleaseMon(sTradeData->pokePicSpriteIdxs[1], gSprites[sTradeData->pokePicSpriteIdxs[1]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeData->tradeSpecies[1]); - FreeSpriteOamMatrix(&gSprites[sTradeData->unk_D3]); - DestroySprite(&gSprites[sTradeData->unk_D3]); - sTradeData->state++; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 120; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PARTNER]].y_offset + 60; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.x = 0; + gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y = 0; + StartSpriteAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); + CreatePokeballSpriteToReleaseMon(sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeWindowData->monSpecies[TRADE_PARTNER]); + FreeSpriteOamMatrix(&gSprites[sTradeWindowData->unk_D3]); + DestroySprite(&gSprites[sTradeWindowData->unk_D3]); + sTradeWindowData->state++; break; case 67: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4435,82 +4440,82 @@ static bool8 sub_807CFC8(void) DISPCNT_OBJ_ON); StringExpandPlaceholders(gStringVar4, gText_XSentOverY); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeData->state = 167; - sTradeData->timer = 0; + sTradeWindowData->state = 167; + sTradeWindowData->timer = 0; break; // 167 and 267 are extra cases added in for animations case 167: - if (++sTradeData->timer > 60) + if (++sTradeWindowData->timer > 60) { - sTradeData->state = 267; - sTradeData->timer = 0; + sTradeWindowData->state = 267; + sTradeWindowData->timer = 0; } break; case 267: if (IsCryFinished()) { - sTradeData->state = 68; + sTradeWindowData->state = 68; } break; case 68: - if (++sTradeData->timer == 10) + if (++sTradeWindowData->timer == 10) { PlayFanfare(MUS_FANFA5); } - if (sTradeData->timer == 250) + if (sTradeWindowData->timer == 250) { - sTradeData->state++; + sTradeWindowData->state++; StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } break; case 69: - if (++sTradeData->timer == 60) + if (++sTradeWindowData->timer == 60) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 70: CheckPartnersMonForRibbons(); - sTradeData->state++; + sTradeWindowData->state++; break; case 71: - if (sTradeData->isLinkTrade) + if (sTradeWindowData->isLinkTrade) { return TRUE; } else if (gMain.newKeys & A_BUTTON) { - sTradeData->state++; + sTradeWindowData->state++; } break; case 72: // Only if in-game trade - sub_807B4D0(gSpecialVar_0x8005, 0); + TradeMons(gSpecialVar_0x8005, 0); gCB2_AfterEvolution = sub_807B60C; evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[TRADE_PLAYER]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); } - sTradeData->state++; + sTradeWindowData->state++; break; case 73: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state++; + sTradeWindowData->state++; break; case 74: if (!gPaletteFade.active) { - PlayNewMapMusic(sTradeData->cachedMapMusic); - if (sTradeData) + PlayNewMapMusic(sTradeWindowData->cachedMapMusic); + if (sTradeWindowData) { FreeAllWindowBuffers(); Free(GetBgTilemapBuffer(3)); Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeData); + FREE_AND_SET_NULL(sTradeWindowData); } SetMainCallback2(CB2_ReturnToField); sub_807E784(); @@ -4533,8 +4538,8 @@ static void c2_08053788(void) gCB2_AfterEvolution = sub_807EB50; evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[1], gSelectedTradeMonPositions[TRADE_PLAYER]); - else if (sub_8077260()) + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + else if (IsWirelessTrade()) SetMainCallback2(sub_807F464); else SetMainCallback2(sub_807EB50); @@ -4551,7 +4556,7 @@ static void c2_08053788(void) static void sub_807E4DC(void) { u8 blockReceivedStatus; - sub_807ACDC(); + TradeGetMultiplayerId(); // no effect call, ret val ignored blockReceivedStatus = GetBlockReceivedStatus(); if (blockReceivedStatus & 0x01) { @@ -4561,7 +4566,7 @@ static void sub_807E4DC(void) } if (gBlockRecvBuffer[0][0] == 0xABCD) { - sTradeData->unk_72 = 1; + sTradeWindowData->unk_72 = 1; } ResetBlockReceivedFlag(0); } @@ -4569,7 +4574,7 @@ static void sub_807E4DC(void) { if (gBlockRecvBuffer[1][0] == 0xABCD) { - sTradeData->unk_73 = 1; + sTradeWindowData->unk_73 = 1; } ResetBlockReceivedFlag(1); } @@ -4620,7 +4625,7 @@ static void sub_807E64C(struct Sprite *sprite) if (++ sprite->data[0] == 23) { DestroySprite(sprite); - sTradeData->state = 14; // Resume the master trade animation + sTradeWindowData->state = 14; // Resume the master trade animation } } } @@ -4703,7 +4708,7 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) if (ItemIsMail(inGameTrade->heldItem)) { SetInGameTradeMail(&mail, inGameTrade); - gUnknown_020321C0[0] = mail; + gTradeMail[0] = mail; SetMonData(pokemon, MON_DATA_MAIL, &isMail); SetMonData(pokemon, MON_DATA_HELD_ITEM, &inGameTrade->heldItem); } @@ -4750,13 +4755,13 @@ static void sub_807EA2C(void) { if (sub_807BBC8() == TRUE) { - DestroySprite(&gSprites[sTradeData->pokePicSpriteIdxs[0]]); - FreeSpriteOamMatrix(&gSprites[sTradeData->pokePicSpriteIdxs[1]]); - sub_807B4D0(gSelectedTradeMonPositions[TRADE_PLAYER], gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE); - if (!sub_8077260()) + DestroySprite(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]]); + FreeSpriteOamMatrix(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]]); + TradeMons(gSelectedTradeMonPositions[TRADE_PLAYER], gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE); + if (!IsWirelessTrade()) { - sTradeData->linkData[0] = 0xABCD; - sTradeData->unk_93 = 1; + sTradeWindowData->linkData[0] = 0xABCD; + sTradeWindowData->unk_93 = 1; } SetMainCallback2(sub_807EACC); } @@ -4771,20 +4776,20 @@ static void sub_807EA2C(void) static void sub_807EACC(void) { - u8 mpId = sub_807ACDC(); - if (sub_8077260()) + u8 mpId = TradeGetMultiplayerId(); + if (IsWirelessTrade()) { SetMainCallback2(c2_08053788); } else { sub_807E4DC(); - if (mpId == 0 && sTradeData->unk_72 == 1 && sTradeData->unk_73 == 1) + if (mpId == 0 && sTradeWindowData->unk_72 == 1 && sTradeWindowData->unk_73 == 1) { - sTradeData->linkData[0] = 0xDCBA; - Trade_SendData(sTradeData); - sTradeData->unk_72 = 2; - sTradeData->unk_73 = 2; + sTradeWindowData->linkData[0] = 0xDCBA; + Trade_SendData(sTradeWindowData); + sTradeWindowData->unk_72 = 2; + sTradeWindowData->unk_73 = 2; } } RunTasks(); @@ -4805,13 +4810,13 @@ static void sub_807EB50(void) case 1: sub_8077288(0); gMain.state = 100; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; break; case 100: - if (++sTradeData->timer > 180) + if (++sTradeWindowData->timer > 180) { gMain.state = 101; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } if (_IsLinkTaskFinished()) { @@ -4839,10 +4844,10 @@ static void sub_807EB50(void) SetContinueGameWarpStatusToDynamicWarp(); sub_8153380(); gMain.state++; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; break; case 51: - if (++sTradeData->timer == 5) + if (++sTradeWindowData->timer == 5) { gMain.state++; } @@ -4855,38 +4860,38 @@ static void sub_807EB50(void) } else { - sTradeData->timer = 0; + sTradeWindowData->timer = 0; gMain.state = 51; } break; case 4: sub_81533E0(); gMain.state = 40; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; break; case 40: - if (++sTradeData->timer > 50) + if (++sTradeWindowData->timer > 50) { if (GetMultiplayerId() == 0) { - sTradeData->timer = Random() % 30; + sTradeWindowData->timer = Random() % 30; } else { - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } gMain.state = 41; } break; case 41: - if (sTradeData->timer == 0) + if (sTradeWindowData->timer == 0) { sub_8077288(1); gMain.state = 42; } else { - sTradeData->timer--; + sTradeWindowData->timer--; } break; case 42: @@ -4897,7 +4902,7 @@ static void sub_807EB50(void) } break; case 5: - if (++sTradeData->timer > 60) + if (++sTradeWindowData->timer > 60) { gMain.state++; sub_8077288(2); @@ -4965,7 +4970,7 @@ static void c2_080543C4(void) Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeData); + FREE_AND_SET_NULL(sTradeWindowData); if (gWirelessCommType) DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(gMain.savedCallback); @@ -4979,15 +4984,15 @@ 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); } @@ -5013,10 +5018,10 @@ void sub_807F19C(void) void DrawTextOnTradeWindow(u8 windowId, const u8 *str, u8 speed) { FillWindowPixelBuffer(windowId, PIXEL_FILL(15)); - 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); + sTradeWindowData->textColors[0] = TEXT_DYNAMIC_COLOR_6; + sTradeWindowData->textColors[1] = TEXT_COLOR_WHITE; + sTradeWindowData->textColors[2] = TEXT_COLOR_GREEN; + AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, sTradeWindowData->textColors, speed, str); CopyWindowToVram(windowId, 3); } @@ -5065,9 +5070,9 @@ static void c3_0805465C(u8 taskId) if (data[0] == 0) { - sTradeData->unk_FB = sTradeData->unk_FD = 120; - sTradeData->unk_FC = 0; - sTradeData->unk_FE = 160; + sTradeWindowData->unk_FB = sTradeWindowData->unk_FD = 120; + sTradeWindowData->unk_FC = 0; + sTradeWindowData->unk_FE = 160; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | @@ -5075,14 +5080,14 @@ static void c3_0805465C(u8 taskId) WININ_WIN0_OBJ); } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->unk_FB, sTradeData->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeWindowData->unk_FB, sTradeWindowData->unk_FD)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeWindowData->unk_FC, sTradeWindowData->unk_FE)); data[0]++; - sTradeData->unk_FB -= 5; - sTradeData->unk_FD += 5; + sTradeWindowData->unk_FB -= 5; + sTradeWindowData->unk_FD += 5; - if (sTradeData->unk_FB < 80) + if (sTradeWindowData->unk_FB < 80) { DestroyTask(taskId); } @@ -5094,24 +5099,24 @@ static void sub_807F39C(u8 taskId) if (data[0] == 0) { - sTradeData->unk_FB = 80; - sTradeData->unk_FD = 160; + sTradeWindowData->unk_FB = 80; + sTradeWindowData->unk_FD = 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(sTradeData->unk_FB, sTradeData->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeWindowData->unk_FB, sTradeWindowData->unk_FD)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeWindowData->unk_FC, sTradeWindowData->unk_FE)); - if (sTradeData->unk_FB != 120) + if (sTradeWindowData->unk_FB != 120) { data[0]++; - sTradeData->unk_FB += 5; - sTradeData->unk_FD -= 5; + sTradeWindowData->unk_FB += 5; + sTradeWindowData->unk_FD -= 5; - if (sTradeData->unk_FB >= 116) + if (sTradeWindowData->unk_FB >= 116) BlendPalettes(0x8, 0, RGB_WHITEALPHA); } else @@ -5133,7 +5138,7 @@ static void sub_807F464(void) case 1: sub_8077288(0); gMain.state = 2; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; break; case 2: if (_IsLinkTaskFinished()) @@ -5143,11 +5148,11 @@ static void sub_807F464(void) DrawTextOnTradeWindow(0, gStringVar4, 0); IncrementGameStat(GAME_STAT_POKEMON_TRADES); sub_8153380(); - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } break; case 3: - if (++sTradeData->timer == 5) + if (++sTradeWindowData->timer == 5) { gMain.state = 4; } @@ -5159,38 +5164,38 @@ static void sub_807F464(void) } else { - sTradeData->timer = 0; + sTradeWindowData->timer = 0; gMain.state = 3; } break; case 5: sub_81533E0(); gMain.state = 6; - sTradeData->timer = 0; + sTradeWindowData->timer = 0; break; case 6: - if (++sTradeData->timer > 10) + if (++sTradeWindowData->timer > 10) { if (GetMultiplayerId() == 0) { - sTradeData->timer = Random() % 30; + sTradeWindowData->timer = Random() % 30; } else { - sTradeData->timer = 0; + sTradeWindowData->timer = 0; } gMain.state = 7; } break; case 7: - if (sTradeData->timer == 0) + if (sTradeWindowData->timer == 0) { sub_8077288(1); gMain.state = 8; } else { - sTradeData->timer--; + sTradeWindowData->timer--; } break; case 8: @@ -5201,7 +5206,7 @@ static void sub_807F464(void) } break; case 9: - if (++sTradeData->timer > 60) + if (++sTradeWindowData->timer > 60) { gMain.state++; sub_8077288(2); diff --git a/src/union_room.c b/src/union_room.c index 908e57423..ba5d7983c 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -2345,7 +2345,7 @@ 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(); gSelectedTradeMonPositions[TRADE_PLAYER] = monId; gSelectedTradeMonPositions[TRADE_PARTNER] = PARTY_SIZE; From 6b556900f81b8f99920012f58060e4eccec70aed Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 4 Oct 2019 17:24:03 -0400 Subject: [PATCH 04/11] Move union room data, more trade doc --- include/constants/trade.h | 16 +- include/librfu.h | 10 +- include/trade.h | 2 +- include/union_room.h | 4 +- src/cable_club.c | 2 + src/data/trade.h | 2 +- src/data/union_room.h | 1039 +++++++++++++++++++++++++++++++++++ src/link_rfu.c | 10 +- src/party_menu.c | 26 +- src/trade.c | 66 +-- src/union_room.c | 1074 +------------------------------------ 11 files changed, 1134 insertions(+), 1117 deletions(-) create mode 100644 src/data/union_room.h diff --git a/include/constants/trade.h b/include/constants/trade.h index a12ee7fca..dbaefcdc3 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -15,9 +15,6 @@ #define PLAYER_MON_VALID 1 #define PARTNER_MON_INVALID 2 -#define MON_VALID 0 - - #define TRADE_ACTION_TEXT_CANCEL 0 #define TRADE_ACTION_TEXT_CHOOSE_MON 1 #define TRADE_ACTION_TEXT_SUMMARY 2 @@ -28,6 +25,7 @@ #define MENU_ACTION_SUMMARY 0 #define MENU_ACTION_TRADE 1 +// Message indexes for sTradeMessages #define TRADE_MSG_STANDBY 0 #define TRADE_MSG_CANCELED 1 #define TRADE_MSG_ONLY_MON1 2 @@ -38,5 +36,17 @@ #define TRADE_MSG_EGG_CANT_BE_TRADED 7 #define TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED 8 +// 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 + #endif //GUARD_CONSTANTS_TRADE_H 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/trade.h b/include/trade.h index e4d2a4897..b415bfa4e 100644 --- a/include/trade.h +++ b/include/trade.h @@ -17,7 +17,7 @@ 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 GetUnionRoomTradeMessageId(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); diff --git a/include/union_room.h b/include/union_room.h index facc63986..2fd8d421d 100644 --- a/include/union_room.h +++ b/include/union_room.h @@ -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/cable_club.c b/src/cable_club.c index 53ad59533..572e7d7bf 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -346,6 +346,7 @@ static void sub_80B2918(u8 taskId) HideFieldMessageBox(); gTasks[taskId].func = sub_80B2CB0; } + // EXCHANGE_STAT_4 or EXCHANGE_STAT_5 in sub_80B2478 else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9) { CloseLink(); @@ -393,6 +394,7 @@ static void sub_80B2A08(u8 taskId) HideFieldMessageBox(); gTasks[taskId].func = sub_80B2CB0; } + // EXCHANGE_STAT_4 or EXCHANGE_STAT_5 in sub_80B2478 else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9) { CloseLink(); diff --git a/src/data/trade.h b/src/data/trade.h index 686c22ca4..9de69983b 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -353,7 +353,7 @@ static const struct MenuAction sSelectTradeMonActions[] = [MENU_ACTION_TRADE] = {sText_Trade2, sub_807A024} }; -static const u8 *const sTradeMessageTexts[] = +static const u8 *const sTradeMessages[] = { [TRADE_MSG_STANDBY] = sText_CommunicationStandby, [TRADE_MSG_CANCELED] = sText_TheTradeHasBeenCanceled, diff --git a/src/data/union_room.h b/src/data/union_room.h new file mode 100644 index 000000000..26f507315 --- /dev/null +++ b/src/data/union_room.h @@ -0,0 +1,1039 @@ +// 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 gUnionRoom_ShowTrainerCard[] = _("The other TRAINER showed\nyou their TRAINER CARD.\pWould you like to show your\nTRAINER CARD?"); +ALIGNED(4) const u8 gUnionRoom_BattleChallenge[] = _("The other TRAINER challenges you\nto battle.\pWill you accept the battle\nchallenge?"); +ALIGNED(4) const u8 gUnionRoom_ChatInvitation[] = _("The other TRAINER invites you\nto chat.\pWill you accept the chat\ninvitation?"); +ALIGNED(4) const u8 gUnionRoom_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 gUnionRoom_OfferToTradeEgg[] = _("There is an offer to trade your\nregistered EGG.\lWill you accept this trade offer?"); +ALIGNED(4) const u8 gUnionRoom_ChatDropped[] = _("The chat has been dropped.\p"); +ALIGNED(4) const u8 gUnionRoom_OfferDeclined1[] = _("You declined the offer.\p"); +ALIGNED(4) const u8 gUnionRoom_OfferDeclined2[] = _("You declined the offer.\p"); +ALIGNED(4) const u8 gUnionRoom_ChatEnded[] = _("The chat was ended.\p"); + +const u8 *const unref_text_ptrs_union_room_3[] = { + gUnionRoom_ShowTrainerCard, + gUnionRoom_BattleChallenge, + gUnionRoom_ChatInvitation, + gUnionRoom_OfferToTradeMon +}; + +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 +}; + +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/link_rfu.c b/src/link_rfu.c index 3b533a3a4..390f71a08 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) @@ -4259,7 +4259,7 @@ void sub_8010FCC(u32 a0, u32 a1, u32 a2) { gUnknown_02022B14.type = a0; gUnknown_02022B14.species = a1; - gUnknown_02022B14.unk_0b_1 = a2; + gUnknown_02022B14.level = a2; } u8 sub_801100C(s32 a0) @@ -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 827819ce0..2495156b1 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -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"); @@ -4661,11 +4661,11 @@ 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]); diff --git a/src/trade.c b/src/trade.c index 019aab2c4..e5752bab1 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2193,7 +2193,7 @@ static void sub_807A0C4(void) static void PrintTradeMessage(u8 messageId) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, sTradeMessageTexts[messageId], 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); @@ -2428,6 +2428,10 @@ static u32 sub_807A5F4(struct Pokemon *playerParty, int partyCount, int monIdx) } } +// Return values are used to determine exchange status in GetLinkPlayerDataExchangeStatusTimed +// 0: EXCHANGE_COMPLETE +// 1: EXCHANGE_STAT_4 +// 2: EXCHANGE_STAT_5 s32 sub_807A728(void) { s32 val; @@ -2452,7 +2456,7 @@ s32 sub_807A728(void) { if (gLinkPlayers[GetMultiplayerId()].name[10] & 0xF0) { - if (val == 2) + if (val == 2) //unnecessary check, val always 2 here { if (gLinkPlayers[GetMultiplayerId() ^ 1].name[10] & 0xF0) { @@ -2483,80 +2487,80 @@ 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 a0, struct UnkLinkRfuStruct_02022B14Substruct a1, 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; + bool8 playerHasNationalDex = a0.hasNationalDex; + bool8 playerIsChampion = a0.isChampion; + bool8 partnerHasNationalDex = a1.hasNationalDex; + bool8 partnerIsChampion = a1.isChampion; u8 r1 = a1.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 species2, u16 species, u8 isObedientBitSet) { - u8 unk = a0.unk_01_0; + u8 unk = a0.hasNationalDex; if (IsDeoxysOrMewUntradable(species, isObedientBitSet)) { diff --git a/src/union_room.c b/src/union_room.c index ba5d7983c..3f0bebbb5 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -56,8 +56,8 @@ 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 u16 gUnionRoomOfferedSpecies = 0; +EWRAM_DATA u8 gUnionRoomRequestedMonType = 0; EWRAM_DATA struct TradeUnkStruct gUnknown_02022C40 = {}; // IWRAM vars @@ -140,1045 +140,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) @@ -1639,11 +601,11 @@ void sub_8013078(u8 *dst, u8 caseId) { case 65: case 68: - StringExpandPlaceholders(dst, gUnknown_082EE560); + StringExpandPlaceholders(dst, gUnionRoom_OfferDeclined1); break; case 69: case 72: - StringExpandPlaceholders(dst, gUnknown_082EE57C); + StringExpandPlaceholders(dst, gUnionRoom_OfferDeclined2); break; } } @@ -2116,7 +1078,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 @@ -3750,7 +2712,7 @@ void sub_80156E0(u8 taskId) if (sub_80168DC(data) && gMain.newKeys & B_BUTTON) { sub_8011DE0(1); - StringCopy(gStringVar4, gUnknown_082EE598); + StringCopy(gStringVar4, gUnionRoom_ChatEnded); data->state = 36; } break; @@ -3871,7 +2833,7 @@ void sub_80156E0(u8 taskId) else { StringCopy(gStringVar1, gSpeciesNames[sub_800F7DC()->species]); - ConvertIntToDecimalStringN(gStringVar2, sub_800F7DC()->unk_0b_1, STR_CONV_MODE_LEFT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar2, sub_800F7DC()->level, STR_CONV_MODE_LEFT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gUnknown_082EF564); } sub_8015664(44, gStringVar4); @@ -3917,7 +2879,7 @@ void sub_80156E0(u8 taskId) } 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) @@ -4022,8 +2984,8 @@ void sub_80156E0(u8 taskId) { gUnknown_02022C40.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); @@ -4945,7 +3907,7 @@ 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) @@ -5097,11 +4059,11 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) switch (arg2[0]) { case 0x41: - StringExpandPlaceholders(dst, gUnknown_082EE3DC); + StringExpandPlaceholders(dst, gUnionRoom_BattleChallenge); result = 1; break; case 0x45: - StringExpandPlaceholders(dst, gUnknown_082EE430); + StringExpandPlaceholders(dst, gUnionRoom_ChatInvitation); result = 1; break; case 0x44: @@ -5119,7 +4081,7 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) } if (species == SPECIES_EGG) { - StringCopy(dst, gUnknown_082EE4F0); + StringCopy(dst, gUnionRoom_OfferToTradeEgg); } else { @@ -5127,16 +4089,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, gUnionRoom_OfferToTradeMon); } result = 1; break; case 0x48: - StringExpandPlaceholders(dst, gUnknown_082EE380); + StringExpandPlaceholders(dst, gUnionRoom_ShowTrainerCard); result = 1; break; case 0x40: - StringExpandPlaceholders(dst, gUnknown_082EE544); + StringExpandPlaceholders(dst, gUnionRoom_ChatDropped); result = 2; break; } From dadb1cb9f14a19cf0e483d4b15122b9d9cfb4baa Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 4 Oct 2019 23:31:25 -0400 Subject: [PATCH 05/11] More trade/union room doc, incidental party_menu doc --- data/scripts/cable_club.inc | 2 +- data/specials.inc | 2 +- include/constants/trade.h | 5 + include/party_menu.h | 4 +- include/trade.h | 2 +- include/union_room.h | 2 +- src/data/union_room.h | 199 +++++++++++----------- src/fldeff_softboiled.c | 12 +- src/link_rfu.c | 8 +- src/party_menu.c | 325 ++++++++++++++++++------------------ src/trade.c | 25 +-- src/union_room.c | 188 ++++++++++----------- 12 files changed, 386 insertions(+), 388 deletions(-) diff --git a/data/scripts/cable_club.inc b/data/scripts/cable_club.inc index 3fcb25807..f20f47ba4 100644 --- a/data/scripts/cable_club.inc +++ b/data/scripts/cable_club.inc @@ -1032,7 +1032,7 @@ OldaleTown_PokemonCenter_2F_EventScript_27759F:: @ 827759F hideobjectat EVENT_OBJ_ID_PLAYER, MAP_PETALBURG_CITY closedoor 5, 1 waitdooranim - special sub_8018090 + special Script_ResetUnionRoomTrade special SetCableClubWarp warpteleport2 MAP_UNION_ROOM, 255, 7, 11 waitstate diff --git a/data/specials.inc b/data/specials.inc index 6a328ca9e..7e9f4e823 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -432,7 +432,7 @@ gSpecials:: @ 81DBA64 def_special BufferUnionRoomPlayerName def_special sub_801DC20 def_special sub_81B8958 - def_special sub_8018090 + def_special Script_ResetUnionRoomTrade def_special IsBadEggInParty def_special ValidateReceivedWonderCard def_special HasAtLeastOneBerry diff --git a/include/constants/trade.h b/include/constants/trade.h index dbaefcdc3..54e58f922 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -48,5 +48,10 @@ #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/party_menu.h b/include/party_menu.h index d76e50788..1ea9ea1d1 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -93,12 +93,12 @@ 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); diff --git a/include/trade.h b/include/trade.h index b415bfa4e..ec94780cb 100644 --- a/include/trade.h +++ b/include/trade.h @@ -16,7 +16,7 @@ extern const struct WindowTemplate gUnknown_0833900C; s32 sub_807A728(void); void sub_80773AC(void); void sub_807AE50(void); -int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16, u16, u8); +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 sub_807A918(struct Pokemon*, u16); void sub_807B140(void); diff --git a/include/union_room.h b/include/union_room.h index 2fd8d421d..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; diff --git a/src/data/union_room.h b/src/data/union_room.h index 26f507315..abe91b010 100644 --- a/src/data/union_room.h +++ b/src/data/union_room.h @@ -51,16 +51,12 @@ const u8 gText_5PlayerMode[] = _("5-PLAYER\nMODE"); const u8 *const gUnknown_082EDB60[][5] = { { gText_1PlayerNeeded, - gText_2PlayerMode, - NULL, - NULL, - NULL + gText_2PlayerMode }, { gText_3PlayersNeeded, gText_2PlayersNeeded, gText_1PlayerNeeded, - gText_4PlayerMode, - NULL + gText_4PlayerMode }, { gText_1PlayerNeeded, gText_2PlayerMode, @@ -77,8 +73,7 @@ const u8 *const gUnknown_082EDB60[][5] = { gText_1PlayerNeeded, gText_2PlayerMode, gText_3PlayerMode, - gText_4PlayerMode, - NULL + gText_4PlayerMode } }; @@ -196,55 +191,56 @@ const u8 *const unref_text_ptrs_union_room_2[][2] = { } }; -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}"); +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}"); -const u8 *const gUnknown_082EE324[] = { - gUnknown_082EE2E8, - gUnknown_082EE308 +static const u8 *const gUnknown_082EE324[] = { + sText_SomebodyHasContactedYou, + sText_XHasContactedYou }; -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}…"); +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}…"); -const u8 *const gUnknown_082EE378[] = { - gUnknown_082EE32C, - gUnknown_082EE358 +static const u8 *const sUnionRoomTexts_AwaitingResponse[] = { + sUnionRoom_AwaitingResponseFromTrainer, + sUnionRoom_AwaitingResponseFromX }; -ALIGNED(4) const u8 gUnionRoom_ShowTrainerCard[] = _("The other TRAINER showed\nyou their TRAINER CARD.\pWould you like to show your\nTRAINER CARD?"); -ALIGNED(4) const u8 gUnionRoom_BattleChallenge[] = _("The other TRAINER challenges you\nto battle.\pWill you accept the battle\nchallenge?"); -ALIGNED(4) const u8 gUnionRoom_ChatInvitation[] = _("The other TRAINER invites you\nto chat.\pWill you accept the chat\ninvitation?"); -ALIGNED(4) const u8 gUnionRoom_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 gUnionRoom_OfferToTradeEgg[] = _("There is an offer to trade your\nregistered EGG.\lWill you accept this trade offer?"); -ALIGNED(4) const u8 gUnionRoom_ChatDropped[] = _("The chat has been dropped.\p"); -ALIGNED(4) const u8 gUnionRoom_OfferDeclined1[] = _("You declined the offer.\p"); -ALIGNED(4) const u8 gUnionRoom_OfferDeclined2[] = _("You declined the offer.\p"); -ALIGNED(4) const u8 gUnionRoom_ChatEnded[] = _("The chat was ended.\p"); +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"); -const u8 *const unref_text_ptrs_union_room_3[] = { - gUnionRoom_ShowTrainerCard, - gUnionRoom_BattleChallenge, - gUnionRoom_ChatInvitation, - gUnionRoom_OfferToTradeMon +// Unused +static const u8 *const sUnionRoomTexts_Invitation[] = { + sText_ShowTrainerCard, + sText_BattleChallenge, + sText_ChatInvitation, + sText_OfferToTradeMon }; -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?"); +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 gUnknown_082EE6B8[][2] = { +const u8 *const sUnionRoomTexts_JoinChat[][GENDER_COUNT] = { { - gUnknown_082EE5C0, - gUnknown_082EE638 + sText_JoinChatMale, + sText_JoinChatFemale }, { - gUnknown_082EE5F8, - gUnknown_082EE674 + sText_PlayerJoinChatMale, + sText_PlayerJoinChatFemale } }; -ALIGNED(4) const u8 gUnknown_082EE6C8[] = _("……\nThe TRAINER appears to be busy…\p"); +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."); @@ -323,15 +319,15 @@ const u8 *const gUnknown_082EEB80[] = { 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"); +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 gUnknown_082EEC9C[] = { - gUnknown_082EEC50, - gUnknown_082EEC7C +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"); @@ -351,13 +347,16 @@ ALIGNED(4) const u8 gUnknown_082EEE24[] = _("That's it!\nThis is the right move 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] = { +const u8 *const gUnknown_082EEEAC[GENDER_COUNT][4] = { + [MALE] = { gUnknown_082EED44, gUnknown_082EED6C, gUnknown_082EED98, gUnknown_082EEDBC - }, { + }, + [FEMALE] = + { gUnknown_082EEDF4, gUnknown_082EEE24, gUnknown_082EEE4C, @@ -374,13 +373,16 @@ 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] = { +const u8 *const gUnknown_082EF010[GENDER_COUNT][4] = { + [MALE] = { gUnknown_082EEECC, gUnknown_082EEEF0, gUnknown_082EEF2C, gUnknown_082EEF50 - }, { + }, + [FEMALE] = + { gUnknown_082EEF7C, gUnknown_082EEFA0, gUnknown_082EEFBC, @@ -393,65 +395,68 @@ 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] = { +const u8 *const gUnknown_082EF100[GENDER_COUNT][2] = { + [MALE] = { gUnknown_082EF030, gUnknown_082EF06C - }, { + }, + [FEMALE] = + { 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"); +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 gUnknown_082EF1CC[][4] = { +const u8 *const sUnionRoomTexts_Traded[GENDER_COUNT][4] = { + [MALE] = { - gUnknown_082EF110, - gUnknown_082EF138, - NULL, - NULL - }, { - gUnknown_082EF178, - gUnknown_082EF198, - NULL, - NULL + sText_MaleTraded1, + sText_MaleTraded2 + }, + [FEMALE] = + { + sText_FemaleTraded1, + sText_FemaleTraded2 } }; -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"); +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"); -const u8 *const unref_text_ptrs_union_room_4[] = { - gUnknown_082EF740, - gUnknown_082EF774 +// unused +const u8 *const sUnionRoomTexts_CantTradeRightNow[] = { + sText_CantTradeMonRightNow, + sText_CantTradePartnersMonRightNow }; -ALIGNED(4) const u8 gUnknown_082EF7B0[] = _("Your trade offer was rejected.\p"); -ALIGNED(4) const u8 gUnknown_082EF7D0[] = _("EGG TRADE"); +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."); 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/link_rfu.c b/src/link_rfu.c index 390f71a08..a8b79c045 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -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.level = a2; + gUnknown_02022B14.type = type; + gUnknown_02022B14.species = species; + gUnknown_02022B14.level = level; } u8 sub_801100C(s32 a0) diff --git a/src/party_menu.c b/src/party_menu.c index 2495156b1..e2092a825 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -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*); @@ -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: @@ -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); @@ -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); } } @@ -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: @@ -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++) { @@ -4575,7 +4575,7 @@ static void CursorCb_Enter(u8 taskId) DisplayPartyPokemonOtherText(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++) { @@ -4619,40 +4619,41 @@ static void CursorCb_NoEntry(u8 taskId) if (gSelectedOrderFromParty[i] != 0) DisplayPartyPokemonOtherText(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; } @@ -4667,23 +4668,23 @@ static void CursorCb_Trade1(u8 taskId) { 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]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); + PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); switch (sub_807A918(gPlayerParty, gUnknown_0203CEC8.slotId)) { case 1: @@ -4699,13 +4700,13 @@ static void CursorCb_Trade2(u8 taskId) 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) @@ -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/trade.c b/src/trade.c index e5752bab1..33b09436a 100644 --- a/src/trade.c +++ b/src/trade.c @@ -2558,31 +2558,24 @@ int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, str return UR_TRADE_MSG_NONE; } -int sub_807A8D0(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species2, u16 species, u8 isObedientBitSet) +int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species2, u16 species, u8 isObedientBitSet) { - u8 unk = a0.hasNationalDex; + bool8 hasNationalDex = a0.hasNationalDex; if (IsDeoxysOrMewUntradable(species, isObedientBitSet)) - { - return 1; - } + return CANT_REGISTER_MON; - if (unk) - { - return 0; - } + if (hasNationalDex) + return CAN_REGISTER_MON; + // Eggs can only be traded if the player has the National Dex if (species2 == SPECIES_EGG) - { - return 2; - } + return CANT_REGISTER_EGG; if (IsSpeciesInHoennDex(species2)) - { - return 0; - } + return CAN_REGISTER_MON; - return 1; + return CANT_REGISTER_MON; } // r6/r7 flip. Ugh. diff --git a/src/union_room.c b/src/union_room.c index 3f0bebbb5..382e6c595 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -58,7 +58,7 @@ EWRAM_DATA u32 gFiller_02022C34 = 0; EWRAM_DATA struct UnkLinkRfuStruct_02022B14Substruct gUnknown_02022C38 = {}; EWRAM_DATA u16 gUnionRoomOfferedSpecies = 0; EWRAM_DATA u8 gUnionRoomRequestedMonType = 0; -EWRAM_DATA struct TradeUnkStruct gUnknown_02022C40 = {}; +static EWRAM_DATA struct UnionRoomTrade sUnionRoomTrade = {}; // IWRAM vars static struct UnkStruct_Leader *gUnknown_03000DA0; @@ -96,8 +96,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); @@ -105,8 +105,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); @@ -122,7 +122,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); @@ -601,11 +601,11 @@ void sub_8013078(u8 *dst, u8 caseId) { case 65: case 68: - StringExpandPlaceholders(dst, gUnionRoom_OfferDeclined1); + StringExpandPlaceholders(dst, sText_OfferDeclined1); break; case 69: case 72: - StringExpandPlaceholders(dst, gUnionRoom_OfferDeclined2); + StringExpandPlaceholders(dst, sText_OfferDeclined2); break; } } @@ -1282,7 +1282,7 @@ u8 sub_8013F78(void) void sub_8013F90(u8 taskId) { - u32 monId = sub_8018120(&gUnknown_02022C40, GetMultiplayerId()); + u32 monId = GetPartyPositionOfRegisteredMon(&sUnionRoomTrade, GetMultiplayerId()); switch (gTasks[taskId].data[0]) { @@ -1313,7 +1313,7 @@ void sub_8013F90(u8 taskId) gSelectedTradeMonPositions[TRADE_PARTNER] = PARTY_SIZE; gMain.savedCallback = CB2_ReturnToField; SetMainCallback2(sub_807AE50); - sub_801807C(&gUnknown_02022C40); + ResetUnionRoomTrade(&sUnionRoomTrade); DestroyTask(taskId); } break; @@ -2296,7 +2296,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(); @@ -2307,22 +2307,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 { @@ -2331,21 +2331,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 { @@ -2453,9 +2453,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; @@ -2513,9 +2513,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 { @@ -2528,7 +2528,7 @@ void sub_80156E0(u8 taskId) } break; case 28: - StringCopy(gStringVar4, gUnknown_082EEB88); + StringCopy(gStringVar4, sText_TrainerBattleBusy); data->state = 36; break; case 27: @@ -2547,15 +2547,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 @@ -2603,7 +2603,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 @@ -2627,7 +2627,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; @@ -2712,7 +2712,7 @@ void sub_80156E0(u8 taskId) if (sub_80168DC(data) && gMain.newKeys & B_BUTTON) { sub_8011DE0(1); - StringCopy(gStringVar4, gUnionRoom_ChatEnded); + StringCopy(gStringVar4, sText_ChatEnded); data->state = 36; } break; @@ -2733,12 +2733,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 { @@ -2828,19 +2828,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()->level, STR_CONV_MODE_LEFT_ALIGN, 3); - StringExpandPlaceholders(gStringVar4, gUnknown_082EF564); + 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: @@ -2856,11 +2856,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; } } @@ -2873,7 +2873,7 @@ 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); } @@ -2886,20 +2886,20 @@ void sub_80156E0(u8 taskId) { 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)) @@ -2915,16 +2915,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: @@ -2948,18 +2948,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; @@ -2980,16 +2980,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)); 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: @@ -3859,7 +3859,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 @@ -3881,7 +3881,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]); @@ -3890,7 +3890,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; @@ -3912,7 +3912,7 @@ void sub_8017B3C(u8 arg0, u8 arg1, struct UnkLinkRfuStruct_02022B14 * arg2, cons 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 { @@ -4023,7 +4023,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]); @@ -4059,16 +4059,16 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) switch (arg2[0]) { case 0x41: - StringExpandPlaceholders(dst, gUnionRoom_BattleChallenge); + StringExpandPlaceholders(dst, sText_BattleChallenge); result = 1; break; case 0x45: - StringExpandPlaceholders(dst, gUnionRoom_ChatInvitation); + 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) @@ -4081,7 +4081,7 @@ s32 sub_8017EA0(u8 *dst, u32 gender, u16 *arg2, struct UnkStruct_URoom *arg3) } if (species == SPECIES_EGG) { - StringCopy(dst, gUnionRoom_OfferToTradeEgg); + StringCopy(dst, sText_OfferToTradeEgg); } else { @@ -4089,16 +4089,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, gUnionRoom_OfferToTradeMon); + DynamicPlaceholderTextUtil_ExpandPlaceholders(dst, sText_OfferToTradeMon); } result = 1; break; case 0x48: - StringExpandPlaceholders(dst, gUnionRoom_ShowTrainerCard); + StringExpandPlaceholders(dst, sText_ShowTrainerCard); result = 1; break; case 0x40: - StringExpandPlaceholders(dst, gUnionRoom_ChatDropped); + StringExpandPlaceholders(dst, sText_ChatDropped); result = 2; break; } @@ -4131,14 +4131,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++; @@ -4146,16 +4146,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; @@ -4167,34 +4163,30 @@ void sub_801807C(struct TradeUnkStruct *arg0) arg0->personality = 0; } -void sub_8018090(void) +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; @@ -4203,15 +4195,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++) @@ -4241,7 +4235,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); } } From 66a68159b17f3c4c5f62219fc4bd0ec636d772b5 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 5 Oct 2019 10:41:37 -0400 Subject: [PATCH 06/11] Continue trade doc --- graphics/trade/{ball.png => pokeball.png} | Bin include/constants/trade.h | 22 +- include/link_rfu.h | 4 +- include/trade.h | 4 +- src/cable_club.c | 4 +- src/data/trade.h | 38 ++-- src/evolution_scene.c | 2 +- src/link.c | 4 +- src/link_rfu.c | 62 +++--- src/party_menu.c | 18 +- src/pokemon_storage_system.c | 4 +- src/trade.c | 234 ++++++++++++---------- src/union_room.c | 2 +- 13 files changed, 205 insertions(+), 193 deletions(-) rename graphics/trade/{ball.png => pokeball.png} (100%) 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/include/constants/trade.h b/include/constants/trade.h index 54e58f922..bd66a16aa 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -9,8 +9,6 @@ #define INGAME_TRADE_HORSEA 2 #define INGAME_TRADE_MEOWTH 3 -#define INGAME_TRADE_MAIL_LENGTH 9 - #define PLAYER_MON_INVALID 0 #define PLAYER_MON_VALID 1 #define PARTNER_MON_INVALID 2 @@ -26,15 +24,15 @@ #define MENU_ACTION_TRADE 1 // 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 +#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 // Message indexes for sUnionRoomTradeMessages #define UR_TRADE_MSG_NONE 0 @@ -53,5 +51,7 @@ #define CANT_REGISTER_MON 1 #define CANT_REGISTER_EGG 2 +#define LINK_TRADE_TIMEOUT 300 + #endif //GUARD_CONSTANTS_TRADE_H diff --git a/include/link_rfu.h b/include/link_rfu.h index d6e1009e1..3284aba88 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,7 +224,7 @@ 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); diff --git a/include/trade.h b/include/trade.h index ec94780cb..9975e17af 100644 --- a/include/trade.h +++ b/include/trade.h @@ -15,13 +15,13 @@ extern const struct WindowTemplate gUnknown_0833900C; s32 sub_807A728(void); void sub_80773AC(void); -void sub_807AE50(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 sub_807A918(struct Pokemon*, u16); void sub_807B140(void); void sub_807B154(void); -void sub_807F19C(void); +void InitTradeBg(void); void DrawTextOnTradeWindow(u8, const u8 *, u8); #endif //GUARD_TRADE_H diff --git a/src/cable_club.c b/src/cable_club.c index 572e7d7bf..0615b37bd 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -346,7 +346,6 @@ static void sub_80B2918(u8 taskId) HideFieldMessageBox(); gTasks[taskId].func = sub_80B2CB0; } - // EXCHANGE_STAT_4 or EXCHANGE_STAT_5 in sub_80B2478 else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9) { CloseLink(); @@ -394,7 +393,6 @@ static void sub_80B2A08(u8 taskId) HideFieldMessageBox(); gTasks[taskId].func = sub_80B2CB0; } - // EXCHANGE_STAT_4 or EXCHANGE_STAT_5 in sub_80B2478 else if (gSpecialVar_Result == 7 || gSpecialVar_Result == 9) { CloseLink(); @@ -1111,7 +1109,7 @@ static void sub_80B3894(u8 taskId) case 0: ScriptContext2_Enable(); FadeScreen(1, 0); - Rfu_set_zero(); + ClearLinkRfuCallback(); data[0]++; break; case 1: diff --git a/src/data/trade.h b/src/data/trade.h index 9de69983b..8d4139571 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -71,7 +71,7 @@ static const union AnimCmd *const gSpriteAnimTable_832DC34[] = gSpriteAnim_832DC2C }; -static const struct SpriteSheet gUnknown_0832DC3C = +static const struct SpriteSheet sTradeButtonsSpriteSheet = { .data = gTradeButtons_Gfx, .size = 0x800, @@ -168,7 +168,7 @@ static const struct SpritePalette gSpritePalette_TradeScreenText = // 2 3 8 9 // 4 5 10 11 // 12 -static const u8 gTradeNextSelectedMonTable[][4][6] = +static const u8 gTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][6] = { { {4, 2, 12, 12, 0, 0}, @@ -250,7 +250,7 @@ static const u8 gTradeNextSelectedMonTable[][4][6] = } }; -static const u8 gTradeMonSpriteCoords[][2] = +static const u8 gTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] = { // Your party {1, 5 }, @@ -271,7 +271,7 @@ static const u8 gTradeMonSpriteCoords[][2] = {23, 18} // CANCEL }; -static const u8 gTradeLevelDisplayCoords[][6][2] = +static const u8 gTradeLevelDisplayCoords[][PARTY_SIZE][2] = { { // Your party @@ -293,7 +293,7 @@ static const u8 gTradeLevelDisplayCoords[][6][2] = } }; -static const u8 gTradeMonBoxCoords[][6][2] = +static const u8 gTradeMonBoxCoords[][PARTY_SIZE][2] = { { // Your party @@ -598,8 +598,8 @@ static const u8 sTradeMenuPartyMonBoxDimensions[3][2] = [TRADE_PARTNER] = {19, 3} }; -static const u16 sTradePal_Ball[] = INCBIN_U16("graphics/trade/ball.gbapal"); -static const u8 sTradeGfx_Ball[] = INCBIN_U8("graphics/trade/ball.4bpp"); +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? @@ -704,16 +704,16 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D0C[] = gSpriteAffineAnim_8338CEC }; -static const struct SpriteSheet gUnknown_08338D18 = +static const struct SpriteSheet sPokeBallSpriteSheet = { - .data = sTradeGfx_Ball, + .data = sTradeGfx_PokeBall, .size = 0x600, .tag = 5557 }; -static const struct SpritePalette gUnknown_08338D20 = +static const struct SpritePalette sPokeBallSpritePalette = { - .data = sTradePal_Ball, + .data = sTradePal_PokeBall, .tag = 5558 }; @@ -760,20 +760,20 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_8338D6C[] = gSpriteAffineAnim_8338D54 }; -static const struct SpriteSheet gUnknown_08338D70 = +static const struct SpriteSheet sGlow1SpriteSheet = { .data = sTradeGfx_Glow1, .size = 0x200, .tag = 5550 }; -static const struct SpritePalette gUnknown_08338D78 = +static const struct SpritePalette sMiscTradeSpritePalette = { .data = sTradePal_Misc, .tag = 5551 }; -static const struct SpritePalette gUnknown_08338D80 = +static const struct SpritePalette sGbaSpritePalette = { .data = sTradePal_Gba, .tag = 5555 @@ -815,7 +815,7 @@ static const union AnimCmd *const gSpriteAnimTable_8338DB8[] = gSpriteAnim_8338DB0 }; -static const struct SpriteSheet gUnknown_08338DC0 = +static const struct SpriteSheet sGlow2SpriteSheet = { .data = sTradeGfx_Glow2, .size = 0x300, @@ -851,7 +851,7 @@ static const union AnimCmd *const gSpriteAnimTable_8338DF0[] = gSpriteAnim_8338DE8 }; -static const struct SpriteSheet gUnknown_08338DF4 = +static const struct SpriteSheet sCableEndSpriteSheet = { .data = sTradeGfx_CableEnd, .size = 0x100, @@ -912,7 +912,7 @@ static const union AnimCmd *const gSpriteAnimTable_8338E68[] = gSpriteAnim_8338E40 }; -static const struct SpriteSheet gUnknown_08338E6C = +static const struct SpriteSheet sGbaScreenSpriteSheet = { .data = sTradeGfx_GbaScreen, .size = 0x1000, @@ -1022,7 +1022,7 @@ static const struct InGameTrade sIngameTrades[] = } }; -static const u16 sIngameTradeMail[][INGAME_TRADE_MAIL_LENGTH + 1] = +static const u16 sIngameTradeMail[][MAIL_WORDS_COUNT + 1] = { { EC_WORD_BE, @@ -1122,7 +1122,7 @@ static const struct BgTemplate gUnknown_08339014[] = }, }; -static const s8 gTradeBallVerticalVelocityTable[] = +static const s8 sTradeBallVerticalVelocityTable[] = { 0, 0, 1, 0, 1, 0, 1, 1, diff --git a/src/evolution_scene.c b/src/evolution_scene.c index ec970d5e5..7cfbc2e6b 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: diff --git a/src/link.c b/src/link.c index db72be19a..45bf82580 100644 --- a/src/link.c +++ b/src/link.c @@ -739,7 +739,7 @@ void ClearLinkCallback(void) { if (gWirelessCommType) { - Rfu_set_zero(); + ClearLinkRfuCallback(); } else { @@ -751,7 +751,7 @@ void ClearLinkCallback_2(void) { if (gWirelessCommType) { - Rfu_set_zero(); + ClearLinkRfuCallback(); } else { diff --git a/src/link_rfu.c b/src/link_rfu.c index a8b79c045..2f47669c4 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -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; } } @@ -3804,13 +3804,13 @@ bool8 sub_8010500(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) @@ -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) diff --git a/src/party_menu.c b/src/party_menu.c index e2092a825..12f91168b 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); @@ -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) @@ -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) { @@ -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); } @@ -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; } } @@ -4572,7 +4572,7 @@ 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(); DisplayPartyMenuStdMessage(0); @@ -4613,11 +4613,11 @@ 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); } DisplayPartyMenuStdMessage(0); gTasks[taskId].func = sub_81B1370; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index a1a614041..83b0dfee8 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1559,8 +1559,8 @@ void sub_80C6D80(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 arg4) txtColor[0] = TEXT_COLOR_TRANSPARENT; else txtColor[0] = zero2; - txtColor[1] = 0xF; - txtColor[2] = 0xE; + txtColor[1] = TEXT_DYNAMIC_COLOR_6; + txtColor[2] = TEXT_DYNAMIC_COLOR_5; AddTextPrinterParameterized4(windowId, 1, 0, 1, 0, 0, txtColor, -1, string); val = arg4; diff --git a/src/trade.c b/src/trade.c index 33b09436a..de7decbc2 100644 --- a/src/trade.c +++ b/src/trade.c @@ -71,8 +71,14 @@ struct InGameTrade { /*0x38*/ u16 requestedSpecies; }; -static EWRAM_DATA u8 *sTradeStringAllocBuffer = NULL; -static EWRAM_DATA u8 *sTradeStringBuffer[14] = {NULL}; +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 { @@ -104,7 +110,7 @@ static EWRAM_DATA struct { /*0x007E*/ u8 partnerCursorPosition; /*0x007F*/ u8 unused_7F; /*0x0080*/ u16 linkData[20]; - /*0x00A8*/ u8 unk_A8; //state var for sub_807A1F0 + /*0x00A8*/ u8 unk_A8; // used as a timer and state var for sub_807A1F0 /*0x00A9*/ u8 unk_A9[11]; //ribbons /*0x00B4*/ u8 filler_B4[0x8D0-0xB4]; /*0x08D0*/ struct { @@ -122,9 +128,9 @@ static EWRAM_DATA struct { /*0x72*/ u8 unk_72; /*0x73*/ u8 unk_73; /*0x74*/ u16 linkData[10]; - /*0x88*/ u8 unk_88; - /*0x89*/ u8 unk_89; - /*0x8A*/ u16 unk_8A; + /*0x88*/ u8 alwaysZero_88; + /*0x89*/ u8 alwaysZero_89; + /*0x8A*/ u16 linkTimeoutCounter; /*0x8C*/ u16 neverRead_8C; /*0x8E*/ u8 pokePicSpriteIdxs[2]; /*0x90*/ u8 unk_90; //sprite id @@ -153,7 +159,7 @@ static EWRAM_DATA struct { /*0xF4*/ u16 cachedMapMusic; /*0xF6*/ u8 textColors[3]; /*0xF9*/ u8 filler_F9; - /*0xFA*/ bool8 isCableLink; + /*0xFA*/ bool8 isCableTrade; /*0xFB*/ u8 unk_FB; /*0xFC*/ u8 unk_FC; /*0xFD*/ u8 unk_FD; @@ -199,19 +205,19 @@ 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 InitTradeBgInternal(void); static void sub_807B60C(void); static void sub_807B62C(u8); -static void sub_807BA94(void); +static void LoadTradeSequenceSpriteSheetsAndPalettes(void); static void SetTradeSceneStrings(void); -static bool8 sub_807BBC8(void); -static bool8 sub_807BBEC(void); -static bool8 sub_807CFC8(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 BuffeInGameTradeMonName(void); static void SetInGameTradeMail(struct MailStruct *mail, const struct InGameTrade *trade); static void sub_807EA2C(void); static void sub_807EACC(void); @@ -376,11 +382,11 @@ static void sub_80773D0(void) case 0: sTradeData = AllocZeroed(sizeof(*sTradeData)); InitTradeMenu(); - sTradeStringAllocBuffer = AllocZeroed(14 * 256); + sMessageBoxAllocBuffer = AllocZeroed(14 * 256); - for (i = 0; i < 14; i++) + for (i = 0; i < (int)ARRAY_COUNT(sMessageBoxTileBuffers); i++) { - sTradeStringBuffer[i] = &sTradeStringAllocBuffer[i * 256]; + sMessageBoxTileBuffers[i] = &sMessageBoxAllocBuffer[i * 256]; } gMain.state++; @@ -522,11 +528,11 @@ static void sub_80773D0(void) gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, sTradeStringBuffer[0], 0, 0, 3); + sub_80C6D80(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, sTradeStringBuffer[3], 0, 0, 3); - sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sTradeStringBuffer[6], 0, 0, 2); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sTradeStringBuffer[8], 24); + sub_80C6D80(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); + sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; sTradeData->unk_A8 = 0; break; @@ -709,11 +715,11 @@ static void sub_8077B74(void) gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, sTradeStringBuffer[0], 0, 0, 3); + sub_80C6D80(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, sTradeStringBuffer[3], 0, 0, 3); - sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sTradeStringBuffer[6], 0, 0, 2); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sTradeStringBuffer[8], 24); + sub_80C6D80(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); + sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; sTradeData->unk_A8 = 0; break; @@ -844,27 +850,29 @@ static void sub_80781C8(void) { gMain.savedCallback = sub_80773AC; + // Wireless Link Trade if (gWirelessCommType) { if (sub_8010500()) { - Free(sTradeStringAllocBuffer); + Free(sMessageBoxAllocBuffer); FreeAllWindowBuffers(); Free(sTradeData); gMain.callback1 = NULL; DestroyWirelessStatusIndicatorSprite(); - SetMainCallback2(sub_807AE50); + SetMainCallback2(CB2_LinkTrade); } } + // Cable Link Trade else { if (!gReceivedRemoteLinkPlayers) { - Free(sTradeStringAllocBuffer); + Free(sMessageBoxAllocBuffer); FreeAllWindowBuffers(); Free(sTradeData); gMain.callback1 = NULL; - SetMainCallback2(sub_807AE50); + SetMainCallback2(CB2_LinkTrade); } } } @@ -1299,7 +1307,7 @@ static void sub_8078C34(void) sub_80789FC(); } -static u8 sub_8078C6C(u8 oldPosition, u8 direction) +static u8 GetNewTradeMenuPosition(u8 oldPosition, u8 direction) { int i; u8 newPosition = 0; @@ -1318,9 +1326,9 @@ static u8 sub_8078C6C(u8 oldPosition, u8 direction) static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) { - u8 newPosition = sub_8078C6C(*cursorPosition, direction); + u8 newPosition = GetNewTradeMenuPosition(*cursorPosition, direction); - if (newPosition == 12) // CANCEL + if (newPosition == (PARTY_SIZE * 2)) // CANCEL { StartSpriteAnim(&gSprites[sTradeData->cursorSpriteIdx], 1); gSprites[sTradeData->cursorSpriteIdx].pos1.x = 224; @@ -1356,7 +1364,7 @@ static void sub_8078D78(void) } } -static void sub_8078DBC(void) +static void TradeMenuProcessInput(void) { if (gMain.newAndRepeatedKeys & DPAD_UP) { @@ -1406,7 +1414,7 @@ static void sub_8078DBC(void) } } -static void sub_8078EF8(void) +static void ReturnToTradeMenu(void) { sub_8079F74(); sTradeData->unk_6F = 0; @@ -1420,7 +1428,7 @@ static void TradeMenuProcessInput_SelectedMon(void) { case MENU_B_PRESSED: PlaySE(SE_SELECT); - sub_8078EF8(); + ReturnToTradeMenu(); break; case MENU_NOTHING_CHOSEN: break; @@ -1454,12 +1462,12 @@ static void TradeMenuProcessInput_SelectedMon(void) } } -static void sub_8079034(void) +static void ReturnToTradeMenuAfterButtonPress(void) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); - sub_8078EF8(); + ReturnToTradeMenu(); } } @@ -1582,7 +1590,7 @@ static void sub_807929C(void) { int i; - for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER] - 4; i++) + for (i = 0; i < sTradeData->partyCounts[1] - 4; i++) { PutWindowTilemap(i + 12); CopyWindowToVram(i + 12, 1); @@ -1603,7 +1611,7 @@ static void sub_80792E4(void) case 1: case MENU_B_PRESSED: PlaySE(SE_SELECT); - sub_8078EF8(); + ReturnToTradeMenu(); break; } } @@ -1687,7 +1695,7 @@ static void sub_80794CC(void) { if (sub_80771BC() && sub_807A09C() == 0) { - Free(sTradeStringAllocBuffer); + Free(sMessageBoxAllocBuffer); Free(sTradeData); FreeAllWindowBuffers(); DestroyWirelessStatusIndicatorSprite(); @@ -1698,7 +1706,7 @@ static void sub_80794CC(void) { if (!gReceivedRemoteLinkPlayers) { - Free(sTradeStringAllocBuffer); + Free(sMessageBoxAllocBuffer); Free(sTradeData); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); @@ -1730,7 +1738,7 @@ static void sub_80795AC(void) switch (sTradeData->unk_6F) { case 0: - sub_8078DBC(); + TradeMenuProcessInput(); break; case 1: TradeMenuProcessInput_SelectedMon(); @@ -1772,7 +1780,7 @@ static void sub_80795AC(void) Wait2SecondsAndCreateYesNoMenu(); break; case 15: - sub_8079034(); + ReturnToTradeMenuAfterButtonPress(); break; case 16: sub_8079550(); @@ -2015,7 +2023,11 @@ static void sub_8079E44(u8 whichParty) for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { - DrawTradeMenuPartyMonInfo(whichParty, i, gTradeLevelDisplayCoords[whichParty][i][0], gTradeLevelDisplayCoords[whichParty][i][1], gTradeMonBoxCoords[whichParty][i][0], gTradeMonBoxCoords[whichParty][i][1]); + DrawTradeMenuPartyMonInfo(whichParty, i, + gTradeLevelDisplayCoords[whichParty][i][0], + gTradeLevelDisplayCoords[whichParty][i][1], + gTradeMonBoxCoords[whichParty][i][0], + gTradeMonBoxCoords[whichParty][i][1]); } } #else @@ -2203,9 +2215,9 @@ static bool8 sub_807A1F0(void) { struct SpriteSheet sheet; - if (sTradeData->unk_A8 < 14) + if (sTradeData->unk_A8 < (int)ARRAY_COUNT(sMessageBoxTileBuffers)) { - sheet.data = sTradeStringBuffer[sTradeData->unk_A8]; + sheet.data = sMessageBoxTileBuffers[sTradeData->unk_A8]; sheet.size = 0x100; sheet.tag = 200 + sTradeData->unk_A8; } @@ -2233,7 +2245,7 @@ static bool8 sub_807A1F0(void) sTradeData->unk_A8++; break; case 16: - LoadSpriteSheet(&gUnknown_0832DC3C); + LoadSpriteSheet(&sTradeButtonsSpriteSheet); sTradeData->unk_A8++; break; case 17: @@ -2350,6 +2362,7 @@ static void sub_807A5B0(void) } } +//TODO: static u32 sub_807A5F4(struct Pokemon *playerParty, int partyCount, int monIdx) { int i, sum; @@ -2860,7 +2873,7 @@ static void sub_807AB04(struct Sprite *sprite) } } -static void sub_807AB28(void) +static void SetTradeBGAffine(void) { struct BgAffineDstData affine; @@ -2875,7 +2888,7 @@ static void sub_807AB28(void) SetGpuReg(REG_OFFSET_BG2Y_H, affine.dy >> 16); } -static void sub_807ABCC(void) +static void SetTradeGpuRegs(void) { u16 dispcnt; @@ -2890,42 +2903,42 @@ static void sub_807ABCC(void) } 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) { - sTradeWindowData->unk_8A = 0; - sTradeWindowData->unk_88 = 0; - sTradeWindowData->unk_89 = 0; + sTradeWindowData->linkTimeoutCounter = 0; + sTradeWindowData->alwaysZero_88 = 0; + sTradeWindowData->alwaysZero_89 = 0; } -static void sub_807AC64(void) +static void CheckForLinkTimeout(void) { - if (sTradeWindowData->unk_88 == sTradeWindowData->unk_89) - sTradeWindowData->unk_8A++; + if (sTradeWindowData->alwaysZero_88 == sTradeWindowData->alwaysZero_89) + sTradeWindowData->linkTimeoutCounter++; else - sTradeWindowData->unk_8A = 0; + sTradeWindowData->linkTimeoutCounter = 0; - if (sTradeWindowData->unk_8A > 300) + if (sTradeWindowData->linkTimeoutCounter > LINK_TRADE_TIMEOUT) { CloseLink(); SetMainCallback2(CB2_LinkError); - sTradeWindowData->unk_8A = 0; - sTradeWindowData->unk_89 = 0; - sTradeWindowData->unk_88 = 0; + sTradeWindowData->linkTimeoutCounter = 0; + sTradeWindowData->alwaysZero_89 = 0; + sTradeWindowData->alwaysZero_88 = 0; } - sTradeWindowData->unk_89 = sTradeWindowData->unk_88; + sTradeWindowData->alwaysZero_89 = sTradeWindowData->alwaysZero_88; } static u32 TradeGetMultiplayerId(void) @@ -2978,7 +2991,7 @@ static void sub_807ACFC(u8 whichParty, u8 a1) } } -void sub_807AE50(void) +void CB2_LinkTrade(void) { switch (gMain.state) { @@ -2993,9 +3006,9 @@ void sub_807AE50(void) ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); - SetVBlankCallback(sub_807AC24); - sub_807B170(); - sub_807AC3C(); + SetVBlankCallback(VBlankCB_Trade); + InitTradeBgInternal(); + ClearLinkTimeoutCounter(); gMain.state++; sTradeWindowData->neverRead_8C = 0; sTradeWindowData->state = 0; @@ -3012,7 +3025,7 @@ void sub_807AE50(void) case 1: if (!gReceivedRemoteLinkPlayers) { - sTradeWindowData->isCableLink = TRUE; + sTradeWindowData->isCableTrade = TRUE; OpenLink(); gMain.state++; sTradeWindowData->timer = 0; @@ -3042,7 +3055,7 @@ void sub_807AE50(void) } else { - sub_807AC64(); + CheckForLinkTimeout(); } } else @@ -3051,7 +3064,7 @@ void sub_807AE50(void) } break; case 4: - sub_807AC64(); + CheckForLinkTimeout(); if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) gMain.state++; break; @@ -3076,9 +3089,9 @@ void sub_807AE50(void) gMain.state++; break; case 9: - sub_807BA94(); - LoadSpriteSheet(&gUnknown_08338D18); - LoadSpritePalette(&gUnknown_08338D20); + LoadTradeSequenceSpriteSheetsAndPalettes(); + LoadSpriteSheet(&sPokeBallSpriteSheet); + LoadSpritePalette(&sPokeBallSpritePalette); gMain.state++; break; case 10: @@ -3123,7 +3136,7 @@ void sub_807B154(void) CopyWindowToVram(0, 3); } -static void sub_807B170(void) +static void InitTradeBgInternal(void) { SetGpuReg(REG_OFFSET_DISPCNT, 0); ResetBgsAndClearDma3BusyFlags(0); @@ -3164,8 +3177,8 @@ static void CB2_InGameTrade(void) ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); - SetVBlankCallback(sub_807AC24); - sub_807B170(); + SetVBlankCallback(VBlankCB_Trade); + InitTradeBgInternal(); sTradeWindowData->isLinkTrade = FALSE; sTradeWindowData->neverRead_8C = 0; sTradeWindowData->state = 0; @@ -3201,9 +3214,9 @@ static void CB2_InGameTrade(void) gMain.state++; break; case 9: - sub_807BA94(); - LoadSpriteSheet(&gUnknown_08338D18); - LoadSpritePalette(&gUnknown_08338D20); + LoadTradeSequenceSpriteSheetsAndPalettes(); + LoadSpriteSheet(&sPokeBallSpriteSheet); + LoadSpritePalette(&sPokeBallSpritePalette); gMain.state++; break; case 10: @@ -3299,7 +3312,7 @@ static void sub_807B5B8(void) static void sub_807B60C(void) { - sub_807BBC8(); + AnimateTradeSequence(); RunTasks(); RunTextPrinters(); AnimateSprites(); @@ -3343,7 +3356,7 @@ static void sub_807B62C(u8 a0) BGCNT_SCREENBASE(18) | BGCNT_TXT256x512); - if (sTradeWindowData->isCableLink) + if (sTradeWindowData->isCableTrade) { DmaCopy16Defvars(3, sTradeTilemap_GbaCable, (void *) BG_SCREEN_ADDR(5), 0x1000); } @@ -3361,7 +3374,7 @@ static void sub_807B62C(u8 a0) case 2: sTradeWindowData->bg1vofs = 0; sTradeWindowData->bg1hofs = 0; - if (!sTradeWindowData->isCableLink) + if (!sTradeWindowData->isCableTrade) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3409,7 +3422,7 @@ static void sub_807B62C(u8 a0) DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (sTradeWindowData->isCableLink) + if (sTradeWindowData->isCableTrade) { DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); } @@ -3442,7 +3455,7 @@ static void sub_807B62C(u8 a0) DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (sTradeWindowData->isCableLink) + if (sTradeWindowData->isCableTrade) { DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); } @@ -3467,14 +3480,14 @@ static void sub_807B62C(u8 a0) } } -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); } /// Buffers "[Pokemon] will be sent to [Trainer]" strings @@ -3503,19 +3516,20 @@ static void SetTradeSceneStrings(void) } } -static bool8 sub_807BBC8(void) +// returns TRUE if it was a link trade, FALSE if it was an in-game trade +static bool8 AnimateTradeSequence(void) { - if (sTradeWindowData->isCableLink) + if (sTradeWindowData->isCableTrade) { - return sub_807BBEC(); + return AnimateTradeSequenceCable(); } else { - return sub_807CFC8(); + return AnimateTradeSequenceWireless(); } } -static bool8 sub_807BBEC(void) +static bool8 AnimateTradeSequenceCable(void) { u16 evoTarget; @@ -3615,7 +3629,7 @@ static bool8 sub_807BBEC(void) case 24: if (++sTradeWindowData->timer > 20) { - sub_807AB28(); + SetTradeBGAffine(); sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); sTradeWindowData->state++; } @@ -3822,7 +3836,7 @@ static bool8 sub_807BBEC(void) sTradeWindowData->bg1vofs = 348; sTradeWindowData->state++; } - if (sTradeWindowData->bg1vofs == 328 && sTradeWindowData->isCableLink) + if (sTradeWindowData->bg1vofs == 328 && sTradeWindowData->isCableTrade) { sTradeWindowData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); gSprites[sTradeWindowData->unk_92].callback = sub_807AAE0; @@ -4000,14 +4014,14 @@ static bool8 sub_807BBEC(void) FREE_AND_SET_NULL(sTradeWindowData); } SetMainCallback2(CB2_ReturnToField); - sub_807E784(); + BuffeInGameTradeMonName(); } break; } return FALSE; } -static bool8 sub_807CFC8(void) +static bool8 AnimateTradeSequenceWireless(void) { u16 evoTarget; @@ -4515,7 +4529,7 @@ static bool8 sub_807CFC8(void) FREE_AND_SET_NULL(sTradeWindowData); } SetMainCallback2(CB2_ReturnToField); - sub_807E784(); + BuffeInGameTradeMonName(); } break; } @@ -4600,7 +4614,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) @@ -4618,7 +4632,7 @@ 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); @@ -4646,7 +4660,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; } @@ -4660,7 +4674,7 @@ u16 GetInGameTradeSpeciesInfo(void) return inGameTrade->requestedSpecies; } -static void sub_807E784(void) +static void BuffeInGameTradeMonName(void) { u8 nickname[32]; const struct InGameTrade *inGameTrade = &sIngameTrades[gSpecialVar_0x8004]; @@ -4720,7 +4734,7 @@ static void _CreateInGameTradePokemon(u8 whichPlayerMon, u8 whichInGameTrade) static void SetInGameTradeMail(struct MailStruct *mail, const struct InGameTrade *trade) { s32 i; - for (i = 0; i < INGAME_TRADE_MAIL_LENGTH; i++) + for (i = 0; i < MAIL_WORDS_COUNT; i++) { mail->words[i] = sIngameTradeMail[trade->mailNum][i]; } @@ -4750,7 +4764,7 @@ void CreateInGameTradePokemon(void) static void sub_807EA2C(void) { - if (sub_807BBC8() == TRUE) + if (AnimateTradeSequence() == TRUE) { DestroySprite(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]]); FreeSpriteOamMatrix(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]]); @@ -5007,9 +5021,9 @@ static void CheckPartnersMonForRibbons(void) FlagSet(FLAG_SYS_RIBBON_GET); } -void sub_807F19C(void) +void InitTradeBg(void) { - sub_807B170(); + InitTradeBgInternal(); } void DrawTextOnTradeWindow(u8 windowId, const u8 *str, u8 speed) diff --git a/src/union_room.c b/src/union_room.c index 382e6c595..0ca925098 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -1312,7 +1312,7 @@ void sub_8013F90(u8 taskId) gSelectedTradeMonPositions[TRADE_PLAYER] = monId; gSelectedTradeMonPositions[TRADE_PARTNER] = PARTY_SIZE; gMain.savedCallback = CB2_ReturnToField; - SetMainCallback2(sub_807AE50); + SetMainCallback2(CB2_LinkTrade); ResetUnionRoomTrade(&sUnionRoomTrade); DestroyTask(taskId); } From d1bcd60b58dafea5b8e48cc615460a8039ae6c4b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 6 Oct 2019 22:58:25 -0400 Subject: [PATCH 07/11] Document more trade.c --- include/constants/trade.h | 31 ++ include/link.h | 14 +- include/party_menu.h | 2 +- include/pokemon_storage_system.h | 2 +- include/trade.h | 2 +- src/data/trade.h | 22 +- src/evolution_scene.c | 2 +- src/party_menu.c | 20 +- src/pokemon_storage_system.c | 21 +- src/trade.c | 612 +++++++++++++++---------------- 10 files changed, 370 insertions(+), 358 deletions(-) diff --git a/include/constants/trade.h b/include/constants/trade.h index bd66a16aa..f03ced677 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -4,6 +4,7 @@ #define TRADE_PLAYER 0 #define TRADE_PARTNER 1 +// In-game Trade IDs #define INGAME_TRADE_SEEDOT 0 #define INGAME_TRADE_PLUSLE 1 #define INGAME_TRADE_HORSEA 2 @@ -13,6 +14,21 @@ #define PLAYER_MON_VALID 1 #define PARTNER_MON_INVALID 2 +// Flag IDs for sending link data +#define CHOSE_VALID_MON 1 +#define CHOSE_INVALID_MON 2 +#define WANTS_TO_TRADE 1 +#define WANTS_TO_CANCEL 2 + +// Return values for CanTradeSelectedMon +#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 + +// Indexes for sTradeActionTexts #define TRADE_ACTION_TEXT_CANCEL 0 #define TRADE_ACTION_TEXT_CHOOSE_MON 1 #define TRADE_ACTION_TEXT_SUMMARY 2 @@ -34,6 +50,21 @@ #define TRADE_MSG_EGG_CANT_BE_TRADED 7 #define TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED 8 +// Queue actions +#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 + +// Queue delays +#define QUEUE_DELAY_MSG 3 +#define QUEUE_DELAY_DATA 5 + // Message indexes for sUnionRoomTradeMessages #define UR_TRADE_MSG_NONE 0 #define UR_TRADE_MSG_NOT_MON_PARTNER_WANTS 1 diff --git a/include/link.h b/include/link.h index c14084066..4d6e4593c 100644 --- a/include/link.h +++ b/include/link.h @@ -48,7 +48,7 @@ #define EXTRACT_LINK_ERRORS(status) \ (((status) & LINK_STAT_ERRORS) >> LINK_STAT_ERRORS_SHIFT) -#define LINKCMD_SEND_LINK_TYPE 0x2222 +#define LINKCMD_SEND_LINK_TYPE 0x2222 #define LINKCMD_0x2FFE 0x2FFE #define LINKCMD_SEND_HELD_KEYS 0x4444 #define LINKCMD_0x5555 0x5555 @@ -59,9 +59,21 @@ #define LINKCMD_CONT_BLOCK 0x8888 #define LINKCMD_0xAAAA 0xAAAA #define LINKCMD_0xAAAB 0xAAAB +#define LINKCMD_0xAABB 0xAABB // used in trade #define LINKCMD_INIT_BLOCK 0xBBBB +#define LINKCMD_0xBBCC 0xBBCC // used in trade #define LINKCMD_SEND_HELD_KEYS_2 0xCAFE #define LINKCMD_0xCCCC 0xCCCC +#define LINKCMD_0xCCDD 0xCCDD // all below linkcmds used in trade +#define LINKCMD_0xDDDD 0xDDDD +#define LINKCMD_0xDDEE 0xDDEE +#define LINKCMD_0xEEAA 0xEEAA +#define LINKCMD_0xEEBB 0xEEBB +#define LINKCMD_0xEECC 0xEECC + +#define LINKCMD_0xABCD 0xABCD +#define LINKCMD_0xDCBA 0xDCBA + struct LinkStatus { diff --git a/include/party_menu.h b/include/party_menu.h index 1ea9ea1d1..1f66ef3f9 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -103,7 +103,7 @@ 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/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 9975e17af..9d48f6b23 100644 --- a/include/trade.h +++ b/include/trade.h @@ -11,7 +11,7 @@ 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); diff --git a/src/data/trade.h b/src/data/trade.h index 8d4139571..1d6cfd441 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -39,14 +39,14 @@ static const u8 sText_OnlyPkmnForBattle[] = _("That's your only\nPOKéMON for ba 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 gOamData_832DC14 = +static const struct OamData sTradeOamData_32x16 = { .shape = SPRITE_SHAPE(32x16), .size = SPRITE_SIZE(32x16), .priority = 1 }; -static const struct OamData gOamData_832DC1C = +static const struct OamData sTradeOamData_64x32 = { .shape = SPRITE_SHAPE(64x32), .size = SPRITE_SIZE(64x32), @@ -134,7 +134,7 @@ static const struct SpriteTemplate gSpriteTemplate_832DC94 = { .tileTag = 300, .paletteTag = 2345, - .oam = &gOamData_832DC1C, + .oam = &sTradeOamData_64x32, .anims = gSpriteAnimTable_832DC34, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -145,7 +145,7 @@ static const struct SpriteTemplate gSpriteTemplate_832DCAC = { .tileTag = 200, .paletteTag = 4925, - .oam = &gOamData_832DC14, + .oam = &sTradeOamData_32x16, .anims = gSpriteAnimTable_832DC7C, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -271,7 +271,7 @@ static const u8 gTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] = {23, 18} // CANCEL }; -static const u8 gTradeLevelDisplayCoords[][PARTY_SIZE][2] = +static const u8 sTradeMonCoords[][PARTY_SIZE][2] = { { // Your party @@ -293,7 +293,7 @@ static const u8 gTradeLevelDisplayCoords[][PARTY_SIZE][2] = } }; -static const u8 gTradeMonBoxCoords[][PARTY_SIZE][2] = +static const u8 sTradeMonBoxDimensions[][PARTY_SIZE][2] = { { // Your party @@ -373,7 +373,7 @@ static const u8 sTradeTextColors[] = TEXT_COLOR_DARK_GREY //shadow color }; -static const struct BgTemplate gUnknown_0832DEE4[] = +static const struct BgTemplate sTradeMenuBgTemplates[] = { { .bg = 0, @@ -413,7 +413,7 @@ static const struct BgTemplate gUnknown_0832DEE4[] = }, }; -static const struct WindowTemplate gUnknown_0832DEF4[] = +static const struct WindowTemplate sTradeMenuWindowTemplates[] = { { .bg = 0, @@ -1057,7 +1057,7 @@ static const u16 sIngameTradeMail[][MAIL_WORDS_COUNT + 1] = } }; -static const struct WindowTemplate gUnknown_08338FFC[] = +static const struct WindowTemplate sTradeSequenceWindowTemplates[] = { { .bg = 0, @@ -1071,7 +1071,7 @@ static const struct WindowTemplate gUnknown_08338FFC[] = DUMMY_WIN_TEMPLATE }; -const struct WindowTemplate gUnknown_0833900C = +const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate = { .bg = 0, .tilemapLeft = 21, @@ -1082,7 +1082,7 @@ const struct WindowTemplate gUnknown_0833900C = .baseBlock = 188 }; -static const struct BgTemplate gUnknown_08339014[] = +static const struct BgTemplate sTradeSequenceBgTemplates[] = { { .bg = 0, diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 7cfbc2e6b..0b8d89658 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -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; diff --git a/src/party_menu.c b/src/party_menu.c index 12f91168b..be2e0a34c 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -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*); @@ -5095,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 who) { u16 i; u16 item; - switch (c) + switch (who) { - 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); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 83b0dfee8..ed87531cb 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 zero1, u8 zero2, s32 arg4) +void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 bytesToBuffer) { - s32 i, val, val2; + s32 i, tileBytesToBuffer, val2; u16 windowId; u8 txtColor[3]; u8 *tileData1, *tileData2; @@ -1563,13 +1563,13 @@ void sub_80C6D80(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 arg4) 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; + val2 = 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,6 +1579,7 @@ void sub_80C6D80(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 arg4) } } + // Never used. bytesToBuffer is always passed <= 6, so val2 is always zero here if (val2 > 0) CpuFill16((zero2 << 4) | zero2, dst, (u32)(val2) * 0x100); @@ -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 de7decbc2..5294ee2e2 100644 --- a/src/trade.c +++ b/src/trade.c @@ -85,7 +85,7 @@ static EWRAM_DATA struct { /*0x0000*/ u8 bg2hofs; /*0x0001*/ u8 bg3hofs; /*0x0002*/ u8 filler_2[0x28 - 2]; - /*0x0028*/ u8 partyIcons[2][PARTY_SIZE]; + /*0x0028*/ u8 partySpriteIds[2][PARTY_SIZE]; /*0x0034*/ u8 cursorSpriteIdx; /*0x0035*/ u8 cursorPosition; /*0x0036*/ u8 partyCounts[2]; @@ -94,30 +94,30 @@ static EWRAM_DATA struct { /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; - /*0x0069*/ u8 unk_69; //state var + /*0x0069*/ u8 unk_69; //state var for shedinja_maker_maybe /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; - /*0x006F*/ u8 unk_6F; //state var for sub_80795AC + /*0x006F*/ u8 tradeMenuFunc; //switch var for sub_80795AC /*0x0070*/ u8 neverRead_70; /*0x0071*/ u8 filler_71; /*0x0072*/ u16 unk_72; //sheet /*0x0074*/ u8 drawPartyState[2]; /*0x0076*/ u8 selectedMonIdx[2]; - /*0x0078*/ u8 unk_78; //recv buffer block flag - /*0x0079*/ u8 unk_79; //recv buffer block flag - /*0x007A*/ u8 unk_7A; //recv buffer block flag - /*0x007B*/ u8 unk_7B; //recv buffer block flag + /*0x0078*/ u8 playerLinkFlagChoseAction; + /*0x0079*/ u8 partnerLinkFlagChoseAction; + /*0x007A*/ u8 playerLinkFlagChoseMon; + /*0x007B*/ u8 partnerLinkFlagChoseMon; /*0x007C*/ u8 filler_7C[0x7E - 0x7C]; /*0x007E*/ u8 partnerCursorPosition; /*0x007F*/ u8 unused_7F; /*0x0080*/ u16 linkData[20]; - /*0x00A8*/ u8 unk_A8; // used as a timer and state var for sub_807A1F0 - /*0x00A9*/ u8 unk_A9[11]; //ribbons + /*0x00A8*/ u8 timer; + /*0x00A9*/ u8 giftRibbons[11]; /*0x00B4*/ u8 filler_B4[0x8D0-0xB4]; /*0x08D0*/ struct { - bool8 unk_0; - u16 unk_2; - u8 monValidity; - } unk_8D0[4]; + bool8 queued; + u16 queueDelay; + u8 actionId; + } queuedActions[4]; /*0x08F0*/ u16 tilemapBuffer[0x400]; } *sTradeData = {NULL}; static EWRAM_DATA struct { @@ -172,34 +172,34 @@ static EWRAM_DATA struct { static bool32 IsWirelessTrade(void); static void sub_80773D0(void); static void sub_807811C(void); -static void sub_807825C(void); +static void CB2_TradeMenu(void); static void sub_80782B8(u8); -static void sub_8078388(void); +static void SetTradePartyMonsVisible(void); static bool8 shedinja_maker_maybe(void); static void sub_8078C34(void); static void sub_80795AC(void); static void SetSelectedMon(u8); static void DrawTradeMenuParty(u8); -static u8 sub_8079A3C(u8 *, u8, 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 sub_8079E44(u8); static void sub_8079F74(void); -static void sub_8079F88(u8); +static void RedrawTradeMenuParty(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 QueueAction(u16, u8); +static u32 GetNumQueuedActions(void); +static void DoQueuedActions(void); static void PrintTradeMessage(u8); -static bool8 sub_807A1F0(void); -static void sub_807A308(const u8 *, u8 *, u8); -static void sub_807A320(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 sub_807A5B0(void); -static u32 sub_807A5F4(struct Pokemon *, int, int); +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); @@ -255,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 { @@ -277,37 +273,25 @@ static u32 _GetBlockReceivedStatus(void) static void TradeResetReceivedFlags(void) { if (IsWirelessTrade()) - { rfu_clearSlot(12, gUnknown_03004140.unk_00); - } else - { ResetBlockReceivedFlags(); - } } static void TradeResetReceivedFlag(u32 who) { if (IsWirelessTrade()) - { rfu_clearSlot(12, gUnknown_03004140.unk_00); - } else - { ResetBlockReceivedFlag(who); - } } static bool32 IsWirelessTrade(void) { if (gWirelessCommType && gUnknown_02022C2C == 29) - { return TRUE; - } else - { return FALSE; - } } static void sub_8077288(u8 unused) @@ -333,10 +317,10 @@ static void InitTradeMenu(void) LoadPalette(gUnknown_0860F074, 0xF0, 20); LoadPalette(gUnknown_0860F074, 0xD0, 20); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_0832DEE4, ARRAY_COUNT(gUnknown_0832DEE4)); + InitBgsFromTemplates(0, sTradeMenuBgTemplates, ARRAY_COUNT(sTradeMenuBgTemplates)); SetBgTilemapBuffer(1, sTradeData->tilemapBuffer); - if (InitWindows(gUnknown_0832DEF4)) + if (InitWindows(sTradeMenuWindowTemplates)) { u32 i; @@ -353,13 +337,13 @@ static void InitTradeMenu(void) LoadUserWindowBorderGfx(2, 1, 0xE0); LoadMonIconPalettes(); sTradeData->unk_69 = 0; - sTradeData->unk_6F = 0; + sTradeData->tradeMenuFunc = 0; sTradeData->neverRead_70 = 0; sTradeData->drawPartyState[TRADE_PLAYER] = 0; sTradeData->drawPartyState[TRADE_PARTNER] = 0; - sTradeData->unk_7A = 0; - sTradeData->unk_7B = 0; - sTradeData->unk_A8 = 0; + sTradeData->playerLinkFlagChoseMon = 0; + sTradeData->partnerLinkFlagChoseMon = 0; + sTradeData->timer = 0; } } @@ -396,7 +380,7 @@ 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); } PrintTradeMessage(TRADE_MSG_STANDBY); @@ -405,7 +389,7 @@ static void sub_80773D0(void) if (!gReceivedRemoteLinkPlayers) { gLinkType = 0x1122; - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; if (gWirelessCommType) { @@ -426,10 +410,10 @@ static void sub_80773D0(void) } break; case 2: - sTradeData->unk_A8++; - if (sTradeData->unk_A8 > 11) + sTradeData->timer++; + if (sTradeData->timer > 11) { - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; gMain.state++; } break; @@ -438,7 +422,7 @@ static void sub_80773D0(void) { if (IsLinkMaster()) { - if (++sTradeData->unk_A8 > 30) + if (++sTradeData->timer > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -456,7 +440,7 @@ static void sub_80773D0(void) sub_8011BD0(); CalculatePlayerPartyCount(); gMain.state++; - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; if (gWirelessCommType) { sub_801048C(TRUE); @@ -496,7 +480,7 @@ static void sub_80773D0(void) for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + sTradeData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -508,7 +492,7 @@ static void sub_80773D0(void) for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -520,24 +504,24 @@ static void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 0); + DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); gMain.state++; break; case 9: - sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 1); + DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); + DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); - sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); + DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); + DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; break; case 11: - if (sub_807A1F0()) + if (LoadTradeMenuSpriteSheetsAndPalettes()) gMain.state++; break; case 12: @@ -579,16 +563,16 @@ static void sub_80773D0(void) rbox_fill_rectangle(0); break; case 14: - sub_807A320(TRADE_PLAYER); + SetTradePartyLiveStatuses(TRADE_PLAYER); PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); sTradeData->bg2hofs = 0; sTradeData->bg3hofs = 0; - sub_8078388(); + SetTradePartyMonsVisible(); gMain.state++; PlayBGM(MUS_P_SCHOOL); break; case 15: - sub_807A320(TRADE_PARTNER); + SetTradePartyLiveStatuses(TRADE_PARTNER); PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); gMain.state++; // fallthrough @@ -622,7 +606,7 @@ static void sub_80773D0(void) if (!gPaletteFade.active) { gMain.callback1 = sub_8078C34; - SetMainCallback2(sub_807825C); + SetMainCallback2(CB2_TradeMenu); } break; } @@ -649,7 +633,7 @@ static void sub_8077B74(void) break; case 1: gMain.state++; - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; break; case 2: gMain.state++; @@ -683,7 +667,7 @@ static void sub_8077B74(void) for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeData->partyIcons[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, @@ -695,7 +679,7 @@ static void sub_8077B74(void) for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeData->partyIcons[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), sub_80D3014, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -707,24 +691,24 @@ static void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 0); + DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); gMain.state++; break; case 9: - sub_81B5D4C(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partyIcons[TRADE_PLAYER], 1); + DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); gMain.state++; break; case 10: - sub_80C6D80(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); + DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); - sub_80C6D80(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); - sub_80C6D80(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); + DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); + DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; break; case 11: - if (sub_807A1F0()) + if (LoadTradeMenuSpriteSheetsAndPalettes()) gMain.state++; break; case 12: @@ -776,7 +760,7 @@ static void sub_8077B74(void) sub_80782B8(1); sTradeData->bg2hofs = 0; sTradeData->bg3hofs = 0; - sub_8078388(); + SetTradePartyMonsVisible(); gMain.state++; break; case 18: @@ -800,7 +784,7 @@ static void sub_8077B74(void) case 22: if (!gPaletteFade.active) { - SetMainCallback2(sub_807825C); + SetMainCallback2(CB2_TradeMenu); } break; } @@ -820,10 +804,10 @@ static void sub_807811C(void) static void sub_8078130(void) { - if (++sTradeData->unk_A8 > 15) + if (++sTradeData->timer > 15) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->unk_6F = 10; + sTradeData->tradeMenuFunc = 10; } } @@ -836,12 +820,12 @@ static void sub_807816C(void) if (gWirelessCommType) { - sTradeData->unk_6F = 16; + sTradeData->tradeMenuFunc = 16; } else { sub_800ABF4(32); - sTradeData->unk_6F = 13; + sTradeData->tradeMenuFunc = 13; } } } @@ -877,12 +861,10 @@ static void sub_80781C8(void) } } -static void sub_807825C(void) +static void CB2_TradeMenu(void) { - u8 temp; - - sub_80795AC(); - sub_807A0C4(); + sub_80795AC(); //func switch + DoQueuedActions(); DrawTradeMenuParty(TRADE_PLAYER); DrawTradeMenuParty(TRADE_PARTNER); @@ -896,11 +878,11 @@ static void sub_807825C(void) UpdatePaletteFade(); } -static void sub_80782B8(u8 a0) +static void sub_80782B8(u8 state) { int i; - switch (a0) + switch (state) { case 0: LoadPalette(gTradeMenu_Pal, 0, 0x60); @@ -927,7 +909,7 @@ static void sub_80782B8(u8 a0) } } -static void sub_8078388(void) +static void SetTradePartyMonsVisible(void) { int i; @@ -935,7 +917,7 @@ static void sub_8078388(void) { if (i < sTradeData->partyCounts[TRADE_PLAYER]) { - gSprites[sTradeData->partyIcons[TRADE_PLAYER][i]].invisible = FALSE; + gSprites[sTradeData->partySpriteIds[TRADE_PLAYER][i]].invisible = FALSE; sTradeData->monPresent[i] = TRUE; } else @@ -945,7 +927,7 @@ static void sub_8078388(void) if (i < sTradeData->partyCounts[TRADE_PARTNER]) { - gSprites[sTradeData->partyIcons[TRADE_PARTNER][i]].invisible = FALSE; + gSprites[sTradeData->partySpriteIds[TRADE_PARTNER][i]].invisible = FALSE; sTradeData->monPresent[i + PARTY_SIZE] = TRUE; } else @@ -981,7 +963,7 @@ static bool8 shedinja_maker_maybe(void) case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); sTradeData->unk_69++; - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; break; case 1: if (sub_80771BC()) @@ -1070,7 +1052,7 @@ static bool8 shedinja_maker_maybe(void) } break; case 17: - Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, 11); + Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, ARRAY_COUNT(sTradeData->giftRibbons)); sTradeData->unk_69++; break; case 19: @@ -1083,7 +1065,7 @@ static bool8 shedinja_maker_maybe(void) case 20: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(sTradeData->unk_A9, gBlockRecvBuffer[id ^ 1], 11); + Trade_Memcpy(sTradeData->giftRibbons, gBlockRecvBuffer[id ^ 1], ARRAY_COUNT(sTradeData->giftRibbons)); TradeResetReceivedFlags(); sTradeData->unk_69++; } @@ -1113,10 +1095,10 @@ static bool8 shedinja_maker_maybe(void) case 10: case 14: case 18: - sTradeData->unk_A8++; - if (sTradeData->unk_A8 > 10) + sTradeData->timer++; + if (sTradeData->timer > 10) { - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; sTradeData->unk_69++; } break; @@ -1124,28 +1106,28 @@ static bool8 shedinja_maker_maybe(void) return FALSE; } -static void sub_80787B8(void) +static void PrintAndBufferIsThisTradeOkay(void) { - sub_807A308(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); + DrawTextWindowAndBuffer6Bytes(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); } -static void sub_80787E0(u8 a0, u8 a1) +static void UpdateLinkFlags(u8 a0, u8 a1) { if (a1 & 1) { switch (gBlockRecvBuffer[0][0]) { case 0xEEAA: - sTradeData->unk_78 = 2; + sTradeData->playerLinkFlagChoseAction = WANTS_TO_CANCEL; break; case 0xAABB: - sTradeData->unk_78 = 1; + sTradeData->playerLinkFlagChoseAction = WANTS_TO_TRADE; break; case 0xBBBB: - sTradeData->unk_7A = 1; + sTradeData->playerLinkFlagChoseMon = CHOSE_VALID_MON; break; case 0xBBCC: - sTradeData->unk_7A = 2; + sTradeData->playerLinkFlagChoseMon = CHOSE_INVALID_MON; break; } TradeResetReceivedFlag(TRADE_PLAYER); @@ -1156,17 +1138,17 @@ static void sub_80787E0(u8 a0, u8 a1) switch (gBlockRecvBuffer[1][0]) { case 0xEEAA: - sTradeData->unk_79 = 2; + sTradeData->partnerLinkFlagChoseAction = WANTS_TO_CANCEL; break; case 0xAABB: sTradeData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; - sTradeData->unk_79 = 1; + sTradeData->partnerLinkFlagChoseAction = WANTS_TO_TRADE; break; case 0xBBBB: - sTradeData->unk_7B = 1; + sTradeData->partnerLinkFlagChoseMon = CHOSE_VALID_MON; break; case 0xBBCC: - sTradeData->unk_7B = 2; + sTradeData->partnerLinkFlagChoseMon = CHOSE_INVALID_MON; break; } TradeResetReceivedFlag(TRADE_PARTNER); @@ -1182,26 +1164,26 @@ static void sub_8078900(u8 a0, u8 a1) case 0xEEBB: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); - sTradeData->unk_6F = 11; + sTradeData->tradeMenuFunc = 11; break; case 0xEECC: PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); - sTradeData->unk_6F = 8; + sTradeData->tradeMenuFunc = 8; break; case 0xDDDD: sTradeData->partnerCursorPosition = gBlockRecvBuffer[0][1] + 6; rbox_fill_rectangle(0); SetSelectedMon(sTradeData->cursorPosition); SetSelectedMon(sTradeData->partnerCursorPosition); - sTradeData->unk_6F = 7; + sTradeData->tradeMenuFunc = 7; break; case 0xCCDD: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->unk_6F = 10; + sTradeData->tradeMenuFunc = 10; break; case 0xDDEE: PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeData->unk_6F = 8; + sTradeData->tradeMenuFunc = 8; } TradeResetReceivedFlag(TRADE_PLAYER); } @@ -1210,84 +1192,91 @@ static void sub_8078900(u8 a0, u8 a1) TradeResetReceivedFlag(TRADE_PARTNER); } +// TODO: SetLinkData with additional steps static void sub_80789FC(void) { - if (sTradeData->unk_78 && sTradeData->unk_79) + if (sTradeData->playerLinkFlagChoseAction && sTradeData->partnerLinkFlagChoseAction) { - if (sTradeData->unk_78 == 1 && sTradeData->unk_79 == 1) + if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_TRADE + && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { - sTradeData->unk_6F = 6; + sTradeData->tradeMenuFunc = 6; sTradeData->linkData[0] = 0xDDDD; sTradeData->linkData[1] = sTradeData->cursorPosition; - sub_807A048(5, 0); - sTradeData->unk_78 = sTradeData->unk_79 = 0; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; } - else if (sTradeData->unk_78 == 1 && sTradeData->unk_79 == 2) + else if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_TRADE + && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { PrintTradeMessage(TRADE_MSG_CANCELED); sTradeData->linkData[0] = 0xEECC; sTradeData->linkData[1] = 0; - sub_807A048(5, 0); - sTradeData->unk_7A = sTradeData->unk_7B = 0; - sTradeData->unk_78 = sTradeData->unk_79 = 0; - sTradeData->unk_6F = 8; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeData->playerLinkFlagChoseMon = sTradeData->partnerLinkFlagChoseMon = 0; + sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; + sTradeData->tradeMenuFunc = 8; } - else if (sTradeData->unk_78 == 2 && sTradeData->unk_79 == 1) + else if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_CANCEL + && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); sTradeData->linkData[0] = 0xDDEE; sTradeData->linkData[1] = 0; - sub_807A048(5, 0); - sTradeData->unk_7A = sTradeData->unk_7B = 0; - sTradeData->unk_78 = sTradeData->unk_79 = 0; - sTradeData->unk_6F = 8; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeData->playerLinkFlagChoseMon = sTradeData->partnerLinkFlagChoseMon = 0; + sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; + sTradeData->tradeMenuFunc = 8; } - else if (sTradeData->unk_78 == 2 && sTradeData->unk_79 == 2) + else if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_CANCEL + && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { sTradeData->linkData[0] = 0xEEBB; sTradeData->linkData[1] = 0; - sub_807A048(5, 0); + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->unk_78 = sTradeData->unk_79 = 0; - sTradeData->unk_6F = 11; + sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; + sTradeData->tradeMenuFunc = 11; } } - if (sTradeData->unk_7A && sTradeData->unk_7B) + if (sTradeData->playerLinkFlagChoseMon && sTradeData->partnerLinkFlagChoseMon) { - if (sTradeData->unk_7A == 1 && sTradeData->unk_7B == 1) + if (sTradeData->playerLinkFlagChoseMon == CHOSE_VALID_MON + && sTradeData->partnerLinkFlagChoseMon == CHOSE_VALID_MON) { sTradeData->linkData[0] = 0xCCDD; sTradeData->linkData[1] = 0; - sub_807A048(5, 0); - sTradeData->unk_7A = 0; - sTradeData->unk_7B = 0; - sTradeData->unk_6F = 9; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeData->playerLinkFlagChoseMon = 0; + sTradeData->partnerLinkFlagChoseMon = 0; + sTradeData->tradeMenuFunc = 9; } - if (sTradeData->unk_7A == 2 || sTradeData->unk_7B == 2) + if (sTradeData->playerLinkFlagChoseMon == CHOSE_INVALID_MON + || sTradeData->partnerLinkFlagChoseMon == CHOSE_INVALID_MON) { PrintTradeMessage(TRADE_MSG_CANCELED); sTradeData->linkData[0] = 0xDDEE; sTradeData->linkData[1] = 0; - sub_807A048(5, 0); - sTradeData->unk_7A = 0; - sTradeData->unk_7B = 0; - sTradeData->unk_6F = 8; + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); + sTradeData->playerLinkFlagChoseMon = 0; + sTradeData->partnerLinkFlagChoseMon = 0; + sTradeData->tradeMenuFunc = 8; } } } -static void sub_8078BFC(u16 *linkData, u16 linkFlag, u16 cursorPosition) +static void _SetLinkData(u16 *linkData, u16 linkCmd, u16 cursorPosition) { - linkData[0] = linkFlag; + linkData[0] = linkCmd; linkData[1] = cursorPosition; - sub_807A048(5, 0); + QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); } -static void SetLinkData(u16 linkFlag, u16 cursorPosition) +static void SetLinkData(u16 linkCmd, u16 cursorPosition) { - sub_8078BFC(sTradeData->linkData, linkFlag, cursorPosition); + _SetLinkData(sTradeData->linkData, linkCmd, cursorPosition); } static void sub_8078C34(void) @@ -1298,7 +1287,7 @@ static void sub_8078C34(void) if ((status = _GetBlockReceivedStatus())) { if (mpId == 0) - sub_80787E0(mpId, status); + UpdateLinkFlags(mpId, status); else sub_8078900(mpId, status); } @@ -1352,7 +1341,7 @@ static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) static void sub_8078D78(void) { PrintTradeMessage(TRADE_MSG_STANDBY); - sTradeData->unk_6F = 100; + sTradeData->tradeMenuFunc = 100; if (GetMultiplayerId() == 1) { @@ -1360,7 +1349,7 @@ static void sub_8078D78(void) } else { - sTradeData->unk_78 = 1; + sTradeData->playerLinkFlagChoseAction = WANTS_TO_TRADE; } } @@ -1396,20 +1385,20 @@ static void TradeMenuProcessInput(void) InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); PutWindowTilemap(1); CopyWindowToVram(1, 3); - sTradeData->unk_6F = 1; + sTradeData->tradeMenuFunc = 1; } // Cursor is in partner's party else if (sTradeData->cursorPosition < PARTY_SIZE * 2) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->unk_6F = 2; + sTradeData->tradeMenuFunc = 2; } // Cursor is on Cancel else if (sTradeData->cursorPosition == PARTY_SIZE * 2) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); - sTradeData->unk_6F = 4; - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); + sTradeData->tradeMenuFunc = 4; + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); } } } @@ -1417,9 +1406,9 @@ static void TradeMenuProcessInput(void) static void ReturnToTradeMenu(void) { sub_8079F74(); - sTradeData->unk_6F = 0; + sTradeData->tradeMenuFunc = 0; gSprites[sTradeData->cursorSpriteIdx].invisible = FALSE; - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); } static void TradeMenuProcessInput_SelectedMon(void) @@ -1434,28 +1423,28 @@ static void TradeMenuProcessInput_SelectedMon(void) break; case MENU_ACTION_SUMMARY: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->unk_6F = 2; + sTradeData->tradeMenuFunc = 2; break; case MENU_ACTION_TRADE: - switch (sub_807A5F4(gPlayerParty, gPlayerPartyCount, sTradeData->cursorPosition)) + switch (CanTradeSelectedMon(gPlayerParty, gPlayerPartyCount, sTradeData->cursorPosition)) { - case 0: + case CAN_TRADE_MON: sub_8078D78(); gSprites[sTradeData->cursorSpriteIdx].invisible = TRUE; break; - case 1: - sub_807A048(3, 3); - sTradeData->unk_6F = 8; + case CANT_TRADE_LAST_MON: + QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); + sTradeData->tradeMenuFunc = 8; break; - case 2: - case 4: - sub_807A048(3, 6); - sTradeData->unk_6F = 8; + case CANT_TRADE_NATIONAL: + case CANT_TRADE_INVALID_MON: + QueueAction(QUEUE_DELAY_MSG, QUEUE_MON_CANT_BE_TRADED); + sTradeData->tradeMenuFunc = 8; break; - case 3: - case 5: - sub_807A048(3, 7); - sTradeData->unk_6F = 8; + case CANT_TRADE_EGG: + case CANT_TRADE_EGG2: + QueueAction(QUEUE_DELAY_MSG, QUEUE_EGG_CANT_BE_TRADED); + sTradeData->tradeMenuFunc = 8; break; } break; @@ -1545,15 +1534,15 @@ static bool32 sub_8079174(void) switch (CheckValidityOfTradeMons(aliveMons, sTradeData->partyCounts[TRADE_PLAYER], sTradeData->cursorPosition, sTradeData->partnerCursorPosition)) { case PLAYER_MON_INVALID: - sub_807A048(3, 3); + QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); SetLinkData(0xBBCC, 0); break; case PLAYER_MON_VALID: - sub_807A048(3, 1); - SetLinkData(0xBBBB, 0); + QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); + SetLinkData(LINKCMD_INIT_BLOCK, 0); break; case PARTNER_MON_INVALID: - sub_807A048(3, 8); + QueueAction(QUEUE_DELAY_MSG, QUEUE_FRIENDS_MON_CANT_BE_TRADED); return TRUE; } @@ -1567,20 +1556,20 @@ static void sub_8079218(void) case 0: if (!sub_8079174()) { - sTradeData->unk_6F = 100; + sTradeData->tradeMenuFunc = 100; } else { - sTradeData->unk_6F = 17; + sTradeData->tradeMenuFunc = 17; } PutWindowTilemap(17); break; case 1: case MENU_B_PRESSED: - sub_807A048(3, 1); + QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); if (sub_80771BC()) SetLinkData(0xBBCC, 0); - sTradeData->unk_6F = 100; + sTradeData->tradeMenuFunc = 100; PutWindowTilemap(17); break; } @@ -1605,7 +1594,7 @@ static void sub_80792E4(void) PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); SetLinkData(0xEEAA, 0); gSprites[sTradeData->cursorSpriteIdx].invisible = TRUE; - sTradeData->unk_6F = 100; + sTradeData->tradeMenuFunc = 100; sub_807929C(); break; case 1: @@ -1624,7 +1613,7 @@ static void sub_807935C(void) SetSelectedMon(sTradeData->cursorPosition); SetSelectedMon(sTradeData->partnerCursorPosition); } - sTradeData->unk_6F = 7; + sTradeData->tradeMenuFunc = 7; } static void sub_8079398(void) @@ -1632,24 +1621,24 @@ static void sub_8079398(void) if (sTradeData->drawPartyState[TRADE_PLAYER] == 5 && sTradeData->drawPartyState[TRADE_PARTNER] == 5) { - sub_80787B8(); - sTradeData->unk_6F = 14; + PrintAndBufferIsThisTradeOkay(); + sTradeData->tradeMenuFunc = 14; } } static void Wait2SecondsAndCreateYesNoMenu(void) { - sTradeData->unk_A8++; + sTradeData->timer++; - if (sTradeData->unk_A8 > 120) + if (sTradeData->timer > 120) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); - sTradeData->unk_A8 = 0; - sTradeData->unk_6F = 3; + sTradeData->timer = 0; + sTradeData->tradeMenuFunc = 3; } } -static void sub_8079408(void) +static void RedrawTradeMenuAfterPressA(void) { int i; @@ -1665,9 +1654,9 @@ static void sub_8079408(void) rbox_fill_rectangle(i + 14); } - sub_8079F88(TRADE_PLAYER); - sub_8079F88(TRADE_PARTNER); - sTradeData->unk_6F = 0; + RedrawTradeMenuParty(TRADE_PLAYER); + RedrawTradeMenuParty(TRADE_PARTNER); + sTradeData->tradeMenuFunc = 0; gSprites[sTradeData->cursorSpriteIdx].invisible = FALSE; } } @@ -1685,7 +1674,7 @@ static void sub_8079490(void) sub_800ABF4(12); } - sTradeData->unk_6F = 12; + sTradeData->tradeMenuFunc = 12; } } @@ -1693,7 +1682,7 @@ static void sub_80794CC(void) { if (gWirelessCommType) { - if (sub_80771BC() && sub_807A09C() == 0) + if (sub_80771BC() && GetNumQueuedActions() == 0) { Free(sMessageBoxAllocBuffer); Free(sTradeData); @@ -1716,10 +1705,10 @@ static void sub_80794CC(void) static void sub_8079550(void) { - if (!sub_801048C(FALSE) && sub_807A09C() == 0) + if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0) { sub_800ADF8(); - sTradeData->unk_6F = 13; + sTradeData->tradeMenuFunc = 13; } } @@ -1728,14 +1717,14 @@ static void sub_807957C(void) if (gMain.newKeys & A_BUTTON) { SetLinkData(0xBBCC, 0); - sTradeData->unk_6F = 100; + sTradeData->tradeMenuFunc = 100; } } //TODO: static void sub_80795AC(void) { - switch (sTradeData->unk_6F) + switch (sTradeData->tradeMenuFunc) { case 0: TradeMenuProcessInput(); @@ -1759,7 +1748,7 @@ static void sub_80795AC(void) sub_8079398(); break; case 8: - sub_8079408(); + RedrawTradeMenuAfterPressA(); break; case 9: sub_8078130(); @@ -1824,7 +1813,7 @@ static void DrawTradeMenuParty(u8 whichParty) case 1: for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { - gSprites[sTradeData->partyIcons[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; + gSprites[sTradeData->partySpriteIds[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; } for (i = 0; i < 6; i++) @@ -1832,13 +1821,13 @@ static void DrawTradeMenuParty(u8 whichParty) ClearWindowTilemap(i + (whichParty * PARTY_SIZE + 2)); } - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].invisible = FALSE; - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; - StoreSpriteCallbackInData6(&gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], sub_80D3014); + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].invisible = FALSE; + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + StoreSpriteCallbackInData6(&gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], sub_80D3014); sTradeData->drawPartyState[whichParty]++; - TradeMenuBouncePartySprites(&gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); + TradeMenuBouncePartySprites(&gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); @@ -1847,17 +1836,17 @@ static void DrawTradeMenuParty(u8 whichParty) sub_8079F74(); break; case 2: - if (gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == sub_80D3014) + if (gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == sub_80D3014) sTradeData->drawPartyState[whichParty] = 3; break; case 3: CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.x = 0; - gSprites[sTradeData->partyIcons[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.y = 0; - nameStringWidth = sub_8079A3C(nickname, selectedMonParty, partyIdx); + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.x = 0; + gSprites[sTradeData->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); @@ -1878,11 +1867,11 @@ static void DrawTradeMenuParty(u8 whichParty) } } -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); @@ -1957,7 +1946,7 @@ static void PrintPartyNicknamesForTradeMenu(u8 whichParty) 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]; @@ -1984,7 +1973,7 @@ static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 w if (sTradeData->isEgg[whichParty][monIdx]) { - r2 = 0x480; + symbolTile = 0x480; } else { @@ -2002,17 +1991,17 @@ static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 w switch (gender) { case MON_MALE: - r2 = !NameHasGenderSymbol(nickname, MON_MALE) ? 0x84 : 0x83; + symbolTile = !NameHasGenderSymbol(nickname, MON_MALE) ? 0x84 : 0x83; break; case MON_FEMALE: - r2 = !NameHasGenderSymbol(nickname, MON_FEMALE) ? 0x85 : 0x83; + symbolTile = !NameHasGenderSymbol(nickname, MON_FEMALE) ? 0x85 : 0x83; break; default: - r2 = 0x83; + symbolTile = 0x83; break; } } - sTradeData->tilemapBuffer[(y - 1) * 32 + x + 1] = r2; + sTradeData->tilemapBuffer[(y - 1) * 32 + x + 1] = symbolTile; } // Very close but loop preamble not working. @@ -2024,10 +2013,10 @@ static void sub_8079E44(u8 whichParty) for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { DrawTradeMenuPartyMonInfo(whichParty, i, - gTradeLevelDisplayCoords[whichParty][i][0], - gTradeLevelDisplayCoords[whichParty][i][1], - gTradeMonBoxCoords[whichParty][i][0], - gTradeMonBoxCoords[whichParty][i][1]); + sTradeMonCoords[whichParty][i][0] + 4, + sTradeMonCoords[whichParty][i][1] - 1, + sTradeMonBoxDimensions[whichParty][i][0], + sTradeMonBoxDimensions[whichParty][i][1]); } } #else @@ -2048,10 +2037,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, =sTradeMonCoords\n\ lsls r0, 2\n\ adds r5, r0, r1\n\ - ldr r1, =gTradeMonBoxCoords\n\ + ldr r1, =sTradeMonBoxDimensions\n\ adds r4, r0, r1\n\ _08079E6A:\n\ lsls r1, r7, 24\n\ @@ -2083,17 +2072,17 @@ _08079E94:\n\ } #endif // NONMATCHING -static void InitTradeMenuPartyPositions(u8 whichParty) +static void ResetTradeMenuPartyPositions(u8 whichParty) { int i; for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) { - gSprites[sTradeData->partyIcons[whichParty][i]].invisible = FALSE; - gSprites[sTradeData->partyIcons[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; - gSprites[sTradeData->partyIcons[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; - gSprites[sTradeData->partyIcons[whichParty][i]].pos2.x = 0; - gSprites[sTradeData->partyIcons[whichParty][i]].pos2.y = 0; + gSprites[sTradeData->partySpriteIds[whichParty][i]].invisible = FALSE; + gSprites[sTradeData->partySpriteIds[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; + gSprites[sTradeData->partySpriteIds[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; + gSprites[sTradeData->partySpriteIds[whichParty][i]].pos2.x = 0; + gSprites[sTradeData->partySpriteIds[whichParty][i]].pos2.y = 0; } } @@ -2103,14 +2092,14 @@ static void sub_8079F74(void) PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); } -static void sub_8079F88(u8 whichParty) +static void RedrawTradeMenuParty(u8 whichParty) { CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); sub_8079E44(whichParty); PrintPartyNicknamesForTradeMenu(whichParty); - InitTradeMenuPartyPositions(whichParty); - sub_807A308(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); + ResetTradeMenuPartyPositions(whichParty); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); sTradeData->drawPartyState[whichParty] = 0; } @@ -2126,77 +2115,76 @@ static void sub_807A024(u8 taskId) CopyBgTilemapBufferToVram(0); } -//TODO: a1 here is the case var for the switch in sub_807A0C4 -static void sub_807A048(u16 a0, u8 validity) +static void QueueAction(u16 delay, u8 actionId) { int i; - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeData->queuedActions); i++) { - if (sTradeData->unk_8D0[i].unk_0 == FALSE) + if (!sTradeData->queuedActions[i].queued) { - sTradeData->unk_8D0[i].unk_2 = a0; //TODO: always 3 or 5 - sTradeData->unk_8D0[i].monValidity = validity; - sTradeData->unk_8D0[i].unk_0 = TRUE; + sTradeData->queuedActions[i].queueDelay = delay; + sTradeData->queuedActions[i].actionId = actionId; + sTradeData->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(sTradeData->queuedActions); i++) { - acc += sTradeData->unk_8D0[i].unk_0; + numActions += sTradeData->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(sTradeData->queuedActions); i++) { - if (sTradeData->unk_8D0[i].unk_0) + if (sTradeData->queuedActions[i].queued) { - if (sTradeData->unk_8D0[i].unk_2) + if (sTradeData->queuedActions[i].queueDelay) { - sTradeData->unk_8D0[i].unk_2--; + sTradeData->queuedActions[i].queueDelay--; } else { - switch (sTradeData->unk_8D0[i].monValidity) + switch (sTradeData->queuedActions[i].actionId) { - case 0: + case QUEUE_SEND_DATA: SendLinkData(sTradeData->linkData, 20); break; - case 1: + case QUEUE_STANDBY: PrintTradeMessage(TRADE_MSG_STANDBY); break; - case 2: + case QUEUE_ONLY_MON1: PrintTradeMessage(TRADE_MSG_ONLY_MON1); break; - case 3: - case 4: - case 5: + case QUEUE_ONLY_MON2: + case QUEUE_UNUSED1: + case QUEUE_UNUSED2: PrintTradeMessage(TRADE_MSG_ONLY_MON2); break; - case 6: + case QUEUE_MON_CANT_BE_TRADED: PrintTradeMessage(TRADE_MSG_MON_CANT_BE_TRADED); break; - case 7: + case QUEUE_EGG_CANT_BE_TRADED: PrintTradeMessage(TRADE_MSG_EGG_CANT_BE_TRADED); break; - case 8: + case QUEUE_FRIENDS_MON_CANT_BE_TRADED: PrintTradeMessage(TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED); break; } - sTradeData->unk_8D0[i].unk_0 = FALSE; + sTradeData->queuedActions[i].queued = FALSE; } } } @@ -2211,57 +2199,57 @@ static void PrintTradeMessage(u8 messageId) CopyWindowToVram(0, 3); } -static bool8 sub_807A1F0(void) +static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) { struct SpriteSheet sheet; - if (sTradeData->unk_A8 < (int)ARRAY_COUNT(sMessageBoxTileBuffers)) + if (sTradeData->timer < (int)ARRAY_COUNT(sMessageBoxTileBuffers)) { - sheet.data = sMessageBoxTileBuffers[sTradeData->unk_A8]; + sheet.data = sMessageBoxTileBuffers[sTradeData->timer]; sheet.size = 0x100; - sheet.tag = 200 + sTradeData->unk_A8; + sheet.tag = 200 + sTradeData->timer; } - switch (sTradeData->unk_A8) + switch (sTradeData->timer) { case 0 ... 7: LoadSpriteSheet(&sheet); - sTradeData->unk_A8++; + sTradeData->timer++; break; case 8: sTradeData->unk_72 = LoadSpriteSheet(&sheet); - sTradeData->unk_A8++; + sTradeData->timer++; break; case 9 ... 13: LoadSpriteSheet(&sheet); - sTradeData->unk_A8++; + sTradeData->timer++; break; case 14: LoadSpritePalette(&gSpritePalette_TradeScreenText); - sTradeData->unk_A8++; + sTradeData->timer++; break; case 15: LoadSpritePalette(&gUnknown_0832DC44); - sTradeData->unk_A8++; + sTradeData->timer++; break; case 16: LoadSpriteSheet(&sTradeButtonsSpriteSheet); - sTradeData->unk_A8++; + sTradeData->timer++; break; case 17: - sTradeData->unk_A8 = 0; + sTradeData->timer = 0; return TRUE; } return FALSE; } -static void sub_807A308(const u8 *str, u8 *dest, u8 unused) +static void DrawTextWindowAndBuffer6Bytes(const u8 *str, u8 *dest, u8 unused) { - sub_80C6D80(str, dest, 0, 0, 6); + DrawTextWindowAndBufferTiles(str, dest, 0, 0, 6); } -static void sub_807A320(u8 whichParty) +static void SetTradePartyLiveStatuses(u8 whichParty) { int i; @@ -2343,7 +2331,7 @@ static void SetTradePartyHPBarSprites(void) { for (j = 0; j < sTradeData->partyCounts[i]; j++) { - SetPartyHPBarSprite(&gSprites[sTradeData->partyIcons[i][j]], 4 - sTradeData->hpBarLevels[i][j]); + SetPartyHPBarSprite(&gSprites[sTradeData->partySpriteIds[i][j]], 4 - sTradeData->hpBarLevels[i][j]); } } } @@ -2352,20 +2340,20 @@ static void sub_807A5B0(void) { int i; - for (i = 0; i < 11; i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeData->giftRibbons); i++) { - if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeData->unk_A9[i] != 0) + if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeData->giftRibbons[i] != 0) { - if (sTradeData->unk_A9[i] < 64) - gSaveBlock1Ptr->giftRibbons[i] = sTradeData->unk_A9[i]; + if (sTradeData->giftRibbons[i] < 64) + gSaveBlock1Ptr->giftRibbons[i] = sTradeData->giftRibbons[i]; } } } //TODO: -static u32 sub_807A5F4(struct Pokemon *playerParty, int partyCount, int monIdx) +static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int monIdx) { - int i, sum; + int i, numAliveMons; struct LinkPlayer *player; u32 species[PARTY_SIZE]; u32 species2[PARTY_SIZE]; @@ -2376,17 +2364,14 @@ static u32 sub_807A5F4(struct Pokemon *playerParty, int partyCount, int monIdx) 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]; @@ -2396,49 +2381,36 @@ static u32 sub_807A5F4(struct Pokemon *playerParty, int partyCount, int monIdx) if ((player->name[10] & 0xF) == 0) { 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(&playerParty[monIdx], MON_DATA_OBEDIENCE)) - { - return 4; - } + return CANT_TRADE_INVALID_MON; } for (i = 0; i < partyCount; i++) { if (species2[i] == SPECIES_EGG) - { species2[i] = SPECIES_NONE; - } } - for (sum = 0, i = 0; i < partyCount; i++) + // Count alive mons in party, excluding selected trade mon + for (numAliveMons = 0, i = 0; i < partyCount; i++) { if (i != monIdx) - { - sum += species2[i]; - } + numAliveMons += species2[i]; } - if (sum != 0) - { - return 0; - } + if (numAliveMons != 0) + return CAN_TRADE_MON; else - { - return 1; - } + return CANT_TRADE_LAST_MON; } // Return values are used to determine exchange status in GetLinkPlayerDataExchangeStatusTimed @@ -3140,7 +3112,7 @@ 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)); @@ -3151,7 +3123,7 @@ static void InitTradeBgInternal(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); @@ -3520,13 +3492,9 @@ static void SetTradeSceneStrings(void) static bool8 AnimateTradeSequence(void) { if (sTradeWindowData->isCableTrade) - { return AnimateTradeSequenceCable(); - } else - { return AnimateTradeSequenceWireless(); - } } static bool8 AnimateTradeSequenceCable(void) @@ -5013,7 +4981,7 @@ static void CheckPartnersMonForRibbons(void) { u8 i; u8 numRibbons = 0; - for (i = 0; i < 12; i ++) //TODO: MON_DATA_GIFT_RIBBON_7 - (MON_DATA_CHAMPION_RIBBON - 1) + for (i = 0; i < 12; i ++) { numRibbons += GetMonData(&gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE], MON_DATA_CHAMPION_RIBBON + i); } From 2c062dc76478c5e6ce126310ece41355d4156c42 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 9 Oct 2019 05:56:44 -0400 Subject: [PATCH 08/11] More trade documentation --- .../menu_mon_box.bin} | Bin .../{unknown => trade}/unknown_DDB444.pal | 0 .../{unknown => trade}/unknown_DDCF04.bin | Bin include/constants/trade.h | 46 +- include/graphics.h | 2 +- include/link.h | 54 +- include/link_rfu.h | 2 +- include/pokeball.h | 2 +- include/pokemon_icon.h | 2 +- include/trade.h | 2 +- src/battle_main.c | 2 +- src/cable_club.c | 2 +- src/data/trade.h | 47 +- src/graphics.c | 6 +- src/link.c | 14 +- src/link_rfu.c | 2 +- src/party_menu.c | 2 +- src/pokeball.c | 2 +- src/pokemon_icon.c | 2 +- src/trade.c | 2044 ++++++++--------- src/union_room.c | 8 +- 21 files changed, 1132 insertions(+), 1109 deletions(-) rename graphics/{unknown/unknown_DDD704.bin => trade/menu_mon_box.bin} (100%) rename graphics/{unknown => trade}/unknown_DDB444.pal (100%) rename graphics/{unknown => trade}/unknown_DDCF04.bin (100%) 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/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/constants/trade.h b/include/constants/trade.h index f03ced677..7f61c88e8 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -4,6 +4,8 @@ #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 @@ -15,8 +17,8 @@ #define PARTNER_MON_INVALID 2 // Flag IDs for sending link data -#define CHOSE_VALID_MON 1 -#define CHOSE_INVALID_MON 2 +#define INITIATE_TRADE 1 +#define CANCEL_TRADE 2 #define WANTS_TO_TRADE 1 #define WANTS_TO_CANCEL 2 @@ -29,15 +31,20 @@ #define CANT_TRADE_EGG2 5 // Indexes for sTradeActionTexts -#define TRADE_ACTION_TEXT_CANCEL 0 -#define TRADE_ACTION_TEXT_CHOOSE_MON 1 -#define TRADE_ACTION_TEXT_SUMMARY 2 -#define TRADE_ACTION_TEXT_TRADE 3 -#define TRADE_ACTION_TEXT_CANCEL_TRADE 4 -#define TRADE_ACTION_TEXT_JP_QUIT 5 +#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 #define MENU_ACTION_SUMMARY 0 #define MENU_ACTION_TRADE 1 +#define MENU_ACTION_CONFIRM_TRADE 0 +#define MENU_ACTION_CANCEL_TRADE 1 + +#define DRAW_PARTY_BEGIN 1 +#define DRAW_PARTY_FINISH 5 // Message indexes for sTradeMessages #define TRADE_MSG_STANDBY 0 @@ -65,6 +72,27 @@ #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 @@ -82,7 +110,5 @@ #define CANT_REGISTER_MON 1 #define CANT_REGISTER_EGG 2 -#define LINK_TRADE_TIMEOUT 300 - #endif //GUARD_CONSTANTS_TRADE_H diff --git a/include/graphics.h b/include/graphics.h index 967af3d6a..a08d3760f 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4853,7 +4853,7 @@ 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 u16 gTradeMenuMonBox_Tilemap[]; extern const u8 gTradeButtons_Gfx[]; extern const u16 gUnknown_08DDB444[]; diff --git a/include/link.h b/include/link.h index 4d6e4593c..c4033d05a 100644 --- a/include/link.h +++ b/include/link.h @@ -48,31 +48,30 @@ #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_0xAABB 0xAABB // used in trade -#define LINKCMD_INIT_BLOCK 0xBBBB -#define LINKCMD_0xBBCC 0xBBCC // used in trade -#define LINKCMD_SEND_HELD_KEYS_2 0xCAFE -#define LINKCMD_0xCCCC 0xCCCC -#define LINKCMD_0xCCDD 0xCCDD // all below linkcmds used in trade -#define LINKCMD_0xDDDD 0xDDDD -#define LINKCMD_0xDDEE 0xDDEE -#define LINKCMD_0xEEAA 0xEEAA -#define LINKCMD_0xEEBB 0xEEBB -#define LINKCMD_0xEECC 0xEECC - -#define LINKCMD_0xABCD 0xABCD -#define LINKCMD_0xDCBA 0xDCBA +#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 // used in trade +#define LINKCMD_0xABCD 0xABCD // used in trade +#define LINKCMD_INIT_BLOCK 0xBBBB +#define LINKCMD_SET_CANCEL_TRADE 0xBBCC // used in trade +#define LINKCMD_SEND_HELD_KEYS_2 0xCAFE +#define LINKCMD_0xCCCC 0xCCCC +#define LINKCMD_START_TRADE 0xCCDD // all below linkcmds used in trade +#define LINKCMD_0xDCBA 0xDCBA +#define LINKCMD_SET_MONS_TO_TRADE 0xDDDD +#define LINKCMD_0xDDEE 0xDDEE +#define LINKCMD_REQUEST_CANCEL 0xEEAA +#define LINKCMD_0xEEBB 0xEEBB +#define LINKCMD_PARTNER_WANTS_TRADE 0xEECC struct LinkStatus @@ -132,7 +131,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 hasClearedGame, 0xF0 is hasNationalDex + /* 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 3284aba88..533e515c5 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -228,7 +228,7 @@ 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/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 efc0028a1..5018de37c 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -21,7 +21,7 @@ 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 UpdateTradeMonIconFrame(struct Sprite *sprite); void SetPartyHPBarSprite(struct Sprite *sprite, u8 animNum); u8 GetMonIconPaletteIndexFromSpecies(u16 species); diff --git a/include/trade.h b/include/trade.h index 9d48f6b23..a0385297e 100644 --- a/include/trade.h +++ b/include/trade.h @@ -14,7 +14,7 @@ extern u8 gSelectedTradeMonPositions[2]; extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; s32 sub_807A728(void); -void sub_80773AC(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); 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 0615b37bd..22fc2d0c1 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -1093,7 +1093,7 @@ static void sub_80B37FC(u8 taskId) case 3: if (!gReceivedRemoteLinkPlayers) { - SetMainCallback2(sub_80773AC); + SetMainCallback2(CB2_StartCreateTradeMenu); DestroyTask(taskId); } break; diff --git a/src/data/trade.h b/src/data/trade.h index 1d6cfd441..81b1e565a 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -168,13 +168,16 @@ static const struct SpritePalette gSpritePalette_TradeScreenText = // 2 3 8 9 // 4 5 10 11 // 12 -static const u8 gTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][6] = +// 1st array is current position ids +// 2nd array is directions of input +// 3rd array is the next position ids to go to, stopping at the first occupied position +static const u8 sTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][PARTY_SIZE] = { { - {4, 2, 12, 12, 0, 0}, - {2, 4, 12, 12, 0, 0}, - {7, 6, 1, 0, 0, 0}, - {1, 6, 7, 0, 0, 0} + {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}, @@ -339,12 +342,12 @@ static const u8 sUnref_0832DE6E[] = static const u8 *const sTradeActionTexts[] = { - [TRADE_ACTION_TEXT_CANCEL] = sText_Cancel, - [TRADE_ACTION_TEXT_CHOOSE_MON] = sText_ChooseAPkmn, - [TRADE_ACTION_TEXT_SUMMARY] = sText_Summary, - [TRADE_ACTION_TEXT_TRADE] = sText_Trade, - [TRADE_ACTION_TEXT_CANCEL_TRADE] = sText_CancelTrade, - [TRADE_ACTION_TEXT_JP_QUIT] = sJPText_PressBButtonToQuit + [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[] = @@ -626,7 +629,7 @@ 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 gOamData_8338C44 = +static const struct OamData sTradeOamData_16x16 = { .affineMode = 1, .shape = SPRITE_SHAPE(16x16), @@ -721,14 +724,14 @@ static const struct SpriteTemplate gSpriteTemplate_8338D28 = { .tileTag = 5557, .paletteTag = 5558, - .oam = &gOamData_8338C44, + .oam = &sTradeOamData_16x16, .anims = gSpriteAnimTable_8338C88, .images = NULL, .affineAnims = gSpriteAffineAnimTable_8338D0C, .callback = sub_807E55C }; -static const struct OamData gOamData_8338D40 = +static const struct OamData sTradeOamData_32x32 = { .affineMode = 1, .objMode = 1, @@ -783,14 +786,14 @@ static const struct SpriteTemplate gUnknown_08338D88 = { .tileTag = 5550, .paletteTag = 5551, - .oam = &gOamData_8338D40, + .oam = &sTradeOamData_32x32, .anims = gSpriteAnimTable_8338D50, .images = NULL, .affineAnims = gSpriteAffineAnimTable_8338D6C, .callback = sub_807AA28 }; -static const struct OamData gOamData_8338DA0 = +static const struct OamData sTradeOamData_16x32 = { .shape = SPRITE_SHAPE(16x32), .size = SPRITE_SIZE(16x32), @@ -826,14 +829,14 @@ static const struct SpriteTemplate gSpriteTemplate_8338DC8 = { .tileTag = 5552, .paletteTag = 5551, - .oam = &gOamData_8338DA0, + .oam = &sTradeOamData_16x32, .anims = gSpriteAnimTable_8338DB8, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_807AA7C }; -static const struct OamData gOamData_8338DE0 = +static const struct OamData sTradeOamData_16x32_2 = { .shape = SPRITE_SHAPE(16x32), .size = SPRITE_SIZE(16x32), @@ -862,14 +865,14 @@ static const struct SpriteTemplate gSpriteTemplate_8338DFC = { .tileTag = 5554, .paletteTag = 5555, - .oam = &gOamData_8338DE0, + .oam = &sTradeOamData_16x32_2, .anims = gSpriteAnimTable_8338DF0, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_807AABC }; -static const struct OamData gOamData_8338E14 = +static const struct OamData sTradeOamData_64x32_2 = { .shape = SPRITE_SHAPE(64x32), .size = SPRITE_SIZE(64x32), @@ -923,7 +926,7 @@ static const struct SpriteTemplate gSpriteTemplate_8338E74 = { .tileTag = 5556, .paletteTag = 5555, - .oam = &gOamData_8338E14, + .oam = &sTradeOamData_64x32_2, .anims = gSpriteAnimTable_8338E64, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, @@ -934,7 +937,7 @@ static const struct SpriteTemplate gSpriteTemplate_8338E8C = { .tileTag = 5556, .paletteTag = 5555, - .oam = &gOamData_8338E14, + .oam = &sTradeOamData_64x32_2, .anims = gSpriteAnimTable_8338E68, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, diff --git a/src/graphics.c b/src/graphics.c index 99d9a22d9..5f27cdea4 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1518,12 +1518,12 @@ asm(".space 0x20"); //blank palette?? // Trade const u16 gTradeMenu_Pal[] = INCBIN_U16("graphics/trade/menu.gbapal"); -const u16 gUnknown_08DDB444[] = INCBIN_U16("graphics/unknown/unknown_DDB444.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 45bf82580..9e35ad5c5 100644 --- a/src/link.c +++ b/src/link.c @@ -316,10 +316,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 +597,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 @@ -1084,7 +1084,7 @@ bool8 IsLinkTaskFinished(void) { if (gWirelessCommType == TRUE) { - return sub_8010500(); + return IsLinkRfuTaskFinished(); } return gLinkCallback == NULL; } @@ -1909,7 +1909,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 2f47669c4..71eb0e58d 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -3800,7 +3800,7 @@ u8 sub_80104F4(void) return gUnknown_03005000.playerCount; } -bool8 sub_8010500(void) +bool8 IsLinkRfuTaskFinished(void) { if (gUnknown_03005000.unk_f1 == 2) return FALSE; diff --git a/src/party_menu.c b/src/party_menu.c index be2e0a34c..94b9de68d 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4974,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; } } 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 ef1377a72..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); } diff --git a/src/trade.c b/src/trade.c index 5294ee2e2..4dae1143b 100644 --- a/src/trade.c +++ b/src/trade.c @@ -90,13 +90,13 @@ static EWRAM_DATA struct { /*0x0035*/ u8 cursorPosition; /*0x0036*/ u8 partyCounts[2]; /*0x0038*/ bool8 monPresent[PARTY_SIZE * 2]; - /*0x0044*/ u8 neverRead_44; + /*0x0044*/ bool8 neverRead_44; /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; /*0x0069*/ u8 unk_69; //state var for shedinja_maker_maybe /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; - /*0x006F*/ u8 tradeMenuFunc; //switch var for sub_80795AC + /*0x006F*/ u8 tradeMenuFunc; //switch var for CallTradeMenuFunc /*0x0070*/ u8 neverRead_70; /*0x0071*/ u8 filler_71; /*0x0072*/ u16 unk_72; //sheet @@ -104,8 +104,8 @@ static EWRAM_DATA struct { /*0x0076*/ u8 selectedMonIdx[2]; /*0x0078*/ u8 playerLinkFlagChoseAction; /*0x0079*/ u8 partnerLinkFlagChoseAction; - /*0x007A*/ u8 playerLinkFlagChoseMon; - /*0x007B*/ u8 partnerLinkFlagChoseMon; + /*0x007A*/ u8 playerLinkFlagStatus; + /*0x007B*/ u8 partnerLinkFlagStatus; /*0x007C*/ u8 filler_7C[0x7E - 0x7C]; /*0x007E*/ u8 partnerCursorPosition; /*0x007F*/ u8 unused_7F; @@ -119,7 +119,7 @@ static EWRAM_DATA struct { u8 actionId; } queuedActions[4]; /*0x08F0*/ u16 tilemapBuffer[0x400]; -} *sTradeData = {NULL}; +} *sTradeMenuData = {NULL}; static EWRAM_DATA struct { /*0x00*/ struct Pokemon mon; /*0x64*/ u32 timer; @@ -139,7 +139,7 @@ static EWRAM_DATA struct { /*0x93*/ u8 unk_93; /*0x94*/ u16 state; /*0x96*/ u8 filler_96[0xD2 - 0x96]; - /*0xD2*/ u8 unk_D2; //sprite id + /*0xD2*/ u8 pokeballSpriteId; /*0xD3*/ u8 unk_D3; //sprite id /*0xD4*/ u16 texX; /*0xD6*/ u16 texY; @@ -164,27 +164,27 @@ static EWRAM_DATA struct { /*0xFC*/ u8 unk_FC; /*0xFD*/ u8 unk_FD; /*0xFE*/ u8 unk_FE; -} *sTradeWindowData = {NULL}; +} *sTradeData = {NULL}; #if !defined(NONMATCHING) && MODERN #define static #endif static bool32 IsWirelessTrade(void); -static void sub_80773D0(void); -static void sub_807811C(void); +static void CB2_CreateTradeMenu(void); +static void VBlankCB_TradeMenu(void); static void CB2_TradeMenu(void); -static void sub_80782B8(u8); +static void LoadTradeBgGfx(u8); static void SetTradePartyMonsVisible(void); static bool8 shedinja_maker_maybe(void); -static void sub_8078C34(void); -static void sub_80795AC(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 sub_8079E44(u8); +static void DrawTradeMenuPartyInfo(u8); static void sub_8079F74(void); static void RedrawTradeMenuParty(u8); static void sub_807A000(u8 taskId); @@ -198,7 +198,7 @@ static void DrawTextWindowAndBuffer6Bytes(const u8 *, u8 *, u8); static void SetTradePartyLiveStatuses(u8); static void GetTradePartyHPBarLevels(u8); static void SetTradePartyHPBarSprites(void); -static void sub_807A5B0(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); @@ -245,16 +245,16 @@ static bool8 SendLinkData(const void *linkData, u32 size) } } -static void sub_80771AC(u8 a0) +static void sub_80771AC(u8 a0) // SKP { sub_800A4D8(a0); } -static bool32 sub_80771BC(void) +static bool32 sub_80771BC(void) // SKP { if (gUnknown_02022C2C == 29) { - if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) + if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) // SKP return TRUE; else return FALSE; @@ -294,9 +294,9 @@ static bool32 IsWirelessTrade(void) return FALSE; } -static void sub_8077288(u8 unused) +static void sub_8077288(u8 unused) // SKP { - sub_800ADF8(); + sub_800ADF8(); // SKP } static bool32 _IsLinkTaskFinished(void) @@ -313,12 +313,12 @@ static void InitTradeMenu(void) gPaletteFade.bufferTransferDisabled = TRUE; - SetVBlankCallback(sub_807811C); - LoadPalette(gUnknown_0860F074, 0xF0, 20); - LoadPalette(gUnknown_0860F074, 0xD0, 20); + SetVBlankCallback(VBlankCB_TradeMenu); + LoadPalette(gUnknown_0860F074, 0xF0, 20); // SKP, some interface gfx + LoadPalette(gUnknown_0860F074, 0xD0, 20); // SKP, some interface gfx ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sTradeMenuBgTemplates, ARRAY_COUNT(sTradeMenuBgTemplates)); - SetBgTilemapBuffer(1, sTradeData->tilemapBuffer); + SetBgTilemapBuffer(1, sTradeMenuData->tilemapBuffer); if (InitWindows(sTradeMenuWindowTemplates)) { @@ -336,25 +336,25 @@ static void InitTradeMenu(void) LoadUserWindowBorderGfx_(0, 20, 0xC0); LoadUserWindowBorderGfx(2, 1, 0xE0); LoadMonIconPalettes(); - sTradeData->unk_69 = 0; - sTradeData->tradeMenuFunc = 0; - sTradeData->neverRead_70 = 0; - sTradeData->drawPartyState[TRADE_PLAYER] = 0; - sTradeData->drawPartyState[TRADE_PARTNER] = 0; - sTradeData->playerLinkFlagChoseMon = 0; - sTradeData->partnerLinkFlagChoseMon = 0; - sTradeData->timer = 0; + sTradeMenuData->unk_69 = 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; @@ -364,7 +364,7 @@ static void sub_80773D0(void) switch (gMain.state) { case 0: - sTradeData = AllocZeroed(sizeof(*sTradeData)); + sTradeMenuData = AllocZeroed(sizeof(*sTradeMenuData)); InitTradeMenu(); sMessageBoxAllocBuffer = AllocZeroed(14 * 256); @@ -389,13 +389,13 @@ static void sub_80773D0(void) if (!gReceivedRemoteLinkPlayers) { gLinkType = 0x1122; - sTradeData->timer = 0; + sTradeMenuData->timer = 0; if (gWirelessCommType) { - sub_800B488(); + sub_800B488(); // SKP OpenLink(); - sub_8011BA4(); + sub_8011BA4(); // SKP } else { @@ -410,10 +410,10 @@ static void sub_80773D0(void) } break; case 2: - sTradeData->timer++; - if (sTradeData->timer > 11) + sTradeMenuData->timer++; + if (sTradeMenuData->timer > 11) { - sTradeData->timer = 0; + sTradeMenuData->timer = 0; gMain.state++; } break; @@ -422,7 +422,7 @@ static void sub_80773D0(void) { if (IsLinkMaster()) { - if (++sTradeData->timer > 30) + if (++sTradeMenuData->timer > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -437,21 +437,21 @@ static void sub_80773D0(void) case 4: if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) { - sub_8011BD0(); + sub_8011BD0(); // SKP CalculatePlayerPartyCount(); gMain.state++; - sTradeData->timer = 0; + sTradeMenuData->timer = 0; if (gWirelessCommType) { - sub_801048C(TRUE); - sub_800ADF8(); + sub_801048C(TRUE); // SKP + sub_800ADF8(); // SKP } } break; case 5: if (gWirelessCommType) { - if (sub_8010500()) + if (IsLinkRfuTaskFinished()) { gMain.state++; LoadWirelessStatusIndicatorSpriteGfx(); @@ -466,7 +466,7 @@ static void sub_80773D0(void) case 6: if (shedinja_maker_maybe()) { - sub_807A5B0(); + SaveTradeGiftRibbons(); gMain.state++; } break; @@ -474,14 +474,14 @@ static void sub_80773D0(void) CalculateEnemyPartyCount(); SetGpuReg(REG_OFFSET_DISPCNT, 0); SetGpuReg(REG_OFFSET_BLDCNT, 0); - sTradeData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; - sTradeData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; + sTradeMenuData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; + sTradeMenuData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; - for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), - sub_80D3014, + sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + UpdateTradeMonIconFrame, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, 1, @@ -489,11 +489,11 @@ static void sub_80773D0(void) TRUE); } - for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - sub_80D3014, + sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + UpdateTradeMonIconFrame, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, @@ -504,21 +504,21 @@ static void sub_80773D0(void) break; case 8: LoadHeldItemIcons(); - DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); gMain.state++; break; case 9: - DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); gMain.state++; break; case 10: DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); - DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); + DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; - sTradeData->timer = 0; + sTradeMenuData->timer = 0; break; case 11: if (LoadTradeMenuSpriteSheetsAndPalettes()) @@ -557,16 +557,16 @@ static void sub_80773D0(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - sTradeData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); - sTradeData->cursorPosition = 0; + sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); + sTradeMenuData->cursorPosition = 0; gMain.state++; rbox_fill_rectangle(0); break; case 14: SetTradePartyLiveStatuses(TRADE_PLAYER); PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); - sTradeData->bg2hofs = 0; - sTradeData->bg3hofs = 0; + sTradeMenuData->bg2hofs = 0; + sTradeMenuData->bg3hofs = 0; SetTradePartyMonsVisible(); gMain.state++; PlayBGM(MUS_P_SCHOOL); @@ -577,11 +577,11 @@ static void sub_80773D0(void) 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: @@ -590,7 +590,7 @@ 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: @@ -605,7 +605,7 @@ static void sub_80773D0(void) case 22: if (!gPaletteFade.active) { - gMain.callback1 = sub_8078C34; + gMain.callback1 = CB1_SendOrReactToLinkTradeData; SetMainCallback2(CB2_TradeMenu); } break; @@ -618,7 +618,7 @@ static void sub_80773D0(void) UpdatePaletteFade(); } -static void sub_8077B74(void) +static void CB2_ReturnToTradeMenu(void) { int i; struct SpriteTemplate temp; @@ -633,7 +633,7 @@ static void sub_8077B74(void) break; case 1: gMain.state++; - sTradeData->timer = 0; + sTradeMenuData->timer = 0; break; case 2: gMain.state++; @@ -658,17 +658,17 @@ static void sub_8077B74(void) break; case 7: CalculateEnemyPartyCount(); - sTradeData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; - sTradeData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; + sTradeMenuData->partyCounts[TRADE_PLAYER] = gPlayerPartyCount; + sTradeMenuData->partyCounts[TRADE_PARTNER] = gEnemyPartyCount; ClearWindowTilemap(0); PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); - for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - sub_80D3014, + sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + UpdateTradeMonIconFrame, (gTradeMonSpriteCoords[i][0] * 8) + 14, (gTradeMonSpriteCoords[i][1] * 8) - 12, 1, @@ -676,11 +676,11 @@ static void sub_8077B74(void) TRUE); } - for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), - sub_80D3014, + sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + UpdateTradeMonIconFrame, (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, @@ -691,21 +691,21 @@ static void sub_8077B74(void) break; case 8: LoadHeldItemIcons(); - DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); gMain.state++; break; case 9: - DrawHeldItemIconsForTrade(&sTradeData->partyCounts[TRADE_PLAYER], sTradeData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); gMain.state++; break; case 10: DrawTextWindowAndBufferTiles(gSaveBlock2Ptr->playerName, sMessageBoxTileBuffers[0], 0, 0, 3); id = GetMultiplayerId(); DrawTextWindowAndBufferTiles(gLinkPlayers[id ^ 1].name, sMessageBoxTileBuffers[3], 0, 0, 3); - DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); + DrawTextWindowAndBufferTiles(sTradeActionTexts[TRADE_TEXT_CANCEL], sMessageBoxTileBuffers[6], 0, 0, 2); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], sMessageBoxTileBuffers[8], 24); gMain.state++; - sTradeData->timer = 0; + sTradeMenuData->timer = 0; break; case 11: if (LoadTradeMenuSpriteSheetsAndPalettes()) @@ -744,22 +744,22 @@ static void sub_8077B74(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - if (sTradeData->cursorPosition < PARTY_SIZE) - sTradeData->cursorPosition = gLastViewedMonIndex; + if (sTradeMenuData->cursorPosition < PARTY_SIZE) + sTradeMenuData->cursorPosition = gLastViewedMonIndex; else - sTradeData->cursorPosition = gLastViewedMonIndex + PARTY_SIZE; + sTradeMenuData->cursorPosition = gLastViewedMonIndex + PARTY_SIZE; - sTradeData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[sTradeData->cursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[sTradeData->cursorPosition][1] * 8, 2); + sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][1] * 8, 2); gMain.state = 16; break; case 16: - sub_80782B8(0); + LoadTradeBgGfx(0); gMain.state++; break; case 17: - sub_80782B8(1); - sTradeData->bg2hofs = 0; - sTradeData->bg3hofs = 0; + LoadTradeBgGfx(1); + sTradeMenuData->bg2hofs = 0; + sTradeMenuData->bg3hofs = 0; SetTradePartyMonsVisible(); gMain.state++; break; @@ -771,7 +771,7 @@ 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: @@ -795,53 +795,53 @@ 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 (++sTradeData->timer > 15) + if (++sTradeMenuData->timer > 15) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->tradeMenuFunc = 10; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE; } } -static void sub_807816C(void) +static void LinkTradeWaitForFade(void) { if (!gPaletteFade.active) { - gSelectedTradeMonPositions[TRADE_PLAYER] = sTradeData->cursorPosition; - gSelectedTradeMonPositions[TRADE_PARTNER] = sTradeData->partnerCursorPosition; + gSelectedTradeMonPositions[TRADE_PLAYER] = sTradeMenuData->cursorPosition; + gSelectedTradeMonPositions[TRADE_PARTNER] = sTradeMenuData->partnerCursorPosition; if (gWirelessCommType) { - sTradeData->tradeMenuFunc = 16; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_QUEUE; } else { - sub_800ABF4(32); - sTradeData->tradeMenuFunc = 13; + sub_800ABF4(32); // SKP + 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(sMessageBoxAllocBuffer); FreeAllWindowBuffers(); - Free(sTradeData); + Free(sTradeMenuData); gMain.callback1 = NULL; DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(CB2_LinkTrade); @@ -854,7 +854,7 @@ static void sub_80781C8(void) { Free(sMessageBoxAllocBuffer); FreeAllWindowBuffers(); - Free(sTradeData); + Free(sTradeMenuData); gMain.callback1 = NULL; SetMainCallback2(CB2_LinkTrade); } @@ -863,13 +863,13 @@ static void sub_80781C8(void) static void CB2_TradeMenu(void) { - sub_80795AC(); //func switch + CallTradeMenuFunc(); DoQueuedActions(); DrawTradeMenuParty(TRADE_PLAYER); DrawTradeMenuParty(TRADE_PARTNER); - SetGpuReg(REG_OFFSET_BG2HOFS, sTradeData->bg2hofs++); - SetGpuReg(REG_OFFSET_BG3HOFS, sTradeData->bg3hofs--); + SetGpuReg(REG_OFFSET_BG2HOFS, sTradeMenuData->bg2hofs++); + SetGpuReg(REG_OFFSET_BG3HOFS, sTradeMenuData->bg3hofs--); RunTextPrintersAndIsPrinter0Active(); RunTasks(); @@ -878,7 +878,7 @@ static void CB2_TradeMenu(void) UpdatePaletteFade(); } -static void sub_80782B8(u8 state) +static void LoadTradeBgGfx(u8 state) { int i; @@ -892,8 +892,8 @@ static void sub_80782B8(u8 state) break; case 1: LoadBgTilemap(3, gTradeStripesBG3Tilemap, 0x800, 0); - sub_8079E44(TRADE_PLAYER); - sub_8079E44(TRADE_PARTNER); + DrawTradeMenuPartyInfo(TRADE_PLAYER); + DrawTradeMenuPartyInfo(TRADE_PARTNER); CopyBgTilemapBufferToVram(1); break; case 2: @@ -915,28 +915,28 @@ static void SetTradePartyMonsVisible(void) for (i = 0; i < PARTY_SIZE; i++) { - if (i < sTradeData->partyCounts[TRADE_PLAYER]) + if (i < sTradeMenuData->partyCounts[TRADE_PLAYER]) { - gSprites[sTradeData->partySpriteIds[TRADE_PLAYER][i]].invisible = FALSE; - sTradeData->monPresent[i] = TRUE; + gSprites[sTradeMenuData->partySpriteIds[TRADE_PLAYER][i]].invisible = FALSE; + sTradeMenuData->monPresent[i] = TRUE; } else { - sTradeData->monPresent[i] = FALSE; + sTradeMenuData->monPresent[i] = FALSE; } - if (i < sTradeData->partyCounts[TRADE_PARTNER]) + if (i < sTradeMenuData->partyCounts[TRADE_PARTNER]) { - gSprites[sTradeData->partySpriteIds[TRADE_PARTNER][i]].invisible = FALSE; - sTradeData->monPresent[i + PARTY_SIZE] = TRUE; + gSprites[sTradeMenuData->partySpriteIds[TRADE_PARTNER][i]].invisible = FALSE; + sTradeMenuData->monPresent[i + PARTY_SIZE] = TRUE; } else { - sTradeData->monPresent[i + PARTY_SIZE] = FALSE; + sTradeMenuData->monPresent[i + PARTY_SIZE] = FALSE; } } - sTradeData->neverRead_44 = 1; + sTradeMenuData->neverRead_44 = TRUE; } // why not just use memcpy? @@ -958,116 +958,116 @@ static bool8 shedinja_maker_maybe(void) int i; struct Pokemon *mon; - switch (sTradeData->unk_69) + switch (sTradeMenuData->unk_69) { case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); - sTradeData->unk_69++; - sTradeData->timer = 0; + sTradeMenuData->unk_69++; + sTradeMenuData->timer = 0; break; case 1: - if (sub_80771BC()) + if (sub_80771BC()) // SKP { if (_GetBlockReceivedStatus() == 0) { - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } else { TradeResetReceivedFlags(); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } } break; case 3: if (id == 0) { - sub_80771AC(1); + sub_80771AC(1); // SKP } - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 4: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon)); TradeResetReceivedFlags(); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } break; case 5: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon)); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 7: if (id == 0) { - sub_80771AC(1); + sub_80771AC(1); // SKP } - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 8: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200); TradeResetReceivedFlags(); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } break; case 9: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 11: if (id == 0) { - sub_80771AC(1); + sub_80771AC(1); // SKP } - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 12: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200); TradeResetReceivedFlags(); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } break; case 13: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 15: if (id == 0) { - sub_80771AC(3); + sub_80771AC(3); // SKP } - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 16: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(gTradeMail, gBlockRecvBuffer[id ^ 1], 216); TradeResetReceivedFlags(); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } break; case 17: - Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, ARRAY_COUNT(sTradeData->giftRibbons)); - sTradeData->unk_69++; + Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, ARRAY_COUNT(sTradeMenuData->giftRibbons)); + sTradeMenuData->unk_69++; break; case 19: if (id == 0) { - sub_80771AC(4); + sub_80771AC(4); // SKP } - sTradeData->unk_69++; + sTradeMenuData->unk_69++; break; case 20: if (_GetBlockReceivedStatus() == 3) { - Trade_Memcpy(sTradeData->giftRibbons, gBlockRecvBuffer[id ^ 1], ARRAY_COUNT(sTradeData->giftRibbons)); + Trade_Memcpy(sTradeMenuData->giftRibbons, gBlockRecvBuffer[id ^ 1], ARRAY_COUNT(sTradeMenuData->giftRibbons)); TradeResetReceivedFlags(); - sTradeData->unk_69++; + sTradeMenuData->unk_69++; } break; case 21: @@ -1095,11 +1095,11 @@ static bool8 shedinja_maker_maybe(void) case 10: case 14: case 18: - sTradeData->timer++; - if (sTradeData->timer > 10) + sTradeMenuData->timer++; + if (sTradeMenuData->timer > 10) { - sTradeData->timer = 0; - sTradeData->unk_69++; + sTradeMenuData->timer = 0; + sTradeMenuData->unk_69++; } break; } @@ -1108,7 +1108,7 @@ static bool8 shedinja_maker_maybe(void) static void PrintAndBufferIsThisTradeOkay(void) { - DrawTextWindowAndBuffer6Bytes(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); + DrawTextWindowAndBuffer6Bytes(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); } static void UpdateLinkFlags(u8 a0, u8 a1) @@ -1117,45 +1117,45 @@ static void UpdateLinkFlags(u8 a0, u8 a1) { switch (gBlockRecvBuffer[0][0]) { - case 0xEEAA: - sTradeData->playerLinkFlagChoseAction = WANTS_TO_CANCEL; + case LINKCMD_REQUEST_CANCEL: + sTradeMenuData->playerLinkFlagChoseAction = WANTS_TO_CANCEL; break; - case 0xAABB: - sTradeData->playerLinkFlagChoseAction = WANTS_TO_TRADE; + case LINKCMD_READY_TO_TRADE: + sTradeMenuData->playerLinkFlagChoseAction = WANTS_TO_TRADE; break; - case 0xBBBB: - sTradeData->playerLinkFlagChoseMon = CHOSE_VALID_MON; + case LINKCMD_INIT_BLOCK: + sTradeMenuData->playerLinkFlagStatus = INITIATE_TRADE; break; - case 0xBBCC: - sTradeData->playerLinkFlagChoseMon = CHOSE_INVALID_MON; + case LINKCMD_SET_CANCEL_TRADE: + sTradeMenuData->playerLinkFlagStatus = CANCEL_TRADE; break; } - TradeResetReceivedFlag(TRADE_PLAYER); + TradeResetReceivedFlag(0); } if (a1 & 2) { switch (gBlockRecvBuffer[1][0]) { - case 0xEEAA: - sTradeData->partnerLinkFlagChoseAction = WANTS_TO_CANCEL; + case LINKCMD_REQUEST_CANCEL: + sTradeMenuData->partnerLinkFlagChoseAction = WANTS_TO_CANCEL; break; - case 0xAABB: - sTradeData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; - sTradeData->partnerLinkFlagChoseAction = WANTS_TO_TRADE; + case LINKCMD_READY_TO_TRADE: + sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[1][1] + 6; + sTradeMenuData->partnerLinkFlagChoseAction = WANTS_TO_TRADE; break; - case 0xBBBB: - sTradeData->partnerLinkFlagChoseMon = CHOSE_VALID_MON; + case LINKCMD_INIT_BLOCK: + sTradeMenuData->partnerLinkFlagStatus = INITIATE_TRADE; break; - case 0xBBCC: - sTradeData->partnerLinkFlagChoseMon = CHOSE_INVALID_MON; + case LINKCMD_SET_CANCEL_TRADE: + sTradeMenuData->partnerLinkFlagStatus = CANCEL_TRADE; break; } - TradeResetReceivedFlag(TRADE_PARTNER); + TradeResetReceivedFlag(1); } } -static void sub_8078900(u8 a0, u8 a1) +static void ReactToLinkTradeData(u8 a0, u8 a1) { if (a1 & 1) { @@ -1164,105 +1164,104 @@ static void sub_8078900(u8 a0, u8 a1) case 0xEEBB: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); - sTradeData->tradeMenuFunc = 11; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1; break; case 0xEECC: PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; - case 0xDDDD: - sTradeData->partnerCursorPosition = gBlockRecvBuffer[0][1] + 6; + case LINKCMD_SET_MONS_TO_TRADE: + sTradeMenuData->partnerCursorPosition = gBlockRecvBuffer[0][1] + 6; rbox_fill_rectangle(0); - SetSelectedMon(sTradeData->cursorPosition); - SetSelectedMon(sTradeData->partnerCursorPosition); - sTradeData->tradeMenuFunc = 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); - sTradeData->tradeMenuFunc = 10; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE; break; case 0xDDEE: PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } - TradeResetReceivedFlag(TRADE_PLAYER); + TradeResetReceivedFlag(0); } if (a1 & 2) - TradeResetReceivedFlag(TRADE_PARTNER); + TradeResetReceivedFlag(1); } -// TODO: SetLinkData with additional steps -static void sub_80789FC(void) +static void QueueLinkTradeData(void) { - if (sTradeData->playerLinkFlagChoseAction && sTradeData->partnerLinkFlagChoseAction) + if (sTradeMenuData->playerLinkFlagChoseAction && sTradeMenuData->partnerLinkFlagChoseAction) { - if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_TRADE - && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) + if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_TRADE + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { - sTradeData->tradeMenuFunc = 6; - sTradeData->linkData[0] = 0xDDDD; - sTradeData->linkData[1] = sTradeData->cursorPosition; + 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); - sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; } - else if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_TRADE - && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) + else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_TRADE + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeData->linkData[0] = 0xEECC; - sTradeData->linkData[1] = 0; + sTradeMenuData->linkData[0] = 0xEECC; + sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); - sTradeData->playerLinkFlagChoseMon = sTradeData->partnerLinkFlagChoseMon = 0; - sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } - else if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_CANCEL - && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) + else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); - sTradeData->linkData[0] = 0xDDEE; - sTradeData->linkData[1] = 0; + sTradeMenuData->linkData[0] = 0xDDEE; + sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); - sTradeData->playerLinkFlagChoseMon = sTradeData->partnerLinkFlagChoseMon = 0; - sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } - else if (sTradeData->playerLinkFlagChoseAction == WANTS_TO_CANCEL - && sTradeData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) + else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL + && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { - sTradeData->linkData[0] = 0xEEBB; - sTradeData->linkData[1] = 0; + sTradeMenuData->linkData[0] = 0xEEBB; + sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->playerLinkFlagChoseAction = sTradeData->partnerLinkFlagChoseAction = 0; - sTradeData->tradeMenuFunc = 11; + sTradeMenuData->playerLinkFlagChoseAction = sTradeMenuData->partnerLinkFlagChoseAction = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1; } } - if (sTradeData->playerLinkFlagChoseMon && sTradeData->partnerLinkFlagChoseMon) + if (sTradeMenuData->playerLinkFlagStatus && sTradeMenuData->partnerLinkFlagStatus) { - if (sTradeData->playerLinkFlagChoseMon == CHOSE_VALID_MON - && sTradeData->partnerLinkFlagChoseMon == CHOSE_VALID_MON) + if (sTradeMenuData->playerLinkFlagStatus == INITIATE_TRADE + && sTradeMenuData->partnerLinkFlagStatus == INITIATE_TRADE) { - sTradeData->linkData[0] = 0xCCDD; - sTradeData->linkData[1] = 0; + sTradeMenuData->linkData[0] = LINKCMD_START_TRADE; + sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); - sTradeData->playerLinkFlagChoseMon = 0; - sTradeData->partnerLinkFlagChoseMon = 0; - sTradeData->tradeMenuFunc = 9; + sTradeMenuData->playerLinkFlagStatus = 0; + sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_FADE_OUT; } - if (sTradeData->playerLinkFlagChoseMon == CHOSE_INVALID_MON - || sTradeData->partnerLinkFlagChoseMon == CHOSE_INVALID_MON) + if (sTradeMenuData->playerLinkFlagStatus == CANCEL_TRADE + || sTradeMenuData->partnerLinkFlagStatus == CANCEL_TRADE) { PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeData->linkData[0] = 0xDDEE; - sTradeData->linkData[1] = 0; + sTradeMenuData->linkData[0] = 0xDDEE; + sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); - sTradeData->playerLinkFlagChoseMon = 0; - sTradeData->partnerLinkFlagChoseMon = 0; - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->playerLinkFlagStatus = 0; + sTradeMenuData->partnerLinkFlagStatus = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } } } @@ -1276,10 +1275,10 @@ static void _SetLinkData(u16 *linkData, u16 linkCmd, u16 cursorPosition) static void SetLinkData(u16 linkCmd, u16 cursorPosition) { - _SetLinkData(sTradeData->linkData, linkCmd, cursorPosition); + _SetLinkData(sTradeMenuData->linkData, linkCmd, cursorPosition); } -static void sub_8078C34(void) +static void CB1_SendOrReactToLinkTradeData(void) { u8 mpId = GetMultiplayerId(); u8 status; @@ -1289,11 +1288,11 @@ static void sub_8078C34(void) if (mpId == 0) UpdateLinkFlags(mpId, status); else - sub_8078900(mpId, status); + ReactToLinkTradeData(mpId, status); } if (mpId == 0) - sub_80789FC(); + QueueLinkTradeData(); } static u8 GetNewTradeMenuPosition(u8 oldPosition, u8 direction) @@ -1303,9 +1302,9 @@ static u8 GetNewTradeMenuPosition(u8 oldPosition, u8 direction) for (i = 0; i < PARTY_SIZE; i++) { - if (sTradeData->monPresent[gTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) + if (sTradeMenuData->monPresent[sTradeNextSelectedMonTable[oldPosition][direction][i]] == TRUE) { - newPosition = gTradeNextSelectedMonTable[oldPosition][direction][i]; + newPosition = sTradeNextSelectedMonTable[oldPosition][direction][i]; break; } } @@ -1319,15 +1318,15 @@ static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) if (newPosition == (PARTY_SIZE * 2)) // CANCEL { - StartSpriteAnim(&gSprites[sTradeData->cursorSpriteIdx], 1); - gSprites[sTradeData->cursorSpriteIdx].pos1.x = 224; - gSprites[sTradeData->cursorSpriteIdx].pos1.y = 160; + StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 1); + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = 224; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = 160; } else { - StartSpriteAnim(&gSprites[sTradeData->cursorSpriteIdx], 0); - gSprites[sTradeData->cursorSpriteIdx].pos1.x = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; - gSprites[sTradeData->cursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; + StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 0); + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; } if (*cursorPosition != newPosition) @@ -1338,38 +1337,34 @@ static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) *cursorPosition = newPosition; } -static void sub_8078D78(void) +static void SetReadyToTrade(void) { PrintTradeMessage(TRADE_MSG_STANDBY); - sTradeData->tradeMenuFunc = 100; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; if (GetMultiplayerId() == 1) - { - SetLinkData(0xAABB, sTradeData->cursorPosition); - } + SetLinkData(LINKCMD_READY_TO_TRADE, sTradeMenuData->cursorPosition); else - { - sTradeData->playerLinkFlagChoseAction = WANTS_TO_TRADE; - } + sTradeMenuData->playerLinkFlagChoseAction = WANTS_TO_TRADE; } static void TradeMenuProcessInput(void) { if (gMain.newAndRepeatedKeys & DPAD_UP) { - TradeMenuMoveCursor(&sTradeData->cursorPosition, 0); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 0); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - TradeMenuMoveCursor(&sTradeData->cursorPosition, 1); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 1); } else if (gMain.newAndRepeatedKeys & DPAD_LEFT) { - TradeMenuMoveCursor(&sTradeData->cursorPosition, 2); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 2); } else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { - TradeMenuMoveCursor(&sTradeData->cursorPosition, 3); + TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 3); } if (gMain.newKeys & A_BUTTON) @@ -1377,7 +1372,7 @@ static void TradeMenuProcessInput(void) PlaySE(SE_SELECT); // Cursor is in player's party - if (sTradeData->cursorPosition < PARTY_SIZE) + if (sTradeMenuData->cursorPosition < PARTY_SIZE) { DrawTextBorderOuter(1, 1, 14); FillWindowPixelBuffer(1, PIXEL_FILL(1)); @@ -1385,30 +1380,30 @@ static void TradeMenuProcessInput(void) InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); PutWindowTilemap(1); CopyWindowToVram(1, 3); - sTradeData->tradeMenuFunc = 1; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SELECTED_MON; } // Cursor is in partner's party - else if (sTradeData->cursorPosition < PARTY_SIZE * 2) + else if (sTradeMenuData->cursorPosition < PARTY_SIZE * 2) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->tradeMenuFunc = 2; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; } // Cursor is on Cancel - else if (sTradeData->cursorPosition == PARTY_SIZE * 2) + else if (sTradeMenuData->cursorPosition == PARTY_SIZE * 2) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); - sTradeData->tradeMenuFunc = 4; - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_PROMPT; + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); } } } -static void ReturnToTradeMenu(void) +static void TradeMenuChooseMon(void) { sub_8079F74(); - sTradeData->tradeMenuFunc = 0; - gSprites[sTradeData->cursorSpriteIdx].invisible = FALSE; - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeData->unk_72 * 32), 24); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_MAIN_MENU; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); } static void TradeMenuProcessInput_SelectedMon(void) @@ -1417,46 +1412,46 @@ static void TradeMenuProcessInput_SelectedMon(void) { case MENU_B_PRESSED: PlaySE(SE_SELECT); - ReturnToTradeMenu(); + TradeMenuChooseMon(); break; case MENU_NOTHING_CHOSEN: break; case MENU_ACTION_SUMMARY: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->tradeMenuFunc = 2; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; break; case MENU_ACTION_TRADE: - switch (CanTradeSelectedMon(gPlayerParty, gPlayerPartyCount, sTradeData->cursorPosition)) + switch (CanTradeSelectedMon(gPlayerParty, gPlayerPartyCount, sTradeMenuData->cursorPosition)) { case CAN_TRADE_MON: - sub_8078D78(); - gSprites[sTradeData->cursorSpriteIdx].invisible = TRUE; + SetReadyToTrade(); + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; break; case CANT_TRADE_LAST_MON: QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; case CANT_TRADE_NATIONAL: case CANT_TRADE_INVALID_MON: QueueAction(QUEUE_DELAY_MSG, QUEUE_MON_CANT_BE_TRADED); - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; case CANT_TRADE_EGG: case CANT_TRADE_EGG2: QueueAction(QUEUE_DELAY_MSG, QUEUE_EGG_CANT_BE_TRADED); - sTradeData->tradeMenuFunc = 8; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; } break; } } -static void ReturnToTradeMenuAfterButtonPress(void) +static void ChooseMonAfterButtonPress(void) { if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { PlaySE(SE_SELECT); - ReturnToTradeMenu(); + TradeMenuChooseMon(); } } @@ -1465,15 +1460,11 @@ static void TradeMenuShowMonSummaryScreen(void) if (!gPaletteFade.active) { // Player's party - if (sTradeData->cursorPosition < PARTY_SIZE) - { - ShowPokemonSummaryScreen(PSS_MODE_UNK1, gPlayerParty, sTradeData->cursorPosition, sTradeData->partyCounts[TRADE_PLAYER] - 1, sub_8077B74); - } + 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, sTradeData->cursorPosition - PARTY_SIZE, sTradeData->partyCounts[TRADE_PARTNER] - 1, sub_8077B74); - } + ShowPokemonSummaryScreen(PSS_MODE_UNK1, gEnemyParty, sTradeMenuData->cursorPosition - PARTY_SIZE, sTradeMenuData->partyCounts[TRADE_PARTNER] - 1, CB2_ReturnToTradeMenu); FreeAllWindowBuffers(); } } @@ -1507,7 +1498,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player // Partner cant trade Egg or non-Hoenn mon if player doesn't have National Dex if (!IsNationalPokedexEnabled()) { - if (sTradeData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) + if (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) { return PARTNER_MON_INVALID; } @@ -1521,21 +1512,22 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player return hasLiveMon; //PLAYER_MON_INVALID or PLAYER_MON_VALID } -static bool32 sub_8079174(void) +// Returns TRUE if the partner's selected mon is invalid, FALSE otherwise +static bool32 QueueMonValidityMessage(void) { int i; u8 aliveMons[PARTY_SIZE * 2]; - for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { - aliveMons[i] = sTradeData->isLiveMon[TRADE_PLAYER][i]; + aliveMons[i] = sTradeMenuData->isLiveMon[TRADE_PLAYER][i]; } - switch (CheckValidityOfTradeMons(aliveMons, sTradeData->partyCounts[TRADE_PLAYER], sTradeData->cursorPosition, sTradeData->partnerCursorPosition)) + switch (CheckValidityOfTradeMons(aliveMons, sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->cursorPosition, sTradeMenuData->partnerCursorPosition)) { case PLAYER_MON_INVALID: QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); - SetLinkData(0xBBCC, 0); + SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); break; case PLAYER_MON_VALID: QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); @@ -1549,27 +1541,27 @@ static bool32 sub_8079174(void) return FALSE; } -static void sub_8079218(void) +static void ConfirmOrCancelTrade(void) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case 0: - if (!sub_8079174()) + case MENU_ACTION_CONFIRM_TRADE: + if (!QueueMonValidityMessage()) { - sTradeData->tradeMenuFunc = 100; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; } else { - sTradeData->tradeMenuFunc = 17; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_PARTNER_MON_INVALID; } PutWindowTilemap(17); break; - case 1: + case MENU_ACTION_CANCEL_TRADE: case MENU_B_PRESSED: QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); - if (sub_80771BC()) - SetLinkData(0xBBCC, 0); - sTradeData->tradeMenuFunc = 100; + if (sub_80771BC()) // SKP + SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; PutWindowTilemap(17); break; } @@ -1579,62 +1571,62 @@ static void sub_807929C(void) { int i; - for (i = 0; i < sTradeData->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: + case 0: // YES, Cancel PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); - SetLinkData(0xEEAA, 0); - gSprites[sTradeData->cursorSpriteIdx].invisible = TRUE; - sTradeData->tradeMenuFunc = 100; + SetLinkData(LINKCMD_REQUEST_CANCEL, 0); + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; sub_807929C(); break; - case 1: + case 1: // NO, Continue case MENU_B_PRESSED: PlaySE(SE_SELECT); - ReturnToTradeMenu(); + TradeMenuChooseMon(); break; } } -static void sub_807935C(void) +static void SetBothSelectedMons(void) { if (GetMultiplayerId() == 0) { rbox_fill_rectangle(0); - SetSelectedMon(sTradeData->cursorPosition); - SetSelectedMon(sTradeData->partnerCursorPosition); + SetSelectedMon(sTradeMenuData->cursorPosition); + SetSelectedMon(sTradeMenuData->partnerCursorPosition); } - sTradeData->tradeMenuFunc = 7; + sTradeMenuData->tradeMenuFunc = 7; } -static void sub_8079398(void) +static void ConfirmTradePrompt(void) { - if (sTradeData->drawPartyState[TRADE_PLAYER] == 5 - && sTradeData->drawPartyState[TRADE_PARTNER] == 5) + if (sTradeMenuData->drawPartyState[TRADE_PLAYER] == DRAW_PARTY_FINISH + && sTradeMenuData->drawPartyState[TRADE_PARTNER] == DRAW_PARTY_FINISH) { PrintAndBufferIsThisTradeOkay(); - sTradeData->tradeMenuFunc = 14; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_DELAY_TRADE_CONFIRM; } } -static void Wait2SecondsAndCreateYesNoMenu(void) +static void DelayTradeConfirmation(void) { - sTradeData->timer++; + sTradeMenuData->timer++; - if (sTradeData->timer > 120) + if (sTradeMenuData->timer > 120) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); - sTradeData->timer = 0; - sTradeData->tradeMenuFunc = 3; + sTradeMenuData->timer = 0; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CONFIRM_OR_CANCEL_TRADE; } } @@ -1656,36 +1648,36 @@ static void RedrawTradeMenuAfterPressA(void) RedrawTradeMenuParty(TRADE_PLAYER); RedrawTradeMenuParty(TRADE_PARTNER); - sTradeData->tradeMenuFunc = 0; - gSprites[sTradeData->cursorSpriteIdx].invisible = FALSE; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_MAIN_MENU; + gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; } } -static void sub_8079490(void) +static void CancelTrade_1(void) { if (!gPaletteFade.active) { if (gWirelessCommType) { - sub_800ADF8(); + sub_800ADF8(); // SKP } else { - sub_800ABF4(12); + sub_800ABF4(12); // SKP } - sTradeData->tradeMenuFunc = 12; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_2; } } -static void sub_80794CC(void) +static void CancelTrade_2(void) { if (gWirelessCommType) { - if (sub_80771BC() && GetNumQueuedActions() == 0) + if (sub_80771BC() && GetNumQueuedActions() == 0) // SKP { Free(sMessageBoxAllocBuffer); - Free(sTradeData); + Free(sTradeMenuData); FreeAllWindowBuffers(); DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); @@ -1696,87 +1688,87 @@ static void sub_80794CC(void) if (!gReceivedRemoteLinkPlayers) { Free(sMessageBoxAllocBuffer); - Free(sTradeData); + Free(sTradeMenuData); FreeAllWindowBuffers(); SetMainCallback2(CB2_ReturnToFieldFromMultiplayer); } } } -static void sub_8079550(void) +static void LinkTradeWaitForQueue(void) { - if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0) + if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0) // SKP { - sub_800ADF8(); - sTradeData->tradeMenuFunc = 13; + sub_800ADF8(); // SKP + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_START_LINK_TRADE; } } -static void sub_807957C(void) +static void PartnersMonWasInvalid(void) { if (gMain.newKeys & A_BUTTON) { - SetLinkData(0xBBCC, 0); - sTradeData->tradeMenuFunc = 100; + SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; } } -//TODO: -static void sub_80795AC(void) +static void CallTradeMenuFunc(void) { - switch (sTradeData->tradeMenuFunc) + switch (sTradeMenuData->tradeMenuFunc) { - case 0: + case TRADEMENUFUNC_MAIN_MENU: TradeMenuProcessInput(); break; - case 1: + case TRADEMENUFUNC_SELECTED_MON: TradeMenuProcessInput_SelectedMon(); break; - case 2: + case TRADEMENUFUNC_SHOW_MON_SUMMARY: TradeMenuShowMonSummaryScreen(); break; - case 3: - sub_8079218(); + case TRADEMENUFUNC_CONFIRM_OR_CANCEL_TRADE: + ConfirmOrCancelTrade(); break; - case 4: - sub_80792E4(); + case TRADEMENUFUNC_CANCEL_TRADE_PROMPT: + CancelTradeYesNo(); break; - case 6: - sub_807935C(); + case TRADEMENUFUNC_BOTH_MONS_SELECTED: + SetBothSelectedMons(); break; - case 7: - sub_8079398(); + case TRADEMENUFUNC_CONFIRM_TRADE_PROMPT: + ConfirmTradePrompt(); break; - case 8: + case TRADEMENUFUNC_REDRAW_MAIN_MENU: RedrawTradeMenuAfterPressA(); break; - case 9: - sub_8078130(); + case TRADEMENUFUNC_LINK_TRADE_FADE_OUT: + LinkTradeFadeOut(); break; - case 10: - sub_807816C(); + case TRADEMENUFUNC_LINK_TRADE_WAIT_FADE: + LinkTradeWaitForFade(); break; - case 11: - sub_8079490(); + case TRADEMENUFUNC_CANCEL_TRADE_1: + CancelTrade_1(); break; - case 12: - sub_80794CC(); + case TRADEMENUFUNC_CANCEL_TRADE_2: + CancelTrade_2(); break; - case 13: - sub_80781C8(); + case TRADEMENUFUNC_START_LINK_TRADE: + SetLinkTradeCallbacks(); break; - case 14: - Wait2SecondsAndCreateYesNoMenu(); + case TRADEMENUFUNC_DELAY_TRADE_CONFIRM: + DelayTradeConfirmation(); break; - case 15: - ReturnToTradeMenuAfterButtonPress(); + case TRADEMENUFUNC_UNUSED_15: + ChooseMonAfterButtonPress(); break; - case 16: - sub_8079550(); + case TRADEMENUFUNC_LINK_TRADE_WAIT_QUEUE: + LinkTradeWaitForQueue(); break; - case 17: - sub_807957C(); + case TRADEMENUFUNC_PARTNER_MON_INVALID: + PartnersMonWasInvalid(); break; + //case TRADEMENUFUNC_STANDBY: is nop } } @@ -1785,10 +1777,10 @@ static void SetSelectedMon(u8 cursorPosition) //cursorPosition 0-5 are the player's mons, 6-11 are the partner's u8 whichParty = cursorPosition / PARTY_SIZE; - if (sTradeData->drawPartyState[whichParty] == 0) + if (sTradeMenuData->drawPartyState[whichParty] == 0) { - sTradeData->drawPartyState[whichParty] = 1; - sTradeData->selectedMonIdx[whichParty] = cursorPosition; + sTradeMenuData->drawPartyState[whichParty] = DRAW_PARTY_BEGIN; + sTradeMenuData->selectedMonIdx[whichParty] = cursorPosition; } } @@ -1800,20 +1792,20 @@ static void DrawTradeMenuParty(u8 whichParty) u8 i; u8 partyIdx; u8 selectedMonParty; - u8 selectedMonIdx = sTradeData->selectedMonIdx[whichParty]; + u8 selectedMonIdx = sTradeMenuData->selectedMonIdx[whichParty]; selectedMonParty = TRADE_PARTNER; - if (sTradeData->selectedMonIdx[whichParty] < PARTY_SIZE) + if (sTradeMenuData->selectedMonIdx[whichParty] < PARTY_SIZE) selectedMonParty = TRADE_PLAYER; partyIdx = selectedMonIdx % PARTY_SIZE; nameStringWidth = 0; - switch (sTradeData->drawPartyState[whichParty]) + switch (sTradeMenuData->drawPartyState[whichParty]) { - case 1: - for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) + case DRAW_PARTY_BEGIN: + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { - gSprites[sTradeData->partySpriteIds[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; + gSprites[sTradeMenuData->partySpriteIds[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; } for (i = 0; i < 6; i++) @@ -1821,13 +1813,13 @@ static void DrawTradeMenuParty(u8 whichParty) ClearWindowTilemap(i + (whichParty * PARTY_SIZE + 2)); } - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].invisible = FALSE; - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[0] = 20; - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[2] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; - StoreSpriteCallbackInData6(&gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]], sub_80D3014); - sTradeData->drawPartyState[whichParty]++; - TradeMenuBouncePartySprites(&gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]]); + 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] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[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, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); @@ -1836,16 +1828,16 @@ static void DrawTradeMenuParty(u8 whichParty) sub_8079F74(); break; case 2: - if (gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == sub_80D3014) - sTradeData->drawPartyState[whichParty] = 3; + if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == UpdateTradeMonIconFrame) + sTradeMenuData->drawPartyState[whichParty] = 3; break; case 3: CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.x = 0; - gSprites[sTradeData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos2.y = 0; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; + gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[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); @@ -1854,7 +1846,7 @@ static void DrawTradeMenuParty(u8 whichParty) CopyWindowToVram((whichParty * 2) + 14, 3); PutWindowTilemap((whichParty * 2) + 15); CopyWindowToVram((whichParty * 2) + 15, 3); - sTradeData->drawPartyState[whichParty]++; + sTradeMenuData->drawPartyState[whichParty]++; break; case 4: DrawTradeMenuPartyMonInfo(whichParty, partyIdx, @@ -1862,7 +1854,7 @@ static void DrawTradeMenuParty(u8 whichParty) sTradeMenuPartyMonBoxDimensions[whichParty][1] + 1, sTradeMenuPartyMonBoxDimensions[whichParty][0], sTradeMenuPartyMonBoxDimensions[whichParty][1]); - sTradeData->drawPartyState[whichParty]++; + sTradeMenuData->drawPartyState[whichParty]++; break; } } @@ -1885,7 +1877,7 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) u16 moves[MAX_MON_MOVES]; u16 i; - if (!sTradeData->isEgg[whichParty][partyIdx]) + if (!sTradeMenuData->isEgg[whichParty][partyIdx]) { for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1935,7 +1927,7 @@ static void PrintPartyNicknamesForTradeMenu(u8 whichParty) u8 str[32]; struct Pokemon *party = (whichParty == TRADE_PLAYER) ? gPlayerParty : gEnemyParty; - for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { GetMonData(&party[i], MON_DATA_NICKNAME, nickname); StringCopy10(str, nickname); @@ -1950,7 +1942,7 @@ static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 w u8 gender; u8 nickname[12]; - CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDD704, width, height, 6, 3, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMenuMonBox_Tilemap, width, height, 6, 3, 0); CopyBgTilemapBufferToVram(1); if (whichParty == TRADE_PLAYER) @@ -1958,20 +1950,20 @@ static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 w else level = GetMonData(&gEnemyParty[monIdx], MON_DATA_LEVEL, NULL); - if (!sTradeData->isEgg[whichParty][monIdx]) + if (!sTradeMenuData->isEgg[whichParty][monIdx]) { if (level / 10 != 0) - sTradeData->tilemapBuffer[x + (y * 32)] = (level / 10) + 0x60; + sTradeMenuData->tilemapBuffer[x + (y * 32)] = (level / 10) + 0x60; - sTradeData->tilemapBuffer[x + (y * 32) + 1] = (level % 10) + 0x70; + sTradeMenuData->tilemapBuffer[x + (y * 32) + 1] = (level % 10) + 0x70; } else { - sTradeData->tilemapBuffer[x + (y * 32) - 32] = sTradeData->tilemapBuffer[x + (y * 32) - 33]; - sTradeData->tilemapBuffer[x + (y * 32) - 31] = sTradeData->tilemapBuffer[x + (y * 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 (sTradeData->isEgg[whichParty][monIdx]) + if (sTradeMenuData->isEgg[whichParty][monIdx]) { symbolTile = 0x480; } @@ -2001,34 +1993,34 @@ static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 w break; } } - sTradeData->tilemapBuffer[(y - 1) * 32 + x + 1] = symbolTile; + 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 < sTradeData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { DrawTradeMenuPartyMonInfo(whichParty, i, - sTradeMonCoords[whichParty][i][0] + 4, - sTradeMonCoords[whichParty][i][1] - 1, + sTradeMonCoords[whichParty][i][0], + sTradeMonCoords[whichParty][i][1], sTradeMonBoxDimensions[whichParty][i][0], sTradeMonBoxDimensions[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, =sTradeData\n\ + ldr r0, =sTradeMenuData\n\ ldr r0, [r0]\n\ adds r0, 0x36\n\ adds r0, r6\n\ @@ -2056,7 +2048,7 @@ _08079E6A:\n\ adds r5, 0x2\n\ adds r4, 0x2\n\ adds r7, 0x1\n\ - ldr r0, =sTradeData\n\ + ldr r0, =sTradeMenuData\n\ ldr r0, [r0]\n\ adds r0, 0x36\n\ adds r0, r6\n\ @@ -2076,13 +2068,13 @@ static void ResetTradeMenuPartyPositions(u8 whichParty) { int i; - for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { - gSprites[sTradeData->partySpriteIds[whichParty][i]].invisible = FALSE; - gSprites[sTradeData->partySpriteIds[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; - gSprites[sTradeData->partySpriteIds[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; - gSprites[sTradeData->partySpriteIds[whichParty][i]].pos2.x = 0; - gSprites[sTradeData->partySpriteIds[whichParty][i]].pos2.y = 0; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].invisible = FALSE; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos2.x = 0; + gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos2.y = 0; } } @@ -2096,19 +2088,21 @@ static void RedrawTradeMenuParty(u8 whichParty) { CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - sub_8079E44(whichParty); + DrawTradeMenuPartyInfo(whichParty); PrintPartyNicknamesForTradeMenu(whichParty); ResetTradeMenuPartyPositions(whichParty); - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_ACTION_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeData->unk_72 * 32)), 24); - sTradeData->drawPartyState[whichParty] = 0; + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); + sTradeMenuData->drawPartyState[whichParty] = 0; } +// Unused static void sub_807A000(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); CopyBgTilemapBufferToVram(0); } +// Unused static void sub_807A024(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); @@ -2119,13 +2113,13 @@ static void QueueAction(u16 delay, u8 actionId) { int i; - for (i = 0; i < (int)ARRAY_COUNT(sTradeData->queuedActions); i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->queuedActions); i++) { - if (!sTradeData->queuedActions[i].queued) + if (!sTradeMenuData->queuedActions[i].queued) { - sTradeData->queuedActions[i].queueDelay = delay; - sTradeData->queuedActions[i].actionId = actionId; - sTradeData->queuedActions[i].queued = TRUE; + sTradeMenuData->queuedActions[i].queueDelay = delay; + sTradeMenuData->queuedActions[i].actionId = actionId; + sTradeMenuData->queuedActions[i].queued = TRUE; break; } } @@ -2136,9 +2130,9 @@ static u32 GetNumQueuedActions(void) u32 numActions = 0; int i; - for (i = 0; i < (int)ARRAY_COUNT(sTradeData->queuedActions); i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->queuedActions); i++) { - numActions += sTradeData->queuedActions[i].queued; + numActions += sTradeMenuData->queuedActions[i].queued; } return numActions; @@ -2148,20 +2142,20 @@ static void DoQueuedActions(void) { int i; - for (i = 0; i < (int)ARRAY_COUNT(sTradeData->queuedActions); i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->queuedActions); i++) { - if (sTradeData->queuedActions[i].queued) + if (sTradeMenuData->queuedActions[i].queued) { - if (sTradeData->queuedActions[i].queueDelay) + if (sTradeMenuData->queuedActions[i].queueDelay) { - sTradeData->queuedActions[i].queueDelay--; + sTradeMenuData->queuedActions[i].queueDelay--; } else { - switch (sTradeData->queuedActions[i].actionId) + switch (sTradeMenuData->queuedActions[i].actionId) { case QUEUE_SEND_DATA: - SendLinkData(sTradeData->linkData, 20); + SendLinkData(sTradeMenuData->linkData, 20); break; case QUEUE_STANDBY: PrintTradeMessage(TRADE_MSG_STANDBY); @@ -2184,7 +2178,7 @@ static void DoQueuedActions(void) PrintTradeMessage(TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED); break; } - sTradeData->queuedActions[i].queued = FALSE; + sTradeMenuData->queuedActions[i].queued = FALSE; } } } @@ -2203,41 +2197,41 @@ static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) { struct SpriteSheet sheet; - if (sTradeData->timer < (int)ARRAY_COUNT(sMessageBoxTileBuffers)) + if (sTradeMenuData->timer < (int)ARRAY_COUNT(sMessageBoxTileBuffers)) { - sheet.data = sMessageBoxTileBuffers[sTradeData->timer]; + sheet.data = sMessageBoxTileBuffers[sTradeMenuData->timer]; sheet.size = 0x100; - sheet.tag = 200 + sTradeData->timer; + sheet.tag = 200 + sTradeMenuData->timer; } - switch (sTradeData->timer) + switch (sTradeMenuData->timer) { case 0 ... 7: LoadSpriteSheet(&sheet); - sTradeData->timer++; + sTradeMenuData->timer++; break; case 8: - sTradeData->unk_72 = LoadSpriteSheet(&sheet); - sTradeData->timer++; + sTradeMenuData->unk_72 = LoadSpriteSheet(&sheet); + sTradeMenuData->timer++; break; case 9 ... 13: LoadSpriteSheet(&sheet); - sTradeData->timer++; + sTradeMenuData->timer++; break; case 14: LoadSpritePalette(&gSpritePalette_TradeScreenText); - sTradeData->timer++; + sTradeMenuData->timer++; break; case 15: LoadSpritePalette(&gUnknown_0832DC44); - sTradeData->timer++; + sTradeMenuData->timer++; break; case 16: LoadSpriteSheet(&sTradeButtonsSpriteSheet); - sTradeData->timer++; + sTradeMenuData->timer++; break; case 17: - sTradeData->timer = 0; + sTradeMenuData->timer = 0; return TRUE; } @@ -2256,42 +2250,42 @@ static void SetTradePartyLiveStatuses(u8 whichParty) switch (whichParty) { case TRADE_PLAYER: - for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) == TRUE) { - sTradeData->isLiveMon[whichParty][i] = FALSE; - sTradeData->isEgg[whichParty][i] = TRUE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = TRUE; } else if (GetMonData(&gPlayerParty[i], MON_DATA_HP) == 0) { - sTradeData->isLiveMon[whichParty][i] = FALSE; - sTradeData->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } else { - sTradeData->isLiveMon[whichParty][i] = TRUE; - sTradeData->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = TRUE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } } break; case TRADE_PARTNER: - for (i = 0; i < sTradeData->partyCounts[whichParty]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_IS_EGG) == TRUE) { - sTradeData->isLiveMon[whichParty][i] = FALSE; - sTradeData->isEgg[whichParty][i] = TRUE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = TRUE; } else if (GetMonData(&gEnemyParty[i], MON_DATA_HP) == 0) { - sTradeData->isLiveMon[whichParty][i] = FALSE; - sTradeData->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = FALSE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } else { - sTradeData->isLiveMon[whichParty][i] = TRUE; - sTradeData->isEgg[whichParty][i] = FALSE; + sTradeMenuData->isLiveMon[whichParty][i] = TRUE; + sTradeMenuData->isEgg[whichParty][i] = FALSE; } } break; @@ -2305,19 +2299,19 @@ static void GetTradePartyHPBarLevels(u8 who) switch (who) { case TRADE_PLAYER: - for (i = 0; i < sTradeData->partyCounts[TRADE_PLAYER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PLAYER]; i++) { curHp = GetMonData(&gPlayerParty[i], MON_DATA_HP); maxHp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); - sTradeData->hpBarLevels[TRADE_PLAYER][i] = GetHPBarLevel(curHp, maxHp); + sTradeMenuData->hpBarLevels[TRADE_PLAYER][i] = GetHPBarLevel(curHp, maxHp); } break; case TRADE_PARTNER: - for (i = 0; i < sTradeData->partyCounts[TRADE_PARTNER]; i++) + for (i = 0; i < sTradeMenuData->partyCounts[TRADE_PARTNER]; i++) { curHp = GetMonData(&gEnemyParty[i], MON_DATA_HP); maxHp = GetMonData(&gEnemyParty[i], MON_DATA_MAX_HP); - sTradeData->hpBarLevels[TRADE_PARTNER][i] = GetHPBarLevel(curHp, maxHp); + sTradeMenuData->hpBarLevels[TRADE_PARTNER][i] = GetHPBarLevel(curHp, maxHp); } break; } @@ -2329,28 +2323,27 @@ static void SetTradePartyHPBarSprites(void) for (i = 0; i < 2; i++) { - for (j = 0; j < sTradeData->partyCounts[i]; j++) + for (j = 0; j < sTradeMenuData->partyCounts[i]; j++) { - SetPartyHPBarSprite(&gSprites[sTradeData->partySpriteIds[i][j]], 4 - sTradeData->hpBarLevels[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 < (int)ARRAY_COUNT(sTradeData->giftRibbons); i++) + for (i = 0; i < (int)ARRAY_COUNT(sTradeMenuData->giftRibbons); i++) { - if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeData->giftRibbons[i] != 0) + if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenuData->giftRibbons[i] != 0) { - if (sTradeData->giftRibbons[i] < 64) - gSaveBlock1Ptr->giftRibbons[i] = sTradeData->giftRibbons[i]; + if (sTradeMenuData->giftRibbons[i] < 64) + gSaveBlock1Ptr->giftRibbons[i] = sTradeMenuData->giftRibbons[i]; } } } -//TODO: static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int monIdx) { int i, numAliveMons; @@ -2378,7 +2371,8 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if ((player->version & 0xFF) != VERSION_RUBY && (player->version & 0xFF) != VERSION_SAPPHIRE) { - if ((player->name[10] & 0xF) == 0) + // Has partner not cleared game + if ((player->progressFlagsCopy & 0xF) == 0) { if (species2[monIdx] == SPECIES_EGG) return CANT_TRADE_EGG2; @@ -2439,18 +2433,16 @@ s32 sub_807A728(void) if (val > 0) { - if (gLinkPlayers[GetMultiplayerId()].name[10] & 0xF0) + // Does player have National Dex + if (gLinkPlayers[GetMultiplayerId()].progressFlagsCopy & 0xF0) //TODO { if (val == 2) //unnecessary check, val always 2 here { - if (gLinkPlayers[GetMultiplayerId() ^ 1].name[10] & 0xF0) - { + // Does partner have National Dex + if (gLinkPlayers[GetMultiplayerId() ^ 1].progressFlagsCopy & 0xF0) return 0; - } else - { return 2; - } } } else @@ -2598,15 +2590,13 @@ 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)) - { + // Has player not cleared game + if ((player->progressFlags & 0xF) == 0) + unk = 0; + + if (versions && (player->progressFlags / 16)) unk = 0; - } } if (unk == 0) @@ -2849,7 +2839,7 @@ static void SetTradeBGAffine(void) { struct BgAffineDstData affine; - DoBgAffineSet(&affine, sTradeWindowData->texX * 0x100, sTradeWindowData->texY * 0x100, sTradeWindowData->scrX, sTradeWindowData->scrY, sTradeWindowData->sXY, sTradeWindowData->sXY, sTradeWindowData->alpha); + 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); @@ -2864,14 +2854,14 @@ static void SetTradeGpuRegs(void) { u16 dispcnt; - SetGpuReg(REG_OFFSET_BG1VOFS, sTradeWindowData->bg1vofs); - SetGpuReg(REG_OFFSET_BG1HOFS, sTradeWindowData->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, sTradeWindowData->bg2vofs); - SetGpuReg(REG_OFFSET_BG2HOFS, sTradeWindowData->bg2hofs); + SetGpuReg(REG_OFFSET_BG2VOFS, sTradeData->bg2vofs); + SetGpuReg(REG_OFFSET_BG2HOFS, sTradeData->bg2hofs); } else { @@ -2889,28 +2879,28 @@ static void VBlankCB_Trade(void) static void ClearLinkTimeoutCounter(void) { - sTradeWindowData->linkTimeoutCounter = 0; - sTradeWindowData->alwaysZero_88 = 0; - sTradeWindowData->alwaysZero_89 = 0; + sTradeData->linkTimeoutCounter = 0; + sTradeData->alwaysZero_88 = 0; + sTradeData->alwaysZero_89 = 0; } static void CheckForLinkTimeout(void) { - if (sTradeWindowData->alwaysZero_88 == sTradeWindowData->alwaysZero_89) - sTradeWindowData->linkTimeoutCounter++; + if (sTradeData->alwaysZero_88 == sTradeData->alwaysZero_89) + sTradeData->linkTimeoutCounter++; else - sTradeWindowData->linkTimeoutCounter = 0; + sTradeData->linkTimeoutCounter = 0; - if (sTradeWindowData->linkTimeoutCounter > LINK_TRADE_TIMEOUT) + if (sTradeData->linkTimeoutCounter > LINK_TRADE_TIMEOUT) { CloseLink(); SetMainCallback2(CB2_LinkError); - sTradeWindowData->linkTimeoutCounter = 0; - sTradeWindowData->alwaysZero_89 = 0; - sTradeWindowData->alwaysZero_88 = 0; + sTradeData->linkTimeoutCounter = 0; + sTradeData->alwaysZero_89 = 0; + sTradeData->alwaysZero_88 = 0; } - sTradeWindowData->alwaysZero_89 = sTradeWindowData->alwaysZero_88; + sTradeData->alwaysZero_89 = sTradeData->alwaysZero_88; } static u32 TradeGetMultiplayerId(void) @@ -2920,6 +2910,7 @@ static u32 TradeGetMultiplayerId(void) return 0; } +// TODO: static void sub_807ACFC(u8 whichParty, u8 a1) { int pos = 0; @@ -2951,14 +2942,14 @@ static void sub_807ACFC(u8 whichParty, u8 a1) HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[whichParty * 2 + 1], species, personality); LoadCompressedSpritePalette(GetMonSpritePalStruct(mon)); - sTradeWindowData->monSpecies[whichParty] = species; - sTradeWindowData->monPersonalities[whichParty] = personality; + sTradeData->monSpecies[whichParty] = species; + sTradeData->monPersonalities[whichParty] = personality; break; case 1: SetMultiuseSpriteTemplateToPokemon(GetMonSpritePalStruct(mon)->tag, pos); - sTradeWindowData->pokePicSpriteIdxs[whichParty] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); - gSprites[sTradeWindowData->pokePicSpriteIdxs[whichParty]].invisible = TRUE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; + sTradeData->pokePicSpriteIdxs[whichParty] = CreateSprite(&gMultiuseSpriteTemplate, 120, 60, 6); + gSprites[sTradeData->pokePicSpriteIdxs[whichParty]].invisible = TRUE; + gSprites[sTradeData->pokePicSpriteIdxs[whichParty]].callback = SpriteCallbackDummy; break; } } @@ -2973,7 +2964,7 @@ void CB2_LinkTrade(void) gLinkType = 0x1144; CloseLink(); } - sTradeWindowData = AllocZeroed(sizeof(*sTradeWindowData)); + sTradeData = AllocZeroed(sizeof(*sTradeData)); AllocateMonSpritesGfx(); ResetTasks(); ResetSpriteData(); @@ -2982,25 +2973,25 @@ void CB2_LinkTrade(void) InitTradeBgInternal(); ClearLinkTimeoutCounter(); gMain.state++; - sTradeWindowData->neverRead_8C = 0; - sTradeWindowData->state = 0; - sTradeWindowData->isLinkTrade = TRUE; - sTradeWindowData->texX = 64; - sTradeWindowData->texY = 64; - sTradeWindowData->neverRead_D8 = 0; - sTradeWindowData->neverRead_DA = 0; - sTradeWindowData->scrX = 120; - sTradeWindowData->scrY = 80; - sTradeWindowData->sXY = 256; - sTradeWindowData->alpha = 0; + 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) { - sTradeWindowData->isCableTrade = TRUE; + sTradeData->isCableTrade = TRUE; OpenLink(); gMain.state++; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; } else { @@ -3008,9 +2999,9 @@ void CB2_LinkTrade(void) } break; case 2: - if (++sTradeWindowData->timer > 60) + if (++sTradeData->timer > 60) { - sTradeWindowData->timer = 0; + sTradeData->timer = 0; gMain.state++; } break; @@ -3019,7 +3010,7 @@ void CB2_LinkTrade(void) { if (GetLinkPlayerCount_2() >= GetSavedPlayerCount()) { - if (++sTradeWindowData->timer > 30) + if (++sTradeData->timer > 30) { CheckShouldAdvanceLinkState(); gMain.state++; @@ -3041,9 +3032,9 @@ void CB2_LinkTrade(void) gMain.state++; break; case 5: - sTradeWindowData->unk_72 = 0; - sTradeWindowData->unk_73 = 0; - sTradeWindowData->unk_93 = 0; + sTradeData->unk_72 = 0; + sTradeData->unk_73 = 0; + sTradeData->unk_93 = 0; sub_807ACFC(TRADE_PLAYER, 0); gMain.state++; break; @@ -3101,6 +3092,7 @@ void sub_807B140(void) sub_807B62C(0); } +// TODO: void sub_807B154(void) { FillWindowPixelBuffer(0, PIXEL_FILL(15)); @@ -3144,25 +3136,25 @@ static void CB2_InGameTrade(void) StringCopy(gLinkPlayers[1].name, otName); gLinkPlayers[0].language = LANGUAGE_ENGLISH; gLinkPlayers[1].language = GetMonData(&gEnemyParty[0], MON_DATA_LANGUAGE); - sTradeWindowData = AllocZeroed(sizeof(*sTradeWindowData)); + sTradeData = AllocZeroed(sizeof(*sTradeData)); AllocateMonSpritesGfx(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); SetVBlankCallback(VBlankCB_Trade); InitTradeBgInternal(); - sTradeWindowData->isLinkTrade = FALSE; - sTradeWindowData->neverRead_8C = 0; - sTradeWindowData->state = 0; - sTradeWindowData->texX = 64; - sTradeWindowData->texY = 64; - sTradeWindowData->neverRead_D8 = 0; - sTradeWindowData->neverRead_DA = 0; - sTradeWindowData->scrX = 120; - sTradeWindowData->scrY = 80; - sTradeWindowData->sXY = 256; - sTradeWindowData->alpha = 0; - sTradeWindowData->timer = 0; + 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: @@ -3249,9 +3241,9 @@ static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx) if (playerMail != 0xFF) ClearMailStruct(&gSaveBlock1Ptr->mail[playerMail]); - sTradeWindowData->mon = *playerMon; + sTradeData->mon = *playerMon; *playerMon = *partnerMon; - *partnerMon = sTradeWindowData->mon; + *partnerMon = sTradeData->mon; friendship = 70; if (!GetMonData(playerMon, MON_DATA_IS_EGG)) @@ -3267,21 +3259,22 @@ static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx) static void sub_807B5B8(void) { - switch (sTradeWindowData->unk_93) + switch (sTradeData->unk_93) { case 1: if (IsLinkTaskFinished()) { - Trade_SendData(sTradeWindowData); - sTradeWindowData->unk_93++; + Trade_SendData(sTradeData); + sTradeData->unk_93++; } // fallthrough case 2: - sTradeWindowData->unk_93 = 0; + sTradeData->unk_93 = 0; break; } } +// TODO: CB2 static void sub_807B60C(void) { AnimateTradeSequence(); @@ -3292,13 +3285,14 @@ static void sub_807B60C(void) UpdatePaletteFade(); } +// TODO: static void sub_807B62C(u8 a0) { switch (a0) { case 0: - sTradeWindowData->bg2vofs = 0; - sTradeWindowData->bg2hofs = 180; + sTradeData->bg2vofs = 0; + sTradeData->bg2hofs = 180; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | @@ -3314,8 +3308,8 @@ static void sub_807B62C(u8 a0) DmaCopy16Defvars(3, gUnknown_08331F60, (void *) BG_SCREEN_ADDR(18), 0x1000); break; case 1: - sTradeWindowData->bg1hofs = 0; - sTradeWindowData->bg1vofs = 348; + sTradeData->bg1hofs = 0; + sTradeData->bg1vofs = 348; SetGpuReg(REG_OFFSET_BG1VOFS, 348); SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | @@ -3328,7 +3322,7 @@ static void sub_807B62C(u8 a0) BGCNT_SCREENBASE(18) | BGCNT_TXT256x512); - if (sTradeWindowData->isCableTrade) + if (sTradeData->isCableTrade) { DmaCopy16Defvars(3, sTradeTilemap_GbaCable, (void *) BG_SCREEN_ADDR(5), 0x1000); } @@ -3344,9 +3338,9 @@ static void sub_807B62C(u8 a0) DISPCNT_OBJ_ON); break; case 2: - sTradeWindowData->bg1vofs = 0; - sTradeWindowData->bg1hofs = 0; - if (!sTradeWindowData->isCableTrade) + sTradeData->bg1vofs = 0; + sTradeData->bg1hofs = 0; + if (!sTradeData->isCableTrade) { SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3369,7 +3363,7 @@ static void sub_807B62C(u8 a0) LoadPalette(sTradePal_Black, 48, 0x20); LZ77UnCompVram(sTradeGfx_WirelessSignal, (void *) BG_CHAR_ADDR(1)); LZ77UnCompVram(sTradeTilemap_WirelessSignal, (void *) BG_SCREEN_ADDR(18)); - sTradeWindowData->bg2vofs = 80; + sTradeData->bg2vofs = 80; SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG1_ON | @@ -3386,15 +3380,15 @@ static void sub_807B62C(u8 a0) BGCNT_256COLOR | BGCNT_SCREENBASE(18) | BGCNT_AFF128x128); - sTradeWindowData->texX = 64; - sTradeWindowData->texY = 92; - sTradeWindowData->sXY = 32; - sTradeWindowData->unk_EA = 1024; - sTradeWindowData->alpha = 0; + sTradeData->texX = 64; + sTradeData->texY = 92; + sTradeData->sXY = 32; + sTradeData->unk_EA = 1024; + sTradeData->alpha = 0; DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (sTradeWindowData->isCableTrade) + if (sTradeData->isCableTrade) { DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); } @@ -3404,8 +3398,8 @@ static void sub_807B62C(u8 a0) } break; case 5: - sTradeWindowData->bg1vofs = 0; - sTradeWindowData->bg1hofs = 0; + sTradeData->bg1vofs = 0; + sTradeData->bg1hofs = 0; break; case 6: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | @@ -3417,17 +3411,17 @@ static void sub_807B62C(u8 a0) BGCNT_256COLOR | BGCNT_SCREENBASE(18) | BGCNT_AFF128x128); - sTradeWindowData->texX = 64; - sTradeWindowData->texY = 92; - sTradeWindowData->sXY = 256; - sTradeWindowData->unk_EA = 128; - sTradeWindowData->scrX = 120; - sTradeWindowData->scrY = 80; - sTradeWindowData->alpha = 0; + sTradeData->texX = 64; + sTradeData->texY = 92; + sTradeData->sXY = 256; + sTradeData->unk_EA = 128; + sTradeData->scrX = 120; + sTradeData->scrY = 80; + sTradeData->alpha = 0; DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - if (sTradeWindowData->isCableTrade) + if (sTradeData->isCableTrade) { DmaCopy16Defvars(3, sTradeAffineMap_GbaCable, (void *) BG_SCREEN_ADDR(18), 0x100); } @@ -3437,8 +3431,8 @@ static void sub_807B62C(u8 a0) } break; case 7: - sTradeWindowData->bg2vofs = 0; - sTradeWindowData->bg2hofs = 0; + sTradeData->bg2vofs = 0; + sTradeData->bg2hofs = 0; SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(1) | @@ -3469,7 +3463,7 @@ static void SetTradeSceneStrings(void) u8 name[20]; const struct InGameTrade *ingameTrade; - if (sTradeWindowData->isLinkTrade) + if (sTradeData->isLinkTrade) { mpId = GetMultiplayerId(); StringCopy(gStringVar1, gLinkPlayers[mpId ^ 1].name); @@ -3491,7 +3485,7 @@ static void SetTradeSceneStrings(void) // returns TRUE if it was a link trade, FALSE if it was an in-game trade static bool8 AnimateTradeSequence(void) { - if (sTradeWindowData->isCableTrade) + if (sTradeData->isCableTrade) return AnimateTradeSequenceCable(); else return AnimateTradeSequenceWireless(); @@ -3501,57 +3495,57 @@ static bool8 AnimateTradeSequenceCable(void) { u16 evoTarget; - switch (sTradeWindowData->state) + switch (sTradeData->state) { case 0: - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = -180; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PLAYER]].y_offset; - sTradeWindowData->state++; - sTradeWindowData->cachedMapMusic = GetCurrentMapMusic(); + 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 (sTradeWindowData->bg2hofs > 0) + if (sTradeData->bg2hofs > 0) { - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; - sTradeWindowData->bg2hofs -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; + sTradeData->bg2hofs -= 3; } else { - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = 0; - sTradeWindowData->bg2hofs = 0; - sTradeWindowData->state = 10; + 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 (sTradeWindowData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) + if (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) { - PlayCry1(sTradeWindowData->monSpecies[TRADE_PLAYER], 0); + PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); } - sTradeWindowData->state = 11; - sTradeWindowData->timer = 0; + sTradeData->state = 11; + sTradeData->timer = 0; break; case 11: - if (++sTradeWindowData->timer == 80) + if (++sTradeData->timer == 80) { - sTradeWindowData->unk_D2 = sub_807671C(sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); - sTradeWindowData->state++; + sTradeData->pokeballSpriteId = CreateTradePokeballSprite(sTradeData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); DrawTextOnTradeWindow(0, gStringVar4, 0); } break; case 12: - if (gSprites[sTradeWindowData->unk_D2].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->pokeballSpriteId].callback == SpriteCallbackDummy) { - sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); - gSprites[sTradeWindowData->unk_D3].callback = sub_807E5D8; - DestroySprite(&gSprites[sTradeWindowData->unk_D2]); - sTradeWindowData->state++; + 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: @@ -3559,7 +3553,7 @@ static bool8 AnimateTradeSequenceCable(void) break; case 14: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeWindowData->state = 20; + sTradeData->state = 20; break; case 20: if (!gPaletteFade.active) @@ -3567,72 +3561,72 @@ static bool8 AnimateTradeSequenceCable(void) sub_807B62C(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); CopyWindowToVram(0, 3); - sTradeWindowData->state++; + sTradeData->state++; } break; case 21: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 22: if (!gPaletteFade.active) { - sTradeWindowData->state = 23; + sTradeData->state = 23; } break; case 23: - if (sTradeWindowData->unk_EA > 0x100) + if (sTradeData->unk_EA > 0x100) { - sTradeWindowData->unk_EA -= 0x34; + sTradeData->unk_EA -= 0x34; } else { sub_807B62C(1); - sTradeWindowData->unk_EA = 0x80; - sTradeWindowData->state++; - sTradeWindowData->timer = 0; + sTradeData->unk_EA = 0x80; + sTradeData->state++; + sTradeData->timer = 0; } - sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; break; case 24: - if (++sTradeWindowData->timer > 20) + if (++sTradeData->timer > 20) { SetTradeBGAffine(); - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - sTradeWindowData->state++; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state++; } break; case 25: - if (gSprites[sTradeWindowData->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + 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)); - sTradeWindowData->state++; + sTradeData->state++; } break; case 26: - if (--sTradeWindowData->bg1vofs == 316) + if (--sTradeData->bg1vofs == 316) { - sTradeWindowData->state++; + sTradeData->state++; } - if (sTradeWindowData->bg1vofs == 328) + if (sTradeData->bg1vofs == 328) { - sTradeWindowData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); } break; case 27: - sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); - StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); - sTradeWindowData->state++; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, 80, 3); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, 80, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeData->state++; break; case 28: - if ((sTradeWindowData->bg1vofs -= 2) == 166) + if ((sTradeData->bg1vofs -= 2) == 166) { - sTradeWindowData->state = 200; + sTradeData->state = 200; } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -3640,126 +3634,126 @@ static bool8 AnimateTradeSequenceCable(void) DISPCNT_OBJ_ON); break; case 200: - gSprites[sTradeWindowData->unk_90].pos1.y -= 2; - gSprites[sTradeWindowData->unk_91].pos1.y -= 2; - if (gSprites[sTradeWindowData->unk_90].pos1.y < -8) + gSprites[sTradeData->unk_90].pos1.y -= 2; + gSprites[sTradeData->unk_91].pos1.y -= 2; + if (gSprites[sTradeData->unk_90].pos1.y < -8) { - sTradeWindowData->state = 29; + sTradeData->state = 29; } break; case 29: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - sTradeWindowData->state = 30; + sTradeData->state = 30; break; case 30: if (!gPaletteFade.active) { - DestroySprite(&gSprites[sTradeWindowData->unk_90]); - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(2); - sTradeWindowData->state++; + sTradeData->state++; } break; case 31: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeWindowData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); - sTradeWindowData->state++; + sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + sTradeData->state++; break; case 32: if (!gPaletteFade.active) { PlaySE(SE_TK_WARPOUT); - sTradeWindowData->state++; + sTradeData->state++; } - gSprites[sTradeWindowData->unk_90].pos2.y -= 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; break; case 33: - gSprites[sTradeWindowData->unk_90].pos2.y -= 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; - if (gSprites[sTradeWindowData->unk_90].pos2.y <= -90) + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -90) { - gSprites[sTradeWindowData->unk_90].data[1] = 1; - gSprites[sTradeWindowData->unk_91].data[1] = 1; - sTradeWindowData->state++; + gSprites[sTradeData->unk_90].data[1] = 1; + gSprites[sTradeData->unk_91].data[1] = 1; + sTradeData->state++; } break; case 34: BlendPalettes(0x1, 16, RGB_WHITEALPHA); - sTradeWindowData->state++; + sTradeData->state++; break; case 35: BlendPalettes(0x1, 0, RGB_WHITEALPHA); - sTradeWindowData->state++; + sTradeData->state++; break; case 36: BlendPalettes(0x1, 16, RGB_WHITEALPHA); - sTradeWindowData->state++; + sTradeData->state++; break; case 37: - if (!IsMonSpriteNotFlipped(sTradeWindowData->monSpecies[TRADE_PLAYER])) + if (!IsMonSpriteNotFlipped(sTradeData->monSpecies[TRADE_PLAYER])) { - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].affineAnims = gSpriteAffineAnimTable_8338ECC; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.affineMode = 3; - CalcCenterToCornerVec(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0, 3, 3); - StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + 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[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); } - StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.x = 60; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 180; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.y = 192; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = -32; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = FALSE; - sTradeWindowData->state++; + 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[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y -= 3; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y += 3; - if (gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -160 && gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y >= -163) + 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[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -222) + if (gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -222) { - gSprites[sTradeWindowData->unk_90].data[1] = 0; - gSprites[sTradeWindowData->unk_91].data[1] = 0; - sTradeWindowData->state++; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = TRUE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = TRUE; + 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); } break; case 39: - gSprites[sTradeWindowData->unk_90].pos2.y -= 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; - if (gSprites[sTradeWindowData->unk_90].pos2.y <= -222) + 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); - sTradeWindowData->state++; - DestroySprite(&gSprites[sTradeWindowData->unk_90]); - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + sTradeData->state++; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); } break; case 40: if (!gPaletteFade.active) { - sTradeWindowData->state++; + sTradeData->state++; sub_807B62C(1); - sTradeWindowData->bg1vofs = 166; - sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); - StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); + sTradeData->bg1vofs = 166; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 128, -20, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); } break; case 41: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 42: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3768,76 +3762,76 @@ static bool8 AnimateTradeSequenceCable(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 43: - gSprites[sTradeWindowData->unk_90].pos2.y += 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; - if (gSprites[sTradeWindowData->unk_90].pos2.y + gSprites[sTradeWindowData->unk_90].pos1.y == 64) + 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) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 44: - if ((sTradeWindowData->bg1vofs += 2) > 316) + if ((sTradeData->bg1vofs += 2) > 316) { - sTradeWindowData->bg1vofs = 316; - sTradeWindowData->state++; + sTradeData->bg1vofs = 316; + sTradeData->state++; } break; case 45: - DestroySprite(&gSprites[sTradeWindowData->unk_90]); - DestroySprite(&gSprites[sTradeWindowData->unk_91]); - sTradeWindowData->state++; - sTradeWindowData->timer = 0; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeData->state++; + sTradeData->timer = 0; break; case 46: - if (++sTradeWindowData->timer == 10) + if (++sTradeData->timer == 10) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 47: - if (++sTradeWindowData->bg1vofs > 348) + if (++sTradeData->bg1vofs > 348) { - sTradeWindowData->bg1vofs = 348; - sTradeWindowData->state++; + sTradeData->bg1vofs = 348; + sTradeData->state++; } - if (sTradeWindowData->bg1vofs == 328 && sTradeWindowData->isCableTrade) + if (sTradeData->bg1vofs == 328 && sTradeData->isCableTrade) { - sTradeWindowData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); - gSprites[sTradeWindowData->unk_92].callback = sub_807AAE0; + sTradeData->unk_92 = CreateSprite(&gSpriteTemplate_8338DFC, 128, 65, 0); + gSprites[sTradeData->unk_92].callback = sub_807AAE0; } break; case 48: - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - sTradeWindowData->state = 50; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state = 50; break; case 50: - if (gSprites[sTradeWindowData->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(6); - sTradeWindowData->state++; + sTradeData->state++; PlaySE(SE_W028); } break; case 51: - if (sTradeWindowData->unk_EA < 0x400) + if (sTradeData->unk_EA < 0x400) { - sTradeWindowData->unk_EA += 0x34; + sTradeData->unk_EA += 0x34; } else { - sTradeWindowData->unk_EA = 0x400; - sTradeWindowData->state++; + sTradeData->unk_EA = 0x400; + sTradeData->state++; } - sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; break; case 52: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeWindowData->state = 60; + sTradeData->state = 60; break; case 60: @@ -3846,13 +3840,13 @@ static bool8 AnimateTradeSequenceCable(void) sub_807B62C(5); sub_807B62C(7); gPaletteFade.bufferTransferDisabled = TRUE; - sTradeWindowData->state++; + sTradeData->state++; } break; case 61: gPaletteFade.bufferTransferDisabled = FALSE; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 62: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -3861,40 +3855,40 @@ static bool8 AnimateTradeSequenceCable(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 63: - sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); - gSprites[sTradeWindowData->unk_D3].data[3] = 74; - gSprites[sTradeWindowData->unk_D3].callback = sub_807E6AC; - StartSpriteAnim(&gSprites[sTradeWindowData->unk_D3], 1); - StartSpriteAffineAnim(&gSprites[sTradeWindowData->unk_D3], 2); - BlendPalettes(1 << (16 + gSprites[sTradeWindowData->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); - sTradeWindowData->state++; - sTradeWindowData->timer = 0; + 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[sTradeWindowData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - sTradeWindowData->state++; + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeData->state++; break; case 65: - if (gSprites[sTradeWindowData->unk_D3].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy) { - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeWindowData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeWindowData->monSpecies[TRADE_PARTNER], sTradeWindowData->monPersonalities[TRADE_PARTNER]); - sTradeWindowData->state++; + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); + sTradeData->state++; } break; case 66: - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 120; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PARTNER]].y_offset + 60; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.x = 0; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y = 0; - StartSpriteAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); - CreatePokeballSpriteToReleaseMon(sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeWindowData->monSpecies[TRADE_PARTNER]); - FreeSpriteOamMatrix(&gSprites[sTradeWindowData->unk_D3]); - DestroySprite(&gSprites[sTradeWindowData->unk_D3]); - sTradeWindowData->state++; + 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 | @@ -3904,54 +3898,54 @@ static bool8 AnimateTradeSequenceCable(void) DISPCNT_OBJ_ON); StringExpandPlaceholders(gStringVar4, gText_XSentOverY); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeWindowData->state = 167; - sTradeWindowData->timer = 0; + sTradeData->state = 167; + sTradeData->timer = 0; break; // 167 and 267 are extra cases added in for animations case 167: - if (++sTradeWindowData->timer > 60) + if (++sTradeData->timer > 60) { - sTradeWindowData->state = 267; - sTradeWindowData->timer = 0; + sTradeData->state = 267; + sTradeData->timer = 0; } break; case 267: if (IsCryFinished()) { - sTradeWindowData->state = 68; + sTradeData->state = 68; } break; case 68: - if (++sTradeWindowData->timer == 10) + if (++sTradeData->timer == 10) { PlayFanfare(MUS_FANFA5); } - if (sTradeWindowData->timer == 250) + if (sTradeData->timer == 250) { - sTradeWindowData->state++; + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeWindowData->timer = 0; + sTradeData->timer = 0; } break; case 69: - if (++sTradeWindowData->timer == 60) + if (++sTradeData->timer == 60) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 70: CheckPartnersMonForRibbons(); - sTradeWindowData->state++; + sTradeData->state++; break; case 71: - if (sTradeWindowData->isLinkTrade) + if (sTradeData->isLinkTrade) { return TRUE; } else if (gMain.newKeys & A_BUTTON) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 72: // Only if in-game trade @@ -3960,26 +3954,26 @@ static bool8 AnimateTradeSequenceCable(void) evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); } - sTradeWindowData->state++; + sTradeData->state++; break; case 73: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 74: if (!gPaletteFade.active) { - PlayNewMapMusic(sTradeWindowData->cachedMapMusic); - if (sTradeWindowData) + PlayNewMapMusic(sTradeData->cachedMapMusic); + if (sTradeData) { FreeAllWindowBuffers(); Free(GetBgTilemapBuffer(3)); Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeWindowData); + FREE_AND_SET_NULL(sTradeData); } SetMainCallback2(CB2_ReturnToField); BuffeInGameTradeMonName(); @@ -3993,57 +3987,57 @@ static bool8 AnimateTradeSequenceWireless(void) { u16 evoTarget; - switch (sTradeWindowData->state) + switch (sTradeData->state) { case 0: - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = -180; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PLAYER]].y_offset; - sTradeWindowData->state++; - sTradeWindowData->cachedMapMusic = GetCurrentMapMusic(); + 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 (sTradeWindowData->bg2hofs > 0) + if (sTradeData->bg2hofs > 0) { - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; - sTradeWindowData->bg2hofs -= 3; + gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x += 3; + sTradeData->bg2hofs -= 3; } else { - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.x = 0; - sTradeWindowData->bg2hofs = 0; - sTradeWindowData->state = 10; + 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 (sTradeWindowData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) + if (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) { - PlayCry1(sTradeWindowData->monSpecies[TRADE_PLAYER], 0); + PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); } - sTradeWindowData->state = 11; - sTradeWindowData->timer = 0; + sTradeData->state = 11; + sTradeData->timer = 0; break; case 11: - if (++sTradeWindowData->timer == 80) + if (++sTradeData->timer == 80) { - sTradeWindowData->unk_D2 = sub_807671C(sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); - sTradeWindowData->state++; + sTradeData->pokeballSpriteId = CreateTradePokeballSprite(sTradeData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.paletteNum, 120, 32, 2, 1, 0x14, 0xfffff); + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); DrawTextOnTradeWindow(0, gStringVar4, 0); } break; case 12: - if (gSprites[sTradeWindowData->unk_D2].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->pokeballSpriteId].callback == SpriteCallbackDummy) { - sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, 32, 0); - gSprites[sTradeWindowData->unk_D3].callback = sub_807E5D8; - DestroySprite(&gSprites[sTradeWindowData->unk_D2]); - sTradeWindowData->state++; + 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: @@ -4051,7 +4045,7 @@ static bool8 AnimateTradeSequenceWireless(void) break; case 14: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeWindowData->state = 20; + sTradeData->state = 20; break; case 20: if (!gPaletteFade.active) @@ -4059,77 +4053,77 @@ static bool8 AnimateTradeSequenceWireless(void) sub_807B62C(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); CopyWindowToVram(0, 3); - sTradeWindowData->state++; + sTradeData->state++; } break; case 21: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 22: if (!gPaletteFade.active) { - sTradeWindowData->state = 23; + sTradeData->state = 23; } break; case 23: - if (sTradeWindowData->unk_EA > 0x100) + if (sTradeData->unk_EA > 0x100) { - sTradeWindowData->unk_EA -= 0x34; + sTradeData->unk_EA -= 0x34; } else { sub_807B62C(1); - sTradeWindowData->unk_EA = 0x80; - sTradeWindowData->state = 124; - sTradeWindowData->timer = 0; + sTradeData->unk_EA = 0x80; + sTradeData->state = 124; + sTradeData->timer = 0; } - sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; break; case 124: - if (++sTradeWindowData->timer > 20) + if (++sTradeData->timer > 20) { sub_807B62C(3); - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); - sTradeWindowData->state++; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E8C, 120, 80, 0); + sTradeData->state++; } break; case 125: - if (gSprites[sTradeWindowData->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + 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(c3_08054588, 5); - sTradeWindowData->state++; + sTradeData->state++; } break; case 126: if (!FuncIsActiveTask(c3_08054588)) { - sTradeWindowData->state = 26; + sTradeData->state = 26; } break; case 26: - if (--sTradeWindowData->bg1vofs == 316) + if (--sTradeData->bg1vofs == 316) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 27: - sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); - gSprites[sTradeWindowData->unk_90].callback = sub_807AA4C; - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0); - StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); - sTradeWindowData->state++; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, 80, 3); + gSprites[sTradeData->unk_90].callback = sub_807AA4C; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, 80, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + sTradeData->state++; break; case 28: - if ((sTradeWindowData->bg1vofs -= 3) == 166) + if ((sTradeData->bg1vofs -= 3) == 166) { - sTradeWindowData->state = 200; + sTradeData->state = 200; } SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | @@ -4137,130 +4131,130 @@ static bool8 AnimateTradeSequenceWireless(void) DISPCNT_OBJ_ON); break; case 200: - gSprites[sTradeWindowData->unk_90].pos1.y -= 2; - gSprites[sTradeWindowData->unk_91].pos1.y -= 2; - if (gSprites[sTradeWindowData->unk_90].pos1.y < -8) + gSprites[sTradeData->unk_90].pos1.y -= 2; + gSprites[sTradeData->unk_91].pos1.y -= 2; + if (gSprites[sTradeData->unk_90].pos1.y < -8) { - sTradeWindowData->state = 29; + sTradeData->state = 29; } break; case 29: BeginNormalPaletteFade(0xFFFFFFFF, -1, 0, 16, RGB_BLACK); - sTradeWindowData->state = 30; + sTradeData->state = 30; break; case 30: if (!gPaletteFade.active) { - DestroySprite(&gSprites[sTradeWindowData->unk_90]); - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(2); - sTradeWindowData->state++; + sTradeData->state++; } break; case 31: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeWindowData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); - sTradeWindowData->state++; + sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + sTradeData->state++; break; case 32: if (!gPaletteFade.active) { PlaySE(SE_TK_WARPOUT); - sTradeWindowData->state++; + sTradeData->state++; } - gSprites[sTradeWindowData->unk_90].pos2.y -= 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; break; case 33: - gSprites[sTradeWindowData->unk_90].pos2.y -= 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; - if (gSprites[sTradeWindowData->unk_90].pos2.y <= -90) + gSprites[sTradeData->unk_90].pos2.y -= 3; + gSprites[sTradeData->unk_91].pos2.y += 3; + if (gSprites[sTradeData->unk_90].pos2.y <= -90) { - gSprites[sTradeWindowData->unk_90].data[1] = 1; - gSprites[sTradeWindowData->unk_91].data[1] = 1; - sTradeWindowData->state++; + 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); - sTradeWindowData->state++; + sTradeData->state++; break; case 35: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - sTradeWindowData->state++; + sTradeData->state++; break; case 36: BlendPalettes(0x8, 16, RGB_WHITEALPHA); - sTradeWindowData->state++; + sTradeData->state++; break; case 37: - if (!IsMonSpriteNotFlipped(sTradeWindowData->monSpecies[TRADE_PLAYER])) + if (!IsMonSpriteNotFlipped(sTradeData->monSpecies[TRADE_PLAYER])) { - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].affineAnims = gSpriteAffineAnimTable_8338ECC; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].oam.affineMode = 3; - CalcCenterToCornerVec(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0, 3, 3); - StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + 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[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); + StartSpriteAffineAnim(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]], 0); } - StartSpriteAffineAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.x = 40; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 200; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos1.y = 192; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = -32; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = FALSE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = FALSE; - sTradeWindowData->state++; + 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[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y -= 3; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y += 3; - if (gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -160 && gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y >= -163) + 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[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -222) + if (gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].pos2.y < -222) { - gSprites[sTradeWindowData->unk_90].data[1] = 0; - gSprites[sTradeWindowData->unk_91].data[1] = 0; - sTradeWindowData->state++; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]].invisible = TRUE; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].invisible = TRUE; + 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[sTradeWindowData->unk_90].pos2.y -= 3; - gSprites[sTradeWindowData->unk_91].pos2.y += 3; - if (gSprites[sTradeWindowData->unk_90].pos2.y <= -222) + 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); - sTradeWindowData->state++; - DestroySprite(&gSprites[sTradeWindowData->unk_90]); - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + sTradeData->state++; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); } break; case 40: if (!gPaletteFade.active) { - sTradeWindowData->state++; + sTradeData->state++; sub_807B62C(1); - sTradeWindowData->bg1vofs = 166; + sTradeData->bg1vofs = 166; sub_807B62C(3); - sTradeWindowData->bg2vofs = 412; - sTradeWindowData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); - gSprites[sTradeWindowData->unk_90].callback = sub_807AA4C; - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0); - StartSpriteAnim(&gSprites[sTradeWindowData->unk_91], 1); + sTradeData->bg2vofs = 412; + sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); + gSprites[sTradeData->unk_90].callback = sub_807AA4C; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 120, -20, 0); + StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); } break; case 41: BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 42: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4269,16 +4263,16 @@ static bool8 AnimateTradeSequenceWireless(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 43: - gSprites[sTradeWindowData->unk_90].pos2.y += 4; - gSprites[sTradeWindowData->unk_91].pos2.y += 4; - if (gSprites[sTradeWindowData->unk_90].pos2.y + gSprites[sTradeWindowData->unk_90].pos1.y == 64) + 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) { - sTradeWindowData->state = 144; - sTradeWindowData->timer = 0; + sTradeData->state = 144; + sTradeData->timer = 0; } break; case 144: @@ -4287,73 +4281,73 @@ static bool8 AnimateTradeSequenceWireless(void) DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON); - sTradeWindowData->bg1vofs += 3; - sTradeWindowData->bg2vofs += 3; - if (++sTradeWindowData->timer == 10) + sTradeData->bg1vofs += 3; + sTradeData->bg2vofs += 3; + if (++sTradeData->timer == 10) { u8 taskId = CreateTask(c3_08054588, 5); - gTasks[taskId].data[2] = 1; + gTasks[taskId].data[2] = TRUE; } - if (sTradeWindowData->bg1vofs > 316) + if (sTradeData->bg1vofs > 316) { - sTradeWindowData->bg1vofs = 316; - sTradeWindowData->state++; + sTradeData->bg1vofs = 316; + sTradeData->state++; } break; case 145: - DestroySprite(&gSprites[sTradeWindowData->unk_90]); - DestroySprite(&gSprites[sTradeWindowData->unk_91]); - sTradeWindowData->state++; - sTradeWindowData->timer = 0; + DestroySprite(&gSprites[sTradeData->unk_90]); + DestroySprite(&gSprites[sTradeData->unk_91]); + sTradeData->state++; + sTradeData->timer = 0; break; case 146: if (!FuncIsActiveTask(c3_08054588)) { - sTradeWindowData->state = 46; - sTradeWindowData->timer = 0; + sTradeData->state = 46; + sTradeData->timer = 0; } break; case 46: - if (++sTradeWindowData->timer == 10) + if (++sTradeData->timer == 10) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 47: - if (++sTradeWindowData->bg1vofs > 348) + if (++sTradeData->bg1vofs > 348) { - sTradeWindowData->bg1vofs = 348; - sTradeWindowData->state++; + sTradeData->bg1vofs = 348; + sTradeData->state++; } break; case 48: - sTradeWindowData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); - sTradeWindowData->state = 50; + sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338E74, 120, 80, 0); + sTradeData->state = 50; break; case 50: - if (gSprites[sTradeWindowData->unk_91].animEnded) + if (gSprites[sTradeData->unk_91].animEnded) { - DestroySprite(&gSprites[sTradeWindowData->unk_91]); + DestroySprite(&gSprites[sTradeData->unk_91]); sub_807B62C(6); - sTradeWindowData->state++; + sTradeData->state++; PlaySE(SE_W028); } break; case 51: - if (sTradeWindowData->unk_EA < 0x400) + if (sTradeData->unk_EA < 0x400) { - sTradeWindowData->unk_EA += 0x34; + sTradeData->unk_EA += 0x34; } else { - sTradeWindowData->unk_EA = 0x400; - sTradeWindowData->state++; + sTradeData->unk_EA = 0x400; + sTradeData->state++; } - sTradeWindowData->sXY = 0x8000 / sTradeWindowData->unk_EA; + sTradeData->sXY = 0x8000 / sTradeData->unk_EA; break; case 52: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeWindowData->state = 60; + sTradeData->state = 60; break; case 60: if (!gPaletteFade.active) @@ -4361,13 +4355,13 @@ static bool8 AnimateTradeSequenceWireless(void) sub_807B62C(5); sub_807B62C(7); gPaletteFade.bufferTransferDisabled = TRUE; - sTradeWindowData->state++; + sTradeData->state++; } break; case 61: gPaletteFade.bufferTransferDisabled = FALSE; BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 62: SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -4376,40 +4370,40 @@ static bool8 AnimateTradeSequenceWireless(void) DISPCNT_OBJ_ON); if (!gPaletteFade.active) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 63: - sTradeWindowData->unk_D3 = CreateSprite(&gSpriteTemplate_8338D28, 120, -8, 0); - gSprites[sTradeWindowData->unk_D3].data[3] = 74; - gSprites[sTradeWindowData->unk_D3].callback = sub_807E6AC; - StartSpriteAnim(&gSprites[sTradeWindowData->unk_D3], 1); - StartSpriteAffineAnim(&gSprites[sTradeWindowData->unk_D3], 2); - BlendPalettes(1 << (16 + gSprites[sTradeWindowData->unk_D3].oam.paletteNum), 16, RGB_WHITEALPHA); - sTradeWindowData->state++; - sTradeWindowData->timer = 0; + 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[sTradeWindowData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); - sTradeWindowData->state++; + BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + sTradeData->state++; break; case 65: - if (gSprites[sTradeWindowData->unk_D3].callback == SpriteCallbackDummy) + if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy) { - HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeWindowData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeWindowData->monSpecies[TRADE_PARTNER], sTradeWindowData->monPersonalities[TRADE_PARTNER]); - sTradeWindowData->state++; + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]); + sTradeData->state++; } break; case 66: - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.x = 120; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos1.y = gMonFrontPicCoords[sTradeWindowData->monSpecies[TRADE_PARTNER]].y_offset + 60; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.x = 0; - gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].pos2.y = 0; - StartSpriteAnim(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]], 0); - CreatePokeballSpriteToReleaseMon(sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]].oam.paletteNum, 120, 84, 2, 1, 20, 0xFFFFF, sTradeWindowData->monSpecies[TRADE_PARTNER]); - FreeSpriteOamMatrix(&gSprites[sTradeWindowData->unk_D3]); - DestroySprite(&gSprites[sTradeWindowData->unk_D3]); - sTradeWindowData->state++; + 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 | @@ -4419,54 +4413,54 @@ static bool8 AnimateTradeSequenceWireless(void) DISPCNT_OBJ_ON); StringExpandPlaceholders(gStringVar4, gText_XSentOverY); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeWindowData->state = 167; - sTradeWindowData->timer = 0; + sTradeData->state = 167; + sTradeData->timer = 0; break; // 167 and 267 are extra cases added in for animations case 167: - if (++sTradeWindowData->timer > 60) + if (++sTradeData->timer > 60) { - sTradeWindowData->state = 267; - sTradeWindowData->timer = 0; + sTradeData->state = 267; + sTradeData->timer = 0; } break; case 267: if (IsCryFinished()) { - sTradeWindowData->state = 68; + sTradeData->state = 68; } break; case 68: - if (++sTradeWindowData->timer == 10) + if (++sTradeData->timer == 10) { PlayFanfare(MUS_FANFA5); } - if (sTradeWindowData->timer == 250) + if (sTradeData->timer == 250) { - sTradeWindowData->state++; + sTradeData->state++; StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); DrawTextOnTradeWindow(0, gStringVar4, 0); - sTradeWindowData->timer = 0; + sTradeData->timer = 0; } break; case 69: - if (++sTradeWindowData->timer == 60) + if (++sTradeData->timer == 60) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 70: CheckPartnersMonForRibbons(); - sTradeWindowData->state++; + sTradeData->state++; break; case 71: - if (sTradeWindowData->isLinkTrade) + if (sTradeData->isLinkTrade) { return TRUE; } else if (gMain.newKeys & A_BUTTON) { - sTradeWindowData->state++; + sTradeData->state++; } break; case 72: // Only if in-game trade @@ -4475,26 +4469,26 @@ static bool8 AnimateTradeSequenceWireless(void) evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) { - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); } - sTradeWindowData->state++; + sTradeData->state++; break; case 73: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeWindowData->state++; + sTradeData->state++; break; case 74: if (!gPaletteFade.active) { - PlayNewMapMusic(sTradeWindowData->cachedMapMusic); - if (sTradeWindowData) + PlayNewMapMusic(sTradeData->cachedMapMusic); + if (sTradeData) { FreeAllWindowBuffers(); Free(GetBgTilemapBuffer(3)); Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeWindowData); + FREE_AND_SET_NULL(sTradeData); } SetMainCallback2(CB2_ReturnToField); BuffeInGameTradeMonName(); @@ -4517,7 +4511,7 @@ static void c2_08053788(void) gCB2_AfterEvolution = sub_807EB50; evoTarget = GetEvolutionTargetSpecies(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], TRUE, ITEM_NONE); if (evoTarget != SPECIES_NONE) - TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); + TradeEvolutionScene(&gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]], evoTarget, sTradeData->pokePicSpriteIdxs[TRADE_PARTNER], gSelectedTradeMonPositions[TRADE_PLAYER]); else if (IsWirelessTrade()) SetMainCallback2(sub_807F464); else @@ -4545,7 +4539,7 @@ static void sub_807E4DC(void) } if (gBlockRecvBuffer[0][0] == 0xABCD) { - sTradeWindowData->unk_72 = 1; + sTradeData->unk_72 = 1; } ResetBlockReceivedFlag(0); } @@ -4553,7 +4547,7 @@ static void sub_807E4DC(void) { if (gBlockRecvBuffer[1][0] == 0xABCD) { - sTradeWindowData->unk_73 = 1; + sTradeData->unk_73 = 1; } ResetBlockReceivedFlag(1); } @@ -4604,7 +4598,7 @@ static void sub_807E64C(struct Sprite *sprite) if (++ sprite->data[0] == 23) { DestroySprite(sprite); - sTradeWindowData->state = 14; // Resume the master trade animation + sTradeData->state = 14; // Resume the master trade animation } } } @@ -4734,13 +4728,13 @@ static void sub_807EA2C(void) { if (AnimateTradeSequence() == TRUE) { - DestroySprite(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PLAYER]]); - FreeSpriteOamMatrix(&gSprites[sTradeWindowData->pokePicSpriteIdxs[TRADE_PARTNER]]); + DestroySprite(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]]); + FreeSpriteOamMatrix(&gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PARTNER]]); TradeMons(gSelectedTradeMonPositions[TRADE_PLAYER], gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE); if (!IsWirelessTrade()) { - sTradeWindowData->linkData[0] = 0xABCD; - sTradeWindowData->unk_93 = 1; + sTradeData->linkData[0] = 0xABCD; + sTradeData->unk_93 = 1; } SetMainCallback2(sub_807EACC); } @@ -4763,12 +4757,12 @@ static void sub_807EACC(void) else { sub_807E4DC(); - if (mpId == 0 && sTradeWindowData->unk_72 == 1 && sTradeWindowData->unk_73 == 1) + if (mpId == 0 && sTradeData->unk_72 == 1 && sTradeData->unk_73 == 1) { - sTradeWindowData->linkData[0] = 0xDCBA; - Trade_SendData(sTradeWindowData); - sTradeWindowData->unk_72 = 2; - sTradeWindowData->unk_73 = 2; + sTradeData->linkData[0] = 0xDCBA; + Trade_SendData(sTradeData); + sTradeData->unk_72 = 2; + sTradeData->unk_73 = 2; } } RunTasks(); @@ -4787,15 +4781,15 @@ static void sub_807EB50(void) DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 1: - sub_8077288(0); + sub_8077288(0); // SKP gMain.state = 100; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; break; case 100: - if (++sTradeWindowData->timer > 180) + if (++sTradeData->timer > 180) { gMain.state = 101; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; } if (_IsLinkTaskFinished()) { @@ -4823,10 +4817,10 @@ static void sub_807EB50(void) SetContinueGameWarpStatusToDynamicWarp(); sub_8153380(); gMain.state++; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; break; case 51: - if (++sTradeWindowData->timer == 5) + if (++sTradeData->timer == 5) { gMain.state++; } @@ -4839,38 +4833,38 @@ static void sub_807EB50(void) } else { - sTradeWindowData->timer = 0; + sTradeData->timer = 0; gMain.state = 51; } break; case 4: sub_81533E0(); gMain.state = 40; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; break; case 40: - if (++sTradeWindowData->timer > 50) + if (++sTradeData->timer > 50) { if (GetMultiplayerId() == 0) { - sTradeWindowData->timer = Random() % 30; + sTradeData->timer = Random() % 30; } else { - sTradeWindowData->timer = 0; + sTradeData->timer = 0; } gMain.state = 41; } break; case 41: - if (sTradeWindowData->timer == 0) + if (sTradeData->timer == 0) { - sub_8077288(1); + sub_8077288(1); // SKP gMain.state = 42; } else { - sTradeWindowData->timer--; + sTradeData->timer--; } break; case 42: @@ -4881,10 +4875,10 @@ static void sub_807EB50(void) } break; case 5: - if (++sTradeWindowData->timer > 60) + if (++sTradeData->timer > 60) { gMain.state++; - sub_8077288(2); + sub_8077288(2); // SKP } break; case 6: @@ -4904,9 +4898,9 @@ static void sub_807EB50(void) case 8: if (IsBGMStopped() == TRUE) { - if (gWirelessCommType && gMain.savedCallback == sub_80773AC) + if (gWirelessCommType && gMain.savedCallback == CB2_StartCreateTradeMenu) { - sub_8077288(3); + sub_8077288(3); // SKP } else { @@ -4916,7 +4910,7 @@ static void sub_807EB50(void) } break; case 9: - if (gWirelessCommType && gMain.savedCallback == sub_80773AC) + if (gWirelessCommType && gMain.savedCallback == CB2_StartCreateTradeMenu) { if (_IsLinkTaskFinished()) { @@ -4949,7 +4943,7 @@ static void c2_080543C4(void) Free(GetBgTilemapBuffer(1)); Free(GetBgTilemapBuffer(0)); FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeWindowData); + FREE_AND_SET_NULL(sTradeData); if (gWirelessCommType) DestroyWirelessStatusIndicatorSprite(); SetMainCallback2(gMain.savedCallback); @@ -4997,20 +4991,22 @@ void InitTradeBg(void) void DrawTextOnTradeWindow(u8 windowId, const u8 *str, u8 speed) { FillWindowPixelBuffer(windowId, PIXEL_FILL(15)); - sTradeWindowData->textColors[0] = TEXT_DYNAMIC_COLOR_6; - sTradeWindowData->textColors[1] = TEXT_COLOR_WHITE; - sTradeWindowData->textColors[2] = TEXT_COLOR_GREEN; - AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, sTradeWindowData->textColors, 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); } +#define signalComingBack data[2] + static void c3_08054588(u8 taskId) { s16 *data = gTasks[taskId].data; u16 unk = gUnknown_08339090[data[0]][0] * 16; - if (!data[2]) + if (!signalComingBack) { if (unk == 0x100) LoadPalette(sTradePal_Black, 0x30, 32); @@ -5043,15 +5039,17 @@ static void c3_08054588(u8 taskId) } } +#undef signalComingBack + static void c3_0805465C(u8 taskId) { s16 *data = gTasks[taskId].data; if (data[0] == 0) { - sTradeWindowData->unk_FB = sTradeWindowData->unk_FD = 120; - sTradeWindowData->unk_FC = 0; - sTradeWindowData->unk_FE = 160; + sTradeData->unk_FB = sTradeData->unk_FD = 120; + sTradeData->unk_FC = 0; + sTradeData->unk_FE = 160; SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 | @@ -5059,14 +5057,14 @@ static void c3_0805465C(u8 taskId) WININ_WIN0_OBJ); } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeWindowData->unk_FB, sTradeWindowData->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeWindowData->unk_FC, sTradeWindowData->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->unk_FB, sTradeData->unk_FD)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); data[0]++; - sTradeWindowData->unk_FB -= 5; - sTradeWindowData->unk_FD += 5; + sTradeData->unk_FB -= 5; + sTradeData->unk_FD += 5; - if (sTradeWindowData->unk_FB < 80) + if (sTradeData->unk_FB < 80) { DestroyTask(taskId); } @@ -5078,24 +5076,24 @@ static void sub_807F39C(u8 taskId) if (data[0] == 0) { - sTradeWindowData->unk_FB = 80; - sTradeWindowData->unk_FD = 160; + sTradeData->unk_FB = 80; + sTradeData->unk_FD = 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(sTradeWindowData->unk_FB, sTradeWindowData->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeWindowData->unk_FC, sTradeWindowData->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->unk_FB, sTradeData->unk_FD)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); - if (sTradeWindowData->unk_FB != 120) + if (sTradeData->unk_FB != 120) { data[0]++; - sTradeWindowData->unk_FB += 5; - sTradeWindowData->unk_FD -= 5; + sTradeData->unk_FB += 5; + sTradeData->unk_FD -= 5; - if (sTradeWindowData->unk_FB >= 116) + if (sTradeData->unk_FB >= 116) BlendPalettes(0x8, 0, RGB_WHITEALPHA); } else @@ -5115,9 +5113,9 @@ static void sub_807F464(void) DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 1: - sub_8077288(0); + sub_8077288(0); // SKP gMain.state = 2; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; break; case 2: if (_IsLinkTaskFinished()) @@ -5127,54 +5125,48 @@ static void sub_807F464(void) DrawTextOnTradeWindow(0, gStringVar4, 0); IncrementGameStat(GAME_STAT_POKEMON_TRADES); sub_8153380(); - sTradeWindowData->timer = 0; + sTradeData->timer = 0; } break; case 3: - if (++sTradeWindowData->timer == 5) - { + if (++sTradeData->timer == 5) gMain.state = 4; - } break; case 4: - if (sub_81533AC()) + if (sub_81533AC()) // TODO: save func { gMain.state = 5; } else { - sTradeWindowData->timer = 0; + sTradeData->timer = 0; gMain.state = 3; } break; case 5: sub_81533E0(); gMain.state = 6; - sTradeWindowData->timer = 0; + sTradeData->timer = 0; break; case 6: - if (++sTradeWindowData->timer > 10) + if (++sTradeData->timer > 10) { if (GetMultiplayerId() == 0) - { - sTradeWindowData->timer = Random() % 30; - } + sTradeData->timer = Random() % 30; else - { - sTradeWindowData->timer = 0; - } + sTradeData->timer = 0; gMain.state = 7; } break; case 7: - if (sTradeWindowData->timer == 0) + if (sTradeData->timer == 0) { - sub_8077288(1); + sub_8077288(1); // SKP gMain.state = 8; } else { - sTradeWindowData->timer--; + sTradeData->timer--; } break; case 8: @@ -5185,10 +5177,10 @@ static void sub_807F464(void) } break; case 9: - if (++sTradeWindowData->timer > 60) + if (++sTradeData->timer > 60) { gMain.state++; - sub_8077288(2); + sub_8077288(2); // SKP } break; case 10: @@ -5202,7 +5194,7 @@ static void sub_807F464(void) case 11: if (!gPaletteFade.active && IsBGMStopped() == TRUE) { - sub_8077288(3); + sub_8077288(3); // SKP gMain.state = 12; } break; diff --git a/src/union_room.c b/src/union_room.c index 0ca925098..f2f8445c1 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -1267,15 +1267,15 @@ 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; } @@ -1589,7 +1589,7 @@ void sub_8014790(u8 taskId) if (gUnknown_02022C2C == 29) { DestroyTask(taskId); - SetMainCallback2(sub_80773AC); + SetMainCallback2(CB2_StartCreateTradeMenu); } else { From 32aa87c7e126357165e1efa2f6e1ed3d3aadbdf8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 9 Oct 2019 09:55:06 -0400 Subject: [PATCH 09/11] More trade doc, fix switch indentations --- include/constants/trade.h | 2 + include/link.h | 4 +- src/data/trade.h | 6 +- src/trade.c | 3723 +++++++++++++++++++------------------ 4 files changed, 1871 insertions(+), 1864 deletions(-) diff --git a/include/constants/trade.h b/include/constants/trade.h index 7f61c88e8..8a2626c9a 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -21,6 +21,8 @@ #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 #define CAN_TRADE_MON 0 diff --git a/include/link.h b/include/link.h index c4033d05a..f149f8a92 100644 --- a/include/link.h +++ b/include/link.h @@ -60,13 +60,13 @@ #define LINKCMD_0xAAAA 0xAAAA #define LINKCMD_0xAAAB 0xAAAB #define LINKCMD_READY_TO_TRADE 0xAABB // used in trade -#define LINKCMD_0xABCD 0xABCD // used in trade +#define LINKCMD_READY_FINISH_TRADE 0xABCD // used in trade #define LINKCMD_INIT_BLOCK 0xBBBB #define LINKCMD_SET_CANCEL_TRADE 0xBBCC // used in trade #define LINKCMD_SEND_HELD_KEYS_2 0xCAFE #define LINKCMD_0xCCCC 0xCCCC #define LINKCMD_START_TRADE 0xCCDD // all below linkcmds used in trade -#define LINKCMD_0xDCBA 0xDCBA +#define LINKCMD_CONFIRM_FINISH_TRADE 0xDCBA #define LINKCMD_SET_MONS_TO_TRADE 0xDDDD #define LINKCMD_0xDDEE 0xDDEE #define LINKCMD_REQUEST_CANCEL 0xEEAA diff --git a/src/data/trade.h b/src/data/trade.h index 81b1e565a..81681985c 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -825,7 +825,7 @@ static const struct SpriteSheet sGlow2SpriteSheet = .tag = 5552 }; -static const struct SpriteTemplate gSpriteTemplate_8338DC8 = +static const struct SpriteTemplate sGlowBallSpriteTemplate = { .tileTag = 5552, .paletteTag = 5551, @@ -1156,7 +1156,7 @@ static const s8 sTradeBallVerticalVelocityTable[] = 1, 1, 2, 3 }; -static const u8 gUnknown_08339090[][2] = +static const u8 sWirelessSignalTiming[][2] = { {0, 1}, {1, 1}, @@ -1190,6 +1190,6 @@ static const u8 gUnknown_08339090[][2] = {13, 4}, {14, 5}, {16, 1}, - {16, -1}, + {16, 255}, {0, 0} }; diff --git a/src/trade.c b/src/trade.c index 4dae1143b..ae8dc3d27 100644 --- a/src/trade.c +++ b/src/trade.c @@ -94,7 +94,7 @@ static EWRAM_DATA struct { /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; - /*0x0069*/ u8 unk_69; //state var for shedinja_maker_maybe + /*0x0069*/ u8 bufferState; /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; /*0x006F*/ u8 tradeMenuFunc; //switch var for CallTradeMenuFunc /*0x0070*/ u8 neverRead_70; @@ -125,8 +125,8 @@ static EWRAM_DATA struct { /*0x64*/ u32 timer; /*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 alwaysZero_88; /*0x89*/ u8 alwaysZero_89; @@ -136,7 +136,7 @@ static EWRAM_DATA struct { /*0x90*/ u8 unk_90; //sprite id /*0x91*/ u8 unk_91; //sprite id /*0x92*/ u8 unk_92; //sprite id - /*0x93*/ u8 unk_93; + /*0x93*/ u8 tradeFinished; /*0x94*/ u16 state; /*0x96*/ u8 filler_96[0xD2 - 0x96]; /*0xD2*/ u8 pokeballSpriteId; @@ -160,10 +160,10 @@ static EWRAM_DATA struct { /*0xF6*/ u8 textColors[3]; /*0xF9*/ u8 filler_F9; /*0xFA*/ bool8 isCableTrade; - /*0xFB*/ u8 unk_FB; - /*0xFC*/ u8 unk_FC; - /*0xFD*/ u8 unk_FD; - /*0xFE*/ u8 unk_FE; + /*0xFB*/ u8 wirelessWinLeft; + /*0xFC*/ u8 wirelessWinTop; + /*0xFD*/ u8 wirelessWinRight; + /*0xFE*/ u8 wirelessWinBottom; } *sTradeData = {NULL}; #if !defined(NONMATCHING) && MODERN @@ -175,7 +175,7 @@ static void VBlankCB_TradeMenu(void); static void CB2_TradeMenu(void); static void LoadTradeBgGfx(u8); static void SetTradePartyMonsVisible(void); -static bool8 shedinja_maker_maybe(void); +static bool8 BufferTradeParties(void); static void CB1_SendOrReactToLinkTradeData(void); static void CallTradeMenuFunc(void); static void SetSelectedMon(u8); @@ -206,10 +206,10 @@ static void sub_807AABC(struct Sprite *sprite); static void sub_807AAE0(struct Sprite *sprite); static void sub_807AB04(struct Sprite *sprite); static void InitTradeBgInternal(void); -static void sub_807B60C(void); -static void sub_807B62C(u8); +static void CB2_UpdateInGameTrade(void); +static void SetTradeSequenceBgGpuRegs(u8); static void LoadTradeSequenceSpriteSheetsAndPalettes(void); -static void SetTradeSceneStrings(void); +static void BufferTradeSceneStrings(void); static bool8 AnimateTradeSequence(void); static bool8 AnimateTradeSequenceCable(void); static bool8 AnimateTradeSequenceWireless(void); @@ -219,16 +219,16 @@ static void sub_807E64C(struct Sprite *sprite); static void sub_807E6AC(struct Sprite *sprite); static void BuffeInGameTradeMonName(void); static void SetInGameTradeMail(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 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 c3_08054588(u8); +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); #include "data/trade.h" @@ -336,7 +336,7 @@ static void InitTradeMenu(void) LoadUserWindowBorderGfx_(0, 20, 0xC0); LoadUserWindowBorderGfx(2, 1, 0xE0); LoadMonIconPalettes(); - sTradeMenuData->unk_69 = 0; + sTradeMenuData->bufferState = 0; sTradeMenuData->tradeMenuFunc = 0; sTradeMenuData->neverRead_70 = 0; sTradeMenuData->drawPartyState[TRADE_PLAYER] = 0; @@ -366,7 +366,7 @@ static void CB2_CreateTradeMenu(void) case 0: sTradeMenuData = AllocZeroed(sizeof(*sTradeMenuData)); InitTradeMenu(); - sMessageBoxAllocBuffer = AllocZeroed(14 * 256); + sMessageBoxAllocBuffer = AllocZeroed(ARRAY_COUNT(sMessageBoxTileBuffers) * 256); for (i = 0; i < (int)ARRAY_COUNT(sMessageBoxTileBuffers); i++) { @@ -464,7 +464,7 @@ static void CB2_CreateTradeMenu(void) } break; case 6: - if (shedinja_maker_maybe()) + if (BufferTradeParties()) { SaveTradeGiftRibbons(); gMain.state++; @@ -504,11 +504,11 @@ static void CB2_CreateTradeMenu(void) break; case 8: LoadHeldItemIcons(); - DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PLAYER); gMain.state++; break; case 9: - DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PARTNER); gMain.state++; break; case 10: @@ -691,11 +691,11 @@ static void CB2_ReturnToTradeMenu(void) break; case 8: LoadHeldItemIcons(); - DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PLAYER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PLAYER); gMain.state++; break; case 9: - DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->partySpriteIds[TRADE_PLAYER], TRADE_PARTNER); + DrawHeldItemIconsForTrade(&sTradeMenuData->partyCounts[0], sTradeMenuData->partySpriteIds[0], TRADE_PARTNER); gMain.state++; break; case 10: @@ -952,17 +952,17 @@ 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 (sTradeMenuData->unk_69) + switch (sTradeMenuData->bufferState) { case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; sTradeMenuData->timer = 0; break; case 1: @@ -970,12 +970,12 @@ static bool8 shedinja_maker_maybe(void) { if (_GetBlockReceivedStatus() == 0) { - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } else { TradeResetReceivedFlags(); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } } break; @@ -984,90 +984,90 @@ static bool8 shedinja_maker_maybe(void) { sub_80771AC(1); // SKP } - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 4: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon)); TradeResetReceivedFlags(); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } break; case 5: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon)); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 7: if (id == 0) { sub_80771AC(1); // SKP } - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 8: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200); TradeResetReceivedFlags(); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } break; case 9: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 11: if (id == 0) { sub_80771AC(1); // SKP } - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 12: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200); TradeResetReceivedFlags(); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } break; case 13: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 15: if (id == 0) { sub_80771AC(3); // SKP } - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 16: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(gTradeMail, gBlockRecvBuffer[id ^ 1], 216); TradeResetReceivedFlags(); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } break; case 17: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, ARRAY_COUNT(sTradeMenuData->giftRibbons)); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 19: if (id == 0) { sub_80771AC(4); // SKP } - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; break; case 20: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(sTradeMenuData->giftRibbons, gBlockRecvBuffer[id ^ 1], ARRAY_COUNT(sTradeMenuData->giftRibbons)); TradeResetReceivedFlags(); - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } break; case 21: @@ -1099,7 +1099,7 @@ static bool8 shedinja_maker_maybe(void) if (sTradeMenuData->timer > 10) { sTradeMenuData->timer = 0; - sTradeMenuData->unk_69++; + sTradeMenuData->bufferState++; } break; } @@ -1111,9 +1111,10 @@ static void PrintAndBufferIsThisTradeOkay(void) DrawTextWindowAndBuffer6Bytes(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); } -static void UpdateLinkFlags(u8 a0, u8 a1) +// mpId is unused +static void UpdateLinkTradeFlags(u8 mpId, u8 status) { - if (a1 & 1) + if (status & 1) { switch (gBlockRecvBuffer[0][0]) { @@ -1133,7 +1134,7 @@ static void UpdateLinkFlags(u8 a0, u8 a1) TradeResetReceivedFlag(0); } - if (a1 & 2) + if (status & 2) { switch (gBlockRecvBuffer[1][0]) { @@ -1155,9 +1156,10 @@ static void UpdateLinkFlags(u8 a0, u8 a1) } } -static void ReactToLinkTradeData(u8 a0, u8 a1) +// mpId is unused +static void ReactToLinkTradeData(u8 mpId, u8 status) { - if (a1 & 1) + if (status & 1) { switch (gBlockRecvBuffer[0][0]) { @@ -1188,7 +1190,7 @@ static void ReactToLinkTradeData(u8 a0, u8 a1) TradeResetReceivedFlag(0); } - if (a1 & 2) + if (status & 2) TradeResetReceivedFlag(1); } @@ -1286,7 +1288,7 @@ static void CB1_SendOrReactToLinkTradeData(void) if ((status = _GetBlockReceivedStatus())) { if (mpId == 0) - UpdateLinkFlags(mpId, status); + UpdateLinkTradeFlags(mpId, status); else ReactToLinkTradeData(mpId, status); } @@ -1410,39 +1412,39 @@ static void TradeMenuProcessInput_SelectedMon(void) { switch (Menu_ProcessInputNoWrap()) { - case MENU_B_PRESSED: - PlaySE(SE_SELECT); - TradeMenuChooseMon(); + case MENU_B_PRESSED: + PlaySE(SE_SELECT); + TradeMenuChooseMon(); + break; + case MENU_NOTHING_CHOSEN: + break; + case MENU_ACTION_SUMMARY: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; + break; + case MENU_ACTION_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 MENU_ACTION_SUMMARY: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; + 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 MENU_ACTION_TRADE: - switch (CanTradeSelectedMon(gPlayerParty, gPlayerPartyCount, sTradeMenuData->cursorPosition)) - { - case CAN_TRADE_MON: - SetReadyToTrade(); - gSprites[sTradeMenuData->cursorSpriteIdx].invisible = TRUE; - break; - case CANT_TRADE_LAST_MON: - QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); - sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; - break; - 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 CANT_TRADE_EGG: - case CANT_TRADE_EGG2: - QueueAction(QUEUE_DELAY_MSG, QUEUE_EGG_CANT_BE_TRADED); - sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; - 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; } } @@ -1525,17 +1527,17 @@ static bool32 QueueMonValidityMessage(void) switch (CheckValidityOfTradeMons(aliveMons, sTradeMenuData->partyCounts[TRADE_PLAYER], sTradeMenuData->cursorPosition, sTradeMenuData->partnerCursorPosition)) { - case PLAYER_MON_INVALID: - QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); - SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); - break; - case PLAYER_MON_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; + case PLAYER_MON_INVALID: + QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); + SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + break; + case PLAYER_MON_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; @@ -1545,28 +1547,29 @@ static void ConfirmOrCancelTrade(void) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case MENU_ACTION_CONFIRM_TRADE: - if (!QueueMonValidityMessage()) - { - sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; - } - else - { - sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_PARTNER_MON_INVALID; - } - PutWindowTilemap(17); - break; - case MENU_ACTION_CANCEL_TRADE: - case MENU_B_PRESSED: - QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); - if (sub_80771BC()) // SKP - SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + case MENU_ACTION_CONFIRM_TRADE: + if (!QueueMonValidityMessage()) + { sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; - PutWindowTilemap(17); - break; + } + else + { + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_PARTNER_MON_INVALID; + } + PutWindowTilemap(17); + break; + case MENU_ACTION_CANCEL_TRADE: + case MENU_B_PRESSED: + QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); + if (sub_80771BC()) // SKP + SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; + PutWindowTilemap(17); + break; } } +// TODO: static void sub_807929C(void) { int i; @@ -1582,18 +1585,18 @@ static void CancelTradeYesNo(void) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - 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; + 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; } } @@ -1717,58 +1720,58 @@ static void CallTradeMenuFunc(void) { switch (sTradeMenuData->tradeMenuFunc) { - 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 + 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 } } @@ -1982,15 +1985,15 @@ static void DrawTradeMenuPartyMonInfo(u8 whichParty, u8 monIdx, u8 x, u8 y, u8 w switch (gender) { - 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; + 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; } } sTradeMenuData->tilemapBuffer[(y - 1) * 32 + x + 1] = symbolTile; @@ -2078,6 +2081,7 @@ static void ResetTradeMenuPartyPositions(u8 whichParty) } } +// TODO: static void sub_8079F74(void) { rbox_fill_rectangle(1); @@ -2154,29 +2158,29 @@ static void DoQueuedActions(void) { switch (sTradeMenuData->queuedActions[i].actionId) { - 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; + 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; } sTradeMenuData->queuedActions[i].queued = FALSE; } @@ -2206,33 +2210,33 @@ static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) switch (sTradeMenuData->timer) { - case 0 ... 7: - LoadSpriteSheet(&sheet); - sTradeMenuData->timer++; - break; - case 8: - sTradeMenuData->unk_72 = 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; + case 0 ... 7: + LoadSpriteSheet(&sheet); + sTradeMenuData->timer++; + break; + case 8: + sTradeMenuData->unk_72 = 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; @@ -2298,22 +2302,22 @@ static void GetTradePartyHPBarLevels(u8 who) switch (who) { - 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; + 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; } } @@ -2411,6 +2415,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int // 0: EXCHANGE_COMPLETE // 1: EXCHANGE_STAT_4 // 2: EXCHANGE_STAT_5 +//TODO: s32 sub_807A728(void) { s32 val; @@ -2434,7 +2439,7 @@ s32 sub_807A728(void) if (val > 0) { // Does player have National Dex - if (gLinkPlayers[GetMultiplayerId()].progressFlagsCopy & 0xF0) //TODO + if (gLinkPlayers[GetMultiplayerId()].progressFlagsCopy & 0xF0) { if (val == 2) //unnecessary check, val always 2 here { @@ -2910,8 +2915,7 @@ static u32 TradeGetMultiplayerId(void) return 0; } -// TODO: -static void sub_807ACFC(u8 whichParty, u8 a1) +static void LoadTradeMonPic(u8 whichParty, u8 state) { int pos = 0; struct Pokemon *mon = NULL; @@ -2921,36 +2925,36 @@ static void sub_807ACFC(u8 whichParty, u8 a1) if (whichParty == TRADE_PLAYER) { mon = &gPlayerParty[gSelectedTradeMonPositions[TRADE_PLAYER]]; - pos = 1; + pos = B_POSITION_OPPONENT_LEFT; } if (whichParty == TRADE_PARTNER) { mon = &gEnemyParty[gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE]; - pos = 3; + 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 == TRADE_PLAYER) - 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)); - 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; + 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; } } @@ -2958,126 +2962,126 @@ void CB2_LinkTrade(void) { switch (gMain.state) { - case 0: - if (!gReceivedRemoteLinkPlayers) - { - gLinkType = 0x1144; - CloseLink(); - } - sTradeData = AllocZeroed(sizeof(*sTradeData)); - AllocateMonSpritesGfx(); - ResetTasks(); - ResetSpriteData(); - FreeAllSpritePalettes(); - SetVBlankCallback(VBlankCB_Trade); - InitTradeBgInternal(); - ClearLinkTimeoutCounter(); + case 0: + if (!gReceivedRemoteLinkPlayers) + { + gLinkType = 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++; - 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->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()) { - sTradeData->isCableTrade = TRUE; - OpenLink(); - gMain.state++; - 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()) + if (++sTradeData->timer > 30) { - if (++sTradeData->timer > 30) - { - CheckShouldAdvanceLinkState(); - gMain.state++; - } - } - else - { - CheckForLinkTimeout(); + CheckShouldAdvanceLinkState(); + gMain.state++; } } else { - gMain.state++; + CheckForLinkTimeout(); } - break; - case 4: - CheckForLinkTimeout(); - if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) - gMain.state++; - break; - case 5: - sTradeData->unk_72 = 0; - sTradeData->unk_73 = 0; - sTradeData->unk_93 = 0; - sub_807ACFC(TRADE_PLAYER, 0); + } + else + { gMain.state++; - break; - case 6: - sub_807ACFC(TRADE_PLAYER, 1); + } + break; + case 4: + CheckForLinkTimeout(); + if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) gMain.state++; - break; - case 7: - sub_807ACFC(TRADE_PARTNER, 0); - gMain.state++; - break; - case 8: - sub_807ACFC(TRADE_PARTNER, 1); - sub_807B154(); - 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: - sub_807B140(); - SetTradeSceneStrings(); - gMain.state++; - break; - case 12: - if (!gPaletteFade.active) + break; + case 5: + sTradeData->playerLinkFlagFinishTrade = 0; + sTradeData->partnerLinkFlagFinishTrade = 0; + sTradeData->tradeFinished = 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); + sub_807B154(); + 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: + sub_807B140(); + 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(); @@ -3088,8 +3092,8 @@ void CB2_LinkTrade(void) void sub_807B140(void) { - sub_807B62C(5); - sub_807B62C(0); + SetTradeSequenceBgGpuRegs(5); + SetTradeSequenceBgGpuRegs(0); } // TODO: @@ -3128,74 +3132,74 @@ static void CB2_InGameTrade(void) switch (gMain.state) { - 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: - sub_807ACFC(TRADE_PLAYER, 0); - gMain.state++; - break; - case 6: - sub_807ACFC(TRADE_PLAYER, 1); - gMain.state++; - break; - case 7: - sub_807ACFC(TRADE_PARTNER, 0); - ShowBg(0); - gMain.state++; - break; - case 8: - sub_807ACFC(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: - 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(); @@ -3220,7 +3224,7 @@ static void UpdatePokedexForReceivedMon(u8 partyIdx) } // Functionally nop after commented code -static void EnableNationalDexFromLinkPlayer(void) +static void TryEnableNationalDexFromLinkPartner(void) { u8 mpId = GetMultiplayerId(); // Originally in Ruby but commented out @@ -3254,28 +3258,27 @@ static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx) UpdatePokedexForReceivedMon(playerPartyIdx); if (gReceivedRemoteLinkPlayers) - EnableNationalDexFromLinkPlayer(); + TryEnableNationalDexFromLinkPartner(); } static void sub_807B5B8(void) { - switch (sTradeData->unk_93) + switch (sTradeData->tradeFinished) { - case 1: - if (IsLinkTaskFinished()) - { - Trade_SendData(sTradeData); - sTradeData->unk_93++; - } - // fallthrough - case 2: - sTradeData->unk_93 = 0; - break; + case 1: + if (IsLinkTaskFinished()) + { + Trade_SendData(sTradeData); + sTradeData->tradeFinished++; + } + // fallthrough + case 2: + sTradeData->tradeFinished = 0; + break; } } -// TODO: CB2 -static void sub_807B60C(void) +static void CB2_UpdateInGameTrade(void) { AnimateTradeSequence(); RunTasks(); @@ -3285,164 +3288,163 @@ static void sub_807B60C(void) UpdatePaletteFade(); } -// TODO: -static void sub_807B62C(u8 a0) +static void SetTradeSequenceBgGpuRegs(u8 state) { - switch (a0) + switch (state) { - 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); + 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 (sTradeData->isCableTrade) - { - DmaCopy16Defvars(3, sTradeTilemap_GbaCable, (void *) BG_SCREEN_ADDR(5), 0x1000); - } - else - { - DmaCopy16Defvars(3, sTradeTilemap_GbaWireless, (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: - 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); - 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, 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 | + 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); - sTradeData->texX = 64; - sTradeData->texY = 92; - sTradeData->sXY = 32; - sTradeData->unk_EA = 1024; - sTradeData->alpha = 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, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); + DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - 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; + 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, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); + DmaCopyLarge16(3, sTradeAffine_Gba, (void *) BG_CHAR_ADDR(1), 0x2840, 0x1000); - 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; + 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; } } @@ -3456,8 +3458,8 @@ static void LoadTradeSequenceSpriteSheetsAndPalettes(void) LoadSpritePalette(&sGbaSpritePalette); } -/// Buffers "[Pokemon] will be sent to [Trainer]" strings -static void SetTradeSceneStrings(void) +// Buffers "[Pokemon] will be sent to [Trainer]" strings +static void BufferTradeSceneStrings(void) { u8 mpId; u8 name[20]; @@ -3497,488 +3499,488 @@ static bool8 AnimateTradeSequenceCable(void) switch (sTradeData->state) { - 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; + 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 (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) + { + PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); + } + + 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++; - 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); + StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); DrawTextOnTradeWindow(0, gStringVar4, 0); - - if (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) - { - PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); - } - - sTradeData->state = 11; + } + 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; - break; - case 11: - if (++sTradeData->timer == 80) - { - sTradeData->pokeballSpriteId = CreateTradePokeballSprite(sTradeData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].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) - { - sub_807B62C(4); - FillWindowPixelBuffer(0, PIXEL_FILL(15)); - CopyWindowToVram(0, 3); - sTradeData->state++; - } - break; - case 21: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + } + 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 22: - if (!gPaletteFade.active) - { - sTradeData->state = 23; - } - break; - case 23: - if (sTradeData->unk_EA > 0x100) - { - sTradeData->unk_EA -= 0x34; - } - else - { - sub_807B62C(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(&gSpriteTemplate_8338DC8, 128, 80, 0); - StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + } + 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 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]); - sub_807B62C(2); - sTradeData->state++; - } - break; - case 31: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + } + break; + case 26: + if (--sTradeData->bg1vofs == 316) + { 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); - } - 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++; - sub_807B62C(1); - sTradeData->bg1vofs = 166; - sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 128, -20, 3); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 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: + } + 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++; - 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]); - sub_807B62C(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; + } + 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); + } + 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) - { - sub_807B62C(5); - sub_807B62C(7); - gPaletteFade.bufferTransferDisabled = TRUE; - sTradeData->state++; - } - break; - case 61: - gPaletteFade.bufferTransferDisabled = FALSE; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + case 60: + if (!gPaletteFade.active) + { + SetTradeSequenceBgGpuRegs(5); + SetTradeSequenceBgGpuRegs(7); + gPaletteFade.bufferTransferDisabled = TRUE; 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); + } + 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 64: - BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + } + break; + case 267: + if (IsCryFinished()) + { + sTradeData->state = 68; + } + break; + case 68: + if (++sTradeData->timer == 10) + { + PlayFanfare(MUS_FANFA5); + } + if (sTradeData->timer == 250) + { 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); + StringExpandPlaceholders(gStringVar4, gText_TakeGoodCareOfX); 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(); + } + break; + case 69: + if (++sTradeData->timer == 60) + { 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 = sub_807B60C; - 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]); - } + } + break; + case 70: + CheckPartnersMonForRibbons(); + sTradeData->state++; + break; + case 71: + if (sTradeData->isLinkTrade) + { + return TRUE; + } + else if (gMain.newKeys & A_BUTTON) + { sTradeData->state++; - break; - case 73: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state++; - break; - case 74: - if (!gPaletteFade.active) + } + 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) { - PlayNewMapMusic(sTradeData->cachedMapMusic); - if (sTradeData) - { - FreeAllWindowBuffers(); - Free(GetBgTilemapBuffer(3)); - Free(GetBgTilemapBuffer(1)); - Free(GetBgTilemapBuffer(0)); - FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeData); - } - SetMainCallback2(CB2_ReturnToField); - BuffeInGameTradeMonName(); + FreeAllWindowBuffers(); + Free(GetBgTilemapBuffer(3)); + Free(GetBgTilemapBuffer(1)); + Free(GetBgTilemapBuffer(0)); + FreeMonSpritesGfx(); + FREE_AND_SET_NULL(sTradeData); } - break; + SetMainCallback2(CB2_ReturnToField); + BuffeInGameTradeMonName(); + } + break; } return FALSE; } @@ -3989,535 +3991,535 @@ static bool8 AnimateTradeSequenceWireless(void) switch (sTradeData->state) { - 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; + 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 (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) + { + PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); + } + + 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++; - 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); + StringExpandPlaceholders(gStringVar4, gText_ByeByeVar1); DrawTextOnTradeWindow(0, gStringVar4, 0); - - if (sTradeData->monSpecies[TRADE_PLAYER] != SPECIES_EGG) - { - PlayCry1(sTradeData->monSpecies[TRADE_PLAYER], 0); - } - - sTradeData->state = 11; + } + 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; - break; - case 11: - if (++sTradeData->timer == 80) - { - sTradeData->pokeballSpriteId = CreateTradePokeballSprite(sTradeData->pokePicSpriteIdxs[TRADE_PLAYER], gSprites[sTradeData->pokePicSpriteIdxs[TRADE_PLAYER]].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) - { - sub_807B62C(4); - FillWindowPixelBuffer(0, PIXEL_FILL(15)); - CopyWindowToVram(0, 3); - sTradeData->state++; - } - break; - case 21: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); + } + 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 22: - if (!gPaletteFade.active) - { - sTradeData->state = 23; - } - break; - case 23: - if (sTradeData->unk_EA > 0x100) - { - sTradeData->unk_EA -= 0x34; - } - else - { - sub_807B62C(1); - sTradeData->unk_EA = 0x80; - sTradeData->state = 124; - sTradeData->timer = 0; - } - sTradeData->sXY = 0x8000 / sTradeData->unk_EA; - break; - case 124: - if (++sTradeData->timer > 20) - { - sub_807B62C(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(c3_08054588, 5); - sTradeData->state++; - } - break; - case 126: - if (!FuncIsActiveTask(c3_08054588)) - { - 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(&gSpriteTemplate_8338DC8, 120, 80, 0); - StartSpriteAnim(&gSprites[sTradeData->unk_91], 1); + } + 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 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]); - sub_807B62C(2); - sTradeData->state++; - } - break; - case 31: - BeginNormalPaletteFade(0xFFFFFFFF, -1, 16, 0, RGB_BLACK); - sTradeData->unk_90 = CreateSprite(&gSpriteTemplate_8338DC8, 111, 170, 0); - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 129, -10, 0); + } + break; + case 126: + if (!FuncIsActiveTask(Task_AnimateWirelessSignal)) + { + sTradeData->state = 26; + } + break; + case 26: + if (--sTradeData->bg1vofs == 316) + { 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); - sTradeData->state++; - DestroySprite(&gSprites[sTradeData->unk_90]); - DestroySprite(&gSprites[sTradeData->unk_91]); - } - break; - case 40: - if (!gPaletteFade.active) - { - sTradeData->state++; - sub_807B62C(1); - sTradeData->bg1vofs = 166; - sub_807B62C(3); - sTradeData->bg2vofs = 412; - sTradeData->unk_90 = CreateSprite(&gUnknown_08338D88, 120, -20, 3); - gSprites[sTradeData->unk_90].callback = sub_807AA4C; - sTradeData->unk_91 = CreateSprite(&gSpriteTemplate_8338DC8, 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(c3_08054588, 5); - gTasks[taskId].data[2] = TRUE; - } - if (sTradeData->bg1vofs > 316) - { - sTradeData->bg1vofs = 316; - sTradeData->state++; - } - break; - case 145: + } + 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); + 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 146: - if (!FuncIsActiveTask(c3_08054588)) - { - 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]); - sub_807B62C(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) - { - sub_807B62C(5); - sub_807B62C(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); + } + 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 64: - BeginNormalPaletteFade(1 << (16 + gSprites[sTradeData->unk_D3].oam.paletteNum), 1, 16, 0, RGB_WHITEALPHA); + } + break; + case 46: + if (++sTradeData->timer == 10) + { 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]); + } + break; + case 47: + if (++sTradeData->bg1vofs > 348) + { + sTradeData->bg1vofs = 348; 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); + } + 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->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(); + } + break; + case 69: + if (++sTradeData->timer == 60) + { 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 = sub_807B60C; - 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]); - } + } + break; + case 70: + CheckPartnersMonForRibbons(); + sTradeData->state++; + break; + case 71: + if (sTradeData->isLinkTrade) + { + return TRUE; + } + else if (gMain.newKeys & A_BUTTON) + { sTradeData->state++; - break; - case 73: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - sTradeData->state++; - break; - case 74: - if (!gPaletteFade.active) + } + 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) { - PlayNewMapMusic(sTradeData->cachedMapMusic); - if (sTradeData) - { - FreeAllWindowBuffers(); - Free(GetBgTilemapBuffer(3)); - Free(GetBgTilemapBuffer(1)); - Free(GetBgTilemapBuffer(0)); - FreeMonSpritesGfx(); - FREE_AND_SET_NULL(sTradeData); - } - SetMainCallback2(CB2_ReturnToField); - BuffeInGameTradeMonName(); + FreeAllWindowBuffers(); + Free(GetBgTilemapBuffer(3)); + Free(GetBgTilemapBuffer(1)); + Free(GetBgTilemapBuffer(0)); + FreeMonSpritesGfx(); + FREE_AND_SET_NULL(sTradeData); } - 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[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(sub_807F464); - else - SetMainCallback2(sub_807EB50); - gSelectedTradeMonPositions[TRADE_PLAYER] = 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(); @@ -4526,29 +4528,26 @@ static void c2_08053788(void) UpdatePaletteFade(); } -static void sub_807E4DC(void) +static void UpdateTradeFinishFlags(void) { u8 blockReceivedStatus; 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) - { - sTradeData->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) - { - sTradeData->unk_73 = 1; - } + if (gBlockRecvBuffer[1][0] == LINKCMD_READY_FINISH_TRADE) + sTradeData->partnerLinkFlagFinishTrade = READY_FINISH_TRADE; + ResetBlockReceivedFlag(1); } } @@ -4724,7 +4723,7 @@ void CreateInGameTradePokemon(void) _CreateInGameTradePokemon(gSpecialVar_0x8005, gSpecialVar_0x8004); } -static void sub_807EA2C(void) +static void CB2_UpdateLinkTrade(void) { if (AnimateTradeSequence() == TRUE) { @@ -4733,13 +4732,13 @@ static void sub_807EA2C(void) TradeMons(gSelectedTradeMonPositions[TRADE_PLAYER], gSelectedTradeMonPositions[TRADE_PARTNER] % PARTY_SIZE); if (!IsWirelessTrade()) { - sTradeData->linkData[0] = 0xABCD; - sTradeData->unk_93 = 1; + sTradeData->linkData[0] = LINKCMD_READY_FINISH_TRADE; + sTradeData->tradeFinished = 1; } - SetMainCallback2(sub_807EACC); + SetMainCallback2(CB2_TryFinishTrade); } sub_807B5B8(); - sub_807E4DC(); + UpdateTradeFinishFlags(); RunTasks(); RunTextPrinters(); AnimateSprites(); @@ -4747,22 +4746,24 @@ static void sub_807EA2C(void) UpdatePaletteFade(); } -static void sub_807EACC(void) +static void CB2_TryFinishTrade(void) { u8 mpId = TradeGetMultiplayerId(); if (IsWirelessTrade()) { - SetMainCallback2(c2_08053788); + SetMainCallback2(CB2_TryTradeEvolution); } else { - sub_807E4DC(); - if (mpId == 0 && sTradeData->unk_72 == 1 && sTradeData->unk_73 == 1) + UpdateTradeFinishFlags(); + if (mpId == 0 + && sTradeData->playerLinkFlagFinishTrade == READY_FINISH_TRADE + && sTradeData->partnerLinkFlagFinishTrade == READY_FINISH_TRADE) { - sTradeData->linkData[0] = 0xDCBA; + sTradeData->linkData[0] = LINKCMD_CONFIRM_FINISH_TRADE; Trade_SendData(sTradeData); - sTradeData->unk_72 = 2; - sTradeData->unk_73 = 2; + sTradeData->playerLinkFlagFinishTrade = FINISH_TRADE; + sTradeData->partnerLinkFlagFinishTrade = FINISH_TRADE; } } RunTasks(); @@ -4771,159 +4772,159 @@ static void sub_807EACC(void) UpdatePaletteFade(); } -static void sub_807EB50(void) +static void CB2_SaveAndEndTrade(void) { switch (gMain.state) { - case 0: - gMain.state++; - StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); - DrawTextOnTradeWindow(0, gStringVar4, 0); - break; - case 1: - sub_8077288(0); // SKP - gMain.state = 100; + case 0: + gMain.state++; + StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); + DrawTextOnTradeWindow(0, gStringVar4, 0); + break; + case 1: + sub_8077288(0); // SKP + gMain.state = 100; + sTradeData->timer = 0; + break; + case 100: + if (++sTradeData->timer > 180) + { + gMain.state = 101; 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(); + } + 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); // SKP + } + SetContinueGameWarpStatusToDynamicWarp(); + sub_8153380(); //TODO: save func + gMain.state++; + sTradeData->timer = 0; + break; + case 51: + if (++sTradeData->timer == 5) + { gMain.state++; + } + break; + case 52: + if (sub_81533AC()) //TODO: save func + { + ClearContinueGameWarpStatus2(); + gMain.state = 4; + } + else + { sTradeData->timer = 0; - break; - case 51: - if (++sTradeData->timer == 5) + gMain.state = 51; + } + break; + case 4: + sub_81533E0(); //TODO: save func + gMain.state = 40; + sTradeData->timer = 0; + break; + case 40: + if (++sTradeData->timer > 50) + { + if (GetMultiplayerId() == 0) { - gMain.state++; - } - break; - case 52: - if (sub_81533AC()) - { - ClearContinueGameWarpStatus2(); - gMain.state = 4; + sTradeData->timer = Random() % 30; } 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) - { - sTradeData->timer = Random() % 30; - } - else - { - sTradeData->timer = 0; - } - gMain.state = 41; - } - break; - case 41: - if (sTradeData->timer == 0) - { - sub_8077288(1); // SKP - 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); // SKP - } - 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) - { - sub_8077288(3); // SKP - } - else - { - sub_800AC34(); - } - gMain.state++; - } - break; - case 9: + gMain.state = 41; + } + break; + case 41: + if (sTradeData->timer == 0) + { + sub_8077288(1); // SKP + gMain.state = 42; + } + else + { + sTradeData->timer--; + } + break; + case 42: + if (_IsLinkTaskFinished()) + { + sub_8153408(); //TODO: save func + gMain.state = 5; + } + break; + case 5: + if (++sTradeData->timer > 60) + { + gMain.state++; + sub_8077288(2); // SKP + } + 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 (_IsLinkTaskFinished()) - { - gSoftResetDisabled = FALSE; - SetMainCallback2(c2_080543C4); - } + sub_8077288(3); // SKP } - else if (!gReceivedRemoteLinkPlayers) + else + { + sub_800AC34(); // SKP + } + gMain.state++; + } + break; + case 9: + if (gWirelessCommType && gMain.savedCallback == CB2_StartCreateTradeMenu) + { + if (_IsLinkTaskFinished()) { gSoftResetDisabled = FALSE; - SetMainCallback2(c2_080543C4); + SetMainCallback2(CB2_FreeTradeData); } - break; + } + else if (!gReceivedRemoteLinkPlayers) + { + gSoftResetDisabled = FALSE; + SetMainCallback2(CB2_FreeTradeData); + } + break; } if (!HasLinkErrorOccurred()) { @@ -4934,7 +4935,7 @@ static void sub_807EB50(void) UpdatePaletteFade(); } -static void c2_080543C4(void) +static void CB2_FreeTradeData(void) { if (!gPaletteFade.active) { @@ -4998,47 +4999,51 @@ void DrawTextOnTradeWindow(u8 windowId, const u8 *str, u8 speed) CopyWindowToVram(windowId, 3); } -#define signalComingBack data[2] +#define idx data[0] +#define counter data[1] +#define signalComingBack data[2] -static void c3_08054588(u8 taskId) +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 (!signalComingBack) { - if (unk == 0x100) + if (paletteIdx == 256) LoadPalette(sTradePal_Black, 0x30, 32); else - LoadPalette(&sTradePal_WirelessSignalSend[unk], 0x30, 32); + LoadPalette(&sTradePal_WirelessSignalSend[paletteIdx], 0x30, 32); } else { - if (unk == 0x100) + if (paletteIdx == 256) LoadPalette(sTradePal_Black, 0x30, 32); else - LoadPalette(&sTradePal_WirelessSignalReceive[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) @@ -5047,9 +5052,9 @@ static void c3_0805465C(u8 taskId) if (data[0] == 0) { - sTradeData->unk_FB = sTradeData->unk_FD = 120; - sTradeData->unk_FC = 0; - sTradeData->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 | @@ -5057,14 +5062,14 @@ static void c3_0805465C(u8 taskId) WININ_WIN0_OBJ); } - SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->unk_FB, sTradeData->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->wirelessWinLeft, sTradeData->wirelessWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->wirelessWinTop, sTradeData->wirelessWinBottom)); data[0]++; - sTradeData->unk_FB -= 5; - sTradeData->unk_FD += 5; + sTradeData->wirelessWinLeft -= 5; + sTradeData->wirelessWinRight += 5; - if (sTradeData->unk_FB < 80) + if (sTradeData->wirelessWinLeft < 80) { DestroyTask(taskId); } @@ -5076,24 +5081,24 @@ static void sub_807F39C(u8 taskId) if (data[0] == 0) { - sTradeData->unk_FB = 80; - sTradeData->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(sTradeData->unk_FB, sTradeData->unk_FD)); - SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->unk_FC, sTradeData->unk_FE)); + SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(sTradeData->wirelessWinLeft, sTradeData->wirelessWinRight)); + SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(sTradeData->wirelessWinTop, sTradeData->wirelessWinBottom)); - if (sTradeData->unk_FB != 120) + if (sTradeData->wirelessWinLeft != 120) { data[0]++; - sTradeData->unk_FB += 5; - sTradeData->unk_FD -= 5; + sTradeData->wirelessWinLeft += 5; + sTradeData->wirelessWinRight -= 5; - if (sTradeData->unk_FB >= 116) + if (sTradeData->wirelessWinLeft >= 116) BlendPalettes(0x8, 0, RGB_WHITEALPHA); } else @@ -5103,108 +5108,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); + case 0: + gMain.state = 1; + StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5); + DrawTextOnTradeWindow(0, gStringVar4, 0); + break; + case 1: + sub_8077288(0); // SKP + gMain.state = 2; + sTradeData->timer = 0; + break; + case 2: + if (_IsLinkTaskFinished()) + { + gMain.state = 3; + StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); DrawTextOnTradeWindow(0, gStringVar4, 0); - break; - case 1: - sub_8077288(0); // SKP - gMain.state = 2; + IncrementGameStat(GAME_STAT_POKEMON_TRADES); + sub_8153380(); // TODO: save func 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()) // TODO: save func - { - gMain.state = 5; - } - else - { - sTradeData->timer = 0; - gMain.state = 3; - } - break; - case 5: - sub_81533E0(); - gMain.state = 6; + } + break; + case 3: + if (++sTradeData->timer == 5) + gMain.state = 4; + break; + case 4: + if (sub_81533AC()) // TODO: save func + { + gMain.state = 5; + } + else + { sTradeData->timer = 0; - break; - case 6: - if (++sTradeData->timer > 10) - { - if (GetMultiplayerId() == 0) - sTradeData->timer = Random() % 30; - else - sTradeData->timer = 0; - gMain.state = 7; - } - break; - case 7: - if (sTradeData->timer == 0) - { - sub_8077288(1); // SKP - gMain.state = 8; - } + gMain.state = 3; + } + break; + case 5: + sub_81533E0(); //TODO: save func + gMain.state = 6; + sTradeData->timer = 0; + break; + case 6: + if (++sTradeData->timer > 10) + { + if (GetMultiplayerId() == 0) + sTradeData->timer = Random() % 30; 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); // SKP - } - 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); // SKP - 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); // SKP + gMain.state = 8; + } + else + { + sTradeData->timer--; + } + break; + case 8: + if (_IsLinkTaskFinished()) + { + sub_8153408(); //TODO: save func + gMain.state = 9; + } + break; + case 9: + if (++sTradeData->timer > 60) + { + gMain.state++; + sub_8077288(2); // SKP + } + 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); // SKP + gMain.state = 12; + } + break; + case 12: + if (_IsLinkTaskFinished()) + { + gSoftResetDisabled = FALSE; + SetMainCallback2(CB2_FreeTradeData); + } + break; } if (!HasLinkErrorOccurred()) From 07fa82c911c5a22f0671a4ea798056b8de3c0a80 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 10 Oct 2019 03:50:51 -0400 Subject: [PATCH 10/11] Last non-anim trade.c doc --- include/constants/trade.h | 26 ++-- include/link.h | 6 +- include/trade.h | 8 +- src/cable_club.c | 4 +- src/data/trade.h | 36 ++--- src/evolution_scene.c | 4 +- src/link.c | 13 +- src/party_menu.c | 8 +- src/trade.c | 290 +++++++++++++++++--------------------- 9 files changed, 185 insertions(+), 210 deletions(-) diff --git a/include/constants/trade.h b/include/constants/trade.h index 8a2626c9a..4fb8966d0 100644 --- a/include/constants/trade.h +++ b/include/constants/trade.h @@ -12,10 +12,6 @@ #define INGAME_TRADE_HORSEA 2 #define INGAME_TRADE_MEOWTH 3 -#define PLAYER_MON_INVALID 0 -#define PLAYER_MON_VALID 1 -#define PARTNER_MON_INVALID 2 - // Flag IDs for sending link data #define INITIATE_TRADE 1 #define CANCEL_TRADE 2 @@ -24,7 +20,7 @@ #define READY_FINISH_TRADE 1 #define FINISH_TRADE 2 -// Return values for CanTradeSelectedMon +// Return values for CanTradeSelectedMon and CanTradeSelectedPartyMenuMon #define CAN_TRADE_MON 0 #define CANT_TRADE_LAST_MON 1 #define CANT_TRADE_NATIONAL 2 @@ -32,6 +28,16 @@ #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 @@ -40,12 +46,7 @@ #define TRADE_TEXT_CANCEL_TRADE 4 #define TRADE_TEXT_JP_QUIT 5 -#define MENU_ACTION_SUMMARY 0 -#define MENU_ACTION_TRADE 1 -#define MENU_ACTION_CONFIRM_TRADE 0 -#define MENU_ACTION_CANCEL_TRADE 1 - -#define DRAW_PARTY_BEGIN 1 +// Checked to confirm DrawTradeMenuParty has reached final state #define DRAW_PARTY_FINISH 5 // Message indexes for sTradeMessages @@ -59,7 +60,7 @@ #define TRADE_MSG_EGG_CANT_BE_TRADED 7 #define TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED 8 -// Queue actions +// IDs for QueueAction #define QUEUE_SEND_DATA 0 #define QUEUE_STANDBY 1 #define QUEUE_ONLY_MON1 2 @@ -70,7 +71,6 @@ #define QUEUE_EGG_CANT_BE_TRADED 7 #define QUEUE_FRIENDS_MON_CANT_BE_TRADED 8 -// Queue delays #define QUEUE_DELAY_MSG 3 #define QUEUE_DELAY_DATA 5 diff --git a/include/link.h b/include/link.h index f149f8a92..04efc973c 100644 --- a/include/link.h +++ b/include/link.h @@ -106,8 +106,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 }; @@ -132,7 +132,7 @@ struct LinkPlayer /* 0x02 */ u16 lp_field_2; /* 0x04 */ u32 trainerId; /* 0x08 */ u8 name[PLAYER_NAME_LENGTH + 1]; - /* 0x10 */ u8 progressFlags; // 0x0F is hasClearedGame, 0xF0 is hasNationalDex + /* 0x10 */ u8 progressFlags; // (& 0x0F) is hasNationalDex, (& 0xF0) is hasClearedGame /* 0x11 */ u8 neverRead; /* 0x12 */ u8 progressFlagsCopy; /* 0x13 */ u8 gender; diff --git a/include/trade.h b/include/trade.h index a0385297e..42bfc1482 100644 --- a/include/trade.h +++ b/include/trade.h @@ -13,14 +13,14 @@ extern u8 gSelectedTradeMonPositions[2]; // Exported ROM declarations extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; -s32 sub_807A728(void); +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 sub_807A918(struct Pokemon*, u16); -void sub_807B140(void); -void sub_807B154(void); +int CanTradeSelectedPartyMenuMon(struct Pokemon*, u16); +void InitTradeSequenceBgGpuRegs(void); +void LinkTradeDrawWindow(void); void InitTradeBg(void); void DrawTextOnTradeWindow(u8, const u8 *, u8); diff --git a/src/cable_club.c b/src/cable_club.c index 22fc2d0c1..755e3575e 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -123,9 +123,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); diff --git a/src/data/trade.h b/src/data/trade.h index 81681985c..7d3f7ba3a 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -8,23 +8,23 @@ static const u32 sUnref_0832C6A8[] = 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}"); +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_EmptyString7[] = _(""); +static const u8 sText_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 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"); @@ -274,7 +274,7 @@ static const u8 gTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] = {23, 18} // CANCEL }; -static const u8 sTradeMonCoords[][PARTY_SIZE][2] = +static const u8 sTradeMonLevelCoords[][PARTY_SIZE][2] = { { // Your party @@ -296,7 +296,7 @@ static const u8 sTradeMonCoords[][PARTY_SIZE][2] = } }; -static const u8 sTradeMonBoxDimensions[][PARTY_SIZE][2] = +static const u8 sTradeMonBoxCoords[][PARTY_SIZE][2] = { { // Your party @@ -352,8 +352,8 @@ static const u8 *const sTradeActionTexts[] = static const struct MenuAction sSelectTradeMonActions[] = { - [MENU_ACTION_SUMMARY] = {sText_Summary2, sub_807A000}, - [MENU_ACTION_TRADE] = {sText_Trade2, sub_807A024} + {sText_Summary2, Task_DrawSelectionSummary}, + {sText_Trade2, Task_DrawSelectionTrade} }; static const u8 *const sTradeMessages[] = diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 0b8d89658..af560bc40 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -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); diff --git a/src/link.c b/src/link.c index 9e35ad5c5..e88dcb861 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; @@ -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; } diff --git a/src/party_menu.c b/src/party_menu.c index 94b9de68d..86806b453 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -4685,15 +4685,15 @@ static void CursorCb_Trade2(u8 taskId) { PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[0]); PartyMenuRemoveWindow(&gUnknown_0203CEC4->windowId[1]); - switch (sub_807A918(gPlayerParty, gUnknown_0203CEC8.slotId)) + 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: diff --git a/src/trade.c b/src/trade.c index ae8dc3d27..3c76aec83 100644 --- a/src/trade.c +++ b/src/trade.c @@ -96,10 +96,10 @@ static EWRAM_DATA struct { /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; /*0x0069*/ u8 bufferState; /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; - /*0x006F*/ u8 tradeMenuFunc; //switch var for CallTradeMenuFunc + /*0x006F*/ u8 tradeMenuFunc; /*0x0070*/ u8 neverRead_70; /*0x0071*/ u8 filler_71; - /*0x0072*/ u16 unk_72; //sheet + /*0x0072*/ u16 bottomTextTileStart; /*0x0074*/ u8 drawPartyState[2]; /*0x0076*/ u8 selectedMonIdx[2]; /*0x0078*/ u8 playerLinkFlagChoseAction; @@ -136,7 +136,7 @@ static EWRAM_DATA struct { /*0x90*/ u8 unk_90; //sprite id /*0x91*/ u8 unk_91; //sprite id /*0x92*/ u8 unk_92; //sprite id - /*0x93*/ u8 tradeFinished; + /*0x93*/ u8 sendTradeFinishState; /*0x94*/ u16 state; /*0x96*/ u8 filler_96[0xD2 - 0x96]; /*0xD2*/ u8 pokeballSpriteId; @@ -185,10 +185,10 @@ 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 sub_8079F74(void); +static void PrintNicknamesForTradeMenu(void); static void RedrawTradeMenuParty(u8); -static void sub_807A000(u8 taskId); -static void sub_807A024(u8 taskId); +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); @@ -245,16 +245,16 @@ static bool8 SendLinkData(const void *linkData, u32 size) } } -static void sub_80771AC(u8 a0) // SKP +static void sub_80771AC(u8 a0) { sub_800A4D8(a0); } -static bool32 sub_80771BC(void) // SKP +static bool32 sub_80771BC(void) { if (gUnknown_02022C2C == 29) { - if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) // SKP + if (gUnknown_03007880[sub_800E87C(gUnknown_03004140.unk_00)]->unk_0 == 0) return TRUE; else return FALSE; @@ -294,9 +294,9 @@ static bool32 IsWirelessTrade(void) return FALSE; } -static void sub_8077288(u8 unused) // SKP +static void sub_8077288(u8 unused) { - sub_800ADF8(); // SKP + sub_800ADF8(); } static bool32 _IsLinkTaskFinished(void) @@ -314,8 +314,8 @@ static void InitTradeMenu(void) gPaletteFade.bufferTransferDisabled = TRUE; SetVBlankCallback(VBlankCB_TradeMenu); - LoadPalette(gUnknown_0860F074, 0xF0, 20); // SKP, some interface gfx - LoadPalette(gUnknown_0860F074, 0xD0, 20); // SKP, some interface gfx + LoadPalette(gUnknown_0860F074, 0xF0, 20); + LoadPalette(gUnknown_0860F074, 0xD0, 20); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sTradeMenuBgTemplates, ARRAY_COUNT(sTradeMenuBgTemplates)); SetBgTilemapBuffer(1, sTradeMenuData->tilemapBuffer); @@ -393,9 +393,9 @@ static void CB2_CreateTradeMenu(void) if (gWirelessCommType) { - sub_800B488(); // SKP + sub_800B488(); OpenLink(); - sub_8011BA4(); // SKP + sub_8011BA4(); } else { @@ -437,14 +437,14 @@ static void CB2_CreateTradeMenu(void) case 4: if (gReceivedRemoteLinkPlayers == TRUE && IsLinkPlayerDataExchangeComplete() == TRUE) { - sub_8011BD0(); // SKP + sub_8011BD0(); CalculatePlayerPartyCount(); gMain.state++; sTradeMenuData->timer = 0; if (gWirelessCommType) { - sub_801048C(TRUE); // SKP - sub_800ADF8(); // SKP + sub_801048C(TRUE); + sub_800ADF8(); } } break; @@ -824,7 +824,7 @@ static void LinkTradeWaitForFade(void) } else { - sub_800ABF4(32); // SKP + sub_800ABF4(32); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_START_LINK_TRADE; } } @@ -888,10 +888,10 @@ static void LoadTradeBgGfx(u8 state) 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); + LoadBgTilemap(3, sTradeStripesBG3Tilemap, 0x800, 0); DrawTradeMenuPartyInfo(TRADE_PLAYER); DrawTradeMenuPartyInfo(TRADE_PARTNER); CopyBgTilemapBufferToVram(1); @@ -966,7 +966,7 @@ static bool8 BufferTradeParties(void) sTradeMenuData->timer = 0; break; case 1: - if (sub_80771BC()) // SKP + if (sub_80771BC()) { if (_GetBlockReceivedStatus() == 0) { @@ -982,7 +982,7 @@ static bool8 BufferTradeParties(void) case 3: if (id == 0) { - sub_80771AC(1); // SKP + sub_80771AC(1); } sTradeMenuData->bufferState++; break; @@ -1001,7 +1001,7 @@ static bool8 BufferTradeParties(void) case 7: if (id == 0) { - sub_80771AC(1); // SKP + sub_80771AC(1); } sTradeMenuData->bufferState++; break; @@ -1020,7 +1020,7 @@ static bool8 BufferTradeParties(void) case 11: if (id == 0) { - sub_80771AC(1); // SKP + sub_80771AC(1); } sTradeMenuData->bufferState++; break; @@ -1039,7 +1039,7 @@ static bool8 BufferTradeParties(void) case 15: if (id == 0) { - sub_80771AC(3); // SKP + sub_80771AC(3); } sTradeMenuData->bufferState++; break; @@ -1058,7 +1058,7 @@ static bool8 BufferTradeParties(void) case 19: if (id == 0) { - sub_80771AC(4); // SKP + sub_80771AC(4); } sTradeMenuData->bufferState++; break; @@ -1108,7 +1108,7 @@ static bool8 BufferTradeParties(void) static void PrintAndBufferIsThisTradeOkay(void) { - DrawTextWindowAndBuffer6Bytes(gText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); + DrawTextWindowAndBuffer6Bytes(sText_IsThisTradeOkay, (void *)(OBJ_VRAM0 + (sTradeMenuData->bottomTextTileStart * 32)), 24); } // mpId is unused @@ -1395,17 +1395,17 @@ static void TradeMenuProcessInput(void) { CreateYesNoMenu(&sTradeYesNoWindowTemplate, 1, 14, 0); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_PROMPT; - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CANCEL_TRADE], (void *)(OBJ_VRAM0 + sTradeMenuData->bottomTextTileStart * 32), 24); } } } static void TradeMenuChooseMon(void) { - sub_8079F74(); + PrintNicknamesForTradeMenu(); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_MAIN_MENU; gSprites[sTradeMenuData->cursorSpriteIdx].invisible = FALSE; - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeMenuData->unk_72 * 32), 24); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + sTradeMenuData->bottomTextTileStart * 32), 24); } static void TradeMenuProcessInput_SelectedMon(void) @@ -1418,11 +1418,11 @@ static void TradeMenuProcessInput_SelectedMon(void) break; case MENU_NOTHING_CHOSEN: break; - case MENU_ACTION_SUMMARY: + case 0: // Summary BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SHOW_MON_SUMMARY; break; - case MENU_ACTION_TRADE: + case 1: // Trade switch (CanTradeSelectedMon(gPlayerParty, gPlayerPartyCount, sTradeMenuData->cursorPosition)) { case CAN_TRADE_MON: @@ -1481,9 +1481,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player for (i = 0; i < playerPartyCount; i++) { if (playerMonIdx != i) - { hasLiveMon += aliveMons[i]; - } } partnerMonIdx %= PARTY_SIZE; species = GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_SPECIES); @@ -1492,26 +1490,20 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player if (species == SPECIES_DEOXYS || species == 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 (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) - { return PARTNER_MON_INVALID; - } } if (hasLiveMon) - { - hasLiveMon = PLAYER_MON_VALID; - } + hasLiveMon = BOTH_MONS_VALID; - return hasLiveMon; //PLAYER_MON_INVALID or PLAYER_MON_VALID + return hasLiveMon; //PLAYER_MON_INVALID or BOTH_MONS_VALID } // Returns TRUE if the partner's selected mon is invalid, FALSE otherwise @@ -1531,7 +1523,7 @@ static bool32 QueueMonValidityMessage(void) QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); break; - case PLAYER_MON_VALID: + case BOTH_MONS_VALID: QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); SetLinkData(LINKCMD_INIT_BLOCK, 0); break; @@ -1547,7 +1539,7 @@ static void ConfirmOrCancelTrade(void) { switch (Menu_ProcessInputNoWrapClearOnChoose()) { - case MENU_ACTION_CONFIRM_TRADE: + case 0: // Confirm Trade if (!QueueMonValidityMessage()) { sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; @@ -1558,10 +1550,10 @@ static void ConfirmOrCancelTrade(void) } PutWindowTilemap(17); break; - case MENU_ACTION_CANCEL_TRADE: + case 1: // Cancel Trade case MENU_B_PRESSED: QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); - if (sub_80771BC()) // SKP + if (sub_80771BC()) SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; PutWindowTilemap(17); @@ -1569,7 +1561,6 @@ static void ConfirmOrCancelTrade(void) } } -// TODO: static void sub_807929C(void) { int i; @@ -1662,11 +1653,11 @@ static void CancelTrade_1(void) { if (gWirelessCommType) { - sub_800ADF8(); // SKP + sub_800ADF8(); } else { - sub_800ABF4(12); // SKP + sub_800ABF4(12); } sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_2; @@ -1677,7 +1668,7 @@ static void CancelTrade_2(void) { if (gWirelessCommType) { - if (sub_80771BC() && GetNumQueuedActions() == 0) // SKP + if (sub_80771BC() && GetNumQueuedActions() == 0) { Free(sMessageBoxAllocBuffer); Free(sTradeMenuData); @@ -1700,9 +1691,9 @@ static void CancelTrade_2(void) static void LinkTradeWaitForQueue(void) { - if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0) // SKP + if (!sub_801048C(FALSE) && GetNumQueuedActions() == 0) { - sub_800ADF8(); // SKP + sub_800ADF8(); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_START_LINK_TRADE; } } @@ -1782,7 +1773,7 @@ static void SetSelectedMon(u8 cursorPosition) if (sTradeMenuData->drawPartyState[whichParty] == 0) { - sTradeMenuData->drawPartyState[whichParty] = DRAW_PARTY_BEGIN; + sTradeMenuData->drawPartyState[whichParty] = 1; sTradeMenuData->selectedMonIdx[whichParty] = cursorPosition; } } @@ -1805,7 +1796,7 @@ static void DrawTradeMenuParty(u8 whichParty) switch (sTradeMenuData->drawPartyState[whichParty]) { - case DRAW_PARTY_BEGIN: + case 1: for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { gSprites[sTradeMenuData->partySpriteIds[0][i + (selectedMonParty * PARTY_SIZE)]].invisible = TRUE; @@ -1823,19 +1814,19 @@ static void DrawTradeMenuParty(u8 whichParty) 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, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(0); if (selectedMonParty == TRADE_PLAYER) - sub_8079F74(); + PrintNicknamesForTradeMenu(); break; case 2: if (gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].callback == UpdateTradeMonIconFrame) sTradeMenuData->drawPartyState[whichParty] = 3; break; case 3: - CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, sTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; @@ -1894,7 +1885,7 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) } } - StringCopy(str, gText_EmptyString7); + StringCopy(str, sText_EmptyString7); for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1903,13 +1894,13 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) StringAppend(str, gMoveNames[moves[i]]); } - StringAppend(str, gText_NewLine3); + StringAppend(str, sText_NewLine); } } else { - StringCopy(str, gText_EmptyString7); - StringAppend(str, gText_FourQuestionMarks); + StringCopy(str, sText_EmptyString7); + StringAppend(str, sText_FourQuestionMarks); } } @@ -2008,10 +1999,10 @@ static void DrawTradeMenuPartyInfo(u8 whichParty) for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { DrawTradeMenuPartyMonInfo(whichParty, i, - sTradeMonCoords[whichParty][i][0], - sTradeMonCoords[whichParty][i][1], - sTradeMonBoxDimensions[whichParty][i][0], - sTradeMonBoxDimensions[whichParty][i][1]); + sTradeMonLevelCoords[whichParty][i][0], + sTradeMonLevelCoords[whichParty][i][1], + sTradeMonBoxCoords[whichParty][i][0], + sTradeMonBoxCoords[whichParty][i][1]); } } #else @@ -2032,10 +2023,10 @@ static void DrawTradeMenuPartyInfo(u8 whichParty) bge _08079E94\n\ lsls r0, r6, 1\n\ adds r0, r6\n\ - ldr r1, =sTradeMonCoords\n\ + ldr r1, =sTradeMonLevelCoords\n\ lsls r0, 2\n\ adds r5, r0, r1\n\ - ldr r1, =sTradeMonBoxDimensions\n\ + ldr r1, =sTradeMonBoxCoords\n\ adds r4, r0, r1\n\ _08079E6A:\n\ lsls r1, r7, 24\n\ @@ -2081,33 +2072,31 @@ static void ResetTradeMenuPartyPositions(u8 whichParty) } } -// TODO: -static void sub_8079F74(void) +static void PrintNicknamesForTradeMenu(void) { rbox_fill_rectangle(1); + //PrintPartyNicknamesForTradeMenu(TRADE_PLAYER); ? PrintPartyNicknamesForTradeMenu(TRADE_PARTNER); } static void RedrawTradeMenuParty(u8 whichParty) { - CopyToBgTilemapBufferRect_ChangePalette(1, gTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, sTradePartyBoxTilemap, whichParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); DrawTradeMenuPartyInfo(whichParty); PrintPartyNicknamesForTradeMenu(whichParty); ResetTradeMenuPartyPositions(whichParty); - DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeMenuData->unk_72 * 32)), 24); + DrawTextWindowAndBuffer6Bytes(sTradeActionTexts[TRADE_TEXT_CHOOSE_MON], (void *)(OBJ_VRAM0 + (sTradeMenuData->bottomTextTileStart * 32)), 24); sTradeMenuData->drawPartyState[whichParty] = 0; } -// Unused -static void sub_807A000(u8 taskId) +static void Task_DrawSelectionSummary(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); CopyBgTilemapBufferToVram(0); } -// Unused -static void sub_807A024(u8 taskId) +static void Task_DrawSelectionTrade(u8 taskId) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); CopyBgTilemapBufferToVram(0); @@ -2215,7 +2204,7 @@ static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) sTradeMenuData->timer++; break; case 8: - sTradeMenuData->unk_72 = LoadSpriteSheet(&sheet); + sTradeMenuData->bottomTextTileStart = LoadSpriteSheet(&sheet); sTradeMenuData->timer++; break; case 9 ... 13: @@ -2350,7 +2339,7 @@ static void SaveTradeGiftRibbons(void) static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int monIdx) { - int i, numAliveMons; + int i, numMonsLeft; struct LinkPlayer *player; u32 species[PARTY_SIZE]; u32 species2[PARTY_SIZE]; @@ -2375,8 +2364,8 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if ((player->version & 0xFF) != VERSION_RUBY && (player->version & 0xFF) != VERSION_SAPPHIRE) { - // Has partner not cleared game - if ((player->progressFlagsCopy & 0xF) == 0) + // Does partner not have National Dex + if (!(player->progressFlagsCopy & 0xF)) { if (species2[monIdx] == SPECIES_EGG) return CANT_TRADE_EGG2; @@ -2392,6 +2381,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int return CANT_TRADE_INVALID_MON; } + // Make Eggs not count for numMonsLeft for (i = 0; i < partyCount; i++) { if (species2[i] == SPECIES_EGG) @@ -2399,64 +2389,56 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int } // Count alive mons in party, excluding selected trade mon - for (numAliveMons = 0, i = 0; i < partyCount; i++) + for (numMonsLeft = 0, i = 0; i < partyCount; i++) { if (i != monIdx) - numAliveMons += species2[i]; + numMonsLeft += species2[i]; } - if (numAliveMons != 0) + if (numMonsLeft != 0) return CAN_TRADE_MON; else return CANT_TRADE_LAST_MON; } -// Return values are used to determine exchange status in GetLinkPlayerDataExchangeStatusTimed -// 0: EXCHANGE_COMPLETE -// 1: EXCHANGE_STAT_4 -// 2: EXCHANGE_STAT_5 -//TODO: -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 (isGameFrLg > 0) { - // Does player have National Dex + // Is player champion if (gLinkPlayers[GetMultiplayerId()].progressFlagsCopy & 0xF0) { - if (val == 2) //unnecessary check, val always 2 here + if (isGameFrLg == 2) //unnecessary check, isGameFrLg always 2 here { - // Does partner have National Dex + // Is partner champion if (gLinkPlayers[GetMultiplayerId() ^ 1].progressFlagsCopy & 0xF0) - return 0; + 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) @@ -2562,22 +2544,23 @@ int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, // 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, unk, 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; } } - versions = 0; unk = 1; + versions = 0; for (i = 0; i < GetLinkPlayerCount(); i++) { version = gLinkPlayers[i].version & 0xFF; @@ -2596,8 +2579,8 @@ int sub_807A918(struct Pokemon *mon, u16 monIdx) { struct LinkPlayer *player = &gLinkPlayers[i]; - // Has player not cleared game - if ((player->progressFlags & 0xF) == 0) + // Does player not have National Dex + if (!(player->progressFlags & 0xF)) unk = 0; if (versions && (player->progressFlags / 16)) @@ -2607,37 +2590,29 @@ int sub_807A918(struct Pokemon *mon, u16 monIdx) if (unk == 0) { 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\ @@ -3038,7 +3013,7 @@ void CB2_LinkTrade(void) case 5: sTradeData->playerLinkFlagFinishTrade = 0; sTradeData->partnerLinkFlagFinishTrade = 0; - sTradeData->tradeFinished = 0; + sTradeData->sendTradeFinishState = 0; LoadTradeMonPic(TRADE_PLAYER, 0); gMain.state++; break; @@ -3052,7 +3027,7 @@ void CB2_LinkTrade(void) break; case 8: LoadTradeMonPic(TRADE_PARTNER, 1); - sub_807B154(); + LinkTradeDrawWindow(); gMain.state++; break; case 9: @@ -3067,7 +3042,7 @@ void CB2_LinkTrade(void) gMain.state++; break; case 11: - sub_807B140(); + InitTradeSequenceBgGpuRegs(); BufferTradeSceneStrings(); gMain.state++; break; @@ -3090,14 +3065,13 @@ void CB2_LinkTrade(void) UpdatePaletteFade(); } -void sub_807B140(void) +void InitTradeSequenceBgGpuRegs(void) { SetTradeSequenceBgGpuRegs(5); SetTradeSequenceBgGpuRegs(0); } -// TODO: -void sub_807B154(void) +void LinkTradeDrawWindow(void) { FillWindowPixelBuffer(0, PIXEL_FILL(15)); PutWindowTilemap(0); @@ -3261,19 +3235,19 @@ static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx) TryEnableNationalDexFromLinkPartner(); } -static void sub_807B5B8(void) +static void TrySendTradeFinishData(void) { - switch (sTradeData->tradeFinished) + switch (sTradeData->sendTradeFinishState) { case 1: if (IsLinkTaskFinished()) { Trade_SendData(sTradeData); - sTradeData->tradeFinished++; + sTradeData->sendTradeFinishState++; } // fallthrough case 2: - sTradeData->tradeFinished = 0; + sTradeData->sendTradeFinishState = 0; break; } } @@ -4733,11 +4707,11 @@ static void CB2_UpdateLinkTrade(void) if (!IsWirelessTrade()) { sTradeData->linkData[0] = LINKCMD_READY_FINISH_TRADE; - sTradeData->tradeFinished = 1; + sTradeData->sendTradeFinishState = 1; } SetMainCallback2(CB2_TryFinishTrade); } - sub_807B5B8(); + TrySendTradeFinishData(); UpdateTradeFinishFlags(); RunTasks(); RunTextPrinters(); @@ -4782,7 +4756,7 @@ static void CB2_SaveAndEndTrade(void) DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 1: - sub_8077288(0); // SKP + sub_8077288(0); gMain.state = 100; sTradeData->timer = 0; break; @@ -4813,10 +4787,10 @@ static void CB2_SaveAndEndTrade(void) IncrementGameStat(GAME_STAT_POKEMON_TRADES); if (gWirelessCommType) { - sub_801B990(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId); // SKP + sub_801B990(2, gLinkPlayers[GetMultiplayerId() ^ 1].trainerId); } SetContinueGameWarpStatusToDynamicWarp(); - sub_8153380(); //TODO: save func + sub_8153380(); gMain.state++; sTradeData->timer = 0; break; @@ -4827,7 +4801,7 @@ static void CB2_SaveAndEndTrade(void) } break; case 52: - if (sub_81533AC()) //TODO: save func + if (sub_81533AC()) { ClearContinueGameWarpStatus2(); gMain.state = 4; @@ -4839,7 +4813,7 @@ static void CB2_SaveAndEndTrade(void) } break; case 4: - sub_81533E0(); //TODO: save func + sub_81533E0(); gMain.state = 40; sTradeData->timer = 0; break; @@ -4860,7 +4834,7 @@ static void CB2_SaveAndEndTrade(void) case 41: if (sTradeData->timer == 0) { - sub_8077288(1); // SKP + sub_8077288(1); gMain.state = 42; } else @@ -4871,7 +4845,7 @@ static void CB2_SaveAndEndTrade(void) case 42: if (_IsLinkTaskFinished()) { - sub_8153408(); //TODO: save func + sub_8153408(); gMain.state = 5; } break; @@ -4879,7 +4853,7 @@ static void CB2_SaveAndEndTrade(void) if (++sTradeData->timer > 60) { gMain.state++; - sub_8077288(2); // SKP + sub_8077288(2); } break; case 6: @@ -4901,11 +4875,11 @@ static void CB2_SaveAndEndTrade(void) { if (gWirelessCommType && gMain.savedCallback == CB2_StartCreateTradeMenu) { - sub_8077288(3); // SKP + sub_8077288(3); } else { - sub_800AC34(); // SKP + sub_800AC34(); } gMain.state++; } @@ -5118,7 +5092,7 @@ static void CB2_SaveAndEndWirelessTrade(void) DrawTextOnTradeWindow(0, gStringVar4, 0); break; case 1: - sub_8077288(0); // SKP + sub_8077288(0); gMain.state = 2; sTradeData->timer = 0; break; @@ -5129,7 +5103,7 @@ static void CB2_SaveAndEndWirelessTrade(void) StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower); DrawTextOnTradeWindow(0, gStringVar4, 0); IncrementGameStat(GAME_STAT_POKEMON_TRADES); - sub_8153380(); // TODO: save func + sub_8153380(); sTradeData->timer = 0; } break; @@ -5138,7 +5112,7 @@ static void CB2_SaveAndEndWirelessTrade(void) gMain.state = 4; break; case 4: - if (sub_81533AC()) // TODO: save func + if (sub_81533AC()) { gMain.state = 5; } @@ -5149,7 +5123,7 @@ static void CB2_SaveAndEndWirelessTrade(void) } break; case 5: - sub_81533E0(); //TODO: save func + sub_81533E0(); gMain.state = 6; sTradeData->timer = 0; break; @@ -5166,7 +5140,7 @@ static void CB2_SaveAndEndWirelessTrade(void) case 7: if (sTradeData->timer == 0) { - sub_8077288(1); // SKP + sub_8077288(1); gMain.state = 8; } else @@ -5177,7 +5151,7 @@ static void CB2_SaveAndEndWirelessTrade(void) case 8: if (_IsLinkTaskFinished()) { - sub_8153408(); //TODO: save func + sub_8153408(); gMain.state = 9; } break; @@ -5185,7 +5159,7 @@ static void CB2_SaveAndEndWirelessTrade(void) if (++sTradeData->timer > 60) { gMain.state++; - sub_8077288(2); // SKP + sub_8077288(2); } break; case 10: @@ -5199,7 +5173,7 @@ static void CB2_SaveAndEndWirelessTrade(void) case 11: if (!gPaletteFade.active && IsBGMStopped() == TRUE) { - sub_8077288(3); // SKP + sub_8077288(3); gMain.state = 12; } break; From 3514f9dd6b48f1a0c42a4ea6cb1ab5317fa88c50 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 10 Oct 2019 18:46:42 -0400 Subject: [PATCH 11/11] Clean up trade.c doc --- include/link.h | 12 +-- src/data/trade.h | 26 +++--- src/party_menu.c | 4 +- src/pokemon_storage_system.c | 10 +-- src/trade.c | 153 +++++++++++++++++------------------ 5 files changed, 103 insertions(+), 102 deletions(-) diff --git a/include/link.h b/include/link.h index 04efc973c..cecc7a3f7 100644 --- a/include/link.h +++ b/include/link.h @@ -59,19 +59,19 @@ #define LINKCMD_CONT_BLOCK 0x8888 #define LINKCMD_0xAAAA 0xAAAA #define LINKCMD_0xAAAB 0xAAAB -#define LINKCMD_READY_TO_TRADE 0xAABB // used in trade -#define LINKCMD_READY_FINISH_TRADE 0xABCD // used in trade +#define LINKCMD_READY_TO_TRADE 0xAABB +#define LINKCMD_READY_FINISH_TRADE 0xABCD #define LINKCMD_INIT_BLOCK 0xBBBB -#define LINKCMD_SET_CANCEL_TRADE 0xBBCC // used in trade +#define LINKCMD_READY_CANCEL_TRADE 0xBBCC #define LINKCMD_SEND_HELD_KEYS_2 0xCAFE #define LINKCMD_0xCCCC 0xCCCC -#define LINKCMD_START_TRADE 0xCCDD // all below linkcmds used in trade +#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_0xEEBB 0xEEBB -#define LINKCMD_PARTNER_WANTS_TRADE 0xEECC +#define LINKCMD_CANCEL_TRADE 0xEEBB +#define LINKCMD_0xEECC 0xEECC struct LinkStatus diff --git a/src/data/trade.h b/src/data/trade.h index 7d3f7ba3a..9e96a54dd 100644 --- a/src/data/trade.h +++ b/src/data/trade.h @@ -1,19 +1,21 @@ -static const u32 sUnref_0832C6A8[] = +// Exists unused in RS as well +static const u32 sUnusedStructSizes[] = { - 0x00000F2C, - 0x00003D88, - 0x0000001C, - 0x00000024, - 0x00000064, - 0x00000528 + 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_EmptyString7[] = _(""); -static const u8 sText_ClrWhtHltTrspntShdwDrkGry[] = _("{COLOR WHITE}{HIGHLIGHT TRANSPARENT}{SHADOW DARK_GREY}"); +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[] = _(""); @@ -168,9 +170,9 @@ static const struct SpritePalette gSpritePalette_TradeScreenText = // 2 3 8 9 // 4 5 10 11 // 12 -// 1st array is current position ids +// 1st array is the current positions // 2nd array is directions of input -// 3rd array is the next position ids to go to, stopping at the first occupied position +// 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] = { { @@ -253,7 +255,7 @@ static const u8 sTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][PARTY_SIZE] } }; -static const u8 gTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] = +static const u8 sTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] = { // Your party {1, 5 }, diff --git a/src/party_menu.c b/src/party_menu.c index 86806b453..aa6597532 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -5095,12 +5095,12 @@ void LoadHeldItemIcons(void) LoadSpritePalette(&sSpritePalette_HeldItem); } -void DrawHeldItemIconsForTrade(u8 *partyCounts, u8 *partySpriteIds, u8 who) +void DrawHeldItemIconsForTrade(u8 *partyCounts, u8 *partySpriteIds, u8 whichParty) { u16 i; u16 item; - switch (who) + switch (whichParty) { case TRADE_PLAYER: for (i = 0; i < partyCounts[TRADE_PLAYER]; i++) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index ed87531cb..69a0161e1 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1542,7 +1542,7 @@ static const u8 gHandCursorShadowTiles[] = INCBIN_U8("graphics/pokemon_storage/h // code void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 bytesToBuffer) { - s32 i, tileBytesToBuffer, val2; + s32 i, tileBytesToBuffer, remainingBytes; u16 windowId; u8 txtColor[3]; u8 *tileData1, *tileData2; @@ -1566,7 +1566,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero tileBytesToBuffer = bytesToBuffer; if (tileBytesToBuffer > 6u) tileBytesToBuffer = 6; - val2 = bytesToBuffer - 6; + remainingBytes = bytesToBuffer - 6; if (tileBytesToBuffer > 0) { for (i = tileBytesToBuffer; i != 0; i--) @@ -1579,9 +1579,9 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero } } - // Never used. bytesToBuffer is always passed <= 6, so val2 is always zero here - if (val2 > 0) - CpuFill16((zero2 << 4) | zero2, 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); } diff --git a/src/trade.c b/src/trade.c index 3c76aec83..4d3ce3756 100644 --- a/src/trade.c +++ b/src/trade.c @@ -94,7 +94,7 @@ static EWRAM_DATA struct { /*0x0045*/ bool8 isLiveMon[2][PARTY_SIZE]; /*0x0051*/ bool8 isEgg[2][PARTY_SIZE]; /*0x005D*/ u8 hpBarLevels[2][PARTY_SIZE]; - /*0x0069*/ u8 bufferState; + /*0x0069*/ u8 bufferPartyState; /*0x006A*/ u8 filler_6A[0x6F - 0x6A]; /*0x006F*/ u8 tradeMenuFunc; /*0x0070*/ u8 neverRead_70; @@ -336,7 +336,7 @@ static void InitTradeMenu(void) LoadUserWindowBorderGfx_(0, 20, 0xC0); LoadUserWindowBorderGfx(2, 1, 0xE0); LoadMonIconPalettes(); - sTradeMenuData->bufferState = 0; + sTradeMenuData->bufferPartyState = 0; sTradeMenuData->tradeMenuFunc = 0; sTradeMenuData->neverRead_70 = 0; sTradeMenuData->drawPartyState[TRADE_PLAYER] = 0; @@ -482,8 +482,8 @@ static void CB2_CreateTradeMenu(void) struct Pokemon *mon = &gPlayerParty[i]; sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), UpdateTradeMonIconFrame, - (gTradeMonSpriteCoords[i][0] * 8) + 14, - (gTradeMonSpriteCoords[i][1] * 8) - 12, + (sTradeMonSpriteCoords[i][0] * 8) + 14, + (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), TRUE); @@ -494,8 +494,8 @@ static void CB2_CreateTradeMenu(void) struct Pokemon *mon = &gEnemyParty[i]; sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), UpdateTradeMonIconFrame, - (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, - (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, + (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, + (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), FALSE); @@ -557,7 +557,7 @@ static void CB2_CreateTradeMenu(void) CreateSprite(&temp, (i * 32) + 24, 150, 1); } - sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[0][0] * 8 + 32, gTradeMonSpriteCoords[0][1] * 8, 2); + sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, sTradeMonSpriteCoords[0][0] * 8 + 32, sTradeMonSpriteCoords[0][1] * 8, 2); sTradeMenuData->cursorPosition = 0; gMain.state++; rbox_fill_rectangle(0); @@ -669,8 +669,8 @@ static void CB2_ReturnToTradeMenu(void) struct Pokemon *mon = &gPlayerParty[i]; sTradeMenuData->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), UpdateTradeMonIconFrame, - (gTradeMonSpriteCoords[i][0] * 8) + 14, - (gTradeMonSpriteCoords[i][1] * 8) - 12, + (sTradeMonSpriteCoords[i][0] * 8) + 14, + (sTradeMonSpriteCoords[i][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), TRUE); @@ -681,8 +681,8 @@ static void CB2_ReturnToTradeMenu(void) struct Pokemon *mon = &gEnemyParty[i]; sTradeMenuData->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), UpdateTradeMonIconFrame, - (gTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, - (gTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, + (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, + (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, 1, GetMonData(mon, MON_DATA_PERSONALITY), FALSE); @@ -749,7 +749,7 @@ static void CB2_ReturnToTradeMenu(void) else sTradeMenuData->cursorPosition = gLastViewedMonIndex + PARTY_SIZE; - sTradeMenuData->cursorSpriteIdx = CreateSprite(&gSpriteTemplate_832DC94, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][0] * 8 + 32, gTradeMonSpriteCoords[sTradeMenuData->cursorPosition][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: @@ -958,11 +958,11 @@ static bool8 BufferTradeParties(void) int i; struct Pokemon *mon; - switch (sTradeMenuData->bufferState) + switch (sTradeMenuData->bufferPartyState) { case 0: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[0], 2 * sizeof(struct Pokemon)); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; sTradeMenuData->timer = 0; break; case 1: @@ -970,12 +970,12 @@ static bool8 BufferTradeParties(void) { if (_GetBlockReceivedStatus() == 0) { - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } else { TradeResetReceivedFlags(); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } } break; @@ -984,90 +984,90 @@ static bool8 BufferTradeParties(void) { sub_80771AC(1); } - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 4: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[0], gBlockRecvBuffer[id ^ 1], 2 * sizeof(struct Pokemon)); TradeResetReceivedFlags(); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } break; case 5: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[2], 2 * sizeof(struct Pokemon)); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 7: if (id == 0) { sub_80771AC(1); } - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 8: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[2], gBlockRecvBuffer[id ^ 1], 200); TradeResetReceivedFlags(); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } break; case 9: Trade_Memcpy(gBlockSendBuffer, &gPlayerParty[4], 200); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 11: if (id == 0) { sub_80771AC(1); } - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 12: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(&gEnemyParty[4], gBlockRecvBuffer[id ^ 1], 200); TradeResetReceivedFlags(); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } break; case 13: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->mail, 220); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 15: if (id == 0) { sub_80771AC(3); } - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 16: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(gTradeMail, gBlockRecvBuffer[id ^ 1], 216); TradeResetReceivedFlags(); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } break; case 17: Trade_Memcpy(gBlockSendBuffer, gSaveBlock1Ptr->giftRibbons, ARRAY_COUNT(sTradeMenuData->giftRibbons)); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 19: if (id == 0) { sub_80771AC(4); } - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; break; case 20: if (_GetBlockReceivedStatus() == 3) { Trade_Memcpy(sTradeMenuData->giftRibbons, gBlockRecvBuffer[id ^ 1], ARRAY_COUNT(sTradeMenuData->giftRibbons)); TradeResetReceivedFlags(); - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } break; case 21: @@ -1090,6 +1090,7 @@ static bool8 BufferTradeParties(void) } } return TRUE; + // Delay until next state case 2: case 6: case 10: @@ -1099,7 +1100,7 @@ static bool8 BufferTradeParties(void) if (sTradeMenuData->timer > 10) { sTradeMenuData->timer = 0; - sTradeMenuData->bufferState++; + sTradeMenuData->bufferPartyState++; } break; } @@ -1127,7 +1128,7 @@ static void UpdateLinkTradeFlags(u8 mpId, u8 status) case LINKCMD_INIT_BLOCK: sTradeMenuData->playerLinkFlagStatus = INITIATE_TRADE; break; - case LINKCMD_SET_CANCEL_TRADE: + case LINKCMD_READY_CANCEL_TRADE: sTradeMenuData->playerLinkFlagStatus = CANCEL_TRADE; break; } @@ -1148,7 +1149,7 @@ static void UpdateLinkTradeFlags(u8 mpId, u8 status) case LINKCMD_INIT_BLOCK: sTradeMenuData->partnerLinkFlagStatus = INITIATE_TRADE; break; - case LINKCMD_SET_CANCEL_TRADE: + case LINKCMD_READY_CANCEL_TRADE: sTradeMenuData->partnerLinkFlagStatus = CANCEL_TRADE; break; } @@ -1163,12 +1164,12 @@ static void ReactToLinkTradeData(u8 mpId, u8 status) { switch (gBlockRecvBuffer[0][0]) { - case 0xEEBB: + case LINKCMD_CANCEL_TRADE: BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); PrintTradeMessage(TRADE_MSG_WAITING_FOR_FRIEND); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CANCEL_TRADE_1; break; - case 0xEECC: + case LINKCMD_0xEECC: PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; break; @@ -1183,7 +1184,7 @@ static void ReactToLinkTradeData(u8 mpId, u8 status) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_LINK_TRADE_WAIT_FADE; break; - case 0xDDEE: + case LINKCMD_0xDDEE: PrintTradeMessage(TRADE_MSG_CANCELED); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_REDRAW_MAIN_MENU; } @@ -1211,7 +1212,7 @@ static void QueueLinkTradeData(void) && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeMenuData->linkData[0] = 0xEECC; + sTradeMenuData->linkData[0] = LINKCMD_0xEECC; sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; @@ -1222,7 +1223,7 @@ static void QueueLinkTradeData(void) && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_TRADE) { PrintTradeMessage(TRADE_MSG_FRIEND_WANTS_TO_TRADE); - sTradeMenuData->linkData[0] = 0xDDEE; + sTradeMenuData->linkData[0] = LINKCMD_0xDDEE; sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); sTradeMenuData->playerLinkFlagStatus = sTradeMenuData->partnerLinkFlagStatus = 0; @@ -1232,7 +1233,7 @@ static void QueueLinkTradeData(void) else if (sTradeMenuData->playerLinkFlagChoseAction == WANTS_TO_CANCEL && sTradeMenuData->partnerLinkFlagChoseAction == WANTS_TO_CANCEL) { - sTradeMenuData->linkData[0] = 0xEEBB; + sTradeMenuData->linkData[0] = LINKCMD_CANCEL_TRADE; sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); @@ -1258,7 +1259,7 @@ static void QueueLinkTradeData(void) || sTradeMenuData->partnerLinkFlagStatus == CANCEL_TRADE) { PrintTradeMessage(TRADE_MSG_CANCELED); - sTradeMenuData->linkData[0] = 0xDDEE; + sTradeMenuData->linkData[0] = LINKCMD_0xDDEE; sTradeMenuData->linkData[1] = 0; QueueAction(QUEUE_DELAY_DATA, QUEUE_SEND_DATA); sTradeMenuData->playerLinkFlagStatus = 0; @@ -1327,8 +1328,8 @@ static void TradeMenuMoveCursor(u8 *cursorPosition, u8 direction) else { StartSpriteAnim(&gSprites[sTradeMenuData->cursorSpriteIdx], 0); - gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = gTradeMonSpriteCoords[newPosition][0] * 8 + 32; - gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = gTradeMonSpriteCoords[newPosition][1] * 8; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.x = sTradeMonSpriteCoords[newPosition][0] * 8 + 32; + gSprites[sTradeMenuData->cursorSpriteIdx].pos1.y = sTradeMonSpriteCoords[newPosition][1] * 8; } if (*cursorPosition != newPosition) @@ -1474,7 +1475,7 @@ static void TradeMenuShowMonSummaryScreen(void) static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 playerMonIdx, u8 partnerMonIdx) { int i; - u16 species; + u16 partnerSpecies; u8 hasLiveMon = 0; // Make sure mon to be traded isn't player's last alive mon @@ -1484,10 +1485,10 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player hasLiveMon += aliveMons[i]; } partnerMonIdx %= PARTY_SIZE; - species = GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_SPECIES); + partnerSpecies = GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_SPECIES); // Partner cant trade illegitimate Deoxys or Mew - if (species == SPECIES_DEOXYS || species == SPECIES_MEW) + if (partnerSpecies == SPECIES_DEOXYS || partnerSpecies == SPECIES_MEW) { if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_OBEDIENCE)) return PARTNER_MON_INVALID; @@ -1496,7 +1497,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player // Partner cant trade Egg or non-Hoenn mon if player doesn't have National Dex if (!IsNationalPokedexEnabled()) { - if (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(species)) + if (sTradeMenuData->isEgg[TRADE_PARTNER][partnerMonIdx] || !IsSpeciesInHoennDex(partnerSpecies)) return PARTNER_MON_INVALID; } @@ -1507,7 +1508,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player } // Returns TRUE if the partner's selected mon is invalid, FALSE otherwise -static bool32 QueueMonValidityMessage(void) +static bool32 CheckMonsBeforeTrade(void) { int i; u8 aliveMons[PARTY_SIZE * 2]; @@ -1521,7 +1522,7 @@ static bool32 QueueMonValidityMessage(void) { case PLAYER_MON_INVALID: QueueAction(QUEUE_DELAY_MSG, QUEUE_ONLY_MON2); - SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); break; case BOTH_MONS_VALID: QueueAction(QUEUE_DELAY_MSG, QUEUE_STANDBY); @@ -1540,21 +1541,18 @@ static void ConfirmOrCancelTrade(void) switch (Menu_ProcessInputNoWrapClearOnChoose()) { case 0: // Confirm Trade - if (!QueueMonValidityMessage()) - { + 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_SET_CANCEL_TRADE, 0); + SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; PutWindowTilemap(17); break; @@ -1599,7 +1597,7 @@ static void SetBothSelectedMons(void) SetSelectedMon(sTradeMenuData->cursorPosition); SetSelectedMon(sTradeMenuData->partnerCursorPosition); } - sTradeMenuData->tradeMenuFunc = 7; + sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_CONFIRM_TRADE_PROMPT; } static void ConfirmTradePrompt(void) @@ -1702,7 +1700,7 @@ static void PartnersMonWasInvalid(void) { if (gMain.newKeys & A_BUTTON) { - SetLinkData(LINKCMD_SET_CANCEL_TRADE, 0); + SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; } } @@ -1809,8 +1807,8 @@ static void DrawTradeMenuParty(u8 whichParty) 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] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].data[4] = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + 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)]]); @@ -1828,8 +1826,8 @@ static void DrawTradeMenuParty(u8 whichParty) case 3: CopyToBgTilemapBufferRect_ChangePalette(1, sTradeMovesBoxTilemap, selectedMonParty * 15, 0, 15, 17, 0); CopyBgTilemapBufferToVram(1); - gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.x = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][0] + gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE + 1][0]) / 2 * 8 + 14; - gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].pos1.y = (gTradeMonSpriteCoords[selectedMonParty * PARTY_SIZE][1] * 8) - 12; + 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); @@ -1885,7 +1883,7 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) } } - StringCopy(str, sText_EmptyString7); + StringCopy(str, sText_EmptyString); for (i = 0; i < MAX_MON_MOVES; i++) { @@ -1899,7 +1897,7 @@ static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) } else { - StringCopy(str, sText_EmptyString7); + StringCopy(str, sText_EmptyString); StringAppend(str, sText_FourQuestionMarks); } } @@ -2065,8 +2063,8 @@ static void ResetTradeMenuPartyPositions(u8 whichParty) for (i = 0; i < sTradeMenuData->partyCounts[whichParty]; i++) { gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].invisible = FALSE; - gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos1.x = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][0] * 8 + 14; - gSprites[sTradeMenuData->partySpriteIds[whichParty][i]].pos1.y = gTradeMonSpriteCoords[(whichParty * PARTY_SIZE) + i][1] * 8 - 12; + 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; } @@ -2418,6 +2416,7 @@ s32 GetGameProgressForLinkTrade(void) else if (version == VERSION_FIRE_RED || version == VERSION_LEAF_GREEN) isGameFrLg = 2; + // If trading with FRLG, both players must be champion if (isGameFrLg > 0) { // Is player champion @@ -2451,13 +2450,13 @@ static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isObedientBitSet) return FALSE; } -int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, struct UnkLinkRfuStruct_02022B14Substruct a1, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, u8 isObedientBitSet) +int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct rfuPlayer, struct UnkLinkRfuStruct_02022B14Substruct rfuPartner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, u8 isObedientBitSet) { - bool8 playerHasNationalDex = a0.hasNationalDex; - bool8 playerIsChampion = a0.isChampion; - bool8 partnerHasNationalDex = a1.hasNationalDex; - bool8 partnerIsChampion = a1.isChampion; - 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) { @@ -2522,9 +2521,9 @@ int GetUnionRoomTradeMessageId(struct UnkLinkRfuStruct_02022B14Substruct a0, str return UR_TRADE_MSG_NONE; } -int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, u16 species2, u16 species, u8 isObedientBitSet) +int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct rfuPlayer, u16 species2, u16 species, u8 isObedientBitSet) { - bool8 hasNationalDex = a0.hasNationalDex; + bool8 hasNationalDex = rfuPlayer.hasNationalDex; if (IsDeoxysOrMewUntradable(species, isObedientBitSet)) return CANT_REGISTER_MON; @@ -2546,7 +2545,7 @@ int CanRegisterMonForTradingBoard(struct UnkLinkRfuStruct_02022B14Substruct a0, #ifdef NONMATCHING int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) { - int i, version, versions, unk, numMonsLeft; + int i, version, versions, canTradeAnyMon, numMonsLeft; int speciesArray[PARTY_SIZE]; // Make Eggs not count for numMonsLeft @@ -2559,7 +2558,7 @@ int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) } } - unk = 1; + canTradeAnyMon = TRUE; versions = 0; for (i = 0; i < GetLinkPlayerCount(); i++) { @@ -2581,13 +2580,13 @@ int CanTradeSelectedPartyMenuMon(struct Pokemon *mon, u16 monIdx) // Does player not have National Dex if (!(player->progressFlags & 0xF)) - unk = 0; + canTradeAnyMon = FALSE; if (versions && (player->progressFlags / 16)) - unk = 0; + canTradeAnyMon = FALSE; } - if (unk == 0) + if (canTradeAnyMon == FALSE) { if (!IsSpeciesInHoennDex(speciesArray[monIdx])) return CANT_TRADE_NATIONAL;