More trade documentation

This commit is contained in:
GriffinR 2019-10-09 05:56:44 -04:00
parent d1bcd60b58
commit 2c062dc764
21 changed files with 1132 additions and 1109 deletions

View File

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

View File

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

View File

@ -59,20 +59,19 @@
#define LINKCMD_CONT_BLOCK 0x8888
#define LINKCMD_0xAAAA 0xAAAA
#define LINKCMD_0xAAAB 0xAAAB
#define LINKCMD_0xAABB 0xAABB // used in trade
#define LINKCMD_READY_TO_TRADE 0xAABB // used in trade
#define LINKCMD_0xABCD 0xABCD // used in trade
#define LINKCMD_INIT_BLOCK 0xBBBB
#define LINKCMD_0xBBCC 0xBBCC // used in trade
#define LINKCMD_SET_CANCEL_TRADE 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_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

View File

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

View File

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

View File

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

View File

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

View File

@ -1491,7 +1491,7 @@ static void CB2_PreInitMultiBattle(void)
case 3:
if (gWirelessCommType)
{
if (sub_8010500())
if (IsLinkRfuTaskFinished())
{
gBattleTypeFlags = *savedBattleTypeFlags;
gMain.savedCallback = *savedCallback;

View File

@ -1093,7 +1093,7 @@ static void sub_80B37FC(u8 taskId)
case 3:
if (!gReceivedRemoteLinkPlayers)
{
SetMainCallback2(sub_80773AC);
SetMainCallback2(CB2_StartCreateTradeMenu);
DestroyTask(taskId);
}
break;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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