Move union room data, more trade doc

This commit is contained in:
GriffinR 2019-10-04 17:24:03 -04:00
parent 2b0c944286
commit 6b556900f8
11 changed files with 1134 additions and 1117 deletions

View File

@ -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

View File

@ -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;
};

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

@ -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,

1039
src/data/union_room.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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]);

View File

@ -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))
{

File diff suppressed because it is too large Load Diff