Document more trade.c

This commit is contained in:
GriffinR 2019-10-06 22:58:25 -04:00
parent 66a68159b1
commit d1bcd60b58
10 changed files with 370 additions and 358 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff