Sync trade

This commit is contained in:
GriffinR 2022-12-09 12:34:55 -05:00
parent dc24fde7f6
commit 347a02ace1
10 changed files with 813 additions and 813 deletions

View File

@ -148,7 +148,7 @@ void AnimThrowProjectile(struct Sprite *sprite);
void GetBgDataForTransform(struct BattleAnimBgData *dest, u8 battlerId);
u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId, bool32 ignoreDeoxysForm);
void ResetSpriteRotScale_PreserveAffine(struct Sprite *sprite);
void TradeMenuBouncePartySprites(struct Sprite *sprite);
void Trade_MoveSelectedMonToTarget(struct Sprite *sprite);
void DestroyAnimVisualTaskAndDisableBlend(u8 taskId);
void DestroySpriteAndFreeResources_(struct Sprite *sprite);
void SetBattlerSpriteYOffsetFromOtherYScale(u8 spriteId, u8 otherSpriteId);

View File

@ -12,21 +12,13 @@
#define INGAME_TRADE_HORSEA 2
#define INGAME_TRADE_MEOWTH 3
// Flag IDs for sending link data
#define INITIATE_TRADE 1
#define CANCEL_TRADE 2
#define WANTS_TO_TRADE 1
#define WANTS_TO_CANCEL 2
#define READY_FINISH_TRADE 1
#define FINISH_TRADE 2
// Return values for CanTradeSelectedMon and CanSpinTradeMon
#define CAN_TRADE_MON 0
#define CANT_TRADE_LAST_MON 1
#define CANT_TRADE_NATIONAL 2
#define CANT_TRADE_EGG_YET 3
#define CANT_TRADE_INVALID_MON 4
#define CANT_TRADE_EGG_YET2 5
#define CAN_TRADE_MON 0
#define CANT_TRADE_LAST_MON 1
#define CANT_TRADE_NATIONAL 2
#define CANT_TRADE_EGG_YET 3
#define CANT_TRADE_INVALID_MON 4
#define CANT_TRADE_PARTNER_EGG_YET 5
// Return values for CheckValidityOfTradeMons
#define PLAYER_MON_INVALID 0
@ -38,63 +30,6 @@
#define TRADE_PLAYER_NOT_READY 1
#define TRADE_PARTNER_NOT_READY 2
// Indexes for sTradeActionTexts
#define TRADE_TEXT_CANCEL 0
#define TRADE_TEXT_CHOOSE_MON 1
#define TRADE_TEXT_SUMMARY 2
#define TRADE_TEXT_TRADE 3
#define TRADE_TEXT_CANCEL_TRADE 4
#define TRADE_TEXT_JP_QUIT 5
// Checked to confirm DrawTradeMenuParty has reached final state
#define DRAW_PARTY_FINISH 5
// Message indexes for sTradeMessages
#define TRADE_MSG_STANDBY 0
#define TRADE_MSG_CANCELED 1
#define TRADE_MSG_ONLY_MON1 2
#define TRADE_MSG_ONLY_MON2 3
#define TRADE_MSG_WAITING_FOR_FRIEND 4
#define TRADE_MSG_FRIEND_WANTS_TO_TRADE 5
#define TRADE_MSG_MON_CANT_BE_TRADED 6
#define TRADE_MSG_EGG_CANT_BE_TRADED 7
#define TRADE_MSG_FRIENDS_MON_CANT_BE_TRADED 8
// IDs for QueueAction
#define QUEUE_SEND_DATA 0
#define QUEUE_STANDBY 1
#define QUEUE_ONLY_MON1 2
#define QUEUE_ONLY_MON2 3
#define QUEUE_UNUSED1 4
#define QUEUE_UNUSED2 5
#define QUEUE_MON_CANT_BE_TRADED 6
#define QUEUE_EGG_CANT_BE_TRADED 7
#define QUEUE_FRIENDS_MON_CANT_BE_TRADED 8
#define QUEUE_DELAY_MSG 3
#define QUEUE_DELAY_DATA 5
// IDs for CallTradeMenuFunc
#define TRADEMENUFUNC_MAIN_MENU 0
#define TRADEMENUFUNC_SELECTED_MON 1
#define TRADEMENUFUNC_SHOW_MON_SUMMARY 2
#define TRADEMENUFUNC_CONFIRM_OR_CANCEL_TRADE 3
#define TRADEMENUFUNC_CANCEL_TRADE_PROMPT 4
#define TRADEMENUFUNC_UNUSED_5 5
#define TRADEMENUFUNC_BOTH_MONS_SELECTED 6
#define TRADEMENUFUNC_CONFIRM_TRADE_PROMPT 7
#define TRADEMENUFUNC_REDRAW_MAIN_MENU 8
#define TRADEMENUFUNC_LINK_TRADE_FADE_OUT 9
#define TRADEMENUFUNC_LINK_TRADE_WAIT_FADE 10
#define TRADEMENUFUNC_CANCEL_TRADE_1 11
#define TRADEMENUFUNC_CANCEL_TRADE_2 12
#define TRADEMENUFUNC_START_LINK_TRADE 13
#define TRADEMENUFUNC_DELAY_TRADE_CONFIRM 14
#define TRADEMENUFUNC_UNUSED_15 15
#define TRADEMENUFUNC_LINK_TRADE_WAIT_QUEUE 16
#define TRADEMENUFUNC_PARTNER_MON_INVALID 17
#define TRADEMENUFUNC_STANDBY 100
// Message indexes for sUnionRoomTradeMessages
#define UR_TRADE_MSG_NONE 0
#define UR_TRADE_MSG_NOT_MON_PARTNER_WANTS 1

View File

@ -83,7 +83,7 @@ struct RfuGameCompatibilityData
u16 hasNews:1;
u16 hasCard:1;
u16 unknown:1; // Never read
u16 isChampion:1;
u16 canLinkNationally:1;
u16 hasNationalDex:1;
u16 gameClear:1;
u16 version:4;

View File

@ -1047,7 +1047,7 @@ void UpdateAnimBg3ScreenSize(bool8 largeScreenSize)
}
}
void TradeMenuBouncePartySprites(struct Sprite *sprite)
void Trade_MoveSelectedMonToTarget(struct Sprite *sprite)
{
sprite->data[1] = sprite->x;
sprite->data[3] = sprite->y;

View File

@ -301,11 +301,28 @@ const struct OamData gOamData_BattleSpritePlayerSide =
.affineParam = 0,
};
// Unknown and unused data. Feel free to remove.
static const u16 sUnused1[] = {0, 5, 0xfffe, 0};
static const u16 *const sUnused1Ptr = sUnused1;
static const u16 sUnused2[] = {0xfff0, 0, 0x0400, 0, 0, 0, 0x3c00, 0, 0x7ffe, 1, 0, 0};
static const u16 *const sUnused2Ptr = sUnused2;
static const union AnimCmd sAnim_Unused[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_JUMP(0),
};
static const union AnimCmd *const sAnims_Unused[] =
{
sAnim_Unused,
};
static const union AffineAnimCmd sAffineAnim_Unused[] =
{
AFFINEANIMCMD_FRAME(-0x10, 0x0, 0, 4),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 0x3C),
AFFINEANIMCMD_JUMP(1),
};
static const union AffineAnimCmd *const sAffineAnims_Unused[] =
{
sAffineAnim_Unused,
};
static const s8 sCenterToCornerVecXs[8] ={-32, -16, -16, -32, -32};

View File

@ -55,7 +55,7 @@ static const u8 sText_OnlyPkmnForBattle[] = _("That's your only\nPOKéMON for ba
static const u8 sText_WaitingForYourFriend[] = _("{COLOR DARK_GRAY}{HIGHLIGHT WHITE}{SHADOW LIGHT_GRAY}Waiting for your friend\nto finish…");
static const u8 sText_YourFriendWantsToTrade[] = _("Your friend wants\nto trade POKéMON.");
static const struct OamData sTradeOamData_32x16 =
static const struct OamData sOamData_MenuText =
{
.shape = SPRITE_SHAPE(32x16),
.size = SPRITE_SIZE(32x16),
@ -167,17 +167,17 @@ static const struct SpriteTemplate sSpriteTemplate_MenuText =
{
.tileTag = GFXTAG_MENU_TEXT,
.paletteTag = PALTAG_MENU_TEXT,
.oam = &sTradeOamData_32x16,
.oam = &sOamData_MenuText,
.anims = sAnims_MenuText,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
static const u16 sTradeScreenTextPalette[] = INCBIN_U16("graphics/trade/text.gbapal");
static const struct SpritePalette sSpritePalette_TradeScreenText =
static const u16 sMenuText_Pal[] = INCBIN_U16("graphics/trade/text.gbapal");
static const struct SpritePalette sSpritePalette_MenuText =
{
.data = sTradeScreenTextPalette,
.data = sMenuText_Pal,
.tag = PALTAG_MENU_TEXT
};
@ -193,7 +193,7 @@ static const struct SpritePalette sSpritePalette_TradeScreenText =
// 1st array is the current positions
// 2nd array is directions of input
// 3rd array is the next positions to go to (unoccupied spaces are skipped over)
static const u8 sTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][PARTY_SIZE] =
static const u8 sCursorMoveDestinations[(PARTY_SIZE * 2) + 1][4][PARTY_SIZE] =
{
{
{4, 2, 12, 12, 0, 0}, // UP
@ -275,86 +275,67 @@ static const u8 sTradeNextSelectedMonTable[(PARTY_SIZE * 2) + 1][4][PARTY_SIZE]
}
};
#define COL0_X 1
#define COL1_X 8
#define COL2_X 16
#define COL3_X 23
#define ROW0_Y 5
#define ROW1_Y 10
#define ROW2_Y 15
#define ROW3_Y 18
static const u8 sTradeMonSpriteCoords[(PARTY_SIZE * 2) + 1][2] =
{
// Your party
{1, 5 },
{8, 5 },
{1, 10},
{8, 10},
{1, 15},
{8, 15},
// Friend's party
{16, 5 },
{23, 5 },
{16, 10},
{23, 10},
{16, 15},
{23, 15},
{23, 18} // CANCEL
// Player's party
{COL0_X, ROW0_Y },
{COL1_X, ROW0_Y },
{COL0_X, ROW1_Y},
{COL1_X, ROW1_Y},
{COL0_X, ROW2_Y},
{COL1_X, ROW2_Y},
// Partners's party
{COL2_X, ROW0_Y },
{COL3_X, ROW0_Y },
{COL2_X, ROW1_Y},
{COL3_X, ROW1_Y},
{COL2_X, ROW2_Y},
{COL3_X, ROW2_Y},
// Cancel
{COL3_X, ROW3_Y}
};
static const u8 sTradeMonLevelCoords[][2][2] =
{
// Your party
{
{5, 4},
{12, 4},
},
{
{5, 9},
{12, 9},
},
{
{5, 14},
static const u8 sTradeMonLevelCoords[PARTY_SIZE * 2][2] = {
[TRADE_PLAYER] =
{ 5, 4},
{12, 4},
{ 5, 9},
{12, 9},
{ 5, 14},
{12, 14},
},
// Friend's party
{
{20, 4},
{27, 4},
},
{
{20, 9},
{27, 9},
},
{
[TRADE_PARTNER * PARTY_SIZE] =
{20, 4},
{27, 4},
{20, 9},
{27, 9},
{20, 14},
{27, 14},
},
};
static const u8 sTradeMonBoxCoords[][2][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},
},
{
static const u8 sTradeMonBoxCoords[PARTY_SIZE * 2][2] = {
[TRADE_PLAYER] =
{ 1, 3},
{ 8, 3},
{ 1, 8},
{ 8, 8},
{ 1, 13},
{ 8, 13},
[TRADE_PARTNER * PARTY_SIZE] =
{16, 3},
{23, 3},
{16, 8},
{23, 8},
{16, 13},
{23, 13},
},
};
static const u8 sUnusedCoords[][2] =
@ -379,14 +360,14 @@ static const u8 sUnusedCoords[][2] =
{23, 12}
};
static const u8 *const sTradeActionTexts[] =
static const u8 *const sActionTexts[] =
{
[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
[TEXT_CANCEL] = sText_Cancel,
[TEXT_CHOOSE_MON] = sText_ChooseAPkmn,
[TEXT_SUMMARY] = sText_Summary,
[TEXT_TRADE] = sText_Trade,
[TEXT_CANCEL_TRADE] = sText_CancelTrade,
[TEXT_JP_QUIT] = sJPText_PressBButtonToQuit
};
static const struct MenuAction sSelectTradeMonActions[] =
@ -395,17 +376,17 @@ static const struct MenuAction sSelectTradeMonActions[] =
{sText_Trade2, Task_DrawSelectionTrade}
};
static const u8 *const sTradeMessages[] =
static const u8 *const sMessages[] =
{
[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
[MSG_STANDBY] = sText_CommunicationStandby,
[MSG_CANCELED] = sText_TheTradeHasBeenCanceled,
[MSG_ONLY_MON1] = sText_OnlyPkmnForBattle,
[MSG_ONLY_MON2] = gText_OnlyPkmnForBattle, //identical text to above
[MSG_WAITING_FOR_FRIEND] = sText_WaitingForYourFriend,
[MSG_FRIEND_WANTS_TO_TRADE] = sText_YourFriendWantsToTrade,
[MSG_MON_CANT_BE_TRADED] = gText_PkmnCantBeTradedNow,
[MSG_EGG_CANT_BE_TRADED] = gText_EggCantBeTradedNow,
[MSG_FRIENDS_MON_CANT_BE_TRADED] = gText_OtherTrainersPkmnCantBeTraded
};
static const u8 sTradeTextColors[] =
@ -415,7 +396,7 @@ static const u8 sTradeTextColors[] =
TEXT_COLOR_DARK_GRAY //shadow color
};
static const struct BgTemplate sTradeMenuBgTemplates[] =
static const struct BgTemplate sBgTemplates[] =
{
{
.bg = 0,
@ -455,7 +436,7 @@ static const struct BgTemplate sTradeMenuBgTemplates[] =
},
};
static const struct WindowTemplate sTradeMenuWindowTemplates[] =
static const struct WindowTemplate sWindowTemplates[] =
{
{
.bg = 0,
@ -633,8 +614,8 @@ static const struct WindowTemplate sTradeYesNoWindowTemplate =
.baseBlock = 582
};
static const u8 sJPText_Shedinja[] = _("ヌケニン");
static const u8 sTradeMenuPartyMonBoxDimensions[3][2] =
static const u8 sText_ShedinjaJP[] = _("ヌケニン");
static const u8 sSelectedMonLevelGenderCoords[3][2] =
{
[TRADE_PLAYER] = {4, 3},
[TRADE_PARTNER] = {19, 3}

View File

@ -677,7 +677,7 @@ void InitHostRfuGameData(struct RfuGameData *data, u8 activity, bool32 startedAc
data->compatibility.hasNews = FALSE;
data->compatibility.hasCard = FALSE;
data->compatibility.unknown = FALSE;
data->compatibility.isChampion = FlagGet(FLAG_IS_CHAMPION);
data->compatibility.canLinkNationally = FlagGet(FLAG_IS_CHAMPION);
data->compatibility.hasNationalDex = IsNationalPokedexEnabled();
data->compatibility.gameClear = FlagGet(FLAG_SYS_GAME_CLEAR);
}

File diff suppressed because it is too large Load Diff

View File

@ -689,8 +689,8 @@ void TryPrepareSecondApproachingTrainer(void)
#define sLocalId data[0]
#define sMapNum data[1]
#define sMapGroup data[2]
#define sData3 data[3]
#define sData4 data[4]
#define sYVelocity data[3]
#define sYOffset data[4]
#define sFldEffId data[7]
u8 FldEff_ExclamationMarkIcon(void)
@ -736,7 +736,7 @@ static void SetIconSpriteData(struct Sprite *sprite, u16 fldEffId, u8 spriteAnim
sprite->sLocalId = gFieldEffectArguments[0];
sprite->sMapNum = gFieldEffectArguments[1];
sprite->sMapGroup = gFieldEffectArguments[2];
sprite->sData3 = -5;
sprite->sYVelocity = -5;
sprite->sFldEffId = fldEffId;
StartSpriteAnim(sprite, spriteAnimNum);
@ -754,23 +754,23 @@ static void SpriteCB_TrainerIcons(struct Sprite *sprite)
else
{
struct Sprite *objEventSprite = &gSprites[gObjectEvents[objEventId].spriteId];
sprite->sData4 += sprite->sData3;
sprite->sYOffset += sprite->sYVelocity;
sprite->x = objEventSprite->x;
sprite->y = objEventSprite->y - 16;
sprite->x2 = objEventSprite->x2;
sprite->y2 = objEventSprite->y2 + sprite->sData4;
if (sprite->sData4)
sprite->sData3++;
sprite->y2 = objEventSprite->y2 + sprite->sYOffset;
if (sprite->sYOffset)
sprite->sYVelocity++;
else
sprite->sData3 = 0;
sprite->sYVelocity = 0;
}
}
#undef sLocalId
#undef sMapNum
#undef sMapGroup
#undef sData3
#undef sData4
#undef sYVelocity
#undef sYOffset
#undef sFldEffId
u8 GetCurrentApproachingTrainerObjectEventId(void)

View File

@ -1271,7 +1271,7 @@ static u32 IsTryingToTradeAcrossVersionTooSoon(struct WirelessLink_Group *data,
{
if (!(gSaveBlock2Ptr->specialSaveWarpFlags & CHAMPION_SAVEWARP))
return UR_TRADE_PLAYER_NOT_READY;
else if (partner->rfu.data.compatibility.isChampion)
else if (partner->rfu.data.compatibility.canLinkNationally)
return UR_TRADE_READY;
}
else